mapbox-gl 2.10.0-beta.1 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -6
- package/dist/mapbox-gl-csp-worker.js +1 -1
- package/dist/mapbox-gl-csp-worker.js.map +1 -1
- package/dist/mapbox-gl-csp.js +1 -1
- package/dist/mapbox-gl-csp.js.map +1 -1
- package/dist/mapbox-gl-dev.js +1 -1
- package/dist/mapbox-gl-unminified.js +1 -1
- package/dist/mapbox-gl.js +1 -1
- package/dist/mapbox-gl.js.map +1 -1
- package/package.json +1 -1
- package/src/style-spec/CHANGELOG.md +9 -0
- package/src/style-spec/package.json +1 -1
package/dist/mapbox-gl-csp.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).mapboxgl=t()}(this,(function(){"use strict";var e="undefined"!=typeof self?self:{},t=i;function i(e,t,i,r){this.cx=3*e,this.bx=3*(i-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(r-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=r,this.p2x=i,this.p2y=r}i.prototype.sampleCurveX=function(e){return((this.ax*e+this.bx)*e+this.cx)*e},i.prototype.sampleCurveY=function(e){return((this.ay*e+this.by)*e+this.cy)*e},i.prototype.sampleCurveDerivativeX=function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},i.prototype.solveCurveX=function(e,t){var i,r,n,o,a;for(void 0===t&&(t=1e-6),n=e,a=0;a<8;a++){if(o=this.sampleCurveX(n)-e,Math.abs(o)<t)return n;var s=this.sampleCurveDerivativeX(n);if(Math.abs(s)<1e-6)break;n-=o/s}if((n=e)<(i=0))return i;if(n>(r=1))return r;for(;i<r;){if(o=this.sampleCurveX(n),Math.abs(o-e)<t)return n;e>o?i=n:r=n,n=.5*(r-i)+i}return n},i.prototype.solve=function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))};var r=n;function n(e,t){this.x=e,this.y=t}function o(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!o(e[i],t[i]))return!1;return!0}if("object"==typeof e&&null!==e&&null!==t){if("object"!=typeof t)return!1;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const i in e)if(!o(e[i],t[i]))return!1;return!0}return e===t}n.prototype={clone:function(){return new n(this.x,this.y)},add:function(e){return this.clone()._add(e)},sub:function(e){return this.clone()._sub(e)},multByPoint:function(e){return this.clone()._multByPoint(e)},divByPoint:function(e){return this.clone()._divByPoint(e)},mult:function(e){return this.clone()._mult(e)},div:function(e){return this.clone()._div(e)},rotate:function(e){return this.clone()._rotate(e)},rotateAround:function(e,t){return this.clone()._rotateAround(e,t)},matMult:function(e){return this.clone()._matMult(e)},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(e){return this.x===e.x&&this.y===e.y},dist:function(e){return Math.sqrt(this.distSqr(e))},distSqr:function(e){var t=e.x-this.x,i=e.y-this.y;return t*t+i*i},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith:function(e){return this.angleWithSep(e.x,e.y)},angleWithSep:function(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult:function(e){var t=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=t,this},_add:function(e){return this.x+=e.x,this.y+=e.y,this},_sub:function(e){return this.x-=e.x,this.y-=e.y,this},_mult:function(e){return this.x*=e,this.y*=e,this},_div:function(e){return this.x/=e,this.y/=e,this},_multByPoint:function(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint:function(e){return this.x/=e.x,this.y/=e.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var e=this.y;return this.y=this.x,this.x=-e,this},_rotate:function(e){var t=Math.cos(e),i=Math.sin(e),r=i*this.x+t*this.y;return this.x=t*this.x-i*this.y,this.y=r,this},_rotateAround:function(e,t){var i=Math.cos(e),r=Math.sin(e),n=t.y+r*(this.x-t.x)+i*(this.y-t.y);return this.x=t.x+i*(this.x-t.x)-r*(this.y-t.y),this.y=n,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},n.convert=function(e){return e instanceof n?e:Array.isArray(e)?new n(e[0],e[1]):e};const a=Math.PI/180,s=180/Math.PI;function l(e){return e*a}function c(e){return e*s}const u=[[0,0],[1,0],[1,1],[0,1]];function h(e){if(e<=0)return 0;if(e>=1)return 1;const t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}function p(e){let t=1/0,i=1/0,n=-1/0,o=-1/0;for(const r of e)t=Math.min(t,r.x),i=Math.min(i,r.y),n=Math.max(n,r.x),o=Math.max(o,r.y);return{min:new r(t,i),max:new r(n,o)}}function d(e,t,i=0,n=!0){const o=new r(i,i),a=e.sub(o),s=t.add(o),l=[a,new r(s.x,a.y),s,new r(a.x,s.y)];return n&&l.push(a.clone()),l}function f(e,i,r,n){const o=new t(e,i,r,n);return function(e){return o.solve(e)}}const m=f(.25,.1,.25,1);function _(e,t,i){return Math.min(i,Math.max(t,e))}function g(e,t,i){return(i=_((i-e)/(t-e),0,1))*i*(3-2*i)}function y(e,t,i){const r=i-t,n=((e-t)%r+r)%r+t;return n===t?i:n}function x(e,t,i){if(!e.length)return i(null,[]);let r=e.length;const n=new Array(e.length);let o=null;e.forEach(((e,a)=>{t(e,((e,t)=>{e&&(o=e),n[a]=t,0==--r&&i(o,n)}))}))}function v(e){const t=[];for(const i in e)t.push(e[i]);return t}function b(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}function w(e,t){const i={};for(let r=0;r<t.length;r++){const n=t[r];n in e&&(i[n]=e[n])}return i}let T=1;function E(){return T++}function S(){return function e(t){return t?(t^Math.random()*(16>>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()}function A(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function C(e){return!!e&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}function I(e,t){e.forEach((e=>{t[e]&&(t[e]=t[e].bind(t))}))}function M(e,t){return-1!==e.indexOf(t,e.length-t.length)}function P(e,t,i){const r={};for(const n in e)r[n]=t.call(i||this,e[n],n,e);return r}function D(e,t,i){const r={};for(const n in e)t.call(i||this,e[n],n,e)&&(r[n]=e[n]);return r}function z(e){return Array.isArray(e)?e.map(z):"object"==typeof e&&e?P(e,z):e}function k(e,t,i,r,n){return _((e-t)/(i-t)*(n-r)+r,r,n)}const L={};function B(e){L[e]||("undefined"!=typeof console&&console.warn(e),L[e]=!0)}function R(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function F(e){let t=0;for(let i,r,n=0,o=e.length,a=o-1;n<o;a=n++)i=e[n],r=e[a],t+=(r.x-i.x)*(i.y+r.y);return t}function O(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}function V(e){const t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,i,r,n)=>{const o=r||n;return t[i]=!o||o.toLowerCase(),""})),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e}return t}let U=null;function j(e){if(null==U){const t=e.navigator?e.navigator.userAgent:null;U=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return U}function N(){return!!e.document.fullscreenElement||!!e.document.webkitFullscreenElement}function G(t){try{const i=e[t];return i.setItem("_mapbox_test_",1),i.removeItem("_mapbox_test_"),!0}catch(e){return!1}}function Z(e,t){return[e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}function q(e,t,i){e[4*t+0]=i[0],e[4*t+1]=i[1],e[4*t+2]=i[2],e[4*t+3]=i[3]}var $=W;function W(e){return!function(e){return"undefined"==typeof window||"undefined"==typeof document?"not a browser":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 e,t,i=new Blob([""],{type:"text/javascript"}),r=URL.createObjectURL(i);try{t=new Worker(r),e=!0}catch(t){e=!1}return t&&t.terminate(),URL.revokeObjectURL(r),e}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var e=document.createElement("canvas");e.width=e.height=1;var t=e.getContext("2d");if(!t)return!1;var i=t.getImageData(0,0,1,1);return i&&i.width===e.width}()?(void 0===H[t=e&&e.failIfMajorPerformanceCaveat]&&(H[t]=function(e){var t,i=function(e){var t=document.createElement("canvas"),i=Object.create(W.webGLContextAttributes);return i.failIfMajorPerformanceCaveat=e,t.getContext("webgl",i)||t.getContext("experimental-webgl",i)}(e);if(!i)return!1;try{t=i.createShader(i.VERTEX_SHADER)}catch(e){return!1}return!(!t||i.isContextLost())&&(i.shaderSource(t,"void main() {}"),i.compileShader(t),!0===i.getShaderParameter(t,i.COMPILE_STATUS))}(t)),H[t]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var t}(e)}var H={};W.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};var X="2.10.0-beta.1";let K,J,Y,Q;const ee={now:()=>void 0!==Y?Y:e.performance.now(),setNow(e){Y=e},restoreNow(){Y=void 0},frame(t){const i=e.requestAnimationFrame(t);return{cancel:()=>e.cancelAnimationFrame(i)}},getImageData(t,i=0){const{width:r,height:n}=t;Q||(Q=e.document.createElement("canvas"));const o=Q.getContext("2d");if(!o)throw new Error("failed to create canvas 2d context");return(r>Q.width||n>Q.height)&&(Q.width=r,Q.height=n),o.clearRect(-i,-i,r+2*i,n+2*i),o.drawImage(t,0,0,r,n),o.getImageData(-i,-i,r+2*i,n+2*i)},resolveURL:t=>(K||(K=e.document.createElement("a")),K.href=t,K.href),get devicePixelRatio(){return e.devicePixelRatio},get prefersReducedMotion(){return!!e.matchMedia&&(null==J&&(J=e.matchMedia("(prefers-reduced-motion: reduce)")),J.matches)}};function te(t,i,r){const n=e.document.createElement(t);return void 0!==i&&(n.className=i),r&&r.appendChild(n),n}function ie(t,i,r){const n=e.document.createElementNS("http://www.w3.org/2000/svg",t);for(const e of Object.keys(i))n.setAttributeNS(null,e,i[e]);return r&&r.appendChild(n),n}const re=e.document&&e.document.documentElement.style,ne=re&&void 0!==re.userSelect?"userSelect":"WebkitUserSelect";let oe,ae;function se(){re&&ne&&(oe=re[ne],re[ne]="none")}function le(){re&&ne&&(re[ne]=oe)}function ce(t){t.preventDefault(),t.stopPropagation(),e.removeEventListener("click",ce,!0)}function ue(){e.addEventListener("click",ce,!0),e.setTimeout((()=>{e.removeEventListener("click",ce,!0)}),0)}function he(e,t){const i=e.getBoundingClientRect();return fe(e,i,t)}function pe(e,t){const i=e.getBoundingClientRect(),r=[];for(let n=0;n<t.length;n++)r.push(fe(e,i,t[n]));return r}function de(t){return void 0!==e.InstallTrigger&&2===t.button&&t.ctrlKey&&e.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:t.button}function fe(e,t,i){const n=e.offsetWidth===t.width?1:e.offsetWidth/t.width;return new r((i.clientX-t.left)*n,(i.clientY-t.top)*n)}const me={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==ae){const e=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{ae=null!=process.env.API_URL_REGEX?new RegExp(process.env.API_URL_REGEX):e}catch(t){ae=e}}return ae},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},_e={supported:!1,testSupport:function(e){!xe&&ye&&(ve?be(e):ge=e)}};let ge,ye,xe=!1,ve=!1;function be(e){const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);try{if(e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,ye),e.isContextLost())return;_e.supported=!0}catch(e){}e.deleteTexture(t),xe=!0}e.document&&(ye=e.document.createElement("img"),ye.onload=function(){ge&&be(ge),ge=null,ve=!0},ye.onerror=function(){xe=!0,ge=null},ye.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const we="01",Te="NO_ACCESS_TOKEN";class RequestManager{constructor(e,t,i){this._transformRequestFn=e,this._customAccessToken=t,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const e=function(){let e="";for(let t=0;t<10;t++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",we,e].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=e.token,this._skuTokenExpiresAt=e.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(e,t){if(!Ee(e))return e;const i=Ce(e);return i.path=`/styles/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeGlyphsURL(e,t){if(!Ee(e))return e;const i=Ce(e);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeSourceURL(e,t,i,r){if(!Ee(e))return e;const n=Ce(e);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),i&&n.params.push(`language=${i}`),r&&n.params.push(`worldview=${r}`),this._makeAPIURL(n,this._customAccessToken||t)}normalizeSpriteURL(e,t,i,r){const n=Ce(e);return Ee(e)?(n.path=`/styles/v1${n.path}/sprite${t}${i}`,this._makeAPIURL(n,this._customAccessToken||r)):(n.path+=`${t}${i}`,Ie(n))}normalizeTileURL(e,t,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),e&&!Ee(e))return e;const r=Ce(e);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${t||i&&"raster"!==r.authority&&512===i?"@2x":""}${_e.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${me.RASTER_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${me.TILE_URL_VERSION}${r.path}`);const n=this._customAccessToken||function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null}(r.params)||me.ACCESS_TOKEN;return me.REQUIRE_ACCESS_TOKEN&&n&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,n)}canonicalizeTileURL(e,t){const i=Ce(e);if(!i.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!i.path.match(/\.[\w]+$/))return e;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${me.RASTER_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${me.TILE_URL_VERSION}/`,"")}`;let n=i.params;return t&&(n=n.filter((e=>!e.match(/^access_token=/)))),n.length&&(r+=`?${n.join("&")}`),r}canonicalizeTileset(e,t){const i=!!t&&Ee(t),r=[];for(const t of e.tiles||[])Se(t)?r.push(this.canonicalizeTileURL(t,i)):r.push(t);return r}_makeAPIURL(e,t){const i="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",r=Ce(me.API_URL);if(e.protocol=r.protocol,e.authority=r.authority,"http"===e.protocol){const t=e.params.indexOf("secure");t>=0&&e.params.splice(t,1)}if("/"!==r.path&&(e.path=`${r.path}${e.path}`),!me.REQUIRE_ACCESS_TOKEN)return Ie(e);if(t=t||me.ACCESS_TOKEN,!this._silenceAuthErrors){if(!t)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===t[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return e.params=e.params.filter((e=>-1===e.indexOf("access_token"))),e.params.push(`access_token=${t||""}`),Ie(e)}}function Ee(e){return 0===e.indexOf("mapbox:")}function Se(e){return me.API_URL_REGEX.test(e)}const Ae=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Ce(e){const t=e.match(Ae);if(!t)throw new Error("Unable to parse URL object");return{protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function Ie(e){const t=e.params.length?`?${e.params.join("&")}`:"";return`${e.protocol}://${e.authority}${e.path}${t}`}function Me(t){if(!t)return null;const i=t.split(".");if(!i||3!==i.length)return null;try{return JSON.parse(decodeURIComponent(e.atob(i[1]).split("").map((e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2))).join("")))}catch(e){return null}}class TelemetryEvent{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(t){const i=Me(me.ACCESS_TOKEN);let r="";return r=i&&i.u?e.btoa(encodeURIComponent(i.u).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(Number("0x"+t))))):me.ACCESS_TOKEN||"",t?`mapbox.eventData.${t}:${r}`:`mapbox.eventData:${r}`}fetchEventData(){const t=G("localStorage"),i=this.getStorageKey(),r=this.getStorageKey("uuid");if(t)try{const t=e.localStorage.getItem(i);t&&(this.eventData=JSON.parse(t));const n=e.localStorage.getItem(r);n&&(this.anonId=n)}catch(e){B("Unable to read from LocalStorage")}}saveEventData(){const t=G("localStorage"),i=this.getStorageKey(),r=this.getStorageKey("uuid");if(t)try{e.localStorage.setItem(r,this.anonId),Object.keys(this.eventData).length>=1&&e.localStorage.setItem(i,JSON.stringify(this.eventData))}catch(e){B("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,t,i,r){if(!me.EVENTS_URL)return;const n=Ce(me.EVENTS_URL);n.params.push(`access_token=${r||me.ACCESS_TOKEN||""}`);const o={event:this.type,created:new Date(e).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:X,skuId:we,userId:this.anonId},a=t?b(o,t):o,s={url:Ie(n),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=et(s,(e=>{this.pendingRequest=null,i(e),this.saveEventData(),this.processRequests(r)}))}queueRequest(e,t){this.queue.push(e),this.processRequests(t)}}const Pe=new class TurnstileEvent extends TelemetryEvent{constructor(e){super("appUserTurnstile"),this._customAccessToken=e}postTurnstileEvent(e,t){me.EVENTS_URL&&me.ACCESS_TOKEN&&Array.isArray(e)&&e.some((e=>Ee(e)||Se(e)))&&this.queueRequest(Date.now(),t)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const t=Me(me.ACCESS_TOKEN),i=t?t.u:me.ACCESS_TOKEN;let r=i!==this.eventData.tokenU;C(this.anonId)||(this.anonId=S(),r=!0);const n=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(n),i=(n-this.eventData.lastSuccess)/864e5;r=r||i>=1||i<-1||e.getDate()!==t.getDate()}else r=!0;r?this.postEvent(n,{"enabled.telemetry":!1},(e=>{e||(this.eventData.lastSuccess=n,this.eventData.tokenU=i)}),e):this.processRequests()}},De=Pe.postTurnstileEvent.bind(Pe),ze=new class MapLoadEvent extends TelemetryEvent{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(e,t,i,r){this.skuToken=t,this.errorCb=r,me.EVENTS_URL&&(i||me.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(Te)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:i}=this.queue.shift();t&&this.success[t]||(this.anonId||this.fetchEventData(),C(this.anonId)||(this.anonId=S()),this.postEvent(i,{skuToken:this.skuToken},(e=>{e?this.errorCb(e):t&&(this.success[t]=!0)}),e))}},ke=ze.postMapLoadEvent.bind(ze),Le=new class MapSessionAPI extends TelemetryEvent{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,t,i,r){if(!me.API_URL||!me.SESSION_PATH)return;const n=Ce(me.API_URL+me.SESSION_PATH);n.params.push(`sku=${t||""}`),n.params.push(`access_token=${r||me.ACCESS_TOKEN||""}`);const o={url:Ie(n),headers:{"Content-Type":"text/plain"}};this.pendingRequest=tt(o,(e=>{this.pendingRequest=null,i(e),this.saveEventData(),this.processRequests(r)}))}getSessionAPI(e,t,i,r){this.skuToken=t,this.errorCb=r,me.SESSION_PATH&&me.API_URL&&(i||me.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(Te)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:i}=this.queue.shift();t&&this.success[t]||this.getSession(i,this.skuToken,(e=>{e?this.errorCb(e):t&&(this.success[t]=!0)}),e)}},Be=Le.getSessionAPI.bind(Le),Re=new Set;function Fe(e,t){t?Re.add(e):Re.delete(e)}let Oe,Ve=500,Ue=50,je={};function Ne(e){const t=qe(e);let i,r;t&&t.forEach((e=>{const t=e.split("=");"language"===t[0]?i=t[1]:"worldview"===t[0]&&(r=t[1])}));let n="mapbox-tiles";return i&&(n+=`-${i}`),r&&(n+=`-${r}`),n}function Ge(){try{return e.caches}catch(e){}}function Ze(e){const t=Ge();t&&!je[e]&&(je[e]=t.open(e))}function qe(e){const t=e.indexOf("?");return t>0?e.slice(t+1).split("&"):[]}function $e(e){const t=e.indexOf("?");if(t<0)return e;const i=qe(e).filter((e=>{const t=e.split("=");return"language"===t[0]||"worldview"===t[0]}));return i.length?`${e.slice(0,t)}?${i.join("&")}`:e.slice(0,t)}let We=1/0;function He(e){We++,We>Ue&&(e.getActor().send("enforceCacheSizeLimit",Ve),We=0)}const Xe={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(Xe);class AJAXError extends Error{constructor(e,t,i){401===t&&Se(i)&&(e+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(e),this.status=t,this.url=i}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const Ke=O()?()=>self.worker&&self.worker.referrer:()=>("blob:"===e.location.protocol?e.parent:e).location.href;const Je=function(t,i){if(!(/^file:/.test(r=t.url)||/^file:/.test(Ke())&&!/^\w+:/.test(r))){if(e.fetch&&e.Request&&e.AbortController&&e.Request.prototype.hasOwnProperty("signal"))return function(t,i){const r=new e.AbortController,n=new e.Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:Ke(),signal:r.signal});let o=!1,a=!1;const s=(l=n.url).indexOf("sku=")>0&&Se(l);var l;"json"===t.type&&n.headers.set("Accept","application/json");const c=(r,o,l)=>{if(a)return;if(r&&"SecurityError"!==r.message&&B(r),o&&l)return u(o);const c=Date.now();e.fetch(n).then((e=>{if(e.ok){const t=s?e.clone():null;return u(e,t,c)}return i(new AJAXError(e.statusText,e.status,t.url))})).catch((e=>{20!==e.code&&i(new Error(e.message))}))},u=(r,s,l)=>{("arrayBuffer"===t.type?r.arrayBuffer():"json"===t.type?r.json():r.text()).then((t=>{a||(s&&l&&function(t,i,r){const n=Ne(t.url);if(Ze(n),!je[n])return;const o={status:i.status,statusText:i.statusText,headers:new e.Headers};i.headers.forEach(((e,t)=>o.headers.set(t,e)));const a=V(i.headers.get("Cache-Control")||"");if(a["no-store"])return;a["max-age"]&&o.headers.set("Expires",new Date(r+1e3*a["max-age"]).toUTCString());const s=o.headers.get("Expires");s&&(new Date(s).getTime()-r<42e4||function(e,t){if(void 0===Oe)try{new Response(new ReadableStream),Oe=!0}catch(e){Oe=!1}Oe?t(e.body):e.blob().then(t)}(i,(i=>{const r=new e.Response(i,o);Ze(n),je[n]&&je[n].then((e=>e.put($e(t.url),r))).catch((e=>B(e.message)))})))}(n,s,l),o=!0,i(null,t,r.headers.get("Cache-Control"),r.headers.get("Expires")))})).catch((e=>{a||i(new Error(e.message))}))};return s?function(e,t){const i=Ne(e.url);if(Ze(i),!je[i])return t(null);const r=$e(e.url);je[i].then((e=>{e.match(r).then((i=>{const n=function(e){if(!e)return!1;const t=new Date(e.headers.get("Expires")||0),i=V(e.headers.get("Cache-Control")||"");return t>Date.now()&&!i["no-cache"]}(i);e.delete(r),n&&e.put(r,i.clone()),t(null,i,n)})).catch(t)})).catch(t)}(n,c):c(null,null),{cancel:()=>{a=!0,o||r.abort()}}}(t,i);if(O()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,i,void 0,!0)}var r;return function(t,i){const r=new e.XMLHttpRequest;r.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(r.responseType="arraybuffer");for(const e in t.headers)r.setRequestHeader(e,t.headers[e]);return"json"===t.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===t.credentials,r.onerror=()=>{i(new Error(r.statusText))},r.onload=()=>{if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){let e=r.response;if("json"===t.type)try{e=JSON.parse(r.response)}catch(e){return i(e)}i(null,e,r.getResponseHeader("Cache-Control"),r.getResponseHeader("Expires"))}else i(new AJAXError(r.statusText,r.status,t.url))},r.send(t.body),{cancel:()=>r.abort()}}(t,i)},Ye=function(e,t){return Je(b(e,{type:"json"}),t)},Qe=function(e,t){return Je(b(e,{type:"arrayBuffer"}),t)},et=function(e,t){return Je(b(e,{method:"POST"}),t)},tt=function(e,t){return Je(b(e,{method:"GET"}),t)};function it(t){const i=e.document.createElement("a");return i.href=t,i.protocol===e.document.location.protocol&&i.host===e.document.location.host}const rt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let nt,ot;nt=[],ot=0;const at=function(t,i){if(_e.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),ot>=me.MAX_PARALLEL_IMAGE_REQUESTS){const e={requestParameters:t,callback:i,cancelled:!1,cancel(){this.cancelled=!0}};return nt.push(e),e}ot++;let r=!1;const n=()=>{if(!r)for(r=!0,ot--;nt.length&&ot<me.MAX_PARALLEL_IMAGE_REQUESTS;){const e=nt.shift(),{requestParameters:t,callback:i,cancelled:r}=e;r||(e.cancel=at(t,i).cancel)}},o=Qe(t,((t,r,o,a)=>{n(),t?i(t):r&&(e.createImageBitmap?function(t,i){const r=new e.Blob([new Uint8Array(t)],{type:"image/png"});e.createImageBitmap(r).then((e=>{i(null,e)})).catch((e=>{i(new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))}))}(r,((e,t)=>i(e,t,o,a))):function(t,i){const r=new e.Image,n=e.URL;r.onload=()=>{i(null,r),n.revokeObjectURL(r.src),r.onload=null,e.requestAnimationFrame((()=>{r.src=rt}))},r.onerror=()=>i(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 o=new e.Blob([new Uint8Array(t)],{type:"image/png"});r.src=t.byteLength?n.createObjectURL(o):rt}(r,((e,t)=>i(e,t,o,a))))}));return{cancel:()=>{o.cancel(),n()}}};function st(e,t,i){i[e]&&-1!==i[e].indexOf(t)||(i[e]=i[e]||[],i[e].push(t))}function lt(e,t,i){if(i&&i[e]){const r=i[e].indexOf(t);-1!==r&&i[e].splice(r,1)}}class Event{constructor(e,t={}){b(this,t),this.type=e}}class ErrorEvent extends Event{constructor(e,t={}){super("error",b({error:e},t))}}class Evented{on(e,t){return this._listeners=this._listeners||{},st(e,t,this._listeners),this}off(e,t){return lt(e,t,this._listeners),lt(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},st(e,t,this._oneTimeListeners),this):new Promise((t=>this.once(e,t)))}fire(e,t){"string"==typeof e&&(e=new Event(e,t||{}));const i=e.type;if(this.listens(i)){e.target=this;const t=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of t)i.call(this,e);const r=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const t of r)lt(i,t,this._oneTimeListeners),t.call(this,e);const n=this._eventedParent;n&&(b(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),n.fire(e))}else e instanceof ErrorEvent&&console.error(e.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}var ct=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"},"fill-extrusion-edge-radius":{"type":"number","private":true,"default":0,"minimum":0,"maximum":1,"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},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"star-intensity":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"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":{},"globe":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90],"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,"requires":["source"]}},"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"},"fill-extrusion-ambient-occlusion-intensity":{"property-type":"data-constant","type":"number","private":true,"default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant","type":"number","private":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"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"},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"transition":false,"requires":[{"source":"geojson","has":{"lineMetrics":true}}],"property-type":"constant"}},"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"}}}');function ut(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}function ht(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function pt(e){if(Array.isArray(e))return e.map(pt);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const i in e)t[i]=pt(e[i]);return t}return ht(e)}class ParsingError extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}var dt=ParsingError;class Scope{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,i]of t)this.bindings[e]=i}concat(e){return new Scope(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}var ft=Scope;const mt={kind:"null"},_t={kind:"number"},gt={kind:"string"},yt={kind:"boolean"},xt={kind:"color"},vt={kind:"object"},bt={kind:"value"},wt={kind:"collator"},Tt={kind:"formatted"},Et={kind:"resolvedImage"};function St(e,t){return{kind:"array",itemType:e,N:t}}function Ct(e){if("array"===e.kind){const t=Ct(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const It=[mt,_t,gt,yt,xt,Tt,vt,St(bt),Et];function Mt(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!Mt(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if("value"===e.kind)for(const e of It)if(!Mt(e,t))return null}return`Expected ${Ct(e)} but found ${Ct(t)} instead.`}function Pt(e,t){return t.some((t=>t.kind===e.kind))}function Dt(e,t){return t.some((t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e))}function zt(e){var t={exports:{}};return e(t,t.exports),t.exports}var kt=zt((function(e,t){var i={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 r(e){return(e=Math.round(e))<0?0:e>255?255:e}function n(e){return r("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function o(e){return(t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t}function a(e,t,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?e+(t-e)*i*6:2*i<1?t:3*i<2?e+(t-e)*(2/3-i)*6:e}try{t.parseCSSColor=function(e){var t,s=e.replace(/ /g,"").toLowerCase();if(s in i)return i[s].slice();if("#"===s[0])return 4===s.length?(t=parseInt(s.substr(1),16))>=0&&t<=4095?[(3840&t)>>4|(3840&t)>>8,240&t|(240&t)>>4,15&t|(15&t)<<4,1]:null:7===s.length&&(t=parseInt(s.substr(1),16))>=0&&t<=16777215?[(16711680&t)>>16,(65280&t)>>8,255&t,1]:null;var l=s.indexOf("("),c=s.indexOf(")");if(-1!==l&&c+1===s.length){var u=s.substr(0,l),h=s.substr(l+1,c-(l+1)).split(","),p=1;switch(u){case"rgba":if(4!==h.length)return null;p=o(h.pop());case"rgb":return 3!==h.length?null:[n(h[0]),n(h[1]),n(h[2]),p];case"hsla":if(4!==h.length)return null;p=o(h.pop());case"hsl":if(3!==h.length)return null;var d=(parseFloat(h[0])%360+360)%360/360,f=o(h[1]),m=o(h[2]),_=m<=.5?m*(f+1):m+f-m*f,g=2*m-_;return[r(255*a(g,_,d+1/3)),r(255*a(g,_,d)),r(255*a(g,_,d-1/3)),p];default:return null}}return null}}catch(e){}}));class Color{constructor(e,t,i,r=1){this.r=e,this.g=t,this.b=i,this.a=r}static parse(e){if(!e)return;if(e instanceof Color)return e;if("string"!=typeof e)return;const t=kt.parseCSSColor(e);return t?new Color(t[0]/255*t[3],t[1]/255*t[3],t[2]/255*t[3],t[3]):void 0}toString(){const[e,t,i,r]=this.toArray();return`rgba(${Math.round(e)},${Math.round(t)},${Math.round(i)},${r})`}toArray(){const{r:e,g:t,b:i,a:r}=this;return 0===r?[0,0,0,0]:[255*e/r,255*t/r,255*i/r,r]}toArray01(){const{r:e,g:t,b:i,a:r}=this;return 0===r?[0,0,0,0]:[e/r,t/r,i/r,r]}toArray01PremultipliedAlpha(){const{r:e,g:t,b:i,a:r}=this;return[e,t,i,r]}}Color.black=new Color(0,0,0,1),Color.white=new Color(1,1,1,1),Color.transparent=new Color(0,0,0,0),Color.red=new Color(1,0,0,1),Color.blue=new Color(0,0,1,1);var Lt=Color;class Collator{constructor(e,t,i){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class FormattedSection{constructor(e,t,i,r,n){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=i,this.fontStack=r,this.textColor=n}}class Formatted{constructor(e){this.sections=e}static fromString(e){return new Formatted([new FormattedSection(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((e=>0!==e.text.length||e.image&&0!==e.image.name.length))}static factory(e){return e instanceof Formatted?e:Formatted.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map((e=>e.text)).join("")}serialize(){const e=["format"];for(const t of this.sections){if(t.image){e.push(["image",t.image.name]);continue}e.push(t.text);const i={};t.fontStack&&(i["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(i["font-scale"]=t.scale),t.textColor&&(i["text-color"]=["rgba"].concat(t.textColor.toArray())),e.push(i)}return e}}class ResolvedImage{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new ResolvedImage({name:e,available:!1}):null}serialize(){return["image",this.name]}}function Bt(e,t,i,r){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Rt(e){if(null===e)return!0;if("string"==typeof e)return!0;if("boolean"==typeof e)return!0;if("number"==typeof e)return!0;if(e instanceof Lt)return!0;if(e instanceof Collator)return!0;if(e instanceof Formatted)return!0;if(e instanceof ResolvedImage)return!0;if(Array.isArray(e)){for(const t of e)if(!Rt(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!Rt(e[t]))return!1;return!0}return!1}function Ft(e){if(null===e)return mt;if("string"==typeof e)return gt;if("boolean"==typeof e)return yt;if("number"==typeof e)return _t;if(e instanceof Lt)return xt;if(e instanceof Collator)return wt;if(e instanceof Formatted)return Tt;if(e instanceof ResolvedImage)return Et;if(Array.isArray(e)){const t=e.length;let i;for(const t of e){const e=Ft(t);if(i){if(i===e)continue;i=bt;break}i=e}return St(i||bt,t)}return vt}function Ot(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Lt||e instanceof Formatted||e instanceof ResolvedImage?e.toString():JSON.stringify(e)}class Literal{constructor(e,t){this.type=e,this.value=t}static parse(e,t){if(2!==e.length)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Rt(e[1]))return t.error("invalid value");const i=e[1];let r=Ft(i);const n=t.expectedType;return"array"!==r.kind||0!==r.N||!n||"array"!==n.kind||"number"==typeof n.N&&0!==n.N||(r=n),new Literal(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof Lt?["rgba"].concat(this.value.toArray()):this.value instanceof Formatted?this.value.serialize():this.value}}var Vt=Literal,Ut=class RuntimeError{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}};const jt={string:gt,number:_t,boolean:yt,object:vt};class Assertion{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let i,r=1;const n=e[0];if("array"===n){let n,o;if(e.length>2){const i=e[1];if("string"!=typeof i||!(i in jt)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);n=jt[i],r++}else n=bt;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);o=e[2],r++}i=St(n,o)}else i=jt[n];const o=[];for(;r<e.length;r++){const i=t.parse(e[r],r,bt);if(!i)return null;o.push(i)}return new Assertion(i,o)}evaluate(e){for(let t=0;t<this.args.length;t++){const i=this.args[t].evaluate(e);if(!Mt(this.type,Ft(i)))return i;if(t===this.args.length-1)throw new Ut(`Expected value to be of type ${Ct(this.type)}, but found ${Ct(Ft(i))} instead.`)}return null}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){const e=this.type,t=[e.kind];if("array"===e.kind){const i=e.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){t.push(i.kind);const r=e.N;("number"==typeof r||this.args.length>1)&&t.push(r)}}return t.concat(this.args.map((e=>e.serialize())))}}var Nt=Assertion;class FormatExpression{constructor(e){this.type=Tt,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[1];if(!Array.isArray(i)&&"object"==typeof i)return t.error("First argument must be an image or text section.");const r=[];let n=!1;for(let i=1;i<=e.length-1;++i){const o=e[i];if(n&&"object"==typeof o&&!Array.isArray(o)){n=!1;let e=null;if(o["font-scale"]&&(e=t.parse(o["font-scale"],1,_t),!e))return null;let i=null;if(o["text-font"]&&(i=t.parse(o["text-font"],1,St(gt)),!i))return null;let a=null;if(o["text-color"]&&(a=t.parse(o["text-color"],1,xt),!a))return null;const s=r[r.length-1];s.scale=e,s.font=i,s.textColor=a}else{const o=t.parse(e[i],1,bt);if(!o)return null;const a=o.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,r.push({content:o,scale:null,font:null,textColor:null})}}return new FormatExpression(r)}evaluate(e){return new Formatted(this.sections.map((t=>{const i=t.content.evaluate(e);return Ft(i)===Et?new FormattedSection("",i,null,null,null):new FormattedSection(Ot(i),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null)})))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const t of this.sections){e.push(t.content.serialize());const i={};t.scale&&(i["font-scale"]=t.scale.serialize()),t.font&&(i["text-font"]=t.font.serialize()),t.textColor&&(i["text-color"]=t.textColor.serialize()),e.push(i)}return e}}class ImageExpression{constructor(e){this.type=Et,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,gt);return i?new ImageExpression(i):t.error("No image name provided.")}evaluate(e){const t=this.input.evaluate(e),i=ResolvedImage.fromString(t);return i&&e.availableImages&&(i.available=e.availableImages.indexOf(t)>-1),i}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const Gt={"to-boolean":yt,"to-color":xt,"to-number":_t,"to-string":gt};class Coercion{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[0];if(("to-boolean"===i||"to-string"===i)&&2!==e.length)return t.error("Expected one argument.");const r=Gt[i],n=[];for(let i=1;i<e.length;i++){const r=t.parse(e[i],i,bt);if(!r)return null;n.push(r)}return new Coercion(r,n)}evaluate(e){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(e));if("color"===this.type.kind){let t,i;for(const r of this.args){if(t=r.evaluate(e),i=null,t instanceof Lt)return t;if("string"==typeof t){const i=e.parseColor(t);if(i)return i}else if(Array.isArray(t)&&(i=t.length<3||t.length>4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Bt(t[0],t[1],t[2],t[3]),!i))return new Lt(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Ut(i||`Could not parse color from value '${"string"==typeof t?t:String(JSON.stringify(t))}'`)}if("number"===this.type.kind){let t=null;for(const i of this.args){if(t=i.evaluate(e),null===t)return 0;const r=Number(t);if(!isNaN(r))return r}throw new Ut(`Could not convert ${JSON.stringify(t)} to number.`)}return"formatted"===this.type.kind?Formatted.fromString(Ot(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?ResolvedImage.fromString(Ot(this.args[0].evaluate(e))):Ot(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new FormatExpression([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new ImageExpression(this.args[0]).serialize();const e=[`to-${this.type.kind}`];return this.eachChild((t=>{e.push(t.serialize())})),e}}var Zt=Coercion;const qt=["Unknown","Point","LineString","Polygon"];var $t=class EvaluationContext{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&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?qt[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 e=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:i,y:r}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*t-e[0])+this.featureDistanceData.bearing[1]*(r*t-e[1])}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=Lt.parse(e)),t}};class CompoundExpression{constructor(e,t,i,r){this.name=e,this.type=t,this._evaluate=i,this.args=r}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((e=>e.serialize())))}static parse(e,t){const i=e[0],r=CompoundExpression.definitions[i];if(!r)return t.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const n=Array.isArray(r)?r[0]:r.type,o=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,a=o.filter((([t])=>!Array.isArray(t)||t.length===e.length-1));let s=null;for(const[r,o]of a){s=new mi(t.registry,t.path,null,t.scope);const a=[];let l=!1;for(let t=1;t<e.length;t++){const i=e[t],n=Array.isArray(r)?r[t-1]:r.type,o=s.parse(i,1+a.length,n);if(!o){l=!0;break}a.push(o)}if(!l)if(Array.isArray(r)&&r.length!==a.length)s.error(`Expected ${r.length} arguments, but found ${a.length} instead.`);else{for(let e=0;e<a.length;e++){const t=Array.isArray(r)?r[e]:r.type,i=a[e];s.concat(e+1).checkSubtype(t,i.type)}if(0===s.errors.length)return new CompoundExpression(i,n,o,a)}}if(1===a.length)t.errors.push(...s.errors);else{const i=(a.length?a:o).map((([e])=>{return t=e,Array.isArray(t)?`(${t.map(Ct).join(", ")})`:`(${Ct(t.type)}...)`;var t})).join(" | "),r=[];for(let i=1;i<e.length;i++){const n=t.parse(e[i],1+r.length);if(!n)return null;r.push(Ct(n.type))}t.error(`Expected arguments of type ${i}, but found (${r.join(", ")}) instead.`)}return null}static register(e,t){CompoundExpression.definitions=t;for(const i in t)e[i]=CompoundExpression}}var Wt=CompoundExpression;class CollatorExpression{constructor(e,t,i){this.type=wt,this.locale=i,this.caseSensitive=e,this.diacriticSensitive=t}static parse(e,t){if(2!==e.length)return t.error("Expected one argument.");const i=e[1];if("object"!=typeof i||Array.isArray(i))return t.error("Collator options argument must be an object.");const r=t.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,yt);if(!r)return null;const n=t.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,yt);if(!n)return null;let o=null;return i.locale&&(o=t.parse(i.locale,1,gt),!o)?null:new CollatorExpression(r,n,o)}evaluate(e){return new Collator(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}serialize(){const e={};return e["case-sensitive"]=this.caseSensitive.serialize(),e["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(e.locale=this.locale.serialize()),["collator",e]}}const Ht=8192;function Xt(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[0]),e[3]=Math.max(e[3],t[1])}function Kt(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function Jt(e,t){const i=(180+e[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,n=Math.pow(2,t.z);return[Math.round(i*n*Ht),Math.round(r*n*Ht)]}function Yt(e,t,i){const r=e[0]-t[0],n=e[1]-t[1],o=e[0]-i[0],a=e[1]-i[1];return r*a-o*n==0&&r*o<=0&&n*a<=0}function Qt(e,t){let i=!1;for(let a=0,s=t.length;a<s;a++){const s=t[a];for(let t=0,a=s.length;t<a-1;t++){if(Yt(e,s[t],s[t+1]))return!1;(n=s[t])[1]>(r=e)[1]!=(o=s[t+1])[1]>r[1]&&r[0]<(o[0]-n[0])*(r[1]-n[1])/(o[1]-n[1])+n[0]&&(i=!i)}}var r,n,o;return i}function ei(e,t){for(let i=0;i<t.length;i++)if(Qt(e,t[i]))return!0;return!1}function ti(e,t,i,r){const n=r[0]-i[0],o=r[1]-i[1],a=(e[0]-i[0])*o-n*(e[1]-i[1]),s=(t[0]-i[0])*o-n*(t[1]-i[1]);return a>0&&s<0||a<0&&s>0}function ii(e,t,i){for(const c of i)for(let i=0;i<c.length-1;++i)if(0!=(s=[(a=c[i+1])[0]-(o=c[i])[0],a[1]-o[1]])[0]*(l=[(n=t)[0]-(r=e)[0],n[1]-r[1]])[1]-s[1]*l[0]&&ti(r,n,o,a)&&ti(o,a,r,n))return!0;var r,n,o,a,s,l;return!1}function ri(e,t){for(let i=0;i<e.length;++i)if(!Qt(e[i],t))return!1;for(let i=0;i<e.length-1;++i)if(ii(e[i],e[i+1],t))return!1;return!0}function ni(e,t){for(let i=0;i<t.length;i++)if(ri(e,t[i]))return!0;return!1}function oi(e,t,i){const r=[];for(let n=0;n<e.length;n++){const o=[];for(let r=0;r<e[n].length;r++){const a=Jt(e[n][r],i);Xt(t,a),o.push(a)}r.push(o)}return r}function ai(e,t,i){const r=[];for(let n=0;n<e.length;n++){const o=oi(e[n],t,i);r.push(o)}return r}function si(e,t,i,r){if(e[0]<i[0]||e[0]>i[2]){const t=.5*r;let n=e[0]-i[0]>t?-r:i[0]-e[0]>t?r:0;0===n&&(n=e[0]-i[2]>t?-r:i[2]-e[0]>t?r:0),e[0]+=n}Xt(t,e)}function li(e,t,i,r){const n=Math.pow(2,r.z)*Ht,o=[r.x*Ht,r.y*Ht],a=[];if(!e)return a;for(const r of e)for(const e of r){const r=[e.x+o[0],e.y+o[1]];si(r,t,i,n),a.push(r)}return a}function ci(e,t,i,r){const n=Math.pow(2,r.z)*Ht,o=[r.x*Ht,r.y*Ht],a=[];if(!e)return a;for(const i of e){const e=[];for(const r of i){const i=[r.x+o[0],r.y+o[1]];Xt(t,i),e.push(i)}a.push(e)}if(t[2]-t[0]<=n/2){(s=t)[0]=s[1]=1/0,s[2]=s[3]=-1/0;for(const e of a)for(const r of e)si(r,t,i,n)}var s;return a}class Within{constructor(e,t){this.type=yt,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Rt(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;e<t.features.length;++e){const i=t.features[e].geometry.type;if("Polygon"===i||"MultiPolygon"===i)return new Within(t,t.features[e].geometry)}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Within(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new Within(t,t)}return t.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,t){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if(!n)return!1;if("Polygon"===t.type){const o=oi(t.coordinates,r,n),a=li(e.geometry(),i,r,n);if(!Kt(i,r))return!1;for(const e of a)if(!Qt(e,o))return!1}if("MultiPolygon"===t.type){const o=ai(t.coordinates,r,n),a=li(e.geometry(),i,r,n);if(!Kt(i,r))return!1;for(const e of a)if(!ei(e,o))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if(!n)return!1;if("Polygon"===t.type){const o=oi(t.coordinates,r,n),a=ci(e.geometry(),i,r,n);if(!Kt(i,r))return!1;for(const e of a)if(!ri(e,o))return!1}if("MultiPolygon"===t.type){const o=ai(t.coordinates,r,n),a=ci(e.geometry(),i,r,n);if(!Kt(i,r))return!1;for(const e of a)if(!ni(e,o))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}var ui=Within;function hi(e){if(e instanceof Wt){if("get"===e.name&&1===e.args.length)return!1;if("feature-state"===e.name)return!1;if("has"===e.name&&1===e.args.length)return!1;if("properties"===e.name||"geometry-type"===e.name||"id"===e.name)return!1;if(/^filter-/.test(e.name))return!1}if(e instanceof ui)return!1;let t=!0;return e.eachChild((e=>{t&&!hi(e)&&(t=!1)})),t}function pi(e){if(e instanceof Wt&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild((e=>{t&&!pi(e)&&(t=!1)})),t}function di(e,t){if(e instanceof Wt&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild((e=>{i&&!di(e,t)&&(i=!1)})),i}class Var{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t}static parse(e,t){if(2!==e.length||"string"!=typeof e[1])return t.error("'var' expression requires exactly one string literal argument.");const i=e[1];return t.scope.has(i)?new Var(i,t.scope.get(i)):t.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var fi=Var;class ParsingContext{constructor(e,t=[],i,r=new ft,n=[]){this.registry=e,this.path=t,this.key=t.map((e=>`[${e}]`)).join(""),this.scope=r,this.errors=n,this.expectedType=i}parse(e,t,i,r,n={}){return t?this.concat(t,i,r)._parse(e,n):this._parse(e,n)}_parse(e,t){function i(e,t,i){return"assert"===i?new Nt(t,[e]):"coerce"===i?new Zt(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r=e[0];if("string"!=typeof r)return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const n=this.registry[r];if(n){let r=n.parse(e,this);if(!r)return null;if(this.expectedType){const e=this.expectedType,n=r.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==n.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==n.kind&&"string"!==n.kind){if(this.checkSubtype(e,n))return null}else r=i(r,e,t.typeAnnotation||"coerce");else r=i(r,e,t.typeAnnotation||"assert")}if(!(r instanceof Vt)&&"resolvedImage"!==r.type.kind&&_i(r)){const e=new $t;try{r=new Vt(r.type,r.evaluate(e))}catch(e){return this.error(e.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,t,i){const r="number"==typeof e?this.path.concat(e):this.path,n=i?this.scope.concat(i):this.scope;return new ParsingContext(this.registry,r,t||null,n,this.errors)}error(e,...t){const i=`${this.key}${t.map((e=>`[${e}]`)).join("")}`;this.errors.push(new dt(i,e))}checkSubtype(e,t){const i=Mt(e,t);return i&&this.error(i),i}}var mi=ParsingContext;function _i(e){if(e instanceof fi)return _i(e.boundExpression);if(e instanceof Wt&&"error"===e.name)return!1;if(e instanceof CollatorExpression)return!1;if(e instanceof ui)return!1;const t=e instanceof Zt||e instanceof Nt;let i=!0;return e.eachChild((e=>{i=t?i&&_i(e):i&&e instanceof Vt})),!!i&&hi(e)&&di(e,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function gi(e,t){const i=e.length-1;let r,n,o=0,a=i,s=0;for(;o<=a;)if(s=Math.floor((o+a)/2),r=e[s],n=e[s+1],r<=t){if(s===i||t<n)return s;o=s+1}else{if(!(r>t))throw new Ut("Input is not a number.");a=s-1}return 0}class Step{constructor(e,t,i){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[e,t]of i)this.labels.push(e),this.outputs.push(t)}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const i=t.parse(e[1],1,_t);if(!i)return null;const r=[];let n=null;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);for(let i=1;i<e.length;i+=2){const o=1===i?-1/0:e[i],a=e[i+1],s=i,l=i+1;if("number"!=typeof o)return t.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',s);if(r.length&&r[r.length-1][0]>=o)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',s);const c=t.parse(a,l,n);if(!c)return null;n=n||c.type,r.push([o,c])}return new Step(n,i,r)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;return r>=t[n-1]?i[n-1].evaluate(e):i[gi(t,r)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}serialize(){const e=["step",this.input.serialize()];for(let t=0;t<this.labels.length;t++)t>0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}var yi=Step;function xi(e,t,i){return e*(1-i)+t*i}function vi(e,t,i){return e.map(((e,r)=>xi(e,t[r],i)))}var bi=Object.freeze({__proto__:null,number:xi,color:function(e,t,i){return new Lt(xi(e.r,t.r,i),xi(e.g,t.g,i),xi(e.b,t.b,i),xi(e.a,t.a,i))},array:vi});const wi=.95047,Ti=1.08883,Ei=4/29,Si=6/29,Ai=3*Si*Si,Ci=Math.PI/180,Ii=180/Math.PI;function Mi(e){return e>.008856451679035631?Math.pow(e,1/3):e/Ai+Ei}function Pi(e){return e>Si?e*e*e:Ai*(e-Ei)}function Di(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function zi(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function ki(e){const t=zi(e.r),i=zi(e.g),r=zi(e.b),n=Mi((.4124564*t+.3575761*i+.1804375*r)/wi),o=Mi((.2126729*t+.7151522*i+.072175*r)/1);return{l:116*o-16,a:500*(n-o),b:200*(o-Mi((.0193339*t+.119192*i+.9503041*r)/Ti)),alpha:e.a}}function Li(e){let t=(e.l+16)/116,i=isNaN(e.a)?t:t+e.a/500,r=isNaN(e.b)?t:t-e.b/200;return t=1*Pi(t),i=wi*Pi(i),r=Ti*Pi(r),new Lt(Di(3.2404542*i-1.5371385*t-.4985314*r),Di(-.969266*i+1.8760108*t+.041556*r),Di(.0556434*i-.2040259*t+1.0572252*r),e.alpha)}function Bi(e,t,i){const r=t-e;return e+i*(r>180||r<-180?r-360*Math.round(r/360):r)}const Ri={forward:ki,reverse:Li,interpolate:function(e,t,i){return{l:xi(e.l,t.l,i),a:xi(e.a,t.a,i),b:xi(e.b,t.b,i),alpha:xi(e.alpha,t.alpha,i)}}},Fi={forward:function(e){const{l:t,a:i,b:r}=ki(e),n=Math.atan2(r,i)*Ii;return{h:n<0?n+360:n,c:Math.sqrt(i*i+r*r),l:t,alpha:e.a}},reverse:function(e){const t=e.h*Ci,i=e.c;return Li({l:e.l,a:Math.cos(t)*i,b:Math.sin(t)*i,alpha:e.alpha})},interpolate:function(e,t,i){return{h:Bi(e.h,t.h,i),c:xi(e.c,t.c,i),l:xi(e.l,t.l,i),alpha:xi(e.alpha,t.alpha,i)}}};var Oi=Object.freeze({__proto__:null,lab:Ri,hcl:Fi});class Interpolate{constructor(e,t,i,r,n){this.type=e,this.operator=t,this.interpolation=i,this.input=r,this.labels=[],this.outputs=[];for(const[e,t]of n)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,i,r,n){let o=0;if("exponential"===e.name)o=Vi(i,e.base,r,n);else if("linear"===e.name)o=Vi(i,1,r,n);else if("cubic-bezier"===e.name){const a=e.controlPoints;o=new t(a[0],a[1],a[2],a[3]).solve(Vi(i,1,r,n))}return o}static parse(e,t){let[i,r,n,...o]=e;if(!Array.isArray(r)||0===r.length)return t.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const e=r[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:e}}else{if("cubic-bezier"!==r[0])return t.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const e=r.slice(1);if(4!==e.length||e.some((e=>"number"!=typeof e||e<0||e>1)))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(n=t.parse(n,2,_t),!n)return null;const a=[];let s=null;"interpolate-hcl"===i||"interpolate-lab"===i?s=xt:t.expectedType&&"value"!==t.expectedType.kind&&(s=t.expectedType);for(let e=0;e<o.length;e+=2){const i=o[e],r=o[e+1],n=e+3,l=e+4;if("number"!=typeof i)return t.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',n);if(a.length&&a[a.length-1][0]>=i)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',n);const c=t.parse(r,l,s);if(!c)return null;s=s||c.type,a.push([i,c])}return"number"===s.kind||"color"===s.kind||"array"===s.kind&&"number"===s.itemType.kind&&"number"==typeof s.N?new Interpolate(s,i,r,n,a):t.error(`Type ${Ct(s)} is not interpolatable.`)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;if(r>=t[n-1])return i[n-1].evaluate(e);const o=gi(t,r),a=Interpolate.interpolationFactor(this.interpolation,r,t[o],t[o+1]),s=i[o].evaluate(e),l=i[o+1].evaluate(e);return"interpolate"===this.operator?bi[this.type.kind.toLowerCase()](s,l,a):"interpolate-hcl"===this.operator?Fi.reverse(Fi.interpolate(Fi.forward(s),Fi.forward(l),a)):Ri.reverse(Ri.interpolate(Ri.forward(s),Ri.forward(l),a))}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}serialize(){let e;e="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 t=[this.operator,e,this.input.serialize()];for(let e=0;e<this.labels.length;e++)t.push(this.labels[e],this.outputs[e].serialize());return t}}function Vi(e,t,i,r){const n=r-i,o=e-i;return 0===n?0:1===t?o/n:(Math.pow(t,o)-1)/(Math.pow(t,n)-1)}var Ui=Interpolate;class Coalesce{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expectected at least one argument.");let i=null;const r=t.expectedType;r&&"value"!==r.kind&&(i=r);const n=[];for(const r of e.slice(1)){const e=t.parse(r,1+n.length,i,void 0,{typeAnnotation:"omit"});if(!e)return null;i=i||e.type,n.push(e)}const o=r&&n.some((e=>Mt(r,e.type)));return new Coalesce(o?bt:i,n)}evaluate(e){let t,i=null,r=0;for(const n of this.args){if(r++,i=n.evaluate(e),i&&i instanceof ResolvedImage&&!i.available&&(t||(t=i),i=null,r===this.args.length))return t;if(null!==i)break}return i}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){const e=["coalesce"];return this.eachChild((t=>{e.push(t.serialize())})),e}}var ji=Coalesce;class Let{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result)}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const i=[];for(let r=1;r<e.length-1;r+=2){const n=e[r];if("string"!=typeof n)return t.error(`Expected string, but found ${typeof n} instead.`,r);if(/[^a-zA-Z0-9_]/.test(n))return t.error("Variable names must contain only alphanumeric characters or '_'.",r);const o=t.parse(e[r+1],r+1);if(!o)return null;i.push([n,o])}const r=t.parse(e[e.length-1],e.length-1,t.expectedType,i);return r?new Let(i,r):null}outputDefined(){return this.result.outputDefined()}serialize(){const e=["let"];for(const[t,i]of this.bindings)e.push(t,i.serialize());return e.push(this.result.serialize()),e}}var Ni=Let;class At{constructor(e,t,i){this.type=e,this.index=t,this.input=i}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,_t),r=t.parse(e[2],2,St(t.expectedType||bt));return i&&r?new At(r.type.itemType,i,r):null}evaluate(e){const t=this.index.evaluate(e),i=this.input.evaluate(e);if(t<0)throw new Ut(`Array index out of bounds: ${t} < 0.`);if(t>=i.length)throw new Ut(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t!==Math.floor(t))throw new Ut(`Array index must be an integer, but found ${t} instead.`);return i[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var Gi=At;class In{constructor(e,t){this.type=yt,this.needle=e,this.haystack=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,bt),r=t.parse(e[2],2,bt);return i&&r?Pt(i.type,[yt,gt,_t,mt,bt])?new In(i,r):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ct(i.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(null==i)return!1;if(!Dt(t,["boolean","string","number","null"]))throw new Ut(`Expected first argument to be of type boolean, string, number or null, but found ${Ct(Ft(t))} instead.`);if(!Dt(i,["string","array"]))throw new Ut(`Expected second argument to be of type array or string, but found ${Ct(Ft(i))} instead.`);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var Zi=In;class IndexOf{constructor(e,t,i){this.type=_t,this.needle=e,this.haystack=t,this.fromIndex=i}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,bt),r=t.parse(e[2],2,bt);if(!i||!r)return null;if(!Pt(i.type,[yt,gt,_t,mt,bt]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ct(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,_t);return n?new IndexOf(i,r,n):null}return new IndexOf(i,r)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!Dt(t,["boolean","string","number","null"]))throw new Ut(`Expected first argument to be of type boolean, string, number or null, but found ${Ct(Ft(t))} instead.`);if(!Dt(i,["string","array"]))throw new Ut(`Expected second argument to be of type array or string, but found ${Ct(Ft(i))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(e);return i.indexOf(t,r)}return i.indexOf(t)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var qi=IndexOf;class Match{constructor(e,t,i,r,n,o){this.inputType=e,this.type=t,this.input=i,this.cases=r,this.outputs=n,this.otherwise=o}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let i,r;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);const n={},o=[];for(let a=2;a<e.length-1;a+=2){let s=e[a];const l=e[a+1];Array.isArray(s)||(s=[s]);const c=t.concat(a);if(0===s.length)return c.error("Expected at least one branch label.");for(const e of s){if("number"!=typeof e&&"string"!=typeof e)return c.error("Branch labels must be numbers or strings.");if("number"==typeof e&&Math.abs(e)>Number.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,Ft(e)))return null}else i=Ft(e);if(void 0!==n[String(e)])return c.error("Branch labels must be unique.");n[String(e)]=o.length}const u=t.parse(l,a,r);if(!u)return null;r=r||u.type,o.push(u)}const a=t.parse(e[1],1,bt);if(!a)return null;const s=t.parse(e[e.length-1],e.length-1,r);return s?"value"!==a.type.kind&&t.concat(1).checkSubtype(i,a.type)?null:new Match(i,r,a,n,o,s):null}evaluate(e){const t=this.input.evaluate(e);return(Ft(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],t=Object.keys(this.cases).sort(),i=[],r={};for(const e of t){const t=r[this.cases[e]];void 0===t?(r[this.cases[e]]=i.length,i.push([this.cases[e],[e]])):i[t][1].push(e)}const n=e=>"number"===this.inputType.kind?Number(e):e;for(const[t,r]of i)e.push(1===r.length?n(r[0]):r.map(n)),e.push(this.outputs[t].serialize());return e.push(this.otherwise.serialize()),e}}var $i=Match;class Case{constructor(e,t,i){this.type=e,this.branches=t,this.otherwise=i}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let i;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);const r=[];for(let n=1;n<e.length-1;n+=2){const o=t.parse(e[n],n,yt);if(!o)return null;const a=t.parse(e[n+1],n+1,i);if(!a)return null;r.push([o,a]),i=i||a.type}const n=t.parse(e[e.length-1],e.length-1,i);return n?new Case(i,r,n):null}evaluate(e){for(const[t,i]of this.branches)if(t.evaluate(e))return i.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[t,i]of this.branches)e(t),e(i);e(this.otherwise)}outputDefined(){return this.branches.every((([e,t])=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild((t=>{e.push(t.serialize())})),e}}var Wi=Case;class Slice{constructor(e,t,i,r){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=r}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,bt),r=t.parse(e[2],2,_t);if(!i||!r)return null;if(!Pt(i.type,[St(bt),gt,bt]))return t.error(`Expected first argument to be of type array or string, but found ${Ct(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,_t);return n?new Slice(i.type,i,r,n):null}return new Slice(i.type,i,r)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);if(!Dt(t,["string","array"]))throw new Ut(`Expected first argument to be of type array or string, but found ${Ct(Ft(t))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(e);return t.slice(i,r)}return t.slice(i)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var Hi=Slice;function Xi(e,t){return"=="===e||"!="===e?"boolean"===t.kind||"string"===t.kind||"number"===t.kind||"null"===t.kind||"value"===t.kind:"string"===t.kind||"number"===t.kind||"value"===t.kind}function Ki(e,t,i,r){return 0===r.compare(t,i)}function Ji(e,t,i){const r="=="!==e&&"!="!==e;return class Comparison{constructor(e,t,i){this.type=yt,this.lhs=e,this.rhs=t,this.collator=i,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind}static parse(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");const i=e[0];let n=t.parse(e[1],1,bt);if(!n)return null;if(!Xi(i,n.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${Ct(n.type)}'.`);let o=t.parse(e[2],2,bt);if(!o)return null;if(!Xi(i,o.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${Ct(o.type)}'.`);if(n.type.kind!==o.type.kind&&"value"!==n.type.kind&&"value"!==o.type.kind)return t.error(`Cannot compare types '${Ct(n.type)}' and '${Ct(o.type)}'.`);r&&("value"===n.type.kind&&"value"!==o.type.kind?n=new Nt(o.type,[n]):"value"!==n.type.kind&&"value"===o.type.kind&&(o=new Nt(n.type,[o])));let a=null;if(4===e.length){if("string"!==n.type.kind&&"string"!==o.type.kind&&"value"!==n.type.kind&&"value"!==o.type.kind)return t.error("Cannot use collator to compare non-string types.");if(a=t.parse(e[3],3,wt),!a)return null}return new Comparison(n,o,a)}evaluate(n){const o=this.lhs.evaluate(n),a=this.rhs.evaluate(n);if(r&&this.hasUntypedArgument){const t=Ft(o),i=Ft(a);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new Ut(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const e=Ft(o),i=Ft(a);if("string"!==e.kind||"string"!==i.kind)return t(n,o,a)}return this.collator?i(n,o,a,this.collator.evaluate(n)):t(n,o,a)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}serialize(){const t=[e];return this.eachChild((e=>{t.push(e.serialize())})),t}}}const Yi=Ji("==",(function(e,t,i){return t===i}),Ki),Qi=Ji("!=",(function(e,t,i){return t!==i}),(function(e,t,i,r){return!Ki(0,t,i,r)})),er=Ji("<",(function(e,t,i){return t<i}),(function(e,t,i,r){return r.compare(t,i)<0})),tr=Ji(">",(function(e,t,i){return t>i}),(function(e,t,i,r){return r.compare(t,i)>0})),ir=Ji("<=",(function(e,t,i){return t<=i}),(function(e,t,i,r){return r.compare(t,i)<=0})),rr=Ji(">=",(function(e,t,i){return t>=i}),(function(e,t,i,r){return r.compare(t,i)>=0}));class NumberFormat{constructor(e,t,i,r,n,o){this.type=gt,this.number=e,this.locale=t,this.currency=i,this.unit=r,this.minFractionDigits=n,this.maxFractionDigits=o}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,_t);if(!i)return null;const r=e[2];if("object"!=typeof r||Array.isArray(r))return t.error("NumberFormat options argument must be an object.");let n=null;if(r.locale&&(n=t.parse(r.locale,1,gt),!n))return null;let o=null;if(r.currency&&(o=t.parse(r.currency,1,gt),!o))return null;let a=null;if(r.unit&&(a=t.parse(r.unit,1,gt),!a))return null;let s=null;if(r["min-fraction-digits"]&&(s=t.parse(r["min-fraction-digits"],1,_t),!s))return null;let l=null;return r["max-fraction-digits"]&&(l=t.parse(r["max-fraction-digits"],1,_t),!l)?null:new NumberFormat(i,n,o,a,s,l)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class Length{constructor(e){this.type=_t,this.input=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=t.parse(e[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?t.error(`Expected argument of type string or array, but found ${Ct(i.type)} instead.`):new Length(i):null}evaluate(e){const t=this.input.evaluate(e);if("string"==typeof t)return t.length;if(Array.isArray(t))return t.length;throw new Ut(`Expected value to be of type string or array, but found ${Ct(Ft(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild((t=>{e.push(t.serialize())})),e}}const nr={"==":Yi,"!=":Qi,">":tr,"<":er,">=":rr,"<=":ir,array:Nt,at:Gi,boolean:Nt,case:Wi,coalesce:ji,collator:CollatorExpression,format:FormatExpression,image:ImageExpression,in:Zi,"index-of":qi,interpolate:Ui,"interpolate-hcl":Ui,"interpolate-lab":Ui,length:Length,let:Ni,literal:Vt,match:$i,number:Nt,"number-format":NumberFormat,object:Nt,slice:Hi,step:yi,string:Nt,"to-boolean":Zt,"to-color":Zt,"to-number":Zt,"to-string":Zt,var:fi,within:ui};function or(e,[t,i,r,n]){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);const o=n?n.evaluate(e):1,a=Bt(t,i,r,o);if(a)throw new Ut(a);return new Lt(t/255*o,i/255*o,r/255*o,o)}function ar(e,t){return e in t}function sr(e,t){const i=t[e];return void 0===i?null:i}function lr(e){return{type:e}}Wt.register(nr,{error:[{kind:"error"},[gt],(e,[t])=>{throw new Ut(t.evaluate(e))}],typeof:[gt,[bt],(e,[t])=>Ct(Ft(t.evaluate(e)))],"to-rgba":[St(_t,4),[xt],(e,[t])=>t.evaluate(e).toArray()],rgb:[xt,[_t,_t,_t],or],rgba:[xt,[_t,_t,_t,_t],or],has:{type:yt,overloads:[[[gt],(e,[t])=>ar(t.evaluate(e),e.properties())],[[gt,vt],(e,[t,i])=>ar(t.evaluate(e),i.evaluate(e))]]},get:{type:bt,overloads:[[[gt],(e,[t])=>sr(t.evaluate(e),e.properties())],[[gt,vt],(e,[t,i])=>sr(t.evaluate(e),i.evaluate(e))]]},"feature-state":[bt,[gt],(e,[t])=>sr(t.evaluate(e),e.featureState||{})],properties:[vt,[],e=>e.properties()],"geometry-type":[gt,[],e=>e.geometryType()],id:[bt,[],e=>e.id()],zoom:[_t,[],e=>e.globals.zoom],pitch:[_t,[],e=>e.globals.pitch||0],"distance-from-center":[_t,[],e=>e.distanceFromCenter()],"heatmap-density":[_t,[],e=>e.globals.heatmapDensity||0],"line-progress":[_t,[],e=>e.globals.lineProgress||0],"sky-radial-progress":[_t,[],e=>e.globals.skyRadialProgress||0],accumulated:[bt,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[_t,lr(_t),(e,t)=>{let i=0;for(const r of t)i+=r.evaluate(e);return i}],"*":[_t,lr(_t),(e,t)=>{let i=1;for(const r of t)i*=r.evaluate(e);return i}],"-":{type:_t,overloads:[[[_t,_t],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[_t],(e,[t])=>-t.evaluate(e)]]},"/":[_t,[_t,_t],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[_t,[_t,_t],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[_t,[],()=>Math.LN2],pi:[_t,[],()=>Math.PI],e:[_t,[],()=>Math.E],"^":[_t,[_t,_t],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[_t,[_t],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[_t,[_t],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[_t,[_t],(e,[t])=>Math.log(t.evaluate(e))],log2:[_t,[_t],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[_t,[_t],(e,[t])=>Math.sin(t.evaluate(e))],cos:[_t,[_t],(e,[t])=>Math.cos(t.evaluate(e))],tan:[_t,[_t],(e,[t])=>Math.tan(t.evaluate(e))],asin:[_t,[_t],(e,[t])=>Math.asin(t.evaluate(e))],acos:[_t,[_t],(e,[t])=>Math.acos(t.evaluate(e))],atan:[_t,[_t],(e,[t])=>Math.atan(t.evaluate(e))],min:[_t,lr(_t),(e,t)=>Math.min(...t.map((t=>t.evaluate(e))))],max:[_t,lr(_t),(e,t)=>Math.max(...t.map((t=>t.evaluate(e))))],abs:[_t,[_t],(e,[t])=>Math.abs(t.evaluate(e))],round:[_t,[_t],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[_t,[_t],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[_t,[_t],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[yt,[gt,bt],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[yt,[bt],(e,[t])=>e.id()===t.value],"filter-type-==":[yt,[gt],(e,[t])=>e.geometryType()===t.value],"filter-<":[yt,[gt,bt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r<n}],"filter-id-<":[yt,[bt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i<r}],"filter->":[yt,[gt,bt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>n}],"filter-id->":[yt,[bt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>r}],"filter-<=":[yt,[gt,bt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r<=n}],"filter-id-<=":[yt,[bt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i<=r}],"filter->=":[yt,[gt,bt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>=n}],"filter-id->=":[yt,[bt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>=r}],"filter-has":[yt,[bt],(e,[t])=>t.value in e.properties()],"filter-has-id":[yt,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[yt,[St(gt)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[yt,[St(bt)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[yt,[gt,St(bt)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[yt,[gt,St(bt)],(e,[t,i])=>function(e,t,i,r){for(;i<=r;){const n=i+r>>1;if(t[n]===e)return!0;t[n]>e?r=n-1:i=n+1}return!1}(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:yt,overloads:[[[yt,yt],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[lr(yt),(e,t)=>{for(const i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:yt,overloads:[[[yt,yt],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[lr(yt),(e,t)=>{for(const i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[yt,[yt],(e,[t])=>!t.evaluate(e)],"is-supported-script":[yt,[gt],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[gt,[gt],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[gt,[gt],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[gt,lr(bt),(e,t)=>t.map((t=>Ot(t.evaluate(e)))).join("")],"resolved-locale":[gt,[wt],(e,[t])=>t.evaluate(e).resolvedLocale()]});var cr=nr;function ur(e){return{result:"success",value:e}}function hr(e){return{result:"error",value:e}}function pr(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function dr(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function fr(e){return!!e.expression&&e.expression.interpolated}function mr(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function _r(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function gr(e){return e}function yr(e,t){const i="color"===t.type,r=e.stops&&"object"==typeof e.stops[0][0],n=r||!(r||void 0!==e.property),o=e.type||(fr(t)?"exponential":"interval");if(i&&((e=ut({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],Lt.parse(e[1])]))),e.default=Lt.parse(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==e.colorSpace&&!Oi[e.colorSpace])throw new Error(`Unknown color space: ${e.colorSpace}`);let a,s,l;if("exponential"===o)a=wr;else if("interval"===o)a=br;else if("categorical"===o){a=vr,s=Object.create(null);for(const t of e.stops)s[t[0]]=t[1];l=typeof e.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);a=Tr}if(r){const i={},r=[];for(let t=0;t<e.stops.length;t++){const n=e.stops[t],o=n[0].zoom;void 0===i[o]&&(i[o]={zoom:o,type:e.type,property:e.property,default:e.default,stops:[]},r.push(o)),i[o].stops.push([n[0].value,n[1]])}const n=[];for(const e of r)n.push([i[e].zoom,yr(i[e],t)]);const o={name:"linear"};return{kind:"composite",interpolationType:o,interpolationFactor:Ui.interpolationFactor.bind(void 0,o),zoomStops:n.map((e=>e[0])),evaluate:({zoom:i},r)=>wr({stops:n,base:e.base},t,i).evaluate(i,r)}}if(n){const i="exponential"===o?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:Ui.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map((e=>e[0])),evaluate:({zoom:i})=>a(e,t,i,s,l)}}return{kind:"source",evaluate(i,r){const n=r&&r.properties?r.properties[e.property]:void 0;return void 0===n?xr(e.default,t.default):a(e,t,n,s,l)}}}function xr(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function vr(e,t,i,r,n){return xr(typeof i===n?r[i]:void 0,e.default,t.default)}function br(e,t,i){if("number"!==mr(i))return xr(e.default,t.default);const r=e.stops.length;if(1===r)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[r-1][0])return e.stops[r-1][1];const n=gi(e.stops.map((e=>e[0])),i);return e.stops[n][1]}function wr(e,t,i){const r=void 0!==e.base?e.base:1;if("number"!==mr(i))return xr(e.default,t.default);const n=e.stops.length;if(1===n)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[n-1][0])return e.stops[n-1][1];const o=gi(e.stops.map((e=>e[0])),i),a=function(e,t,i,r){const n=r-i,o=e-i;return 0===n?0:1===t?o/n:(Math.pow(t,o)-1)/(Math.pow(t,n)-1)}(i,r,e.stops[o][0],e.stops[o+1][0]),s=e.stops[o][1],l=e.stops[o+1][1];let c=bi[t.type]||gr;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=Oi[e.colorSpace];c=(e,i)=>t.reverse(t.interpolate(t.forward(e),t.forward(i),a))}return"function"==typeof s.evaluate?{evaluate(...e){const t=s.evaluate.apply(void 0,e),i=l.evaluate.apply(void 0,e);if(void 0!==t&&void 0!==i)return c(t,i,a)}}:c(s,l,a)}function Tr(e,t,i){return"color"===t.type?i=Lt.parse(i):"formatted"===t.type?i=Formatted.fromString(i.toString()):"resolvedImage"===t.type?i=ResolvedImage.fromString(i.toString()):mr(i)===t.type||"enum"===t.type&&t.values[i]||(i=void 0),xr(i,e.default,t.default)}class StyleExpression{constructor(e,t){this.expression=e,this._warningHistory={},this._evaluator=new $t,this._defaultValue=t?function(e){return"color"===e.type&&(_r(e.default)||Array.isArray(e.default))?new Lt(0,0,0,0):"color"===e.type?Lt.parse(e.default)||null:void 0===e.default?null:e.default}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null}evaluateWithoutErrorHandling(e,t,i,r,n,o,a,s){return this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=r||null,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o,this._evaluator.featureTileCoord=a||null,this._evaluator.featureDistanceData=s||null,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,r,n,o,a,s){this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r||null,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o||null,this._evaluator.featureTileCoord=a||null,this._evaluator.featureDistanceData=s||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new Ut(`Expected value to be one of ${Object.keys(this._enumValues).map((e=>JSON.stringify(e))).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(e.message)),this._defaultValue}}}function Er(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in cr}function Sr(e,t){const i=new mi(cr,[],t?function(e){const t={color:xt,string:gt,number:_t,enum:gt,boolean:yt,formatted:Tt,resolvedImage:Et};return"array"===e.type?St(t[e.value]||bt,e.length):t[e.type]}(t):void 0),r=i.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return r?ur(new StyleExpression(r,t)):hr(i.errors)}class ZoomConstantExpression{constructor(e,t){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!pi(t.expression)}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o){return this._styleExpression.evaluate(e,t,i,r,n,o)}}class ZoomDependentExpression{constructor(e,t,i,r){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!pi(t.expression),this.interpolationType=r}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o){return this._styleExpression.evaluate(e,t,i,r,n,o)}interpolationFactor(e,t,i){return this.interpolationType?Ui.interpolationFactor(this.interpolationType,e,t,i):0}}function Ar(e,t){if("error"===(e=Sr(e,t)).result)return e;const i=e.value.expression,r=hi(i);if(!r&&!pr(t))return hr([new dt("","data expressions not supported")]);const n=di(i,["zoom","pitch","distance-from-center"]);if(!n&&!dr(t))return hr([new dt("","zoom expressions not supported")]);const o=Cr(i);return o||n?o instanceof dt?hr([o]):o instanceof Ui&&!fr(t)?hr([new dt("",'"interpolate" expressions cannot be used with this property')]):ur(o?new ZoomDependentExpression(r?"camera":"composite",e.value,o.labels,o instanceof Ui?o.interpolation:void 0):new ZoomConstantExpression(r?"constant":"source",e.value)):hr([new dt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class StylePropertyFunction{constructor(e,t){this._parameters=e,this._specification=t,ut(this,yr(this._parameters,this._specification))}static deserialize(e){return new StylePropertyFunction(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Cr(e){let t=null;if(e instanceof Ni)t=Cr(e.result);else if(e instanceof ji){for(const i of e.args)if(t=Cr(i),t)break}else(e instanceof yi||e instanceof Ui)&&e.input instanceof Wt&&"zoom"===e.input.name&&(t=e);return t instanceof dt||e.eachChild((e=>{const i=Cr(e);i instanceof dt?t=i:!t&&i?t=new dt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&i&&t!==i&&(t=new dt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),t}class ValidationError{constructor(e,t,i,r){this.message=(e?`${e}: `:"")+i,r&&(this.identifier=r),null!=t&&t.__line__&&(this.line=t.__line__)}}function Ir(e){const t=e.key,i=e.value,r=e.valueSpec||{},n=e.objectElementValidators||{},o=e.style,a=e.styleSpec;let s=[];const l=mr(i);if("object"!==l)return[new ValidationError(t,i,`object expected, ${l} found`)];for(const e in i){const l=e.split(".")[0],c=r[l]||r["*"];let u;n[l]?u=n[l]:r[l]?u=ln:n["*"]?u=n["*"]:r["*"]&&(u=ln),u?s=s.concat(u({key:(t?`${t}.`:t)+e,value:i[e],valueSpec:c,style:o,styleSpec:a,object:i,objectKey:e},i)):s.push(new ValidationError(t,i[e],`unknown property "${e}"`))}for(const e in r)n[e]||r[e].required&&void 0===r[e].default&&void 0===i[e]&&s.push(new ValidationError(t,i,`missing required property "${e}"`));return s}function Mr(e){const t=e.value,i=e.valueSpec,r=e.style,n=e.styleSpec,o=e.key,a=e.arrayElementValidator||ln;if("array"!==mr(t))return[new ValidationError(o,t,`array expected, ${mr(t)} found`)];if(i.length&&t.length!==i.length)return[new ValidationError(o,t,`array length ${i.length} expected, length ${t.length} found`)];if(i["min-length"]&&t.length<i["min-length"])return[new ValidationError(o,t,`array length at least ${i["min-length"]} expected, length ${t.length} found`)];let s={type:i.value,values:i.values,minimum:i.minimum,maximum:i.maximum,function:void 0};n.$version<7&&(s.function=i.function),"object"===mr(i.value)&&(s=i.value);let l=[];for(let e=0;e<t.length;e++)l=l.concat(a({array:t,arrayIndex:e,value:t[e],valueSpec:s,style:r,styleSpec:n,key:`${o}[${e}]`}));return l}function Pr(e){const t=e.key,i=e.value,r=e.valueSpec;let n=mr(i);if("number"===n&&i!=i&&(n="NaN"),"number"!==n)return[new ValidationError(t,i,`number expected, ${n} found`)];if("minimum"in r){let n=r.minimum;if("array"===mr(r.minimum)&&(n=r.minimum[e.arrayIndex]),i<n)return[new ValidationError(t,i,`${i} is less than the minimum value ${n}`)]}if("maximum"in r){let n=r.maximum;if("array"===mr(r.maximum)&&(n=r.maximum[e.arrayIndex]),i>n)return[new ValidationError(t,i,`${i} is greater than the maximum value ${n}`)]}return[]}function Dr(e){const t=e.valueSpec,i=ht(e.value.type);let r,n,o,a={};const s="categorical"!==i&&void 0===e.value.property,l=!s,c="array"===mr(e.value.stops)&&"array"===mr(e.value.stops[0])&&"object"===mr(e.value.stops[0][0]),u=Ir({key:e.key,value:e.value,valueSpec:e.styleSpec.function,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===i)return[new ValidationError(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const r=e.value;return t=t.concat(Mr({key:e.key,value:r,valueSpec:e.valueSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:h})),"array"===mr(r)&&0===r.length&&t.push(new ValidationError(e.key,r,"array must have at least one stop")),t},default:function(e){return ln({key:e.key,value:e.value,valueSpec:t,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===i&&s&&u.push(new ValidationError(e.key,e.value,'missing required property "property"')),"identity"===i||e.value.stops||u.push(new ValidationError(e.key,e.value,'missing required property "stops"')),"exponential"===i&&e.valueSpec.expression&&!fr(e.valueSpec)&&u.push(new ValidationError(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!pr(e.valueSpec)?u.push(new ValidationError(e.key,e.value,"property functions not supported")):s&&!dr(e.valueSpec)&&u.push(new ValidationError(e.key,e.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==e.value.property||u.push(new ValidationError(e.key,e.value,'"property" property is required')),u;function h(e){let i=[];const r=e.value,s=e.key;if("array"!==mr(r))return[new ValidationError(s,r,`array expected, ${mr(r)} found`)];if(2!==r.length)return[new ValidationError(s,r,`array length 2 expected, length ${r.length} found`)];if(c){if("object"!==mr(r[0]))return[new ValidationError(s,r,`object expected, ${mr(r[0])} found`)];if(void 0===r[0].zoom)return[new ValidationError(s,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new ValidationError(s,r,"object stop key must have value")];const t=ht(r[0].zoom);if("number"!=typeof t)return[new ValidationError(s,r[0].zoom,"stop zoom values must be numbers")];if(o&&o>t)return[new ValidationError(s,r[0].zoom,"stop zoom values must appear in ascending order")];t!==o&&(o=t,n=void 0,a={}),i=i.concat(Ir({key:`${s}[0]`,value:r[0],valueSpec:{zoom:{}},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:Pr,value:p}}))}else i=i.concat(p({key:`${s}[0]`,value:r[0],valueSpec:{},style:e.style,styleSpec:e.styleSpec},r));return Er(pt(r[1]))?i.concat([new ValidationError(`${s}[1]`,r[1],"expressions are not allowed in function stops.")]):i.concat(ln({key:`${s}[1]`,value:r[1],valueSpec:t,style:e.style,styleSpec:e.styleSpec}))}function p(e,o){const s=mr(e.value),l=ht(e.value),c=null!==e.value?e.value:o;if(r){if(s!==r)return[new ValidationError(e.key,c,`${s} stop domain type must match previous stop domain type ${r}`)]}else r=s;if("number"!==s&&"string"!==s&&"boolean"!==s&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return[new ValidationError(e.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==s&&"categorical"!==i){let r=`number expected, ${s} found`;return pr(t)&&void 0===i&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new ValidationError(e.key,c,r)]}return"categorical"!==i||"number"!==s||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===s&&"number"==typeof l&&"number"==typeof n&&void 0!==n&&l<n?[new ValidationError(e.key,c,"stop domain values must appear in ascending order")]:(n=l,"categorical"===i&&l in a?[new ValidationError(e.key,c,"stop domain values must be unique")]:(a[l]=!0,[])):[new ValidationError(e.key,c,`integer expected, found ${String(l)}`)]}}function zr(e){const t=("property"===e.expressionContext?Ar:Sr)(pt(e.value),e.valueSpec);if("error"===t.result)return t.value.map((t=>new ValidationError(`${e.key}${t.key}`,e.value,t.message)));const i=t.value.expression||t.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!i.outputDefined())return[new ValidationError(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!pi(i))return[new ValidationError(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext)return kr(i,e);if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!di(i,["zoom","feature-state"]))return[new ValidationError(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!hi(i))return[new ValidationError(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function kr(e,t){const i=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(t.valueSpec&&t.valueSpec.expression)for(const e of t.valueSpec.expression.parameters)i.delete(e);if(0===i.size)return[];const r=[];return e instanceof Wt&&i.has(e.name)?[new ValidationError(t.key,t.value,`["${e.name}"] expression is not supported in a filter for a ${t.object.type} layer with id: ${t.object.id}`)]:(e.eachChild((e=>{r.push(...kr(e,t))})),r)}function Lr(e){const t=e.key,i=e.value,r=e.valueSpec,n=[];return Array.isArray(r.values)?-1===r.values.indexOf(ht(i))&&n.push(new ValidationError(t,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(ht(i))&&n.push(new ValidationError(t,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),n}function Br(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const t of e.slice(1))if(!Br(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}function Rr(e,t="fill"){if(null==e)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Br(e)||(e=Gr(e));const i=e;let r=!0;try{r=function(e){if(!Vr(e))return e;let t=pt(e);return Or(t),t=Fr(t),t}(i)}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(i,null,2)}\n `)}const n=ct[`filter_${t}`],o=Sr(r,n);let a=null;if("error"===o.result)throw new Error(o.value.map((e=>`${e.key}: ${e.message}`)).join(", "));a=(e,t,i)=>o.value.evaluate(e,t,{},i);let s=null,l=null;if(r!==i){const e=Sr(i,n);if("error"===e.result)throw new Error(e.value.map((e=>`${e.key}: ${e.message}`)).join(", "));s=(t,i,r,n,o)=>e.value.evaluate(t,i,{},r,void 0,void 0,n,o),l=!hi(e.value.expression)}return a=a,{filter:a,dynamicFilter:s||void 0,needGeometry:Nr(r),needFeature:!!l}}function Fr(e){if(!Array.isArray(e))return e;const t=function(e){if(Ur.has(e[0]))for(let t=1;t<e.length;t++)if(Vr(e[t]))return!0;return e}(e);return!0===t?t:t.map((e=>Fr(e)))}function Or(e){let t=!1;const i=[];if("case"===e[0]){for(let r=1;r<e.length-1;r+=2)t=t||Vr(e[r]),i.push(e[r+1]);i.push(e[e.length-1])}else if("match"===e[0]){t=t||Vr(e[1]);for(let t=2;t<e.length-1;t+=2)i.push(e[t+1]);i.push(e[e.length-1])}else if("step"===e[0]){t=t||Vr(e[1]);for(let t=1;t<e.length-1;t+=2)i.push(e[t+1])}t&&(e.length=0,e.push("any",...i));for(let t=1;t<e.length;t++)Or(e[t])}function Vr(e){if(!Array.isArray(e))return!1;if("pitch"===(t=e[0])||"distance-from-center"===t)return!0;var t;for(let t=1;t<e.length;t++)if(Vr(e[t]))return!0;return!1}const Ur=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function jr(e,t){return e<t?-1:e>t?1:0}function Nr(e){if(!Array.isArray(e))return!1;if("within"===e[0])return!0;for(let t=1;t<e.length;t++)if(Nr(e[t]))return!0;return!1}function Gr(e){if(!e)return!0;const t=e[0];return e.length<=1?"any"!==t:"=="===t?Zr(e[1],e[2],"=="):"!="===t?Wr(Zr(e[1],e[2],"==")):"<"===t||">"===t||"<="===t||">="===t?Zr(e[1],e[2],t):"any"===t?(i=e.slice(1),["any"].concat(i.map(Gr))):"all"===t?["all"].concat(e.slice(1).map(Gr)):"none"===t?["all"].concat(e.slice(1).map(Gr).map(Wr)):"in"===t?qr(e[1],e.slice(2)):"!in"===t?Wr(qr(e[1],e.slice(2))):"has"===t?$r(e[1]):"!has"===t?Wr($r(e[1])):"within"!==t||e;var i}function Zr(e,t,i){switch(e){case"$type":return[`filter-type-${i}`,t];case"$id":return[`filter-id-${i}`,t];default:return[`filter-${i}`,e,t]}}function qr(e,t){if(0===t.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some((e=>typeof e!=typeof t[0]))?["filter-in-large",e,["literal",t.sort(jr)]]:["filter-in-small",e,["literal",t]]}}function $r(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function Wr(e){return["!",e]}function Hr(e){return Br(pt(e.value))?zr(ut({},e,{expressionContext:"filter",valueSpec:e.styleSpec[`filter_${e.layerType||"fill"}`]})):Xr(e)}function Xr(e){const t=e.value,i=e.key;if("array"!==mr(t))return[new ValidationError(i,t,`array expected, ${mr(t)} found`)];const r=e.styleSpec;let n,o=[];if(t.length<1)return[new ValidationError(i,t,"filter array must have at least 1 element")];switch(o=o.concat(Lr({key:`${i}[0]`,value:t[0],valueSpec:r.filter_operator,style:e.style,styleSpec:e.styleSpec})),ht(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===ht(t[1])&&o.push(new ValidationError(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":3!==t.length&&o.push(new ValidationError(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(n=mr(t[1]),"string"!==n&&o.push(new ValidationError(`${i}[1]`,t[1],`string expected, ${n} found`)));for(let a=2;a<t.length;a++)n=mr(t[a]),"$type"===ht(t[1])?o=o.concat(Lr({key:`${i}[${a}]`,value:t[a],valueSpec:r.geometry_type,style:e.style,styleSpec:e.styleSpec})):"string"!==n&&"number"!==n&&"boolean"!==n&&o.push(new ValidationError(`${i}[${a}]`,t[a],`string, number, or boolean expected, ${n} found`));break;case"any":case"all":case"none":for(let r=1;r<t.length;r++)o=o.concat(Xr({key:`${i}[${r}]`,value:t[r],style:e.style,styleSpec:e.styleSpec}));break;case"has":case"!has":n=mr(t[1]),2!==t.length?o.push(new ValidationError(i,t,`filter array for "${t[0]}" operator must have 2 elements`)):"string"!==n&&o.push(new ValidationError(`${i}[1]`,t[1],`string expected, ${n} found`));break;case"within":n=mr(t[1]),2!==t.length?o.push(new ValidationError(i,t,`filter array for "${t[0]}" operator must have 2 elements`)):"object"!==n&&o.push(new ValidationError(`${i}[1]`,t[1],`object expected, ${n} found`))}return o}function Kr(e,t){const i=e.key,r=e.style,n=e.styleSpec,o=e.value,a=e.objectKey,s=n[`${t}_${e.layerType}`];if(!s)return[];const l=a.match(/^(.*)-transition$/);if("paint"===t&&l&&s[l[1]]&&s[l[1]].transition)return ln({key:i,value:o,valueSpec:n.transition,style:r,styleSpec:n});const c=e.valueSpec||s[a];if(!c)return[new ValidationError(i,o,`unknown property "${a}"`)];let u;if("string"===mr(o)&&pr(c)&&!c.tokens&&(u=/^{([^}]+)}$/.exec(o)))return[new ValidationError(i,o,`"${a}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(u[1])} }\`.`)];const h=[];return"symbol"===e.layerType&&("text-field"===a&&r&&!r.glyphs&&h.push(new ValidationError(i,o,'use of "text-field" requires a style "glyphs" property')),"text-font"===a&&_r(pt(o))&&"identity"===ht(o.type)&&h.push(new ValidationError(i,o,'"text-font" does not support identity functions'))),h.concat(ln({key:e.key,value:o,valueSpec:c,style:r,styleSpec:n,expressionContext:"property",propertyType:t,propertyKey:a}))}function Jr(e){return Kr(e,"paint")}function Yr(e){return Kr(e,"layout")}function Qr(e){let t=[];const i=e.value,r=e.key,n=e.style,o=e.styleSpec;i.type||i.ref||t.push(new ValidationError(r,i,'either "type" or "ref" is required'));let a=ht(i.type);const s=ht(i.ref);if(i.id){const o=ht(i.id);for(let a=0;a<e.arrayIndex;a++){const e=n.layers[a];ht(e.id)===o&&t.push(new ValidationError(r,i.id,`duplicate layer id "${i.id}", previously used at line ${e.id.__line__}`))}}if("ref"in i){let e;["type","source","source-layer","filter","layout"].forEach((e=>{e in i&&t.push(new ValidationError(r,i[e],`"${e}" is prohibited for ref layers`))})),n.layers.forEach((t=>{ht(t.id)===s&&(e=t)})),e?e.ref?t.push(new ValidationError(r,i.ref,"ref cannot reference another ref layer")):a=ht(e.type):"string"==typeof s&&t.push(new ValidationError(r,i.ref,`ref layer "${s}" not found`))}else if("background"!==a&&"sky"!==a)if(i.source){const e=n.sources&&n.sources[i.source],o=e&&ht(e.type);e?"vector"===o&&"raster"===a?t.push(new ValidationError(r,i.source,`layer "${i.id}" requires a raster source`)):"raster"===o&&"raster"!==a?t.push(new ValidationError(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==o||i["source-layer"]?"raster-dem"===o&&"hillshade"!==a?t.push(new ValidationError(r,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==a||!i.paint||!i.paint["line-gradient"]&&!i.paint["line-trim-offset"]||"geojson"===o&&e.lineMetrics||t.push(new ValidationError(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new ValidationError(r,i,`layer "${i.id}" must specify a "source-layer"`)):t.push(new ValidationError(r,i.source,`source "${i.source}" not found`))}else t.push(new ValidationError(r,i,'missing required property "source"'));return t=t.concat(Ir({key:r,value:i,valueSpec:o.layer,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":()=>[],type:()=>ln({key:`${r}.type`,value:i.type,valueSpec:o.layer.type,style:e.style,styleSpec:e.styleSpec,object:i,objectKey:"type"}),filter:e=>Hr(ut({layerType:a},e)),layout:e=>Ir({layer:i,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>Yr(ut({layerType:a},e))}}),paint:e=>Ir({layer:i,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>Jr(ut({layerType:a},e))}})}})),t}function en(e){const t=e.value,i=e.key,r=mr(t);return"string"!==r?[new ValidationError(i,t,`string expected, ${r} found`)]:[]}const tn={promoteId:function({key:e,value:t}){if("string"===mr(t))return en({key:e,value:t});{const i=[];for(const r in t)i.push(...en({key:`${e}.${r}`,value:t[r]}));return i}}};function rn(e){const t=e.value,i=e.key,r=e.styleSpec,n=e.style;if(!t.type)return[new ValidationError(i,t,'"type" is required')];const o=ht(t.type);let a;switch(o){case"vector":case"raster":case"raster-dem":return a=Ir({key:i,value:t,valueSpec:r[`source_${o.replace("-","_")}`],style:e.style,styleSpec:r,objectElementValidators:tn}),a;case"geojson":if(a=Ir({key:i,value:t,valueSpec:r.source_geojson,style:n,styleSpec:r,objectElementValidators:tn}),t.cluster)for(const e in t.clusterProperties){const[r,n]=t.clusterProperties[e],o="string"==typeof r?[r,["accumulated"],["get",e]]:r;a.push(...zr({key:`${i}.${e}.map`,value:n,expressionContext:"cluster-map"})),a.push(...zr({key:`${i}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return a;case"video":return Ir({key:i,value:t,valueSpec:r.source_video,style:n,styleSpec:r});case"image":return Ir({key:i,value:t,valueSpec:r.source_image,style:n,styleSpec:r});case"canvas":return[new ValidationError(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Lr({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:n,styleSpec:r})}}function nn(e){const t=e.value,i=e.styleSpec,r=i.light,n=e.style;let o=[];const a=mr(t);if(void 0===t)return o;if("object"!==a)return o=o.concat([new ValidationError("light",t,`object expected, ${a} found`)]),o;for(const e in t){const a=e.match(/^(.*)-transition$/);o=o.concat(a&&r[a[1]]&&r[a[1]].transition?ln({key:e,value:t[e],valueSpec:i.transition,style:n,styleSpec:i}):r[e]?ln({key:e,value:t[e],valueSpec:r[e],style:n,styleSpec:i}):[new ValidationError(e,t[e],`unknown property "${e}"`)])}return o}function on(e){const t=e.value,i=e.key,r=e.style,n=e.styleSpec,o=n.terrain;let a=[];const s=mr(t);if(void 0===t)return a;if("object"!==s)return a=a.concat([new ValidationError("terrain",t,`object expected, ${s} found`)]),a;for(const e in t){const i=e.match(/^(.*)-transition$/);a=a.concat(i&&o[i[1]]&&o[i[1]].transition?ln({key:e,value:t[e],valueSpec:n.transition,style:r,styleSpec:n}):o[e]?ln({key:e,value:t[e],valueSpec:o[e],style:r,styleSpec:n}):[new ValidationError(e,t[e],`unknown property "${e}"`)])}if(t.source){const e=r.sources&&r.sources[t.source],n=e&&ht(e.type);e?"raster-dem"!==n&&a.push(new ValidationError(i,t.source,`terrain cannot be used with a source of type ${String(n)}, it only be used with a "raster-dem" source type`)):a.push(new ValidationError(i,t.source,`source "${t.source}" not found`))}else a.push(new ValidationError(i,t,'terrain is missing required property "source"'));return a}function an(e){const t=e.value,i=e.style,r=e.styleSpec,n=r.fog;let o=[];const a=mr(t);if(void 0===t)return o;if("object"!==a)return o=o.concat([new ValidationError("fog",t,`object expected, ${a} found`)]),o;for(const e in t){const a=e.match(/^(.*)-transition$/);o=o.concat(a&&n[a[1]]&&n[a[1]].transition?ln({key:e,value:t[e],valueSpec:r.transition,style:i,styleSpec:r}):n[e]?ln({key:e,value:t[e],valueSpec:n[e],style:i,styleSpec:r}):[new ValidationError(e,t[e],`unknown property "${e}"`)])}return o}const sn={"*":()=>[],array:Mr,boolean:function(e){const t=e.value,i=e.key,r=mr(t);return"boolean"!==r?[new ValidationError(i,t,`boolean expected, ${r} found`)]:[]},number:Pr,color:function(e){const t=e.key,i=e.value,r=mr(i);return"string"!==r?[new ValidationError(t,i,`color expected, ${r} found`)]:null===kt.parseCSSColor(i)?[new ValidationError(t,i,`color expected, "${i}" found`)]:[]},enum:Lr,filter:Hr,function:Dr,layer:Qr,object:Ir,source:rn,light:nn,terrain:on,fog:an,string:en,formatted:function(e){return 0===en(e).length?[]:zr(e)},resolvedImage:function(e){return 0===en(e).length?[]:zr(e)},projection:function(e){const t=e.value,i=e.styleSpec,r=i.projection,n=e.style;let o=[];const a=mr(t);if("object"===a)for(const e in t)o=o.concat(ln({key:e,value:t[e],valueSpec:r[e],style:n,styleSpec:i}));else"string"!==a&&(o=o.concat([new ValidationError("projection",t,`object or string expected, ${a} found`)]));return o}};function ln(e){const t=e.value,i=e.valueSpec,r=e.styleSpec;return i.expression&&_r(ht(t))?Dr(e):i.expression&&Er(pt(t))?zr(e):i.type&&sn[i.type]?sn[i.type](e):Ir(ut({},e,{valueSpec:i.type?r[i.type]:i}))}function cn(e){const t=e.value,i=e.key,r=en(e);return r.length||(-1===t.indexOf("{fontstack}")&&r.push(new ValidationError(i,t,'"glyphs" url must include a "{fontstack}" token')),-1===t.indexOf("{range}")&&r.push(new ValidationError(i,t,'"glyphs" url must include a "{range}" token'))),r}function un(e,t=ct){return xn(ln({key:"",value:e,valueSpec:t.$root,styleSpec:t,style:e,objectElementValidators:{glyphs:cn,"*":()=>[]}}))}const hn=e=>xn(rn(e)),pn=e=>xn(nn(e)),dn=e=>xn(on(e)),fn=e=>xn(an(e)),mn=e=>xn(Qr(e)),_n=e=>xn(Hr(e)),gn=e=>xn(Jr(e)),yn=e=>xn(Yr(e));function xn(e){return e.slice().sort(((e,t)=>e.line&&t.line?e.line-t.line:0))}function vn(e,t){let i=!1;if(t&&t.length)for(const r of t)e.fire(new ErrorEvent(new Error(r.message))),i=!0;return i}var bn=wn;function wn(e,t,i){var r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var n=new Int32Array(this.arrayBuffer);e=n[0],this.d=(t=n[1])+2*(i=n[2]);for(var o=0;o<this.d*this.d;o++){var a=n[3+o],s=n[3+o+1];r.push(a===s?null:n.subarray(a,s))}var l=n[3+r.length+1];this.keys=n.subarray(n[3+r.length],l),this.bboxes=n.subarray(l),this.insert=this._insertReadonly}else{this.d=t+2*i;for(var c=0;c<this.d*this.d;c++)r.push([]);this.keys=[],this.bboxes=[]}this.n=t,this.extent=e,this.padding=i,this.scale=t/e,this.uid=0;var u=i/t*e;this.min=-u,this.max=e+u}wn.prototype.insert=function(e,t,i,r,n){this._forEachCell(t,i,r,n,this._insertCell,this.uid++),this.keys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)},wn.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},wn.prototype._insertCell=function(e,t,i,r,n,o){this.cells[n].push(o)},wn.prototype.query=function(e,t,i,r,n){var o=this.min,a=this.max;if(e<=o&&t<=o&&a<=i&&a<=r&&!n)return Array.prototype.slice.call(this.keys);var s=[];return this._forEachCell(e,t,i,r,this._queryCell,s,{},n),s},wn.prototype._queryCell=function(e,t,i,r,n,o,a,s){var l=this.cells[n];if(null!==l)for(var c=this.keys,u=this.bboxes,h=0;h<l.length;h++){var p=l[h];if(void 0===a[p]){var d=4*p;(s?s(u[d+0],u[d+1],u[d+2],u[d+3]):e<=u[d+2]&&t<=u[d+3]&&i>=u[d+0]&&r>=u[d+1])?(a[p]=!0,o.push(c[p])):a[p]=!1}}},wn.prototype._forEachCell=function(e,t,i,r,n,o,a,s){for(var l=this._convertToCellCoord(e),c=this._convertToCellCoord(t),u=this._convertToCellCoord(i),h=this._convertToCellCoord(r),p=l;p<=u;p++)for(var d=c;d<=h;d++){var f=this.d*d+p;if((!s||s(this._convertFromCellCoord(p),this._convertFromCellCoord(d),this._convertFromCellCoord(p+1),this._convertFromCellCoord(d+1)))&&n.call(this,e,t,i,r,f,o,a,s))return}},wn.prototype._convertFromCellCoord=function(e){return(e-this.padding)/this.scale},wn.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},wn.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var e=this.cells,t=3+this.cells.length+1+1,i=0,r=0;r<this.cells.length;r++)i+=this.cells[r].length;var n=new Int32Array(t+i+this.keys.length+this.bboxes.length);n[0]=this.extent,n[1]=this.n,n[2]=this.padding;for(var o=t,a=0;a<e.length;a++){var s=e[a];n[3+a]=o,n.set(s,o),o+=s.length}return n[3+e.length]=o,n.set(this.keys,o),n[3+e.length+1]=o+=this.keys.length,n.set(this.bboxes,o),o+=this.bboxes.length,n.buffer};const Tn={};function En(e,t,i={}){Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),Tn[t]={klass:e,omit:i.omit||[]}}En(Object,"Object"),bn.serialize=function(e,t){const i=e.toArrayBuffer();return t&&t.push(i),{buffer:i}},bn.deserialize=function(e){return new bn(e.buffer)},Object.defineProperty(bn,"name",{value:"Grid"}),En(bn,"Grid"),En(Lt,"Color"),En(Error,"Error"),En(AJAXError,"AJAXError"),En(ResolvedImage,"ResolvedImage"),En(StylePropertyFunction,"StylePropertyFunction"),En(StyleExpression,"StyleExpression",{omit:["_evaluator"]}),En(ZoomDependentExpression,"ZoomDependentExpression"),En(ZoomConstantExpression,"ZoomConstantExpression"),En(Wt,"CompoundExpression",{omit:["_evaluate"]});for(const e in cr)Tn[cr[e]._classRegistryKey]||En(cr[e],`Expression${e}`);function Sn(e){return e&&"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}function An(t){return e.ImageBitmap&&t instanceof e.ImageBitmap}function Cn(t,i){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp)return t;if(Sn(t)||An(t))return i&&i.push(t),t;if(ArrayBuffer.isView(t)){const e=t;return i&&i.push(e.buffer),e}if(t instanceof e.ImageData)return i&&i.push(t.data.buffer),t;if(Array.isArray(t)){const e=[];for(const r of t)e.push(Cn(r,i));return e}if("object"==typeof t){const e=t.constructor,r=e._classRegistryKey;if(!r)throw new Error(`can't serialize object of unregistered class ${r}`);const n=e.serialize?e.serialize(t,i):{};if(!e.serialize){for(const e in t)t.hasOwnProperty(e)&&(Tn[r].omit.indexOf(e)>=0||(n[e]=Cn(t[e],i)));t instanceof Error&&(n.message=t.message)}if(n.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(n.$name=r),n}throw new Error("can't serialize object of type "+typeof t)}function Mn(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||Sn(t)||An(t)||ArrayBuffer.isView(t)||t instanceof e.ImageData)return t;if(Array.isArray(t))return t.map(Mn);if("object"==typeof t){const e=t.$name||"Object",{klass:i}=Tn[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const r=Object.create(i.prototype);for(const e of Object.keys(t))"$name"!==e&&(r[e]=Mn(t[e]));return r}throw new Error("can't deserialize object of type "+typeof t)}class ZoomHistory{constructor(){this.first=!0}update(e,t){const i=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=t):this.lastFloorZoom<i&&(this.lastIntegerZoom=i,this.lastIntegerZoomTime=t),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=i,!0))}}const Pn=e=>e>=12288&&e<=12351,Dn=e=>e>=12352&&e<=12447,zn=e=>e>=12448&&e<=12543,kn=e=>e>=19968&&e<=40959,Ln=e=>e>=44032&&e<=55215;function Bn(e){for(const t of e)if(Rn(t.charCodeAt(0)))return!0;return!1}function Rn(e){return!(746!==e&&747!==e&&(e<4352||!((e=>e>=12704&&e<=12735)(e)||(e=>e>=12544&&e<=12591)(e)||(e=>e>=65072&&e<=65103)(e)&&!(e>=65097&&e<=65103)||(e=>e>=63744&&e<=64255)(e)||(e=>e>=13056&&e<=13311)(e)||(e=>e>=11904&&e<=12031)(e)||(e=>e>=12736&&e<=12783)(e)||!(!Pn(e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||(e=>e>=13312&&e<=19903)(e)||kn(e)||(e=>e>=12800&&e<=13055)(e)||(e=>e>=12592&&e<=12687)(e)||(e=>e>=43360&&e<=43391)(e)||(e=>e>=55216&&e<=55295)(e)||(e=>e>=4352&&e<=4607)(e)||Ln(e)||Dn(e)||(e=>e>=12272&&e<=12287)(e)||(e=>e>=12688&&e<=12703)(e)||(e=>e>=12032&&e<=12255)(e)||(e=>e>=12784&&e<=12799)(e)||zn(e)&&12540!==e||!(!(e=>e>=65280&&e<=65519)(e)||65288===e||65289===e||65293===e||e>=65306&&e<=65310||65339===e||65341===e||65343===e||e>=65371&&e<=65503||65507===e||e>=65512&&e<=65519)||!(!(e=>e>=65104&&e<=65135)(e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||(e=>e>=5120&&e<=5759)(e)||(e=>e>=6320&&e<=6399)(e)||(e=>e>=65040&&e<=65055)(e)||(e=>e>=19904&&e<=19967)(e)||(e=>e>=40960&&e<=42127)(e)||(e=>e>=42128&&e<=42191)(e))))}function Fn(e){return e>=1424&&e<=2303||(e=>e>=64336&&e<=65023)(e)||(e=>e>=65136&&e<=65279)(e)}function On(e,t){return!(!t&&Fn(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||(e=>e>=6016&&e<=6143)(e))}function Vn(e){for(const t of e)if(Fn(t.charCodeAt(0)))return!0;return!1}const Un="deferred",jn="loading",Nn="loaded";let Gn=null,Zn="unavailable",qn=null;const $n=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(Zn="error"),Gn&&Gn(e)};function Wn(){Hn.fire(new Event("pluginStateChange",{pluginStatus:Zn,pluginURL:qn}))}const Hn=new Evented,Xn=function(){return Zn},Kn=function(){if(Zn!==Un||!qn)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Zn=jn,Wn(),qn&&Qe({url:qn},(e=>{e?$n(e):(Zn=Nn,Wn())}))},Jn={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Zn===Nn||null!=Jn.applyArabicShaping,isLoading:()=>Zn===jn,setState(e){Zn=e.pluginStatus,qn=e.pluginURL},isParsed:()=>null!=Jn.applyArabicShaping,getPluginURL:()=>qn};class EvaluationParameters{constructor(e,t){this.zoom=e,t?(this.now=t.now,this.fadeDuration=t.fadeDuration,this.zoomHistory=t.zoomHistory,this.transition=t.transition,this.pitch=t.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new ZoomHistory,this.transition={},this.pitch=0)}isSupportedScript(e){return function(e,t){for(const i of e)if(!On(i.charCodeAt(0),t))return!1;return!0}(e,Jn.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,t=e-Math.floor(e),i=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:t+(1-t)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*t}}}class PropertyValue{constructor(e,t){this.property=e,this.value=t,this.expression=function(e,t){if(_r(e))return new StylePropertyFunction(e,t);if(Er(e)){const i=Ar(e,t);if("error"===i.result)throw new Error(i.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return i.value}{let i=e;return"string"==typeof e&&"color"===t.type&&(i=Lt.parse(e)),{kind:"constant",evaluate:()=>i}}}(void 0===t?e.specification.default:t,e.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,i){return this.property.possiblyEvaluate(this,e,t,i)}}class TransitionablePropertyValue{constructor(e){this.property=e,this.value=new PropertyValue(e,void 0)}transitioned(e,t){return new TransitioningPropertyValue(this.property,this.value,t,b({},e.transition,this.transition),e.now)}untransitioned(){return new TransitioningPropertyValue(this.property,this.value,null,{},0)}}class Transitionable{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return z(this._values[e].value.value)}setValue(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new TransitionablePropertyValue(this._values[e].property)),this._values[e].value=new PropertyValue(this._values[e].property,null===t?void 0:z(t))}getTransition(e){return z(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new TransitionablePropertyValue(this._values[e].property)),this._values[e].transition=z(t)||void 0}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i);const r=this.getTransition(t);void 0!==r&&(e[`${t}-transition`]=r)}return e}transitioned(e,t){const i=new Transitioning(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(e,t._values[r]);return i}untransitioned(){const e=new Transitioning(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class TransitioningPropertyValue{constructor(e,t,i,r,n){const o=r.delay||0,a=r.duration||0;n=n||0,this.property=e,this.value=t,this.begin=n+o,this.end=this.begin+a,e.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(e,t,i){const r=e.now||0,n=this.value.possiblyEvaluate(e,t,i),o=this.prior;if(o){if(r>this.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(r<this.begin)return o.possiblyEvaluate(e,t,i);{const a=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(o.possiblyEvaluate(e,t,i),n,h(a))}}return n}}class Transitioning{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,t,i){const r=new PossiblyEvaluated(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(e,t,i);return r}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class Layout{constructor(e){this._properties=e,this._values=Object.create(e.defaultPropertyValues)}getValue(e){return z(this._values[e].value)}setValue(e,t){this._values[e]=new PropertyValue(this._values[e].property,null===t?void 0:z(t))}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i)}return e}possiblyEvaluate(e,t,i){const r=new PossiblyEvaluated(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(e,t,i);return r}}class PossiblyEvaluatedPropertyValue{constructor(e,t,i){this.property=e,this.value=t,this.parameters=i}isConstant(){return"constant"===this.value.kind}constantOr(e){return"constant"===this.value.kind?this.value.value:e}evaluate(e,t,i,r){return this.property.evaluate(this.value,this.parameters,e,t,i,r)}}class PossiblyEvaluated{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class DataConstantProperty{constructor(e){this.specification=e}possiblyEvaluate(e,t){return e.expression.evaluate(t)}interpolate(e,t,i){const r=bi[this.specification.type];return r?r(e,t,i):e}}class DataDrivenProperty{constructor(e,t){this.specification=e,this.overrides=t}possiblyEvaluate(e,t,i,r){return new PossiblyEvaluatedPropertyValue(this,"constant"===e.expression.kind||"camera"===e.expression.kind?{kind:"constant",value:e.expression.evaluate(t,null,{},i,r)}:e.expression,t)}interpolate(e,t,i){if("constant"!==e.value.kind||"constant"!==t.value.kind)return e;if(void 0===e.value.value||void 0===t.value.value)return new PossiblyEvaluatedPropertyValue(this,{kind:"constant",value:void 0},e.parameters);const r=bi[this.specification.type];return r?new PossiblyEvaluatedPropertyValue(this,{kind:"constant",value:r(e.value.value,t.value.value,i)},e.parameters):e}evaluate(e,t,i,r,n,o){return"constant"===e.kind?e.value:e.evaluate(t,i,r,n,o)}}class CrossFadedDataDrivenProperty extends DataDrivenProperty{possiblyEvaluate(e,t,i,r){if(void 0===e.value)return new PossiblyEvaluatedPropertyValue(this,{kind:"constant",value:void 0},t);if("constant"===e.expression.kind){const n=e.expression.evaluate(t,null,{},i,r),o="resolvedImage"===e.property.specification.type&&"string"!=typeof n?n.name:n,a=this._calculate(o,o,o,t);return new PossiblyEvaluatedPropertyValue(this,{kind:"constant",value:a},t)}if("camera"===e.expression.kind){const i=this._calculate(e.expression.evaluate({zoom:t.zoom-1}),e.expression.evaluate({zoom:t.zoom}),e.expression.evaluate({zoom:t.zoom+1}),t);return new PossiblyEvaluatedPropertyValue(this,{kind:"constant",value:i},t)}return new PossiblyEvaluatedPropertyValue(this,e.expression,t)}evaluate(e,t,i,r,n,o){if("source"===e.kind){const a=e.evaluate(t,i,r,n,o);return this._calculate(a,a,a,t)}return"composite"===e.kind?this._calculate(e.evaluate({zoom:Math.floor(t.zoom)-1},i,r),e.evaluate({zoom:Math.floor(t.zoom)},i,r),e.evaluate({zoom:Math.floor(t.zoom)+1},i,r),t):e.value}_calculate(e,t,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t,other:i}:{from:i,to:t,other:e}}interpolate(e){return e}}class CrossFadedProperty{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,r){if(void 0!==e.value){if("constant"===e.expression.kind){const n=e.expression.evaluate(t,null,{},i,r);return this._calculate(n,n,n,t)}return this._calculate(e.expression.evaluate(new EvaluationParameters(Math.floor(t.zoom-1),t)),e.expression.evaluate(new EvaluationParameters(Math.floor(t.zoom),t)),e.expression.evaluate(new EvaluationParameters(Math.floor(t.zoom+1),t)),t)}}_calculate(e,t,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}}class ColorRampProperty{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,r){return!!e.expression.evaluate(t,null,{},i,r)}interpolate(){return!1}}class Properties{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const t=new EvaluationParameters(0,{});for(const i in e){const r=e[i];r.specification.overridable&&this.overridableProperties.push(i);const n=this.defaultPropertyValues[i]=new PropertyValue(r,void 0),o=this.defaultTransitionablePropertyValues[i]=new TransitionablePropertyValue(r);this.defaultTransitioningPropertyValues[i]=o.untransitioned(),this.defaultPossiblyEvaluatedValues[i]=n.possiblyEvaluate(t)}}}function Yn(e,t){return 256*(e=_(Math.floor(e),0,255))+_(Math.floor(t),0,255)}En(DataDrivenProperty,"DataDrivenProperty"),En(DataConstantProperty,"DataConstantProperty"),En(CrossFadedDataDrivenProperty,"CrossFadedDataDrivenProperty"),En(CrossFadedProperty,"CrossFadedProperty"),En(ColorRampProperty,"ColorRampProperty");const Qn={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Struct{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class StructArray{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}_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(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function eo(e,t=1){let i=0,r=0;return{members:e.map((e=>{const n=Qn[e.type].BYTES_PER_ELEMENT,o=i=to(i,Math.max(t,n)),a=e.components||1;return r=Math.max(r,n),i+=n*a,{name:e.name,type:e.type,components:a,offset:o}})),size:to(i,Math.max(r,t)),alignment:t}}function to(e,t){return Math.ceil(e/t)*t}class StructArrayLayout2i4 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.int16[r+0]=t,this.int16[r+1]=i,e}}StructArrayLayout2i4.prototype.bytesPerElement=4,En(StructArrayLayout2i4,"StructArrayLayout2i4");class StructArrayLayout3i6 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.int16[n+0]=t,this.int16[n+1]=i,this.int16[n+2]=r,e}}StructArrayLayout3i6.prototype.bytesPerElement=6,En(StructArrayLayout3i6,"StructArrayLayout3i6");class StructArrayLayout4i8 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=n,e}}StructArrayLayout4i8.prototype.bytesPerElement=8,En(StructArrayLayout4i8,"StructArrayLayout4i8");class StructArrayLayout2i4ub1f12 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,a){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o,a)}emplace(e,t,i,r,n,o,a,s){const l=6*e,c=12*e,u=3*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.uint8[c+4]=r,this.uint8[c+5]=n,this.uint8[c+6]=o,this.uint8[c+7]=a,this.float32[u+2]=s,e}}StructArrayLayout2i4ub1f12.prototype.bytesPerElement=12,En(StructArrayLayout2i4ub1f12,"StructArrayLayout2i4ub1f12");class StructArrayLayout4f16 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=r,this.float32[o+3]=n,e}}StructArrayLayout4f16.prototype.bytesPerElement=16,En(StructArrayLayout4f16,"StructArrayLayout4f16");class StructArrayLayout10ui20 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,a,s,l,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,t,i,r,n,o,a,s,l,c)}emplace(e,t,i,r,n,o,a,s,l,c,u){const h=10*e;return this.uint16[h+0]=t,this.uint16[h+1]=i,this.uint16[h+2]=r,this.uint16[h+3]=n,this.uint16[h+4]=o,this.uint16[h+5]=a,this.uint16[h+6]=s,this.uint16[h+7]=l,this.uint16[h+8]=c,this.uint16[h+9]=u,e}}StructArrayLayout10ui20.prototype.bytesPerElement=20,En(StructArrayLayout10ui20,"StructArrayLayout10ui20");class StructArrayLayout8ui16 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,a,s){const l=this.length;return this.resize(l+1),this.emplace(l,e,t,i,r,n,o,a,s)}emplace(e,t,i,r,n,o,a,s,l){const c=8*e;return this.uint16[c+0]=t,this.uint16[c+1]=i,this.uint16[c+2]=r,this.uint16[c+3]=n,this.uint16[c+4]=o,this.uint16[c+5]=a,this.uint16[c+6]=s,this.uint16[c+7]=l,e}}StructArrayLayout8ui16.prototype.bytesPerElement=16,En(StructArrayLayout8ui16,"StructArrayLayout8ui16");class StructArrayLayout6i12 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,a){const s=6*e;return this.int16[s+0]=t,this.int16[s+1]=i,this.int16[s+2]=r,this.int16[s+3]=n,this.int16[s+4]=o,this.int16[s+5]=a,e}}StructArrayLayout6i12.prototype.bytesPerElement=12,En(StructArrayLayout6i12,"StructArrayLayout6i12");class StructArrayLayout4i4ui4i24 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,a,s,l,c,u,h){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,i,r,n,o,a,s,l,c,u,h)}emplace(e,t,i,r,n,o,a,s,l,c,u,h,p){const d=12*e;return this.int16[d+0]=t,this.int16[d+1]=i,this.int16[d+2]=r,this.int16[d+3]=n,this.uint16[d+4]=o,this.uint16[d+5]=a,this.uint16[d+6]=s,this.uint16[d+7]=l,this.int16[d+8]=c,this.int16[d+9]=u,this.int16[d+10]=h,this.int16[d+11]=p,e}}StructArrayLayout4i4ui4i24.prototype.bytesPerElement=24,En(StructArrayLayout4i4ui4i24,"StructArrayLayout4i4ui4i24");class StructArrayLayout3i3f20 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,a){const s=10*e,l=5*e;return this.int16[s+0]=t,this.int16[s+1]=i,this.int16[s+2]=r,this.float32[l+2]=n,this.float32[l+3]=o,this.float32[l+4]=a,e}}StructArrayLayout3i3f20.prototype.bytesPerElement=20,En(StructArrayLayout3i3f20,"StructArrayLayout3i3f20");class StructArrayLayout1ul4 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}StructArrayLayout1ul4.prototype.bytesPerElement=4,En(StructArrayLayout1ul4,"StructArrayLayout1ul4");class StructArrayLayout5i4f1i1ul2ui40 extends StructArray{_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(e,t,i,r,n,o,a,s,l,c,u,h,p){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,i,r,n,o,a,s,l,c,u,h,p)}emplace(e,t,i,r,n,o,a,s,l,c,u,h,p,d){const f=20*e,m=10*e;return this.int16[f+0]=t,this.int16[f+1]=i,this.int16[f+2]=r,this.int16[f+3]=n,this.int16[f+4]=o,this.float32[m+3]=a,this.float32[m+4]=s,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=u,this.uint32[m+8]=h,this.uint16[f+18]=p,this.uint16[f+19]=d,e}}StructArrayLayout5i4f1i1ul2ui40.prototype.bytesPerElement=40,En(StructArrayLayout5i4f1i1ul2ui40,"StructArrayLayout5i4f1i1ul2ui40");class StructArrayLayout3i2i2i16 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,a){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o,a)}emplace(e,t,i,r,n,o,a,s){const l=8*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.int16[l+2]=r,this.int16[l+4]=n,this.int16[l+5]=o,this.int16[l+6]=a,this.int16[l+7]=s,e}}StructArrayLayout3i2i2i16.prototype.bytesPerElement=16,En(StructArrayLayout3i2i2i16,"StructArrayLayout3i2i2i16");class StructArrayLayout2f1f2i16 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const a=4*e,s=8*e;return this.float32[a+0]=t,this.float32[a+1]=i,this.float32[a+2]=r,this.int16[s+6]=n,this.int16[s+7]=o,e}}StructArrayLayout2f1f2i16.prototype.bytesPerElement=16,En(StructArrayLayout2f1f2i16,"StructArrayLayout2f1f2i16");class StructArrayLayout2ub2f12 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=12*e,a=3*e;return this.uint8[o+0]=t,this.uint8[o+1]=i,this.float32[a+1]=r,this.float32[a+2]=n,e}}StructArrayLayout2ub2f12.prototype.bytesPerElement=12,En(StructArrayLayout2ub2f12,"StructArrayLayout2ub2f12");class StructArrayLayout3f12 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.float32[n+0]=t,this.float32[n+1]=i,this.float32[n+2]=r,e}}StructArrayLayout3f12.prototype.bytesPerElement=12,En(StructArrayLayout3f12,"StructArrayLayout3f12");class StructArrayLayout3ui6 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.uint16[n+0]=t,this.uint16[n+1]=i,this.uint16[n+2]=r,e}}StructArrayLayout3ui6.prototype.bytesPerElement=6,En(StructArrayLayout3ui6,"StructArrayLayout3ui6");class StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60 extends StructArray{_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(e,t,i,r,n,o,a,s,l,c,u,h,p,d,f,m,_,g,y,x,v){const b=this.length;return this.resize(b+1),this.emplace(b,e,t,i,r,n,o,a,s,l,c,u,h,p,d,f,m,_,g,y,x,v)}emplace(e,t,i,r,n,o,a,s,l,c,u,h,p,d,f,m,_,g,y,x,v,b){const w=30*e,T=15*e,E=60*e;return this.int16[w+0]=t,this.int16[w+1]=i,this.int16[w+2]=r,this.float32[T+2]=n,this.float32[T+3]=o,this.uint16[w+8]=a,this.uint16[w+9]=s,this.uint32[T+5]=l,this.uint32[T+6]=c,this.uint32[T+7]=u,this.uint16[w+16]=h,this.uint16[w+17]=p,this.uint16[w+18]=d,this.float32[T+10]=f,this.float32[T+11]=m,this.uint8[E+48]=_,this.uint8[E+49]=g,this.uint8[E+50]=y,this.uint32[T+13]=x,this.int16[w+28]=v,this.uint8[E+58]=b,e}}StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60.prototype.bytesPerElement=60,En(StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class StructArrayLayout3i2f6i15ui1ul3f76 extends StructArray{_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(e,t,i,r,n,o,a,s,l,c,u,h,p,d,f,m,_,g,y,x,v,b,w,T,E,S,A,C,I,M){const P=this.length;return this.resize(P+1),this.emplace(P,e,t,i,r,n,o,a,s,l,c,u,h,p,d,f,m,_,g,y,x,v,b,w,T,E,S,A,C,I,M)}emplace(e,t,i,r,n,o,a,s,l,c,u,h,p,d,f,m,_,g,y,x,v,b,w,T,E,S,A,C,I,M,P){const D=38*e,z=19*e;return this.int16[D+0]=t,this.int16[D+1]=i,this.int16[D+2]=r,this.float32[z+2]=n,this.float32[z+3]=o,this.int16[D+8]=a,this.int16[D+9]=s,this.int16[D+10]=l,this.int16[D+11]=c,this.int16[D+12]=u,this.int16[D+13]=h,this.uint16[D+14]=p,this.uint16[D+15]=d,this.uint16[D+16]=f,this.uint16[D+17]=m,this.uint16[D+18]=_,this.uint16[D+19]=g,this.uint16[D+20]=y,this.uint16[D+21]=x,this.uint16[D+22]=v,this.uint16[D+23]=b,this.uint16[D+24]=w,this.uint16[D+25]=T,this.uint16[D+26]=E,this.uint16[D+27]=S,this.uint16[D+28]=A,this.uint32[z+15]=C,this.float32[z+16]=I,this.float32[z+17]=M,this.float32[z+18]=P,e}}StructArrayLayout3i2f6i15ui1ul3f76.prototype.bytesPerElement=76,En(StructArrayLayout3i2f6i15ui1ul3f76,"StructArrayLayout3i2f6i15ui1ul3f76");class StructArrayLayout1f4 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}StructArrayLayout1f4.prototype.bytesPerElement=4,En(StructArrayLayout1f4,"StructArrayLayout1f4");class StructArrayLayout5f20 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const a=5*e;return this.float32[a+0]=t,this.float32[a+1]=i,this.float32[a+2]=r,this.float32[a+3]=n,this.float32[a+4]=o,e}}StructArrayLayout5f20.prototype.bytesPerElement=20,En(StructArrayLayout5f20,"StructArrayLayout5f20");class StructArrayLayout1ul3ui12 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=6*e;return this.uint32[3*e+0]=t,this.uint16[o+2]=i,this.uint16[o+3]=r,this.uint16[o+4]=n,e}}StructArrayLayout1ul3ui12.prototype.bytesPerElement=12,En(StructArrayLayout1ul3ui12,"StructArrayLayout1ul3ui12");class StructArrayLayout2ui4 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.uint16[r+0]=t,this.uint16[r+1]=i,e}}StructArrayLayout2ui4.prototype.bytesPerElement=4,En(StructArrayLayout2ui4,"StructArrayLayout2ui4");class StructArrayLayout1ui2 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}StructArrayLayout1ui2.prototype.bytesPerElement=2,En(StructArrayLayout1ui2,"StructArrayLayout1ui2");class StructArrayLayout2f8 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.float32[r+0]=t,this.float32[r+1]=i,e}}StructArrayLayout2f8.prototype.bytesPerElement=8,En(StructArrayLayout2f8,"StructArrayLayout2f8");class FillExtrusionExtStruct extends Struct{get a_pos_30(){return this._structArray.int16[this._pos2+0]}get a_pos_31(){return this._structArray.int16[this._pos2+1]}get a_pos_32(){return this._structArray.int16[this._pos2+2]}get a_pos_normal_30(){return this._structArray.int16[this._pos2+3]}get a_pos_normal_31(){return this._structArray.int16[this._pos2+4]}get a_pos_normal_32(){return this._structArray.int16[this._pos2+5]}}FillExtrusionExtStruct.prototype.size=12;class FillExtrusionExtArray extends StructArrayLayout6i12{get(e){return new FillExtrusionExtStruct(this,e)}}En(FillExtrusionExtArray,"FillExtrusionExtArray");class CollisionBoxStruct extends Struct{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]}}CollisionBoxStruct.prototype.size=40;class CollisionBoxArray extends StructArrayLayout5i4f1i1ul2ui40{get(e){return new CollisionBoxStruct(this,e)}}En(CollisionBoxArray,"CollisionBoxArray");class PlacedSymbolStruct extends Struct{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(e){this._structArray.uint8[this._pos1+49]=e}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(e){this._structArray.uint8[this._pos1+50]=e}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(e){this._structArray.uint32[this._pos4+13]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(e){this._structArray.uint8[this._pos1+58]=e}}PlacedSymbolStruct.prototype.size=60;class PlacedSymbolArray extends StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60{get(e){return new PlacedSymbolStruct(this,e)}}En(PlacedSymbolArray,"PlacedSymbolArray");class SymbolInstanceStruct extends Struct{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(e){this._structArray.uint32[this._pos4+15]=e}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]}}SymbolInstanceStruct.prototype.size=76;class SymbolInstanceArray extends StructArrayLayout3i2f6i15ui1ul3f76{get(e){return new SymbolInstanceStruct(this,e)}}En(SymbolInstanceArray,"SymbolInstanceArray");class GlyphOffsetArray extends StructArrayLayout1f4{getoffsetX(e){return this.float32[1*e+0]}}En(GlyphOffsetArray,"GlyphOffsetArray");class SymbolLineVertexArray extends StructArrayLayout3i6{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}En(SymbolLineVertexArray,"SymbolLineVertexArray");class FeatureIndexStruct extends Struct{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]}}FeatureIndexStruct.prototype.size=12;class FeatureIndexArray extends StructArrayLayout1ul3ui12{get(e){return new FeatureIndexStruct(this,e)}}En(FeatureIndexArray,"FeatureIndexArray");class FillExtrusionCentroidStruct extends Struct{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}FillExtrusionCentroidStruct.prototype.size=4;class FillExtrusionCentroidArray extends StructArrayLayout2ui4{get(e){return new FillExtrusionCentroidStruct(this,e)}}En(FillExtrusionCentroidArray,"FillExtrusionCentroidArray");class CircleGlobeExtStruct extends Struct{get a_pos_30(){return this._structArray.int16[this._pos2+0]}get a_pos_31(){return this._structArray.int16[this._pos2+1]}get a_pos_32(){return this._structArray.int16[this._pos2+2]}get a_pos_normal_30(){return this._structArray.int16[this._pos2+3]}get a_pos_normal_31(){return this._structArray.int16[this._pos2+4]}get a_pos_normal_32(){return this._structArray.int16[this._pos2+5]}}CircleGlobeExtStruct.prototype.size=12;class CircleGlobeExtArray extends StructArrayLayout6i12{get(e){return new CircleGlobeExtStruct(this,e)}}En(CircleGlobeExtArray,"CircleGlobeExtArray");const io=eo([{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"}]),ro=eo([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var no=zt((function(e){e.exports=function(e,t){var i,r,n,o,a,s,l,c;for(r=e.length-(i=3&e.length),n=t,a=3432918353,s=461845907,c=0;c<r;)l=255&e.charCodeAt(c)|(255&e.charCodeAt(++c))<<8|(255&e.charCodeAt(++c))<<16|(255&e.charCodeAt(++c))<<24,++c,n=27492+(65535&(o=5*(65535&(n=(n^=l=(65535&(l=(l=(65535&l)*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&e.charCodeAt(c+2))<<16;case 2:l^=(255&e.charCodeAt(c+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(c)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295}return n^=e.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0}})),oo=zt((function(e){e.exports=function(e,t){for(var i,r=e.length,n=t^r,o=0;r>=4;)i=1540483477*(65535&(i=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(i>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:n^=(255&e.charCodeAt(o+2))<<16;case 2:n^=(255&e.charCodeAt(o+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(o)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}})),ao=no,so=oo;ao.murmur3=no,ao.murmur2=so;class FeaturePositionMap{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,i,r){this.ids.push(lo(e)),this.positions.push(t,i,r)}getPositions(e){const t=lo(e);let i=0,r=this.ids.length-1;for(;i<r;){const e=i+r>>1;this.ids[e]>=t?r=e:i=e+1}const n=[];for(;this.ids[i]===t;)n.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return n}static serialize(e,t){const i=new Float64Array(e.ids),r=new Uint32Array(e.positions);return co(i,r,0,i.length-1),t&&t.push(i.buffer,r.buffer),{ids:i,positions:r}}static deserialize(e){const t=new FeaturePositionMap;return t.ids=e.ids,t.positions=e.positions,t.indexed=!0,t}}function lo(e){const t=+e;return!isNaN(t)&&Number.MIN_SAFE_INTEGER<=t&&t<=Number.MAX_SAFE_INTEGER?t:ao(String(e))}function co(e,t,i,r){for(;i<r;){const n=e[i+r>>1];let o=i-1,a=r+1;for(;;){do{o++}while(e[o]<n);do{a--}while(e[a]>n);if(o>=a)break;uo(e,o,a),uo(t,3*o,3*a),uo(t,3*o+1,3*a+1),uo(t,3*o+2,3*a+2)}a-i<r-a?(co(e,t,i,a),i=a+1):(co(e,t,a+1,r),r=a)}}function uo(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}En(FeaturePositionMap,"FeaturePositionMap");class Uniform{constructor(e){this.gl=e.gl,this.initialized=!1}fetchUniformLocation(e,t){return this.location||this.initialized||(this.location=this.gl.getUniformLocation(e,t),this.initialized=!0),!!this.location}}class Uniform1i extends Uniform{constructor(e){super(e),this.current=0}set(e,t,i){this.fetchUniformLocation(e,t)&&this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}}class Uniform1f extends Uniform{constructor(e){super(e),this.current=0}set(e,t,i){this.fetchUniformLocation(e,t)&&this.current!==i&&(this.current=i,this.gl.uniform1f(this.location,i))}}class Uniform2f extends Uniform{constructor(e){super(e),this.current=[0,0]}set(e,t,i){this.fetchUniformLocation(e,t)&&(i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1])))}}class Uniform3f extends Uniform{constructor(e){super(e),this.current=[0,0,0]}set(e,t,i){this.fetchUniformLocation(e,t)&&(i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2])))}}class Uniform4f extends Uniform{constructor(e){super(e),this.current=[0,0,0,0]}set(e,t,i){this.fetchUniformLocation(e,t)&&(i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]&&i[3]===this.current[3]||(this.current=i,this.gl.uniform4f(this.location,i[0],i[1],i[2],i[3])))}}class UniformColor extends Uniform{constructor(e){super(e),this.current=Lt.transparent}set(e,t,i){this.fetchUniformLocation(e,t)&&(i.r===this.current.r&&i.g===this.current.g&&i.b===this.current.b&&i.a===this.current.a||(this.current=i,this.gl.uniform4f(this.location,i.r,i.g,i.b,i.a)))}}const ho=new Float32Array(16);class UniformMatrix4f extends Uniform{constructor(e){super(e),this.current=ho}set(e,t,i){if(this.fetchUniformLocation(e,t)){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let e=1;e<16;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}}}const po=new Float32Array(9);class UniformMatrix3f extends Uniform{constructor(e){super(e),this.current=po}set(e,t,i){if(this.fetchUniformLocation(e,t))for(let e=0;e<9;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}}const fo=new Float32Array(4);class UniformMatrix2f extends Uniform{constructor(e){super(e),this.current=fo}set(e,t,i){if(this.fetchUniformLocation(e,t))for(let e=0;e<4;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}}function mo(e){return[Yn(255*e.r,255*e.g),Yn(255*e.b,255*e.a)]}class ConstantBinder{constructor(e,t,i){this.value=e,this.uniformNames=t.map((e=>`u_${e}`)),this.type=i}setUniform(e,t,i,r,n){t.set(e,n,r.constantOr(this.value))}getBinding(e,t){return"color"===this.type?new UniformColor(e):new Uniform1f(e)}}class CrossFadedConstantBinder{constructor(e,t){this.uniformNames=t.map((e=>`u_${e}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,t){this.pixelRatioFrom=t.pixelRatio||1,this.pixelRatioTo=e.pixelRatio||1,this.patternFrom=t.tl.concat(t.br),this.patternTo=e.tl.concat(e.br)}setUniform(e,t,i,r,n){const o="u_pattern_to"===n||"u_dash_to"===n?this.patternTo:"u_pattern_from"===n||"u_dash_from"===n?this.patternFrom:"u_pixel_ratio_to"===n?this.pixelRatioTo:"u_pixel_ratio_from"===n?this.pixelRatioFrom:null;o&&t.set(e,n,o)}getBinding(e,t){return"u_pattern_from"===t||"u_pattern_to"===t||"u_dash_from"===t||"u_dash_to"===t?new Uniform4f(e):new Uniform1f(e)}}class SourceExpressionBinder{constructor(e,t,i,r){this.expression=e,this.type=i,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new r}populatePaintArray(e,t,i,r,n,o){const a=this.paintVertexArray.length,s=this.expression.evaluate(new EvaluationParameters(0),t,{},n,r,o);this.paintVertexArray.resize(e),this._setPaintValue(a,e,s)}updatePaintArray(e,t,i,r,n){const o=this.expression.evaluate({zoom:0},i,r,void 0,n);this._setPaintValue(e,t,o)}_setPaintValue(e,t,i){if("color"===this.type){const r=mo(i);for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,r[0],r[1])}else{for(let r=e;r<t;r++)this.paintVertexArray.emplace(r,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class CompositeExpressionBinder{constructor(e,t,i,r,n,o){this.expression=e,this.uniformNames=t.map((e=>`u_${e}_t`)),this.type=i,this.useIntegerZoom=r,this.zoom=n,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new o}populatePaintArray(e,t,i,r,n,o){const a=this.expression.evaluate(new EvaluationParameters(this.zoom),t,{},n,r,o),s=this.expression.evaluate(new EvaluationParameters(this.zoom+1),t,{},n,r,o),l=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(l,e,a,s)}updatePaintArray(e,t,i,r,n){const o=this.expression.evaluate({zoom:this.zoom},i,r,void 0,n),a=this.expression.evaluate({zoom:this.zoom+1},i,r,void 0,n);this._setPaintValue(e,t,o,a)}_setPaintValue(e,t,i,r){if("color"===this.type){const n=mo(i),o=mo(r);for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,n[0],n[1],o[0],o[1])}else{for(let n=e;n<t;n++)this.paintVertexArray.emplace(n,i,r);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(r))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,t,i,r,n){const o=this.useIntegerZoom?Math.floor(i.zoom):i.zoom,a=_(this.expression.interpolationFactor(o,this.zoom,this.zoom+1),0,1);t.set(e,n,a)}getBinding(e,t){return new Uniform1f(e)}}class CrossFadedCompositeBinder{constructor(e,t,i,r,n,o,a){this.expression=e,this.type=i,this.useIntegerZoom=r,this.zoom=n,this.layerId=a,this.paintVertexAttributes=("array"===i?ro:io).members;for(let e=0;e<t.length;++e);this.zoomInPaintVertexArray=new o,this.zoomOutPaintVertexArray=new o}populatePaintArray(e,t,i){const r=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(r,e,t.patterns&&t.patterns[this.layerId],i)}updatePaintArray(e,t,i,r,n,o){this._setPaintValues(e,t,i.patterns&&i.patterns[this.layerId],o)}_setPaintValues(e,t,i,r){if(!r||!i)return;const{min:n,mid:o,max:a}=i,s=r[n],l=r[o],c=r[a];if(s&&l&&c)for(let i=e;i<t;i++)this._setPaintValue(this.zoomInPaintVertexArray,i,l,s),this._setPaintValue(this.zoomOutPaintVertexArray,i,l,c)}_setPaintValue(e,t,i,r){e.emplace(t,i.tl[0],i.tl[1],i.br[0],i.br[1],r.tl[0],r.tl[1],r.br[0],r.br[1],i.pixelRatio,r.pixelRatio)}upload(e){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class ProgramConfiguration{constructor(e,t,i=(()=>!0)){this.binders={},this._buffers=[];const r=[];for(const n in e.paint._values){if(!i(n))continue;const o=e.paint.get(n);if(!(o instanceof PossiblyEvaluatedPropertyValue&&pr(o.property.specification)))continue;const a=go(n,e.type),s=o.value,l=o.property.specification.type,c=o.property.useIntegerZoom,u=o.property.specification["property-type"],h="cross-faded"===u||"cross-faded-data-driven"===u,p="line-dasharray"===String(n)&&"constant"!==e.layout.get("line-cap").value.kind;if("constant"!==s.kind||p)if("source"===s.kind||p||h){const i=vo(n,l,"source");this.binders[n]=h?new CrossFadedCompositeBinder(s,a,l,c,t,i,e.id):new SourceExpressionBinder(s,a,l,i),r.push(`/a_${n}`)}else{const e=vo(n,l,"composite");this.binders[n]=new CompositeExpressionBinder(s,a,l,c,t,e),r.push(`/z_${n}`)}else this.binders[n]=h?new CrossFadedConstantBinder(s.value,a):new ConstantBinder(s.value,a,l),r.push(`/u_${n}`)}this.cacheKey=r.sort().join("")}getMaxValue(e){const t=this.binders[e];return t instanceof SourceExpressionBinder||t instanceof CompositeExpressionBinder?t.maxValue:0}populatePaintArrays(e,t,i,r,n,o){for(const a in this.binders){const s=this.binders[a];(s instanceof SourceExpressionBinder||s instanceof CompositeExpressionBinder||s instanceof CrossFadedCompositeBinder)&&s.populatePaintArray(e,t,i,r,n,o)}}setConstantPatternPositions(e,t){for(const i in this.binders){const r=this.binders[i];r instanceof CrossFadedConstantBinder&&r.setConstantPatternPositions(e,t)}}updatePaintArrays(e,t,i,r,n,o){let a=!1;for(const s in e){const l=t.getPositions(s);for(const t of l){const l=i.feature(t.index);for(const i in this.binders){const c=this.binders[i];if((c instanceof SourceExpressionBinder||c instanceof CompositeExpressionBinder||c instanceof CrossFadedCompositeBinder)&&!0===c.expression.isStateDependent){const u=r.paint.get(i);c.expression=u.value,c.updatePaintArray(t.start,t.end,l,e[s],n,o),a=!0}}}}return a}defines(){const e=[];for(const t in this.binders){const i=this.binders[t];(i instanceof ConstantBinder||i instanceof CrossFadedConstantBinder)&&e.push(...i.uniformNames.map((e=>`#define HAS_UNIFORM_${e}`)))}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof SourceExpressionBinder||i instanceof CompositeExpressionBinder||i instanceof CrossFadedCompositeBinder)for(let t=0;t<i.paintVertexAttributes.length;t++)e.push(i.paintVertexAttributes[t].name)}return e}getBinderUniforms(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof ConstantBinder||i instanceof CrossFadedConstantBinder||i instanceof CompositeExpressionBinder)for(const t of i.uniformNames)e.push(t)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e){const t=[];for(const i in this.binders){const r=this.binders[i];if(r instanceof ConstantBinder||r instanceof CrossFadedConstantBinder||r instanceof CompositeExpressionBinder)for(const n of r.uniformNames)t.push({name:n,property:i,binding:r.getBinding(e,n)})}return t}setUniforms(e,t,i,r,n){for(const{name:t,property:o,binding:a}of i)this.binders[o].setUniform(e,a,n,r.get(o),t)}updatePaintBuffers(e){this._buffers=[];for(const t in this.binders){const i=this.binders[t];if(e&&i instanceof CrossFadedCompositeBinder){const t=2===e.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;t&&this._buffers.push(t)}else(i instanceof SourceExpressionBinder||i instanceof CompositeExpressionBinder)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(e){for(const t in this.binders){const i=this.binders[t];(i instanceof SourceExpressionBinder||i instanceof CompositeExpressionBinder||i instanceof CrossFadedCompositeBinder)&&i.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const t=this.binders[e];(t instanceof SourceExpressionBinder||t instanceof CompositeExpressionBinder||t instanceof CrossFadedCompositeBinder)&&t.destroy()}}}class ProgramConfigurationSet{constructor(e,t,i=(()=>!0)){this.programConfigurations={};for(const r of e)this.programConfigurations[r.id]=new ProgramConfiguration(r,t,i);this.needsUpload=!1,this._featureMap=new FeaturePositionMap,this._bufferOffset=0}populatePaintArrays(e,t,i,r,n,o,a){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(e,t,r,n,o,a);void 0!==t.id&&this._featureMap.add(t.id,i,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,i,r,n){for(const o of i)this.needsUpload=this.programConfigurations[o.id].updatePaintArrays(e,this._featureMap,t,o,r,n)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}const _o={"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 go(e,t){return _o[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}const yo={"line-pattern":{source:StructArrayLayout10ui20,composite:StructArrayLayout10ui20},"fill-pattern":{source:StructArrayLayout10ui20,composite:StructArrayLayout10ui20},"fill-extrusion-pattern":{source:StructArrayLayout10ui20,composite:StructArrayLayout10ui20},"line-dasharray":{source:StructArrayLayout8ui16,composite:StructArrayLayout8ui16}},xo={color:{source:StructArrayLayout2f8,composite:StructArrayLayout4f16},number:{source:StructArrayLayout1f4,composite:StructArrayLayout2f8}};function vo(e,t,i){const r=yo[e];return r&&r[i]||xo[t][i]}En(ConstantBinder,"ConstantBinder"),En(CrossFadedConstantBinder,"CrossFadedConstantBinder"),En(SourceExpressionBinder,"SourceExpressionBinder"),En(CrossFadedCompositeBinder,"CrossFadedCompositeBinder"),En(CompositeExpressionBinder,"CompositeExpressionBinder"),En(ProgramConfiguration,"ProgramConfiguration",{omit:["_buffers"]}),En(ProgramConfigurationSet,"ProgramConfigurationSet");const bo="-transition";class StyleLayer extends Evented{constructor(e,t){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==e.type&&(this.metadata=(e=e).metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&"sky"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),t.layout&&(this._unevaluatedLayout=new Layout(t.layout)),t.paint)){this._transitionablePaint=new Transitionable(t.paint);for(const t in e.paint)this.setPaintProperty(t,e.paint[t],{validate:!1});for(const t in e.layout)this.setLayoutProperty(t,e.layout[t],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new PossiblyEvaluated(t.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t,i={}){null!=t&&this._validate(yn,`layers.${this.id}.layout.${e}`,e,t,i)||("visibility"!==e?this._unevaluatedLayout.setValue(e,t):this.visibility=t)}getPaintProperty(e){return M(e,bo)?this._transitionablePaint.getTransition(e.slice(0,-bo.length)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t,i={}){if(null!=t&&this._validate(gn,`layers.${this.id}.paint.${e}`,e,t,i))return!1;if(M(e,bo))return this._transitionablePaint.setTransition(e.slice(0,-bo.length),t||void 0),!1;{const i=this._transitionablePaint._values[e],r="cross-faded-data-driven"===i.property.specification["property-type"],n=i.value.isDataDriven(),o=i.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);const a=this._transitionablePaint._values[e].value;return a.isDataDriven()||n||r||this._handleOverridablePaintPropertyUpdate(e,o,a)}}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getProgramConfiguration(e){return null}_handleOverridablePaintPropertyUpdate(e,t,i){return!1}isHidden(e){return!!(this.minzoom&&e<this.minzoom)||!!(this.maxzoom&&e>=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){const e={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&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),D(e,((e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length)))}_validate(e,t,i,r,n={}){return(!n||!1!==n.validate)&&vn(this,e.call(un,{key:t,layerType:this.type,objectKey:i,value:r,styleSpec:ct,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof PossiblyEvaluatedPropertyValue&&pr(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=Rr(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const wo=eo([{name:"a_pos",components:2,type:"Int16"}],4),To=eo([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class SegmentVector{constructor(e=[]){this.segments=e}prepareSegment(e,t,i,r){let n=this.segments[this.segments.length-1];return e>SegmentVector.MAX_VERTEX_ARRAY_LENGTH&&B(`Max vertices per segment is ${SegmentVector.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!n||n.vertexLength+e>SegmentVector.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==r)&&(n={vertexOffset:t.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0},void 0!==r&&(n.sortKey=r),this.segments.push(n)),n}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy()}static simpleSegment(e,t,i,r){return new SegmentVector([{vertexOffset:e,primitiveOffset:t,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}SegmentVector.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,En(SegmentVector,"SegmentVector");var Eo=8192;class LngLatBounds{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1]))}setNorthEast(e){return this._ne=e instanceof LngLat?new LngLat(e.lng,e.lat):LngLat.convert(e),this}setSouthWest(e){return this._sw=e instanceof LngLat?new LngLat(e.lng,e.lat):LngLat.convert(e),this}extend(e){const t=this._sw,i=this._ne;let r,n;if(e instanceof LngLat)r=e,n=e;else{if(!(e instanceof LngLatBounds))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(LngLatBounds.convert(e)):this.extend(LngLat.convert(e)):this;if(r=e._sw,n=e._ne,!r||!n)return this}return t||i?(t.lng=Math.min(r.lng,t.lng),t.lat=Math.min(r.lat,t.lat),i.lng=Math.max(n.lng,i.lng),i.lat=Math.max(n.lat,i.lat)):(this._sw=new LngLat(r.lng,r.lat),this._ne=new LngLat(n.lng,n.lat)),this}getCenter(){return new LngLat((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 LngLat(this.getWest(),this.getNorth())}getSouthEast(){return new LngLat(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(e){const{lng:t,lat:i}=LngLat.convert(e);let r=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&r}static convert(e){return!e||e instanceof LngLatBounds?e:new LngLatBounds(e)}}const So=6371008.8;class LngLat{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new LngLat(y(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const t=Math.PI/180,i=this.lat*t,r=e.lat*t,n=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return So*Math.acos(Math.min(n,1))}toBounds(e=0){const t=360*e/40075017,i=t/Math.cos(Math.PI/180*this.lat);return new LngLatBounds(new LngLat(this.lng-i,this.lat-t),new LngLat(this.lng+i,this.lat+t))}static convert(e){if(e instanceof LngLat)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new LngLat(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new LngLat(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const Ao=2*Math.PI*So;function Co(e){return Ao*Math.cos(e*Math.PI/180)}function Io(e){return(180+e)/360}function Mo(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Po(e,t){return e/Co(t)}function Do(e){return 360*e-180}function zo(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function ko(e,t){return e*Co(zo(t))}const Lo=85.051129;function Bo(e){return 1/Math.cos(e*Math.PI/180)}class MercatorCoordinate{constructor(e,t,i=0){this.x=+e,this.y=+t,this.z=+i}static fromLngLat(e,t=0){const i=LngLat.convert(e);return new MercatorCoordinate(Io(i.lng),Mo(i.lat),Po(t,i.lat))}toLngLat(){return new LngLat(Do(this.x),zo(this.y))}toAltitude(){return ko(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Ao*Bo(zo(this.y))}}function Ro(e,t,i,n,o,a,s,l,c){const u=(t+n)/2,h=(i+o)/2,p=new r(u,h);l(p),function(e,t,i,r,n,o){const a=i-n,s=r-o;return Math.abs((r-t)*a-(i-e)*s)/Math.hypot(a,s)}(p.x,p.y,a.x,a.y,s.x,s.y)>=c?(Ro(e,t,i,u,h,a,p,l,c),Ro(e,u,h,n,o,p,s,l,c)):e.push(s)}function Fo(e,t,i){let r=e[0],n=r.x,o=r.y;t(r);const a=[r];for(let s=1;s<e.length;s++){const l=e[s],{x:c,y:u}=l;t(l),Ro(a,n,o,c,u,r,l,t,i),n=c,o=u,r=l}return a}function Oo(e,t,i,r,n){if(n(t,i)){const o=t.add(i).mult(.5);r(o),Oo(e,t,o,r,n),Oo(e,o,i,r,n)}else e.push(i)}function Vo(e,t,i){let r=e[0];t(r);const n=[r];for(let o=1;o<e.length;o++){const a=e[o];t(a),Oo(n,r,a,t,i),r=a}return n}const Uo=Math.pow(2,14)-1,jo=-Uo-1;function No(e,t){const i=Math.round(e.x*t),r=Math.round(e.y*t);return e.x=_(i,jo,Uo),e.y=_(r,jo,Uo),(i<e.x||i>e.x+1||r<e.y||r>e.y+1)&&B("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function Go(e,t,i){const r=e.loadGeometry(),n=e.extent,o=Eo/n;if(t&&i&&i.projection.isReprojectedInTileSpace){const o=1<<t.z,{scale:a,x:s,y:l,projection:c}=i,u=e=>{const i=Do((t.x+e.x/n)/o),r=zo((t.y+e.y/n)/o),u=c.project(i,r);e.x=(u.x*a-s)*n,e.y=(u.y*a-l)*n};for(let t=0;t<r.length;t++)if(1!==e.type)r[t]=Fo(r[t],u,1);else{const e=[];for(const i of r[t])i.x<0||i.x>=n||i.y<0||i.y>=n||(u(i),e.push(i));r[t]=e}}for(const e of r)for(const t of e)No(t,o);return r}function Zo(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Go(e):[]}}function qo(e,t,i,r,n){e.emplaceBack(2*t+(r+1)/2,2*i+(n+1)/2)}function $o(e,t,i){const r=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*r,i[1]*r,i[2]*r)}class CircleBucket{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new StructArrayLayout2i4,this.indexArray=new StructArrayLayout3ui6,this.segments=new SegmentVector,this.programConfigurations=new ProgramConfigurationSet(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,i,r){const n=this.layers[0],o=[];let a=null;"circle"===n.type&&(a=n.layout.get("circle-sort-key"));for(const{feature:t,id:n,index:s,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Zo(t,e);if(!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom),c,i))continue;const u=a?a.evaluate(c,{},i):void 0,h={id:n,properties:t.properties,type:t.type,sourceLayerIndex:l,index:s,geometry:e?c.geometry:Go(t,i,r),patterns:{},sortKey:u};o.push(h)}a&&o.sort(((e,t)=>e.sortKey-t.sortKey));let s=null;"globe"===r.projection.name&&(this.globeExtVertexArray=new CircleGlobeExtArray,s=r.projection);for(const r of o){const{geometry:n,index:o,sourceLayerIndex:a}=r,l=e[o].feature;this.addFeature(r,n,o,t.availableImages,i,s),t.featureIndex.insert(l,n,o,a,this.index)}}update(e,t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,wo.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,To.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(e,t,i,r,n,o){for(const i of t)for(const t of i){const i=t.x,r=t.y;if(i<0||i>=Eo||r<0||r>=Eo)continue;if(o){const e=o.projectTilePoint(i,r,n),t=o.upVector(n,i,r),a=this.globeExtVertexArray;$o(a,e,t),$o(a,e,t),$o(a,e,t),$o(a,e,t)}const a=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),s=a.vertexLength;qo(this.layoutVertexArray,i,r,-1,-1),qo(this.layoutVertexArray,i,r,1,-1),qo(this.layoutVertexArray,i,r,1,1),qo(this.layoutVertexArray,i,r,-1,1),this.indexArray.emplaceBack(s,s+1,s+2),this.indexArray.emplaceBack(s,s+2,s+3),a.vertexLength+=4,a.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{},r,n)}}function Wo(e,t){for(let i=0;i<e.length;i++)if(ia(t,e[i]))return!0;for(let i=0;i<t.length;i++)if(ia(e,t[i]))return!0;return!!Jo(e,t)}function Ho(e,t,i){return!!ia(e,t)||!!Qo(t,e,i)}function Xo(e,t){if(1===e.length)return ta(t,e[0]);for(let i=0;i<t.length;i++){const r=t[i];for(let t=0;t<r.length;t++)if(ia(e,r[t]))return!0}for(let i=0;i<e.length;i++)if(ta(t,e[i]))return!0;for(let i=0;i<t.length;i++)if(Jo(e,t[i]))return!0;return!1}function Ko(e,t,i){if(e.length>1){if(Jo(e,t))return!0;for(let r=0;r<t.length;r++)if(Qo(t[r],e,i))return!0}for(let r=0;r<e.length;r++)if(Qo(e[r],t,i))return!0;return!1}function Jo(e,t){if(0===e.length||0===t.length)return!1;for(let i=0;i<e.length-1;i++){const r=e[i],n=e[i+1];for(let e=0;e<t.length-1;e++)if(Yo(r,n,t[e],t[e+1]))return!0}return!1}function Yo(e,t,i,r){return R(e,i,r)!==R(t,i,r)&&R(e,t,i)!==R(e,t,r)}function Qo(e,t,i){const r=i*i;if(1===t.length)return e.distSqr(t[0])<r;for(let i=1;i<t.length;i++)if(ea(e,t[i-1],t[i])<r)return!0;return!1}function ea(e,t,i){const r=t.distSqr(i);if(0===r)return e.distSqr(t);const n=((e.x-t.x)*(i.x-t.x)+(e.y-t.y)*(i.y-t.y))/r;return e.distSqr(n<0?t:n>1?i:i.sub(t)._mult(n)._add(t))}function ta(e,t){let i,r,n,o=!1;for(let a=0;a<e.length;a++){i=e[a];for(let e=0,a=i.length-1;e<i.length;a=e++)r=i[e],n=i[a],r.y>t.y!=n.y>t.y&&t.x<(n.x-r.x)*(t.y-r.y)/(n.y-r.y)+r.x&&(o=!o)}return o}function ia(e,t){let i=!1;for(let r=0,n=e.length-1;r<e.length;n=r++){const o=e[r],a=e[n];o.y>t.y!=a.y>t.y&&t.x<(a.x-o.x)*(t.y-o.y)/(a.y-o.y)+o.x&&(i=!i)}return i}function ra(e,t,i,n,o){for(const r of e)if(t<=r.x&&i<=r.y&&n>=r.x&&o>=r.y)return!0;const a=[new r(t,i),new r(t,o),new r(n,o),new r(n,i)];if(e.length>2)for(const t of a)if(ia(e,t))return!0;for(let t=0;t<e.length-1;t++)if(na(e[t],e[t+1],a))return!0;return!1}function na(e,t,i){const r=i[0],n=i[2];if(e.x<r.x&&t.x<r.x||e.x>n.x&&t.x>n.x||e.y<r.y&&t.y<r.y||e.y>n.y&&t.y>n.y)return!1;const o=R(e,t,i[0]);return o!==R(e,t,i[1])||o!==R(e,t,i[2])||o!==R(e,t,i[3])}function oa(e,t,i){const r=t.paint.get(e).value;return"constant"===r.kind?r.value:i.programConfigurations.get(t.id).getMaxValue(e)}function aa(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function sa(e,t,i,n,o){if(!t[0]&&!t[1])return e;const a=r.convert(t)._mult(o);"viewport"===i&&a._rotate(-n);const s=[];for(let t=0;t<e.length;t++)s.push(e[t].sub(a));return s}function la(e,t,i,n){const o=r.convert(e)._mult(n);return"viewport"===t&&o._rotate(-i),o}En(CircleBucket,"CircleBucket",{omit:["layers"]});const ca=new Properties({"circle-sort-key":new DataDrivenProperty(ct.layout_circle["circle-sort-key"])});var ua={paint:new Properties({"circle-radius":new DataDrivenProperty(ct.paint_circle["circle-radius"]),"circle-color":new DataDrivenProperty(ct.paint_circle["circle-color"]),"circle-blur":new DataDrivenProperty(ct.paint_circle["circle-blur"]),"circle-opacity":new DataDrivenProperty(ct.paint_circle["circle-opacity"]),"circle-translate":new DataConstantProperty(ct.paint_circle["circle-translate"]),"circle-translate-anchor":new DataConstantProperty(ct.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new DataConstantProperty(ct.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new DataConstantProperty(ct.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new DataDrivenProperty(ct.paint_circle["circle-stroke-width"]),"circle-stroke-color":new DataDrivenProperty(ct.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new DataDrivenProperty(ct.paint_circle["circle-stroke-opacity"])}),layout:ca},ha=1e-6,pa="undefined"!=typeof Float32Array?Float32Array:Array;function da(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],a=i*o-n*r;return a?(e[0]=o*(a=1/a),e[1]=-r*a,e[2]=-n*a,e[3]=i*a,e):null}function fa(){var e=new pa(9);return pa!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function ma(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],a=t[4],s=t[5],l=t[6],c=t[7],u=t[8];return e[0]=a*u-s*c,e[1]=n*c-r*u,e[2]=r*s-n*a,e[3]=s*l-o*u,e[4]=i*u-n*l,e[5]=n*o-i*s,e[6]=o*c-a*l,e[7]=r*l-i*c,e[8]=i*a-r*o,e}function _a(e,t,i){var r=t[0],n=t[1],o=t[2],a=t[3],s=t[4],l=t[5],c=t[6],u=t[7],h=t[8],p=i[0],d=i[1],f=i[2],m=i[3],_=i[4],g=i[5],y=i[6],x=i[7],v=i[8];return e[0]=p*r+d*a+f*c,e[1]=p*n+d*s+f*u,e[2]=p*o+d*l+f*h,e[3]=m*r+_*a+g*c,e[4]=m*n+_*s+g*u,e[5]=m*o+_*l+g*h,e[6]=y*r+x*a+v*c,e[7]=y*n+x*s+v*u,e[8]=y*o+x*l+v*h,e}function ga(){var e=new pa(16);return pa!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function ya(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function xa(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],a=t[4],s=t[5],l=t[6],c=t[7],u=t[8],h=t[9],p=t[10],d=t[11],f=t[12],m=t[13],_=t[14],g=t[15],y=i*s-r*a,x=i*l-n*a,v=i*c-o*a,b=r*l-n*s,w=r*c-o*s,T=n*c-o*l,E=u*m-h*f,S=u*_-p*f,A=u*g-d*f,C=h*_-p*m,I=h*g-d*m,M=p*g-d*_,P=y*M-x*I+v*C+b*A-w*S+T*E;return P?(e[0]=(s*M-l*I+c*C)*(P=1/P),e[1]=(n*I-r*M-o*C)*P,e[2]=(m*T-_*w+g*b)*P,e[3]=(p*w-h*T-d*b)*P,e[4]=(l*A-a*M-c*S)*P,e[5]=(i*M-n*A+o*S)*P,e[6]=(_*v-f*T-g*x)*P,e[7]=(u*T-p*v+d*x)*P,e[8]=(a*I-s*A+c*E)*P,e[9]=(r*A-i*I-o*E)*P,e[10]=(f*w-m*v+g*y)*P,e[11]=(h*v-u*w-d*y)*P,e[12]=(s*S-a*C-l*E)*P,e[13]=(i*C-r*S+n*E)*P,e[14]=(m*x-f*b-_*y)*P,e[15]=(u*b-h*x+p*y)*P,e):null}function va(e,t,i){var r=t[0],n=t[1],o=t[2],a=t[3],s=t[4],l=t[5],c=t[6],u=t[7],h=t[8],p=t[9],d=t[10],f=t[11],m=t[12],_=t[13],g=t[14],y=t[15],x=i[0],v=i[1],b=i[2],w=i[3];return e[0]=x*r+v*s+b*h+w*m,e[1]=x*n+v*l+b*p+w*_,e[2]=x*o+v*c+b*d+w*g,e[3]=x*a+v*u+b*f+w*y,e[4]=(x=i[4])*r+(v=i[5])*s+(b=i[6])*h+(w=i[7])*m,e[5]=x*n+v*l+b*p+w*_,e[6]=x*o+v*c+b*d+w*g,e[7]=x*a+v*u+b*f+w*y,e[8]=(x=i[8])*r+(v=i[9])*s+(b=i[10])*h+(w=i[11])*m,e[9]=x*n+v*l+b*p+w*_,e[10]=x*o+v*c+b*d+w*g,e[11]=x*a+v*u+b*f+w*y,e[12]=(x=i[12])*r+(v=i[13])*s+(b=i[14])*h+(w=i[15])*m,e[13]=x*n+v*l+b*p+w*_,e[14]=x*o+v*c+b*d+w*g,e[15]=x*a+v*u+b*f+w*y,e}function ba(e,t,i){var r,n,o,a,s,l,c,u,h,p,d,f,m=i[0],_=i[1],g=i[2];return t===e?(e[12]=t[0]*m+t[4]*_+t[8]*g+t[12],e[13]=t[1]*m+t[5]*_+t[9]*g+t[13],e[14]=t[2]*m+t[6]*_+t[10]*g+t[14],e[15]=t[3]*m+t[7]*_+t[11]*g+t[15]):(n=t[1],o=t[2],a=t[3],s=t[4],l=t[5],c=t[6],u=t[7],h=t[8],p=t[9],d=t[10],f=t[11],e[0]=r=t[0],e[1]=n,e[2]=o,e[3]=a,e[4]=s,e[5]=l,e[6]=c,e[7]=u,e[8]=h,e[9]=p,e[10]=d,e[11]=f,e[12]=r*m+s*_+h*g+t[12],e[13]=n*m+l*_+p*g+t[13],e[14]=o*m+c*_+d*g+t[14],e[15]=a*m+u*_+f*g+t[15]),e}function wa(e,t,i){var r=i[0],n=i[1],o=i[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Ta(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[4],a=t[5],s=t[6],l=t[7],c=t[8],u=t[9],h=t[10],p=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=o*n+c*r,e[5]=a*n+u*r,e[6]=s*n+h*r,e[7]=l*n+p*r,e[8]=c*n-o*r,e[9]=u*n-a*r,e[10]=h*n-s*r,e[11]=p*n-l*r,e}function Ea(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[0],a=t[1],s=t[2],l=t[3],c=t[8],u=t[9],h=t[10],p=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*n-c*r,e[1]=a*n-u*r,e[2]=s*n-h*r,e[3]=l*n-p*r,e[8]=o*r+c*n,e[9]=a*r+u*n,e[10]=s*r+h*n,e[11]=l*r+p*n,e}function Sa(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[0],a=t[1],s=t[2],l=t[3],c=t[4],u=t[5],h=t[6],p=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*n+c*r,e[1]=a*n+u*r,e[2]=s*n+h*r,e[3]=l*n+p*r,e[4]=c*n-o*r,e[5]=u*n-a*r,e[6]=h*n-s*r,e[7]=p*n-l*r,e}function Aa(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Ca(e,t,i){var r,n,o,a=i[0],s=i[1],l=i[2],c=Math.hypot(a,s,l);return c<ha?null:(a*=c=1/c,s*=c,l*=c,r=Math.sin(t),n=Math.cos(t),e[0]=a*a*(o=1-n)+n,e[1]=s*a*o+l*r,e[2]=l*a*o-s*r,e[3]=0,e[4]=a*s*o-l*r,e[5]=s*s*o+n,e[6]=l*s*o+a*r,e[7]=0,e[8]=a*l*o+s*r,e[9]=s*l*o-a*r,e[10]=l*l*o+n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function Ia(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],a=i+i,s=r+r,l=n+n,c=i*a,u=r*a,h=r*s,p=n*a,d=n*s,f=n*l,m=o*a,_=o*s,g=o*l;return e[0]=1-h-f,e[1]=u+g,e[2]=p-_,e[3]=0,e[4]=u-g,e[5]=1-c-f,e[6]=d+m,e[7]=0,e[8]=p+_,e[9]=d-m,e[10]=1-c-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var Ma=function(e,t,i,r,n){var o,a=1/Math.tan(t/2);return e[0]=a/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=n&&n!==1/0?(e[10]=(n+r)*(o=1/(r-n)),e[14]=2*n*r*o):(e[10]=-1,e[14]=-2*r),e},Pa=function(e,t,i,r,n,o,a){var s=1/(t-i),l=1/(r-n),c=1/(o-a);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+i)*s,e[13]=(n+r)*l,e[14]=(a+o)*c,e[15]=1,e},Da=va;function za(){var e=new pa(3);return pa!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function ka(e){var t=new pa(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function La(e){return Math.hypot(e[0],e[1],e[2])}function Ba(e,t,i){var r=new pa(3);return r[0]=e,r[1]=t,r[2]=i,r}function Ra(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e}function Fa(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}function Oa(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e}function Va(e,t,i){return e[0]=Math.min(t[0],i[0]),e[1]=Math.min(t[1],i[1]),e[2]=Math.min(t[2],i[2]),e}function Ua(e,t,i){return e[0]=Math.max(t[0],i[0]),e[1]=Math.max(t[1],i[1]),e[2]=Math.max(t[2],i[2]),e}function ja(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function Na(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e}function Ga(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2])}function Za(e,t){var i=t[0],r=t[1],n=t[2],o=i*i+r*r+n*n;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function qa(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function $a(e,t,i){var r=t[0],n=t[1],o=t[2],a=i[0],s=i[1],l=i[2];return e[0]=n*l-o*s,e[1]=o*a-r*l,e[2]=r*s-n*a,e}function Wa(e,t,i){var r=t[0],n=t[1],o=t[2],a=i[3]*r+i[7]*n+i[11]*o+i[15];return e[0]=(i[0]*r+i[4]*n+i[8]*o+i[12])/(a=a||1),e[1]=(i[1]*r+i[5]*n+i[9]*o+i[13])/a,e[2]=(i[2]*r+i[6]*n+i[10]*o+i[14])/a,e}function Ha(e,t,i){var r=t[0],n=t[1],o=t[2];return e[0]=r*i[0]+n*i[3]+o*i[6],e[1]=r*i[1]+n*i[4]+o*i[7],e[2]=r*i[2]+n*i[5]+o*i[8],e}function Xa(e,t,i){var r=i[0],n=i[1],o=i[2],a=t[0],s=t[1],l=t[2],c=n*l-o*s,u=o*a-r*l,h=r*s-n*a,p=n*h-o*u,d=o*c-r*h,f=r*u-n*c,m=2*i[3];return u*=m,h*=m,d*=2,f*=2,e[0]=a+(c*=m)+(p*=2),e[1]=s+u+d,e[2]=l+h+f,e}var Ka,Ja=Fa,Ya=Oa,Qa=function(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e[2]=t[2]/i[2],e},es=La;function ts(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e}function is(e,t,i){var r=t[0],n=t[1],o=t[2],a=t[3];return e[0]=i[0]*r+i[4]*n+i[8]*o+i[12]*a,e[1]=i[1]*r+i[5]*n+i[9]*o+i[13]*a,e[2]=i[2]*r+i[6]*n+i[10]*o+i[14]*a,e[3]=i[3]*r+i[7]*n+i[11]*o+i[15]*a,e}function rs(){var e=new pa(4);return pa!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function ns(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function os(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],a=t[3],s=Math.sin(i),l=Math.cos(i);return e[0]=r*l+a*s,e[1]=n*l+o*s,e[2]=o*l-n*s,e[3]=a*l-r*s,e}function as(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],a=t[3],s=Math.sin(i),l=Math.cos(i);return e[0]=r*l-o*s,e[1]=n*l+a*s,e[2]=o*l+r*s,e[3]=a*l-n*s,e}function ss(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],a=t[3],s=Math.sin(i),l=Math.cos(i);return e[0]=r*l+n*s,e[1]=n*l-r*s,e[2]=o*l+a*s,e[3]=a*l-o*s,e}za(),Ka=new pa(4),pa!=Float32Array&&(Ka[0]=0,Ka[1]=0,Ka[2]=0,Ka[3]=0),za(),Ba(1,0,0),Ba(0,1,0),rs(),rs(),fa();class Ray{constructor(e,t){this.pos=e,this.dir=t}intersectsPlane(e,t,i){const r=qa(t,this.dir);if(Math.abs(r)<1e-6)return!1;const n=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1]+(e[2]-this.pos[2])*t[2])/r;return i[0]=this.pos[0]+this.dir[0]*n,i[1]=this.pos[1]+this.dir[1]*n,i[2]=this.pos[2]+this.dir[2]*n,!0}closestPointOnSphere(e,t,i){if(function(e,t){var i=e[0],r=e[1],n=e[2],o=t[0],a=t[1],s=t[2];return Math.abs(i-o)<=ha*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(r-a)<=ha*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(n-s)<=ha*Math.max(1,Math.abs(n),Math.abs(s))}(this.pos,e)||0===t)return i[0]=i[1]=i[2]=0,!1;const[r,n,o]=this.dir,a=this.pos[0]-e[0],s=this.pos[1]-e[1],l=this.pos[2]-e[2],c=r*r+n*n+o*o,u=2*(a*r+s*n+l*o),h=u*u-4*c*(a*a+s*s+l*l-t*t);if(h<0){const e=Math.max(-u/2,0),c=a+r*e,h=s+n*e,p=l+o*e,d=Math.hypot(c,h,p);return i[0]=c*t/d,i[1]=h*t/d,i[2]=p*t/d,!1}{const e=(-u-Math.sqrt(h))/(2*c);if(e<0){const e=Math.hypot(a,s,l);return i[0]=a*t/e,i[1]=s*t/e,i[2]=l*t/e,!1}return i[0]=a+r*e,i[1]=s+n*e,i[2]=l+o*e,!0}}}class FrustumCorners{constructor(e,t,i,r,n){this.TL=e,this.TR=t,this.BR=i,this.BL=r,this.horizon=n}static fromInvProjectionMatrix(e,t,i){const r=[-1,1,1],n=[1,1,1],o=[1,-1,1],a=[-1,-1,1],s=Wa(r,r,e),l=Wa(n,n,e),c=Wa(o,o,e),u=Wa(a,a,e);return new FrustumCorners(s,l,c,u,t/i)}}class Frustum{constructor(e,t){this.points=e,this.planes=t}static fromInvProjectionMatrix(e,t,i,r){const n=Math.pow(2,i),o=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((i=>{const o=is([],i,e),a=1/o[3]/t*n;return function(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e[3]=t[3]*i[3],e}(o,o,[a,a,r?1/o[3]:a,a])})),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const t=Za([],$a([],Ja([],o[e[0]],o[e[1]]),Ja([],o[e[2]],o[e[1]]))),i=-qa(t,o[e[1]]);return t.concat(i)}));return new Frustum(o,a)}}class Aabb{static fromPoints(e){const t=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],i=[Number.MIN_VALUE,Number.MIN_VALUE,Number.MIN_VALUE];for(const r of e)t[0]=Math.min(t[0],r[0]),t[1]=Math.min(t[1],r[1]),t[2]=Math.min(t[2],r[2]),i[0]=Math.max(i[0],r[0]),i[1]=Math.max(i[1],r[1]),i[2]=Math.max(i[2],r[2]);return new Aabb(t,i)}constructor(e,t){this.min=e,this.max=t,this.center=ja([],Ra([],this.min,this.max),.5)}quadrant(e){const t=[e%2==0,e<2],i=ka(this.min),r=ka(this.max);for(let e=0;e<t.length;e++)i[e]=t[e]?this.min[e]:this.center[e],r[e]=t[e]?this.center[e]:this.max[e];return r[2]=this.max[2],new Aabb(i,r)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}distanceZ(e){return Math.max(Math.min(this.max[2],e[2]),this.min[2])-e[2]}getCorners(){const e=this.min,t=this.max;return[[e[0],e[1],e[2]],[t[0],e[1],e[2]],[t[0],t[1],e[2]],[e[0],t[1],e[2]],[e[0],e[1],t[2]],[t[0],e[1],t[2]],[t[0],t[1],t[2]],[e[0],t[1],t[2]]]}intersects(e){const t=this.getCorners();let i=!0;for(let r=0;r<e.planes.length;r++){const n=e.planes[r];let o=0;for(let e=0;e<t.length;e++)o+=qa(n,t[e])+n[3]>=0;if(0===o)return 0;o!==t.length&&(i=!1)}if(i)return 2;for(let t=0;t<3;t++){let i=Number.MAX_VALUE,r=-Number.MAX_VALUE;for(let n=0;n<e.points.length;n++){const o=e.points[n][t]-this.min[t];i=Math.min(i,o),r=Math.max(r,o)}if(r<0||i>this.max[t]-this.min[t])return 0}return 1}}function ls(e,t,i,r,n,o,a,s,l){if(o&&e.queryGeometry.isAboveHorizon)return!1;o&&(l*=e.pixelToTileUnitsFactor);const c=e.tileID.canonical,u=i.projection.upVectorScale(c,i.center.lat,i.worldSize).metersToTile;for(const h of t)for(const t of h){const h=t.add(s),p=n&&i.elevation?i.elevation.exaggeration()*n.getElevationAt(h.x,h.y,!0):0,d=i.projection.projectTilePoint(h.x,h.y,c);if(p>0){const e=i.projection.upVector(c,h.x,h.y);d.x+=e[0]*u*p,d.y+=e[1]*u*p,d.z+=e[2]*u*p}const f=o?h:cs(d.x,d.y,d.z,r),m=o?e.tilespaceRays.map((e=>ps(e,p))):e.queryGeometry.screenGeometry,_=is([],[d.x,d.y,d.z,1],r);if(!a&&o?l*=_[3]/i.cameraToCenterDistance:a&&!o&&(l*=i.cameraToCenterDistance/_[3]),o){const e=zo((t.y/Eo+c.y)/(1<<c.z));l/=i.projection.pixelsPerMeter(e,1)/Po(1,e)}if(Ho(m,f,l))return!0}return!1}function cs(e,t,i,n){const o=is([],[e,t,i,1],n);return new r(o[0]/o[3],o[1]/o[3])}const us=Ba(0,0,0),hs=Ba(0,0,1);function ps(e,t){const i=za();return us[2]=t,e.intersectsPlane(us,hs,i),new r(i[0],i[1])}class HeatmapBucket extends CircleBucket{}function ds(e,{width:t,height:i},r,n){if(n){if(n instanceof Uint8ClampedArray)n=new Uint8Array(n.buffer);else if(n.length!==t*i*r)throw new RangeError("mismatched image size")}else n=new Uint8Array(t*i*r);return e.width=t,e.height=i,e.data=n,e}function fs(e,t,i){const{width:r,height:n}=t;r===e.width&&n===e.height||(ms(e,t,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,r),height:Math.min(e.height,n)},i),e.width=r,e.height=n,e.data=t.data)}function ms(e,t,i,r,n,o){if(0===n.width||0===n.height)return t;if(n.width>e.width||n.height>e.height||i.x>e.width-n.width||i.y>e.height-n.height)throw new RangeError("out of range source coordinates for image copy");if(n.width>t.width||n.height>t.height||r.x>t.width-n.width||r.y>t.height-n.height)throw new RangeError("out of range destination coordinates for image copy");const a=e.data,s=t.data;for(let l=0;l<n.height;l++){const c=((i.y+l)*e.width+i.x)*o,u=((r.y+l)*t.width+r.x)*o;for(let e=0;e<n.width*o;e++)s[u+e]=a[c+e]}return t}En(HeatmapBucket,"HeatmapBucket",{omit:["layers"]});class AlphaImage{constructor(e,t){ds(this,e,1,t)}resize(e){fs(this,new AlphaImage(e),1)}clone(){return new AlphaImage({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,r,n){ms(e,t,i,r,n,1)}}class RGBAImage{constructor(e,t){ds(this,e,4,t)}resize(e){fs(this,new RGBAImage(e),4)}replace(e,t){t?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new RGBAImage({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,r,n){ms(e,t,i,r,n,4)}}En(AlphaImage,"AlphaImage"),En(RGBAImage,"RGBAImage");var _s={paint:new Properties({"heatmap-radius":new DataDrivenProperty(ct.paint_heatmap["heatmap-radius"]),"heatmap-weight":new DataDrivenProperty(ct.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new DataConstantProperty(ct.paint_heatmap["heatmap-intensity"]),"heatmap-color":new ColorRampProperty(ct.paint_heatmap["heatmap-color"]),"heatmap-opacity":new DataConstantProperty(ct.paint_heatmap["heatmap-opacity"])})};function gs(e){const t={},i=e.resolution||256,r=e.clips?e.clips.length:1,n=e.image||new RGBAImage({width:i,height:r}),o=(i,r,o)=>{t[e.evaluationKey]=o;const a=e.expression.evaluate(t);n.data[i+r+0]=Math.floor(255*a.r/a.a),n.data[i+r+1]=Math.floor(255*a.g/a.a),n.data[i+r+2]=Math.floor(255*a.b/a.a),n.data[i+r+3]=Math.floor(255*a.a)};if(e.clips)for(let t=0,n=0;t<r;++t,n+=4*i)for(let r=0,a=0;r<i;r++,a+=4){const s=r/(i-1),{start:l,end:c}=e.clips[t];o(n,a,l*(1-s)+c*s)}else for(let e=0,t=0;e<i;e++,t+=4)o(0,t,e/(i-1));return n}var ys={paint:new Properties({"hillshade-illumination-direction":new DataConstantProperty(ct.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new DataConstantProperty(ct.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new DataConstantProperty(ct.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new DataConstantProperty(ct.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new DataConstantProperty(ct.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new DataConstantProperty(ct.paint_hillshade["hillshade-accent-color"])})};const xs=eo([{name:"a_pos",components:2,type:"Int16"}],4),{members:vs}=xs;var bs=Ts,ws=Ts;function Ts(e,t,i){i=i||2;var r,n,o,a,s,l,c,u=t&&t.length,h=u?t[0]*i:e.length,p=Es(e,0,h,i,!0),d=[];if(!p||p.next===p.prev)return d;if(u&&(p=function(e,t,i,r){var n,o,a,s=[];for(n=0,o=t.length;n<o;n++)(a=Es(e,t[n]*r,n<o-1?t[n+1]*r:e.length,r,!1))===a.next&&(a.steiner=!0),s.push(Bs(a));for(s.sort(Ds),n=0;n<s.length;n++)i=zs(s[n],i);return i}(e,t,p,i)),e.length>80*i){r=o=e[0],n=a=e[1];for(var f=i;f<h;f+=i)(s=e[f])<r&&(r=s),(l=e[f+1])<n&&(n=l),s>o&&(o=s),l>a&&(a=l);c=0!==(c=Math.max(o-r,a-n))?32767/c:0}return As(p,d,i,r,n,c,0),d}function Es(e,t,i,r,n){var o,a;if(n===Hs(e,t,i,r)>0)for(o=t;o<i;o+=r)a=qs(o,e[o],e[o+1],a);else for(o=i-r;o>=t;o-=r)a=qs(o,e[o],e[o+1],a);return a&&Vs(a,a.next)&&($s(a),a=a.next),a}function Ss(e,t){if(!e)return e;t||(t=e);var i,r=e;do{if(i=!1,r.steiner||!Vs(r,r.next)&&0!==Os(r.prev,r,r.next))r=r.next;else{if($s(r),(r=t=r.prev)===r.next)break;i=!0}}while(i||r!==t);return t}function As(e,t,i,r,n,o,a){if(e){!a&&o&&function(e,t,i,r){var n=e;do{0===n.z&&(n.z=Ls(n.x,n.y,t,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,function(e){var t,i,r,n,o,a,s,l,c=1;do{for(i=e,e=null,o=null,a=0;i;){for(a++,r=i,s=0,t=0;t<c&&(s++,r=r.nextZ);t++);for(l=c;s>0||l>0&&r;)0!==s&&(0===l||!r||i.z<=r.z)?(n=i,i=i.nextZ,s--):(n=r,r=r.nextZ,l--),o?o.nextZ=n:e=n,n.prevZ=o,o=n;i=r}o.nextZ=null,c*=2}while(a>1)}(n)}(e,r,n,o);for(var s,l,c=e;e.prev!==e.next;)if(s=e.prev,l=e.next,o?Is(e,r,n,o):Cs(e))t.push(s.i/i|0),t.push(e.i/i|0),t.push(l.i/i|0),$s(e),e=l.next,c=l.next;else if((e=l)===c){a?1===a?As(e=Ms(Ss(e),t,i),t,i,r,n,o,2):2===a&&Ps(e,t,i,r,n,o):As(Ss(e),t,i,r,n,o,1);break}}}function Cs(e){var t=e.prev,i=e,r=e.next;if(Os(t,i,r)>=0)return!1;for(var n=t.x,o=i.x,a=r.x,s=t.y,l=i.y,c=r.y,u=n<o?n<a?n:a:o<a?o:a,h=s<l?s<c?s:c:l<c?l:c,p=n>o?n>a?n:a:o>a?o:a,d=s>l?s>c?s:c:l>c?l:c,f=r.next;f!==t;){if(f.x>=u&&f.x<=p&&f.y>=h&&f.y<=d&&Rs(n,s,o,l,a,c,f.x,f.y)&&Os(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Is(e,t,i,r){var n=e.prev,o=e,a=e.next;if(Os(n,o,a)>=0)return!1;for(var s=n.x,l=o.x,c=a.x,u=n.y,h=o.y,p=a.y,d=s<l?s<c?s:c:l<c?l:c,f=u<h?u<p?u:p:h<p?h:p,m=s>l?s>c?s:c:l>c?l:c,_=u>h?u>p?u:p:h>p?h:p,g=Ls(d,f,t,i,r),y=Ls(m,_,t,i,r),x=e.prevZ,v=e.nextZ;x&&x.z>=g&&v&&v.z<=y;){if(x.x>=d&&x.x<=m&&x.y>=f&&x.y<=_&&x!==n&&x!==a&&Rs(s,u,l,h,c,p,x.x,x.y)&&Os(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,v.x>=d&&v.x<=m&&v.y>=f&&v.y<=_&&v!==n&&v!==a&&Rs(s,u,l,h,c,p,v.x,v.y)&&Os(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;x&&x.z>=g;){if(x.x>=d&&x.x<=m&&x.y>=f&&x.y<=_&&x!==n&&x!==a&&Rs(s,u,l,h,c,p,x.x,x.y)&&Os(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;v&&v.z<=y;){if(v.x>=d&&v.x<=m&&v.y>=f&&v.y<=_&&v!==n&&v!==a&&Rs(s,u,l,h,c,p,v.x,v.y)&&Os(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Ms(e,t,i){var r=e;do{var n=r.prev,o=r.next.next;!Vs(n,o)&&Us(n,r,r.next,o)&&Gs(n,o)&&Gs(o,n)&&(t.push(n.i/i|0),t.push(r.i/i|0),t.push(o.i/i|0),$s(r),$s(r.next),r=e=o),r=r.next}while(r!==e);return Ss(r)}function Ps(e,t,i,r,n,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&Fs(a,s)){var l=Zs(a,s);return a=Ss(a,a.next),l=Ss(l,l.next),As(a,t,i,r,n,o,0),void As(l,t,i,r,n,o,0)}s=s.next}a=a.next}while(a!==e)}function Ds(e,t){return e.x-t.x}function zs(e,t){var i=function(e,t){var i,r=t,n=e.x,o=e.y,a=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var s=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=n&&s>a&&(a=s,i=r.x<r.next.x?r:r.next,s===n))return i}r=r.next}while(r!==t);if(!i)return null;var l,c=i,u=i.x,h=i.y,p=1/0;r=i;do{n>=r.x&&r.x>=u&&n!==r.x&&Rs(o<h?n:a,o,u,h,o<h?a:n,o,r.x,r.y)&&(l=Math.abs(o-r.y)/(n-r.x),Gs(r,e)&&(l<p||l===p&&(r.x>i.x||r.x===i.x&&ks(i,r)))&&(i=r,p=l)),r=r.next}while(r!==c);return i}(e,t);if(!i)return t;var r=Zs(i,e);return Ss(r,r.next),Ss(i,i.next)}function ks(e,t){return Os(e.prev,e,t.prev)<0&&Os(t.next,e,e.next)<0}function Ls(e,t,i,r,n){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Bs(e){var t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function Rs(e,t,i,r,n,o,a,s){return(n-a)*(t-s)>=(e-a)*(o-s)&&(e-a)*(r-s)>=(i-a)*(t-s)&&(i-a)*(o-s)>=(n-a)*(r-s)}function Fs(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&Us(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(Gs(e,t)&&Gs(t,e)&&function(e,t){var i=e,r=!1,n=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==e);return r}(e,t)&&(Os(e.prev,e,t.prev)||Os(e,t.prev,t))||Vs(e,t)&&Os(e.prev,e,e.next)>0&&Os(t.prev,t,t.next)>0)}function Os(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Vs(e,t){return e.x===t.x&&e.y===t.y}function Us(e,t,i,r){var n=Ns(Os(e,t,i)),o=Ns(Os(e,t,r)),a=Ns(Os(i,r,e)),s=Ns(Os(i,r,t));return n!==o&&a!==s||!(0!==n||!js(e,i,t))||!(0!==o||!js(e,r,t))||!(0!==a||!js(i,e,r))||!(0!==s||!js(i,t,r))}function js(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Ns(e){return e>0?1:e<0?-1:0}function Gs(e,t){return Os(e.prev,e,e.next)<0?Os(e,t,e.next)>=0&&Os(e,e.prev,t)>=0:Os(e,t,e.prev)<0||Os(e,e.next,t)<0}function Zs(e,t){var i=new Ws(e.i,e.x,e.y),r=new Ws(t.i,t.x,t.y),n=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function qs(e,t,i,r){var n=new Ws(e,t,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function $s(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Ws(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Hs(e,t,i,r){for(var n=0,o=t,a=i-r;o<i;o+=r)n+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return n}function Xs(e,t,i,r,n){Ks(e,t,i||0,r||e.length-1,n||Ys)}function Ks(e,t,i,r,n){for(;r>i;){if(r-i>600){var o=r-i+1,a=t-i+1,s=Math.log(o),l=.5*Math.exp(2*s/3),c=.5*Math.sqrt(s*l*(o-l)/o)*(a-o/2<0?-1:1);Ks(e,t,Math.max(i,Math.floor(t-a*l/o+c)),Math.min(r,Math.floor(t+(o-a)*l/o+c)),n)}var u=e[t],h=i,p=r;for(Js(e,i,t),n(e[r],u)>0&&Js(e,i,r);h<p;){for(Js(e,h,p),h++,p--;n(e[h],u)<0;)h++;for(;n(e[p],u)>0;)p--}0===n(e[i],u)?Js(e,i,p):Js(e,++p,r),p<=t&&(i=p+1),t<=p&&(r=p-1)}}function Js(e,t,i){var r=e[t];e[t]=e[i],e[i]=r}function Ys(e,t){return e<t?-1:e>t?1:0}function Qs(e,t){const i=e.length;if(i<=1)return[e];const r=[];let n,o;for(let t=0;t<i;t++){const i=F(e[t]);0!==i&&(e[t].area=Math.abs(i),void 0===o&&(o=i<0),o===i<0?(n&&r.push(n),n=[e[t]]):n.push(e[t]))}if(n&&r.push(n),t>1)for(let e=0;e<r.length;e++)r[e].length<=t||(Xs(r[e],t,1,r[e].length-1,el),r[e]=r[e].slice(0,t));return r}function el(e,t){return t.area-e.area}function tl(e,t,i){const r=i.patternDependencies;let n=!1;for(const i of t){const t=i.paint.get(`${e}-pattern`);t.isConstant()||(n=!0);const o=t.constantOr(null);o&&(n=!0,r[o.to]=!0,r[o.from]=!0)}return n}function il(e,t,i,r,n){const o=n.patternDependencies;for(const a of t){const t=a.paint.get(`${e}-pattern`).value;if("constant"!==t.kind){let e=t.evaluate({zoom:r-1},i,{},n.availableImages),s=t.evaluate({zoom:r},i,{},n.availableImages),l=t.evaluate({zoom:r+1},i,{},n.availableImages);e=e&&e.name?e.name:e,s=s&&s.name?s.name:s,l=l&&l.name?l.name:l,o[e]=!0,o[s]=!0,o[l]=!0,i.patterns[a.id]={min:e,mid:s,max:l}}}return i}Ts.deviation=function(e,t,i,r){var n=t&&t.length,o=Math.abs(Hs(e,0,n?t[0]*i:e.length,i));if(n)for(var a=0,s=t.length;a<s;a++)o-=Math.abs(Hs(e,t[a]*i,a<s-1?t[a+1]*i:e.length,i));var l=0;for(a=0;a<r.length;a+=3){var c=r[a]*i,u=r[a+1]*i,h=r[a+2]*i;l+=Math.abs((e[c]-e[h])*(e[u+1]-e[c+1])-(e[c]-e[u])*(e[h+1]-e[c+1]))}return 0===o&&0===l?0:Math.abs((l-o)/o)},Ts.flatten=function(e){for(var t=e[0][0].length,i={vertices:[],holes:[],dimensions:t},r=0,n=0;n<e.length;n++){for(var o=0;o<e[n].length;o++)for(var a=0;a<t;a++)i.vertices.push(e[n][o][a]);n>0&&i.holes.push(r+=e[n-1].length)}return i},bs.default=ws;class FillBucket{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new StructArrayLayout2i4,this.indexArray=new StructArrayLayout3ui6,this.indexArray2=new StructArrayLayout2ui4,this.programConfigurations=new ProgramConfigurationSet(e.layers,e.zoom),this.segments=new SegmentVector,this.segments2=new SegmentVector,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.projection=e.projection}populate(e,t,i,r){this.hasPattern=tl("fill",this.layers,t);const n=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:a,id:s,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Zo(a,e);if(!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom),u,i))continue;const h=n?n.evaluate(u,{},i,t.availableImages):void 0,p={id:s,properties:a.properties,type:a.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:Go(a,i,r),patterns:{},sortKey:h};o.push(p)}n&&o.sort(((e,t)=>e.sortKey-t.sortKey));for(const r of o){const{geometry:n,index:o,sourceLayerIndex:a}=r;if(this.hasPattern){const e=il("fill",this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,n,o,i,{},t.availableImages);t.featureIndex.insert(e[o].feature,n,o,a,this.index)}}update(e,t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i,r)}addFeatures(e,t,i,r,n){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,vs),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),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(e,t,i,r,n,o=[]){for(const e of Qs(t,500)){let t=0;for(const i of e)t+=i.length;const i=this.segments.prepareSegment(t,this.layoutVertexArray,this.indexArray),r=i.vertexLength,n=[],o=[];for(const t of e){if(0===t.length)continue;t!==e[0]&&o.push(n.length/2);const i=this.segments2.prepareSegment(t.length,this.layoutVertexArray,this.indexArray2),r=i.vertexLength;this.layoutVertexArray.emplaceBack(t[0].x,t[0].y),this.indexArray2.emplaceBack(r+t.length-1,r),n.push(t[0].x),n.push(t[0].y);for(let e=1;e<t.length;e++)this.layoutVertexArray.emplaceBack(t[e].x,t[e].y),this.indexArray2.emplaceBack(r+e-1,r+e),n.push(t[e].x),n.push(t[e].y);i.vertexLength+=t.length,i.primitiveLength+=t.length}const a=bs(n,o);for(let e=0;e<a.length;e+=3)this.indexArray.emplaceBack(r+a[e],r+a[e+1],r+a[e+2]);i.vertexLength+=t,i.primitiveLength+=a.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,n,o,r)}}En(FillBucket,"FillBucket",{omit:["layers","patternFeatures"]});const rl=new Properties({"fill-sort-key":new DataDrivenProperty(ct.layout_fill["fill-sort-key"])});var nl={paint:new Properties({"fill-antialias":new DataConstantProperty(ct.paint_fill["fill-antialias"]),"fill-opacity":new DataDrivenProperty(ct.paint_fill["fill-opacity"]),"fill-color":new DataDrivenProperty(ct.paint_fill["fill-color"]),"fill-outline-color":new DataDrivenProperty(ct.paint_fill["fill-outline-color"]),"fill-translate":new DataConstantProperty(ct.paint_fill["fill-translate"]),"fill-translate-anchor":new DataConstantProperty(ct.paint_fill["fill-translate-anchor"]),"fill-pattern":new CrossFadedDataDrivenProperty(ct.paint_fill["fill-pattern"])}),layout:rl};const ol=eo([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),al=eo([{name:"a_centroid_pos",components:2,type:"Uint16"}]),sl=eo([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:ll}=ol;var cl=ul;function ul(e,t,i,r,n){this.properties={},this.extent=i,this.type=0,this._pbf=e,this._geometry=-1,this._keys=r,this._values=n,e.readFields(hl,this,t)}function hl(e,t,i){1==e?t.id=i.readVarint():2==e?function(e,t){for(var i=e.readVarint()+e.pos;e.pos<i;){var r=t._keys[e.readVarint()],n=t._values[e.readVarint()];t.properties[r]=n}}(i,t):3==e?t.type=i.readVarint():4==e&&(t._geometry=i.pos)}function pl(e){for(var t,i,r=0,n=0,o=e.length,a=o-1;n<o;a=n++)r+=((i=e[a]).x-(t=e[n]).x)*(t.y+i.y);return r}ul.types=["Unknown","Point","LineString","Polygon"],ul.prototype.loadGeometry=function(){var e=this._pbf;e.pos=this._geometry;for(var t,i=e.readVarint()+e.pos,n=1,o=0,a=0,s=0,l=[];e.pos<i;){if(o<=0){var c=e.readVarint();n=7&c,o=c>>3}if(o--,1===n||2===n)a+=e.readSVarint(),s+=e.readSVarint(),1===n&&(t&&l.push(t),t=[]),t.push(new r(a,s));else{if(7!==n)throw new Error("unknown command "+n);t&&t.push(t[0].clone())}}return t&&l.push(t),l},ul.prototype.bbox=function(){var e=this._pbf;e.pos=this._geometry;for(var t=e.readVarint()+e.pos,i=1,r=0,n=0,o=0,a=1/0,s=-1/0,l=1/0,c=-1/0;e.pos<t;){if(r<=0){var u=e.readVarint();i=7&u,r=u>>3}if(r--,1===i||2===i)(n+=e.readSVarint())<a&&(a=n),n>s&&(s=n),(o+=e.readSVarint())<l&&(l=o),o>c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[a,l,s,c]},ul.prototype.toGeoJSON=function(e,t,i){var r,n,o=this.extent*Math.pow(2,i),a=this.extent*e,s=this.extent*t,l=this.loadGeometry(),c=ul.types[this.type];function u(e){for(var t=0;t<e.length;t++){var i=e[t];e[t]=[360*(i.x+a)/o-180,360/Math.PI*Math.atan(Math.exp((180-360*(i.y+s)/o)*Math.PI/180))-90]}}switch(this.type){case 1:var h=[];for(r=0;r<l.length;r++)h[r]=l[r][0];u(l=h);break;case 2:for(r=0;r<l.length;r++)u(l[r]);break;case 3:for(l=function(e){var t=e.length;if(t<=1)return[e];for(var i,r,n=[],o=0;o<t;o++){var a=pl(e[o]);0!==a&&(void 0===r&&(r=a<0),r===a<0?(i&&n.push(i),i=[e[o]]):i.push(e[o]))}return i&&n.push(i),n}(l),r=0;r<l.length;r++)for(n=0;n<l[r].length;n++)u(l[r][n])}1===l.length?l=l[0]:c="Multi"+c;var p={type:"Feature",geometry:{type:c,coordinates:l},properties:this.properties};return"id"in this&&(p.id=this.id),p};var dl=fl;function fl(e,t){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(ml,this,t),this.length=this._features.length}function ml(e,t,i){15===e?t.version=i.readVarint():1===e?t.name=i.readString():5===e?t.extent=i.readVarint():2===e?t._features.push(i.pos):3===e?t._keys.push(i.readString()):4===e&&t._values.push(function(e){for(var t=null,i=e.readVarint()+e.pos;e.pos<i;){var r=e.readVarint()>>3;t=1===r?e.readString():2===r?e.readFloat():3===r?e.readDouble():4===r?e.readVarint64():5===r?e.readVarint():6===r?e.readSVarint():7===r?e.readBoolean():null}return t}(i))}function _l(e,t,i){if(3===e){var r=new dl(i,i.readVarint()+i.pos);r.length&&(t[r.name]=r)}}fl.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var t=this._pbf.readVarint()+this._pbf.pos;return new cl(this._pbf,t,this.extent,this._keys,this._values)};var gl={VectorTile:function(e,t){this.layers=e.readFields(_l,{},t)},VectorTileFeature:cl,VectorTileLayer:dl};function yl(e,t,i,n){const o=[],a=0===n?(e,t,i,n,o,a)=>{e.push(new r(a,i+(a-t)/(n-t)*(o-i)))}:(e,t,i,n,o,a)=>{e.push(new r(t+(a-i)/(o-i)*(n-t),a))};for(const r of e){const e=[];for(const o of r){if(o.length<=2)continue;const r=[];for(let e=0;e<o.length-1;e++){const s=o[e].x,l=o[e].y,c=o[e+1].x,u=o[e+1].y,h=0===n?s:l,p=0===n?c:u;h<t?p>t&&a(r,s,l,c,u,t):h>i?p<i&&a(r,s,l,c,u,i):r.push(o[e]),p<t&&h>=t&&a(r,s,l,c,u,t),p>i&&h<=i&&a(r,s,l,c,u,i)}let s=o[o.length-1];const l=0===n?s.x:s.y;l>=t&&l<=i&&r.push(s),r.length&&(s=r[r.length-1],r[0].x===s.x&&r[0].y===s.y||r.push(r[0]),e.push(r))}e.length&&o.push(e)}return o}const xl=gl.VectorTileFeature.types,vl=Math.pow(2,13);function bl(e,t,i,r,n,o,a,s){e.emplaceBack((t<<1)+a,(i<<1)+o,(Math.floor(r*vl)<<1)+n,Math.round(s))}function wl(e,t,i){const r=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*r,i[1]*r,i[2]*r)}class PartMetadata{constructor(){this.acc=new r(0,0),this.polyCount=[]}startRing(e){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new r(e.x,e.y),this.max=new r(e.x,e.y))}append(e,t){this.currentPolyCount.edges++,this.acc._add(e);const i=this.min,r=this.max;e.x<i.x?i.x=e.x:e.x>r.x&&(r.x=e.x),e.y<i.y?i.y=e.y:e.y>r.y&&(r.y=e.y),((0===e.x||e.x===Eo)&&e.x===t.x)!=((0===e.y||e.y===Eo)&&e.y===t.y)&&this.processBorderOverlap(e,t),t.x<0!=e.x<0&&this.addBorderIntersection(0,xi(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>Eo!=e.x>Eo&&this.addBorderIntersection(1,xi(t.y,e.y,(Eo-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,xi(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>Eo!=e.y>Eo&&this.addBorderIntersection(3,xi(t.x,e.x,(Eo-t.y)/(e.y-t.y)))}addBorderIntersection(e,t){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 i=this.borders[e];t<i[0]&&(i[0]=t),t>i[1]&&(i[1]=t)}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const i=0===e.x?0:1;this.addBorderIntersection(i,t.y),this.addBorderIntersection(i,e.y)}else{const i=0===e.y?2:3;this.addBorderIntersection(i,t.x),this.addBorderIntersection(i,e.x)}}centroid(){const e=this.polyCount.reduce(((e,t)=>e+t.edges),0);return 0!==e?this.acc.div(e)._round():new r(0,0)}span(){return new r(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce(((e,t)=>e+ +(t[0]!==Number.MAX_VALUE)),0)}}class FillExtrusionBucket{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.layoutVertexArray=new StructArrayLayout4i8,this.centroidVertexArray=new FillExtrusionCentroidArray,this.indexArray=new StructArrayLayout3ui6,this.programConfigurations=new ProgramConfigurationSet(e.layers,e.zoom),this.segments=new SegmentVector,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.enableTerrain=e.enableTerrain}populate(e,t,i,r){this.features=[],this.hasPattern=tl("fill-extrusion",this.layers,t),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(e){const t=Math.exp(Math.PI*(1-e.y/(1<<e.z)*2));return 80150034*t/(t*t+1)/Eo/(1<<e.z)}(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:n,id:o,index:a,sourceLayerIndex:s}of e){const e=this.layers[0]._featureFilter.needGeometry,l=Zo(n,e);if(!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:s,index:a,geometry:e?l.geometry:Go(n,i,r),properties:n.properties,type:n.type,patterns:{}},u=this.layoutVertexArray.length;this.hasPattern?this.features.push(il("fill-extrusion",this.layers,c,this.zoom,t)):this.addFeature(c,c.geometry,a,i,{},t.availableImages,r),t.featureIndex.insert(n,c.geometry,a,s,this.index,u)}this.sortBorders()}addFeatures(e,t,i,r,n){for(const e of this.features){const{geometry:o}=e;this.addFeature(e,o,e.index,t,i,r,n)}this.sortBorders()}update(e,t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ll),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,sl.members,!0))),this.programConfigurations.upload(e),this.uploaded=!0}uploadCentroid(e){0!==this.centroidVertexArray.length&&(this.centroidVertexBuffer?this.needsCentroidUpdate&&this.centroidVertexBuffer.updateData(this.centroidVertexArray):this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,al.members,!0),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,t,i,n,o,a,s){const l=[new r(0,0),new r(Eo,Eo)],c=s.projection,u="globe"===c.name,h=this.enableTerrain&&!u?new PartMetadata:null,p="Polygon"===xl[e.type];u&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new FillExtrusionExtArray);const d=Qs(t,500);for(let e=d.length-1;e>=0;e--){const t=d[e];(0===t.length||(f=t[0]).every((e=>e.x<=0))||f.every((e=>e.x>=Eo))||f.every((e=>e.y<=0))||f.every((e=>e.y>=Eo)))&&d.splice(e,1)}var f;let m;if(u)m=Pl(d,l,n);else{m=[];for(const e of d)m.push({polygon:e,bounds:l})}const _=p?this.edgeRadius:0;for(const{polygon:e,bounds:t}of m){let i=0,r=0;for(const t of e)p&&!t[0].equals(t[t.length-1])&&t.push(t[0]),r+=p?t.length-1:t.length;const o=this.segments.prepareSegment((p?5:4)*r,this.layoutVertexArray,this.indexArray);if(p){const t=[],r=[];i=o.vertexLength;for(const i of e){let a,s;i.length&&i!==e[0]&&r.push(t.length/2),a=i[1].sub(i[0])._perp()._unit();for(let e=1;e<i.length;e++){const r=i[e],l=i[e===i.length-1?1:e+1];let{x:h,y:p}=r;if(_){s=l.sub(r)._perp()._unit();const e=a.add(s)._unit(),t=_*Math.min(4,1/(a.x*e.x+a.y*e.y));h+=t*e.x,p+=t*e.y,a=s}bl(this.layoutVertexArray,h,p,0,0,1,1,0),o.vertexLength++,t.push(r.x,r.y),u&&wl(this.layoutVertexExtArray,c.projectTilePoint(h,p,n),c.upVector(n,h,p))}}const a=bs(t,r);for(let e=0;e<a.length;e+=3)this.indexArray.emplaceBack(i+a[e],i+a[e+2],i+a[e+1]),o.primitiveLength++}for(const r of e){h&&r.length&&h.startRing(r[0]);let e,a,s,l=r.length>4&&Cl(r[r.length-2],r[0],r[1]),d=_?El(r[r.length-2],r[0],r[1],_):0;a=r[1].sub(r[0])._perp()._unit();for(let f=1,m=0;f<r.length;f++){let g=r[f-1],y=r[f];const x=r[f===r.length-1?1:f+1];if(h&&p&&h.currentPolyCount.top++,Al(y,g,t)){_&&(a=x.sub(y)._perp()._unit());continue}h&&h.append(y,g);const v=y.sub(g)._perp(),b=v.x/(Math.abs(v.x)+Math.abs(v.y)),w=v.y>0?1:0,T=g.dist(y);if(m+T>32768&&(m=0),_){s=x.sub(y)._perp()._unit();let e=Sl(g,y,x,Tl(a,s),_);isNaN(e)&&(e=0);const t=y.sub(g)._unit();g=g.add(t.mult(d))._round(),y=y.add(t.mult(-e))._round(),d=e,a=s}const E=o.vertexLength,S=r.length>4&&Cl(g,y,x);let A=Il(m,l,!0);if(bl(this.layoutVertexArray,g.x,g.y,b,w,0,0,A),bl(this.layoutVertexArray,g.x,g.y,b,w,0,1,A),m+=T,A=Il(m,S,!1),l=S,bl(this.layoutVertexArray,y.x,y.y,b,w,0,0,A),bl(this.layoutVertexArray,y.x,y.y,b,w,0,1,A),o.vertexLength+=4,this.indexArray.emplaceBack(E+0,E+1,E+2),this.indexArray.emplaceBack(E+1,E+3,E+2),o.primitiveLength+=2,_){const n=i+(1===f?r.length-2:f-2),a=1===f?i:n+1;if(this.indexArray.emplaceBack(E+1,n,E+3),this.indexArray.emplaceBack(n,a,E+3),o.primitiveLength+=2,void 0===e&&(e=E),!Al(x,r[f],t)){const t=f===r.length-1?e:o.vertexLength;this.indexArray.emplaceBack(E+2,E+3,t),this.indexArray.emplaceBack(E+3,t+1,t),this.indexArray.emplaceBack(E+3,a,t+1),o.primitiveLength+=3}}if(u){const e=this.layoutVertexExtArray,t=c.projectTilePoint(g.x,g.y,n),i=c.projectTilePoint(y.x,y.y,n),r=c.upVector(n,g.x,g.y),o=c.upVector(n,y.x,y.y);wl(e,t,r),wl(e,t,r),wl(e,i,o),wl(e,i,o)}}p&&(i+=r.length-1)}}if(h&&h.polyCount.length>0){if(h.borders){h.vertexArrayOffset=this.centroidVertexArray.length;const e=h.borders,t=this.featuresOnBorder.push(h)-1;for(let i=0;i<4;i++)e[i][0]!==Number.MAX_VALUE&&this.borders[i].push(t)}this.encodeCentroid(h.borders?void 0:h.centroid(),h)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,o,a,n)}sortBorders(){for(let e=0;e<4;e++)this.borders[e].sort(((t,i)=>this.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[i].borders[e][0]))}encodeCentroid(e,t,i=!0){let r,n;if(e)if(0!==e.y){const i=t.span()._mult(this.tileToMeter);r=(Math.max(e.x,1)<<3)+Math.min(7,Math.round(i.x/10)),n=(Math.max(e.y,1)<<3)+Math.min(7,Math.round(i.y/10))}else r=Math.ceil(7*(e.x+450)),n=0;else r=0,n=+i;let o=i?this.centroidVertexArray.length:t.vertexArrayOffset;for(const e of t.polyCount){i&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*e.edges+e.top);for(let t=0;t<e.top;t++)this.centroidVertexArray.emplace(o++,r,n);for(let t=0;t<2*e.edges;t++)this.centroidVertexArray.emplace(o++,0,n),this.centroidVertexArray.emplace(o++,r,n)}}}function Tl(e,t){const i=e.add(t)._unit();return e.x*i.x+e.y*i.y}function El(e,t,i,r){const n=t.sub(e)._perp()._unit(),o=i.sub(t)._perp()._unit();return Sl(e,t,i,Tl(n,o),r)}function Sl(e,t,i,r,n){const o=Math.sqrt(1-r*r);return Math.min(e.dist(t)/3,t.dist(i)/3,n*o/r)}function Al(e,t,i){return e.x<i[0].x&&t.x<i[0].x||e.x>i[1].x&&t.x>i[1].x||e.y<i[0].y&&t.y<i[0].y||e.y>i[1].y&&t.y>i[1].y}function Cl(e,t,i){if(e.x<0||e.x>=Eo||t.x<0||t.x>=Eo||i.x<0||i.x>=Eo)return!1;const r=i.sub(t),n=r.perp(),o=e.sub(t);return(r.x*o.x+r.y*o.y)/Math.sqrt((r.x*r.x+r.y*r.y)*(o.x*o.x+o.y*o.y))>-.866&&n.x*o.x+n.y*o.y<0}function Il(e,t,i){const r=t?2|e:-3&e;return i?1|r:-2&r}function Ml(){const e=Math.PI/32,t=Math.tan(e),i=So;return i*Math.sqrt(1+2*t*t)-i}function Pl(e,t,i){const n=1<<i.z,o=Do(i.x/n),a=Do((i.x+1)/n),s=zo(i.y/n),l=zo((i.y+1)/n);return function(e,t,i,n,o=0,a){const s=[];if(!e.length||!i||!n)return s;const l=(e,t)=>{for(const i of e)s.push({polygon:i,bounds:t})},c=Math.ceil(Math.log2(i)),u=Math.ceil(Math.log2(n)),h=c-u,p=[];for(let e=0;e<Math.abs(h);e++)p.push(h>0?0:1);for(let e=0;e<Math.min(c,u);e++)p.push(0),p.push(1);let d=e;if(d=yl(d,t[0].y-o,t[1].y+o,1),d=yl(d,t[0].x-o,t[1].x+o,0),!d.length)return s;const f=[];for(p.length?f.push({polygons:d,bounds:t,depth:0}):l(d,t);f.length;){const e=f.pop(),t=e.depth,i=p[t],n=e.bounds[0],s=e.bounds[1],c=0===i?n.x:n.y,u=0===i?s.x:s.y,h=a?a(i,c,u):.5*(c+u),d=yl(e.polygons,c-o,h+o,i),m=yl(e.polygons,h-o,u+o,i);if(d.length){const e=[n,new r(0===i?h:s.x,1===i?h:s.y)];p.length>t+1?f.push({polygons:d,bounds:e,depth:t+1}):l(d,e)}if(m.length){const e=[new r(0===i?h:n.x,1===i?h:n.y),s];p.length>t+1?f.push({polygons:m,bounds:e,depth:t+1}):l(m,e)}}return s}(e,t,Math.ceil((a-o)/11.25),Math.ceil((s-l)/11.25),1,((e,t,r)=>{if(0===e)return.5*(t+r);{const e=zo((i.y+t/Eo)/n);return(Mo(.5*(zo((i.y+r/Eo)/n)+e))*n-i.y)*Eo}}))}En(FillExtrusionBucket,"FillExtrusionBucket",{omit:["layers","features"]}),En(PartMetadata,"PartMetadata");const Dl=new Properties({"fill-extrusion-edge-radius":new DataConstantProperty(ct["layout_fill-extrusion"]["fill-extrusion-edge-radius"])});var zl={paint:new Properties({"fill-extrusion-opacity":new DataConstantProperty(ct["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new DataDrivenProperty(ct["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new DataConstantProperty(ct["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new DataConstantProperty(ct["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new CrossFadedDataDrivenProperty(ct["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new DataDrivenProperty(ct["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new DataDrivenProperty(ct["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new DataConstantProperty(ct["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new DataConstantProperty(ct["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new DataConstantProperty(ct["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"])}),layout:Dl};function kl(e,t,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return[e*r-2*Math.PI*6378137/2,t*r-2*Math.PI*6378137/2]}class CanonicalTileID{constructor(e,t,i){this.z=e,this.x=t,this.y=i,this.key=Ll(0,e,e,t,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t){const i=function(e,t,i){var r=kl(256*e,256*(t=Math.pow(2,i)-t-1),i),n=kl(256*(e+1),256*(t+1),i);return r[0]+","+r[1]+","+n[0]+","+n[1]}(this.x,this.y,this.z),r=function(e,t,i){let r,n="";for(let o=e;o>0;o--)r=1<<o-1,n+=(t&r?1:0)+(i&r?2:0);return n}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace("{prefix}",(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String("tms"===t?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",r).replace("{bbox-epsg-3857}",i)}toString(){return`${this.z}/${this.x}/${this.y}`}}class UnwrappedTileID{constructor(e,t){this.wrap=e,this.canonical=t,this.key=Ll(e,t.z,t.z,t.x,t.y)}}class OverscaledTileID{constructor(e,t,i,r,n){this.overscaledZ=e,this.wrap=t,this.canonical=new CanonicalTileID(i,+r,+n),this.key=0===t&&e===i?this.canonical.key:Ll(t,e,i,r,n)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){const t=this.canonical.z-e;return e>this.canonical.z?new OverscaledTileID(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new OverscaledTileID(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e,t=!0){if(this.overscaledZ===e&&t)return this.key;if(e>this.canonical.z)return Ll(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-e;return Ll(this.wrap*+t,e,e,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const t=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ<this.overscaledZ&&e.canonical.x===this.canonical.x>>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new OverscaledTileID(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new OverscaledTileID(t,this.wrap,t,i,r),new OverscaledTileID(t,this.wrap,t,i+1,r),new OverscaledTileID(t,this.wrap,t,i,r+1),new OverscaledTileID(t,this.wrap,t,i+1,r+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new OverscaledTileID(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new OverscaledTileID(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new UnwrappedTileID(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function Ll(e,t,i,r,n){const o=1<<Math.min(i,22);let a=o*(n%o)+r%o;return e&&i<22&&(a+=o*o*((e<0?-2*e-1:2*e)%(1<<2*(22-i)))),16*(32*a+i)+(t-i)}function Bl(e,t){return e.x*t.x+e.y*t.y}function Rl(e,t){if(1===e.length){let i=0;const r=t[i++];let n;for(;!n||r.equals(n);)if(n=t[i++],!n)return 1/0;for(;i<t.length;i++){const o=t[i],a=e[0],s=n.sub(r),l=o.sub(r),c=a.sub(r),u=Bl(s,s),h=Bl(s,l),p=Bl(l,l),d=Bl(c,s),f=Bl(c,l),m=u*p-h*h,_=(p*d-h*f)/m,g=(u*f-h*d)/m,y=r.z*(1-_-g)+n.z*_+o.z*g;if(isFinite(y))return y}return 1/0}{let e=1/0;for(const i of t)e=Math.min(e,i.z);return e}}function Fl(e){const t=new r(e[0],e[1]);return t.z=e[2],t}function Ol(e,t,i,r,n,o,a,s){const l=a*n.getElevationAt(e,t,!0,!0),c=0!==o[0],u=c?0===o[1]?a*(o[0]/7-450):a*function(e,t,i){const r=Math.floor(t[0]/8),n=Math.floor(t[1]/8),o=10*(t[0]-8*r),a=10*(t[1]-8*n),s=e.getElevationAt(r,n,!0,!0),l=e.getMeterToDEM(i),c=Math.floor(.5*(o*l-1)),u=Math.floor(.5*(a*l-1)),h=e.tileCoordToPixel(r,n),p=2*c+1,d=2*u+1,f=function(e,t,i,r,n){return[e.getElevationAtPixel(t,i,!0),e.getElevationAtPixel(t+n,i,!0),e.getElevationAtPixel(t,i+n,!0),e.getElevationAtPixel(t+r,i+n,!0)]}(e,h.x-c,h.y-u,p,d),m=Math.abs(f[0]-f[1]),_=Math.abs(f[2]-f[3]),g=Math.abs(f[0]-f[2])+Math.abs(f[1]-f[3]),y=Math.min(.25,.5*l*(m+_)/p),x=Math.min(.25,.5*l*g/d);return s+Math.max(y*o,x*a)}(n,o,s):l;return{base:l+(0===i)?-1:i,top:c?Math.max(u+r,l+i+2):l+r}}En(CanonicalTileID,"CanonicalTileID"),En(OverscaledTileID,"OverscaledTileID",{omit:["projMatrix"]});const Vl=eo([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:Ul}=Vl,jl=eo([{name:"a_packed",components:4,type:"Float32"}]),{members:Nl}=jl,Gl=gl.VectorTileFeature.types,Zl=Math.cos(Math.PI/180*37.5);class LineBucket{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((e=>{this.gradients[e.id]={}})),this.layoutVertexArray=new StructArrayLayout2i4ub1f12,this.layoutVertexArray2=new StructArrayLayout4f16,this.indexArray=new StructArrayLayout3ui6,this.programConfigurations=new ProgramConfigurationSet(e.layers,e.zoom),this.segments=new SegmentVector,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,i,r){this.hasPattern=tl("line",this.layers,t);const n=this.layers[0].layout.get("line-sort-key"),o=[];for(const{feature:t,id:a,index:s,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Zo(t,e);if(!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom),c,i))continue;const u=n?n.evaluate(c,{},i):void 0,h={id:a,properties:t.properties,type:t.type,sourceLayerIndex:l,index:s,geometry:e?c.geometry:Go(t,i,r),patterns:{},sortKey:u};o.push(h)}n&&o.sort(((e,t)=>e.sortKey-t.sortKey));const{lineAtlas:a,featureIndex:s}=t,l=this.addConstantDashes(a);for(const r of o){const{geometry:n,index:o,sourceLayerIndex:c}=r;if(l&&this.addFeatureDashes(r,a),this.hasPattern){const e=il("line",this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,n,o,i,a.positions,t.availableImages);s.insert(e[o].feature,n,o,c,this.index)}}addConstantDashes(e){let t=!1;for(const i of this.layers){const r=i.paint.get("line-dasharray").value,n=i.layout.get("line-cap").value;if("constant"!==r.kind||"constant"!==n.kind)t=!0;else{const t=n.value,i=r.value;if(!i)continue;e.addDash(i.from,t),e.addDash(i.to,t),i.other&&e.addDash(i.other,t)}}return t}addFeatureDashes(e,t){const i=this.zoom;for(const r of this.layers){const n=r.paint.get("line-dasharray").value,o=r.layout.get("line-cap").value;if("constant"===n.kind&&"constant"===o.kind)continue;let a,s,l,c,u,h;if("constant"===n.kind){const e=n.value;if(!e)continue;a=e.other||e.to,s=e.to,l=e.from}else a=n.evaluate({zoom:i-1},e),s=n.evaluate({zoom:i},e),l=n.evaluate({zoom:i+1},e);"constant"===o.kind?c=u=h=o.value:(c=o.evaluate({zoom:i-1},e),u=o.evaluate({zoom:i},e),h=o.evaluate({zoom:i+1},e)),t.addDash(a,c),t.addDash(s,u),t.addDash(l,h);const p=t.getKey(a,c),d=t.getKey(s,u),f=t.getKey(l,h);e.patterns[r.id]={min:p,mid:d,max:f}}}update(e,t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i,r)}addFeatures(e,t,i,r,n){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Nl)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ul),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&e.properties.hasOwnProperty("mapbox_clip_start")&&e.properties.hasOwnProperty("mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,t,i,r,n,o){const a=this.layers[0].layout,s=a.get("line-join").evaluate(e,{}),l=a.get("line-cap").evaluate(e,{}),c=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const i of t)this.addLine(i,e,s,l,c,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,n,o,r)}addLine(e,t,i,r,n,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t<e.length-1;t++)this.totalDistance+=e[t].dist(e[t+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const a="Polygon"===Gl[t.type];let s=e.length;for(;s>=2&&e[s-1].equals(e[s-2]);)s--;let l=0;for(;l<s-1&&e[l].equals(e[l+1]);)l++;if(s<(a?3:2))return;"bevel"===i&&(n=1.05);const c=this.overscaling<=16?122880/(512*this.overscaling):0,u=this.segments.prepareSegment(10*s,this.layoutVertexArray,this.indexArray);let h,p,d,f,m;this.e1=this.e2=-1,a&&(h=e[s-2],m=e[l].sub(h)._unit()._perp());for(let t=l;t<s;t++){if(d=t===s-1?a?e[l+1]:void 0:e[t+1],d&&e[t].equals(d))continue;m&&(f=m),h&&(p=h),h=e[t],m=d?d.sub(h)._unit()._perp():f,f=f||m;let _=f.add(m);0===_.x&&0===_.y||_._unit();const g=f.x*m.x+f.y*m.y,y=_.x*m.x+_.y*m.y,x=0!==y?1/y:1/0,v=2*Math.sqrt(2-2*y),b=y<Zl&&p&&d,w=f.x*m.y-f.y*m.x>0;if(b&&t>l){const e=h.dist(p);if(e>2*c){const t=h.sub(h.sub(p)._mult(c/e)._round());this.updateDistance(p,t),this.addCurrentVertex(t,f,0,0,u),p=t}}const T=p&&d;let E=T?i:a?"butt":r;if(T&&"round"===E&&(x<o?E="miter":x<=2&&(E="fakeround")),"miter"===E&&x>n&&(E="bevel"),"bevel"===E&&(x>2&&(E="flipbevel"),x<n&&(E="miter")),p&&this.updateDistance(p,h),"miter"===E)_._mult(x),this.addCurrentVertex(h,_,0,0,u);else if("flipbevel"===E){if(x>100)_=m.mult(-1);else{const e=x*f.add(m).mag()/f.sub(m).mag();_._perp()._mult(e*(w?-1:1))}this.addCurrentVertex(h,_,0,0,u),this.addCurrentVertex(h,_.mult(-1),0,0,u)}else if("bevel"===E||"fakeround"===E){const e=-Math.sqrt(x*x-1),t=w?e:0,i=w?0:e;if(p&&this.addCurrentVertex(h,f,t,i,u),"fakeround"===E){const e=Math.round(180*v/Math.PI/20);for(let t=1;t<e;t++){let i=t/e;if(.5!==i){const e=i-.5;i+=i*e*(i-1)*((1.0904+g*(g*(3.55645-1.43519*g)-3.2452))*e*e+(.848013+g*(.215638*g-1.06021)))}const r=m.sub(f)._mult(i)._add(f)._unit()._mult(w?-1:1);this.addHalfVertex(h,r.x,r.y,!1,w,0,u)}}d&&this.addCurrentVertex(h,m,-t,-i,u)}else if("butt"===E)this.addCurrentVertex(h,_,0,0,u);else if("square"===E){const e=p?1:-1;p||this.addCurrentVertex(h,_,e,e,u),this.addCurrentVertex(h,_,0,0,u),p&&this.addCurrentVertex(h,_,e,e,u)}else"round"===E&&(p&&(this.addCurrentVertex(h,f,0,0,u),this.addCurrentVertex(h,f,1,1,u,!0)),d&&(this.addCurrentVertex(h,m,-1,-1,u,!0),this.addCurrentVertex(h,m,0,0,u)));if(b&&t<s-1){const e=h.dist(d);if(e>2*c){const t=h.add(d.sub(h)._mult(c/e)._round());this.updateDistance(h,t),this.addCurrentVertex(t,m,0,0,u),h=t}}}}addCurrentVertex(e,t,i,r,n,o=!1){const a=t.y*r-t.x,s=-t.y-t.x*r;this.addHalfVertex(e,t.x+t.y*i,t.y-t.x*i,o,!1,i,n),this.addHalfVertex(e,a,s,o,!0,-r,n)}addHalfVertex({x:e,y:t},i,r,n,o,a,s){this.layoutVertexArray.emplaceBack((e<<1)+(n?1:0),(t<<1)+(o?1:0),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===a?0:a<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const l=s.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,l),s.primitiveLength++),o?this.e2=l:this.e1=l}updateScaledDistance(){if(this.lineClips){const e=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}}En(LineBucket,"LineBucket",{omit:["layers","patternFeatures"]});const ql=new Properties({"line-cap":new DataDrivenProperty(ct.layout_line["line-cap"]),"line-join":new DataDrivenProperty(ct.layout_line["line-join"]),"line-miter-limit":new DataConstantProperty(ct.layout_line["line-miter-limit"]),"line-round-limit":new DataConstantProperty(ct.layout_line["line-round-limit"]),"line-sort-key":new DataDrivenProperty(ct.layout_line["line-sort-key"])});var $l={paint:new Properties({"line-opacity":new DataDrivenProperty(ct.paint_line["line-opacity"]),"line-color":new DataDrivenProperty(ct.paint_line["line-color"]),"line-translate":new DataConstantProperty(ct.paint_line["line-translate"]),"line-translate-anchor":new DataConstantProperty(ct.paint_line["line-translate-anchor"]),"line-width":new DataDrivenProperty(ct.paint_line["line-width"]),"line-gap-width":new DataDrivenProperty(ct.paint_line["line-gap-width"]),"line-offset":new DataDrivenProperty(ct.paint_line["line-offset"]),"line-blur":new DataDrivenProperty(ct.paint_line["line-blur"]),"line-dasharray":new CrossFadedDataDrivenProperty(ct.paint_line["line-dasharray"]),"line-pattern":new CrossFadedDataDrivenProperty(ct.paint_line["line-pattern"]),"line-gradient":new ColorRampProperty(ct.paint_line["line-gradient"]),"line-trim-offset":new DataConstantProperty(ct.paint_line["line-trim-offset"])}),layout:ql};const Wl=new class LineFloorwidthProperty extends DataDrivenProperty{possiblyEvaluate(e,t){return t=new EvaluationParameters(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,r){return t=b({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,r)}}($l.paint.properties["line-width"].specification);function Hl(e,t){return t>0?t+2*e:e}Wl.useIntegerZoom=!0;const Xl=eo([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Kl=eo([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Jl=eo([{name:"a_projected_pos",components:4,type:"Float32"}],4);eo([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Yl=eo([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),Ql=eo([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);eo([{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 ec=eo([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),tc=eo([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);eo([{name:"triangle",components:3,type:"Uint16"}]),eo([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),eo([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),eo([{type:"Float32",name:"offsetX"}]),eo([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);const ic=128;function rc(e,t){const{expression:i}=t;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new EvaluationParameters(e+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:r}=i;let n=0;for(;n<t.length&&t[n]<=e;)n++;n=Math.max(0,n-1);let o=n;for(;o<t.length&&t[o]<e+1;)o++;o=Math.min(t.length-1,o);const a=t[n],s=t[o];return"composite"===i.kind?{kind:"composite",minZoom:a,maxZoom:s,interpolationType:r}:{kind:"camera",minZoom:a,maxZoom:s,minSize:i.evaluate(new EvaluationParameters(a)),maxSize:i.evaluate(new EvaluationParameters(s)),interpolationType:r}}}function nc(e,{uSize:t,uSizeT:i},{lowerSize:r,upperSize:n}){return"source"===e.kind?r/ic:"composite"===e.kind?xi(r/ic,n/ic,i):t}function oc(e,t){let i=0,r=0;if("constant"===e.kind)r=e.layoutSize;else if("source"!==e.kind){const{interpolationType:n,minZoom:o,maxZoom:a}=e,s=n?_(Ui.interpolationFactor(n,t,o,a),0,1):0;"camera"===e.kind?r=xi(e.minSize,e.maxSize,s):i=s}return{uSizeT:i,uSize:r}}var ac=Object.freeze({__proto__:null,getSizeData:rc,evaluateSizeForFeature:nc,evaluateSizeForZoom:oc,SIZE_PACK_FACTOR:ic});function sc(e,t,i){return e.sections.forEach((e=>{e.text=function(e,t,i){const r=t.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?e=e.toLocaleUpperCase():"lowercase"===r&&(e=e.toLocaleLowerCase()),e}(e.text,t,i)})),e}const lc={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var cc=function(e,t,i,r,n){var o,a,s=8*n-r-1,l=(1<<s)-1,c=l>>1,u=-7,h=i?n-1:0,p=i?-1:1,d=e[t+h];for(h+=p,o=d&(1<<-u)-1,d>>=-u,u+=s;u>0;o=256*o+e[t+h],h+=p,u-=8);for(a=o&(1<<-u)-1,o>>=-u,u+=r;u>0;a=256*a+e[t+h],h+=p,u-=8);if(0===o)o=1-c;else{if(o===l)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,r),o-=c}return(d?-1:1)*a*Math.pow(2,o-r)},uc=function(e,t,i,r,n,o){var a,s,l,c=8*o-n-1,u=(1<<c)-1,h=u>>1,p=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,f=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=u):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),(t+=a+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(a++,l/=2),a+h>=u?(s=0,a=u):a+h>=1?(s=(t*l-1)*Math.pow(2,n),a+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,n),a=0));n>=8;e[i+d]=255&s,d+=f,s/=256,n-=8);for(a=a<<n|s,c+=n;c>0;e[i+d]=255&a,d+=f,a/=256,c-=8);e[i+d-f]|=128*m},hc=pc;function pc(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}pc.Varint=0,pc.Fixed64=1,pc.Bytes=2,pc.Fixed32=5;var dc=4294967296,fc=1/dc,mc="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function _c(e){return e.type===pc.Bytes?e.readVarint()+e.pos:e.pos+1}function gc(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function yc(e,t,i){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(r);for(var n=i.pos-1;n>=e;n--)i.buf[n+r]=i.buf[n]}function xc(e,t){for(var i=0;i<e.length;i++)t.writeVarint(e[i])}function vc(e,t){for(var i=0;i<e.length;i++)t.writeSVarint(e[i])}function bc(e,t){for(var i=0;i<e.length;i++)t.writeFloat(e[i])}function wc(e,t){for(var i=0;i<e.length;i++)t.writeDouble(e[i])}function Tc(e,t){for(var i=0;i<e.length;i++)t.writeBoolean(e[i])}function Ec(e,t){for(var i=0;i<e.length;i++)t.writeFixed32(e[i])}function Sc(e,t){for(var i=0;i<e.length;i++)t.writeSFixed32(e[i])}function Ac(e,t){for(var i=0;i<e.length;i++)t.writeFixed64(e[i])}function Cc(e,t){for(var i=0;i<e.length;i++)t.writeSFixed64(e[i])}function Ic(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+16777216*e[t+3]}function Mc(e,t,i){e[i]=t,e[i+1]=t>>>8,e[i+2]=t>>>16,e[i+3]=t>>>24}function Pc(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function Dc(e,t,i){t.glyphs=[],1===e&&i.readMessage(zc,t)}function zc(e,t,i){if(3===e){const{id:e,bitmap:r,width:n,height:o,left:a,top:s,advance:l}=i.readMessage(kc,{});t.glyphs.push({id:e,bitmap:new AlphaImage({width:n+6,height:o+6},r),metrics:{width:n,height:o,left:a,top:s,advance:l}})}else 4===e?t.ascender=i.readSVarint():5===e&&(t.descender=i.readSVarint())}function kc(e,t,i){1===e?t.id=i.readVarint():2===e?t.bitmap=i.readBytes():3===e?t.width=i.readVarint():4===e?t.height=i.readVarint():5===e?t.left=i.readSVarint():6===e?t.top=i.readSVarint():7===e&&(t.advance=i.readVarint())}function Lc(e){let t=0,i=0;for(const r of e)t+=r.w*r.h,i=Math.max(i,r.w);e.sort(((e,t)=>t.h-e.h));const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let n=0,o=0;for(const t of e)for(let e=r.length-1;e>=0;e--){const i=r[e];if(!(t.w>i.w||t.h>i.h)){if(t.x=i.x,t.y=i.y,o=Math.max(o,t.y+t.h),n=Math.max(n,t.x+t.w),t.w===i.w&&t.h===i.h){const t=r.pop();e<r.length&&(r[e]=t)}else t.h===i.h?(i.x+=t.w,i.w-=t.w):t.w===i.w?(i.y+=t.h,i.h-=t.h):(r.push({x:i.x+t.w,y:i.y,w:i.w-t.w,h:t.h}),i.y+=t.h,i.h-=t.h);break}}return{w:n,h:o,fill:t/(n*o)||0}}pc.prototype={destroy:function(){this.buf=null},readFields:function(e,t,i){for(i=i||this.length;this.pos<i;){var r=this.readVarint(),n=r>>3,o=this.pos;this.type=7&r,e(n,t,this),this.pos===o&&this.skip(r)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=Ic(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=Pc(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=Ic(this.buf,this.pos)+Ic(this.buf,this.pos+4)*dc;return this.pos+=8,e},readSFixed64:function(){var e=Ic(this.buf,this.pos)+Pc(this.buf,this.pos+4)*dc;return this.pos+=8,e},readFloat:function(){var e=cc(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=cc(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t,i,r=this.buf;return t=127&(i=r[this.pos++]),i<128?t:(t|=(127&(i=r[this.pos++]))<<7,i<128?t:(t|=(127&(i=r[this.pos++]))<<14,i<128?t:(t|=(127&(i=r[this.pos++]))<<21,i<128?t:function(e,t,i){var r,n,o=i.buf;if(r=(112&(n=o[i.pos++]))>>4,n<128)return gc(e,r,t);if(r|=(127&(n=o[i.pos++]))<<3,n<128)return gc(e,r,t);if(r|=(127&(n=o[i.pos++]))<<10,n<128)return gc(e,r,t);if(r|=(127&(n=o[i.pos++]))<<17,n<128)return gc(e,r,t);if(r|=(127&(n=o[i.pos++]))<<24,n<128)return gc(e,r,t);if(r|=(1&(n=o[i.pos++]))<<31,n<128)return gc(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(i=r[this.pos]))<<28,e,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&mc?function(e,t,i){return mc.decode(e.subarray(t,i))}(this.buf,t,e):function(e,t,i){for(var r="",n=t;n<i;){var o,a,s,l=e[n],c=null,u=l>239?4:l>223?3:l>191?2:1;if(n+u>i)break;1===u?l<128&&(c=l):2===u?128==(192&(o=e[n+1]))&&(c=(31&l)<<6|63&o)<=127&&(c=null):3===u?(a=e[n+2],128==(192&(o=e[n+1]))&&128==(192&a)&&((c=(15&l)<<12|(63&o)<<6|63&a)<=2047||c>=55296&&c<=57343)&&(c=null)):4===u&&(a=e[n+2],s=e[n+3],128==(192&(o=e[n+1]))&&128==(192&a)&&128==(192&s)&&((c=(15&l)<<18|(63&o)<<12|(63&a)<<6|63&s)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,u=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),n+=u}return r}(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==pc.Bytes)return e.push(this.readVarint(t));var i=_c(this);for(e=e||[];this.pos<i;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==pc.Bytes)return e.push(this.readSVarint());var t=_c(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==pc.Bytes)return e.push(this.readBoolean());var t=_c(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==pc.Bytes)return e.push(this.readFloat());var t=_c(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==pc.Bytes)return e.push(this.readDouble());var t=_c(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==pc.Bytes)return e.push(this.readFixed32());var t=_c(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==pc.Bytes)return e.push(this.readSFixed32());var t=_c(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==pc.Bytes)return e.push(this.readFixed64());var t=_c(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==pc.Bytes)return e.push(this.readSFixed64());var t=_c(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var t=7&e;if(t===pc.Varint)for(;this.buf[this.pos++]>127;);else if(t===pc.Bytes)this.pos=this.readVarint()+this.pos;else if(t===pc.Fixed32)this.pos+=4;else{if(t!==pc.Fixed64)throw new Error("Unimplemented type: "+t);this.pos+=8}},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t<this.pos+e;)t*=2;if(t!==this.length){var i=new Uint8Array(t);i.set(this.buf),this.buf=i,this.length=t}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(e){this.realloc(4),Mc(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),Mc(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),Mc(this.buf,-1&e,this.pos),Mc(this.buf,Math.floor(e*fc),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),Mc(this.buf,-1&e,this.pos),Mc(this.buf,Math.floor(e*fc),this.pos+4),this.pos+=8},writeVarint:function(e){(e=+e||0)>268435455||e<0?function(e,t){var i,r;if(e>=0?(i=e%4294967296|0,r=e/4294967296|0):(r=~(-e/4294967296),4294967295^(i=~(-e%4294967296))?i=i+1|0:(i=0,r=r+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,i){i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,i.buf[i.pos]=127&(e>>>=7)}(i,0,t),function(e,t){var i=(7&e)<<4;t.buf[t.pos++]|=i|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))))}(r,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))},writeSVarint:function(e){this.writeVarint(e<0?2*-e-1:2*e)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(4*e.length),this.pos++;var t=this.pos;this.pos=function(e,t,i){for(var r,n,o=0;o<t.length;o++){if((r=t.charCodeAt(o))>55295&&r<57344){if(!n){r>56319||o+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):n=r;continue}if(r<56320){e[i++]=239,e[i++]=191,e[i++]=189,n=r;continue}r=n-55296<<10|r-56320|65536,n=null}else n&&(e[i++]=239,e[i++]=191,e[i++]=189,n=null);r<128?e[i++]=r:(r<2048?e[i++]=r>>6|192:(r<65536?e[i++]=r>>12|224:(e[i++]=r>>18|240,e[i++]=r>>12&63|128),e[i++]=r>>6&63|128),e[i++]=63&r|128)}return i}(this.buf,e,this.pos);var i=this.pos-t;i>=128&&yc(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),uc(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),uc(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var i=0;i<t;i++)this.buf[this.pos++]=e[i]},writeRawMessage:function(e,t){this.pos++;var i=this.pos;e(t,this);var r=this.pos-i;r>=128&&yc(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,t,i){this.writeTag(e,pc.Bytes),this.writeRawMessage(t,i)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,xc,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,vc,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,Tc,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,bc,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,wc,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,Ec,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,Sc,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,Ac,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,Cc,t)},writeBytesField:function(e,t){this.writeTag(e,pc.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,pc.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,pc.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,pc.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,pc.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,pc.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,pc.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,pc.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,pc.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,pc.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};class ImagePosition{constructor(e,{pixelRatio:t,version:i,stretchX:r,stretchY:n,content:o}){this.paddedRect=e,this.pixelRatio=t,this.stretchX=r,this.stretchY=n,this.content=o,this.version=i}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]}}En(ImagePosition,"ImagePosition"),En(class ImageAtlas{constructor(e,t){const i={},r={};this.haveRenderCallbacks=[];const n=[];this.addImages(e,i,n),this.addImages(t,r,n);const{w:o,h:a}=Lc(n),s=new RGBAImage({width:o||1,height:a||1});for(const t in e){const r=e[t],n=i[t].paddedRect;RGBAImage.copy(r.data,s,{x:0,y:0},{x:n.x+1,y:n.y+1},r.data)}for(const e in t){const i=t[e],n=r[e].paddedRect,o=n.x+1,a=n.y+1,l=i.data.width,c=i.data.height;RGBAImage.copy(i.data,s,{x:0,y:0},{x:o,y:a},i.data),RGBAImage.copy(i.data,s,{x:0,y:c-1},{x:o,y:a-1},{width:l,height:1}),RGBAImage.copy(i.data,s,{x:0,y:0},{x:o,y:a+c},{width:l,height:1}),RGBAImage.copy(i.data,s,{x:l-1,y:0},{x:o-1,y:a},{width:1,height:c}),RGBAImage.copy(i.data,s,{x:0,y:0},{x:o+l,y:a},{width:1,height:c})}this.image=s,this.iconPositions=i,this.patternPositions=r}addImages(e,t,i){for(const r in e){const n=e[r],o={x:0,y:0,w:n.data.width+2,h:n.data.height+2};i.push(o),t[r]=new ImagePosition(o,n),n.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(e,t){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((t=>e.hasImage(t))),e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const i in e.updatedImages)this.patchUpdatedImage(this.iconPositions[i],e.getImage(i),t),this.patchUpdatedImage(this.patternPositions[i],e.getImage(i),t)}patchUpdatedImage(e,t,i){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[r,n]=e.tl;i.update(t.data,void 0,{x:r,y:n})}},"ImageAtlas");const Bc={horizontal:1,vertical:2,horizontalOnly:3};function Rc(e){let t=.5,i=.5;switch(e){case"right":case"top-right":case"bottom-right":t=1;break;case"left":case"top-left":case"bottom-left":t=0}switch(e){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:t,verticalAlign:i}}class Anchor extends r{constructor(e,t,i,r,n){super(e,t),this.angle=r,this.z=i,void 0!==n&&(this.segment=n)}clone(){return new Anchor(this.x,this.y,this.z,this.angle,this.segment)}}En(Anchor,"Anchor");const Fc=1e20;function Oc(e,t,i,r,n,o,a,s,l){for(let c=t;c<t+r;c++)Vc(e,i*o+c,o,n,a,s,l);for(let c=i;c<i+n;c++)Vc(e,c*o+t,1,r,a,s,l)}function Vc(e,t,i,r,n,o,a){o[0]=0,a[0]=-Fc,a[1]=Fc,n[0]=e[t];for(let s=1,l=0,c=0;s<r;s++){n[s]=e[t+s*i];const r=s*s;do{const e=o[l];c=(n[s]-n[e]+r-e*e)/(s-e)/2}while(c<=a[l]&&--l>-1);l++,o[l]=s,a[l]=c,a[l+1]=Fc}for(let s=0,l=0;s<r;s++){for(;a[l+1]<s;)l++;const r=o[l],c=s-r;e[t+s*i]=n[r]+c*c}}class GlyphManager{constructor(e,t,i){this.requestManager=e,this.localGlyphMode=t,this.localFontFamily=i,this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(e){this.url=e}getGlyphs(e,t){const i=[];for(const t in e)for(const r of e[t])i.push({stack:t,id:r});x(i,(({stack:e,id:t},i)=>{let r=this.entries[e];r||(r=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let n=r.glyphs[t];if(void 0!==n)return void i(null,{stack:e,id:t,glyph:n});if(n=this._tinySDF(r,e,t),n)return r.glyphs[t]=n,void i(null,{stack:e,id:t,glyph:n});const o=Math.floor(t/256);if(256*o>65535)return void i(new Error("glyphs > 65535 not supported"));if(r.ranges[o])return void i(null,{stack:e,id:t,glyph:n});let a=r.requests[o];a||(a=r.requests[o]=[],GlyphManager.loadGlyphRange(e,o,this.url,this.requestManager,((e,t)=>{if(t){r.ascender=t.ascender,r.descender=t.descender;for(const e in t.glyphs)this._doesCharSupportLocalGlyph(+e)||(r.glyphs[+e]=t.glyphs[+e]);r.ranges[o]=!0}for(const i of a)i(e,t);delete r.requests[o]}))),a.push(((r,n)=>{r?i(r):n&&i(null,{stack:e,id:t,glyph:n.glyphs[t]||null})}))}),((e,i)=>{if(e)t(e);else if(i){const e={};for(const{stack:t,id:r,glyph:n}of i)void 0===e[t]&&(e[t]={}),void 0===e[t].glyphs&&(e[t].glyphs={}),e[t].glyphs[r]=n&&{id:n.id,bitmap:n.bitmap.clone(),metrics:n.metrics},e[t].ascender=this.entries[t].ascender,e[t].descender=this.entries[t].descender;t(null,e)}}))}_doesCharSupportLocalGlyph(e){return 0!==this.localGlyphMode&&(2===this.localGlyphMode?!!this.localFontFamily:!!this.localFontFamily&&(kn(e)||Ln(e)||Dn(e)||zn(e)||Pn(e)))}_tinySDF(e,t,i){const r=this.localFontFamily;if(!r||!this._doesCharSupportLocalGlyph(i))return;let n=e.tinySDF;if(!n){let i="400";/bold/i.test(t)?i="900":/medium/i.test(t)?i="500":/light/i.test(t)&&(i="200"),n=e.tinySDF=new GlyphManager.TinySDF({fontFamily:r,fontWeight:i,fontSize:48,buffer:6,radius:16}),n.fontWeight=i}if(this.localGlyphs[n.fontWeight][i])return this.localGlyphs[n.fontWeight][i];const o=String.fromCharCode(i),{data:a,width:s,height:l,glyphWidth:c,glyphHeight:u,glyphLeft:h,glyphTop:p,glyphAdvance:d}=n.draw(o);return this.localGlyphs[n.fontWeight][i]={id:i,bitmap:new AlphaImage({width:s,height:l},a),metrics:{width:c/2,height:u/2,left:h/2,top:p/2-27,advance:d/2,localGlyph:!0}}}}GlyphManager.loadGlyphRange=function(e,t,i,r,n){const o=256*t,a=o+255,s=r.transformRequest(r.normalizeGlyphsURL(i).replace("{fontstack}",e).replace("{range}",`${o}-${a}`),Xe.Glyphs);Qe(s,((e,t)=>{if(e)n(e);else if(t){const e={},i=function(e){return new hc(e).readFields(Dc,{})}(t);for(const t of i.glyphs)e[t.id]=t;n(null,{glyphs:e,ascender:i.ascender,descender:i.descender})}}))},GlyphManager.TinySDF=class TinySDF{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:n="sans-serif",fontWeight:o="normal",fontStyle:a="normal"}={}){this.buffer=t,this.cutoff=r,this.radius=i;const s=this.size=e+4*t,l=this._createCanvas(s),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${a} ${o} ${e}px ${n}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(s*s),this.gridInner=new Float64Array(s*s),this.f=new Float64Array(s),this.z=new Float64Array(s+1),this.v=new Uint16Array(s)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:n,actualBoundingBoxRight:o}=this.ctx.measureText(e),a=Math.ceil(i),s=Math.min(this.size-this.buffer,Math.ceil(o-n)),l=Math.min(this.size-this.buffer,a+Math.ceil(r)),c=s+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),p=new Uint8ClampedArray(h),d={data:p,width:c,height:u,glyphWidth:s,glyphHeight:l,glyphTop:a,glyphLeft:0,glyphAdvance:t};if(0===s||0===l)return d;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,s,l),f.fillText(e,m,m+a);const y=f.getImageData(m,m,s,l);g.fill(Fc,0,h),_.fill(0,0,h);for(let e=0;e<l;e++)for(let t=0;t<s;t++){const i=y.data[4*(e*s+t)+3]/255;if(0===i)continue;const r=(e+m)*c+t+m;if(1===i)g[r]=0,_[r]=Fc;else{const e=.5-i;g[r]=e>0?e*e:0,_[r]=e<0?e*e:0}}Oc(g,0,0,c,u,c,this.f,this.v,this.z),Oc(_,m,m,s,l,c,this.f,this.v,this.z);for(let e=0;e<h;e++){const t=Math.sqrt(g[e])-Math.sqrt(_[e]);p[e]=Math.round(255-255*(t/this.radius+this.cutoff))}return d}};const Uc=Number.POSITIVE_INFINITY,jc=Math.sqrt(2);function Nc(e,t){return t[1]!==Uc?function(e,t,i){let r=0,n=0;switch(t=Math.abs(t),i=Math.abs(i),e){case"top-right":case"top-left":case"top":n=i-7;break;case"bottom-right":case"bottom-left":case"bottom":n=7-i}switch(e){case"top-right":case"bottom-right":case"right":r=-t;break;case"top-left":case"bottom-left":case"left":r=t}return[r,n]}(e,t[0],t[1]):function(e,t){let i=0,r=0;t<0&&(t=0);const n=t/jc;switch(e){case"top-right":case"top-left":r=n-7;break;case"bottom-right":case"bottom-left":r=7-n;break;case"bottom":r=7-t;break;case"top":r=t-7}switch(e){case"top-right":case"bottom-right":i=-n;break;case"top-left":case"bottom-left":i=n;break;case"left":i=t;break;case"right":i=-t}return[i,r]}(e,t[0])}const Gc=eo([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:Zc}=Gc,qc=eo([{name:"a_pos_3",components:3,type:"Int16"}]);var $c=eo([{name:"a_pos",type:"Int16",components:2}]);const Wc=Eo/Math.PI/2,Hc=2*Po(1,0)*Wc*Math.PI,Xc=[64,32,16],Kc=-Wc,Jc=Wc,Yc=[new Aabb([Kc,Kc,Kc],[Jc,Jc,Jc]),new Aabb([Kc,Kc,Kc],[0,0,Jc]),new Aabb([0,Kc,Kc],[Jc,0,Jc]),new Aabb([Kc,0,Kc],[0,Jc,Jc]),new Aabb([0,0,Kc],[Jc,Jc,Jc])];function Qc(e,t,i,r=!0){const n=ja([],e._camera.position,e.worldSize),o=[t,i,1,1];is(o,o,e.pixelMatrixInverse),ts(o,o,1/o[3]);const a=Za([],Ja([],o,n)),s=e.globeMatrix,l=[s[12],s[13],s[14]],u=Ja([],l,n),h=La(u),p=Za([],u),d=e.worldSize/(2*Math.PI),f=qa(p,a),m=Math.asin(d/h);if(m<Math.acos(f)){if(!r)return null;const e=[],t=[];ja(e,a,h/f),Za(t,Ja(t,e,u)),Za(a,Ra(a,u,ja(a,t,Math.tan(m)*h)))}const g=[];new Ray(n,a).closestPointOnSphere(l,d,g);const y=Za([],Z(s,0)),x=Za([],Z(s,1)),v=Za([],Z(s,2)),b=qa(y,g),w=qa(x,g),T=qa(v,g),E=c(Math.asin(-w/d));let S=c(Math.atan2(b,T));S=e.center.lng+function(e,t){const i=(t-e+180)%360-180;return i<-180?i+360:i}(e.center.lng,S);const A=Io(S),C=_(Mo(E),0,1);return new MercatorCoordinate(A,C)}class Arc{constructor(e,t,i){this.a=Ja([],e,i),this.b=Ja([],t,i),this.center=i;const r=Za([],this.a),n=Za([],this.b);this.angle=Math.acos(qa(r,n))}}function eu(e,t){if(0===e.angle)return null;let i;return i=0===e.a[t]?1/e.angle*.5*Math.PI:1/e.angle*Math.atan(e.b[t]/e.a[t]/Math.sin(e.angle)-1/Math.tan(e.angle)),i<0||i>1?null:function(e,t,i,r){const n=Math.sin(i);return e*(Math.sin((1-r)*i)/n)+t*(Math.sin(r*i)/n)}(e.a[t],e.b[t],e.angle,_(i,0,1))+e.center[t]}function tu(e){if(e.z<=1)return Yc[e.z+2*e.y+e.x];const t=au(ou(e));return Aabb.fromPoints(t)}function iu(e,t){const i=_u(t.zoom);if(0===i)return tu(e);const r=ou(e),n=au(r),o=Io(r.getWest())*t.worldSize,a=Io(r.getEast())*t.worldSize,s=Mo(r.getNorth())*t.worldSize,l=Mo(r.getSouth())*t.worldSize,c=[o,s,0],u=[a,s,0],h=[o,l,0],p=[a,l,0],d=xa([],t.globeMatrix);return Wa(c,c,d),Wa(u,u,d),Wa(h,h,d),Wa(p,p,d),n[0]=vi(n[0],h,i),n[1]=vi(n[1],p,i),n[2]=vi(n[2],u,i),n[3]=vi(n[3],c,i),Aabb.fromPoints(n)}function ru(e,t,i,r,n){for(const o of i)Wa(o,o,r),ja(o,o,n),Va(e,e,o),Ua(t,t,o)}function nu(e,t,i){const r=t/e.worldSize,n=Number.MAX_VALUE,o=[-n,-n,-n],a=[n,n,n],s=e.globeMatrix;if(i.z<=1)return ru(a,o,tu(i).getCorners(),s,r),new Aabb(a,o);const c=ou(i),u=au(c);if(ru(a,o,u,s,r),c.contains(e.center)){o[2]=0;const t=e.point,i=[t.x*r,t.y*r,0];return Va(a,a,i),Ua(o,o,i),new Aabb(a,o)}const h=[s[12]*r,s[13]*r,s[14]*r],p=c.getCenter(),d=_(e.center.lat,-85.051129,Lo),f=_(p.lat,-85.051129,Lo),m=Io(e.center.lng),g=Mo(d);let y=m-Io(p.lng);const x=g-Mo(f);y>.5?y-=1:y<-.5&&(y+=1);let v=0;Math.abs(y)>Math.abs(x)?v=y>=0?1:3:(v=x>=0?0:2,Na(h,h,[s[4]*r,s[5]*r,s[6]*r],-Math.sin(l(x>=0?c.getSouth():c.getNorth()))*Wc));const b=u[v],w=u[(v+1)%4],T=new Arc(b,w,h),E=[eu(T,0)||b[0],eu(T,1)||b[1],eu(T,2)||b[2]];return a[2]=Math.min(b[2],w[2]),Va(a,a,E),Ua(o,o,E),new Aabb(a,o)}function ou({x:e,y:t,z:i}){const r=1/(1<<i),n=new LngLat(Do(e*r),zo((t+1)*r)),o=new LngLat(Do((e+1)*r),zo(t*r));return new LngLatBounds(n,o)}function au(e){const t=l(e.getNorth()),i=l(e.getSouth()),r=Math.cos(t),n=Math.cos(i),o=Math.sin(t),a=Math.sin(i),s=e.getWest(),c=e.getEast();return[su(n,a,s),su(n,a,c),su(r,o,c),su(r,o,s)]}function su(e,t,i,r=Wc){return i=l(i),[e*Math.sin(i)*r,-t*r,e*Math.cos(i)*r]}function lu(e,t,i){return su(Math.cos(l(e)),Math.sin(l(e)),t,i)}function cu(e,t,i,r){const n=1<<i.z,o=(e/Eo+i.x)/n;return lu(zo((t/Eo+i.y)/n),Do(o),r)}function uu({min:e,max:t}){return 16383/Math.max(t[0]-e[0],t[1]-e[1],t[2]-e[2])}const hu=new Float64Array(16);function pu(e){const t=uu(e),i=Aa(hu,[t,t,t]);return ba(i,i,((r=[])[0]=-(n=e.min)[0],r[1]=-n[1],r[2]=-n[2],r));var r,n}function du(e){const t=(r=e.min,(i=hu)[0]=1,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=1,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=1,i[11]=0,i[12]=r[0],i[13]=r[1],i[14]=r[2],i[15]=1,i);var i,r;const n=1/uu(e);return wa(t,t,[n,n,n])}function fu(e,t){return Eo/(512*Math.pow(2,e))*uu(tu(t))}function mu(e,t,i,r,n){const o=function(e){const t=Eo/(2*Math.PI);return e/(2*Math.PI)/t}(i),a=[e,t,-i/(2*Math.PI)],s=ya(new Float64Array(16));return ba(s,s,a),wa(s,s,[o,o,o]),Ta(s,s,l(-n)),Ea(s,s,l(-r)),s}function _u(e){return g(5,6,e)}function gu(e,t,i){const r=ya(new Float64Array(16)),n=(t/(1<<e)-.5)*Math.PI*2;return Ea(r,i.globeMatrix,n),Float32Array.from(r)}function yu(e,t,i){const r=_u(i.zoom),n=e.style.map._antialias,o=!!t.extStandardDerivatives,a=t.extStandardDerivativesForceOff||e.terrain&&e.terrain.exaggeration()>0;return 0===r&&!n&&!a&&o}function xu(e,t,i){const r=t.getNorth(),n=t.getSouth(),o=t.getWest(),a=.015625;return[0,(t.getEast()-o)*a,1<<e.z,(n-r)/Xc[i],0,e.y,r,o,a]}function vu(e){const t=80.051129;e=_(e,-80.051129,t)/t*90;const i=Math.pow(Math.abs(Math.sin(l(e))),3);return Math.round(i*(Xc.length-1))}function bu(e){const t=[0,0,0],i=ya(new Float64Array(16));return va(i,e.pixelMatrix,e.globeMatrix),Wa(t,t,i),new r(t[0],t[1])}function wu(e,t){const i=lu(t.lat,t.lng);return o=(r=Fa([],function(e){const t=lu(e._center.lat,e._center.lng);let i=$a([],Ba(0,1,0),t);const r=Ca([],-e.angle,t);i=Wa(i,i,r),Ca(r,-e._pitch,i);const n=Za([],t);return ja(n,n,e.cameraToCenterDistance/e.pixelsPerMeter*Hc),Wa(n,n,r),Ra([],t,n)}(e),i))[0],a=r[1],s=r[2],l=(n=i)[0],c=n[1],u=n[2],p=(h=Math.sqrt(o*o+a*a+s*s)*Math.sqrt(l*l+c*c+u*u))&&qa(r,n)/h,Math.acos(Math.min(Math.max(p,-1),1));var r,n,o,a,s,l,c,u,h,p}function Tu(e,t){return wu(e,t)>Math.PI/2*1.01}const Eu=l(85),Su=Math.cos(Eu),Au=Math.sin(Eu);class GlobeSharedBuffers{constructor(e){this._createGrid(e),this._createPoles(e)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const e of this._poleSegments)e.destroy();for(const e of this._gridSegments)e.destroy();if(this._wireframeIndexBuffer){this._wireframeIndexBuffer.destroy();for(const e of this._wireframeSegments)e.destroy()}}_createGrid(e){const t=new StructArrayLayout2i4,i=new StructArrayLayout3ui6,r=65;for(let e=0;e<r;e++)for(let i=0;i<r;i++)t.emplaceBack(i,e);this._gridSegments=[];for(let e=0,t=0;e<Xc.length;e++){const n=Xc[e];for(let e=0;e<n;e++)for(let t=0;t<64;t++){const n=e*r+t;i.emplaceBack(n+1,n,n+r),i.emplaceBack(n+r,n+r+1,n+1)}const o=64*n*2;this._gridSegments.push(SegmentVector.simpleSegment(0,t,(n+1)*r,o)),t+=o}this._gridBuffer=e.createVertexBuffer(t,$c.members),this._gridIndexBuffer=e.createIndexBuffer(i,!0)}_createPoles(e){const t=new StructArrayLayout3ui6;for(let e=0;e<=64;e++)t.emplaceBack(0,e+1,e+2);this._poleIndexBuffer=e.createIndexBuffer(t,!0);const i=new StructArrayLayout5f20,r=new StructArrayLayout5f20;this._poleSegments=[];for(let e=0,t=0;e<5;e++){const n=360/(1<<e);i.emplaceBack(0,-Wc,0,.5,0),r.emplaceBack(0,-Wc,0,.5,1);for(let e=0;e<=64;e++){const t=e/64,o=xi(0,n,t),[a,s,l]=su(Su,Au,o,Wc);i.emplaceBack(a,s,l,t,0),r.emplaceBack(a,s,l,t,1)}this._poleSegments.push(SegmentVector.simpleSegment(t,0,66,64)),t+=66}this._poleNorthVertexBuffer=e.createVertexBuffer(i,Zc,!1),this._poleSouthVertexBuffer=e.createVertexBuffer(r,Zc,!1)}getGridBuffers(e){return[this._gridBuffer,this._gridIndexBuffer,this._gridSegments[e]]}getPoleBuffers(e){return[this._poleNorthVertexBuffer,this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[e]]}getWirefameBuffers(e,t){if(!this._wireframeSegments){const t=new StructArrayLayout2ui4,i=64,r=i+1;this._wireframeSegments=[];for(let e=0,n=0;e<Xc.length;e++){const o=Xc[e];for(let e=0;e<o;e++)for(let n=0;n<i;n++){const i=e*r+n;t.emplaceBack(i,i+1),t.emplaceBack(i,i+r),t.emplaceBack(i,i+r+1)}const a=o*i*3;this._wireframeSegments.push(SegmentVector.simpleSegment(0,n,(o+1)*r,a)),n+=a}this._wireframeIndexBuffer=e.createIndexBuffer(t)}return[this._gridBuffer,this._wireframeIndexBuffer,this._wireframeSegments[t]]}}function Cu(e,t){const i=e.fovAboveCenter,r=e.elevation?e.elevation.getMinElevationBelowMSL()*t:0,n=(e._camera.position[2]*e.worldSize-r)/Math.cos(e._pitch),o=Math.sin(i)*n/Math.sin(Math.max(Math.PI/2-e._pitch-i,.01)),a=Math.sin(e._pitch)*o+n;return Math.min(1.01*a,n*(1/e._horizonShift))}function Iu(e,t){if(!t.isReprojectedInTileSpace)return{scale:1<<e.z,x:e.x,y:e.y,x2:e.x+1,y2:e.y+1,projection:t};const i=Math.pow(2,-e.z),r=e.x*i,n=(e.x+1)*i,o=e.y*i,a=(e.y+1)*i,s=Do(r),l=Do(n),c=zo(o),u=zo(a),h=t.project(s,c),p=t.project(l,c),d=t.project(l,u),f=t.project(s,u);let m=Math.min(h.x,p.x,d.x,f.x),_=Math.min(h.y,p.y,d.y,f.y),g=Math.max(h.x,p.x,d.x,f.x),y=Math.max(h.y,p.y,d.y,f.y);const x=i/16;function v(e,i,r,n,o,a){const s=(r+o)/2,l=(n+a)/2,c=t.project(Do(s),zo(l)),u=Math.max(0,m-c.x,_-c.y,c.x-g,c.y-y);m=Math.min(m,c.x),g=Math.max(g,c.x),_=Math.min(_,c.y),y=Math.max(y,c.y),u>x&&(v(e,c,r,n,s,l),v(c,i,s,l,o,a))}v(h,p,r,o,n,o),v(p,d,n,o,n,a),v(d,f,n,a,r,a),v(f,h,r,a,r,o),m-=x,_-=x,g+=x,y+=x;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:t}}function Mu(e,t,i,r,n,o,a,s,l){if("globe"===l.name)return nu(e,t,new CanonicalTileID(i,r,n));const c=Iu({z:i,x:r,y:n},l);return new Aabb([(o+c.x/c.scale)*t,t*(c.y/c.scale),a],[(o+c.x2/c.scale)*t,t*(c.y2/c.scale),s])}function Pu(e,{x:t,y:i},n=0){return new r(((t-n)*e.scale-e.x)*Eo,(i*e.scale-e.y)*Eo)}function Du(e,t,i=0){return Ba(((t.x-i)*e.scale-e.x)*Eo,(t.y*e.scale-e.y)*Eo,ko(t.z,t.y))}const zu=ya(new Float32Array(16));class Projection{constructor(e){this.spec=e,this.name=e.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(e,t){return{x:0,y:0,z:0}}unproject(e,t){return new LngLat(0,0)}projectTilePoint(e,t,i){return{x:e,y:t,z:0}}locationPoint(e,t,i=!0){return e._coordinatePoint(e.locationCoordinate(t),i)}pixelsPerMeter(e,t){return Po(1,e)*t}pixelSpaceConversion(e,t,i){return 1}farthestPixelDistance(e){return Cu(e,e.pixelsPerMeter)}pointCoordinate(e,t,i,n){const o=e.horizonLineFromTop(!1),a=new r(t,Math.max(o,i));return e.rayIntersectionCoordinate(e.pointRayIntersection(a,n))}pointCoordinate3D(e,t,i){const n=new r(t,i);if(e.elevation)return e.elevation.pointCoordinate(n);{const t=this.pointCoordinate(e,n.x,n.y,0);return[t.x,t.y,t.z]}}isPointAboveHorizon(e,t){if(e.elevation)return!this.pointCoordinate3D(e,t.x,t.y);const i=e.horizonLineFromTop();return t.y<i}createInversionMatrix(e,t){return zu}createTileMatrix(e,t,i){let r,n,o;const a=i.canonical,s=ya(new Float64Array(16));if(this.isReprojectedInTileSpace){const l=Iu(a,this);r=1,n=l.x+i.wrap*l.scale,o=l.y,wa(s,s,[r/l.scale,r/l.scale,e.pixelsPerMeter/t])}else r=t/e.zoomScale(a.z),n=(a.x+Math.pow(2,a.z)*i.wrap)*r,o=a.y*r;return ba(s,s,[n,o,0]),wa(s,s,[r/Eo,r/Eo,1]),s}upVector(e,t,i){return[0,0,1]}upVectorScale(e,t,i){return{metersToTile:1}}}class Albers extends Projection{constructor(e){super(e),this.range=[4,7],this.center=e.center||[-96,37.5];const[t,i]=this.parallels=e.parallels||[29.5,45.5],r=Math.sin(l(t));this.n=(r+Math.sin(l(i)))/2,this.c=1+r*(2*this.n-r),this.r0=Math.sqrt(this.c)/this.n}project(e,t){const{n:i,c:r,r0:n}=this,o=l(e-this.center[0]),a=l(t),s=Math.sqrt(r-2*i*Math.sin(a))/i;return{x:s*Math.sin(o*i),y:s*Math.cos(o*i)-n,z:0}}unproject(e,t){const{n:i,c:r,r0:n}=this,o=n+t;let a=Math.atan2(e,Math.abs(o))*Math.sign(o);o*i<0&&(a-=Math.PI*Math.sign(e)*Math.sign(o));const s=l(this.center[0])*i;a=y(a,-Math.PI-s,Math.PI-s);const u=c(a/i)+this.center[0],h=Math.asin(_((r-(e*e+o*o)*i*i)/(2*i),-1,1)),p=_(c(h),-85.051129,Lo);return new LngLat(u,p)}}const ku=1.340264,Lu=-.081106,Bu=893e-6,Ru=.003796,Fu=Math.sqrt(3)/2;class EqualEarth extends Projection{project(e,t){t=t/180*Math.PI,e=e/180*Math.PI;const i=Math.asin(Fu*Math.sin(t)),r=i*i,n=r*r*r;return{x:.5*(e*Math.cos(i)/(Fu*(ku+3*Lu*r+n*(7*Bu+9*Ru*r)))/Math.PI+.5),y:1-.5*(i*(ku+Lu*r+n*(Bu+Ru*r))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,r=i*i,n=r*r*r;for(let e,o,a,s=0;s<12&&(o=i*(ku+Lu*r+n*(Bu+Ru*r))-t,a=ku+3*Lu*r+n*(7*Bu+9*Ru*r),e=o/a,i=_(i-e,-Math.PI/3,Math.PI/3),r=i*i,n=r*r*r,!(Math.abs(e)<1e-12));++s);const o=Fu*e*(ku+3*Lu*r+n*(7*Bu+9*Ru*r))/Math.cos(i),a=Math.asin(Math.sin(i)/Fu),s=_(180*o/Math.PI,-180,180),l=_(180*a/Math.PI,-85.051129,Lo);return new LngLat(s,l)}}class Equirectangular extends Projection{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0}project(e,t){return{x:.5+e/360,y:.5-t/360,z:0}}unproject(e,t){const i=360*(e-.5),r=_(360*(.5-t),-85.051129,Lo);return new LngLat(i,r)}}const Ou=Math.PI/2;function Vu(e){return Math.tan((Ou+e)/2)}class LambertConformalConic extends Projection{constructor(e){super(e),this.center=e.center||[0,30];const[t,i]=this.parallels=e.parallels||[30,30],r=l(t),n=l(i),o=Math.cos(r);this.n=r===n?Math.sin(r):Math.log(o/Math.cos(n))/Math.log(Vu(n)/Vu(r)),this.f=o*Math.pow(Vu(r),this.n)/this.n}project(e,t){t=l(t),e=l(e-this.center[0]);const i=1e-6,{n:r,f:n}=this;n>0?t<-Ou+i&&(t=-Ou+i):t>Ou-i&&(t=Ou-i);const o=n/Math.pow(Vu(t),r),a=o*Math.sin(r*e),s=n-o*Math.cos(r*e);return{x:.5*(a/Math.PI+.5),y:1-.5*(s/Math.PI+.5),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI,t=(2*(1-t)-.5)*Math.PI;const{n:i,f:r}=this,n=r-t,o=Math.sign(n),a=Math.sign(i)*Math.sqrt(e*e+n*n);let s=Math.atan2(e,Math.abs(n))*o;n*i<0&&(s-=Math.PI*Math.sign(e)*o);const l=_(c(s/i)+this.center[0],-180,180),u=_(c(2*Math.atan(Math.pow(r/a,1/i))-Ou),-85.051129,Lo);return new LngLat(l,u)}}class Mercator extends Projection{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(e,t){return{x:Io(e),y:Mo(t),z:0}}unproject(e,t){const i=Do(e),r=zo(t);return new LngLat(i,r)}}const Uu=l(Lo);class NaturalEarth extends Projection{project(e,t){const i=(t=l(t))*t,r=i*i;return{x:.5*((e=l(e))*(.8707-.131979*i+r*(r*(.003971*i-.001529*r)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+i*(.015085+r*(.028874*i-.044475-.005916*r)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,r=25,n=0,o=i*i;do{o=i*i;const e=o*o;n=(i*(1.007226+o*(.015085+e*(.028874*o-.044475-.005916*e)))-t)/(1.007226+o*(.045255+e*(.259866*o-.311325-.005916*11*e))),i=_(i-n,-Uu,Uu)}while(Math.abs(n)>1e-6&&--r>0);o=i*i;const a=_(c(e/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),s=c(i);return new LngLat(a,s)}}const ju=l(Lo);class WinkelTripel extends Projection{project(e,t){t=l(t),e=l(e);const i=Math.cos(t),r=2/Math.PI,n=Math.acos(i*Math.cos(e/2)),o=Math.sin(n)/n,a=.5*(e*r+2*i*Math.sin(e/2)/o)||0,s=.5*(t+Math.sin(t)/o)||0;return{x:.5*(a/Math.PI+.5),y:1-.5*(s/Math.PI+1),z:0}}unproject(e,t){let i=e=(2*e-.5)*Math.PI,r=t=(2*(1-t)-1)*Math.PI,n=25;const o=1e-6;let a=0,s=0;do{const n=Math.cos(r),o=Math.sin(r),l=2*o*n,c=o*o,u=n*n,h=Math.cos(i/2),p=Math.sin(i/2),d=2*h*p,f=p*p,m=1-u*h*h,g=m?1/m:0,y=m?Math.acos(n*h)*Math.sqrt(1/m):0,x=.5*(2*y*n*p+2*i/Math.PI)-e,v=.5*(y*o+r)-t,b=.5*g*(u*f+y*n*h*c)+1/Math.PI,w=g*(d*l/4-y*o*p),T=.125*g*(l*p-y*o*u*d),E=.5*g*(c*h+y*f*n)+.5,S=w*T-E*b;a=(v*w-x*E)/S,s=(x*T-v*b)/S,i=_(i-a,-Math.PI,Math.PI),r=_(r-s,-ju,ju)}while((Math.abs(a)>o||Math.abs(s)>o)&&--n>0);return new LngLat(c(i),c(r))}}class CylindricalEqualArea extends Projection{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(l(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,t){const{scale:i,cosPhi:r}=this;return{x:l(e)*r*i+.5,y:-Math.sin(l(t))/r*i+.5,z:0}}unproject(e,t){const{scale:i,cosPhi:r}=this,n=-(t-.5)/i,o=_(c((e-.5)/i)/r,-180,180),a=Math.asin(_(n*r,-1,1)),s=_(c(a),-85.051129,Lo);return new LngLat(o,s)}}class Globe extends Mercator{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug","custom"],this.range=[3,5]}projectTilePoint(e,t,i){const r=cu(e,t,i);return Wa(r,r,pu(tu(i))),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,t){const i=lu(t.lat,t.lng),n=Za([],i),o=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude;Na(i,i,n,Po(1,0)*Eo*o);const a=ya(new Float64Array(16));return va(a,e.pixelMatrix,e.globeMatrix),Wa(i,i,a),new r(i[0],i[1])}pixelsPerMeter(e,t){return Po(1,0)*t}pixelSpaceConversion(e,t,i){const r=xi(Po(1,45)*t,Po(1,e)*t,i);return this.pixelsPerMeter(e,t)/r}createTileMatrix(e,t,i){const r=du(tu(i.canonical));return va(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,t){const{center:i}=e,r=pu(tu(t));return Ea(r,r,l(i.lng)),Ta(r,r,l(i.lat)),wa(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(e,t,i,r){return Qc(e,t,i,!0)||new MercatorCoordinate(0,0)}pointCoordinate3D(e,t,i){const r=this.pointCoordinate(e,t,i,0);return[r.x,r.y,r.z]}isPointAboveHorizon(e,t){return!Qc(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(e,t){const i=e.cameraToCenterDistance,r=e._centerAltitude*t,n=e._camera,o=e._camera.forward(),a=Ra([],ja([],o,-i),[0,0,r]),s=e.worldSize/(2*Math.PI),l=[0,0,-s],c=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=ja([],n.up(),u),p=ja([],n.right(),u*c),d=Za([],Ra([],Ra([],o,h),p)),f=[];let m;if(new Ray(a,d).closestPointOnSphere(l,s,f)){const t=Ra([],f,l),i=Ja([],t,a);m=Math.cos(e.fovAboveCenter)*La(i)}else{const e=Ja([],a,l),t=Ja([],l,a);Za(t,t);const i=La(e)-s;m=Math.sqrt(i*(i+2*s));const r=Math.acos(m/(s+i))-Math.acos(qa(o,t));m*=Math.cos(r)}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),i=_u(e.zoom);if(i>0){const r=Cu(e,Po(1,e.center.lat)*e.worldSize),n=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return xi(t,r+n*(1-Math.cos(o)),Math.pow(i,10))}return t}upVector(e,t,i){return cu(t,i,e,1)}upVectorScale(e){return{metersToTile:Hc*uu(tu(e))}}}function Nu(e){const t=e.parallels,i=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case"mercator":return new Mercator(e);case"equirectangular":return new Equirectangular(e);case"naturalEarth":return new NaturalEarth(e);case"equalEarth":return new EqualEarth(e);case"winkelTripel":return new WinkelTripel(e);case"albers":return i?new CylindricalEqualArea(e):new Albers(e);case"lambertConformalConic":return i?new CylindricalEqualArea(e):new LambertConformalConic(e);case"globe":return new Globe(e)}throw new Error(`Invalid projection name: ${e.name}`)}const Gu=gl.VectorTileFeature.types,Zu=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function qu(e,t,i,r,n,o,a,s,l,c,u,h,p){const d=s?Math.min(32640,Math.round(s[0])):0,f=s?Math.min(32640,Math.round(s[1])):0;e.emplaceBack(t,i,Math.round(32*r),Math.round(32*n),o,a,(d<<1)+(l?1:0),f,16*c,16*u,256*h,256*p)}function $u(e,t,i,r,n,o,a){e.emplaceBack(t,i,r,n,o,a)}function Wu(e,t,i,r,n){const o=5*t+2;e.float32[o+0]=i,e.float32[o+1]=r,e.float32[o+2]=n}function Hu(e,t,i,r,n){e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n)}function Xu(e){for(const t of e.sections)if(Vn(t.text))return!0;return!1}class SymbolBuffers{constructor(e){this.layoutVertexArray=new StructArrayLayout4i4ui4i24,this.indexArray=new StructArrayLayout3ui6,this.programConfigurations=e,this.segments=new SegmentVector,this.dynamicLayoutVertexArray=new StructArrayLayout4f16,this.opacityVertexArray=new StructArrayLayout1ul4,this.placedSymbolArray=new PlacedSymbolArray,this.globeExtVertexArray=new StructArrayLayout3i3f20}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(e,t,i,r){this.isEmpty()||(i&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Xl.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Jl.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,Zu,!0),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Kl.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}}En(SymbolBuffers,"SymbolBuffers");class CollisionBuffers{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new SegmentVector,this.collisionVertexArray=new StructArrayLayout2ub2f12,this.collisionVertexArrayExt=new StructArrayLayout3f12}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Yl.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,Ql.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}En(CollisionBuffers,"CollisionBuffers");class SymbolBucket{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=ya([]),this.placementViewportMatrix=ya([]);const t=this.layers[0]._unevaluatedLayout._values;this.textSizeData=rc(this.zoom,t["text-size"]),this.iconSizeData=rc(this.zoom,t["icon-size"]);const i=this.layers[0].layout,r=i.get("symbol-sort-key"),n=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==n&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===n||"auto"===n&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((e=>Bc[e])),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.sourceID=e.sourceID,this.projection=e.projection}createArrays(){this.text=new SymbolBuffers(new ProgramConfigurationSet(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new SymbolBuffers(new ProgramConfigurationSet(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new GlyphOffsetArray,this.lineVertexArray=new SymbolLineVertexArray,this.symbolInstances=new SymbolInstanceArray}calculateGlyphDependencies(e,t,i,r,n){for(let i=0;i<e.length;i++)if(t[e.charCodeAt(i)]=!0,r&&n){const r=lc[e.charAt(i)];r&&(t[r.charCodeAt(0)]=!0)}}populate(e,t,i,r){const n=this.layers[0],o=n.layout,a="globe"===this.projection.name,s=o.get("text-font"),l=o.get("text-field"),c=o.get("icon-image"),u=("constant"!==l.value.kind||l.value.value instanceof Formatted&&!l.value.value.isEmpty()||l.value.value.toString().length>0)&&("constant"!==s.value.kind||s.value.value.length>0),h="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,p=o.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const d=t.iconDependencies,f=t.glyphDependencies,m=t.availableImages,_=new EvaluationParameters(this.zoom);for(const{feature:t,id:l,index:c,sourceLayerIndex:g}of e){const e=n._featureFilter.needGeometry,y=Zo(t,e);if(!n._featureFilter.filter(_,y,i))continue;if(e||(y.geometry=Go(t,i,r)),a&&1!==t.type&&i.z<=5){const e=y.geometry,t=.98078528056;for(let r=0;r<e.length;r++)e[r]=Vo(e[r],(e=>e),((e,r)=>qa(cu(e.x,e.y,i,1),cu(r.x,r.y,i,1))<t))}let x,v;if(u){const e=n.getValueAndResolveTokens("text-field",y,i,m),t=Formatted.factory(e);Xu(t)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===Xn()||this.hasRTLText&&Jn.isParsed())&&(x=sc(t,n,y))}if(h){const e=n.getValueAndResolveTokens("icon-image",y,i,m);v=e instanceof ResolvedImage?e:ResolvedImage.fromString(e)}if(!x&&!v)continue;const b=this.sortFeaturesByKey?p.evaluate(y,{},i):void 0;if(this.features.push({id:l,text:x,icon:v,index:c,sourceLayerIndex:g,geometry:y.geometry,properties:t.properties,type:Gu[t.type],sortKey:b}),v&&(d[v.name]=!0),x){const e=s.evaluate(y,{},i).join(","),t="map"===o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(Bc.vertical)>=0;for(const i of x.sections)if(i.image)d[i.image.name]=!0;else{const r=Bn(x.toString()),n=i.fontStack||e,o=f[n]=f[n]||{};this.calculateGlyphDependencies(i.text,o,t,this.allowVerticalPlacement,r)}}}"line"===o.get("symbol-placement")&&(this.features=function(e){const t={},i={},r=[];let n=0;function o(t){r.push(e[t]),n++}function a(e,t,n){const o=i[e];return delete i[e],i[t]=o,r[o].geometry[0].pop(),r[o].geometry[0]=r[o].geometry[0].concat(n[0]),o}function s(e,i,n){const o=t[i];return delete t[i],t[e]=o,r[o].geometry[0].shift(),r[o].geometry[0]=n[0].concat(r[o].geometry[0]),o}function l(e,t,i){const r=i?t[0][t[0].length-1]:t[0][0];return`${e}:${r.x}:${r.y}`}for(let c=0;c<e.length;c++){const u=e[c],h=u.geometry,p=u.text?u.text.toString():null;if(!p){o(c);continue}const d=l(p,h),f=l(p,h,!0);if(d in i&&f in t&&i[d]!==t[f]){const e=s(d,f,h),n=a(d,f,r[e].geometry);delete t[d],delete i[f],i[l(p,r[n].geometry,!0)]=n,r[e].geometry=null}else d in i?a(d,f,h):f in t?s(d,f,h):(o(c),t[d]=n-1,i[f]=n-1)}return r.filter((e=>e.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((e,t)=>e.sortKey-t.sortKey))}update(e,t,i,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,i,r),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,i,r))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Nu(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const i=this.lineVertexArray.length,r=e.segment;if(void 0!==r){let i=e.dist(t[r+1]),n=e.dist(t[r]);const o={};for(let e=r+1;e<t.length;e++)o[e]={x:t[e].x,y:t[e].y,tileUnitDistanceFromAnchor:i},e<t.length-1&&(i+=t[e+1].dist(t[e]));for(let e=r||0;e>=0;e--)o[e]={x:t[e].x,y:t[e].y,tileUnitDistanceFromAnchor:n},e>0&&(n+=t[e-1].dist(t[e]));for(let e=0;e<t.length;e++){const t=o[e];this.lineVertexArray.emplaceBack(t.x,t.y,t.tileUnitDistanceFromAnchor)}}return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(e,t,i,r,n,o,a,s,l,c,u,h,p,d){const f=e.indexArray,m=e.layoutVertexArray,_=e.globeExtVertexArray,g=e.segments.prepareSegment(4*t.length,m,f,this.canOverlap?o.sortKey:void 0),y=this.glyphOffsetArray.length,x=g.vertexLength,v=this.allowVerticalPlacement&&a===Bc.vertical?Math.PI/2:0,b=o.text&&o.text.sections;for(let r=0;r<t.length;r++){const{tl:n,tr:a,bl:c,br:u,tex:h,pixelOffsetTL:y,pixelOffsetBR:x,minFontScaleX:w,minFontScaleY:T,glyphOffset:E,isSDF:S,sectionIndex:A}=t[r],C=g.vertexLength,I=E[1];if(qu(m,l.x,l.y,n.x,I+n.y,h.x,h.y,i,S,y.x,y.y,w,T),qu(m,l.x,l.y,a.x,I+a.y,h.x+h.w,h.y,i,S,x.x,y.y,w,T),qu(m,l.x,l.y,c.x,I+c.y,h.x,h.y+h.h,i,S,y.x,x.y,w,T),qu(m,l.x,l.y,u.x,I+u.y,h.x+h.w,h.y+h.h,i,S,x.x,x.y,w,T),s){const t=s.anchor,i=s.up;$u(_,t.x,t.y,t.z,i[0],i[1],i[2]),$u(_,t.x,t.y,t.z,i[0],i[1],i[2]),$u(_,t.x,t.y,t.z,i[0],i[1],i[2]),$u(_,t.x,t.y,t.z,i[0],i[1],i[2]),Hu(e.dynamicLayoutVertexArray,t.x,t.y,t.z,v)}else Hu(e.dynamicLayoutVertexArray,l.x,l.y,l.z,v);f.emplaceBack(C,C+1,C+2),f.emplaceBack(C+1,C+2,C+3),g.vertexLength+=4,g.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(E[0]),r!==t.length-1&&A===t[r+1].sectionIndex||e.programConfigurations.populatePaintArrays(m.length,o,o.index,{},p,d,b&&b[A])}const w=s?s.anchor:l;e.placedSymbolArray.emplaceBack(w.x,w.y,w.z,l.x,l.y,y,this.glyphOffsetArray.length-y,x,c,u,l.segment,i?i[0]:0,i?i[1]:0,r[0],r[1],a,0,!1,0,h,0)}_commitLayoutVertex(e,t,i,r,n,o,a){e.emplaceBack(t,i,r,n,o,Math.round(a.x),Math.round(a.y))}_addCollisionDebugVertices(e,t,i,n,o,a,s){const l=i.segments.prepareSegment(4,i.layoutVertexArray,i.indexArray),c=l.vertexLength,u=s.tileAnchorX,h=s.tileAnchorY;for(let e=0;e<4;e++)i.collisionVertexArray.emplaceBack(0,0,0,0);i.collisionVertexArrayExt.emplaceBack(t,-e.padding,-e.padding),i.collisionVertexArrayExt.emplaceBack(t,e.padding,-e.padding),i.collisionVertexArrayExt.emplaceBack(t,e.padding,e.padding),i.collisionVertexArrayExt.emplaceBack(t,-e.padding,e.padding),this._commitLayoutVertex(i.layoutVertexArray,n,o,a,u,h,new r(e.x1,e.y1)),this._commitLayoutVertex(i.layoutVertexArray,n,o,a,u,h,new r(e.x2,e.y1)),this._commitLayoutVertex(i.layoutVertexArray,n,o,a,u,h,new r(e.x2,e.y2)),this._commitLayoutVertex(i.layoutVertexArray,n,o,a,u,h,new r(e.x1,e.y2)),l.vertexLength+=4;const p=i.indexArray;p.emplaceBack(c,c+1),p.emplaceBack(c+1,c+2),p.emplaceBack(c+2,c+3),p.emplaceBack(c+3,c),l.primitiveLength+=4}_addTextDebugCollisionBoxes(e,t,i,r,n,o){for(let a=r;a<n;a++){const r=i.get(a),n=this.getSymbolInstanceTextSize(e,o,t,a);this._addCollisionDebugVertices(r,n,this.textCollisionBox,r.projectedAnchorX,r.projectedAnchorY,r.projectedAnchorZ,o)}}_addIconDebugCollisionBoxes(e,t,i,r,n,o){for(let a=r;a<n;a++){const r=i.get(a),n=this.getSymbolInstanceIconSize(e,t,a);this._addCollisionDebugVertices(r,n,this.iconCollisionBox,r.projectedAnchorX,r.projectedAnchorY,r.projectedAnchorZ,o)}}generateCollisionDebugBuffers(e,t){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new CollisionBuffers(StructArrayLayout3i2i2i16,ec.members,StructArrayLayout2ui4),this.iconCollisionBox=new CollisionBuffers(StructArrayLayout3i2i2i16,ec.members,StructArrayLayout2ui4);const i=oc(this.iconSizeData,e),r=oc(this.textSizeData,e);for(let n=0;n<this.symbolInstances.length;n++){const o=this.symbolInstances.get(n);this._addTextDebugCollisionBoxes(r,e,t,o.textBoxStartIndex,o.textBoxEndIndex,o),this._addTextDebugCollisionBoxes(r,e,t,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._addIconDebugCollisionBoxes(i,e,t,o.iconBoxStartIndex,o.iconBoxEndIndex,o),this._addIconDebugCollisionBoxes(i,e,t,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex,o)}}getSymbolInstanceTextSize(e,t,i,r){const n=this.text.placedSymbolArray.get(t.rightJustifiedTextSymbolIndex>=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:r),o=nc(this.textSizeData,e,n)/24;return this.tilePixelRatio*o}getSymbolInstanceIconSize(e,t,i){const r=this.icon.placedSymbolArray.get(i),n=nc(this.iconSizeData,e,r);return this.tilePixelRatio*n}_commitDebugCollisionVertexUpdate(e,t,i){e.emplaceBack(t,-i,-i),e.emplaceBack(t,i,-i),e.emplaceBack(t,i,i),e.emplaceBack(t,-i,i)}_updateTextDebugCollisionBoxes(e,t,i,r,n,o){for(let a=r;a<n;a++){const r=i.get(a),n=this.getSymbolInstanceTextSize(e,o,t,a);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,n,r.padding)}}_updateIconDebugCollisionBoxes(e,t,i,r,n){for(let o=r;o<n;o++){const r=i.get(o),n=this.getSymbolInstanceIconSize(e,t,o);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,n,r.padding)}}updateCollisionDebugBuffers(e,t){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const i=oc(this.iconSizeData,e),r=oc(this.textSizeData,e);for(let n=0;n<this.symbolInstances.length;n++){const o=this.symbolInstances.get(n);this._updateTextDebugCollisionBoxes(r,e,t,o.textBoxStartIndex,o.textBoxEndIndex,o),this._updateTextDebugCollisionBoxes(r,e,t,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._updateIconDebugCollisionBoxes(i,e,t,o.iconBoxStartIndex,o.iconBoxEndIndex),this._updateIconDebugCollisionBoxes(i,e,t,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex)}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt)}_deserializeCollisionBoxesForSymbol(e,t,i,r,n,o,a,s,l){const c={};for(let r=t;r<i;r++){const t=e.get(r);c.textBox={x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,padding:t.padding,projectedAnchorX:t.projectedAnchorX,projectedAnchorY:t.projectedAnchorY,projectedAnchorZ:t.projectedAnchorZ,tileAnchorX:t.tileAnchorX,tileAnchorY:t.tileAnchorY},c.textFeatureIndex=t.featureIndex;break}for(let t=r;t<n;t++){const i=e.get(t);c.verticalTextBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,padding:i.padding,projectedAnchorX:i.projectedAnchorX,projectedAnchorY:i.projectedAnchorY,projectedAnchorZ:i.projectedAnchorZ,tileAnchorX:i.tileAnchorX,tileAnchorY:i.tileAnchorY},c.verticalTextFeatureIndex=i.featureIndex;break}for(let t=o;t<a;t++){const i=e.get(t);c.iconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,padding:i.padding,projectedAnchorX:i.projectedAnchorX,projectedAnchorY:i.projectedAnchorY,projectedAnchorZ:i.projectedAnchorZ,tileAnchorX:i.tileAnchorX,tileAnchorY:i.tileAnchorY},c.iconFeatureIndex=i.featureIndex;break}for(let t=s;t<l;t++){const i=e.get(t);c.verticalIconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,padding:i.padding,projectedAnchorX:i.projectedAnchorX,projectedAnchorY:i.projectedAnchorY,projectedAnchorZ:i.projectedAnchorZ,tileAnchorX:i.tileAnchorX,tileAnchorY:i.tileAnchorY},c.verticalIconFeatureIndex=i.featureIndex;break}return c}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let t=0;t<this.symbolInstances.length;t++){const i=this.symbolInstances.get(t);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}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(e,t){const i=e.placedSymbolArray.get(t),r=i.vertexStartIndex+4*i.numGlyphs;for(let t=i.vertexStartIndex;t<r;t+=4)e.indexArray.emplaceBack(t,t+1,t+2),e.indexArray.emplaceBack(t+1,t+2,t+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const t=Math.sin(e),i=Math.cos(e),r=[],n=[],o=[];for(let e=0;e<this.symbolInstances.length;++e){o.push(e);const a=this.symbolInstances.get(e);r.push(0|Math.round(t*a.tileAnchorX+i*a.tileAnchorY)),n.push(a.featureIndex)}return o.sort(((e,t)=>r[e]-r[t]||n[t]-n[e])),o}addToSortKeyRanges(e,t){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===t?i.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex),[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex].forEach(((e,t,i)=>{e>=0&&i.indexOf(e)===t&&this.addIndicesForPlacedSymbol(this.text,e)})),t.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,t.verticalPlacedTextSymbolIndex),t.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.placedIconSymbolIndex),t.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}En(SymbolBucket,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),SymbolBucket.MAX_GLYPHS=65535,SymbolBucket.addDynamicAttributes=Hu;const Ku=new Properties({"symbol-placement":new DataConstantProperty(ct.layout_symbol["symbol-placement"]),"symbol-spacing":new DataConstantProperty(ct.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new DataConstantProperty(ct.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new DataDrivenProperty(ct.layout_symbol["symbol-sort-key"]),"symbol-z-order":new DataConstantProperty(ct.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new DataConstantProperty(ct.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new DataConstantProperty(ct.layout_symbol["icon-ignore-placement"]),"icon-optional":new DataConstantProperty(ct.layout_symbol["icon-optional"]),"icon-rotation-alignment":new DataConstantProperty(ct.layout_symbol["icon-rotation-alignment"]),"icon-size":new DataDrivenProperty(ct.layout_symbol["icon-size"]),"icon-text-fit":new DataConstantProperty(ct.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new DataConstantProperty(ct.layout_symbol["icon-text-fit-padding"]),"icon-image":new DataDrivenProperty(ct.layout_symbol["icon-image"]),"icon-rotate":new DataDrivenProperty(ct.layout_symbol["icon-rotate"]),"icon-padding":new DataConstantProperty(ct.layout_symbol["icon-padding"]),"icon-keep-upright":new DataConstantProperty(ct.layout_symbol["icon-keep-upright"]),"icon-offset":new DataDrivenProperty(ct.layout_symbol["icon-offset"]),"icon-anchor":new DataDrivenProperty(ct.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new DataConstantProperty(ct.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new DataConstantProperty(ct.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new DataConstantProperty(ct.layout_symbol["text-rotation-alignment"]),"text-field":new DataDrivenProperty(ct.layout_symbol["text-field"]),"text-font":new DataDrivenProperty(ct.layout_symbol["text-font"]),"text-size":new DataDrivenProperty(ct.layout_symbol["text-size"]),"text-max-width":new DataDrivenProperty(ct.layout_symbol["text-max-width"]),"text-line-height":new DataDrivenProperty(ct.layout_symbol["text-line-height"]),"text-letter-spacing":new DataDrivenProperty(ct.layout_symbol["text-letter-spacing"]),"text-justify":new DataDrivenProperty(ct.layout_symbol["text-justify"]),"text-radial-offset":new DataDrivenProperty(ct.layout_symbol["text-radial-offset"]),"text-variable-anchor":new DataConstantProperty(ct.layout_symbol["text-variable-anchor"]),"text-anchor":new DataDrivenProperty(ct.layout_symbol["text-anchor"]),"text-max-angle":new DataConstantProperty(ct.layout_symbol["text-max-angle"]),"text-writing-mode":new DataConstantProperty(ct.layout_symbol["text-writing-mode"]),"text-rotate":new DataDrivenProperty(ct.layout_symbol["text-rotate"]),"text-padding":new DataConstantProperty(ct.layout_symbol["text-padding"]),"text-keep-upright":new DataConstantProperty(ct.layout_symbol["text-keep-upright"]),"text-transform":new DataDrivenProperty(ct.layout_symbol["text-transform"]),"text-offset":new DataDrivenProperty(ct.layout_symbol["text-offset"]),"text-allow-overlap":new DataConstantProperty(ct.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new DataConstantProperty(ct.layout_symbol["text-ignore-placement"]),"text-optional":new DataConstantProperty(ct.layout_symbol["text-optional"])});var Ju={paint:new Properties({"icon-opacity":new DataDrivenProperty(ct.paint_symbol["icon-opacity"]),"icon-color":new DataDrivenProperty(ct.paint_symbol["icon-color"]),"icon-halo-color":new DataDrivenProperty(ct.paint_symbol["icon-halo-color"]),"icon-halo-width":new DataDrivenProperty(ct.paint_symbol["icon-halo-width"]),"icon-halo-blur":new DataDrivenProperty(ct.paint_symbol["icon-halo-blur"]),"icon-translate":new DataConstantProperty(ct.paint_symbol["icon-translate"]),"icon-translate-anchor":new DataConstantProperty(ct.paint_symbol["icon-translate-anchor"]),"text-opacity":new DataDrivenProperty(ct.paint_symbol["text-opacity"]),"text-color":new DataDrivenProperty(ct.paint_symbol["text-color"],{runtimeType:xt,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new DataDrivenProperty(ct.paint_symbol["text-halo-color"]),"text-halo-width":new DataDrivenProperty(ct.paint_symbol["text-halo-width"]),"text-halo-blur":new DataDrivenProperty(ct.paint_symbol["text-halo-blur"]),"text-translate":new DataConstantProperty(ct.paint_symbol["text-translate"]),"text-translate-anchor":new DataConstantProperty(ct.paint_symbol["text-translate-anchor"])}),layout:Ku};class FormatSectionOverride{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:mt,this.defaultValue=e}evaluate(e){if(e.formattedSection){const t=this.defaultValue.property.overrides;if(t&&t.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}En(FormatSectionOverride,"FormatSectionOverride",{omit:["defaultValue"]});class SymbolStyleLayer extends StyleLayer{constructor(e){super(e,Ju)}recalculate(e,t){super.recalculate(e,t),"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 i=this.layout.get("text-writing-mode");if(i){const e=[];for(const t of i)e.indexOf(t)<0&&e.push(t);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(e,t,i,r){const n=this.layout.get(e).evaluate(t,{},i,r),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||Er(o.value)||!n?n:function(e,t){return t.replace(/{([^{}]+)}/g,((t,i)=>i in e?String(e[i]):""))}(t.properties,n)}createBucket(e){return new SymbolBucket(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of Ju.paint.overridableProperties){if(!SymbolStyleLayer.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new FormatSectionOverride(t),r=new StyleExpression(i,t.property.specification);let n=null;n="constant"===t.value.kind||"source"===t.value.kind?new ZoomConstantExpression("source",r):new ZoomDependentExpression("composite",r,t.value.zoomStops,t.value._interpolationType),this.paint._values[e]=new PossiblyEvaluatedPropertyValue(t.property,n,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven())&&SymbolStyleLayer.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),r=Ju.paint.properties[t];let n=!1;const o=e=>{for(const t of e)if(r.overrides&&r.overrides.hasOverride(t))return void(n=!0)};if("constant"===i.value.kind&&i.value.value instanceof Formatted)o(i.value.value.sections);else if("source"===i.value.kind){const e=t=>{n||(t instanceof Vt&&Ft(t.value)===Tt?o(t.value.sections):t instanceof FormatExpression?o(t.sections):t.eachChild(e))},t=i.value;t._styleExpression&&e(t._styleExpression.expression)}return n}getProgramConfiguration(e){return new ProgramConfiguration(this,e)}}var Yu={paint:new Properties({"background-color":new DataConstantProperty(ct.paint_background["background-color"]),"background-pattern":new CrossFadedProperty(ct.paint_background["background-pattern"]),"background-opacity":new DataConstantProperty(ct.paint_background["background-opacity"])})},Qu={paint:new Properties({"raster-opacity":new DataConstantProperty(ct.paint_raster["raster-opacity"]),"raster-hue-rotate":new DataConstantProperty(ct.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new DataConstantProperty(ct.paint_raster["raster-brightness-min"]),"raster-brightness-max":new DataConstantProperty(ct.paint_raster["raster-brightness-max"]),"raster-saturation":new DataConstantProperty(ct.paint_raster["raster-saturation"]),"raster-contrast":new DataConstantProperty(ct.paint_raster["raster-contrast"]),"raster-resampling":new DataConstantProperty(ct.paint_raster["raster-resampling"]),"raster-fade-duration":new DataConstantProperty(ct.paint_raster["raster-fade-duration"])})};class CustomStyleLayer extends StyleLayer{constructor(e){super(e,{}),this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)}}var eh={paint:new Properties({"sky-type":new DataConstantProperty(ct.paint_sky["sky-type"]),"sky-atmosphere-sun":new DataConstantProperty(ct.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new DataConstantProperty(ct.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new DataConstantProperty(ct.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new DataConstantProperty(ct.paint_sky["sky-gradient-radius"]),"sky-gradient":new ColorRampProperty(ct.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new DataConstantProperty(ct.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new DataConstantProperty(ct.paint_sky["sky-atmosphere-color"]),"sky-opacity":new DataConstantProperty(ct.paint_sky["sky-opacity"])})};function th(e,t,i){const r=[0,0,1],n=ns([]);return as(n,n,i?-l(e)+Math.PI:l(e)),os(n,n,-l(t)),Xa(r,r,n),Za(r,r)}const ih={circle:class CircleStyleLayer extends StyleLayer{constructor(e){super(e,ua)}createBucket(e){return new CircleBucket(e)}queryRadius(e){const t=e;return oa("circle-radius",this,t)+oa("circle-stroke-width",this,t)+aa(this.paint.get("circle-translate"))}queryIntersectsFeature(e,t,i,r,n,o,a,s){const l=la(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),c=this.paint.get("circle-radius").evaluate(t,i)+this.paint.get("circle-stroke-width").evaluate(t,i);return ls(e,r,o,a,s,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,c)}getProgramIds(){return["circle"]}getProgramConfiguration(e){return new ProgramConfiguration(this,e)}},heatmap:class HeatmapStyleLayer extends StyleLayer{createBucket(e){return new HeatmapBucket(e)}constructor(e){super(e,_s),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=gs({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(e){return oa("heatmap-radius",this,e)}queryIntersectsFeature(e,t,i,n,o,a,s,l){const c=this.paint.get("heatmap-radius").evaluate(t,i);return ls(e,n,a,s,l,!0,!0,new r(0,0),c)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(e){return new ProgramConfiguration(this,e)}},hillshade:class HillshadeStyleLayer extends StyleLayer{constructor(e){super(e,ys)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class FillStyleLayer extends StyleLayer{constructor(e){super(e,nl)}getProgramIds(){const e=this.paint.get("fill-pattern"),t=e&&e.constantOr(1),i=[t?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&i.push(t&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),i}getProgramConfiguration(e){return new ProgramConfiguration(this,e)}recalculate(e,t){super.recalculate(e,t);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new FillBucket(e)}queryRadius(){return aa(this.paint.get("fill-translate"))}queryIntersectsFeature(e,t,i,r,n,o){return!e.queryGeometry.isAboveHorizon&&Xo(sa(e.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),r)}isTileClipped(){return!0}},"fill-extrusion":class FillExtrusionStyleLayer extends StyleLayer{constructor(e){super(e,zl)}createBucket(e){return new FillExtrusionBucket(e)}queryRadius(){return aa(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(e){return new ProgramConfiguration(this,e)}queryIntersectsFeature(e,t,i,n,o,a,s,l,c){const u=la(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,e.pixelToTileUnitsFactor),h=this.paint.get("fill-extrusion-height").evaluate(t,i),p=this.paint.get("fill-extrusion-base").evaluate(t,i),d=[0,0],f=l&&a.elevation,m=a.elevation?a.elevation.exaggeration():1,_=e.tile.getBucket(this);if(f&&_ instanceof FillExtrusionBucket){const e=_.centroidVertexArray,t=c+1;if(t<e.length){const i=e.get(t);d[0]=i.a_centroid_pos0,d[1]=i.a_centroid_pos1}}if(0===d[0]&&1===d[1])return!1;"globe"===a.projection.name&&(n=Pl([n],[new r(0,0),new r(Eo,Eo)],e.tileID.canonical).map((e=>e.polygon)).flat());const g=function(e,t,i,n,o,a,s,l,c,u,h){return"globe"===e.projection.name?function(e,t,i,r,n,o,a,s,l,c,u){const h=[],p=[],d=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(e,t,i,r)=>{e[0]=t,e[1]=i,e[2]=r,e[3]=1},g=Ml();i>0&&(i+=g),r+=g;for(const g of t){const t=[],y=[];for(const h of g){const p=h.x+n.x,g=h.y+n.y,x=e.projection.projectTilePoint(p,g,u),v=e.projection.upVector(u,h.x,h.y);let b=i,w=r;if(a){const e=Ol(p,g,i,r,a,s,l,c);b+=e.base,w+=e.top}0!==i?_(f,x.x+v[0]*d*b,x.y+v[1]*d*b,x.z+v[2]*d*b):_(f,x.x,x.y,x.z),_(m,x.x+v[0]*d*w,x.y+v[1]*d*w,x.z+v[2]*d*w),Wa(f,f,o),Wa(m,m,o),t.push(Fl(f)),y.push(Fl(m))}h.push(t),p.push(y)}return[h,p]}(e,t,i,n,o,a,s,l,c,u,h):s?function(e,t,i,r,n,o,a,s,l){const c=[],u=[],h=[0,0,0,1];for(const p of e){const e=[],d=[];for(const c of p){const u=c.x+r.x,p=c.y+r.y,f=Ol(u,p,t,i,o,a,s,l);h[0]=u,h[1]=p,h[2]=f.base,h[3]=1,is(h,h,n),h[3]=Math.max(h[3],1e-5);const m=Fl([h[0]/h[3],h[1]/h[3],h[2]/h[3]]);h[0]=u,h[1]=p,h[2]=f.top,h[3]=1,is(h,h,n),h[3]=Math.max(h[3],1e-5);const _=Fl([h[0]/h[3],h[1]/h[3],h[2]/h[3]]);e.push(m),d.push(_)}c.push(e),u.push(d)}return[c,u]}(t,i,n,o,a,s,l,c,u):function(e,t,i,n,o){const a=[],s=[],l=o[8]*t,c=o[9]*t,u=o[10]*t,h=o[11]*t,p=o[8]*i,d=o[9]*i,f=o[10]*i,m=o[11]*i;for(const t of e){const e=[],i=[];for(const a of t){const t=a.x+n.x,s=a.y+n.y,_=o[0]*t+o[4]*s+o[12],g=o[1]*t+o[5]*s+o[13],y=o[2]*t+o[6]*s+o[14],x=o[3]*t+o[7]*s+o[15],v=_+l,b=g+c,w=y+u,T=Math.max(x+h,1e-5),E=_+p,S=g+d,A=y+f,C=Math.max(x+m,1e-5),I=new r(v/T,b/T);I.z=w/T,e.push(I);const M=new r(E/C,S/C);M.z=A/C,i.push(M)}a.push(e),s.push(i)}return[a,s]}(t,i,n,o,a)}(a,n,p,h,u,s,f?l:null,d,m,a.center.lat,e.tileID.canonical),y=e.queryGeometry;return function(e,t,i){let r=1/0;Xo(i,t)&&(r=Rl(i,t[0]));for(let n=0;n<t.length;n++){const o=t[n],a=e[n];for(let e=0;e<o.length-1;e++){const t=o[e],n=[t,o[e+1],a[e+1],a[e],t];Wo(i,n)&&(r=Math.min(r,Rl(i,n)))}}return r!==1/0&&r}(g[0],g[1],y.isPointQuery()?y.screenBounds:y.screenGeometry)}},line:class LineStyleLayer extends StyleLayer{constructor(e){super(e,$l),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof yi,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=Wl.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new LineBucket(e)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getProgramConfiguration(e){return new ProgramConfiguration(this,e)}queryRadius(e){const t=e,i=Hl(oa("line-width",this,t),oa("line-gap-width",this,t)),r=oa("line-offset",this,t);return i/2+Math.abs(r)+aa(this.paint.get("line-translate"))}queryIntersectsFeature(e,t,i,n,o,a){if(e.queryGeometry.isAboveHorizon)return!1;const s=sa(e.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),a.angle,e.pixelToTileUnitsFactor),l=e.pixelToTileUnitsFactor/2*Hl(this.paint.get("line-width").evaluate(t,i),this.paint.get("line-gap-width").evaluate(t,i)),c=this.paint.get("line-offset").evaluate(t,i);return c&&(n=function(e,t){const i=[],n=new r(0,0);for(let r=0;r<e.length;r++){const o=e[r],a=[];for(let e=0;e<o.length;e++){const i=o[e-1],r=o[e],s=o[e+1],l=0===e?n:r.sub(i)._unit()._perp(),c=e===o.length-1?n:s.sub(r)._unit()._perp(),u=l._add(c)._unit();u._mult(1/(u.x*c.x+u.y*c.y)),a.push(u._mult(t)._add(r))}i.push(a)}return i}(n,c*e.pixelToTileUnitsFactor)),function(e,t,i){for(let r=0;r<t.length;r++){const n=t[r];if(e.length>=3)for(let t=0;t<n.length;t++)if(ia(e,n[t]))return!0;if(Ko(e,n,i))return!0}return!1}(s,n,l)}isTileClipped(){return!0}},symbol:SymbolStyleLayer,background:class BackgroundStyleLayer extends StyleLayer{constructor(e){super(e,Yu)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}},raster:class RasterStyleLayer extends StyleLayer{constructor(e){super(e,Qu)}getProgramIds(){return["raster"]}},sky:class SkyLayer extends StyleLayer{constructor(e){super(e,eh),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"sky-gradient"===e?this._updateColorRamp():"sky-atmosphere-sun"!==e&&"sky-atmosphere-halo-color"!==e&&"sky-atmosphere-color"!==e&&"sky-atmosphere-sun-intensity"!==e||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=gs({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(e){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const t=e.style.light.properties.get("position");return this._lightPosition.azimuthal!==t.azimuthal||this._lightPosition.polar!==t.polar}return!1}getCenter(e,t){if("atmosphere"===this.paint.get("sky-type")){const i=this.paint.get("sky-atmosphere-sun"),r=!i,n=e.style.light,o=n.properties.get("position");return r&&"viewport"===n.properties.get("anchor")&&B("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),r?th(o.azimuthal,90-o.polar,t):th(i[0],90-i[1],t)}const i=this.paint.get("sky-gradient-center");return th(i[0],90-i[1],t)}is3D(){return!1}isSky(){return!0}markSkyboxValid(e){this._skyboxInvalidated=!1,this._lightPosition=e.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const e=this.paint.get("sky-type");return"atmosphere"===e?["skyboxCapture","skybox"]:"gradient"===e?["skyboxGradient"]:null}}};function rh(e){return"custom"===e.type?new CustomStyleLayer(e):new ih[e.type](e)}class Texture{constructor(e,t,i,r){this.context=e,this.format=i,this.texture=e.gl.createTexture(),this.update(t,r)}update(t,i,r){const{width:n,height:o}=t,{context:a}=this,{gl:s}=a,{HTMLImageElement:l,HTMLCanvasElement:c,HTMLVideoElement:u,ImageData:h,ImageBitmap:p}=e;if(s.bindTexture(s.TEXTURE_2D,this.texture),a.pixelStoreUnpackFlipY.set(!1),a.pixelStoreUnpack.set(1),a.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!i||!1!==i.premultiply)),r||this.size&&this.size[0]===n&&this.size[1]===o){const{x:e,y:i}=r||{x:0,y:0};t instanceof l||t instanceof c||t instanceof u||t instanceof h||p&&t instanceof p?s.texSubImage2D(s.TEXTURE_2D,0,e,i,s.RGBA,s.UNSIGNED_BYTE,t):s.texSubImage2D(s.TEXTURE_2D,0,e,i,n,o,s.RGBA,s.UNSIGNED_BYTE,t.data)}else this.size=[n,o],t instanceof l||t instanceof c||t instanceof u||t instanceof h||p&&t instanceof p?s.texImage2D(s.TEXTURE_2D,0,this.format,this.format,s.UNSIGNED_BYTE,t):s.texImage2D(s.TEXTURE_2D,0,this.format,n,o,0,this.format,s.UNSIGNED_BYTE,t.data);this.useMipmap=Boolean(i&&i.useMipmap&&this.isSizePowerOfTwo()),this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(e,t){const{context:i}=this,{gl:r}=i;r.bindTexture(r.TEXTURE_2D,this.texture),e!==this.filter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap?e===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_NEAREST:e),this.filter=e),t!==this.wrap&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,t),this.wrap=t)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}function nh(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class ImageManager extends Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,callback:t}of this.requestors)this._notify(e,t);this.requestors=[]}}hasImage(e){return!!this.getImage(e)}getImage(e){return this.images[e]}addImage(e,t){this._validate(e,t)&&(this.images[e]=t)}_validate(e,t){let i=!0;return this._validateStretch(t.stretchX,t.data&&t.data.width)||(this.fire(new ErrorEvent(new Error(`Image "${e}" has invalid "stretchX" value`))),i=!1),this._validateStretch(t.stretchY,t.data&&t.data.height)||(this.fire(new ErrorEvent(new Error(`Image "${e}" has invalid "stretchY" value`))),i=!1),this._validateContent(t.content,t)||(this.fire(new ErrorEvent(new Error(`Image "${e}" has invalid "content" value`))),i=!1),i}_validateStretch(e,t){if(!e)return!0;let i=0;for(const r of e){if(r[0]<i||r[1]<r[0]||t<r[1])return!1;i=r[1]}return!0}_validateContent(e,t){return!(e&&(4!==e.length||e[0]<0||t.data.width<e[0]||e[1]<0||t.data.height<e[1]||e[2]<0||t.data.width<e[2]||e[3]<0||t.data.height<e[3]||e[2]<e[0]||e[3]<e[1]))}updateImage(e,t){t.version=this.images[e].version+1,this.images[e]=t,this.updatedImages[e]=!0}removeImage(e){const t=this.images[e];delete this.images[e],delete this.patterns[e],t.userImage&&t.userImage.onRemove&&t.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(e,t){let i=!0;if(!this.isLoaded())for(const t of e)this.images[t]||(i=!1);this.isLoaded()||i?this._notify(e,t):this.requestors.push({ids:e,callback:t})}_notify(e,t){const i={};for(const t of e){this.images[t]||this.fire(new Event("styleimagemissing",{id:t}));const e=this.images[t];e?i[t]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:B(`Image "${t}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}t(null,i)}getPixelSize(){const{width:e,height:t}=this.atlasImage;return{width:e,height:t}}getPattern(e){const t=this.patterns[e],i=this.getImage(e);if(!i)return null;if(t&&t.position.version===i.version)return t.position;if(t)t.position.version=i.version;else{const t={w:i.data.width+2,h:i.data.height+2,x:0,y:0},r=new ImagePosition(t,i);this.patterns[e]={bin:t,position:r}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const t=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new Texture(e,this.atlasImage,t.RGBA),this.atlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const t in this.patterns)e.push(this.patterns[t].bin);const{w:t,h:i}=Lc(e),r=this.atlasImage;r.resize({width:t||1,height:i||1});for(const e in this.patterns){const{bin:t}=this.patterns[e],i=t.x+1,n=t.y+1,o=this.images[e].data,a=o.width,s=o.height;RGBAImage.copy(o,r,{x:0,y:0},{x:i,y:n},{width:a,height:s}),RGBAImage.copy(o,r,{x:0,y:s-1},{x:i,y:n-1},{width:a,height:1}),RGBAImage.copy(o,r,{x:0,y:0},{x:i,y:n+s},{width:a,height:1}),RGBAImage.copy(o,r,{x:a-1,y:0},{x:i-1,y:n},{width:1,height:s}),RGBAImage.copy(o,r,{x:0,y:0},{x:i+a,y:n},{width:1,height:s})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const t of e){if(this.callbackDispatchedThisFrame[t])continue;this.callbackDispatchedThisFrame[t]=!0;const e=this.images[t];nh(e)&&this.updateImage(t,e)}}}const oh=new Properties({anchor:new DataConstantProperty(ct.light.anchor),position:new class LightPositionProperty{constructor(){this.specification=ct.light.position}possiblyEvaluate(e,t){return function([e,t,i]){const r=l(t+90),n=l(i);return{x:e*Math.cos(r)*Math.sin(n),y:e*Math.sin(r)*Math.sin(n),z:e*Math.cos(n),azimuthal:t,polar:i}}(e.expression.evaluate(t))}interpolate(e,t,i){return{x:xi(e.x,t.x,i),y:xi(e.y,t.y,i),z:xi(e.z,t.z,i),azimuthal:xi(e.azimuthal,t.azimuthal,i),polar:xi(e.polar,t.polar,i)}}},color:new DataConstantProperty(ct.light.color),intensity:new DataConstantProperty(ct.light.intensity)}),ah="-transition";class Light extends Evented{constructor(e){super(),this._transitionable=new Transitionable(oh),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,t={}){if(!this._validate(pn,e,t))for(const t in e){const i=e[t];M(t,ah)?this._transitionable.setTransition(t.slice(0,-ah.length),i):this._transitionable.setValue(t,i)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,i){return(!i||!1!==i.validate)&&vn(this,e.call(un,b({value:t,style:{glyphs:!0,sprite:!0},styleSpec:ct})))}}const sh=new Properties({source:new DataConstantProperty(ct.terrain.source),exaggeration:new DataConstantProperty(ct.terrain.exaggeration)}),lh="-transition";class Terrain$1 extends Evented{constructor(e,t){super(),this._transitionable=new Transitionable(sh),this.set(e),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=t}get(){return this._transitionable.serialize()}set(e){for(const t in e){const i=e[t];M(t,lh)?this._transitionable.setTransition(t.slice(0,-lh.length),i):this._transitionable.setValue(t,i)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}}function ch(e,t,i,r){const n=g(45,65,i),[o,a]=uh(e,r),s=La(t);let l=1-Math.min(1,Math.exp((s-o)/(a-o)*-6));return l*=l*l,l=Math.min(1,1.00747*l),l*n*e.alpha}function uh(e,t){const i=.5/Math.tan(.5*t);return[e.range[0]+i,e.range[1]+i]}const hh=new Properties({range:new DataConstantProperty(ct.fog.range),color:new DataConstantProperty(ct.fog.color),"high-color":new DataConstantProperty(ct.fog["high-color"]),"space-color":new DataConstantProperty(ct.fog["space-color"]),"horizon-blend":new DataConstantProperty(ct.fog["horizon-blend"]),"star-intensity":new DataConstantProperty(ct.fog["star-intensity"])}),ph="-transition";class Fog extends Evented{constructor(e,t){super(),this._transitionable=new Transitionable(hh),this.set(e),this._transitioning=this._transitionable.untransitioned(),this._transform=t}get state(){const e=this._transform,t="globe"===e.projection.name,i=_u(e.zoom),r=this.properties.get("range"),n=[.5,3];return{range:t?[xi(n[0],r[0],i),xi(n[1],r[1],i)]:r,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(e,t={}){if(!this._validate(fn,e,t)){for(const t of Object.keys(ct.fog))e&&void 0===e[t]&&(e[t]=ct.fog[t].default);for(const t in e){const i=e[t];M(t,ph)?this._transitionable.setTransition(t.slice(0,-ph.length),i):this._transitionable.setValue(t,i)}}}getOpacity(e){if(!this._transform.projection.supportsFog)return 0;const t=this.properties&&this.properties.get("color")||1;return("globe"===this._transform.projection.name?1:g(45,65,e))*t.a}getOpacityAtLatLng(e,t){return this._transform.projection.supportsFog?function(e,t,i){const r=MercatorCoordinate.fromLngLat(t),n=i.elevation?i.elevation.getAtPointOrZero(r):0,o=[r.x,r.y,n];return Wa(o,o,i.mercatorFogMatrix),ch(e,o,i.pitch,i._fov)}(this.state,e,t):0}getFovAdjustedRange(e){return this._transform.projection.supportsFog?uh(this.state,e):[0,1]}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,i){return(!i||!1!==i.validate)&&vn(this,e.call(un,b({value:t,style:{glyphs:!0,sprite:!0},styleSpec:ct})))}}class LineAtlas{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.image=new AlphaImage({width:e,height:t}),this.positions={},this.uploaded=!1}getDash(e,t){const i=this.getKey(e,t);return this.positions[i]}trim(){const e=this.width,t=this.height=A(this.nextRow);this.image.resize({width:e,height:t})}getKey(e,t){return e.join(",")+t}getDashRanges(e,t,i){const r=[];let n=e.length%2==1?-e[e.length-1]*i:0,o=e[0]*i,a=!0;r.push({left:n,right:o,isDash:a,zeroLength:0===e[0]});let s=e[0];for(let t=1;t<e.length;t++){a=!a;const l=e[t];n=s*i,s+=l,o=s*i,r.push({left:n,right:o,isDash:a,zeroLength:0===l})}return r}addRoundDash(e,t,i){const r=t/2;for(let t=-i;t<=i;t++){const n=this.width*(this.nextRow+i+t);let o=0,a=e[o];for(let s=0;s<this.width;s++){s/a.right>1&&(a=e[++o]);const l=Math.abs(s-a.left),c=Math.abs(s-a.right),u=Math.min(l,c);let h;const p=t/i*(r+1);if(a.isDash){const e=r-Math.abs(p);h=Math.sqrt(u*u+e*e)}else h=r-Math.sqrt(u*u+p*p);this.image.data[n+s]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(e,t){for(let t=e.length-1;t>=0;--t){const i=e[t],r=e[t+1];i.zeroLength?e.splice(t,1):r&&r.isDash===i.isDash&&(r.left=i.left,e.splice(t,1))}const i=e[0],r=e[e.length-1];i.isDash===r.isDash&&(i.left=r.left-this.width,r.right=i.right+this.width);const n=this.width*this.nextRow;let o=0,a=e[o];for(let i=0;i<this.width;i++){i/a.right>1&&(a=e[++o]);const r=Math.abs(i-a.left),s=Math.abs(i-a.right),l=Math.min(r,s);this.image.data[n+i]=Math.max(0,Math.min(255,(a.isDash?l:-l)+t+128))}}addDash(e,t){const i=this.getKey(e,t);if(this.positions[i])return this.positions[i];const r="round"===t,n=r?7:0,o=2*n+1;if(this.nextRow+o>this.height)return B("LineAtlas out of space"),null;0===e.length&&e.push(1);let a=0;for(let t=0;t<e.length;t++)e[t]<0&&(B("Negative value is found in line dasharray, replacing values with 0"),e[t]=0),a+=e[t];if(0!==a){const i=this.width/a,o=this.getDashRanges(e,this.width,i);r?this.addRoundDash(o,i,n):this.addRegularDash(o,"square"===t?.5*i:0)}const s=this.nextRow+n;this.nextRow+=o;const l={tl:[s,n],br:[a,0]};return this.positions[i]=l,l}}En(LineAtlas,"LineAtlas");class ThrottledInvoker{constructor(e){this._callback=e,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(){this._channel=void 0,this._callback=()=>{}}}class Scheduler{constructor(){this.tasks={},this.taskQueue=[],I(["process"],this),this.invoker=new ThrottledInvoker(this.process),this.nextId=0}add(e,t){const i=this.nextId++,r=function({type:e,isSymbolTile:t,zoom:i}){return i=i||0,"message"===e?0:"maybePrepare"!==e||t?"parseTile"!==e||t?"parseTile"===e&&t?300-i:"maybePrepare"===e&&t?400-i:500:200-i:100-i}(t);if(0===r){O();try{e()}finally{}return{cancel:()=>{}}}return this.tasks[i]={fn:e,metadata:t,priority:r,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){O();try{if(this.taskQueue=this.taskQueue.filter((e=>!!this.tasks[e])),!this.taskQueue.length)return;const e=this.pick();if(null===e)return;const t=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!t)return;t.fn()}finally{}}pick(){let e=null,t=1/0;for(let i=0;i<this.taskQueue.length;i++){const r=this.tasks[this.taskQueue[i]];r.priority<t&&(t=r.priority,e=i)}if(null===e)return null;const i=this.taskQueue[e];return this.taskQueue.splice(e,1),i}remove(){this.invoker.remove()}}class Dispatcher{constructor(e,t){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=E();const i=this.workerPool.acquire(this.id);for(let e=0;e<i.length;e++){const r=new Dispatcher.Actor(i[e],t,this.id);r.name=`Worker ${e}`,this.actors.push(r)}this.ready=!1,this.broadcast("checkIfReady",null,(()=>{this.ready=!0}))}broadcast(e,t,i){x(this.actors,((i,r)=>{i.send(e,t,r)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((e=>{e.remove()})),this.actors=[],this.workerPool.release(this.id)}}function dh(e,t,i){return t*(Eo/(e.tileSize*Math.pow(2,i-e.tileID.overscaledZ)))}Dispatcher.Actor=class Actor{constructor(t,i,r){this.target=t,this.parent=i,this.mapId=r,this.callbacks={},this.cancelCallbacks={},I(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=O()?t:e,this.scheduler=new Scheduler}send(e,t,i,r,n=!1,o){const a=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=o,this.callbacks[a]=i);const s=j(this.globalScope)?void 0:[];return this.target.postMessage({id:a,type:e,hasCallback:!!i,targetMapId:r,mustQueue:n,sourceMapId:this.mapId,data:Cn(t,s)},s),{cancel:()=>{i&&delete this.callbacks[a],this.target.postMessage({id:a,type:"<cancel>",targetMapId:r,sourceMapId:this.mapId})}}}receive(e){const t=e.data,i=t.id;if(i&&(!t.targetMapId||this.mapId===t.targetMapId))if("<cancel>"===t.type){const e=this.cancelCallbacks[i];delete this.cancelCallbacks[i],e&&e.cancel()}else if(t.mustQueue||O()){const e=this.callbacks[i];this.cancelCallbacks[i]=this.scheduler.add((()=>this.processTask(i,t)),e&&e.metadata||{type:"message"})}else this.processTask(i,t)}processTask(e,t){if("<response>"===t.type){const i=this.callbacks[e];delete this.callbacks[e],i&&(t.error?i(Mn(t.error)):i(null,Mn(t.data)))}else{const i=j(this.globalScope)?void 0:[],r=t.hasCallback?(t,r)=>{delete this.cancelCallbacks[e],this.target.postMessage({id:e,type:"<response>",sourceMapId:this.mapId,error:t?Cn(t):null,data:Cn(r,i)},i)}:e=>{},n=Mn(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,n,r);else if(this.parent.getWorkerSource){const e=t.type.split(".");this.parent.getWorkerSource(t.sourceMapId,e[0],n.source)[e[1]](n,r)}else r(new Error(`Could not find function ${t.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}};class QueryGeometry{constructor(e,t,i,r){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,r)}static createFromScreenPoints(e,t){let i,n;if(e instanceof r||"number"==typeof e[0]){const o=r.convert(e);i=[r.convert(e)],n=t.isPointAboveHorizon(o)}else{const o=r.convert(e[0]),a=r.convert(e[1]);i=[o,a],n=d(o,a).every((e=>t.isPointAboveHorizon(e)))}return new QueryGeometry(i,t.getCameraPoint(),n,t)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(e){return d(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],e)}bufferedCameraGeometry(e){const t=this.screenBounds[0],i=1===this.screenBounds.length?this.screenBounds[0].add(new r(1,1)):this.screenBounds[1],n=d(t,i,0,!1);return this.cameraPoint.y>i.y&&(this.cameraPoint.x>t.x&&this.cameraPoint.x<i.x?n.splice(3,0,this.cameraPoint):this.cameraPoint.x>=i.x?n[2]=this.cameraPoint:this.cameraPoint.x<=t.x&&(n[3]=this.cameraPoint)),function(e,t){const i=[];for(let r=0;r<e.length;r++){const n=y(r-1,-1,e.length-1),o=y(r+1,-1,e.length-1),a=e[r],s=e[o],l=e[n].sub(a).unit(),c=s.sub(a).unit(),u=c.angleWithSep(l.x,l.y),h=l.add(c).unit().mult(-1*t/Math.sin(u/2));i.push(a.add(h))}return i}(n,e)}bufferedCameraGeometryGlobe(e){const t=this.screenBounds[0],i=1===this.screenBounds.length?this.screenBounds[0].add(new r(1,1)):this.screenBounds[1],n=d(t,i,e),o=this.cameraPoint.clone();switch(3*((o.y>t.y)+(o.y>i.y))+((o.x>t.x)+(o.x>i.x))){case 0:n[0]=o,n[4]=o.clone();break;case 1:n.splice(1,0,o);break;case 2:n[1]=o;break;case 3:n.splice(4,0,o);break;case 5:n.splice(2,0,o);break;case 6:n[3]=o;break;case 7:n.splice(3,0,o);break;case 8:n[2]=o}return n}containsTile(e,t,i,n=0){const o=e.queryPadding/t._pixelsPerMercatorPixel+1,a=i?this._bufferedCameraMercator(o,t):this._bufferedScreenMercator(o,t);let s=e.tileID.wrap+(a.unwrapped?n:0);const l=a.polygon.map((t=>Pu(e.tileTransform,t,s)));if(!ra(l,0,0,Eo,Eo))return;s=e.tileID.wrap+(this.screenGeometryMercator.unwrapped?n:0);const c=this.screenGeometryMercator.polygon.map((t=>Du(e.tileTransform,t,s))),u=c.map((e=>new r(e[0],e[1]))),h=t.getFreeCameraOptions().position||new MercatorCoordinate(0,0,0),d=Du(e.tileTransform,h,s),f=c.map((e=>{const t=Ja(e,e,d);return Za(t,t),new Ray(d,t)})),m=dh(e,1,t.zoom)*t._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:f,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(g=p(l),g.min.x=_(g.min.x,0,Eo),g.min.y=_(g.min.y,0,Eo),g.max.x=_(g.max.x,0,Eo),g.max.y=_(g.max.y,0,Eo),g),tile:e,tileID:e.tileID,pixelToTileUnitsFactor:m};var g}_bufferedScreenMercator(e,t){const i=_h(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._screenRaycastCache[i]=r,r}}_bufferedCameraMercator(e,t){const i=_h(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._cameraRaycastCache[i]=r,r}}_projectAndResample(e,t){const i=function(e,t){const i=va([],t.pixelMatrix,t.globeMatrix),n=[0,-Wc,0,1],o=[0,Wc,0,1],a=[0,0,0,1];is(n,n,i),is(o,o,i),is(a,a,i);const s=new r(n[0]/n[3],n[1]/n[3]),l=new r(o[0]/o[3],o[1]/o[3]),c=ia(e,s)&&n[3]<a[3],u=ia(e,l)&&o[3]<a[3];if(!c&&!u)return null;const h=function(e,t,i){for(let r=1;r<e.length;r++){const n=mh(t.pointCoordinate3D(e[r-1]).x),o=mh(t.pointCoordinate3D(e[r]).x);if(i<0){if(n<o)return{idx:r,t:-n/(o-1-n)}}else if(o<n)return{idx:r,t:(1-n)/(o+1-n)}}return null}(e,t,c?-1:1);if(!h)return null;const{idx:p,t:d}=h;let f=p>1?fh(e.slice(0,p),t):[],m=p<e.length?fh(e.slice(p),t):[];f=f.map((e=>new r(mh(e.x),e.y))),m=m.map((e=>new r(mh(e.x),e.y)));const _=[...f];0===_.length&&_.push(m[m.length-1]);const g=xi(_[_.length-1].y,(0===m.length?f[0]:m[0]).y,d);let y;return y=c?[new r(0,g),new r(0,0),new r(1,0),new r(1,g)]:[new r(1,g),new r(1,1),new r(0,1),new r(0,g)],_.push(...y),0===m.length?_.push(f[0]):_.push(...m),{polygon:_.map((e=>new MercatorCoordinate(e.x,e.y))),unwrapped:!1}}(e,t);if(i)return i;const n=function(e,t){let i=!1,r=-1/0,n=0;for(let t=0;t<e.length-1;t++)e[t].x>r&&(r=e[t].x,n=t);for(let t=0;t<e.length-1;t++){const r=(n+t)%(e.length-1),o=e[r],a=e[r+1];Math.abs(o.x-a.x)>.5&&(o.x<a.x?(o.x+=1,0===r&&(e[e.length-1].x+=1)):(a.x+=1,r+1===e.length-1&&(e[0].x+=1)),i=!0)}const o=Io(t.center.lng);return i&&o<Math.abs(o-1)&&e.forEach((e=>{e.x-=1})),{polygon:e,unwrapped:i}}(fh(e,t).map((e=>new r(mh(e.x),e.y))),t);return{polygon:n.polygon.map((e=>new MercatorCoordinate(e.x,e.y))),unwrapped:n.unwrapped}}}function fh(e,t){return Fo(e,(e=>{const i=t.pointCoordinate3D(e);e.x=i.x,e.y=i.y}),1/256)}function mh(e){return e<0?1+e%1:e%1}function _h(e){return 100*e|0}function gh(e,t,i,r,n){const o=function(i,r){if(i)return n(i);if(r){const i=w(b(r,e),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);r.vector_layers&&(i.vectorLayers=r.vector_layers,i.vectorLayerIds=i.vectorLayers.map((e=>e.id))),r.language_options&&(i.languageOptions=r.language_options),r.language&&r.language[r.id]&&(i.language=r.language[r.id]),r.worldview_options&&(i.worldviewOptions=r.worldview_options),r.worldview?i.worldview=r.worldview[r.id]:r.worldview_default&&(i.worldview=r.worldview_default),i.tiles=t.canonicalizeTileset(i,e.url),n(null,i)}};return e.url?Ye(t.transformRequest(t.normalizeSourceURL(e.url,null,i,r),Xe.Source),o):ee.frame((()=>o(null,e)))}class TileBounds{constructor(e,t,i){this.bounds=LngLatBounds.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=i||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const t=Math.pow(2,e.z),i=Math.floor(Io(this.bounds.getWest())*t),r=Math.floor(Mo(this.bounds.getNorth())*t),n=Math.ceil(Io(this.bounds.getEast())*t),o=Math.ceil(Mo(this.bounds.getSouth())*t);return e.x>=i&&e.x<n&&e.y>=r&&e.y<o}}class DictionaryCoder{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t<e.length;t++){const i=e[t];this._stringToNumber[i]=t,this._numberToString[t]=i}}encode(e){return this._stringToNumber[e]}decode(e){return this._numberToString[e]}}const yh=["tile","layer","source","sourceLayer","state"];class Feature{constructor(e,t,i,r,n){this.type="Feature",this._vectorTileFeature=e,this._z=t,this._x=i,this._y=r,this.properties=e.properties,this.id=n}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={type:"Feature",geometry:this.geometry,properties:this.properties};void 0!==this.id&&(e.id=this.id);for(const t of yh)void 0!==this[t]&&(e[t]=this[t]);return e}}const xh=32,vh=33,bh=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,i=0,r=0,n=0,o=0,a=0,s=0;for(1&t?n=o=a=xh:i=r=s=xh;(t>>=1)>1;){const e=i+n>>1,l=r+o>>1;1&t?(n=i,o=r,i=a,r=s):(i=n,r=o,n=a,o=s),a=e,s=l}const l=4*e;bh[l+0]=i,bh[l+1]=r,bh[l+2]=n,bh[l+3]=o}const wh=new Uint16Array(2178),Th=new Uint8Array(1089),Eh=new Uint16Array(1089);function Sh(e){return 0===e?-.03125:32===e?.03125:0}var Ah=eo([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const Ch={type:2,extent:Eo,loadGeometry:()=>[[new r(0,0),new r(8193,0),new r(8193,8193),new r(0,8193),new r(0,0)]]};class Tile{constructor(e,t,i,r,n){this.tileID=e,this.uid=E(),this.uses=0,this.tileSize=t,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=n,this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection)}registerFadeDuration(e){const t=e+this.timeAdded;t<ee.now()||this.fadeEndTime&&t<this.fadeEndTime||(this.fadeEndTime=t)}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}get tileTransform(){return this._tileTransform||(this._tileTransform=Iu(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(e,t,i){if(this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(e,t){const i={};if(!t)return i;for(const r of e){const e=r.layerIds.map((e=>t.getLayer(e))).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(const t of e)i[t.id]=r}}return i}(e.buckets,t.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const t=this.buckets[e];if(t instanceof SymbolBucket){if(this.hasSymbolBuckets=!0,!i)break;t.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const t=this.buckets[e];if(t instanceof SymbolBucket&&t.hasRTLText){this.hasRTLText=!0,Jn.isLoading()||Jn.isLoaded()||"deferred"!==Xn()||Kn();break}}this.queryPadding=0;for(const e in this.buckets){const i=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,t.style.getLayer(e).queryRadius(i))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas)}else this.collisionBoxArray=new CollisionBoxArray}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].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._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const i=this.buckets[t];i.uploadPending()&&i.upload(e)}const t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Texture(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Texture(e,this.glyphAtlasImage,t.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Texture(e,this.lineAtlas.image,t.ALPHA),this.lineAtlas.uploaded=!0)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,i,r,n,o,a,s){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:r,pixelPosMatrix:a,transform:o,params:n,tileTransform:this.tileTransform},e,t,i):{}}querySourceFeatures(e,t){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const r=i.loadVTLayers(),n=t?t.sourceLayer:"",o=r._geojsonTileLayer||r[n];if(!o)return;const a=Rr(t&&t.filter),{z:s,x:l,y:c}=this.tileID.canonical,u={z:s,x:l,y:c};for(let t=0;t<o.length;t++){const r=o.feature(t);if(a.needGeometry){const e=Zo(r,!0);if(!a.filter(new EvaluationParameters(this.tileID.overscaledZ),e,this.tileID.canonical))continue}else if(!a.filter(new EvaluationParameters(this.tileID.overscaledZ),r))continue;const h=i.getId(r,n),p=new Feature(r,s,l,c,h);p.tile=u,e.push(p)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return!!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){const t=this.expirationTime;if(e.cacheControl){const t=V(e.cacheControl);t["max-age"]&&(this.expirationTime=Date.now()+1e3*t["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){const e=Date.now();let i=!1;if(this.expirationTime>e)i=!1;else if(t)if(this.expirationTime<t)i=!0;else{const r=this.expirationTime-t;r?this.expirationTime=e+Math.max(r,3e4):i=!0}else i=!0;i?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-(new Date).getTime(),Math.pow(2,31)-1)}setFeatureState(e,t){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||0===Object.keys(e).length||!t)return;const i=this.latestFeatureIndex.loadVTLayers(),r=t.style.listImages();for(const n in this.buckets){if(!t.style.hasLayer(n))continue;const o=this.buckets[n],a=o.layers[0].sourceLayer||"_geojsonTileLayer",s=i[a],l=e[a];if(!s||!l||0===Object.keys(l).length)continue;if(o.update(l,s,r,this.imageAtlas&&this.imageAtlas.patternPositions||{}),o instanceof LineBucket||o instanceof FillBucket){const e=t.style._getSourceCache(o.layers[0].source);t._terrain&&t._terrain.enabled&&e&&o.programConfigurations.needsUpload&&t._terrain._clearRenderCacheForTile(e.id,this.tileID)}const c=t&&t.style&&t.style.getLayer(n);c&&(this.queryPadding=Math.max(this.queryPadding,c.queryRadius(o)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<ee.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(e){this.symbolFadeHoldUntil=ee.now()+e}setTexture(e,t){const i=t.context,r=i.gl;this.texture=t.getTileTexture(e.width),this.texture?this.texture.update(e,{useMipmap:!0}):(this.texture=new Texture(i,e,r.RGBA,{useMipmap:!0}),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),i.extTextureFilterAnisotropic&&r.texParameterf(r.TEXTURE_2D,i.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,i.extTextureFilterAnisotropicMax))}setDependencies(e,t){const i={};for(const e of t)i[e]=!0;this.dependencies[e]=i}hasDependency(e,t){for(const i of e){const e=this.dependencies[i];if(e)for(const i of t)if(e[i])return!0}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(e,t){if(!t||"mercator"===t.name||this._tileDebugBuffer)return;const i=Go(Ch,this.tileID.canonical,this.tileTransform)[0],r=new StructArrayLayout2i4,n=new StructArrayLayout1ui2;for(let e=0;e<i.length;e++){const{x:t,y:o}=i[e];r.emplaceBack(t,o),n.emplaceBack(e)}n.emplaceBack(0),this._tileDebugIndexBuffer=e.createIndexBuffer(n),this._tileDebugBuffer=e.createVertexBuffer(r,$c.members),this._tileDebugSegments=SegmentVector.simpleSegment(0,0,r.length,n.length)}_makeTileBoundsBuffers(e,t){if(this._tileBoundsBuffer||!t||"mercator"===t.name)return;const i=Go(Ch,this.tileID.canonical,this.tileTransform)[0];let r,n;if(this.isRaster){const e=function(e,t){const i=Iu(e,t),r=Math.pow(2,e.z);for(let n=0;n<vh;n++)for(let o=0;o<vh;o++){const a=Do((e.x+(o+Sh(o))/xh)/r),s=zo((e.y+(n+Sh(n))/xh)/r),l=t.project(a,s),c=n*vh+o;wh[2*c+0]=Math.round((l.x*i.scale-i.x)*Eo),wh[2*c+1]=Math.round((l.y*i.scale-i.y)*Eo)}Th.fill(0),Eh.fill(0);for(let e=2045;e>=0;e--){const t=4*e,i=bh[t+0],r=bh[t+1],n=bh[t+2],o=bh[t+3],a=i+n>>1,s=r+o>>1,l=a+s-r,c=s+i-a,u=r*vh+i,h=o*vh+n,p=s*vh+a,d=Math.hypot((wh[2*u+0]+wh[2*h+0])/2-wh[2*p+0],(wh[2*u+1]+wh[2*h+1])/2-wh[2*p+1])>=16;if(Th[p]=Th[p]||(d?1:0),e<1022){const e=(r+c>>1)*vh+(i+l>>1),t=(o+c>>1)*vh+(n+l>>1);Th[p]=Th[p]||Th[e]||Th[t]}}const n=new StructArrayLayout4i8,o=new StructArrayLayout3ui6;let a=0;function s(e,t){const i=t*vh+e;return 0===Eh[i]&&(n.emplaceBack(wh[2*i+0],wh[2*i+1],e*Eo/xh,t*Eo/xh),Eh[i]=++a),Eh[i]-1}function l(e,t,i,r,n,a){const c=e+i>>1,u=t+r>>1;if(Math.abs(e-n)+Math.abs(t-a)>1&&Th[u*vh+c])l(n,a,e,t,c,u),l(i,r,n,a,c,u);else{const l=s(e,t),c=s(i,r),u=s(n,a);o.emplaceBack(l,c,u)}}return l(0,0,xh,xh,xh,0),l(xh,xh,0,0,0,xh),{vertices:n,indices:o}}(this.tileID.canonical,t);r=e.vertices,n=e.indices}else{r=new StructArrayLayout4i8,n=new StructArrayLayout3ui6;for(const{x:e,y:t}of i)r.emplaceBack(e,t,0,0);const e=bs(r.int16,void 0,4);for(let t=0;t<e.length;t+=3)n.emplaceBack(e[t],e[t+1],e[t+2])}this._tileBoundsBuffer=e.createVertexBuffer(r,Ah.members),this._tileBoundsIndexBuffer=e.createIndexBuffer(n),this._tileBoundsSegments=SegmentVector.simpleSegment(0,0,r.length,n.length)}_makeGlobeTileDebugBuffers(e,t){const i=t.projection;if(!i||"globe"!==i.name||t.freezeTileCoverage)return;const r=this.tileID.canonical,n=pu(iu(r,t)),o=_u(t.zoom);let a;o>0&&(a=xa(new Float64Array(16),t.globeMatrix));const s=(r.x+.5)/(1<<r.z)-Io(t.center.lng);let l=0;s>.5?l=-1:s<-.5&&(l=1),this._makeGlobeTileDebugBorderBuffer(e,r,t,n,a,o,l),this._makeGlobeTileDebugTextBuffer(e,r,t,n,a,o,l)}_globePoint(e,t,i,r,n,o,a,s){let l=cu(e,t,i);if(o){const n=1<<i.z,c=[((e/Eo+i.x)/n+s)*r,(t/Eo+i.y)/n*r,0];Wa(c,c,o),l=vi(l,c,a)}return Wa(l,l,n)}_makeGlobeTileDebugBorderBuffer(e,t,i,r,n,o,a){const s=new StructArrayLayout2i4,l=new StructArrayLayout1ui2,c=new StructArrayLayout3i6,u=(e,u,h,p,d)=>{const f=(h-e)/(d-1),m=(p-u)/(d-1),_=s.length;for(let h=0;h<d;h++){const p=e+h*f,d=u+h*m;s.emplaceBack(p,d);const g=this._globePoint(p,d,t,i.worldSize,r,n,o,a);c.emplaceBack(g[0],g[1],g[2]),l.emplaceBack(_+h)}},h=Eo;u(0,0,h,0,16),u(h,0,h,h,16),u(h,h,0,h,16),u(0,h,0,0,16),this._tileDebugIndexBuffer=e.createIndexBuffer(l),this._tileDebugBuffer=e.createVertexBuffer(s,$c.members),this._globeTileDebugBorderBuffer=e.createVertexBuffer(c,qc.members),this._tileDebugSegments=SegmentVector.simpleSegment(0,0,s.length,l.length)}_makeGlobeTileDebugTextBuffer(e,t,i,r,n,o,a){const s=new StructArrayLayout2i4,l=new StructArrayLayout3ui6,c=new StructArrayLayout3i6,u=25;l.reserve(32),s.reserve(u),c.reserve(u);const h=(e,t)=>u*e+t;for(let e=0;e<u;e++){const l=2048*e;for(let e=0;e<u;e++){const u=2048*e;s.emplaceBack(u,l);const h=this._globePoint(u,l,t,i.worldSize,r,n,o,a);c.emplaceBack(h[0],h[1],h[2])}}for(let e=0;e<4;e++)for(let t=0;t<4;t++){const i=h(e,t),r=h(e,t+1),n=h(e+1,t),o=h(e+1,t+1);l.emplaceBack(i,r,n),l.emplaceBack(n,r,o)}this._tileDebugTextIndexBuffer=e.createIndexBuffer(l),this._tileDebugTextBuffer=e.createVertexBuffer(s,$c.members),this._globeTileDebugTextBuffer=e.createVertexBuffer(c,qc.members),this._tileDebugTextSegments=SegmentVector.simpleSegment(0,0,u,32)}}class SourceFeatureState{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,t,i){const r=String(t);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][r]=this.stateChanges[e][r]||{},b(this.stateChanges[e][r],i),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==r&&(this.deletedStates[e][t]=null)}else if(this.deletedStates[e]&&null===this.deletedStates[e][r]){this.deletedStates[e][r]={};for(const t in this.state[e][r])i[t]||(this.deletedStates[e][r][t]=null)}else for(const t in i)this.deletedStates[e]&&this.deletedStates[e][r]&&null===this.deletedStates[e][r][t]&&delete this.deletedStates[e][r][t]}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const r=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][r]&&(this.deletedStates[e][r]=this.deletedStates[e][r]||{},this.deletedStates[e][r][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][r])for(i in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][i]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null}getState(e,t){const i=String(t),r=b({},(this.state[e]||{})[i],(this.stateChanges[e]||{})[i]);if(null===this.deletedStates[e])return{};if(this.deletedStates[e]){const i=this.deletedStates[e][t];if(null===i)return{};for(const e in i)delete r[e]}return r}initializeTileState(e,t){e.setFeatureState(this.state,t)}coalesceChanges(e,t){const i={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const t={};for(const i in this.stateChanges[e])this.state[e][i]||(this.state[e][i]={}),b(this.state[e][i],this.stateChanges[e][i]),t[i]=this.state[e][i];i[e]=t}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const t={};if(null===this.deletedStates[e])for(const i in this.state[e])t[i]={},this.state[e][i]={};else for(const i in this.deletedStates[e]){if(null===this.deletedStates[e][i])this.state[e][i]={};else for(const t of Object.keys(this.deletedStates[e][i]))delete this.state[e][i][t];t[i]=this.state[e][i]}i[e]=i[e]||{},b(i[e],t)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const r in e)e[r].setFeatureState(i,t)}}class MipLevel{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(e,t){const i=this.toIdx(e,t);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(e,t){return this.leaves[this.toIdx(e,t)]}toIdx(e,t){return t*this.size+e}}function Ih(e,t,i,r){let n=0,o=Number.MAX_VALUE;for(let a=0;a<3;a++)if(Math.abs(r[a])<1e-15){if(i[a]<e[a]||i[a]>t[a])return null}else{const s=1/r[a];let l=(e[a]-i[a])*s,c=(t[a]-i[a])*s;if(l>c){const e=l;l=c,c=e}if(l>n&&(n=l),c<o&&(o=c),n>o)return null}return n}function Mh(e,t,i,r,n,o,a,s,l,c,u){const h=r-e,p=n-t,d=o-i,f=a-e,m=s-t,_=l-i,g=u[1]*_-u[2]*m,y=u[2]*f-u[0]*_,x=u[0]*m-u[1]*f,v=h*g+p*y+d*x;if(Math.abs(v)<1e-15)return null;const b=1/v,w=c[0]-e,T=c[1]-t,E=c[2]-i,S=(w*g+T*y+E*x)*b;if(S<0||S>1)return null;const A=T*d-E*p,C=E*h-w*d,I=w*p-T*h,M=(u[0]*A+u[1]*C+u[2]*I)*b;return M<0||S+M>1?null:(f*A+m*C+_*I)*b}function Ph(e,t,i){return(e-t)/(i-t)}function Dh(e,t,i,r,n,o,a,s,l){const c=1<<i,u=o-r,h=a-n,p=(e+1)/c*u+r,d=(t+0)/c*h+n,f=(t+1)/c*h+n;s[0]=(e+0)/c*u+r,s[1]=d,l[0]=p,l[1]=f}class DemMinMaxQuadTree{constructor(e){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=e,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;const t=function(e){const t=Math.ceil(Math.log2(e.dim/8)),i=[];let r=Math.ceil(Math.pow(2,t));const n=1/r,o=(e,t,i,r,n)=>{const o=r?1:0,a=(e+1)*i-o,s=t*i,l=(t+1)*i-o;n[0]=e*i,n[1]=s,n[2]=a,n[3]=l};let a=new MipLevel(r);const s=[];for(let t=0;t<r*r;t++){o(t%r,Math.floor(t/r),n,!1,s);const i=kh(s[0],s[1],e),l=kh(s[2],s[1],e),c=kh(s[2],s[3],e),u=kh(s[0],s[3],e);a.minimums.push(Math.min(i,l,c,u)),a.maximums.push(Math.max(i,l,c,u)),a.leaves.push(1)}for(i.push(a),r/=2;r>=1;r/=2){const e=i[i.length-1];a=new MipLevel(r);for(let t=0;t<r*r;t++){o(t%r,Math.floor(t/r),2,!0,s);const i=e.getElevation(s[0],s[1]),n=e.getElevation(s[2],s[1]),l=e.getElevation(s[2],s[3]),c=e.getElevation(s[0],s[3]),u=e.isLeaf(s[0],s[1]),h=e.isLeaf(s[2],s[1]),p=e.isLeaf(s[2],s[3]),d=e.isLeaf(s[0],s[3]),f=Math.min(i.min,n.min,l.min,c.min),m=Math.max(i.max,n.max,l.max,c.max),_=u&&h&&p&&d;a.maximums.push(m),a.minimums.push(f),a.leaves.push(m-f<=5&&_?1:0)}i.push(a)}return i}(this.dem),i=t.length-1,r=t[i];this._addNode(r.minimums[0],r.maximums[0],r.leaves[0]),this._construct(t,0,0,i,0)}raycastRoot(e,t,i,r,n,o,a=1){return Ih([e,t,-100],[i,r,this.maximums[0]*a],n,o)}raycast(e,t,i,r,n,o,a=1){if(!this.nodeCount)return null;const s=this.raycastRoot(e,t,i,r,n,o,a);if(null==s)return null;const l=[],c=[],u=[],h=[],p=[{idx:0,t:s,nodex:0,nodey:0,depth:0}];for(;p.length>0;){const{idx:s,t:d,nodex:f,nodey:m,depth:_}=p.pop();if(this.leaves[s]){Dh(f,m,_,e,t,i,r,u,h);const s=1<<_,l=(f+0)/s,c=(f+1)/s,p=(m+0)/s,g=(m+1)/s,y=kh(l,p,this.dem)*a,x=kh(c,p,this.dem)*a,v=kh(c,g,this.dem)*a,b=kh(l,g,this.dem)*a,w=Mh(u[0],u[1],y,h[0],u[1],x,h[0],h[1],v,n,o),T=Mh(h[0],h[1],v,u[0],h[1],b,u[0],u[1],y,n,o),E=Math.min(null!==w?w:Number.MAX_VALUE,null!==T?T:Number.MAX_VALUE);if(E!==Number.MAX_VALUE)return E;{const e=Na([],n,o,d);if(zh(y,x,b,v,Ph(e[0],u[0],h[0]),Ph(e[1],u[1],h[1]))>=e[2])return d}continue}let g=0;for(let p=0;p<this._siblingOffset.length;p++){Dh((f<<1)+this._siblingOffset[p][0],(m<<1)+this._siblingOffset[p][1],_+1,e,t,i,r,u,h),u[2]=-100,h[2]=this.maximums[this.childOffsets[s]+p]*a;const d=Ih(u,h,n,o);if(null!=d){const e=d;l[p]=e;let t=!1;for(let i=0;i<g&&!t;i++)e>=l[c[i]]&&(c.splice(i,0,p),t=!0);t||(c[g]=p),g++}}for(let e=0;e<g;e++){const t=c[e];p.push({idx:this.childOffsets[s]+t,t:l[t],nodex:(f<<1)+this._siblingOffset[t][0],nodey:(m<<1)+this._siblingOffset[t][1],depth:_+1})}}return null}_addNode(e,t,i){return this.minimums.push(e),this.maximums.push(t),this.leaves.push(i),this.childOffsets.push(0),this.nodeCount++}_construct(e,t,i,r,n){if(1===e[r].isLeaf(t,i))return;this.childOffsets[n]||(this.childOffsets[n]=this.nodeCount);const o=r-1,a=e[o];let s=0,l=0;for(let e=0;e<this._siblingOffset.length;e++){const r=2*t+this._siblingOffset[e][0],n=2*i+this._siblingOffset[e][1],o=a.getElevation(r,n),c=a.isLeaf(r,n),u=this._addNode(o.min,o.max,c);c&&(s|=1<<e),l||(l=u)}for(let r=0;r<this._siblingOffset.length;r++)s&1<<r||this._construct(e,2*t+this._siblingOffset[r][0],2*i+this._siblingOffset[r][1],o,l+r)}}function zh(e,t,i,r,n,o){return xi(xi(e,i,o),xi(t,r,o),n)}function kh(e,t,i){const r=i.dim,n=_(e*r-.5,0,r-1),o=_(t*r-.5,0,r-1),a=Math.floor(n),s=Math.floor(o),l=Math.min(a+1,r-1),c=Math.min(s+1,r-1);return zh(i.get(a,s),i.get(l,s),i.get(a,c),i.get(l,c),n-a,o-s)}const Lh={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};class DEMData{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,t,i,r=!1,n=!1){if(this.uid=e,t.height!==t.width)throw new RangeError("DEM tiles must be square");if(i&&"mapbox"!==i&&"terrarium"!==i)return B(`"${i}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=t.height;const o=this.dim=t.height-2,a=new Uint32Array(t.data.buffer);if(this.pixels=new Uint8Array(t.data.buffer),this.encoding=i||"mapbox",this.borderReady=r,!r){for(let e=0;e<o;e++)a[this._idx(-1,e)]=a[this._idx(0,e)],a[this._idx(o,e)]=a[this._idx(o-1,e)],a[this._idx(e,-1)]=a[this._idx(e,0)],a[this._idx(e,o)]=a[this._idx(e,o-1)];a[this._idx(-1,-1)]=a[this._idx(0,0)],a[this._idx(o,-1)]=a[this._idx(o-1,0)],a[this._idx(-1,o)]=a[this._idx(0,o-1)],a[this._idx(o,o)]=a[this._idx(o-1,o-1)],n&&this._buildQuadTree()}}_buildQuadTree(){this._tree=new DemMinMaxQuadTree(this)}get(e,t,i=!1){i&&(e=_(e,-1,this.dim),t=_(t,-1,this.dim));const r=4*this._idx(e,t);return("terrarium"===this.encoding?this._unpackTerrarium:this._unpackMapbox)(this.pixels[r],this.pixels[r+1],this.pixels[r+2])}static getUnpackVector(e){return Lh[e]}get unpackVector(){return Lh[this.encoding]}_idx(e,t){if(e<-1||e>=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(t+1)*this.stride+(e+1)}_unpackMapbox(e,t,i){return(256*e*256+256*t+i)/10-1e4}_unpackTerrarium(e,t,i){return 256*e+t+i/256-32768}static pack(e,t){const i=[0,0,0,0],r=DEMData.getUnpackVector(t);let n=Math.floor((e+r[3])/r[2]);return i[2]=n%256,n=Math.floor(n/256),i[1]=n%256,n=Math.floor(n/256),i[0]=n,i}getPixels(){return new RGBAImage({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let r=t*this.dim,n=t*this.dim+this.dim,o=i*this.dim,a=i*this.dim+this.dim;switch(t){case-1:r=n-1;break;case 1:n=r+1}switch(i){case-1:o=a-1;break;case 1:a=o+1}const s=-t*this.dim,l=-i*this.dim;for(let t=o;t<a;t++)for(let i=r;i<n;i++){const r=4*this._idx(i,t),n=4*this._idx(i+s,t+l);this.pixels[r+0]=e.pixels[n+0],this.pixels[r+1]=e.pixels[n+1],this.pixels[r+2]=e.pixels[n+2],this.pixels[r+3]=e.pixels[n+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}En(DEMData,"DEMData"),En(DemMinMaxQuadTree,"DemMinMaxQuadTree",{omit:["dem"]});class TileCache{constructor(e,t){this.max=e,this.onRemove=t,this.reset()}reset(){for(const e in this.data)for(const t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,i){const r=e.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);const n={value:t,timeout:void 0};if(void 0!==i&&(n.timeout=setTimeout((()=>{this.remove(e,n)}),i)),this.data[r].push(n),this.order.push(r),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const i=e.wrapped().key,r=void 0===t?0:this.data[i].indexOf(t),n=this.data[i][r];return this.data[i].splice(r,1),n.timeout&&clearTimeout(n.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(n.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){const t=[];for(const i in this.data)for(const r of this.data[i])e(r.value)||t.push(r);for(const e of t)this.remove(e.value.tileID,e)}}class IndexBuffer{constructor(e,t,i){this.context=e;const r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||t.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Bh={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class VertexBuffer{constructor(e,t,i,r){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.context=e;const n=e.gl;this.buffer=n.createBuffer(),e.bindVertexBuffer.set(this.buffer),n.bufferData(n.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||t.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let i=0;i<this.attributes.length;i++){const r=t.attributes[this.attributes[i].name];void 0!==r&&e.enableVertexAttribArray(r)}}setVertexAttribPointers(e,t,i){for(let r=0;r<this.attributes.length;r++){const n=this.attributes[r],o=t.attributes[n.name];void 0!==o&&e.vertexAttribPointer(o,n.components,e[Bh[n.type]],!1,this.itemSize,n.offset+this.itemSize*(i||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class BaseValue{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class ClearColor extends BaseValue{getDefault(){return Lt.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class ClearDepth extends BaseValue{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class ClearStencil extends BaseValue{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class ColorMask extends BaseValue{getDefault(){return[!0,!0,!0,!0]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class DepthMask extends BaseValue{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class StencilMask extends BaseValue{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class StencilFunc extends BaseValue{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}}class StencilOp extends BaseValue{getDefault(){const e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}}class StencilTest extends BaseValue{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1}}class DepthRange extends BaseValue{getDefault(){return[0,1]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}}class DepthTest extends BaseValue{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1}}class DepthFunc extends BaseValue{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class Blend extends BaseValue{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1}}class BlendFunc extends BaseValue{getDefault(){const e=this.gl;return[e.ONE,e.ZERO]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.blendFunc(e[0],e[1]),this.current=e,this.dirty=!1)}}class BlendColor extends BaseValue{getDefault(){return Lt.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class BlendEquation extends BaseValue{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}}class CullFace extends BaseValue{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1}}class CullFaceSide extends BaseValue{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class FrontFace extends BaseValue{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}class Program$1 extends BaseValue{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}}class ActiveTextureUnit extends BaseValue{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class Viewport extends BaseValue{getDefault(){const e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class BindFramebuffer extends BaseValue{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class BindRenderbuffer extends BaseValue{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class BindTexture extends BaseValue{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class BindVertexBuffer extends BaseValue{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class BindElementBuffer extends BaseValue{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class BindVertexArrayOES extends BaseValue{constructor(e){super(e),this.vao=e.extVertexArrayObject}getDefault(){return null}set(e){this.vao&&(e!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(e),this.current=e,this.dirty=!1)}}class PixelStoreUnpack extends BaseValue{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class PixelStoreUnpackPremultiplyAlpha extends BaseValue{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class PixelStoreUnpackFlipY extends BaseValue{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class FramebufferAttachment extends BaseValue{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class ColorAttachment extends FramebufferAttachment{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class DepthAttachment extends FramebufferAttachment{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,this.attachment(),t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class DepthStencilAttachment extends DepthAttachment{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class Framebuffer{constructor(e,t,i,r){this.context=e,this.width=t,this.height=i;const n=this.framebuffer=e.gl.createFramebuffer();this.colorAttachment=new ColorAttachment(e,n),r&&(this.depthAttachment=new DepthAttachment(e,n))}destroy(){const e=this.context.gl,t=this.colorAttachment.get();if(t&&e.deleteTexture(t),this.depthAttachment){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t)}e.deleteFramebuffer(this.framebuffer)}}class DepthMode{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}}DepthMode.ReadOnly=!1,DepthMode.ReadWrite=!0,DepthMode.disabled=new DepthMode(519,DepthMode.ReadOnly,[0,1]);const Rh=7680;class StencilMode{constructor(e,t,i,r,n,o){this.test=e,this.ref=t,this.mask=i,this.fail=r,this.depthFail=n,this.pass=o}}StencilMode.disabled=new StencilMode({func:519,mask:0},0,0,Rh,Rh,Rh);class ColorMode{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i}}ColorMode.Replace=[1,0],ColorMode.disabled=new ColorMode(ColorMode.Replace,Lt.transparent,[!1,!1,!1,!1]),ColorMode.unblended=new ColorMode(ColorMode.Replace,Lt.transparent,[!0,!0,!0,!0]),ColorMode.alphaBlended=new ColorMode([1,771],Lt.transparent,[!0,!0,!0,!0]);const Fh=1029,Oh=2305;class CullFaceMode{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}}CullFaceMode.disabled=new CullFaceMode(!1,Fh,Oh),CullFaceMode.backCCW=new CullFaceMode(!0,Fh,Oh),CullFaceMode.backCW=new CullFaceMode(!0,Fh,2304),CullFaceMode.frontCW=new CullFaceMode(!0,1028,2304),CullFaceMode.frontCCW=new CullFaceMode(!0,1028,Oh);class Context{constructor(e){this.gl=e,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),this.clearColor=new ClearColor(this),this.clearDepth=new ClearDepth(this),this.clearStencil=new ClearStencil(this),this.colorMask=new ColorMask(this),this.depthMask=new DepthMask(this),this.stencilMask=new StencilMask(this),this.stencilFunc=new StencilFunc(this),this.stencilOp=new StencilOp(this),this.stencilTest=new StencilTest(this),this.depthRange=new DepthRange(this),this.depthTest=new DepthTest(this),this.depthFunc=new DepthFunc(this),this.blend=new Blend(this),this.blendFunc=new BlendFunc(this),this.blendColor=new BlendColor(this),this.blendEquation=new BlendEquation(this),this.cullFace=new CullFace(this),this.cullFaceSide=new CullFaceSide(this),this.frontFace=new FrontFace(this),this.program=new Program$1(this),this.activeTexture=new ActiveTextureUnit(this),this.viewport=new Viewport(this),this.bindFramebuffer=new BindFramebuffer(this),this.bindRenderbuffer=new BindRenderbuffer(this),this.bindTexture=new BindTexture(this),this.bindVertexBuffer=new BindVertexBuffer(this),this.bindElementBuffer=new BindElementBuffer(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new BindVertexArrayOES(this),this.pixelStoreUnpack=new PixelStoreUnpack(this),this.pixelStoreUnpackPremultiplyAlpha=new PixelStoreUnpackPremultiplyAlpha(this),this.pixelStoreUnpackFlipY=new PixelStoreUnpackFlipY(this),this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureFilterAnisotropicForceOff=!1,this.extStandardDerivativesForceOff=!1,this.extTextureHalfFloat=e.getExtension("OES_texture_half_float"),this.extTextureHalfFloat&&(e.getExtension("OES_texture_half_float_linear"),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float")),this.extStandardDerivatives=e.getExtension("OES_standard_derivatives"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE)}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.extVertexArrayObject&&(this.bindVertexArrayOES.dirty=!0),this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(e,t){return new IndexBuffer(this,e,t)}createVertexBuffer(e,t,i){return new VertexBuffer(this,e,t,i)}createRenderbuffer(e,t,i){const r=this.gl,n=r.createRenderbuffer();return this.bindRenderbuffer.set(n),r.renderbufferStorage(r.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),n}createFramebuffer(e,t,i){return new Framebuffer(this,e,t,i)}clear({color:e,depth:t,stencil:i}){const r=this.gl;let n=0;e&&(n|=r.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),void 0!==t&&(n|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(n|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.clear(n)}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(e){o(e.blendFunction,ColorMode.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor)),this.colorMask.set(e.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}class SourceCache extends Evented{constructor(e,t,i){super(),this.id=e,this._onlySymbols=i,t.on("data",(e=>{"source"===e.dataType&&"metadata"===e.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===e.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),t.on("error",(()=>{this._sourceErrored=!0})),this._source=t,this._tiles={},this._cache=new TileCache(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new SourceFeatureState,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(e){this.map=e,this._minTileCacheSize=void 0===this._minTileCacheSize&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&e?e._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const e in this._tiles){const t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(e,t){return e.isSymbolTile=this._onlySymbols,this._source.loadTile(e,t)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e,(()=>{}))}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e,(()=>{}))}serialize(){return this._source.serialize()}prepare(e){if(this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._source.prepareTile)for(const t in this._tiles){const i=this._tiles[t];this._source.prepareTile(i)&&this.map.painter.terrain&&this.map.painter.terrain._clearRenderCacheForTile(this.id,i.tileID),i.upload(e),i.prepare(this.map.style.imageManager)}else for(const t in this._tiles){const i=this._tiles[t];i.upload(e),i.prepare(this.map.style.imageManager)}}getIds(){return v(this._tiles).map((e=>e.tileID)).sort(Vh).map((e=>e.key))}getRenderableIds(e){const t=[];for(const i in this._tiles)this._isIdRenderable(+i,e)&&t.push(this._tiles[i]);return e?t.sort(((e,t)=>{const i=e.tileID,n=t.tileID,o=new r(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),a=new r(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||a.y-o.y||a.x-o.x})).map((e=>e.tileID.key)):t.map((e=>e.tileID)).sort(Vh).map((e=>e.key))}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return!!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const e in this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading")}}_reloadTile(e,t){const i=this._tiles[e];i&&("loading"!==i.state&&(i.state=t),this._loadTile(i,this._tileLoaded.bind(this,i,e,t)))}_tileLoaded(e,t,i,r){if(r)if(e.state="errored",404!==r.status)this._source.fire(new ErrorEvent(r,{tile:e}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id)}else this.update(this.transform);else e.timeAdded=ee.now(),"expired"===i&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(t,e),"raster-dem"===this._source.type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),this._source.fire(new Event("data",{dataType:"source",tile:e,coord:e.tileID,sourceCacheId:this.id}))}_backfillDEM(e){const t=this.getRenderableIds();for(let r=0;r<t.length;r++){const n=t[r];if(e.neighboringTiles&&e.neighboringTiles[n]){const t=this.getTileByID(n);i(e,t),i(t,e)}}function i(e,t){if(!e.dem||e.dem.borderReady)return;e.needsHillshadePrepare=!0,e.needsDEMTextureUpload=!0;let i=t.tileID.canonical.x-e.tileID.canonical.x;const r=t.tileID.canonical.y-e.tileID.canonical.y,n=Math.pow(2,e.tileID.canonical.z),o=t.tileID.key;0===i&&0===r||Math.abs(r)>1||(Math.abs(i)>1&&(1===Math.abs(i+n)?i+=n:1===Math.abs(i-n)&&(i-=n)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,r),e.neighboringTiles&&e.neighboringTiles[o]&&(e.neighboringTiles[o].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,r){for(const n in this._tiles){let o=this._tiles[n];if(r[n]||!o.hasData()||o.tileID.overscaledZ<=t||o.tileID.overscaledZ>i)continue;let a=o.tileID;for(;o&&o.tileID.overscaledZ>t+1;){const e=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[e.key],o&&o.hasData()&&(a=e)}let s=a;for(;s.overscaledZ>t;)if(s=s.scaledTo(s.overscaledZ-1),e[s.key]){r[a.key]=a;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=t?i:null}for(let i=e.overscaledZ-1;i>=t;i--){const t=e.scaledTo(i),r=this._getLoadedTile(t);if(r)return r}}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,t){t=t||this._source.tileSize;const i=Math.ceil(e.width/t)+1,r=Math.ceil(e.height/t)+1,n=Math.floor(i*r*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,n):n,a="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(a)}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(+e,this._tiles[e])}}update(e,t,i){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;this.updateCacheSize(e,t),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new OverscaledTileID(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(r=e.coveringTiles({tileSize:t||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(r=r.filter((e=>this._source.hasTile(e))))):r=[];const n=this._updateRetainedTiles(r);if(Uh(this._source.type)&&0!==r.length){const e={},t={},i=Object.keys(n);for(const r of i){const i=n[r],o=this._tiles[r];if(!o||o.fadeEndTime&&o.fadeEndTime<=ee.now())continue;const a=this.findLoadedParent(i,Math.max(i.overscaledZ-SourceCache.maxOverzooming,this._source.minzoom));a&&(this._addTile(a.tileID),e[a.tileID.key]=a.tileID),t[r]=i}const o=r[r.length-1].overscaledZ;for(const e in this._tiles){const i=this._tiles[e];if(n[e]||!i.hasData())continue;let r=i.tileID;for(;r.overscaledZ>o;){r=r.scaledTo(r.overscaledZ-1);const o=this._tiles[r.key];if(o&&o.hasData()&&t[r.key]){n[e]=i.tileID;break}}}for(const t in e)n[t]||(this._coveredTiles[t]=!0,n[t]=e[t])}for(const e in n)this._tiles[e].clearFadeHold();const o=function(e,t){const i=[];for(const r in e)r in t||i.push(r);return i}(this._tiles,n);for(const e of o){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}_updateRetainedTiles(e){const t={};if(0===e.length)return t;const i={},r=e.reduce(((e,t)=>Math.min(e,t.overscaledZ)),1/0),n=e[0].overscaledZ,o=Math.max(n-SourceCache.maxOverzooming,this._source.minzoom),a=Math.max(n+SourceCache.maxUnderzooming,this._source.minzoom),s={};for(const i of e){const e=this._addTile(i);t[i.key]=i,e.hasData()||r<this._source.maxzoom&&(s[i.key]=i)}this._retainLoadedChildren(s,r,a,t);for(const r of e){let e=this._tiles[r.key];if(e.hasData())continue;if(r.canonical.z>=this._source.maxzoom){const e=r.children(this._source.maxzoom)[0],i=this.getTile(e);if(i&&i.hasData()){t[e.key]=e;continue}}else{const e=r.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let n=e.wasRequested();for(let a=r.overscaledZ-1;a>=o;--a){const o=r.scaledTo(a);if(i[o.key])break;if(i[o.key]=!0,e=this.getTile(o),!e&&n&&(e=this._addTile(o)),e&&(t[o.key]=o,n=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,r=this._tiles[e].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}t.push(r.key);const e=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;r=e}for(const e of t)this._loadedParentTiles[e]=i}}_addTile(e){let t=this._tiles[e.key];if(t)return this._source.prepareTile&&this._source.prepareTile(t),t;t=this._cache.getAndRemove(e),t&&(this._setTileReloadTimer(e.key,t),t.tileID=e,this._state.initializeTileState(t,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,t)));const i=Boolean(t);if(!i){const i=this.map?this.map.painter:null;t=new Tile(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,i,this._isRaster),this._source.prepareTile&&this._source.prepareTile(t)||this._loadTile(t,this._tileLoaded.bind(this,t,e.key,t.state))}return t?(t.uses++,this._tiles[e.key]=t,i||this._source.fire(new Event("dataloading",{tile:t,coord:t.tileID,dataType:"source"})),t):null}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e]}),i))}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(e,t,i){const r=[],n=this.transform;if(!n)return r;const o="globe"===n.projection.name,a=Io(n.center.lng);for(const s in this._tiles){const l=this._tiles[s];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const e=l.tileID.canonical;if(0===e.z){const t=[Math.abs(_(a,...jh(e,-1))-a),Math.abs(_(a,...jh(e,1))-a)];c=[0,2*t.indexOf(Math.min(...t))-1]}else{const t=[Math.abs(_(a,...jh(e,-1))-a),Math.abs(_(a,...jh(e,0))-a),Math.abs(_(a,...jh(e,1))-a)];c=[t.indexOf(Math.min(...t))-1]}}else c=[0];for(const i of c){const o=e.containsTile(l,n,t,i);o&&r.push(o)}}return r}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map((e=>this._tiles[e].tileID));for(const e of t)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped());return t}hasTransition(){if(this._source.hasTransition())return!0;if(Uh(this._source.type))for(const e in this._tiles){const t=this._tiles[e];if(void 0!==t.fadeEndTime&&t.fadeEndTime>=ee.now())return!0}return!1}setFeatureState(e,t,i){this._state.updateState(e=e||"_geojsonTileLayer",t,i)}removeFeatureState(e,t,i){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,i)}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,i){const r=this._tiles[e];r&&r.setDependencies(t,i)}reloadTilesForDependencies(e,t){for(const i in this._tiles)this._tiles[i].hasDependency(e,t)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(e,t)))}_preloadTiles(e,t){const i=new Map,r=Array.isArray(e)?e:[e],n=this.map.painter.terrain,o=this.usedForTerrain&&n?n.getScaledDemTileSize():this._source.tileSize;for(const e of r){const t=e.coveringTiles({tileSize:o,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 t)i.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1)}x(Array.from(i.values()),((e,t)=>{const i=new Tile(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(e=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),t(e,i)}))}),t)}}function Vh(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function Uh(e){return"raster"===e||"image"===e||"video"===e}function jh(e,t){const i=1<<e.z;return[e.x/i+t,(e.x+1)/i+t]}SourceCache.maxOverzooming=10,SourceCache.maxUnderzooming=3;class DEMSampler{constructor(e,t,i){this._demTile=e,this._dem=this._demTile.dem,this._scale=t,this._offset=i}static create(e,t,i){const r=i||e.findDEMTileFor(t);if(!r||!r.dem)return;const n=r.dem,o=r.tileID,a=1<<t.canonical.z-o.canonical.z;return new DEMSampler(r,r.tileSize/Eo/a,[(t.canonical.x/a-o.canonical.x)*n.dim,(t.canonical.y/a-o.canonical.y)*n.dim])}tileCoordToPixel(e,t){const i=t*this._scale+this._offset[1],n=Math.floor(e*this._scale+this._offset[0]),o=Math.floor(i);return new r(n,o)}getElevationAt(e,t,i,r){const n=e*this._scale+this._offset[0],o=t*this._scale+this._offset[1],a=Math.floor(n),s=Math.floor(o),l=this._dem;return r=!!r,i?xi(xi(l.get(a,s,r),l.get(a,s+1,r),o-s),xi(l.get(a+1,s,r),l.get(a+1,s+1,r),o-s),n-a):l.get(a,s,r)}getElevationAtPixel(e,t,i){return this._dem.get(e,t,!!i)}getMeterToDEM(e){return(1<<this._demTile.tileID.canonical.z)*Po(1,e)*this._dem.stride}}function Nh(e,t,i,r,n){return P(e,((e,o)=>{const a=t instanceof PossiblyEvaluated?t.get(o):null;return a&&a.evaluate?a.evaluate(i,r,n):a}))}function Gh(e,t){return t-e}En(class FeatureIndex{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new bn(Eo,16,0),this.featureIndexArray=new FeatureIndexArray,this.promoteId=t}insert(e,t,i,r,n,o=0){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,n,o);const s=this.grid;for(let e=0;e<t.length;e++){const i=t[e],r=[1/0,1/0,-1/0,-1/0];for(let e=0;e<i.length;e++){const t=i[e];r[0]=Math.min(r[0],t.x),r[1]=Math.min(r[1],t.y),r[2]=Math.max(r[2],t.x),r[3]=Math.max(r[3],t.y)}r[0]<Eo&&r[1]<Eo&&r[2]>=0&&r[3]>=0&&s.insert(a,r[0],r[1],r[2],r[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new gl.VectorTile(new hc(this.rawTileData)).layers,this.sourceLayerCoder=new DictionaryCoder(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,t,i,r){this.loadVTLayers();const n=e.params||{},o=Rr(n.filter),a=e.tileResult,s=e.transform,l=a.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((e,t,i,r)=>ra(a.bufferedTilespaceGeometry,e,t,i,r)));c.sort(Gh);let u=null;s.elevation&&c.length>0&&(u=DEMSampler.create(s.elevation,this.tileID));const h={};let p;for(let s=0;s<c.length;s++){const l=c[s];if(l===p)continue;p=l;const d=this.featureIndexArray.get(l);let f=null;this.loadMatchingFeature(h,d,o,n.layers,n.availableImages,t,i,r,((t,i,r,n=0)=>(f||(f=Go(t,this.tileID.canonical,e.tileTransform)),i.queryIntersectsFeature(a,t,r,f,this.z,e.transform,e.pixelPosMatrix,u,n))))}return h}loadMatchingFeature(e,t,i,r,n,o,a,s,l){const{featureIndex:c,bucketIndex:u,sourceLayerIndex:h,layoutVertexArrayOffset:p}=t,d=this.bucketLayerIDs[u];if(r&&!function(e,t){for(let i=0;i<e.length;i++)if(t.indexOf(e[i])>=0)return!0;return!1}(r,d))return;const f=this.sourceLayerCoder.decode(h),m=this.vtLayers[f].feature(c);if(i.needGeometry){const e=Zo(m,!0);if(!i.filter(new EvaluationParameters(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!i.filter(new EvaluationParameters(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let t=0;t<d.length;t++){const i=d[t];if(r&&r.indexOf(i)<0)continue;const u=o[i];if(!u)continue;let h={};void 0!==_&&s&&(h=s.getState(u.sourceLayer||"_geojsonTileLayer",_));const f=b({},a[i]);f.paint=Nh(f.paint,u.paint,m,h,n),f.layout=Nh(f.layout,u.layout,m,h,n);const g=!l||l(m,u,h,p);if(!g)continue;const y=new Feature(m,this.z,this.x,this.y,_);y.layer=f;let x=e[i];void 0===x&&(x=e[i]=[]),x.push({featureIndex:c,feature:y,intersectionZ:g})}}lookupSymbolFeatures(e,t,i,r,n,o,a,s){const l={};this.loadVTLayers();const c=Rr(n);for(const n of e)this.loadMatchingFeature(l,{bucketIndex:i,sourceLayerIndex:r,featureIndex:n,layoutVertexArrayOffset:0},c,o,a,s,t);return l}loadFeature(e){const{featureIndex:t,sourceLayerIndex:i}=e;this.loadVTLayers();const r=this.sourceLayerCoder.decode(i),n=this.vtFeatures[r];if(n[t])return n[t];const o=this.vtLayers[r].feature(t);return n[t]=o,o}hasLayer(e){for(const t of this.bucketLayerIDs)for(const i of t)if(e===i)return!0;return!1}getId(e,t){let i=e.id;return this.promoteId&&(i=e.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[t]],"boolean"==typeof i&&(i=Number(i))),i}},"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]}),En(class GlyphAtlas{constructor(e){const t={},i=[];for(const r in e){const n=e[r],o=t[r]={};for(const e in n.glyphs){const t=n.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const r=t.metrics.localGlyph?2:1,a={x:0,y:0,w:t.bitmap.width+2*r,h:t.bitmap.height+2*r};i.push(a),o[e]=a}}const{w:r,h:n}=Lc(i),o=new AlphaImage({width:r||1,height:n||1});for(const i in e){const r=e[i];for(const e in r.glyphs){const n=r.glyphs[+e];if(!n||0===n.bitmap.width||0===n.bitmap.height)continue;const a=t[i][e],s=n.metrics.localGlyph?2:1;AlphaImage.copy(n.bitmap,o,{x:0,y:0},{x:a.x+s,y:a.y+s},n.bitmap)}}this.image=o,this.positions=t}},"GlyphAtlas");class DedupedRequest{constructor(e){this.entries={},this.scheduler=e}request(e,t,i,r){const n=this.entries[e]=this.entries[e]||{callbacks:[]};if(n.result){const[e,i]=n.result;return this.scheduler?this.scheduler.add((()=>{r(e,i)}),t):r(e,i),()=>{}}return n.callbacks.push(r),n.cancel||(n.cancel=i(((i,r)=>{n.result=[i,r];for(const e of n.callbacks)this.scheduler?this.scheduler.add((()=>{e(i,r)}),t):e(i,r);setTimeout((()=>delete this.entries[e]),3e3)}))),()=>{n.result||(n.callbacks=n.callbacks.filter((e=>e!==r)),n.callbacks.length||(n.cancel(),delete this.entries[e]))}}}function Zh(e,t,i){const r=JSON.stringify(e.request);return e.data&&(this.deduped.entries[r]={result:[null,e.data]}),this.deduped.request(r,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom},(t=>{const r=Qe(e.request,((e,r,n,o)=>{e?t(e):r&&t(null,{vectorTile:i?void 0:new gl.VectorTile(new hc(r)),rawData:r,cacheControl:n,expires:o})}));return()=>{r.cancel(),t()}}),t)}class RasterTileSource extends Evented{constructor(e,t,i,r){super(),this.id=e,this.dispatcher=i,this.setEventedParent(r),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=b({type:"raster"},t),b(this,w(t,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new Event("dataloading",{dataType:"source"})),this._tileJSONRequest=gh(this._options,this.map._requestManager,null,null,((e,t)=>{this._tileJSONRequest=null,this._loaded=!0,e?this.fire(new ErrorEvent(e)):t&&(b(this,t),t.bounds&&(this.tileBounds=new TileBounds(t.bounds,this.minzoom,this.maxzoom)),De(t.tiles),this.fire(new Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new Event("data",{dataType:"source",sourceDataType:"content"})))}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return b({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,t){const i=ee.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),i,this.tileSize);e.request=at(this.map._requestManager.transformRequest(r,Xe.Tile),((i,r,n,o)=>(delete e.request,e.aborted?(e.state="unloaded",t(null)):i?(e.state="errored",t(i)):r?(this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:n,expires:o}),e.setTexture(r,this.map.painter),e.state="loaded",He(this.dispatcher),void t(null)):t(null))))}static loadTileData(e,t,i){e.setTexture(t,i)}static unloadTileData(e,t){e.texture&&t.saveTileTexture(e.texture)}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t()}unloadTile(e,t){e.texture&&this.map.painter.saveTileTexture(e.texture),t()}hasTransition(){return!1}}let qh;function $h(e,t,i,r,n,o,a,s){const l=[e,i,n,t,r,o,1,1,1],c=[a,s,1],u=ma([],l),[h,p,d]=Ha(c,c,function(e,t){if(e===t){var i=t[1],r=t[2],n=t[5];e[1]=t[3],e[2]=t[6],e[3]=i,e[5]=t[7],e[6]=r,e[7]=n}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e}(u,u));return _a(l,[h,0,0,0,p,0,0,0,d],l)}class ImageSource extends Evented{constructor(e,t,i,r){super(),this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=t}load(t,i){this._loaded=i||!1,this.fire(new Event("dataloading",{dataType:"source"})),this.url=this.options.url,at(this.map._requestManager.transformRequest(this.url,Xe.Image),((i,r)=>{if(this._loaded=!0,i)this.fire(new ErrorEvent(i));else if(r){const{HTMLImageElement:i}=e;this.image=r instanceof i?ee.getImageData(r):r,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading()}}))}loaded(){return this._loaded}updateImage(e){return this.image&&e.url?(this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this.texture&&this.texture.destroy()}setCoordinates(e){this.coordinates=e,this._boundsArray=void 0;const t=e.map(MercatorCoordinate.fromLngLat);return this.tileID=function(e){let t=1/0,i=1/0,r=-1/0,n=-1/0;for(const o of e)t=Math.min(t,o.x),i=Math.min(i,o.y),r=Math.max(r,o.x),n=Math.max(n,o.y);const o=Math.max(r-t,n-i),a=Math.max(0,Math.floor(-Math.log(o)/Math.LN2)),s=Math.pow(2,a);return new CanonicalTileID(a,Math.floor((t+r)/2*s),Math.floor((i+n)/2*s))}(t),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(e){for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture)}if(this._boundsArray)return;const t=Iu(this.tileID,this.map.transform.projection),[i,r,n,o]=this.coordinates.map((e=>{const i=t.projection.project(e[0],e[1]);return Pu(t,i)._round()}));this.perspectiveTransform=function(e,t,i,r,n,o,a,s,l,c){const u=$h(0,0,e,0,0,t,e,t),h=$h(i,r,n,o,a,s,l,c);return _a(h,ma(u,u),h),[h[6]/h[8]*e/Eo,h[7]/h[8]*t/Eo]}(this.width,this.height,i.x,i.y,r.x,r.y,o.x,o.y,n.x,n.y);const a=this._boundsArray=new StructArrayLayout4i8;a.emplaceBack(i.x,i.y,0,0),a.emplaceBack(r.x,r.y,Eo,0),a.emplaceBack(o.x,o.y,0,Eo),a.emplaceBack(n.x,n.y,Eo,Eo),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=e.createVertexBuffer(a,Ah.members),this.boundsSegments=SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,t=e.gl;this.texture?this.texture.update(this.image):(this.texture=new Texture(e,this.image,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE)),this._prepareData(e)}loadTile(e,t){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={},t(null)):(e.state="errored",t(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const Wh={vector:class VectorTileSource extends Evented{constructor(e,t,i,r){if(super(),this.id=e,this.dispatcher=i,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,b(this,w(t,["url","scheme","tileSize","promoteId"])),this._options=b({type:"vector"},t),this._collectResourceTiming=t.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r),this._tileWorkers={},this._deduped=new DedupedRequest}load(e){this._loaded=!1,this.fire(new Event("dataloading",{dataType:"source"}));const t=this.language||this.map._language,i=this.worldview||this.map._worldview;this._tileJSONRequest=gh(this._options,this.map._requestManager,t,i,((r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?(t&&console.warn(`Ensure that your requested language string is a valid BCP-47 code. Found: ${t}`),i&&2!==i.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${i}`),this.fire(new ErrorEvent(r))):n&&(b(this,n),n.bounds&&(this.tileBounds=new TileBounds(n.bounds,this.minzoom,this.maxzoom)),De(n.tiles,this.map._requestManager._customAccessToken),this.fire(new Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new Event("data",{dataType:"source",sourceDataType:"content"}))),e&&e(r)}))}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}setSourceProperty(e){this._tileJSONRequest&&this._tileJSONRequest.cancel(),e(),this.load((()=>{const e=this.map.style._getSourceCaches(this.id);for(const t of e)t.clearTiles()}))}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e})),this}_setLanguage(e){return e===this.language||this.setSourceProperty((()=>{this.language=e})),this}_setWorldview(e){return e===this.worldview?this:this.worldviewOptions&&e&&!this.worldviewOptions[e]?(console.warn(`Vector tile source "${this.id}" does not support worldview "${e}".`),this):(this.setSourceProperty((()=>{this.worldview=e})),this)}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return b({},this._options)}loadTile(e,t){const i=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(i,Xe.Tile),data:void 0,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:ee.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:e.isSymbolTile};if(r.request.collectResourceTiming=this._collectResourceTiming,e.actor&&"expired"!==e.state)"loading"===e.state?e.reloadCallback=t:e.request=e.actor.send("reloadTile",r,n.bind(this));else if(e.actor=this._tileWorkers[i]=this._tileWorkers[i]||this.dispatcher.getActor(),this.dispatcher.ready)e.request=e.actor.send("loadTile",r,n.bind(this),void 0,!0);else{const t=Zh.call({deduped:this._deduped},r,((t,i)=>{t||!i?n.call(this,t):(r.data={cacheControl:i.cacheControl,expires:i.expires,rawData:i.rawData.slice(0)},e.actor&&e.actor.send("loadTile",r,n.bind(this),void 0,!0))}),!0);e.request={cancel:t}}function n(i,r){return delete e.request,e.aborted?t(null):i&&404!==i.status?t(i):(r&&r.resourceTiming&&(e.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&e.setExpiryData(r),e.loadVectorData(r,this.map.painter),He(this.dispatcher),t(null),void(e.reloadCallback&&(this.loadTile(e,e.reloadCallback),e.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id})}unloadTile(e){e.unloadVectorData(),e.actor&&e.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:RasterTileSource,"raster-dem":class RasterDEMTileSource extends RasterTileSource{constructor(e,t,i,r){super(e,t,i,r),this.type="raster-dem",this.maxzoom=22,this._options=b({type:"raster-dem"},t),this.encoding=t.encoding||"mapbox"}loadTile(t,i){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function n(e,r){e&&(t.state="errored",i(e)),r&&(t.dem=r,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state="loaded",i(null))}t.request=at(this.map._requestManager.transformRequest(r,Xe.Tile),function(r,o,a,s){if(delete t.request,t.aborted)t.state="unloaded",i(null);else if(r)t.state="errored",i(r);else if(o){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:a,expires:s});const i=e.ImageBitmap&&o instanceof e.ImageBitmap&&(null==qh&&(qh=e.OffscreenCanvas&&new e.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof e.createImageBitmap),qh),r=1-(o.width-((l=o.width)<=1?1:Math.pow(2,Math.floor(Math.log(l)/Math.LN2))))/2;r<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));const c=i?o:ee.getImageData(o,r),u={uid:t.uid,coord:t.tileID,source:this.id,rawImageData:c,encoding:this.encoding,padding:r};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",u,n.bind(this),void 0,!0))}var l}.bind(this))}_getNeighboringTiles(e){const t=e.canonical,i=Math.pow(2,t.z),r=(t.x-1+i)%i,n=0===t.x?e.wrap-1:e.wrap,o=(t.x+1+i)%i,a=t.x+1===i?e.wrap+1:e.wrap,s={};return s[new OverscaledTileID(e.overscaledZ,n,t.z,r,t.y).key]={backfilled:!1},s[new OverscaledTileID(e.overscaledZ,a,t.z,o,t.y).key]={backfilled:!1},t.y>0&&(s[new OverscaledTileID(e.overscaledZ,n,t.z,r,t.y-1).key]={backfilled:!1},s[new OverscaledTileID(e.overscaledZ,e.wrap,t.z,t.x,t.y-1).key]={backfilled:!1},s[new OverscaledTileID(e.overscaledZ,a,t.z,o,t.y-1).key]={backfilled:!1}),t.y+1<i&&(s[new OverscaledTileID(e.overscaledZ,n,t.z,r,t.y+1).key]={backfilled:!1},s[new OverscaledTileID(e.overscaledZ,e.wrap,t.z,t.x,t.y+1).key]={backfilled:!1},s[new OverscaledTileID(e.overscaledZ,a,t.z,o,t.y+1).key]={backfilled:!1}),s}unloadTile(e){e.demTexture&&this.map.painter.saveTileTexture(e.demTexture),e.fbo&&(e.fbo.destroy(),delete e.fbo),e.dem&&delete e.dem,delete e.neighboringTiles,e.state="unloaded"}},geojson:class GeoJSONSource extends Evented{constructor(e,t,i,r){super(),this.id=e,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=i.getActor(),this.setEventedParent(r),this._data=t.data,this._options=b({},t),this._collectResourceTiming=t.collectResourceTiming,void 0!==t.maxzoom&&(this.maxzoom=t.maxzoom),t.type&&(this.type=t.type),t.attribution&&(this.attribution=t.attribution),this.promoteId=t.promoteId;const n=Eo/this.tileSize;this.workerOptions=b({source:this.id,cluster:t.cluster||!1,geojsonVtOptions:{buffer:(void 0!==t.buffer?t.buffer:128)*n,tolerance:(void 0!==t.tolerance?t.tolerance:.375)*n,extent:Eo,maxZoom:this.maxzoom,lineMetrics:t.lineMetrics||!1,generateId:t.generateId||!1},superclusterOptions:{maxZoom:void 0!==t.clusterMaxZoom?t.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,t.clusterMinPoints||2),extent:Eo,radius:(void 0!==t.clusterRadius?t.clusterRadius:50)*n,log:!1,generateId:t.generateId||!1},clusterProperties:t.clusterProperties,filter:t.filter},t.workerOptions)}onAdd(e){this.map=e,this.setData(this._data)}setData(e){return this._data=e,this._updateWorkerData(),this}getClusterExpansionZoom(e,t){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:e,source:this.id},t),this}getClusterChildren(e,t){return this.actor.send("geojson.getClusterChildren",{clusterId:e,source:this.id},t),this}getClusterLeaves(e,t,i,r){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:e,limit:t,offset:i},r),this}_updateWorkerData(){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new Event("dataloading",{dataType:"source"})),this._loaded=!1;const e=b({},this.workerOptions),t=this._data;"string"==typeof t?(e.request=this.map._requestManager.transformRequest(ee.resolveURL(t),Xe.Source),e.request.collectResourceTiming=this._collectResourceTiming):e.data=JSON.stringify(t),this._pendingLoad=this.actor.send(`${this.type}.loadData`,e,((e,t)=>{if(this._loaded=!0,this._pendingLoad=null,e)this.fire(new ErrorEvent(e));else{const e={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&t&&t.resourceTiming&&t.resourceTiming[this.id]&&(e.resourceTiming=t.resourceTiming[this.id]),this.fire(new Event("data",e)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)}))}loaded(){return this._loaded}loadTile(e,t){const i=e.actor?"reloadTile":"loadTile";e.actor=this.actor,e.request=this.actor.send(i,{type:this.type,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:ee.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},((r,n)=>(delete e.request,e.unloadVectorData(),e.aborted?t(null):r?t(r):(e.loadVectorData(n,this.map.painter,"reloadTile"===i),t(null)))),void 0,"loadTile"===i)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}unloadTile(e){e.unloadVectorData(),this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return b({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class VideoSource extends ImageSource{constructor(e,t,i,r){super(e,t,i,r),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const e of t.urls)this.urls.push(this.map._requestManager.transformRequest(e,Xe.Source).url);!function(t,i){const r=e.document.createElement("video");r.muted=!0,r.onloadstart=function(){i(null,r)};for(let i=0;i<t.length;i++){const n=e.document.createElement("source");it(t[i])||(r.crossOrigin="Anonymous"),n.src=t[i],r.appendChild(n)}}(this.urls,((e,t)=>{this._loaded=!0,e?this.fire(new ErrorEvent(e)):t&&(this.video=t,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(e){if(this.video){const t=this.video.seekable;e<t.start(0)||e>t.end(0)?this.fire(new ErrorEvent(new ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${t.start(0)} and ${t.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,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 e=this.map.painter.context,t=e.gl;this.texture?this.video.paused||(this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,this.video)):(this.texture=new Texture(e,this.video,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(e)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:ImageSource,canvas:class CanvasSource extends ImageSource{constructor(t,i,r,n){super(t,i,r,n),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new ErrorEvent(new ValidationError(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new ErrorEvent(new ValidationError(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new ErrorEvent(new ValidationError(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof e.HTMLCanvasElement||this.fire(new ErrorEvent(new ValidationError(`sources.${t}`,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 ErrorEvent(new ValidationError(`sources.${t}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof e.HTMLCanvasElement?this.options.canvas:e.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new 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(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const t=this.map.painter.context;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new Texture(t,this.canvas,t.gl.RGBA,{premultiply:!0}),this._prepareData(t)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}},custom:class CustomSource extends Evented{constructor(e,t,i,r){super(),this.id=e,this.type="custom",this._dataType="raster",this._dispatcher=i,this._implementation=t,this.setEventedParent(r),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new TileBounds(this._implementation.bounds,this.minzoom,this.maxzoom)),t.update=this._update.bind(this),t.coveringTiles=this._coveringTiles.bind(this),b(this,w(t,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return w(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(e){this._map=e,this._loaded=!1,this.fire(new Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(e),this.load()}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e)}hasTile(e){if(this._implementation.hasTile){const{x:t,y:i,z:r}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:r})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const{x:r,y:n,z:o}=t.tileID.canonical,a=new e.AbortController,s=this._implementation.loadTile({x:r,y:n,z:o},{signal:a.signal});if(!s)return this.loadTileData(t,{width:this.tileSize,height:this.tileSize,data:null}),t.state="loaded",i(null);s.cancel=()=>a.abort(),t.request=s.then(function(r){return delete t.request,t.aborted?(t.state="unloaded",i(null)):r?function(t){return t instanceof e.ImageData||t instanceof e.ImageBitmap||t instanceof e.HTMLCanvasElement}(r)?(this.loadTileData(t,r),t.state="loaded",void i(null)):(t.state="errored",i(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`))):(this.loadTileData(t,{width:this.tileSize,height:this.tileSize,data:null}),t.state="loaded",i(null))}.bind(this)).catch((e=>{20!==e.code&&(t.state="errored",i(e))}))}loadTileData(e,t){RasterTileSource.loadTileData(e,t,this._map.painter)}unloadTileData(e){RasterTileSource.unloadTileData(e,this._map.painter)}prepareTile(e){if(!this._implementation.prepareTile)return null;const{x:t,y:i,z:r}=e.tileID.canonical,n=this._implementation.prepareTile({x:t,y:i,z:r});return n?(this.loadTileData(e,n),e.state="loaded",n):null}unloadTile(e,t){if(this.unloadTileData(e),this._implementation.unloadTile){const{x:t,y:i,z:r}=e.tileID.canonical;this._implementation.unloadTile({x:t,y:i,z:r})}t()}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map((e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z})))}_update(){this.fire(new Event("data",{dataType:"source",sourceDataType:"content"}))}}},Hh=function(e,t,i,r){const n=new Wh[t.type](e,t,i,r);if(n.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${n.id}`);return I(["load","abort","unload","serialize","prepare"],n),n};function Xh(e,t){const i=ya([]);return wa(i,i,[.5*e.width,.5*-e.height,1]),ba(i,i,[1,-1,0]),va(i,i,e.calculateProjMatrix(t.toUnwrapped())),Float32Array.from(i)}function Kh(e,t,i,r,n,o,a,s=!1){const l=e.tilesIn(r,a,s);l.sort(Yh);const c=[];for(const r of l)c.push({wrappedTileID:r.tile.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(t,i,e._state,r,n,o,Xh(e.transform,r.tile.tileID),s)});const u=function(e){const t={},i={};for(const r of e){const e=r.queryResults,n=r.wrappedTileID,o=i[n]=i[n]||{};for(const i in e){const r=e[i],n=o[i]=o[i]||{},a=t[i]=t[i]||[];for(const e of r)n[e.featureIndex]||(n[e.featureIndex]=!0,a.push(e))}}return t}(c);for(const t in u)u[t].forEach((t=>{const i=t.feature,r=i.layer;r&&"background"!==r.type&&"sky"!==r.type&&(i.source=r.source,r["source-layer"]&&(i.sourceLayer=r["source-layer"]),i.state=void 0!==i.id?e.getFeatureState(r["source-layer"],i.id):{})}));return u}function Jh(e,t){const i=e.getRenderableIds().map((t=>e.getTileByID(t))),r=[],n={};for(let e=0;e<i.length;e++){const o=i[e],a=o.tileID.canonical.key;n[a]||(n[a]=!0,o.querySourceFeatures(r,t))}return r}function Yh(e,t){const i=e.tileID,r=t.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function Qh(){return null!=gm.workerClass?new gm.workerClass:new e.Worker(gm.workerUrl)}const ep="mapboxgl_preloaded_worker_pool";class WorkerPool{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length<WorkerPool.workerCount;)this.workers.push(new Qh);return this.active[e]=!0,this.workers.slice()}release(e){delete this.active[e],0===this.numActive()&&(this.workers.forEach((e=>{e.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[ep]}numActive(){return Object.keys(this.active).length}}let tp;function ip(){return tp||(tp=new WorkerPool),tp}WorkerPool.workerCount=2;var rp=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function np(e,t){const i={};for(const t in e)"ref"!==t&&(i[t]=e[t]);return rp.forEach((e=>{e in t&&(i[e]=t[e])})),i}function op(e){e=e.slice();const t=Object.create(null);for(let i=0;i<e.length;i++)t[e[i].id]=e[i];for(let i=0;i<e.length;i++)"ref"in e[i]&&(e[i]=np(e[i],t[e[i].ref]));return e}const ap={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setProjection:"setProjection"};function sp(e,t,i){i.push({command:ap.addSource,args:[e,t[e]]})}function lp(e,t,i){t.push({command:ap.removeSource,args:[e]}),i[e]=!0}function cp(e,t,i,r){lp(e,i,r),sp(e,t,i)}function up(e,t,i){let r;for(r in e[i])if(e[i].hasOwnProperty(r)&&"data"!==r&&!o(e[i][r],t[i][r]))return!1;for(r in t[i])if(t[i].hasOwnProperty(r)&&"data"!==r&&!o(e[i][r],t[i][r]))return!1;return!0}function hp(e,t,i,r,n,a){let s;for(s in t=t||{},e=e||{})e.hasOwnProperty(s)&&(o(e[s],t[s])||i.push({command:a,args:[r,s,t[s],n]}));for(s in t)t.hasOwnProperty(s)&&!e.hasOwnProperty(s)&&(o(e[s],t[s])||i.push({command:a,args:[r,s,t[s],n]}))}function pp(e){return e.id}function dp(e,t){return e[t.id]=t,e}class PathInterpolator{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e<this.points.length;e++)this._distances[e]=this._distances[e-1]+this.points[e].dist(this.points[e-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(t||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(e){if(1===this.points.length)return this.points[0];e=_(e,0,1);let t=1,i=this._distances[t];const r=e*this.paddedLength+this.padding;for(;i<r&&t<this._distances.length;)i=this._distances[++t];const n=t-1,o=this._distances[n],a=i-o,s=a>0?(r-o)/a:0;return this.points[n].mult(1-s).add(this.points[t].mult(s))}}class GridIndex{constructor(e,t,i){const r=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;e<this.xCellCount*this.yCellCount;e++)r.push([]),n.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=t,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/t,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,t,i,r,n){this._forEachCell(t,i,r,n,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)}insertCircle(e,t,i,r){this._forEachCell(t-r,i-r,t+r,i+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(i),this.circles.push(r)}_insertBoxCell(e,t,i,r,n,o){this.boxCells[n].push(o)}_insertCircleCell(e,t,i,r,n,o){this.circleCells[n].push(o)}_query(e,t,i,r,n,o){if(i<0||e>this.width||r<0||t>this.height)return!n&&[];const a=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(n)return!0;for(let e=0;e<this.boxKeys.length;e++)a.push({key:this.boxKeys[e],x1:this.bboxes[4*e],y1:this.bboxes[4*e+1],x2:this.bboxes[4*e+2],y2:this.bboxes[4*e+3]});for(let e=0;e<this.circleKeys.length;e++){const t=this.circles[3*e],i=this.circles[3*e+1],r=this.circles[3*e+2];a.push({key:this.circleKeys[e],x1:t-r,y1:i-r,x2:t+r,y2:i+r})}return o?a.filter(o):a}return this._forEachCell(e,t,i,r,this._queryCell,a,{hitTest:n,seenUids:{box:{},circle:{}}},o),n?a.length>0:a}_queryCircle(e,t,i,r,n){const o=e-i,a=e+i,s=t-i,l=t+i;if(a<0||o>this.width||l<0||s>this.height)return!r&&[];const c=[];return this._forEachCell(o,s,a,l,this._queryCellCircle,c,{hitTest:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},n),r?c.length>0:c}query(e,t,i,r,n){return this._query(e,t,i,r,!1,n)}hitTest(e,t,i,r,n){return this._query(e,t,i,r,!0,n)}hitTestCircle(e,t,i,r){return this._queryCircle(e,t,i,!0,r)}_queryCell(e,t,i,r,n,o,a,s){const l=a.seenUids,c=this.boxCells[n];if(null!==c){const n=this.bboxes;for(const u of c)if(!l.box[u]){l.box[u]=!0;const c=4*u;if(e<=n[c+2]&&t<=n[c+3]&&i>=n[c+0]&&r>=n[c+1]&&(!s||s(this.boxKeys[u]))){if(a.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[u],x1:n[c],y1:n[c+1],x2:n[c+2],y2:n[c+3]})}}}const u=this.circleCells[n];if(null!==u){const n=this.circles;for(const c of u)if(!l.circle[c]){l.circle[c]=!0;const u=3*c;if(this._circleAndRectCollide(n[u],n[u+1],n[u+2],e,t,i,r)&&(!s||s(this.circleKeys[c]))){if(a.hitTest)return o.push(!0),!0;{const e=n[u],t=n[u+1],i=n[u+2];o.push({key:this.circleKeys[c],x1:e-i,y1:t-i,x2:e+i,y2:t+i})}}}}}_queryCellCircle(e,t,i,r,n,o,a,s){const l=a.circle,c=a.seenUids,u=this.boxCells[n];if(null!==u){const e=this.bboxes;for(const t of u)if(!c.box[t]){c.box[t]=!0;const i=4*t;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!s||s(this.boxKeys[t])))return o.push(!0),!0}}const h=this.circleCells[n];if(null!==h){const e=this.circles;for(const t of h)if(!c.circle[t]){c.circle[t]=!0;const i=3*t;if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!s||s(this.circleKeys[t])))return o.push(!0),!0}}}_forEachCell(e,t,i,r,n,o,a,s){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),u=this._convertToXCellCoord(i),h=this._convertToYCellCoord(r);for(let p=l;p<=u;p++)for(let l=c;l<=h;l++)if(n.call(this,e,t,i,r,this.xCellCount*l+p,o,a,s))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,r,n,o){const a=r-e,s=n-t,l=i+o;return l*l>a*a+s*s}_circleAndRectCollide(e,t,i,r,n,o,a){const s=(o-r)/2,l=Math.abs(e-(r+s));if(l>s+i)return!1;const c=(a-n)/2,u=Math.abs(t-(n+c));if(u>c+i)return!1;if(l<=s||u<=c)return!0;const h=l-s,p=u-c;return h*h+p*p<=i*i}}const fp=Math.tan(85*Math.PI/180);function mp(e,t,i,r,n,o,a){const s=ga();if(i)if("globe"===o.name){const e=function(e,t){const{x:i,y:r}=e.point,n=mu(i,r,e.worldSize/e._pixelsPerMercatorPixel,0,0);return va(n,n,du(tu(t)))}(n,t);va(s,s,e)}else{const e=da([],a);s[0]=e[0],s[1]=e[1],s[4]=e[2],s[5]=e[3],r||Sa(s,s,n.angle)}else va(s,n.labelPlaneMatrix,e);return s}function _p(e,t,i,r,n,o,a){const s=mp(e,t,i,r,n,o,a);return"globe"===o.name&&i||(s[2]=s[6]=s[10]=s[14]=0),s}function gp(e,t,i,r,n,o,a){if(i){if("globe"===o.name){const s=mp(e,t,i,r,n,o,a);return xa(s,s),va(s,e,s),s}{const t=(s=e,(l=new pa(16))[0]=s[0],l[1]=s[1],l[2]=s[2],l[3]=s[3],l[4]=s[4],l[5]=s[5],l[6]=s[6],l[7]=s[7],l[8]=s[8],l[9]=s[9],l[10]=s[10],l[11]=s[11],l[12]=s[12],l[13]=s[13],l[14]=s[14],l[15]=s[15],l),i=ya([]);return i[0]=a[0],i[1]=a[1],i[4]=a[2],i[5]=a[3],va(t,t,i),r||Sa(t,t,-n.angle),t}}return n.glCoordMatrix;var s,l}function yp(e,t,i=0){const r=[e.x,e.y,i,1];i?is(r,r,t):Dp(r,r,t);const n=r[3];return{point:[r[0]/n,r[1]/n,r[2]/n],signedDistanceFromCamera:n}}function xp(e,t){const i=[e[0],e[1],e[2],1];is(i,i,t);const r=i[3];return{point:[i[0]/r,i[1]/r,i[2]/r],signedDistanceFromCamera:r}}function vp(e,t){return Math.min(.5+e/t*.5,1.5)}function bp(e,t){const i=e[0]/e[3],r=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&r>=-t[1]&&r<=t[1]}function wp(e,t,i,n,o,a,s,l,c,u){const h=i.transform,p=n?e.textSizeData:e.iconSizeData,d=oc(p,i.transform.zoom),f="globe"===h.projection.name,m=[256/i.width*2+1,256/i.height*2+1],_=n?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;_.clear();let g=null;f&&(g=n?e.text.globeExtVertexArray:e.icon.globeExtVertexArray);const y=e.lineVertexArray,x=n?e.text.placedSymbolArray:e.icon.placedSymbolArray,v=i.transform.width/i.transform.height;let b=!1;for(let n=0;n<x.length;n++){const f=x.get(n);if(f.writingMode!==Bc.vertical||b||0!==n&&x.get(n-1).writingMode===Bc.horizontal||(b=!0),(f.hidden||f.writingMode===Bc.vertical)&&!b){Pp(f.numGlyphs,_);continue}b=!1;const w=new r(f.tileAnchorX,f.tileAnchorY),T=c?c(w):[0,0,0],E=h.projection.projectTilePoint(w.x,w.y,u.canonical),S=[E.x+T[0],E.y+T[1],E.z+T[2]],A=[...S,1];if(is(A,A,t),!bp(A,m)){Pp(f.numGlyphs,_);continue}const C=vp(i.transform.cameraToCenterDistance,A[3]),I=nc(p,d,f),M=s?I/C:I*C,P=yp(new r(S[0],S[1]),o,S[2]);if(P.signedDistanceFromCamera<=0){Pp(f.numGlyphs,_);continue}let D={};const z=s?null:c,k=Sp(f,M,!1,l,t,o,a,e.glyphOffsetArray,y,_,g,P.point,w,D,v,z,h.projection,u,s);b=k.useVertical,z&&k.needsFlipping&&(D={}),(k.notEnoughRoom||b||k.needsFlipping&&Sp(f,M,!0,l,t,o,a,e.glyphOffsetArray,y,_,g,P.point,w,D,v,z,h.projection,u,s).notEnoughRoom)&&Pp(f.numGlyphs,_)}n?(e.text.dynamicLayoutVertexBuffer.updateData(_),g&&e.text.globeExtVertexBuffer.updateData(g)):(e.icon.dynamicLayoutVertexBuffer.updateData(_),g&&e.icon.globeExtVertexBuffer.updateData(g))}function Tp(e,t,i,r,n,o,a,s,l,c,u,h,p,d,f,m){const _=s.glyphStartIndex+s.numGlyphs,g=s.lineStartIndex,y=s.lineStartIndex+s.lineLength,x=t.getoffsetX(s.glyphStartIndex),v=t.getoffsetX(_-1),b=Ip(e*x,i,r,n,o,a,s.segment,g,y,l,c,u,h,p,!0,d,f,m);if(!b)return null;const w=Ip(e*v,i,r,n,o,a,s.segment,g,y,l,c,u,h,p,!0,d,f,m);return w?{first:b,last:w}:null}function Ep(e,t,i,r){return e.writingMode===Bc.horizontal&&Math.abs(i.y-t.y)>Math.abs(i.x-t.x)*r?{useVertical:!0}:e.writingMode===Bc.vertical?t.y<i.y?{needsFlipping:!0}:null:0!==e.flipState&&function(e,t,i){const r=(t.x-e.x)*i;return 0===r||Math.abs((t.y-e.y)/r)>fp}(t,i,r)?1===e.flipState?{needsFlipping:!0}:null:t.x>i.x?{needsFlipping:!0}:null}function Sp(e,t,i,n,o,a,s,l,c,u,h,p,d,f,m,_,g,y,x){const v=t/24,b=e.lineOffsetX*v,w=e.lineOffsetY*v;let T;if(e.numGlyphs>1){const t=e.glyphStartIndex+e.numGlyphs,o=e.lineStartIndex,u=e.lineStartIndex+e.lineLength,h=Tp(v,l,b,w,i,p,d,e,c,a,f,_,!1,g,y,x);if(!h)return{notEnoughRoom:!0};const E=xp(h.first.point,s).point,S=xp(h.last.point,s).point,A=new r(E[0],E[1]),C=new r(S[0],S[1]);if(n&&!i){const t=Ep(e,A,C,m);if(e.flipState=t&&t.needsFlipping?1:2,t)return t}T=[h.first];for(let r=e.glyphStartIndex+1;r<t-1;r++)T.push(Ip(v*l.getoffsetX(r),b,w,i,p,d,e.segment,o,u,c,a,f,_,!1,!1,g,y,x));T.push(h.last)}else{if(n&&!i){const t=yp(d,o).point,i=e.lineStartIndex+e.segment+1,n=new r(c.getx(i),c.gety(i)),a=yp(n,o),s=a.signedDistanceFromCamera>0?a.point:Cp(d,n,t,1,o,void 0,g,y.canonical),l=Ep(e,new r(t[0],t[1]),new r(s[0],s[1]),m);if(e.flipState=l&&l.needsFlipping?1:2,l)return l}const t=Ip(v*l.getoffsetX(e.glyphStartIndex),b,w,i,p,d,e.segment,e.lineStartIndex,e.lineStartIndex+e.lineLength,c,a,f,_,!1,!1,g,y,x);if(!t)return{notEnoughRoom:!0};T=[t]}if(h)for(const e of T)Wu(h,u.length+0,e.up[0],e.up[1],e.up[2]),Wu(h,u.length+1,e.up[0],e.up[1],e.up[2]),Wu(h,u.length+2,e.up[0],e.up[1],e.up[2]),Wu(h,u.length+3,e.up[0],e.up[1],e.up[2]),Hu(u,e.point[0],e.point[1],e.point[2],e.angle);else for(const e of T)Hu(u,e.point[0],e.point[1],e.point[2],e.angle);return{}}function Ap(e,t,i,n,o){const a=n.projectTilePoint(e.x,e.y,t);if(!o)return yp(a,i,a.z);const s=o(e);return yp(new r(a.x+s[0],a.y+s[1]),i,a.z+s[2])}function Cp(e,t,i,r,n,o,a,s){const l=Ap(e.add(e.sub(t)._unit()),s,n,a,o).point,c=Ja([],i,l);return Na([],i,c,r/La(c))}function Ip(e,t,i,n,o,a,s,l,c,u,h,p,d,f,m,_,g,y){const x=n?e-t:e+t;let v=x>0?1:-1,b=0;n&&(v*=-1,b=Math.PI),v<0&&(b+=Math.PI);let w=v>0?l+s:l+s+1,T=o,E=o,S=0,A=0;const C=Math.abs(x),I=[],M=[];let P=a;const D=()=>{const e=w-v;return 0===S?a:new r(u.getx(e),u.gety(e))},z=()=>Cp(D(),P,E,C-S+1,h,d,_,g.canonical);for(;S+A<=C;){if(w+=v,w<l||w>=c)return null;if(E=T,I.push(T),f&&M.push(P||D()),T=p[w],void 0===T){P=new r(u.getx(w),u.gety(w));const e=Ap(P,g.canonical,h,_,d);T=e.signedDistanceFromCamera>0?p[w]=e.point:z()}else P=null;S+=A,A=Ga(E,T)}P=P||new r(u.getx(w),u.gety(w));const k=D();m&&d&&(p[w]=T=void 0===p[w]?T:z(),A=Ga(E,T));const L=(C-S)/A,B=P.sub(k).mult(L)._add(k),R=Ja([],T,E),F=Na([],E,R,L);let O=[0,0,1],V=R[0],U=R[1];if(y&&(O=_.upVector(g.canonical,B.x,B.y),0!==O[0]||0!==O[1]||1!==O[2])){const e=[1,0,0],t=[0,1,0];e[0]=O[2],e[1]=0,e[2]=-O[0],$a(t,O,e),Za(e,e),Za(t,t),V=qa(R,e),U=qa(R,t)}if(i){const e=$a([],O,R);Za(e,e),Na(F,F,e,i*v)}const j=b+Math.atan2(U,V);return I.push(F),f&&M.push(B),{point:F,angle:j,path:I,tilePath:M,up:O}}const Mp=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Pp(e,t){for(let i=0;i<e;i++){const e=t.length;t.resize(e+4),t.float32.set(Mp,4*e)}}function Dp(e,t,i){const r=t[0],n=t[1];return e[0]=i[0]*r+i[4]*n+i[12],e[1]=i[1]*r+i[5]*n+i[13],e[3]=i[3]*r+i[7]*n+i[15],e}const zp=100;class CollisionIndex{constructor(e,t,i=new GridIndex(e.width+200,e.height+200,25),r=new GridIndex(e.width+200,e.height+200,25)){this.transform=e,this.grid=i,this.ignoredGrid=r,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+zp,this.screenBottomBoundary=e.height+zp,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=t}placeCollisionBox(e,t,i,r,n,o,a,s){let l=i.projectedAnchorX,c=i.projectedAnchorY,u=i.projectedAnchorZ;const h=i.elevation,p=i.tileID;if(h&&p){const t=e.getProjection().upVector(p.canonical,i.tileAnchorX,i.tileAnchorY),r=e.getProjection().upVectorScale(p.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=t[0]*h*r,c+=t[1]*h*r,u+=t[2]*h*r}const d=this.projectAndGetPerspectiveRatio(a,[l,c,u],i.tileID,"globe"===e.projection.name||!!h||this.transform.pitch>0,e.getProjection()),f=o*d.perspectiveRatio,m=(i.x1*t+r.x-i.padding)*f+d.point.x,_=(i.y1*t+r.y-i.padding)*f+d.point.y,g=(i.x2*t+r.x+i.padding)*f+d.point.x,y=(i.y2*t+r.y+i.padding)*f+d.point.y,x=d.perspectiveRatio<=.55||d.occluded;return!this.isInsideGrid(m,_,g,y)||!n&&this.grid.hitTest(m,_,g,y,s)||x?{box:[],offscreen:!1,occluded:d.occluded}:{box:[m,_,g,y],offscreen:this.isOffscreen(m,_,g,y),occluded:!1}}placeCollisionCircles(e,t,i,n,o,a,s,l,c,u,h,p,d,f,m){const _=[],g=this.transform.elevation,y=g?g.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,e.getProjection()):e=>[0,0,0],x=new r(i.tileAnchorX,i.tileAnchorY),v=e.getProjection().projectTilePoint(i.tileAnchorX,i.tileAnchorY,m.canonical),b=y(x),w=[v.x+b[0],v.y+b[1],v.z+b[2]],T="globe"===e.projection.name,E=this.projectAndGetPerspectiveRatio(s,[w[0],w[1],w[2]],m,T||!!g||this.transform.pitch>0,e.getProjection()),{perspectiveRatio:S}=E,A=(h?a/S:a*S)/24,C=yp(new r(w[0],w[1]),l,w[2]).point,I=E.signedDistanceFromCamera>0?Tp(A,o,i.lineOffsetX*A,i.lineOffsetY*A,!1,C,x,i,n,l,{},g&&!h?y:null,h&&!!g,e.getProjection(),m,h):null;let M=!1,P=!1,D=!0;if(I&&!E.occluded){const e=.5*d*S+f,i=new r(-100,-100),n=new r(this.screenRightBoundary,this.screenBottomBoundary),o=new PathInterpolator,a=I.first,s=I.last;let l=[];for(let e=a.path.length-1;e>=1;e--)l.push(a.path[e]);for(let e=1;e<s.path.length;e++)l.push(s.path[e]);const h=2.5*e;if(c){const e=l.map(g&&!T?(e,t)=>{const i=y(t<a.path.length-1?a.tilePath[a.path.length-1-t]:s.tilePath[t-a.path.length+2]);return e[2]=i[2],xp(e,c)}:e=>xp(e,c));l=e.some((e=>e.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point))}let m=[];if(l.length>0){const e=l.map((e=>new r(e[0],e[1])));let t=1/0,o=-1/0,a=1/0,s=-1/0;for(let i=0;i<e.length;i++)t=Math.min(t,e[i].x),a=Math.min(a,e[i].y),o=Math.max(o,e[i].x),s=Math.max(s,e[i].y);m=t>=i.x&&o<=n.x&&a>=i.y&&s<=n.y?[e]:o<i.x||t>n.x||s<i.y||a>n.y?[]:function(e,t,i,n,o){const a=[];for(let s=0;s<e.length;s++){const l=e[s];let c;for(let e=0;e<l.length-1;e++){let s=l[e],u=l[e+1];s.x<t&&u.x<t||(s.x<t?s=new r(t,s.y+(t-s.x)/(u.x-s.x)*(u.y-s.y))._round():u.x<t&&(u=new r(t,s.y+(t-s.x)/(u.x-s.x)*(u.y-s.y))._round()),s.y<i&&u.y<i||(s.y<i?s=new r(s.x+(i-s.y)/(u.y-s.y)*(u.x-s.x),i)._round():u.y<i&&(u=new r(s.x+(i-s.y)/(u.y-s.y)*(u.x-s.x),i)._round()),s.x>=n&&u.x>=n||(s.x>=n?s=new r(n,s.y+(n-s.x)/(u.x-s.x)*(u.y-s.y))._round():u.x>=n&&(u=new r(n,s.y+(n-s.x)/(u.x-s.x)*(u.y-s.y))._round()),s.y>=o&&u.y>=o||(s.y>=o?s=new r(s.x+(o-s.y)/(u.y-s.y)*(u.x-s.x),o)._round():u.y>=o&&(u=new r(s.x+(o-s.y)/(u.y-s.y)*(u.x-s.x),o)._round()),c&&s.equals(c[c.length-1])||(c=[s],a.push(c)),c.push(u)))))}}return a}([e],i.x,i.y,n.x,n.y)}for(const i of m){o.reset(i,.25*e);let r=0;r=o.length<=.5*e?1:Math.ceil(o.paddedLength/h)+1;for(let i=0;i<r;i++){const n=i/Math.max(r-1,1),a=o.lerp(n),s=a.x+zp,l=a.y+zp;_.push(s,l,e,0);const c=s-e,h=l-e,d=s+e,f=l+e;if(D=D&&this.isOffscreen(c,h,d,f),P=P||this.isInsideGrid(c,h,d,f),!t&&this.grid.hitTestCircle(s,l,e,p)&&(M=!0,!u))return{circles:[],offscreen:!1,collisionDetected:M,occluded:!1}}}}return{circles:!u&&M||!P?[]:_,offscreen:D,collisionDetected:M,occluded:E.occluded}}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const t=[];let i=1/0,n=1/0,o=-1/0,a=-1/0;for(const s of e){const e=new r(s.x+zp,s.y+zp);i=Math.min(i,e.x),n=Math.min(n,e.y),o=Math.max(o,e.x),a=Math.max(a,e.y),t.push(e)}const s=this.grid.query(i,n,o,a).concat(this.ignoredGrid.query(i,n,o,a)),l={},c={};for(const e of s){const i=e.key;void 0===l[i.bucketInstanceId]&&(l[i.bucketInstanceId]={}),l[i.bucketInstanceId][i.featureIndex]||Wo(t,[new r(e.x1,e.y1),new r(e.x2,e.y1),new r(e.x2,e.y2),new r(e.x1,e.y2)])&&(l[i.bucketInstanceId][i.featureIndex]=!0,void 0===c[i.bucketInstanceId]&&(c[i.bucketInstanceId]=[]),c[i.bucketInstanceId].push(i.featureIndex))}return c}insertCollisionBox(e,t,i,r,n){(t?this.ignoredGrid:this.grid).insert({bucketInstanceId:i,featureIndex:r,collisionGroupID:n},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,i,r,n){const o=t?this.ignoredGrid:this.grid,a={bucketInstanceId:i,featureIndex:r,collisionGroupID:n};for(let t=0;t<e.length;t+=4)o.insertCircle(a,e[t],e[t+1],e[t+2])}projectAndGetPerspectiveRatio(e,t,i,n,o){const a=[t[0],t[1],t[2],1];let s=!1;if(t[2]||this.transform.pitch>0){is(a,a,e);const r="globe"===o.name;this.fogState&&i&&!r&&(s=function(e,t,i,r,n,o){const a=[t,i,r];return Wa(a,a,o.calculateFogTileMatrix(n)),ch(e,a,o.pitch,o._fov)}(this.fogState,t[0],t[1],t[2],i.toUnwrapped(),this.transform)>.9)}else Dp(a,a,e);return{point:new r((a[0]/a[3]+1)/2*this.transform.width+zp,(-a[1]/a[3]+1)/2*this.transform.height+zp),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(o)/a[3]*.5,1.5),signedDistanceFromCamera:a[3],occluded:n&&a[2]>a[3]||s}}isOffscreen(e,t,i,r){return i<zp||e>=this.screenRightBoundary||r<zp||t>this.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e<this.gridRightBoundary&&r>=0&&t<this.gridBottomBoundary}getViewportMatrix(){const e=ya([]);return ba(e,e,[-100,-100,0]),e}}function kp(e,t,i){const r=t.createTileMatrix(e,e.worldSize,i.toUnwrapped());return va(new Float32Array(16),e.projMatrix,r)}function Lp(e,t,i){if(t.projection.name===i.projection.name)return e.projMatrix;const r=i.clone();return r.setProjection(t.projection),kp(r,t.getProjection(),e)}function Bp(e,t,i){return t.name===i.projection.name?e.projMatrix:kp(i,t,e)}class OpacityState{constructor(e,t,i,r){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):r&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class JointOpacityState{constructor(e,t,i,r,n,o=!1){this.text=new OpacityState(e?e.text:null,t,i,n),this.icon=new OpacityState(e?e.icon:null,t,r,n),this.clipped=o}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class JointPlacement{constructor(e,t,i,r=!1){this.text=e,this.icon=t,this.skipFade=i,this.clipped=r}}class CollisionCircleArray{constructor(){this.invProjMatrix=ga(),this.viewportMatrix=ga(),this.circles=[]}}class RetainedQueryData{constructor(e,t,i,r,n){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=n}}class CollisionGroups{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){const t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t}}return this.collisionGroups[e]}}function Rp(e,t,i,n,o){const{horizontalAlign:a,verticalAlign:s}=Rc(e),l=-(a-.5)*t,c=-(s-.5)*i,u=Nc(e,n);return new r(l+u[0]*o,c+u[1]*o)}function Fp(e,t,i,n,o){const a=new r(e,t);return i&&a._rotate(n?o:-o),a}class Placement{constructor(e,t,i,r,n){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new CollisionIndex(this.transform,n),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new CollisionGroups(i),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(e,t,i,r){const n=i.getBucket(t),o=i.latestFeatureIndex;if(!n||!o||t.id!==n.layerIds[0])return;const a=n.layers[0].layout,s=i.collisionBoxArray,l=Math.pow(2,this.transform.zoom-i.tileID.overscaledZ),c=i.tileSize/Eo,u=i.tileID.toUnwrapped();this.transform.setProjection(n.projection);const h=(p=i.tileID,d=n.getProjection(),f=this.transform,d.name===this.projection?f.calculateProjMatrix(p.toUnwrapped()):kp(f,d,p));var p,d,f;const m="map"===a.get("text-pitch-alignment"),_="map"===a.get("text-rotation-alignment");t.compileFilter();const g=t.dynamicFilter(),y=t.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(i),v=_p(h,i.tileID.canonical,m,_,this.transform,n.getProjection(),x);let b=null;if(m){const e=gp(h,i.tileID.canonical,m,_,this.transform,n.getProjection(),x);b=va([],this.transform.labelPlaneMatrix,e)}let w=null;g&&i.latestFeatureIndex&&(w={unwrappedTileID:u,dynamicFilter:g,dynamicFilterNeedsFeature:y,featureIndex:i.latestFeatureIndex}),this.retainedQueryData[n.bucketInstanceId]=new RetainedQueryData(n.bucketInstanceId,o,n.sourceLayerIndex,n.index,i.tileID);const T={bucket:n,layout:a,posMatrix:h,textLabelPlaneMatrix:v,labelToScreenMatrix:b,clippingData:w,scale:l,textPixelRatio:c,holdingForFade:i.holdingForFade(),collisionBoxArray:s,partiallyEvaluatedTextSize:oc(n.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:oc(n.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(n.sourceID)};if(r)for(const t of n.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n}=t;e.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n,parameters:T})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:n.symbolInstances.length,parameters:T})}attemptAnchorPlacement(e,t,i,r,n,o,a,s,l,c,u,h,p,d,f,m,_,g){const y=[h.textOffset0,h.textOffset1],x=Rp(e,i,r,y,n),v=this.collisionIndex.placeCollisionBox(d,n,t,Fp(x.x,x.y,o,a,this.transform.angle),u,s,l,c.predicate);if((!m||0!==this.collisionIndex.placeCollisionBox(d,d.getSymbolInstanceIconSize(g,this.transform.zoom,p),m,Fp(x.x,x.y,o,a,this.transform.angle),u,s,l,c.predicate).box.length)&&v.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[h.crossTileID]&&this.prevPlacement.placements[h.crossTileID]&&this.prevPlacement.placements[h.crossTileID].text&&(t=this.prevPlacement.variableOffsets[h.crossTileID].anchor),this.variableOffsets[h.crossTileID]={textOffset:y,width:i,height:r,anchor:e,textScale:n,prevAnchor:t},this.markUsedJustification(d,e,h,f),d.allowVerticalPlacement&&(this.markUsedOrientation(d,f,h),this.placedOrientations[h.crossTileID]=f),{shift:x,placedGlyphBoxes:v}}}placeLayerBucketPart(e,t,i,n){const{bucket:o,layout:a,posMatrix:s,textLabelPlaneMatrix:l,labelToScreenMatrix:c,clippingData:u,textPixelRatio:h,holdingForFade:p,collisionBoxArray:d,partiallyEvaluatedTextSize:f,partiallyEvaluatedIconSize:m,collisionGroup:_}=e.parameters,g=a.get("text-optional"),y=a.get("icon-optional"),x=a.get("text-allow-overlap"),v=a.get("icon-allow-overlap"),b="map"===a.get("text-rotation-alignment"),w="map"===a.get("text-pitch-alignment"),T="none"!==a.get("icon-text-fit"),E="viewport-y"===a.get("symbol-z-order");this.transform.setProjection(o.projection);let S=x&&(v||!o.hasIconData()||y),A=v&&(x||!o.hasTextData()||g);!o.collisionArrays&&d&&o.deserializeCollisionBoxes(d),i&&n&&o.updateCollisionDebugBuffers(this.transform.zoom,d);const C=(e,n,d)=>{if(u){const i={zoom:this.transform.zoom,pitch:this.transform.pitch};let n=null;if(u.dynamicFilterNeedsFeature){const t=this.retainedQueryData[o.bucketInstanceId];n=u.featureIndex.loadFeature({featureIndex:e.featureIndex,bucketIndex:t.bucketIndex,sourceLayerIndex:t.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,u.dynamicFilter)(i,n,this.retainedQueryData[o.bucketInstanceId].tileID.canonical,new r(e.tileAnchorX,e.tileAnchorY),this.transform.calculateDistanceTileData(u.unwrappedTileID)))return this.placements[e.crossTileID]=new JointPlacement(!1,!1,!1,!0),void(t[e.crossTileID]=!0)}if(t[e.crossTileID])return;if(p)return void(this.placements[e.crossTileID]=new JointPlacement(!1,!1,!1));let E=!1,C=!1,I=!0,M=!1,P=!1,D=null,z={box:null,offscreen:null,occluded:null},k={box:null,offscreen:null,occluded:null},L=null,B=null,R=null,F=0,O=0,V=0;d.textFeatureIndex?F=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(F=e.featureIndex),d.verticalTextFeatureIndex&&(O=d.verticalTextFeatureIndex);const U=e=>{e.tileID=this.retainedQueryData[o.bucketInstanceId].tileID,(this.transform.elevation||e.elevation)&&(e.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[o.bucketInstanceId].tileID,e.tileAnchorX,e.tileAnchorY):0)},j=d.textBox;if(j){U(j);const t=t=>{let i=Bc.horizontal;if(o.allowVerticalPlacement&&!t&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,i=t,this.markUsedOrientation(o,i,e))}return i},i=(t,i)=>{if(o.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const e of o.writingModes)if(e===Bc.vertical?(z=i(),k=z):z=t(),z&&z.box&&z.box.length)break}else z=t()};if(a.get("text-variable-anchor")){let r=a.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[e.crossTileID]){const t=this.prevPlacement.variableOffsets[e.crossTileID];r.indexOf(t.anchor)>0&&(r=r.filter((e=>e!==t.anchor)),r.unshift(t.anchor))}const l=(t,i,a)=>{const l=o.getSymbolInstanceTextSize(f,e,this.transform.zoom,n),c=(t.x2-t.x1)*l+2*t.padding,u=(t.y2-t.y1)*l+2*t.padding,p=T&&!v?i:null;p&&U(p);let d={box:[],offscreen:!1,occluded:!1};const g=x?2*r.length:r.length;for(let i=0;i<g;++i){const g=this.attemptAnchorPlacement(r[i%r.length],t,c,u,l,b,w,h,s,_,i>=r.length,e,n,o,a,p,f,m);if(g&&(d=g.placedGlyphBoxes,d&&d.box&&d.box.length)){E=!0,D=g.shift;break}}return d};i((()=>l(j,d.iconBox,Bc.horizontal)),(()=>{const t=d.verticalTextBox;return t&&U(t),o.allowVerticalPlacement&&!(z&&z.box&&z.box.length)&&e.numVerticalGlyphVertices>0&&t?l(t,d.verticalIconBox,Bc.vertical):{box:null,offscreen:null,occluded:null}})),z&&(E=z.box,I=z.offscreen,M=z.occluded);const c=t(z&&z.box);if(!E&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(o,t.anchor,e,c))}}else{const a=(t,i)=>{const a=o.getSymbolInstanceTextSize(f,e,this.transform.zoom,n),l=this.collisionIndex.placeCollisionBox(o,a,t,new r(0,0),x,h,s,_.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(o,i,e),this.placedOrientations[e.crossTileID]=i),l};i((()=>a(j,Bc.horizontal)),(()=>{const t=d.verticalTextBox;return o.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&t?(U(t),a(t,Bc.vertical)):{box:null,offscreen:null,occluded:null}})),t(z&&z.box&&z.box.length)}}if(L=z,E=L&&L.box&&L.box.length>0,I=L&&L.offscreen,M=L&&L.occluded,e.useRuntimeCollisionCircles){const t=o.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex),r=nc(o.textSizeData,f,t),n=a.get("text-padding");B=this.collisionIndex.placeCollisionCircles(o,x,t,o.lineVertexArray,o.glyphOffsetArray,r,s,l,c,i,w,_.predicate,e.collisionCircleDiameter*r/24,n,this.retainedQueryData[o.bucketInstanceId].tileID),E=x||B.circles.length>0&&!B.collisionDetected,I=I&&B.offscreen,M=B.occluded}if(d.iconFeatureIndex&&(V=d.iconFeatureIndex),d.iconBox){const e=e=>{U(e);const t=T&&D?Fp(D.x,D.y,b,w,this.transform.angle):new r(0,0),i=o.getSymbolInstanceIconSize(m,this.transform.zoom,n);return this.collisionIndex.placeCollisionBox(o,i,e,t,v,h,s,_.predicate)};k&&k.box&&k.box.length&&d.verticalIconBox?(R=e(d.verticalIconBox),C=R.box.length>0):(R=e(d.iconBox),C=R.box.length>0),I=I&&R.offscreen,P=R.occluded}const N=g||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,G=y||0===e.numIconVertices;if(N||G?G?N||(C=C&&E):E=C&&E:C=E=C&&E,E&&L&&L.box&&this.collisionIndex.insertCollisionBox(L.box,a.get("text-ignore-placement"),o.bucketInstanceId,k&&k.box&&O?O:F,_.ID),C&&R&&this.collisionIndex.insertCollisionBox(R.box,a.get("icon-ignore-placement"),o.bucketInstanceId,V,_.ID),B&&(E&&this.collisionIndex.insertCollisionCircles(B.circles,a.get("text-ignore-placement"),o.bucketInstanceId,F,_.ID),i)){const e=o.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new CollisionCircleArray);for(let e=0;e<B.circles.length;e+=4)t.circles.push(B.circles[e+0]),t.circles.push(B.circles[e+1]),t.circles.push(B.circles[e+2]),t.circles.push(B.collisionDetected?1:0)}const Z="globe"!==o.projection.name;S=S&&(Z||!M),A=A&&(Z||!P),this.placements[e.crossTileID]=new JointPlacement(E||S,C||A,I||o.justReloaded),t[e.crossTileID]=!0};if(E){const e=o.getSortedSymbolIndexes(this.transform.angle);for(let t=e.length-1;t>=0;--t){const i=e[t];C(o.symbolInstances.get(i),i,o.collisionArrays[i])}}else for(let t=e.symbolInstanceStart;t<e.symbolInstanceEnd;t++)C(o.symbolInstances.get(t),t,o.collisionArrays[t]);if(i&&o.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[o.bucketInstanceId];xa(e.invProjMatrix,s),e.viewportMatrix=this.collisionIndex.getViewportMatrix()}o.justReloaded=!1}markUsedJustification(e,t,i,r){let n;n=r===Bc.vertical?i.verticalPlacedTextSymbolIndex:{left:i.leftJustifiedTextSymbolIndex,center:i.centerJustifiedTextSymbolIndex,right:i.rightJustifiedTextSymbolIndex}[function(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}(t)];const o=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex,i.verticalPlacedTextSymbolIndex];for(const t of o)t>=0&&(e.text.placedSymbolArray.get(t).crossTileID=n>=0&&t!==n?0:i.crossTileID)}markUsedOrientation(e,t,i){const r=t===Bc.horizontal||t===Bc.horizontalOnly?t:0,n=t===Bc.vertical?t:0,o=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex];for(const t of o)e.text.placedSymbolArray.get(t).placedOrientation=r;i.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(i.verticalPlacedTextSymbolIndex).placedOrientation=n)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const r=t?t.symbolFadeChange(e):1,n=t?t.opacities:{},o=t?t.variableOffsets:{},a=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=n[e];o?(this.opacities[e]=new JointOpacityState(o,r,t.text,t.icon,null,t.clipped),i=i||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new JointOpacityState(null,r,t.text,t.icon,t.skipFade,t.clipped),i=i||t.text||t.icon)}for(const e in n){const t=n[e];if(!this.opacities[e]){const n=new JointOpacityState(t,r,!1,!1);n.isHidden()||(this.opacities[e]=n,i=i||t.text.placed||t.icon.placed)}}for(const e in o)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=o[e]);for(const e in a)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=a[e]);i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){const i={};for(const r of t){const t=r.getBucket(e);t&&r.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,i,r.collisionBoxArray)}}updateBucketOpacities(e,t,i){e.hasTextData()&&e.text.opacityVertexArray.clear(),e.hasIconData()&&e.icon.opacityVertexArray.clear(),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const n=e.layers[0].layout,o=!!e.layers[0].dynamicFilter(),a=new JointOpacityState(null,0,!1,!1,!0),s=n.get("text-allow-overlap"),l=n.get("icon-allow-overlap"),c=n.get("text-variable-anchor"),u="map"===n.get("text-rotation-alignment"),h="map"===n.get("text-pitch-alignment"),p="none"!==n.get("icon-text-fit"),d=new JointOpacityState(null,0,s&&(l||!e.hasIconData()||n.get("icon-optional")),l&&(s||!e.hasTextData()||n.get("text-optional")),!0);!e.collisionArrays&&i&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(i);const f=(e,t,i)=>{for(let r=0;r<t/4;r++)e.opacityVertexArray.emplaceBack(i)};let m=0;for(let i=0;i<e.symbolInstances.length;i++){const n=e.symbolInstances.get(i),{numHorizontalGlyphVertices:s,numVerticalGlyphVertices:l,crossTileID:_}=n;let g=this.opacities[_];t[_]?g=a:g||(g=d,this.opacities[_]=g),t[_]=!0;const y=s>0||l>0,x=n.numIconVertices>0,v=this.placedOrientations[n.crossTileID],b=v===Bc.vertical,w=v===Bc.horizontal||v===Bc.horizontalOnly;if(!y&&!x||g.isHidden()||m++,y){const t=$p(g.text);f(e.text,s,b?Wp:t),f(e.text,l,w?Wp:t);const i=g.text.isHidden();[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex].forEach((t=>{t>=0&&(e.text.placedSymbolArray.get(t).hidden=i||b?1:0)})),n.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(n.verticalPlacedTextSymbolIndex).hidden=i||w?1:0);const r=this.variableOffsets[n.crossTileID];r&&this.markUsedJustification(e,r.anchor,n,v);const o=this.placedOrientations[n.crossTileID];o&&(this.markUsedJustification(e,"left",n,o),this.markUsedOrientation(e,o,n))}if(x){const t=$p(g.icon);n.placedIconSymbolIndex>=0&&(f(e.icon,n.numIconVertices,b?Wp:t),e.icon.placedSymbolArray.get(n.placedIconSymbolIndex).hidden=g.icon.isHidden()),n.verticalPlacedIconSymbolIndex>=0&&(f(e.icon,n.numVerticalIconVertices,w?Wp:t),e.icon.placedSymbolArray.get(n.verticalPlacedIconSymbolIndex).hidden=g.icon.isHidden())}if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const t=e.collisionArrays[i];if(t){let i=new r(0,0),n=!0;if(t.textBox||t.verticalTextBox){if(c){const e=this.variableOffsets[_];e?(i=Rp(e.anchor,e.width,e.height,e.textOffset,e.textScale),u&&i._rotate(h?this.transform.angle:-this.transform.angle)):n=!1}o&&(n=!g.clipped),t.textBox&&Op(e.textCollisionBox.collisionVertexArray,g.text.placed,!n||b,i.x,i.y),t.verticalTextBox&&Op(e.textCollisionBox.collisionVertexArray,g.text.placed,!n||w,i.x,i.y)}const a=n&&Boolean(!w&&t.verticalIconBox);t.iconBox&&Op(e.iconCollisionBox.collisionVertexArray,g.icon.placed,a,p?i.x:0,p?i.y:0),t.verticalIconBox&&Op(e.iconCollisionBox.collisionVertexArray,g.icon.placed,!a,p?i.x:0,p?i.y:0)}}}if(e.fullyClipped=0===m,e.sortFeatures(this.transform.angle),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[e.bucketInstanceId];e.placementInvProjMatrix=t.invProjMatrix,e.placementViewportMatrix=t.viewportMatrix,e.collisionCircleArray=t.circles,delete this.collisionCircleArrays[e.bucketInstanceId]}}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,t){const i=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*i>e}setStale(){this.stale=!0}}function Op(e,t,i,r,n){e.emplaceBack(t?1:0,i?1:0,r||0,n||0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0)}const Vp=Math.pow(2,25),Up=Math.pow(2,24),jp=Math.pow(2,17),Np=Math.pow(2,16),Gp=Math.pow(2,9),Zp=Math.pow(2,8),qp=Math.pow(2,1);function $p(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,i=Math.floor(127*e.opacity);return i*Vp+t*Up+i*jp+t*Np+i*Gp+t*Zp+i*qp+t}const Wp=0;class LayerPlacement{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&void 0!==e.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,i,r,n){const o=this._bucketParts;for(;this._currentTileIndex<e.length;)if(t.getBucketParts(o,r,e[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,n())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,o.sort(((e,t)=>e.sortKey-t.sortKey)));this._currentPartIndex<o.length;){const e=o[this._currentPartIndex];if(t.placeLayerBucketPart(e,this._seenCrossTileIDs,i,0===e.symbolInstanceStart),this._currentPartIndex++,n())return!0}return!1}}class PauseablePlacement{constructor(e,t,i,r,n,o,a,s){this.placement=new Placement(e,n,o,a,s),this._currentPlacementIndex=t.length-1,this._forceFullPlacement=i,this._showCollisionBoxes=r,this._done=!1}isDone(){return this._done}continuePlacement(e,t,i){const r=ee.now(),n=()=>{const e=ee.now()-r;return!this._forceFullPlacement&&e>2};for(;this._currentPlacementIndex>=0;){const r=t[e[this._currentPlacementIndex]],o=this.placement.collisionIndex.transform.zoom;if("symbol"===r.type&&(!r.minzoom||r.minzoom<=o)&&(!r.maxzoom||r.maxzoom>o)){if(this._inProgressLayer||(this._inProgressLayer=new LayerPlacement(r)),this._inProgressLayer.continuePlacement(i[r.source],this.placement,this._showCollisionBoxes,r,n))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}class TileLayerIndex{constructor(e,t,i){this.tileID=e,this.indexedSymbolInstances={},this.bucketInstanceId=i;for(let i=0;i<t.length;i++){const r=t.get(i),n=r.key;this.indexedSymbolInstances[n]||(this.indexedSymbolInstances[n]=[]),this.indexedSymbolInstances[n].push({crossTileID:r.crossTileID,coord:this.getScaledCoordinates(r,e)})}}getScaledCoordinates(e,t){const i=.03125/Math.pow(2,t.canonical.z-this.tileID.canonical.z);return{x:Math.floor((t.canonical.x*Eo+e.tileAnchorX)*i),y:Math.floor((t.canonical.y*Eo+e.tileAnchorY)*i)}}findMatches(e,t,i){const r=this.tileID.canonical.z<t.canonical.z?1:Math.pow(2,this.tileID.canonical.z-t.canonical.z);for(let n=0;n<e.length;n++){const o=e.get(n);if(o.crossTileID)continue;const a=this.indexedSymbolInstances[o.key];if(!a)continue;const s=this.getScaledCoordinates(o,t);for(const e of a)if(Math.abs(e.coord.x-s.x)<=r&&Math.abs(e.coord.y-s.y)<=r&&!i[e.crossTileID]){i[e.crossTileID]=!0,o.crossTileID=e.crossTileID;break}}}}class CrossTileIDs{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class CrossTileSymbolLayerIndex{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const e in this.indexes){const i=this.indexes[e],r={};for(const e in i){const n=i[e];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),r[n.tileID.key]=n}this.indexes[e]=r}this.lng=e}addBucket(e,t,i){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let e=0;e<t.symbolInstances.length;e++)t.symbolInstances.get(e).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||(this.usedCrossTileIDs[e.overscaledZ]={});const r=this.usedCrossTileIDs[e.overscaledZ];for(const i in this.indexes){const n=this.indexes[i];if(Number(i)>e.overscaledZ)for(const i in n){const o=n[i];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,r)}else{const o=n[e.scaledTo(Number(i)).key];o&&o.findMatches(t.symbolInstances,e,r)}}for(let e=0;e<t.symbolInstances.length;e++){const n=t.symbolInstances.get(e);n.crossTileID||(n.crossTileID=i.generate(),r[n.crossTileID]=!0)}return void 0===this.indexes[e.overscaledZ]&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new TileLayerIndex(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(const i in t.indexedSymbolInstances)for(const r of t.indexedSymbolInstances[i])delete this.usedCrossTileIDs[e][r.crossTileID]}removeStaleBuckets(e){let t=!1;for(const i in this.indexes){const r=this.indexes[i];for(const n in r)e[r[n].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,r[n]),delete r[n],t=!0)}return t}}class CrossTileSymbolIndex{constructor(){this.layerIndexes={},this.crossTileIDs=new CrossTileIDs,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,i,r){let n=this.layerIndexes[e.id];void 0===n&&(n=this.layerIndexes[e.id]=new CrossTileSymbolLayerIndex);let o=!1;const a={};"globe"!==r.name&&n.handleWrapJump(i);for(const i of t){const t=i.getBucket(e);t&&e.id===t.layerIds[0]&&(t.bucketInstanceId||(t.bucketInstanceId=++this.maxBucketInstanceId),n.addBucket(i.tileID,t,this.crossTileIDs)&&(o=!0),a[t.bucketInstanceId]=!0)}return n.removeStaleBuckets(a)&&(o=!0),o}pruneUnusedLayers(e){const t={};e.forEach((e=>{t[e]=!0}));for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}const Hp=(e,t)=>vn(e,t&&t.filter((e=>"source.canvas"!==e.identifier))),Xp=w(ap,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Kp=w(ap,["setCenter","setZoom","setBearing","setPitch"]),Jp={version:8,layers:[],sources:{}},Yp={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class Style extends Evented{constructor(e,t={}){super(),this.map=e,this.dispatcher=new Dispatcher(ip(),this),this.imageManager=new ImageManager,this.imageManager.setEventedParent(this),this.glyphManager=new GlyphManager(e._requestManager,t.localFontFamily?2:t.localIdeographFontFamily?1:0,t.localFontFamily||t.localIdeographFontFamily),this.lineAtlas=new LineAtlas(256,512),this.crossTileSymbolIndex=new CrossTileSymbolIndex,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",Ke());const i=this;this._rtlTextPluginCallback=Style.registerForPluginStateChange((e=>{i.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:e.pluginStatus,pluginURL:e.pluginURL},((e,t)=>{if($n(e),t&&t.every((e=>e)))for(const e in i._sourceCaches){const t=i._sourceCaches[e],r=t.getSource().type;"vector"!==r&&"geojson"!==r||t.reload()}}))})),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getSource(e.sourceId);if(t&&t.vectorLayerIds)for(const e in this._layers){const i=this._layers[e];i.source===t.id&&this._validateLayer(i)}}))}loadURL(e,t={}){this.fire(new Event("dataloading",{dataType:"style"}));const i="boolean"==typeof t.validate?t.validate:!Ee(e);e=this.map._requestManager.normalizeStyleURL(e,t.accessToken);const r=this.map._requestManager.transformRequest(e,Xe.Style);this._request=Ye(r,((e,t)=>{this._request=null,e?this.fire(new ErrorEvent(e)):t&&this._load(t,i)}))}loadJSON(e,t={}){this.fire(new Event("dataloading",{dataType:"style"})),this._request=ee.frame((()=>{this._request=null,this._load(e,!1!==t.validate)}))}loadEmpty(){this.fire(new Event("dataloading",{dataType:"style"})),this._load(Jp,!1)}_updateLayerCount(e,t){const i=t?1:-1;e.is3D()&&(this._num3DLayers+=i),"circle"===e.type&&(this._numCircleLayers+=i),"symbol"===e.type&&(this._numSymbolLayers+=i)}_load(e,t){if(t&&Hp(this,un(e)))return;this._loaded=!0,this.stylesheet=z(e),this._updateMapProjection();for(const t in e.sources)this.addSource(t,e.sources[t],{validate:!1});this._changed=!1,e.sprite?this._loadSprite(e.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(e.glyphs);const i=op(this.stylesheet.layers);this._order=i.map((e=>e.id)),this._layers={},this._serializedLayers={};for(let e of i)e=rh(e),e.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=e,this._serializedLayers[e.id]=e.serialize(),this._updateLayerCount(e,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new Light(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 Event("data",{dataType:"style"})),this.fire(new Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}setProjection(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null))}_updateMapProjection(){this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.stylesheet.projection)}_loadSprite(e){this._spriteRequest=function(e,t,i){let r,n,o;const a=ee.devicePixelRatio>1?"@2x":"";let s=Ye(t.transformRequest(t.normalizeSpriteURL(e,a,".json"),Xe.SpriteJSON),((e,t)=>{s=null,o||(o=e,r=t,c())})),l=at(t.transformRequest(t.normalizeSpriteURL(e,a,".png"),Xe.SpriteImage),((e,t)=>{l=null,o||(o=e,n=t,c())}));function c(){if(o)i(o);else if(r&&n){const e=ee.getImageData(n),t={};for(const i in r){const{width:n,height:o,x:a,y:s,sdf:l,pixelRatio:c,stretchX:u,stretchY:h,content:p}=r[i],d=new RGBAImage({width:n,height:o});RGBAImage.copy(e,d,{x:a,y:s},{x:0,y:0},{width:n,height:o}),t[i]={data:d,pixelRatio:c,sdf:l,stretchX:u,stretchY:h,content:p}}i(null,t)}}return{cancel(){s&&(s.cancel(),s=null),l&&(l.cancel(),l=null)}}}(e,this.map._requestManager,((e,t)=>{if(this._spriteRequest=null,e)this.fire(new ErrorEvent(e));else if(t)for(const e in t)this.imageManager.addImage(e,t[e]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new Event("data",{dataType:"style"}))}))}_validateLayer(e){const t=this.getSource(e.source);if(!t)return;const i=e.sourceLayer;i&&("geojson"===t.type||t.vectorLayerIds&&-1===t.vectorLayerIds.indexOf(i))&&this.fire(new ErrorEvent(new Error(`Source layer "${i}" does not exist on source "${t.id}" as specified by style layer "${e.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(e){const t=[];for(const i of e){const e=this._layers[i];"custom"!==e.type&&t.push(e.serialize())}return t}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;if(this.fog&&this.fog.hasTransition())return!0;for(const e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(e){return!!this.terrain&&Yp[e.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(e){if(!this._loaded)return;const t=this._changed;if(this._changed){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const e in this._updatedSources){const t=this._updatedSources[e];"reload"===t?this._reloadSource(e):"clear"===t&&this._clearSource(e)}this._updateTilesForChangedImages();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.fog&&this.fog.updateTransitions(e),this._resetUpdates()}const i={};for(const e in this._sourceCaches){const t=this._sourceCaches[e];i[e]=t.used,t.used=!1}for(const t of this._order){const i=this._layers[t];if(i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)){const e=this._getLayerSourceCache(i);e&&(e.used=!0)}const r=this.map.painter;if(r){const t=i.getProgramIds();if(!t)continue;const n=i.getProgramConfiguration(e.zoom);for(const e of t)r.useProgram(e,n)}}for(const e in i){const t=this._sourceCaches[e];i[e]!==t.used&&t.getSource().fire(new Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:t.getSource().id}))}this.light.recalculate(e),this.terrain&&this.terrain.recalculate(e),this.fog&&this.fog.recalculate(e),this.z=e.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),t&&this.fire(new Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this._sourceCaches)this._sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(e),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(e){if(this._checkLoaded(),Hp(this,un(e)))return!1;(e=z(e)).layers=op(e.layers);const t=function(e,t){if(!e)return[{command:ap.setStyle,args:[t]}];let i=[];try{if(!o(e.version,t.version))return[{command:ap.setStyle,args:[t]}];o(e.center,t.center)||i.push({command:ap.setCenter,args:[t.center]}),o(e.zoom,t.zoom)||i.push({command:ap.setZoom,args:[t.zoom]}),o(e.bearing,t.bearing)||i.push({command:ap.setBearing,args:[t.bearing]}),o(e.pitch,t.pitch)||i.push({command:ap.setPitch,args:[t.pitch]}),o(e.sprite,t.sprite)||i.push({command:ap.setSprite,args:[t.sprite]}),o(e.glyphs,t.glyphs)||i.push({command:ap.setGlyphs,args:[t.glyphs]}),o(e.transition,t.transition)||i.push({command:ap.setTransition,args:[t.transition]}),o(e.light,t.light)||i.push({command:ap.setLight,args:[t.light]}),o(e.fog,t.fog)||i.push({command:ap.setFog,args:[t.fog]}),o(e.projection,t.projection)||i.push({command:ap.setProjection,args:[t.projection]});const r={},n=[];!function(e,t,i,r){let n;for(n in t=t||{},e=e||{})e.hasOwnProperty(n)&&(t.hasOwnProperty(n)||lp(n,i,r));for(n in t)t.hasOwnProperty(n)&&(e.hasOwnProperty(n)?o(e[n],t[n])||("geojson"===e[n].type&&"geojson"===t[n].type&&up(e,t,n)?i.push({command:ap.setGeoJSONSourceData,args:[n,t[n].data]}):cp(n,t,i,r)):sp(n,t,i))}(e.sources,t.sources,n,r);const a=[];e.layers&&e.layers.forEach((e=>{e.source&&r[e.source]?i.push({command:ap.removeLayer,args:[e.id]}):a.push(e)}));let s=e.terrain;s&&r[s.source]&&(i.push({command:ap.setTerrain,args:[void 0]}),s=void 0),i=i.concat(n),o(s,t.terrain)||i.push({command:ap.setTerrain,args:[t.terrain]}),function(e,t,i){t=t||[];const r=(e=e||[]).map(pp),n=t.map(pp),a=e.reduce(dp,{}),s=t.reduce(dp,{}),l=r.slice(),c=Object.create(null);let u,h,p,d,f,m,_;for(u=0,h=0;u<r.length;u++)p=r[u],s.hasOwnProperty(p)?h++:(i.push({command:ap.removeLayer,args:[p]}),l.splice(l.indexOf(p,h),1));for(u=0,h=0;u<n.length;u++)p=n[n.length-1-u],l[l.length-1-u]!==p&&(a.hasOwnProperty(p)?(i.push({command:ap.removeLayer,args:[p]}),l.splice(l.lastIndexOf(p,l.length-h),1)):h++,m=l[l.length-u],i.push({command:ap.addLayer,args:[s[p],m]}),l.splice(l.length-u,0,p),c[p]=!0);for(u=0;u<n.length;u++)if(p=n[u],d=a[p],f=s[p],!c[p]&&!o(d,f))if(o(d.source,f.source)&&o(d["source-layer"],f["source-layer"])&&o(d.type,f.type)){for(_ in hp(d.layout,f.layout,i,p,null,ap.setLayoutProperty),hp(d.paint,f.paint,i,p,null,ap.setPaintProperty),o(d.filter,f.filter)||i.push({command:ap.setFilter,args:[p,f.filter]}),o(d.minzoom,f.minzoom)&&o(d.maxzoom,f.maxzoom)||i.push({command:ap.setLayerZoomRange,args:[p,f.minzoom,f.maxzoom]}),d)d.hasOwnProperty(_)&&"layout"!==_&&"paint"!==_&&"filter"!==_&&"metadata"!==_&&"minzoom"!==_&&"maxzoom"!==_&&(0===_.indexOf("paint.")?hp(d[_],f[_],i,p,_.slice(6),ap.setPaintProperty):o(d[_],f[_])||i.push({command:ap.setLayerProperty,args:[p,_,f[_]]}));for(_ in f)f.hasOwnProperty(_)&&!d.hasOwnProperty(_)&&"layout"!==_&&"paint"!==_&&"filter"!==_&&"metadata"!==_&&"minzoom"!==_&&"maxzoom"!==_&&(0===_.indexOf("paint.")?hp(d[_],f[_],i,p,_.slice(6),ap.setPaintProperty):o(d[_],f[_])||i.push({command:ap.setLayerProperty,args:[p,_,f[_]]}))}else i.push({command:ap.removeLayer,args:[p]}),m=l[l.lastIndexOf(p)+1],i.push({command:ap.addLayer,args:[f,m]})}(a,t.layers,i)}catch(e){console.warn("Unable to compute style diff:",e),i=[{command:ap.setStyle,args:[t]}]}return i}(this.serialize(),e).filter((e=>!(e.command in Kp)));if(0===t.length)return!1;const i=t.filter((e=>!(e.command in Xp)));if(i.length>0)throw new Error(`Unimplemented: ${i.map((e=>e.command)).join(", ")}.`);return t.forEach((e=>{"setTransition"!==e.command&&"setProjection"!==e.command&&this[e.command].apply(this,e.args)})),this.stylesheet=e,this._updateMapProjection(),!0}addImage(e,t){return this.getImage(e)?this.fire(new ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(e,t),this._afterImageUpdated(e),this)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){return this.getImage(e)?(this.imageManager.removeImage(e),this._afterImageUpdated(e),this):this.fire(new ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(e,t,i={}){if(this._checkLoaded(),void 0!==this.getSource(e))throw new Error("There is already a source with this ID");if(!t.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(t).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(t.type)>=0&&this._validate(hn,`sources.${e}`,t,null,i))return;this.map&&this.map._collectResourceTiming&&(t.collectResourceTiming=!0);const r=Hh(e,t,this.dispatcher,this);r.setEventedParent(this,(()=>({isSourceLoaded:this._isSourceCacheLoaded(e),source:r.serialize(),sourceId:e})));const n=t=>{const i=(t?"symbol:":"other:")+e,n=this._sourceCaches[i]=new SourceCache(i,r,t);(t?this._symbolSourceCaches:this._otherSourceCaches)[e]=n,n.style=this,n.onAdd(this.map)};n(!1),"vector"!==t.type&&"geojson"!==t.type||n(!0),r.onAdd&&r.onAdd(this.map),this._changed=!0}removeSource(e){this._checkLoaded();const t=this.getSource(e);if(!t)throw new Error("There is no source with this ID");for(const t in this._layers)if(this._layers[t].source===e)return this.fire(new ErrorEvent(new Error(`Source "${e}" cannot be removed while layer "${t}" is using it.`)));if(this.terrain&&this.terrain.get().source===e)return this.fire(new ErrorEvent(new Error(`Source "${e}" cannot be removed while terrain is using it.`)));const i=this._getSourceCaches(e);for(const e of i)delete this._sourceCaches[e.id],delete this._updatedSources[e.id],e.fire(new Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:e.getSource().id})),e.setEventedParent(null),e.clearTiles();return delete this._otherSourceCaches[e],delete this._symbolSourceCaches[e],t.setEventedParent(null),t.onRemove&&t.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(e,t){this._checkLoaded(),this.getSource(e).setData(t),this._changed=!0}getSource(e){const t=this._getSourceCache(e);return t&&t.getSource()}addLayer(e,t,i={}){this._checkLoaded();const r=e.id;if(this.getLayer(r))return void this.fire(new ErrorEvent(new Error(`Layer with id "${r}" already exists on this map`)));let n;if("custom"===e.type){if(Hp(this,function(e){const t=[],i=e.id;return void 0===i&&t.push({message:`layers.${i}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${i}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),t}(e)))return;n=rh(e)}else{if("object"==typeof e.source&&(this.addSource(r,e.source),e=b(e=z(e),{source:r})),this._validate(mn,`layers.${r}`,e,{arrayIndex:-1},i))return;n=rh(e),this._validateLayer(n),n.setEventedParent(this,{layer:{id:r}}),this._serializedLayers[n.id]=n.serialize(),this._updateLayerCount(n,!0)}const o=t?this._order.indexOf(t):this._order.length;if(t&&-1===o)return void this.fire(new ErrorEvent(new Error(`Layer with id "${t}" does not exist on this map.`)));this._order.splice(o,0,r),this._layerOrderChanged=!0,this._layers[r]=n;const a=this._getLayerSourceCache(n);if(this._removedLayers[r]&&n.source&&a&&"custom"!==n.type){const e=this._removedLayers[r];delete this._removedLayers[r],e.type!==n.type?this._updatedSources[n.source]="clear":(this._updatedSources[n.source]="reload",a.pause())}this._updateLayer(n),n.onAdd&&n.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(e,t){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===t)return;const i=this._order.indexOf(e);this._order.splice(i,1);const r=t?this._order.indexOf(t):this._order.length;t&&-1===r?this.fire(new ErrorEvent(new Error(`Layer with id "${t}" does not exist on this map.`))):(this._order.splice(r,0,e),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(e){this._checkLoaded();const t=this._layers[e];if(!t)return void this.fire(new ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be removed.`)));t.setEventedParent(null),this._updateLayerCount(t,!1);const i=this._order.indexOf(e);this._order.splice(i,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=t,delete this._layers[e],delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],t.onRemove&&t.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(e){return this._layers[e]}hasLayer(e){return e in this._layers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return!0;return!1}setLayerZoomRange(e,t,i){this._checkLoaded();const r=this.getLayer(e);r?r.minzoom===t&&r.maxzoom===i||(null!=t&&(r.minzoom=t),null!=i&&(r.maxzoom=i),this._updateLayer(r)):this.fire(new ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(e,t,i={}){this._checkLoaded();const r=this.getLayer(e);if(r){if(!o(r.filter,t))return null==t?(r.filter=void 0,void this._updateLayer(r)):void(this._validate(_n,`layers.${r.id}.filter`,t,{layerType:r.type},i)||(r.filter=z(t),this._updateLayer(r)))}else this.fire(new ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be filtered.`)))}getFilter(e){const t=this.getLayer(e);return t&&z(t.filter)}setLayoutProperty(e,t,i,r={}){this._checkLoaded();const n=this.getLayer(e);n?o(n.getLayoutProperty(t),i)||(n.setLayoutProperty(t,i,r),this._updateLayer(n)):this.fire(new ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(e,t){const i=this.getLayer(e);if(i)return i.getLayoutProperty(t);this.fire(new ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style.`)))}setPaintProperty(e,t,i,r={}){this._checkLoaded();const n=this.getLayer(e);n?o(n.getPaintProperty(t),i)||(n.setPaintProperty(t,i,r)&&this._updateLayer(n),this._changed=!0,this._updatedPaintProps[e]=!0):this.fire(new ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(e,t){const i=this.getLayer(e);return i&&i.getPaintProperty(t)}setFeatureState(e,t){this._checkLoaded();const i=e.source,r=e.sourceLayer,n=this.getSource(i);if(!n)return void this.fire(new ErrorEvent(new Error(`The source '${i}' does not exist in the map's style.`)));const o=n.type;if("geojson"===o&&r)return void this.fire(new ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===o&&!r)return void this.fire(new ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===e.id&&this.fire(new ErrorEvent(new Error("The feature id parameter must be provided.")));const a=this._getSourceCaches(i);for(const i of a)i.setFeatureState(r,e.id,t)}removeFeatureState(e,t){this._checkLoaded();const i=e.source,r=this.getSource(i);if(!r)return void this.fire(new ErrorEvent(new Error(`The source '${i}' does not exist in the map's style.`)));const n=r.type,o="vector"===n?e.sourceLayer:void 0;if("vector"===n&&!o)return void this.fire(new ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(t&&"string"!=typeof e.id&&"number"!=typeof e.id)return void this.fire(new ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const a=this._getSourceCaches(i);for(const i of a)i.removeFeatureState(o,e.id,t)}getFeatureState(e){this._checkLoaded();const t=e.source,i=e.sourceLayer,r=this.getSource(t);if(r){if("vector"!==r.type||i)return void 0===e.id&&this.fire(new ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(t)[0].getFeatureState(i,e.id);this.fire(new ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new ErrorEvent(new Error(`The source '${t}' does not exist in the map's style.`)))}getTransition(){return b({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const e={};for(const t in this._sourceCaches){const i=this._sourceCaches[t].getSource();e[i.id]||(e[i.id]=i.serialize())}return D({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:e,layers:this._serializeLayers(this._order)},(e=>void 0!==e))}_updateLayer(e){this._updatedLayers[e.id]=!0;const t=this._getLayerSourceCache(e);e.source&&!this._updatedSources[e.source]&&t&&"raster"!==t.getSource().type&&(this._updatedSources[e.source]="reload",t.pause()),this._changed=!0,e.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._layers[e].type,i={},r=[];for(let n=this._order.length-1;n>=0;n--){const o=this._order[n];if(t(o)){i[o]=n;for(const t of e){const e=t[o];if(e)for(const t of e)r.push(t)}}}r.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const n=[];for(let o=this._order.length-1;o>=0;o--){const a=this._order[o];if(t(a))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(i[t.layer.id]<o)break;n.push(t),r.pop()}else for(const t of e){const e=t[a];if(e)for(const t of e)n.push(t.feature)}}return n}queryRenderedFeatures(e,t,i){t&&t.filter&&this._validate(_n,"queryRenderedFeatures.filter",t.filter,null,t);const r={};if(t&&t.layers){if(!Array.isArray(t.layers))return this.fire(new ErrorEvent(new Error("parameters.layers must be an Array."))),[];for(const e of t.layers){const t=this._layers[e];if(!t)return this.fire(new ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be queried for features.`))),[];r[t.source]=!0}}const n=[];t.availableImages=this._availableImages;const o=t&&t.layers?t.layers.some((e=>{const t=this.getLayer(e);return t&&t.is3D()})):this.has3DLayers(),a=QueryGeometry.createFromScreenPoints(e,i);for(const e in this._sourceCaches){const s=this._sourceCaches[e].getSource().id;t.layers&&!r[s]||n.push(Kh(this._sourceCaches[e],this._layers,this._serializedLayers,a,t,i,o,!!this.map._showQueryGeometry))}return this.placement&&n.push(function(e,t,i,r,n,o,a){const s={},l=o.queryRenderedSymbols(r),c=[];for(const e of Object.keys(l).map(Number))c.push(a[e]);c.sort(Yh);for(const i of c){const r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,n.filter,n.layers,n.availableImages,e);for(const e in r){const t=s[e]=s[e]||[],n=r[e];n.sort(((e,t)=>{const r=i.featureSortOrder;if(r){const i=r.indexOf(e.featureIndex);return r.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex}));for(const e of n)t.push(e)}}for(const t in s)s[t].forEach((r=>{const n=r.feature,o=i(e[t]).getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=o}));return s}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),a.screenGeometry,t,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(n)}querySourceFeatures(e,t){t&&t.filter&&this._validate(_n,"querySourceFeatures.filter",t.filter,null,t);const i=this._getSourceCaches(e);let r=[];for(const e of i)r=r.concat(Jh(e,t));return r}addSourceType(e,t,i){return Style.getSourceType(e)?i(new Error(`A source type called "${e}" already exists.`)):(Style.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},i):i(null,null))}getLight(){return this.light.getLight()}setLight(e,t={}){this._checkLoaded();const i=this.light.getLight();let r=!1;for(const t in e)if(!o(e[t],i[t])){r=!0;break}if(!r)return;const n=this._setTransitionParameters({duration:300,delay:0});this.light.setLight(e,t),this.light.updateTransitions(n)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(e,t=1){if(this._checkLoaded(),!e)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(1===t){if("object"==typeof e.source){const t="terrain-dem-src";this.addSource(t,e.source),e=b(e=z(e),{source:t})}if(this._validate(dn,"terrain",e))return}if(!this.terrain||this.terrain&&t!==this.terrain.drapeRenderMode)this._createTerrain(e,t);else{const t=this.terrain,i=t.get();for(const t of Object.keys(ct.terrain))!e.hasOwnProperty(t)&&ct.terrain[t].default&&(e[t]=ct.terrain[t].default);for(const r in e)if(!o(e[r],i[r])){t.set(e),this.stylesheet.terrain=e;const i=this._setTransitionParameters({duration:0});t.updateTransitions(i);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){const t=this.fog=new Fog(e,this.map.transform);this.stylesheet.fog=e;const i=this._setTransitionParameters({duration:0});t.updateTransitions(i)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask((()=>{for(const e of this.map._markers)e._evaluateOpacity()}))}getFog(){return this.fog?this.fog.get():null}setFog(e){if(this._checkLoaded(),!e)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const t=this.fog,i=t.get();0===Object.keys(e).length&&t.set(e);for(const r in e)if(!o(e[r],i[r])){t.set(e),this.stylesheet.fog=e;const i=this._setTransitionParameters({duration:0});t.updateTransitions(i);break}}else this._createFog(e);this._markersNeedUpdate=!0}_setTransitionParameters(e){return{now:ee.now(),transition:b(e,this.stylesheet.transition)}}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const e=this._order.filter((e=>this.isLayerDraped(this._layers[e]))),t=this._order.filter((e=>!this.isLayerDraped(this._layers[e])));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t)}_createTerrain(e,t){const i=this.terrain=new Terrain$1(e,t);this.stylesheet.terrain=e,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const r=this._setTransitionParameters({duration:0});i.updateTransitions(r)}_force3DLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"fill-extrusion"===t.type&&this._updateLayer(t)}}_forceSymbolLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"symbol"===t.type&&this._updateLayer(t)}}_validate(e,t,i,r,n={}){return(!n||!1!==n.validate)&&Hp(this,e.call(un,b({key:t,style:this.serialize(),value:i,styleSpec:ct},r)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),Hn.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._layers)this._layers[e].setEventedParent(null);for(const e in this._sourceCaches)this._sourceCaches[e].clearTiles(),this._sourceCaches[e].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(e){const t=this._getSourceCaches(e);for(const e of t)e.clearTiles()}_reloadSource(e){const t=this._getSourceCaches(e);for(const e of t)e.resume(),e.reload()}_updateSources(e){for(const t in this._sourceCaches)this._sourceCaches[t].update(e)}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload()}}_updatePlacement(e,t,i,r,n=!1){let o=!1,a=!1;const s={};for(const t of this._order){const i=this._layers[t];if("symbol"!==i.type)continue;if(!s[i.source]){const e=this._getLayerSourceCache(i);if(!e)continue;s[i.source]=e.getRenderableIds(!0).map((t=>e.getTileByID(t))).sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)))}const r=this.crossTileSymbolIndex.addLayer(i,s[i.source],e.center.lng,e.projection);o=o||r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),n=n||this._layerOrderChanged||0===i,this._layerOrderChanged&&this.fire(new Event("neworder")),(n||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(ee.now(),e.zoom))&&(this.pauseablePlacement=new PauseablePlacement(e,this._order,n,t,i,r,this.placement,this.fog&&e.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,s),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(ee.now()),a=!0),o&&this.pauseablePlacement.placement.setStale()),a||o)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,s[t.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(ee.now())}_releaseSymbolFadeTiles(){for(const e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles()}getImages(e,t,i){this.imageManager.getImages(t.icons,i),this._updateTilesForChangedImages();const r=e=>{e&&e.setDependencies(t.tileID.key,t.type,t.icons)};r(this._otherSourceCaches[t.source]),r(this._symbolSourceCaches[t.source])}getGlyphs(e,t,i){this.glyphManager.getGlyphs(t.stacks,i)}getResource(e,t,i){return Je(t,i)}_getSourceCache(e){return this._otherSourceCaches[e]}_getLayerSourceCache(e){return"symbol"===e.type?this._symbolSourceCaches[e.source]:this._otherSourceCaches[e.source]}_getSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),t}_isSourceCacheLoaded(e){const t=this._getSourceCaches(e);return 0===t.length?(this.fire(new ErrorEvent(new Error(`There is no source with ID '${e}'`))),!1):t.every((e=>e.loaded()))}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)}}Style.getSourceType=function(e){return Wh[e]},Style.setSourceType=function(e,t){Wh[e]=t},Style.registerForPluginStateChange=function(e){return e({pluginStatus:Zn,pluginURL:qn}),Hn.on("pluginStateChange",e),e};var Qp="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#define EXTENT 8192.0\n#define HALF_PI PI/2.0\n#define QUARTER_PI PI/4.0\n#define RAD_TO_DEG 180.0/PI\n#define DEG_TO_RAD PI/180.0\n#define GLOBE_RADIUS EXTENT/PI/2.0",ed="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;}",td="\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\nhighp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.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",id="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;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);}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",rd="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump float u_fog_temporal_offset;varying vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;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);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}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;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {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";let nd={},od={};const ad=[];hd(Qp,ad),hd(td,ad),hd(id,ad),hd(rd,ad),nd=pd("",td),od=pd(rd,id);const sd=pd("\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;}highp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}","\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;}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#ifndef 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) {return mix(globe,mercator,t);}mat3 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."),ld=Qp,cd="\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";var ud={background:pd("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:pd("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:pd("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;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\nvec3 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(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\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:pd("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:pd("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\nif (u_is_globe==0) {gl_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;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\nvec3 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:pd("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:pd("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:pd("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:pd("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:pd("#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:pd("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:pd("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:pd("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:pd("uniform lowp vec3 u_lightpos;varying vec4 v_color;\n#ifdef RENDER_SHADOWS\nvarying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;varying highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\nvoid main() {vec4 color=v_color;\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);color.rgb=color.rgb*shade;\n#endif\n#ifdef RENDER_SHADOWS\ncolor.xyz=shadowed_color_normal(color.xyz,normalize(v_normal),v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#endif\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;uniform float u_edge_radius;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#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying highp vec3 v_normal;varying float v_depth;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\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\nvec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;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,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : 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\nfloat ele=0.0;float h=0.0;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;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\nh=t > 0.0 ? height : base;vec3 pos=vec3(pos_nx.xy,h);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=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*h);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);\n#ifdef RENDER_SHADOWS\nv_pos_light_view_0=u_light_matrix_0*vec4(pos,1);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1);v_normal=normal;v_depth=gl_Position.w;\n#endif\nfloat 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)));}\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);directional*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\nv_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:pd("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\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;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 FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;\n#endif\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#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\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;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;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\nfloat ele=0.0;float h=z;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;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;h+=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)));}\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);directional*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\nv_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:pd("#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:pd("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:pd("uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec4 v_uv;\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;\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\nhighp vec4 out_color=texture2D(u_gradient_image,v_uv.xy);\n#else\nvec4 out_color=color;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {out_color=vec4(0,0,0,0);}}\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#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nattribute highp vec4 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\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;varying highp vec4 v_uv;\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;\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#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];\n#ifdef RENDER_LINE_GRADIENT\nhighp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);\n#else\nv_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\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:pd("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:pd("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:pd("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_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform 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 bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;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;uniform vec3 u_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying 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_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];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;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(tile_anchor,0)+h;float globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.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 font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);vec4 offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\nvec4 offsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetProjected_point.xy/offsetProjected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,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_min_font_scale,font_scale)+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(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat 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:pd("#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_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform 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 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_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying 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[3];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;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(tile_anchor,0)+h;float globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.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) {\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);vec4 offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\nvec4 offsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,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(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat 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:pd("#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_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform 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 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_up_vector;uniform vec2 u_texsize_icon;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying 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[3];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;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(tile_anchor,0)+h;float globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.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 font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,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*font_scale);\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(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat 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:pd("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nvarying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef RENDER_SHADOWS\ncolor.xyz=shadowed_color(color.xyz,v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#endif\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\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;\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#ifdef RENDER_SHADOWS\nvec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);v_depth=gl_Position.w;\n#endif\n}"),terrainDepth:pd("#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:pd("\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}",ed),skyboxGradient:pd("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}",ed),skyboxCapture:pd("\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:pd("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifndef FOG\nuniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;\n#endif\nvoid main() {\n#ifdef CUSTOM_ANTIALIASING\nvec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture2D(u_image0,v_pos0);vec4 color=vec4(raster.rgb*antialias,raster.a*antialias);\n#else\nvec4 color=texture2D(u_image0,v_pos0);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\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_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;\n#ifdef GLOBE_POLES\nattribute vec3 a_globe_pos;attribute vec2 a_uv;\n#else\nattribute vec2 a_pos;\n#endif\nvarying vec2 v_pos0;const float wireframeOffset=1e3;float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(QUARTER_PI+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}void main() {\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;vec2 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idy=u_grid_matrix[1][2];float S=u_grid_matrix[2][2];vec3 latLng=u_grid_matrix*vec3(a_pos,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=a_pos[0]*S;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;vec2 tile_pos=uv*EXTENT;\n#ifdef GLOBE_POLES\nvec3 up_vector=normalize(globe_pos)*u_tile_up_scale;\n#else\nvec3 up_vector=elevationVector(tile_pos);\n#endif\nfloat height=elevation(tile_pos);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nglobe_pos+=up_vector*height;\n#ifdef GLOBE_POLES\nvec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);\n#else\nvec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);\n#endif\ngl_Position=u_proj_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}"),globeAtmosphere:pd("uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec3 u_start_color;uniform vec4 u_color;uniform vec4 u_space_color;uniform vec4 u_high_color;uniform float u_star_intensity;uniform float u_star_size;uniform float u_star_density;uniform float u_horizon_angle;uniform mat4 u_rotation_matrix;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;highp float random(highp vec3 p) {p=fract(p*vec3(23.2342,97.1231,91.2342));p+=dot(p.zxy,p.yxz+123.1234);return fract(p.x*p.y);}float stars(vec3 p,float scale,vec2 offset) {vec2 uv_scale=(u_viewport/u_star_size)*scale;vec3 position=vec3(p.xy*uv_scale+offset*u_viewport,p.z);vec3 q=fract(position)-0.5;vec3 id=floor(position);float random_visibility=step(random(id),u_star_density);float circle=smoothstep(0.5+u_star_intensity,0.5,length(q));return circle*random_visibility;}void main() {highp vec3 dir=normalize(v_ray_dir);\n#ifdef PROJECTION_GLOBE_VIEW\nfloat globe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {discard;return;}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(dot(dir,horizon_dir)),0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nhighp vec3 closest_point=globe_pos_dot_dir*dir;float closest_point_to_center=length(closest_point-u_globe_pos);float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));float horizon_angle=globe_pos_dot_dir < 0.0 ?\nPI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);\n#else\nfloat horizon_angle=horizon_angle_mercator;\n#endif\nhorizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;vec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c =mix(color_stop_2,c2,t);float a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);vec2 uv=gl_FragCoord.xy/u_viewport-0.5;float aspect_ratio=u_viewport.x/u_viewport.y;vec4 uv_dir=vec4(normalize(vec3(uv.x*aspect_ratio,uv.y,1.0)),1.0);uv_dir=u_rotation_matrix*uv_dir;vec3 n=abs(uv_dir.xyz);vec2 uv_remap=(n.x > n.y && n.x > n.z) ? uv_dir.yz/uv_dir.x:\n(n.y > n.x && n.y > n.z) ? uv_dir.zx/uv_dir.y:\nuv_dir.xy/uv_dir.z;uv_remap.x/=aspect_ratio;vec3 D=vec3(uv_remap,1.0);highp float star_field=0.0;if (u_star_intensity > 0.0) {star_field+=stars(D,1.2,vec2(0.0,0.0));star_field+=stars(D,1.0,vec2(1.0,0.0));star_field+=stars(D,0.8,vec2(0.0,1.0));star_field+=stars(D,0.6,vec2(1.0,1.0));star_field*=(1.0-pow(t,0.25+(1.0-u_high_color.a)*0.75));c+=star_field*alpha_2;}c=dither(c,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=vec4(c,a);}","attribute vec3 a_pos;attribute vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(\nmix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}")};function hd(e,t){const i=e.replace(/\s*\/\/[^\n]*\n/g,"\n").split("\n");for(let e of i)if(e=e.trim(),"#"===e[0]&&e.includes("if")&&!e.includes("endif")){e=e.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const i=e.split(" ");for(const e of i)t.includes(e)||t.push(e)}}function pd(e,t){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),n={},o=[...ad];return hd(e,o),hd(t,o),{fragmentSource:e=e.replace(i,((e,t,i,r,o)=>(n[o]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nvarying ${i} ${r} ${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = u_${o};\n#endif\n`))),vertexSource:t=t.replace(i,((e,t,i,r,o)=>{const a="float"===r?"vec2":"vec4",s=o.match(/color/)?"color":a;return n[o]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nattribute ${i} ${a} a_${o};\nvarying ${i} ${r} ${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = a_${o};\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nattribute ${i} ${a} a_${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = a_${o};\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`})),staticAttributes:r,usedDefines:o}}class VertexArrayObject{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(e,t,i,r,n,o,a){this.context=e;let s=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!s&&e<r.length;e++)this.boundPaintVertexBuffers[e]!==r[e]&&(s=!0);let l=this.boundDynamicVertexBuffers.length!==a.length;for(let e=0;!l&&e<a.length;e++)this.boundDynamicVertexBuffers[e]!==a[e]&&(l=!0);if(!e.extVertexArrayObject||!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==i||s||l||this.boundIndexBuffer!==n||this.boundVertexOffset!==o)this.freshBind(t,i,r,n,o,a);else{e.bindVertexArrayOES.set(this.vao);for(const e of a)e&&e.bind();n&&n.dynamicDraw&&n.bind()}}freshBind(e,t,i,r,n,o){let a;const s=e.numAttributes,l=this.context,c=l.gl;if(l.extVertexArrayObject)this.vao&&this.destroy(),this.vao=l.extVertexArrayObject.createVertexArrayOES(),l.bindVertexArrayOES.set(this.vao),a=0,this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=r,this.boundVertexOffset=n,this.boundDynamicVertexBuffers=o;else{a=l.currentNumAttributes||0;for(let e=s;e<a;e++)c.disableVertexAttribArray(e)}t.enableAttributes(c,e),t.bind(),t.setVertexAttribPointers(c,e,n);for(const t of i)t.enableAttributes(c,e),t.bind(),t.setVertexAttribPointers(c,e,n);for(const t of o)t&&(t.enableAttributes(c,e),t.bind(),t.setVertexAttribPointers(c,e,n));r&&r.bind(),l.currentNumAttributes=s}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}function dd(e,t){const i=Math.pow(2,t.canonical.z),r=t.canonical.y;return[new MercatorCoordinate(0,r/i).toLngLat().lat,new MercatorCoordinate(0,(r+1)/i).toLngLat().lat]}function fd(e,t,i,r,n,o,a){const s=e.context,l=s.gl,c=i.fbo;if(!c)return;e.prepareDrawTile();const u=e.useProgram("hillshade");s.activeTexture.set(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,c.colorAttachment.get());const h=((e,t,i,r)=>{const n=i.paint.get("hillshade-shadow-color"),o=i.paint.get("hillshade-highlight-color"),a=i.paint.get("hillshade-accent-color");let s=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===i.paint.get("hillshade-illumination-anchor")&&(s-=e.transform.angle);const l=!e.options.moving;return{u_matrix:r||e.transform.calculateProjMatrix(t.tileID.toUnwrapped(),l),u_image:0,u_latrange:dd(0,t.tileID),u_light:[i.paint.get("hillshade-exaggeration"),s],u_shadow:n,u_highlight:o,u_accent:a}})(e,i,r,e.terrain?t.projMatrix:null);e.prepareDrawProgram(s,u,t.toUnwrapped());const{tileBoundsBuffer:p,tileBoundsIndexBuffer:d,tileBoundsSegments:f}=e.getTileBoundsBuffers(i);u.draw(s,l.TRIANGLES,n,o,a,CullFaceMode.disabled,h,r.id,p,d,f)}function md(e,t,i){if(!t.needsDEMTextureUpload)return;const r=e.context,n=r.gl;r.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||e.getTileTexture(i.stride);const o=i.getPixels();t.demTexture?t.demTexture.update(o,{premultiply:!1}):t.demTexture=new Texture(r,o,n.RGBA,{premultiply:!1}),t.needsDEMTextureUpload=!1}function _d(e,t,i,r,n,o){const a=e.context,s=a.gl;if(!t.dem)return;const l=t.dem;if(a.activeTexture.set(s.TEXTURE1),md(e,t,l),!t.demTexture)return;t.demTexture.bind(s.NEAREST,s.CLAMP_TO_EDGE);const c=l.dim;a.activeTexture.set(s.TEXTURE0);let u=t.fbo;if(!u){const e=new Texture(a,{width:c,height:c,data:null},s.RGBA);e.bind(s.LINEAR,s.CLAMP_TO_EDGE),u=t.fbo=a.createFramebuffer(c,c,!0),u.colorAttachment.set(e.texture)}a.bindFramebuffer.set(u.framebuffer),a.viewport.set([0,0,c,c]);const{tileBoundsBuffer:h,tileBoundsIndexBuffer:p,tileBoundsSegments:d}=e.getMercatorTileBoundsBuffers();e.useProgram("hillshadePrepare").draw(a,s.TRIANGLES,r,n,o,CullFaceMode.disabled,((e,t)=>{const i=t.stride,r=ga();return Pa(r,0,Eo,-8192,0,0,1),ba(r,r,[0,-8192,0]),{u_matrix:r,u_image:1,u_dimension:[i,i],u_zoom:e.overscaledZ,u_unpack:t.unpackVector}})(t.tileID,l),i.id,h,p,d),t.needsHillshadePrepare=!1}const gd=e=>({u_matrix:new UniformMatrix4f(e),u_image0:new Uniform1i(e),u_skirt_height:new Uniform1f(e)}),yd=(e,t)=>({u_matrix:e,u_image0:0,u_skirt_height:t}),xd=(e,t,i,r,n,o,a,s,l,c,u,h,p,d)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(r),u_merc_matrix:i,u_zoom_transition:n,u_merc_center:o,u_image0:0,u_frustum_tl:a,u_frustum_tr:s,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:u,u_globe_radius:h,u_viewport:p,u_grid_matrix:d?Float32Array.from(d):new Float32Array(9)});function vd(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const bd=new class VertexMorphing{constructor(){this.operations={}}newMorphing(e,t,i,r,n){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==i.tileID.key&&(t.queued=i)}else this.operations[e]={startTime:r,phase:0,duration:n,from:t,to:i,queued:null}}getMorphValuesForProxy(e){if(!(e in this.operations))return null;const t=this.operations[e];return{from:t.from,to:t.to,phase:t.phase}}update(e){for(const t in this.operations){const i=this.operations[t];for(i.phase=(e-i.startTime)/i.duration;i.phase>=1||!this._validOp(i);)if(!this._nextOp(i,e)){delete this.operations[t];break}}}_nextOp(e,t){return!!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=t,!0)}_validOp(e){return e.from.hasData()&&e.to.hasData()}},wd={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function Td(e,t){const i=1<<e.z;return!t&&(0===e.x||e.x===i-1)||0===e.y||e.y===i-1}const Ed=e=>({u_matrix:e});function Sd(e,t,i,r,n){if(n>0){const o=ee.now(),a=(o-e.timeAdded)/n,s=t?(o-t.timeAdded)/n:-1,l=i.getSource(),c=r.coveringZoomLevel({tileSize:l.tileSize,roundZoom:l.roundZoom}),u=!t||Math.abs(t.tileID.overscaledZ-c)>Math.abs(e.tileID.overscaledZ-c),h=u&&e.refreshedUponExpiration?1:_(u?a:1-s,0,1);return e.refreshedUponExpiration&&a>=1&&(e.refreshedUponExpiration=!1),t?{opacity:1,mix:1-h}:{opacity:h,mix:0}}return{opacity:1,mix:0}}class MockSourceCache extends SourceCache{constructor(e){const t={type:"raster-dem",maxzoom:e.transform.maxZoom},i=new Dispatcher(ip(),null),r=Hh("mock-dem",t,i,e.style);super("mock-dem",r,!1),r.setEventedParent(this),this._sourceLoaded=!0}_loadTile(e,t){e.state="loaded",t(null)}}class ProxySourceCache extends SourceCache{constructor(e){const t=Hh("proxy",{type:"geojson",maxzoom:e.transform.maxZoom},new Dispatcher(ip(),null),e.style);super("proxy",t,!1),t.setEventedParent(this),this.map=this.getSource().map=e,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(e,t,i){if(e.freezeTileCoverage)return;this.transform=e;const r=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce(((t,i)=>{if(t[i.key]="",!this._tiles[i.key]){const t=new Tile(i,this._source.tileSize*i.overscaleFactor(),e.tileZoom);t.state="loaded",this._tiles[i.key]=t}return t}),{});for(const e in this._tiles)e in r||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e])}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const i=Object.values(t);this.renderCachePool.push(...i),delete this.proxyCachedFBO[e]}}deallocRenderCache(){this.renderCache.forEach((e=>e.fb.destroy())),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class ProxiedTileID extends OverscaledTileID{constructor(e,t,i){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=t,this.projMatrix=i}}class Terrain extends class Elevation{isDataAvailableAtPoint(e){const t=this._source();if(!t||e.y<0||e.y>1)return!1;const i=t.getSource().maxzoom,r=1<<i,n=Math.floor(e.x),o=Math.floor((e.x-n)*r),a=Math.floor(e.y*r),s=this.findDEMTileFor(new OverscaledTileID(i,n,i,o,a));return!(!s||!s.dem)}getAtPointOrZero(e,t=0){return this.getAtPoint(e,t)||0}getAtPoint(e,t,i=!0){null==t&&(t=null);const r=this._source();if(!r)return t;if(e.y<0||e.y>1)return t;const n=r.getSource().maxzoom,o=1<<n,a=Math.floor(e.x),s=e.x-a,l=new OverscaledTileID(n,a,n,Math.floor(s*o),Math.floor(e.y*o)),c=this.findDEMTileFor(l);if(!c||!c.dem)return t;const u=c.dem,h=1<<c.tileID.canonical.z,p=(s*h-c.tileID.canonical.x)*u.dim,d=(e.y*h-c.tileID.canonical.y)*u.dim,f=Math.floor(p),m=Math.floor(d);return(i?this.exaggeration():1)*xi(xi(u.get(f,m),u.get(f,m+1),d-m),xi(u.get(f+1,m),u.get(f+1,m+1),d-m),p-f)}getAtTileOffset(e,t,i){const r=1<<e.canonical.z;return this.getAtPointOrZero(new MercatorCoordinate(e.wrap+(e.canonical.x+t/Eo)/r,(e.canonical.y+i/Eo)/r))}getAtTileOffsetFunc(e,t,i,r){return n=>{const o=this.getAtTileOffset(e,n.x,n.y),a=r.upVector(e.canonical,n.x,n.y);return ja(a,a,o*r.upVectorScale(e.canonical,t,i).metersToTile),a}}getForTilePoints(e,t,i,r){const n=DEMSampler.create(this,e,r);return!!n&&(t.forEach((e=>{e[2]=this.exaggeration()*n.getElevationAt(e[0],e[1],i)})),!0)}getMinMaxForTile(e){const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const i=t.dem.tree,r=t.tileID,n=1<<e.canonical.z-r.canonical.z;let o=e.canonical.x/n-r.canonical.x,a=e.canonical.y/n-r.canonical.y,s=0;for(let t=0;t<e.canonical.z-r.canonical.z&&!i.leaves[s];t++){o*=2,a*=2;const e=2*Math.floor(a)+Math.floor(o);s=i.childOffsets[s]+e,o%=1,a%=1}return{min:this.exaggeration()*i.minimums[s],max:this.exaggeration()*i.maximums[s]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(e,t,i){throw new Error("Pure virtual method called.")}pointCoordinate(e){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(e){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}}{constructor(e,t){super(),this.painter=e,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[i,r,n]=function(e){const t=new StructArrayLayout4i8,i=new StructArrayLayout3ui6,r=131;t.reserve(17161),i.reserve(33800);for(let e=-64;e<8288;e+=64)for(let i=-64;i<8288;i+=64){const r=i<0||i>8224||e<0||e>8224?24575:0,n=_(Math.round(i),0,Eo),o=_(Math.round(e),0,Eo);t.emplaceBack(n+r,o,n,o)}const n=(e,t)=>{const n=t*r+e;i.emplaceBack(n+1,n,n+r),i.emplaceBack(n+r,n+r+1,n+1)};for(let e=1;e<129;e++)for(let t=1;t<129;t++)n(t,e);return[0,129].forEach((e=>{for(let t=0;t<130;t++)n(t,e),n(e,t)})),[t,i,32768]}(),o=e.context;this.gridBuffer=o.createVertexBuffer(i,Ah.members),this.gridIndexBuffer=o.createIndexBuffer(r),this.gridSegments=SegmentVector.simpleSegment(0,0,i.length,r.length),this.gridNoSkirtSegments=SegmentVector.simpleSegment(0,0,i.length,n),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new ProxySourceCache(t.map),this.orthoMatrix=ga(),Pa(this.orthoMatrix,0,Eo,0,Eo,0,1);const a=o.gl;this._overlapStencilMode=new StencilMode({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=e.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=t,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new MockSourceCache(t.map)}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),e.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=e,this._checkRenderCacheEfficiency()}update(e,t,i){if(e&&e.terrain){this._style!==e&&(this.style=e),this.enabled=!0;const r=e.terrain.properties;this.sourceCache=0===e.terrain.drapeRenderMode?this._mockSourceCache:e._getSourceCache(r.get("source")),this._exaggeration=r.get("exaggeration");const n=()=>{this.sourceCache.used&&B(`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 e=this.getScaledDemTileSize();this.sourceCache.update(t,e,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,n(),this._initializing=!0),n(),t.updateElevation(!i),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(t),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(e){this._findCoveringTileCache[e]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const e=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||100!==e.efficiency&&B(`Terrain render cache efficiency is not optimal (${e.efficiency}%) and performance\n may be affected negatively, consider placing all background, fill and line layers before layer\n with id '${e.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(e){e.coord&&"source"===e.dataType?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const e in this._style._sourceCaches)this._style._sourceCaches[e].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach((e=>e.fb.destroy())),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0)}_source(){return this.enabled?this.sourceCache:null}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const e=2*this.proxySourceCache.getSource().tileSize;return[e,e]}set useVertexMorphing(e){this._useVertexMorphing=e}updateTileBinding(e){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const t=this.proxySourceCache,i=this.painter.transform;this._initializing&&(this._initializing=0===i._centerAltitude&&-1===this.getAtPointOrZero(MercatorCoordinate.fromLngLat(i.center),-1),this._emptyDEMTextureDirty=!this._initializing);const n=this.proxyCoords=t.getIds().map((e=>{const r=t.getTileByID(e).tileID;return r.projMatrix=i.calculateProjMatrix(r.toUnwrapped()),r}));!function(e,t){const i=t.transform.pointCoordinate(t.transform.getCameraPoint()),n=new r(i.x,i.y);e.sort(((e,t)=>{if(t.overscaledZ-e.overscaledZ)return t.overscaledZ-e.overscaledZ;const i=new r(e.canonical.x+(1<<e.canonical.z)*e.wrap,e.canonical.y),o=new r(t.canonical.x+(1<<t.canonical.z)*t.wrap,t.canonical.y),a=n.mult(1<<e.canonical.z);return a.x-=.5,a.y-=.5,a.distSqr(i)-a.distSqr(o)}))}(n,this.painter),this._previousZoom=i.zoom;const o=this.proxyToSource||{};this.proxyToSource={},n.forEach((e=>{this.proxyToSource[e.key]={}})),this.terrainTileForTile={};const a=this._style._sourceCaches;for(const t in a){const i=a[t];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,e[t],o),i.usedForTerrain)continue;const r=e[t];i.getSource().reparseOverscaled&&this._assignTerrainTiles(r)}this.proxiedCoords[t.id]=n.map((e=>new ProxiedTileID(e,e.key,this.orthoMatrix))),this._assignTerrainTiles(n),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(o),this.renderingToTexture=!1,this._updateTimestamp=ee.now();const s={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const i=t.tileID.key;i in s||(this._visibleDemTiles.push(t),s[i]=i)}}_assignTerrainTiles(e){this._initializing||e.forEach((e=>{if(this.terrainTileForTile[e.key])return;const t=this._findTileCoveringTileID(e,this.sourceCache);t&&(this.terrainTileForTile[e.key]=t)}))}_prepareDEMTextures(){const e=this.painter.context,t=e.gl;for(const i in this.terrainTileForTile){const r=this.terrainTileForTile[i],n=r.dem;!n||r.demTexture&&!r.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),md(this.painter,r,n))}}_prepareDemTileUniforms(e,t,i,r){if(!t||null==t.demTexture)return!1;const n=e.tileID.canonical,o=Math.pow(2,t.tileID.canonical.z-n.z),a=r||"";return i[`u_dem_tl${a}`]=[n.x*o%1,n.y*o%1],i[`u_dem_scale${a}`]=o,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const e=this.painter.context,t=e.gl;if(!this._emptyDepthBufferTexture){const i=new RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new Texture(e,i,t.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let e=0;const t=this._visibleDemTiles.reduce(((t,i)=>{if(!i.dem)return t;const r=i.dem.tree.minimums[0];return r>0&&e++,t+r}),0);return e?t/e:0}_updateEmptyDEMTexture(){const e=this.painter.context,t=e.gl;e.activeTexture.set(t.TEXTURE2);const i=this._getLoadedAreaMinimum(),r=new RGBAImage({width:1,height:1},new Uint8Array(DEMData.pack(i,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let n=this._emptyDEMTexture;return n?n.update(r,{premultiply:!1}):n=this._emptyDEMTexture=new Texture(e,r,t.RGBA,{premultiply:!1}),n}setupElevationDraw(e,t,i){const r=this.painter.context,n=r.gl,o=(a=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:DEMData.getUnpackVector(a),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});var a;o.u_dem_size=this.sourceCache.getSource().tileSize,o.u_exaggeration=this.exaggeration();const s=this.painter.transform,l=s.projection,c=e.tileID.canonical;o.u_tile_tl_up=l.upVector(c,0,0),o.u_tile_tr_up=l.upVector(c,Eo,0),o.u_tile_br_up=l.upVector(c,Eo,Eo),o.u_tile_bl_up=l.upVector(c,0,Eo),o.u_tile_up_scale=i&&i.useDenormalizedUpVectorScale?Hc:l.upVectorScale(c,s.center.lat,s.worldSize).metersToTile;let u=null,h=null,p=1;if(i&&i.morphing&&this._useVertexMorphing){const t=i.morphing.srcDemTile,r=i.morphing.dstDemTile;p=i.morphing.phase,t&&r&&(this._prepareDemTileUniforms(e,t,o,"_prev")&&(h=t),this._prepareDemTileUniforms(e,r,o)&&(u=r))}if(h&&u?(r.activeTexture.set(n.TEXTURE2),u.demTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE,n.NEAREST),r.activeTexture.set(n.TEXTURE4),h.demTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE,n.NEAREST),o.u_dem_lerp=p):(u=this.terrainTileForTile[e.tileID.key],r.activeTexture.set(n.TEXTURE2),(this._prepareDemTileUniforms(e,u,o)?u.demTexture:this.emptyDEMTexture).bind(n.NEAREST,n.CLAMP_TO_EDGE)),r.activeTexture.set(n.TEXTURE3),i&&i.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE),this._depthFBO&&(o.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE),o.u_depth_size_inv=[1,1]),i&&i.useMeterToDem&&u){const e=(1<<u.tileID.canonical.z)*Po(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;o.u_meter_to_dem=e}i&&i.labelPlaneMatrixInv&&(o.u_label_plane_matrix_inv=i.labelPlaneMatrixInv),t.setTerrainUniformValues(r,o)}renderToBackBuffer(e){const t=this.painter,i=this.painter.context;0!==e.length&&(i.bindFramebuffer.set(null),i.viewport.set([0,0,t.width,t.height]),t.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(e,t,i,r,n){if("globe"===e.transform.projection.name)!function(e,t,i,r,n){const o=e.context,a=o.gl;let s,l;const c=e.options.showTerrainWireframe?2:0,u=e.transform,p=yu(e,o,u),d=(t,i)=>{if(l===t)return;const r=[wd[t],"PROJECTION_GLOBE_VIEW"];p&&r.push("CUSTOM_ANTIALIASING"),i&&r.push(wd[c]),s=e.useProgram("globeRaster",null,r),l=t},f=e.colorModeForRenderPass(),m=new DepthMode(a.LEQUAL,DepthMode.ReadWrite,e.depthRangeFor3D);bd.update(n);const _=function(e){const t=e.pixelsPerMeter,i=t/Po(1,e.center.lat),r=ya(new Float64Array(16));return ba(r,r,[e.point.x,e.point.y,0]),wa(r,r,[i,i,t]),Float32Array.from(r)}(u),g=[Io(u.center.lng),Mo(u.center.lat)],y=c?[!1,!0]:[!1],x=e.globeSharedBuffers,v=[u.width*ee.devicePixelRatio,u.height*ee.devicePixelRatio],b=Float32Array.from(u.globeMatrix),w={useDenormalizedUpVectorScale:!0};if(y.forEach((c=>{l=-1;const p=c?a.LINES:a.TRIANGLES;for(const l of r){const r=i.getTile(l),y=StencilMode.disabled,T=t.prevTerrainTileForTile[l.key],E=t.terrainTileForTile[l.key];vd(T,E)&&bd.newMorphing(l.key,T,E,n,250),o.activeTexture.set(a.TEXTURE0),r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const S=bd.getMorphValuesForProxy(l.key),A=S?1:0;S&&ut(w,{morphing:{srcDemTile:S.from,dstDemTile:S.to,phase:h(S.phase)}});const C=ou(l.canonical),I=vu(C.getCenter().lat),M=xu(l.canonical,C,I),P=pu(tu(l.canonical)),D=xd(u.projMatrix,b,_,P,_u(u.zoom),g,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,v,M);if(d(A,c),t.setupElevationDraw(r,s,w),e.prepareDrawProgram(o,s,l.toUnwrapped()),x){const[t,i,r]=c?x.getWirefameBuffers(e.context,I):x.getGridBuffers(I);s.draw(o,p,m,y,f,CullFaceMode.backCCW,D,"globe_raster",t,i,r)}}})),x){const n=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];p&&n.push("CUSTOM_ANTIALIASING"),s=e.useProgram("globeRaster",null,n);for(const n of r){const{x:r,y:l,z:c}=n.canonical,h=0===l,p=l===(1<<c)-1,[d,_,y,b]=x.getPoleBuffers(c);if(b&&(h||p)){const l=i.getTile(n);o.activeTexture.set(a.TEXTURE0),l.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);let x=gu(c,r,u);const T=pu(tu(n.canonical)),E=(e,t)=>e.draw(o,a.TRIANGLES,m,StencilMode.disabled,f,CullFaceMode.disabled,xd(u.projMatrix,x,x,T,0,g,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,v),"globe_pole_raster",t,y,b);t.setupElevationDraw(l,s,w),e.prepareDrawProgram(o,s,n.toUnwrapped()),h&&E(s,d),p&&(x=wa(ga(),x,[1,-1,1]),E(s,_))}}}}(e,t,i,r,n);else{const o=e.context,a=o.gl;let s,l;const c=e.options.showTerrainWireframe?2:0,u=(t,i)=>{if(l===t)return;const r=[wd[t]];i&&r.push(wd[c]),s=e.useProgram("terrainRaster",null,r),l=t},p=e.colorModeForRenderPass(),d=new DepthMode(a.LEQUAL,DepthMode.ReadWrite,e.depthRangeFor3D);bd.update(n);const f=e.transform,m=6*Math.pow(1.5,22-f.zoom)*t.exaggeration();(c?[!1,!0]:[!1]).forEach((c=>{l=-1;const _=c?a.LINES:a.TRIANGLES,[g,y]=c?t.getWirefameBuffer():[t.gridIndexBuffer,t.gridSegments];for(const l of r){const r=i.getTile(l),x=StencilMode.disabled,v=t.prevTerrainTileForTile[l.key],b=t.terrainTileForTile[l.key];vd(v,b)&&bd.newMorphing(l.key,v,b,n,250),o.activeTexture.set(a.TEXTURE0),r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE,a.LINEAR_MIPMAP_NEAREST);const w=bd.getMorphValuesForProxy(l.key),T=w?1:0;let E;w&&(E={morphing:{srcDemTile:w.from,dstDemTile:w.to,phase:h(w.phase)}});const S=yd(l.projMatrix,Td(l.canonical,f.renderWorldCopies)?m/10:m);u(T,c),t.setupElevationDraw(r,s,E),e.prepareDrawProgram(o,s,l.toUnwrapped()),s.draw(o,_,d,x,p,CullFaceMode.backCCW,S,"terrain_raster",t.gridBuffer,g,y)}}))}}(t,this,this.proxySourceCache,e,this._updateTimestamp),this.renderingToTexture=!0,t.gpuTimingDeferredRenderEnd(),e.splice(0,e.length))}renderBatch(e){if(0===this._drapedRenderBatches.length)return e+1;this.renderingToTexture=!0;const t=this.painter,i=this.painter.context,r=this.proxySourceCache,n=this.proxiedCoords[r.id],o=this._drapedRenderBatches.shift(),a=[],s=t.style.order;let l=0;for(const c of n){const n=r.getTileByID(c.proxyTileKey),u=r.proxyCachedFBO[c.key]?r.proxyCachedFBO[c.key][e]:void 0,h=void 0!==u?r.renderCache[u]:this.pool[l++],p=void 0!==u;if(n.texture=h.tex,p&&!h.dirty){a.push(n.tileID);continue}let d;i.bindFramebuffer.set(h.fb.framebuffer),this.renderedToTile=!1,h.dirty&&(i.clear({color:Lt.transparent,stencil:0}),h.dirty=!1);for(let e=o.start;e<=o.end;++e){const r=t.style._layers[s[e]];if(r.isHidden(t.transform.zoom))continue;const n=t.style._getLayerSourceCache(r),o=n?this.proxyToSource[c.key][n.id]:[c];if(!o)continue;const a=o;i.viewport.set([0,0,h.fb.width,h.fb.height]),d!==(n?n.id:null)&&(this._setupStencil(h,o,r,n),d=n?n.id:null),t.renderLayer(t,n,r,a)}this.renderedToTile?(h.dirty=!0,a.push(n.tileID)):p||--l,5===l&&(l=0,this.renderToBackBuffer(a))}return this.renderToBackBuffer(a),this.renderingToTexture=!1,i.bindFramebuffer.set(null),i.viewport.set([0,0,t.width,t.height]),o.end+1}postRender(){}renderCacheEfficiency(e){const t=e.order.length;if(0===t)return{efficiency:100};let i,r=0,n=0,o=!1;for(let a=0;a<t;++a){const t=e._layers[e.order[a]];this._style.isLayerDraped(t)?(o&&++r,++n):o||(o=!0,i=t.id)}return 0===n?{efficiency:100}:{efficiency:100*(1-r/n),firstUndrapedLayer:i}}getMinElevationBelowMSL(){let e=0;return this._visibleDemTiles.filter((e=>e.dem)).forEach((t=>{e=Math.min(e,t.dem.tree.minimums[0])})),0===e?e:(e-30)*this._exaggeration}raycast(e,t,i){if(!this._visibleDemTiles)return null;const r=this._visibleDemTiles.filter((e=>e.dem)).map((r=>{const n=r.tileID,o=1<<n.overscaledZ,{x:a,y:s}=n.canonical,l=a/o,c=(a+1)/o,u=s/o,h=(s+1)/o;return{minx:l,miny:u,maxx:c,maxy:h,t:r.dem.tree.raycastRoot(l,u,c,h,e,t,i),tile:r}}));r.sort(((e,t)=>(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE)));for(const n of r){if(null==n.t)return null;const r=n.tile.dem.tree.raycast(n.minx,n.miny,n.maxx,n.maxy,e,t,i);if(null!=r)return r}return null}_createFBO(){const e=this.painter.context,t=e.gl,i=this.drapeBufferSize;e.activeTexture.set(t.TEXTURE0);const r=new Texture(e,{width:i[0],height:i[1],data:null},t.RGBA);r.bind(t.LINEAR,t.CLAMP_TO_EDGE);const n=e.createFramebuffer(i[0],i[1],!1);return n.colorAttachment.set(r.texture),n.depthAttachment=new DepthStencilAttachment(e,n.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=e.createRenderbuffer(e.gl.DEPTH_STENCIL,i[0],i[1]),this._stencilRef=0,n.depthAttachment.set(this._sharedDepthStencil),e.clear({stencil:0})):n.depthAttachment.set(this._sharedDepthStencil),e.extTextureFilterAnisotropic&&!e.extTextureFilterAnisotropicForceOff&&t.texParameterf(t.TEXTURE_2D,e.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,e.extTextureFilterAnisotropicMax),{fb:n,tex:r,dirty:!1}}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._style.light&&this._style.light.hasTransition())return!0;for(const e in this._style._sourceCaches)if(this._style._sourceCaches[e].hasTransition())return!0;return this._style.order.some((e=>{const t=this._style._layers[e],i=t.isHidden(this.painter.transform.zoom),r=t.getCrossfadeParameters(),n=!!r&&1!==r.t,o=t.hasTransition();return"custom"!==t.type&&!i&&(n||o)}))}_clearRasterFadeFromRenderCache(){let e=!1;for(const t in this._style._sourceCaches)if(this._style._sourceCaches[t]._source instanceof RasterTileSource){e=!0;break}if(e)for(let e=0;e<this._style.order.length;++e){const t=this._style._layers[this._style.order[e]],i=t.isHidden(this.painter.transform.zoom),r=this._style._getLayerSourceCache(t);if("raster"!==t.type||i||!r)continue;const n=t.paint.get("raster-fade-duration");for(const e of this.proxyCoords){const t=this.proxyToSource[e.key][r.id];if(t)for(const e of t){const t=Sd(r.getTile(e),r.findLoadedParent(e,0),r,this.painter.transform,n);(1!==t.opacity||0!==t.mix)&&this._clearRenderCacheForTile(r.id,e)}}}}_setupDrapedRenderBatches(){const e=this._style.order,t=e.length;if(0===t)return;const i=[];let r,n=0,o=this._style._layers[e[n]];for(;!this._style.isLayerDraped(o)&&o.isHidden(this.painter.transform.zoom)&&++n<t;)o=this._style._layers[e[n]];for(;n<t;++n){const t=this._style._layers[e[n]];t.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(t)?void 0===r&&(r=n):void 0!==r&&(i.push({start:r,end:n-1}),r=void 0))}void 0!==r&&i.push({start:r,end:n-1}),this._drapedRenderBatches=i}_setupRenderCache(e){const t=this.proxySourceCache;if(this._shouldDisableRenderCache()||this._invalidateRenderCache){if(this._invalidateRenderCache=!1,t.renderCache.length>t.renderCachePool.length){const e=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(let i=0;i<e.length;++i){const r=Object.values(e[i]);t.renderCachePool.push(...r)}}return}this._clearRasterFadeFromRenderCache();const i=this.proxyCoords,r=this._tilesDirty;for(let n=i.length-1;n>=0;n--){const o=i[n];if(t.getTileByID(o.key),void 0!==t.proxyCachedFBO[o.key]){const i=e[o.key],n=this.proxyToSource[o.key];let a=0;for(const e in n){const t=n[e],o=i[e];if(!o||o.length!==t.length||t.some(((t,i)=>t!==o[i]||r[e]&&r[e].hasOwnProperty(t.key)))){a=-1;break}++a}for(const e in t.proxyCachedFBO[o.key])t.renderCache[t.proxyCachedFBO[o.key][e]].dirty=a<0||a!==Object.values(i).length}}const n=[...this._drapedRenderBatches];n.sort(((e,t)=>t.end-t.start-(e.end-e.start)));for(const e of n)for(const r of i){if(t.proxyCachedFBO[r.key])continue;let i=t.renderCachePool.pop();void 0===i&&t.renderCache.length<50&&(i=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==i&&(t.proxyCachedFBO[r.key]={},t.proxyCachedFBO[r.key][e.start]=i,t.renderCache[i].dirty=!0)}this._tilesDirty={}}_setupStencil(e,t,i,r){if(!r||!this._sourceTilesOverlap[r.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const n=this.painter.context,o=n.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let a;if(i.isTileClipped())a=t.length,this._overlapStencilMode.test={func:o.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);a=1,this._overlapStencilMode.test={func:o.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+a>255&&(n.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=a,this._overlapStencilMode.ref=this._stencilRef,i.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(e){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[e.key]),this._overlapStencilMode):StencilMode.disabled}_renderTileClippingMasks(e,t){const i=this.painter,r=this.painter.context,n=r.gl;i._tileClippingMaskIDs={},r.setColorMode(ColorMode.disabled),r.setDepthMode(DepthMode.disabled);const o=i.useProgram("clippingMask");for(const a of e){const e=i._tileClippingMaskIDs[a.key]=--t;o.draw(r,n.TRIANGLES,DepthMode.disabled,new StencilMode({func:n.ALWAYS,mask:0},e,255,n.KEEP,n.KEEP,n.REPLACE),ColorMode.disabled,CullFaceMode.disabled,Ed(a.projMatrix),"$clipping",i.tileExtentBuffer,i.quadTriangleIndexBuffer,i.tileExtentSegments)}}pointCoordinate(e){const t=this.painter.transform;if(e.x<0||e.x>t.width||e.y<0||e.y>t.height)return null;const i=[e.x,e.y,1,1];is(i,i,t.pixelMatrixInverse),ts(i,i,1/i[3]),i[0]/=t.worldSize,i[1]/=t.worldSize;const r=t._camera.position,n=Po(1,t.center.lat),o=[r[0],r[1],r[2]/n,0],a=Fa([],i.slice(0,3),o);Za(a,a);const s=this.raycast(o,a,this._exaggeration);return null!==s&&s?(Na(o,o,a,s),o[3]=o[2],o[2]*=n,o):null}drawDepth(){const e=this.painter,t=e.context,i=this.proxySourceCache,r=Math.ceil(e.width),n=Math.ceil(e.height);if(!this._depthFBO||this._depthFBO.width===r&&this._depthFBO.height===n||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const e=t.gl,i=t.createFramebuffer(r,n,!0);t.activeTexture.set(e.TEXTURE0);const o=new Texture(t,{width:r,height:n,data:null},e.RGBA);o.bind(e.NEAREST,e.CLAMP_TO_EDGE),i.colorAttachment.set(o.texture);const a=t.createRenderbuffer(t.gl.DEPTH_COMPONENT16,r,n);i.depthAttachment.set(a),this._depthFBO=i,this._depthTexture=o}t.bindFramebuffer.set(this._depthFBO.framebuffer),t.viewport.set([0,0,r,n]),function(e,t,i,r){if("globe"===e.transform.projection.name)return;const n=e.context,o=n.gl;n.clear({depth:1});const a=e.useProgram("terrainDepth"),s=new DepthMode(o.LESS,DepthMode.ReadWrite,e.depthRangeFor3D);for(const e of r){const r=i.getTile(e),l=yd(e.projMatrix,0);t.setupElevationDraw(r,a),a.draw(n,o.TRIANGLES,s,StencilMode.disabled,ColorMode.unblended,CullFaceMode.backCCW,l,"terrain_depth",t.gridBuffer,t.gridIndexBuffer,t.gridNoSkirtSegments)}}(e,this,i,this.proxyCoords)}_setupProxiedCoordsForOrtho(e,t,i){if(e.getSource()instanceof ImageSource)return this._setupProxiedCoordsForImageSource(e,t,i);this._findCoveringTileCache[e.id]=this._findCoveringTileCache[e.id]||{};const r=this.proxiedCoords[e.id]=[],n=this.proxyCoords;for(let t=0;t<n.length;t++){const o=n[t],a=this._findTileCoveringTileID(o,e);if(a){const t=this._createProxiedId(o,a,i[o.key]&&i[o.key][e.id]);r.push(t),this.proxyToSource[o.key][e.id]=[t]}}let o=!1;for(let n=0;n<t.length;n++){const a=e.getTile(t[n]);if(!a||!a.hasData())continue;const s=this._findTileCoveringTileID(a.tileID,this.proxySourceCache);if(s&&s.tileID.canonical.z!==a.tileID.canonical.z){const t=this.proxyToSource[s.tileID.key][e.id],n=this._createProxiedId(s.tileID,a,i[s.tileID.key]&&i[s.tileID.key][e.id]);t?t.splice(t.length-1,0,n):this.proxyToSource[s.tileID.key][e.id]=[n],r.push(n),o=!0}}this._sourceTilesOverlap[e.id]=o}_setupProxiedCoordsForImageSource(e,t,i){if(!e.getSource().loaded())return;const n=this.proxiedCoords[e.id]=[],o=this.proxyCoords,a=e.getSource(),s=new r(a.tileID.x,a.tileID.y)._div(1<<a.tileID.z),l=a.coordinates.map(MercatorCoordinate.fromLngLat).reduce(((e,t)=>(e.min.x=Math.min(e.min.x,t.x-s.x),e.min.y=Math.min(e.min.y,t.y-s.y),e.max.x=Math.max(e.max.x,t.x-s.x),e.max.y=Math.max(e.max.y,t.y-s.y),e)),{min:new r(Number.MAX_VALUE,Number.MAX_VALUE),max:new r(-Number.MAX_VALUE,-Number.MAX_VALUE)}),c=(e,t)=>{const i=e.wrap+e.canonical.x/(1<<e.canonical.z),r=e.canonical.y/(1<<e.canonical.z),n=Eo/(1<<e.canonical.z),o=t.wrap+t.canonical.x/(1<<t.canonical.z),a=t.canonical.y/(1<<t.canonical.z);return i+n<o+l.min.x||i>o+l.max.x||r+n<a+l.min.y||r>a+l.max.y};for(let r=0;r<o.length;r++){const a=o[r];for(let r=0;r<t.length;r++){const o=e.getTile(t[r]);if(!o||!o.hasData())continue;if(c(a,o.tileID))continue;const s=this._createProxiedId(a,o,i[a.key]&&i[a.key][e.id]),l=this.proxyToSource[a.key][e.id];l?l.push(s):this.proxyToSource[a.key][e.id]=[s],n.push(s)}}}_createProxiedId(e,t,i){let r=this.orthoMatrix;if(i){const e=i.find((e=>e.key===t.tileID.key));if(e)return e}if(t.tileID.key!==e.key){const i=e.canonical.z-t.tileID.canonical.z;let n,o,a;r=ga();const s=t.tileID.wrap-e.wrap<<e.overscaledZ;i>0?(n=Eo>>i,o=n*((t.tileID.canonical.x<<i)-e.canonical.x+s),a=n*((t.tileID.canonical.y<<i)-e.canonical.y)):(n=Eo<<-i,o=Eo*(t.tileID.canonical.x-(e.canonical.x+s<<-i)),a=Eo*(t.tileID.canonical.y-(e.canonical.y<<-i))),Pa(r,0,n,0,n,0,1),ba(r,r,[o,a,0])}return new ProxiedTileID(t.tileID,e.key,r)}_findTileCoveringTileID(e,t){let i=t.getTile(e);if(i&&i.hasData())return i;const r=this._findCoveringTileCache[t.id],n=r[e.key];if(i=n?t.getTileByID(n):null,i&&i.hasData()||null===n)return i;let o=i?i.tileID:e,a=o.overscaledZ;const s=t.getSource().minzoom,l=[];if(!n){const r=t.getSource().maxzoom;if(e.canonical.z>=r){const i=e.canonical.z-r;t.getSource().reparseOverscaled?(a=Math.max(e.canonical.z+2,t.transform.tileZoom),o=new OverscaledTileID(a,e.wrap,r,e.canonical.x>>i,e.canonical.y>>i)):0!==i&&(a=r,o=new OverscaledTileID(a,e.wrap,r,e.canonical.x>>i,e.canonical.y>>i))}o.key!==e.key&&(l.push(o.key),i=t.getTile(o))}const c=e=>{l.forEach((t=>{r[t]=e})),l.length=0};for(a-=1;a>=s&&(!i||!i.hasData());a--){i&&c(i.tileID.key);const e=o.calculateScaledKey(a);if(i=t.getTileByID(e),i&&i.hasData())break;const n=r[e];if(null===n)break;void 0===n?l.push(e):i=t.getTileByID(n)}return c(i?i.tileID.key:null),i&&i.hasData()?i:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(e,t){let i=this._tilesDirty[e];i||(i=this._tilesDirty[e]={}),i[t.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const e=function(e){let t=0;const i=new StructArrayLayout2ui4,r=131;for(let e=1;e<129;e++){for(let n=1;n<129;n++)t=e*r+n,i.emplaceBack(t,t+1),i.emplaceBack(t,t+r),i.emplaceBack(t+1,t+r),128===e&&i.emplaceBack(t+r,t+r+1);i.emplaceBack(t+1,t+1+r)}return i}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(e),this.wireframeSegments=SegmentVector.simpleSegment(0,0,this.gridBuffer.length,e.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}class Program{static cacheKey(e,t,i,r){let n=`${t}${r?r.cacheKey:""}`;for(const t of i)e.usedDefines.includes(t)&&(n+=`/${t}`);return n}constructor(e,t,i,r,n,o){const a=e.gl;this.program=a.createProgram();const s=function(e){const t=[];for(let i=0;i<e.length;i++){if(null===e[i])continue;const r=e[i].split(" ");t.push(r.pop())}return t}(i.staticAttributes),l=r?r.getBinderAttributes():[],c=s.concat(l);let u=r?r.defines():[];u=u.concat(o.map((e=>`#define ${e}`)));const h=u.concat(e.extStandardDerivatives?"#extension GL_OES_standard_derivatives : enable\n".concat(cd):cd,cd,ld,sd.fragmentSource,od.fragmentSource,i.fragmentSource).join("\n"),p=u.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",ld,sd.vertexSource,od.vertexSource,nd.vertexSource,i.vertexSource).join("\n"),d=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(d,h),a.compileShader(d),a.attachShader(this.program,d);const f=a.createShader(a.VERTEX_SHADER);if(a.isContextLost())this.failedToCreate=!0;else{a.shaderSource(f,p),a.compileShader(f),a.attachShader(this.program,f),this.attributes={},this.numAttributes=c.length;for(let e=0;e<this.numAttributes;e++)c[e]&&(a.bindAttribLocation(this.program,e,c[e]),this.attributes[c[e]]=e);a.linkProgram(this.program),a.deleteShader(f),a.deleteShader(d),this.fixedUniforms=n(e),this.binderUniforms=r?r.getUniforms(e):[],-1!==o.indexOf("TERRAIN")&&(this.terrainUniforms=(e=>({u_dem:new Uniform1i(e),u_dem_prev:new Uniform1i(e),u_dem_unpack:new Uniform4f(e),u_dem_tl:new Uniform2f(e),u_dem_scale:new Uniform1f(e),u_dem_tl_prev:new Uniform2f(e),u_dem_scale_prev:new Uniform1f(e),u_dem_size:new Uniform1f(e),u_dem_lerp:new Uniform1f(e),u_exaggeration:new Uniform1f(e),u_depth:new Uniform1i(e),u_depth_size_inv:new Uniform2f(e),u_meter_to_dem:new Uniform1f(e),u_label_plane_matrix_inv:new UniformMatrix4f(e),u_tile_tl_up:new Uniform3f(e),u_tile_tr_up:new Uniform3f(e),u_tile_br_up:new Uniform3f(e),u_tile_bl_up:new Uniform3f(e),u_tile_up_scale:new Uniform1f(e)}))(e)),-1!==o.indexOf("FOG")&&(this.fogUniforms=(e=>({u_fog_matrix:new UniformMatrix4f(e),u_fog_range:new Uniform2f(e),u_fog_color:new Uniform4f(e),u_fog_horizon_blend:new Uniform1f(e),u_fog_temporal_offset:new Uniform1f(e),u_frustum_tl:new Uniform3f(e),u_frustum_tr:new Uniform3f(e),u_frustum_br:new Uniform3f(e),u_frustum_bl:new Uniform3f(e),u_globe_pos:new Uniform3f(e),u_globe_radius:new Uniform1f(e),u_globe_transition:new Uniform1f(e),u_is_globe:new Uniform1i(e),u_viewport:new Uniform2f(e)}))(e))}}setTerrainUniformValues(e,t){if(!this.terrainUniforms)return;const i=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e])}}setFogUniformValues(e,t){if(!this.fogUniforms)return;const i=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e])}}draw(e,t,i,r,n,o,a,s,l,c,u,h,p,d,f){const m=e.gl;if(this.failedToCreate)return;e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(r),e.setColorMode(n),e.setCullFace(o);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(this.program,e,a[e]);d&&d.setUniforms(this.program,e,this.binderUniforms,h,{zoom:p});const _={[m.LINES]:2,[m.TRIANGLES]:3,[m.LINE_STRIP]:1}[t];for(const i of u.get()){const r=i.vaos||(i.vaos={});(r[s]||(r[s]=new VertexArrayObject)).bind(e,this,l,d?d.getPaintVertexBuffers():[],c,i.vertexOffset,f||[]),m.drawElements(t,i.primitiveLength*_,m.UNSIGNED_SHORT,i.primitiveOffset*_*2)}}}function Ad(e,t,i){const r=1/dh(i,1,t.transform.tileZoom),n=Math.pow(2,i.tileID.overscaledZ),o=i.tileSize*Math.pow(2,t.transform.tileZoom)/n,a=o*(i.tileID.canonical.x+i.tileID.wrap*n),s=o*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[r,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[a>>16,s>>16],u_pixel_coord_lower:[65535&a,65535&s]}}const Cd=ga(),Id=(e,t,i,r,n,o,a,s,l,c,u)=>{const h=t.style.light,p=h.properties.get("position"),d=[p.x,p.y,p.z],f=fa();var m,_,g,y;"viewport"===h.properties.get("anchor")&&(m=f,_=-t.transform.angle,g=Math.sin(_),y=Math.cos(_),m[0]=y,m[1]=g,m[2]=0,m[3]=-g,m[4]=y,m[5]=0,m[6]=0,m[7]=0,m[8]=1,Ha(d,d,f));const x=h.properties.get("color"),v=t.transform,b={u_matrix:e,u_lightpos:d,u_lightintensity:h.properties.get("intensity"),u_lightcolor:[x.r,x.g,x.b],u_vertical_gradient:+i,u_opacity:r,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Cd,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:n,u_edge_radius:o};return"globe"===v.projection.name&&(b.u_tile_id=[a.canonical.x,a.canonical.y,1<<a.canonical.z],b.u_zoom_transition=l,b.u_inv_rot_matrix=u,b.u_merc_center=c,b.u_up_dir=v.projection.upVector(new CanonicalTileID(0,0,0),c[0]*Eo,c[1]*Eo),b.u_height_lift=s),b},Md=(e,t,i,r,n,o,a,s,l,c,u,h,p)=>{const d=Id(e,t,i,r,n,o,a,c,u,h,p),f={u_height_factor:-Math.pow(2,a.overscaledZ)/l.tileSize/8};return b(d,Ad(s,t,l),f)},Pd=e=>({u_matrix:e}),Dd=(e,t,i,r)=>b(Pd(e),Ad(i,t,r)),zd=(e,t)=>({u_matrix:e,u_world:t}),kd=(e,t,i,r,n)=>b(Dd(e,t,i,r),{u_world:n}),Ld=ga(),Bd=(e,t,i,r,n,o)=>{const a=e.transform,s="globe"===a.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(s){const e=fu(a.zoom,t.canonical)*a._pixelsPerMercatorPixel;l=Float32Array.from([e,0,0,e])}else l=a.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([a.pixelsToGLUnits[0],0,0,a.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:a.cameraToCenterDistance,u_matrix:e.translatePosMatrix(t.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ee.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Ld,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(s){c.u_inv_rot_matrix=r,c.u_merc_center=n,c.u_tile_id=[t.canonical.x,t.canonical.y,1<<t.canonical.z],c.u_zoom_transition=_u(a.zoom);const e=n[0]*Eo,i=n[1]*Eo;c.u_up_dir=a.projection.upVector(new CanonicalTileID(0,0,0),e,i)}return c},Rd=e=>{const t=[];return"map"===e.paint.get("circle-pitch-alignment")&&t.push("PITCH_WITH_MAP"),"map"===e.paint.get("circle-pitch-scale")&&t.push("SCALE_WITH_MAP"),t},Fd=(e,t,i,r)=>{const n=Eo/i.tileSize;return{u_matrix:e,u_camera_to_center_distance:t.getCameraToCenterDistance(r),u_extrude_scale:[t.pixelsToGLUnits[0]/n,t.pixelsToGLUnits[1]/n]}},Od=(e,t,i=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:i}),Vd=ga(),Ud=(e,t,i,r,n,o,a)=>{const s=e.transform,l="globe"===s.projection.name,c=l?fu(s.zoom,t.canonical)*s._pixelsPerMercatorPixel:dh(i,1,o),u={u_matrix:t.projMatrix,u_extrude_scale:c,u_intensity:a,u_inv_rot_matrix:Vd,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(l){u.u_inv_rot_matrix=r,u.u_merc_center=n,u.u_tile_id=[t.canonical.x,t.canonical.y,1<<t.canonical.z],u.u_zoom_transition=_u(s.zoom);const e=n[0]*Eo,i=n[1]*Eo;u.u_up_dir=s.projection.upVector(new CanonicalTileID(0,0,0),e,i)}return u},jd=(e,t,i,r,n,o,a,s)=>{const l=e.transform,c=l.calculatePixelsToTileUnitsMatrix(t),u={u_matrix:Zd(e,t,i,n),u_pixels_to_tile_units:c,u_device_pixel_ratio:a,u_units_to_pixels:[1/l.pixelsToGLUnits[0],1/l.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:o,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0,u_trim_offset:s};if(qd(i)){const i=Gd(t,e.transform);u.u_texsize=t.lineAtlasTexture.size,u.u_scale=[i,r.fromScale,r.toScale],u.u_mix=r.t}return u},Nd=(e,t,i,r,n,o)=>{const a=e.transform,s=Gd(t,a);return{u_matrix:Zd(e,t,i,n),u_texsize:t.imageAtlasTexture.size,u_pixels_to_tile_units:a.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:o,u_image:0,u_scale:[s,r.fromScale,r.toScale],u_fade:r.t,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function Gd(e,t){return 1/dh(e,1,t.tileZoom)}function Zd(e,t,i,r){return e.translatePosMatrix(r||t.tileID.projMatrix,t,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}function qd(e){const t=e.paint.get("line-dasharray").value;return t.value||"constant"!==t.kind}const $d=(e,t,i,r,n,o)=>{return{u_matrix:e,u_tl_parent:t,u_scale_parent:i,u_fade_t:r.mix,u_opacity:r.opacity*n.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:n.paint.get("raster-brightness-min"),u_brightness_high:n.paint.get("raster-brightness-max"),u_saturation_factor:(s=n.paint.get("raster-saturation"),s>0?1-1/(1.001-s):-s),u_contrast_factor:(a=n.paint.get("raster-contrast"),a>0?1/(1-a):1+a),u_spin_weights:Wd(n.paint.get("raster-hue-rotate")),u_perspective_transform:o};var a,s};function Wd(e){e*=Math.PI/180;const t=Math.sin(e),i=Math.cos(e);return[(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}const Hd=ga(),Xd=(e,t,i,r,n,o,a,s,l,c,u,h,p,d,f,m)=>{const _=n.transform,g={u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:_.cameraToCenterDistance,u_rotate_symbol:+i,u_aspect_ratio:_.width/_.height,u_fade_change:n.options.fadeDuration?n.symbolFadeChange:1,u_matrix:o,u_label_plane_matrix:a,u_coord_matrix:s,u_is_text:+l,u_pitch_with_map:+r,u_texsize:c,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Hd,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Hd,u_up_vector:[0,-1,0]};return"globe"===m.name&&(g.u_tile_id=[u.canonical.x,u.canonical.y,1<<u.canonical.z],g.u_zoom_transition=h,g.u_inv_rot_matrix=d,g.u_merc_center=p,g.u_camera_forward=_._camera.forward(),g.u_ecef_origin=function(e,t){const i=[0,0,0];return Wa(i,i,pu(tu(t.canonical))),Wa(i,i,e),i}(_.globeMatrix,u.toUnwrapped()),g.u_tile_matrix=Float32Array.from(_.globeMatrix),g.u_up_vector=f),g},Kd=(e,t,i,r,n,o,a,s,l,c,u,h,p,d,f,m,_)=>b(Xd(e,t,i,r,n,o,a,s,l,c,h,p,d,f,m,_),{u_gamma_scale:r?n.transform.cameraToCenterDistance*Math.cos(n.terrain?0:n.transform._pitch):1,u_device_pixel_ratio:ee.devicePixelRatio,u_is_halo:+u}),Jd=(e,t,i,r,n,o,a,s,l,c,u,h,p,d,f,m)=>b(Kd(e,t,i,r,n,o,a,s,!0,l,!0,u,h,p,d,f,m),{u_texsize_icon:c,u_texture_icon:1}),Yd=(e,t,i)=>({u_matrix:e,u_opacity:t,u_color:i}),Qd=(e,t,i,r,n,o)=>b(function(e,t,i,r){const n=i.imageManager.getPattern(e.from.toString()),o=i.imageManager.getPattern(e.to.toString()),{width:a,height:s}=i.imageManager.getPixelSize(),l=Math.pow(2,r.tileID.overscaledZ),c=r.tileSize*Math.pow(2,i.transform.tileZoom)/l,u=c*(r.tileID.canonical.x+r.tileID.wrap*l),h=c*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:n.tl,u_pattern_br_a:n.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[a,s],u_mix:t.t,u_pattern_size_a:n.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:t.fromScale,u_scale_b:t.toScale,u_tile_units_to_pixels:1/dh(r,1,i.transform.tileZoom),u_pixel_coord_upper:[u>>16,h>>16],u_pixel_coord_lower:[65535&u,65535&h]}}(r,o,i,n),{u_matrix:e,u_opacity:t}),ef={fillExtrusion:e=>({u_matrix:new UniformMatrix4f(e),u_lightpos:new Uniform3f(e),u_lightintensity:new Uniform1f(e),u_lightcolor:new Uniform3f(e),u_vertical_gradient:new Uniform1f(e),u_opacity:new Uniform1f(e),u_edge_radius:new Uniform1f(e),u_ao:new Uniform2f(e),u_tile_id:new Uniform3f(e),u_zoom_transition:new Uniform1f(e),u_inv_rot_matrix:new UniformMatrix4f(e),u_merc_center:new Uniform2f(e),u_up_dir:new Uniform3f(e),u_height_lift:new Uniform1f(e)}),fillExtrusionPattern:e=>({u_matrix:new UniformMatrix4f(e),u_lightpos:new Uniform3f(e),u_lightintensity:new Uniform1f(e),u_lightcolor:new Uniform3f(e),u_vertical_gradient:new Uniform1f(e),u_height_factor:new Uniform1f(e),u_edge_radius:new Uniform1f(e),u_ao:new Uniform2f(e),u_tile_id:new Uniform3f(e),u_zoom_transition:new Uniform1f(e),u_inv_rot_matrix:new UniformMatrix4f(e),u_merc_center:new Uniform2f(e),u_up_dir:new Uniform3f(e),u_height_lift:new Uniform1f(e),u_image:new Uniform1i(e),u_texsize:new Uniform2f(e),u_pixel_coord_upper:new Uniform2f(e),u_pixel_coord_lower:new Uniform2f(e),u_scale:new Uniform3f(e),u_fade:new Uniform1f(e),u_opacity:new Uniform1f(e)}),fill:e=>({u_matrix:new UniformMatrix4f(e)}),fillPattern:e=>({u_matrix:new UniformMatrix4f(e),u_image:new Uniform1i(e),u_texsize:new Uniform2f(e),u_pixel_coord_upper:new Uniform2f(e),u_pixel_coord_lower:new Uniform2f(e),u_scale:new Uniform3f(e),u_fade:new Uniform1f(e)}),fillOutline:e=>({u_matrix:new UniformMatrix4f(e),u_world:new Uniform2f(e)}),fillOutlinePattern:e=>({u_matrix:new UniformMatrix4f(e),u_world:new Uniform2f(e),u_image:new Uniform1i(e),u_texsize:new Uniform2f(e),u_pixel_coord_upper:new Uniform2f(e),u_pixel_coord_lower:new Uniform2f(e),u_scale:new Uniform3f(e),u_fade:new Uniform1f(e)}),circle:e=>({u_camera_to_center_distance:new Uniform1f(e),u_extrude_scale:new UniformMatrix2f(e),u_device_pixel_ratio:new Uniform1f(e),u_matrix:new UniformMatrix4f(e),u_inv_rot_matrix:new UniformMatrix4f(e),u_merc_center:new Uniform2f(e),u_tile_id:new Uniform3f(e),u_zoom_transition:new Uniform1f(e),u_up_dir:new Uniform3f(e)}),collisionBox:e=>({u_matrix:new UniformMatrix4f(e),u_camera_to_center_distance:new Uniform1f(e),u_extrude_scale:new Uniform2f(e)}),collisionCircle:e=>({u_matrix:new UniformMatrix4f(e),u_inv_matrix:new UniformMatrix4f(e),u_camera_to_center_distance:new Uniform1f(e),u_viewport_size:new Uniform2f(e)}),debug:e=>({u_color:new UniformColor(e),u_matrix:new UniformMatrix4f(e),u_overlay:new Uniform1i(e),u_overlay_scale:new Uniform1f(e)}),clippingMask:e=>({u_matrix:new UniformMatrix4f(e)}),heatmap:e=>({u_extrude_scale:new Uniform1f(e),u_intensity:new Uniform1f(e),u_matrix:new UniformMatrix4f(e),u_inv_rot_matrix:new UniformMatrix4f(e),u_merc_center:new Uniform2f(e),u_tile_id:new Uniform3f(e),u_zoom_transition:new Uniform1f(e),u_up_dir:new Uniform3f(e)}),heatmapTexture:e=>({u_image:new Uniform1i(e),u_color_ramp:new Uniform1i(e),u_opacity:new Uniform1f(e)}),hillshade:e=>({u_matrix:new UniformMatrix4f(e),u_image:new Uniform1i(e),u_latrange:new Uniform2f(e),u_light:new Uniform2f(e),u_shadow:new UniformColor(e),u_highlight:new UniformColor(e),u_accent:new UniformColor(e)}),hillshadePrepare:e=>({u_matrix:new UniformMatrix4f(e),u_image:new Uniform1i(e),u_dimension:new Uniform2f(e),u_zoom:new Uniform1f(e),u_unpack:new Uniform4f(e)}),line:e=>({u_matrix:new UniformMatrix4f(e),u_pixels_to_tile_units:new UniformMatrix2f(e),u_device_pixel_ratio:new Uniform1f(e),u_units_to_pixels:new Uniform2f(e),u_dash_image:new Uniform1i(e),u_gradient_image:new Uniform1i(e),u_image_height:new Uniform1f(e),u_texsize:new Uniform2f(e),u_scale:new Uniform3f(e),u_mix:new Uniform1f(e),u_alpha_discard_threshold:new Uniform1f(e),u_trim_offset:new Uniform2f(e)}),linePattern:e=>({u_matrix:new UniformMatrix4f(e),u_texsize:new Uniform2f(e),u_pixels_to_tile_units:new UniformMatrix2f(e),u_device_pixel_ratio:new Uniform1f(e),u_image:new Uniform1i(e),u_units_to_pixels:new Uniform2f(e),u_scale:new Uniform3f(e),u_fade:new Uniform1f(e),u_alpha_discard_threshold:new Uniform1f(e)}),raster:e=>({u_matrix:new UniformMatrix4f(e),u_tl_parent:new Uniform2f(e),u_scale_parent:new Uniform1f(e),u_fade_t:new Uniform1f(e),u_opacity:new Uniform1f(e),u_image0:new Uniform1i(e),u_image1:new Uniform1i(e),u_brightness_low:new Uniform1f(e),u_brightness_high:new Uniform1f(e),u_saturation_factor:new Uniform1f(e),u_contrast_factor:new Uniform1f(e),u_spin_weights:new Uniform3f(e),u_perspective_transform:new Uniform2f(e)}),symbolIcon:e=>({u_is_size_zoom_constant:new Uniform1i(e),u_is_size_feature_constant:new Uniform1i(e),u_size_t:new Uniform1f(e),u_size:new Uniform1f(e),u_camera_to_center_distance:new Uniform1f(e),u_rotate_symbol:new Uniform1i(e),u_aspect_ratio:new Uniform1f(e),u_fade_change:new Uniform1f(e),u_matrix:new UniformMatrix4f(e),u_label_plane_matrix:new UniformMatrix4f(e),u_coord_matrix:new UniformMatrix4f(e),u_is_text:new Uniform1i(e),u_pitch_with_map:new Uniform1i(e),u_texsize:new Uniform2f(e),u_tile_id:new Uniform3f(e),u_zoom_transition:new Uniform1f(e),u_inv_rot_matrix:new UniformMatrix4f(e),u_merc_center:new Uniform2f(e),u_camera_forward:new Uniform3f(e),u_tile_matrix:new UniformMatrix4f(e),u_up_vector:new Uniform3f(e),u_ecef_origin:new Uniform3f(e),u_texture:new Uniform1i(e)}),symbolSDF:e=>({u_is_size_zoom_constant:new Uniform1i(e),u_is_size_feature_constant:new Uniform1i(e),u_size_t:new Uniform1f(e),u_size:new Uniform1f(e),u_camera_to_center_distance:new Uniform1f(e),u_rotate_symbol:new Uniform1i(e),u_aspect_ratio:new Uniform1f(e),u_fade_change:new Uniform1f(e),u_matrix:new UniformMatrix4f(e),u_label_plane_matrix:new UniformMatrix4f(e),u_coord_matrix:new UniformMatrix4f(e),u_is_text:new Uniform1i(e),u_pitch_with_map:new Uniform1i(e),u_texsize:new Uniform2f(e),u_texture:new Uniform1i(e),u_gamma_scale:new Uniform1f(e),u_device_pixel_ratio:new Uniform1f(e),u_tile_id:new Uniform3f(e),u_zoom_transition:new Uniform1f(e),u_inv_rot_matrix:new UniformMatrix4f(e),u_merc_center:new Uniform2f(e),u_camera_forward:new Uniform3f(e),u_tile_matrix:new UniformMatrix4f(e),u_up_vector:new Uniform3f(e),u_ecef_origin:new Uniform3f(e),u_is_halo:new Uniform1i(e)}),symbolTextAndIcon:e=>({u_is_size_zoom_constant:new Uniform1i(e),u_is_size_feature_constant:new Uniform1i(e),u_size_t:new Uniform1f(e),u_size:new Uniform1f(e),u_camera_to_center_distance:new Uniform1f(e),u_rotate_symbol:new Uniform1i(e),u_aspect_ratio:new Uniform1f(e),u_fade_change:new Uniform1f(e),u_matrix:new UniformMatrix4f(e),u_label_plane_matrix:new UniformMatrix4f(e),u_coord_matrix:new UniformMatrix4f(e),u_is_text:new Uniform1i(e),u_pitch_with_map:new Uniform1i(e),u_texsize:new Uniform2f(e),u_texsize_icon:new Uniform2f(e),u_texture:new Uniform1i(e),u_texture_icon:new Uniform1i(e),u_gamma_scale:new Uniform1f(e),u_device_pixel_ratio:new Uniform1f(e),u_is_halo:new Uniform1i(e)}),background:e=>({u_matrix:new UniformMatrix4f(e),u_opacity:new Uniform1f(e),u_color:new UniformColor(e)}),backgroundPattern:e=>({u_matrix:new UniformMatrix4f(e),u_opacity:new Uniform1f(e),u_image:new Uniform1i(e),u_pattern_tl_a:new Uniform2f(e),u_pattern_br_a:new Uniform2f(e),u_pattern_tl_b:new Uniform2f(e),u_pattern_br_b:new Uniform2f(e),u_texsize:new Uniform2f(e),u_mix:new Uniform1f(e),u_pattern_size_a:new Uniform2f(e),u_pattern_size_b:new Uniform2f(e),u_scale_a:new Uniform1f(e),u_scale_b:new Uniform1f(e),u_pixel_coord_upper:new Uniform2f(e),u_pixel_coord_lower:new Uniform2f(e),u_tile_units_to_pixels:new Uniform1f(e)}),terrainRaster:gd,terrainDepth:gd,skybox:e=>({u_matrix:new UniformMatrix4f(e),u_sun_direction:new Uniform3f(e),u_cubemap:new Uniform1i(e),u_opacity:new Uniform1f(e),u_temporal_offset:new Uniform1f(e)}),skyboxGradient:e=>({u_matrix:new UniformMatrix4f(e),u_color_ramp:new Uniform1i(e),u_center_direction:new Uniform3f(e),u_radius:new Uniform1f(e),u_opacity:new Uniform1f(e),u_temporal_offset:new Uniform1f(e)}),skyboxCapture:e=>({u_matrix_3f:new UniformMatrix3f(e),u_sun_direction:new Uniform3f(e),u_sun_intensity:new Uniform1f(e),u_color_tint_r:new Uniform4f(e),u_color_tint_m:new Uniform4f(e),u_luminance:new Uniform1f(e)}),globeRaster:e=>({u_proj_matrix:new UniformMatrix4f(e),u_globe_matrix:new UniformMatrix4f(e),u_normalize_matrix:new UniformMatrix4f(e),u_merc_matrix:new UniformMatrix4f(e),u_zoom_transition:new Uniform1f(e),u_merc_center:new Uniform2f(e),u_image0:new Uniform1i(e),u_grid_matrix:new UniformMatrix3f(e),u_frustum_tl:new Uniform3f(e),u_frustum_tr:new Uniform3f(e),u_frustum_br:new Uniform3f(e),u_frustum_bl:new Uniform3f(e),u_globe_pos:new Uniform3f(e),u_globe_radius:new Uniform1f(e),u_viewport:new Uniform2f(e)}),globeAtmosphere:e=>({u_frustum_tl:new Uniform3f(e),u_frustum_tr:new Uniform3f(e),u_frustum_br:new Uniform3f(e),u_frustum_bl:new Uniform3f(e),u_horizon:new Uniform1f(e),u_transition:new Uniform1f(e),u_fadeout_range:new Uniform1f(e),u_color:new Uniform4f(e),u_high_color:new Uniform4f(e),u_space_color:new Uniform4f(e),u_star_intensity:new Uniform1f(e),u_star_density:new Uniform1f(e),u_star_size:new Uniform1f(e),u_temporal_offset:new Uniform1f(e),u_horizon_angle:new Uniform1f(e),u_rotation_matrix:new UniformMatrix4f(e)})};let tf;function rf(e,t,i,r,n,o,a){const s=e.context,l=s.gl,c=e.transform,u=e.useProgram("collisionBox"),h=[];let p=0,d=0;for(let f=0;f<r.length;f++){const m=r[f],_=t.getTile(m),g=_.getBucket(i);if(!g)continue;const y=Lp(m,g,c);let x=y;0===n[0]&&0===n[1]||(x=e.translatePosMatrix(y,_,n,o));const v=a?g.textCollisionBox:g.iconCollisionBox,b=g.collisionCircleArray;if(b.length>0){const e=ga(),t=x;Da(e,g.placementInvProjMatrix,c.glCoordMatrix),Da(e,e,g.placementViewportMatrix),h.push({circleArray:b,circleOffset:d,transform:t,invTransform:e,projection:g.getProjection()}),p+=b.length/4,d=p}v&&(e.terrain&&e.terrain.setupElevationDraw(_,u),u.draw(s,l.LINES,DepthMode.disabled,StencilMode.disabled,e.colorModeForRenderPass(),CullFaceMode.disabled,Fd(x,c,_,g.getProjection()),i.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,null,c.zoom,null,[v.collisionVertexBuffer,v.collisionVertexBufferExt]))}if(!a||!h.length)return;const f=e.useProgram("collisionCircle"),m=new StructArrayLayout2f1f2i16;m.resize(4*p),m._trim();let _=0;for(const e of h)for(let t=0;t<e.circleArray.length/4;t++){const i=4*t,r=e.circleArray[i+0],n=e.circleArray[i+1],o=e.circleArray[i+2],a=e.circleArray[i+3];m.emplace(_++,r,n,o,a,0),m.emplace(_++,r,n,o,a,1),m.emplace(_++,r,n,o,a,2),m.emplace(_++,r,n,o,a,3)}(!tf||tf.length<2*p)&&(tf=function(e){const t=2*e,i=new StructArrayLayout3ui6;i.resize(t),i._trim();for(let e=0;e<t;e++){const t=6*e;i.uint16[t+0]=4*e+0,i.uint16[t+1]=4*e+1,i.uint16[t+2]=4*e+2,i.uint16[t+3]=4*e+2,i.uint16[t+4]=4*e+3,i.uint16[t+5]=4*e+0}return i}(p));const g=s.createIndexBuffer(tf,!0),y=s.createVertexBuffer(m,tc.members,!0);for(const t of h){const r={u_matrix:t.transform,u_inv_matrix:t.invTransform,u_camera_to_center_distance:(x=c).getCameraToCenterDistance(t.projection),u_viewport_size:[x.width,x.height]};f.draw(s,l.TRIANGLES,DepthMode.disabled,StencilMode.disabled,e.colorModeForRenderPass(),CullFaceMode.disabled,r,i.id,y,g,SegmentVector.simpleSegment(0,2*t.circleOffset,t.circleArray.length,t.circleArray.length/2),null,c.zoom)}var x;y.destroy(),g.destroy()}const nf=ga();function of(e,t,i,n,o,a){const{horizontalAlign:s,verticalAlign:l}=Rc(e),c=-(s-.5)*t,u=-(l-.5)*i,h=Nc(e,n);return new r((c/o+h[0])*a,(u/o+h[1])*a)}function af(e,t,i,n,o,a,s,l,c,u,h){const p=e.text.placedSymbolArray,d=e.text.dynamicLayoutVertexArray,f=e.icon.dynamicLayoutVertexArray,m={},_=Bp(l,e.getProjection(),a),g=a.elevation,y=e.getProjection().upVectorScale(l.canonical,a.center.lat,a.worldSize);d.clear();for(let f=0;f<p.length;f++){const x=p.get(f),v=e.allowVerticalPlacement&&!x.placedOrientation,b=x.hidden||!x.crossTileID||v?null:n[x.crossTileID];if(b){const n=new r(x.tileAnchorX,x.tileAnchorY),p=e.getProjection().upVector(l.canonical,n.x,n.y),f=g?g.getAtTileOffset(l,n.x,n.y):0,v=xp([x.projectedAnchorX+f*p[0]*y.metersToTile,x.projectedAnchorY+f*p[1]*y.metersToTile,x.projectedAnchorZ+f*p[2]*y.metersToTile],i?_:s),w=vp(a.getCameraToCenterDistance(e.getProjection()),v.signedDistanceFromCamera);let T=o.evaluateSizeForFeature(e.textSizeData,u,x)*w/24;i&&(T*=e.tilePixelRatio/c);const{width:E,height:S,anchor:A,textOffset:C,textScale:I}=b,M=of(A,E,S,C,I,T);let P;if(i){const t=n.add(M),{x:i,y:r,z:o}=e.getProjection().projectTilePoint(t.x,t.y,l.canonical);P=xp([i+f*p[0]*y.metersToTile,r+f*p[1]*y.metersToTile,o+f*p[2]*y.metersToTile],s).point}else{const e=t?M.rotate(-a.angle):M;P=[v.point[0]+e.x,v.point[1]+e.y,0]}const D=e.allowVerticalPlacement&&x.placedOrientation===Bc.vertical?Math.PI/2:0;for(let e=0;e<x.numGlyphs;e++)Hu(d,P[0],P[1],P[2],D);h&&x.associatedIconIndex>=0&&(m[x.associatedIconIndex]={shiftedAnchor:P,angle:D})}else Pp(x.numGlyphs,d)}if(h){f.clear();const t=e.icon.placedSymbolArray;for(let e=0;e<t.length;e++){const i=t.get(e);if(i.hidden)Pp(i.numGlyphs,f);else{const t=m[e];if(t)for(let e=0;e<i.numGlyphs;e++)Hu(f,t.shiftedAnchor[0],t.shiftedAnchor[1],t.shiftedAnchor[2],t.angle);else Pp(i.numGlyphs,f)}}e.icon.dynamicLayoutVertexBuffer.updateData(f)}e.text.dynamicLayoutVertexBuffer.updateData(d)}function sf(e,t,i){return i.iconsInText&&t?"symbolTextAndIcon":e?"symbolSDF":"symbolIcon"}function lf(e,t,i,r,n,o,a,s,l,c,u,h){const p=e.context,d=p.gl,f=e.transform,m="map"===s,_="map"===l,g=m&&"point"!==i.layout.get("symbol-placement"),y=m&&!_&&!g,x=void 0!==i.layout.get("symbol-sort-key").constantOr(1);let v=!1;const b=e.depthModeForSublayer(0,DepthMode.ReadOnly),w=[Io(f.center.lng),Mo(f.center.lat)],T=i.layout.get("text-variable-anchor"),E="globe"===f.projection.name,S=[],A=[0,-1,0];let C=A;!E&&!f.mercatorFromTransition||m||(C=function(e){const t=va([],e._camera.getWorldToCamera(e.worldSize,1),e.globeMatrix);xa(t,t);const i=[0,0,0],r=[0,1,0,0];return is(r,r,t),i[0]=r[0],i[1]=r[1],i[2]=r[2],Za(i,i),i}(f));for(const s of r){const r=t.getTile(s),l=r.getBucket(i);if(!l)continue;if("mercator"===l.projection.name&&E)continue;const u=n?l.text:l.icon;if(!u||l.fullyClipped||!u.segments.get().length)continue;const h=u.programConfigurations.get(i.id),p=n||l.sdfIcons,b=n?l.textSizeData:l.iconSizeData,I=_||0!==f.pitch,M=oc(b,f.zoom);let P,D,z,k,L=[0,0],B=null;if(n){if(D=r.glyphAtlasTexture,z=d.LINEAR,P=r.glyphAtlasTexture.size,l.iconsInText){L=r.imageAtlasTexture.size,B=r.imageAtlasTexture;const t="composite"===b.kind||"camera"===b.kind;k=I||e.options.rotating||e.options.zooming||t?d.LINEAR:d.NEAREST}}else{const t=1!==i.layout.get("icon-size").constantOr(0)||l.iconsNeedLinear;D=r.imageAtlasTexture,z=p||e.options.rotating||e.options.zooming||t||I?d.LINEAR:d.NEAREST,P=r.imageAtlasTexture.size}const R="globe"===l.projection.name,F=R?C:A,O=R?_u(f.zoom):0,V=Bp(s,l.getProjection(),f),U=f.calculatePixelsToTileUnitsMatrix(r),j=mp(V,r.tileID.canonical,_,m,f,l.getProjection(),U),N=e.terrain&&_&&g?xa(ga(),j):nf,G=gp(V,r.tileID.canonical,_,m,f,l.getProjection(),U),Z=T&&l.hasTextData(),q="none"!==i.layout.get("icon-text-fit")&&Z&&l.hasIconData();if(g){const t=f.elevation,i=t?t.getAtTileOffsetFunc(s,f.center.lat,f.worldSize,l.getProjection()):e=>[0,0,0],o=_p(V,r.tileID.canonical,_,m,f,l.getProjection(),U);wp(l,V,e,n,o,G,_,c,i,s)}const $=g||n&&T||q,W=e.translatePosMatrix(V,r,o,a),H=$?nf:j,X=e.translatePosMatrix(G,r,o,a,!0),K=l.getProjection().createInversionMatrix(f,s.canonical),J=[];e.terrain&&_&&J.push("PITCH_WITH_MAP_TERRAIN"),R&&J.push("PROJECTION_GLOBE_VIEW"),$&&J.push("PROJECTED_POS_ON_VIEWPORT");const Y=p&&0!==i.paint.get(n?"text-halo-width":"icon-halo-width").constantOr(1);let Q;Q=p?l.iconsInText?Jd(b.kind,M,y,_,e,W,H,X,P,L,s,O,w,K,F,l.getProjection()):Kd(b.kind,M,y,_,e,W,H,X,n,P,!0,s,O,w,K,F,l.getProjection()):Xd(b.kind,M,y,_,e,W,H,X,n,P,s,O,w,K,F,l.getProjection());const ee={program:e.useProgram(sf(p,n,l),h,J),buffers:u,uniformValues:Q,atlasTexture:D,atlasTextureIcon:B,atlasInterpolation:z,atlasInterpolationIcon:k,isSDF:p,hasHalo:Y,tile:r,labelPlaneMatrixInv:N};if(x&&l.canOverlap){v=!0;const e=u.segments.get();for(const t of e)S.push({segments:new SegmentVector([t]),sortKey:t.sortKey,state:ee})}else S.push({segments:u.segments,sortKey:0,state:ee})}v&&S.sort(((e,t)=>e.sortKey-t.sortKey));for(const t of S){const r=t.state;if(e.terrain&&e.terrain.setupElevationDraw(r.tile,r.program,{useDepthForOcclusion:!E,labelPlaneMatrixInv:r.labelPlaneMatrixInv}),p.activeTexture.set(d.TEXTURE0),r.atlasTexture.bind(r.atlasInterpolation,d.CLAMP_TO_EDGE),r.atlasTextureIcon&&(p.activeTexture.set(d.TEXTURE1),r.atlasTextureIcon&&r.atlasTextureIcon.bind(r.atlasInterpolationIcon,d.CLAMP_TO_EDGE)),r.isSDF){const n=r.uniformValues;r.hasHalo&&(n.u_is_halo=1,cf(r.buffers,t.segments,i,e,r.program,b,u,h,n)),n.u_is_halo=0}cf(r.buffers,t.segments,i,e,r.program,b,u,h,r.uniformValues)}}function cf(e,t,i,r,n,o,a,s,l){const c=r.context,u=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.globeExtVertexBuffer];n.draw(c,c.gl.TRIANGLES,o,a,s,CullFaceMode.disabled,l,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,r.transform.zoom,e.programConfigurations.get(i.id),u)}function uf(e,t,i,r,n,o,a){const s=e.context.gl,l=i.paint.get("fill-pattern"),c=l&&l.constantOr(1),u=i.getCrossfadeParameters();let h,p,d,f,m;a?(p=c&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",h=s.LINES):(p=c?"fillPattern":"fill",h=s.TRIANGLES);for(const _ of r){const r=t.getTile(_);if(c&&!r.patternsLoaded())continue;const g=r.getBucket(i);if(!g)continue;e.prepareDrawTile();const y=g.programConfigurations.get(i.id),x=e.useProgram(p,y);c&&(e.context.activeTexture.set(s.TEXTURE0),r.imageAtlasTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE),y.updatePaintBuffers(u));const v=l.constantOr(null);if(v&&r.imageAtlas){const e=r.imageAtlas,t=e.patternPositions[v.to.toString()],i=e.patternPositions[v.from.toString()];t&&i&&y.setConstantPatternPositions(t,i)}const b=e.translatePosMatrix(_.projMatrix,r,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor"));if(a){f=g.indexBuffer2,m=g.segments2;const t=e.terrain&&e.terrain.renderingToTexture?e.terrain.drapeBufferSize:[s.drawingBufferWidth,s.drawingBufferHeight];d="fillOutlinePattern"===p&&c?kd(b,e,u,r,t):zd(b,t)}else f=g.indexBuffer,m=g.segments,d=c?Dd(b,e,u,r):Pd(b);e.prepareDrawProgram(e.context,x,_.toUnwrapped()),x.draw(e.context,h,n,e.stencilModeForClipping(_),o,CullFaceMode.disabled,d,i.id,g.layoutVertexBuffer,f,m,i.paint,e.transform.zoom,y)}}function hf(e,t,i,r,n,o,a){const s=e.context,l=s.gl,c=e.transform,u=i.paint.get("fill-extrusion-pattern"),h=u.constantOr(1),p=i.getCrossfadeParameters(),d=i.paint.get("fill-extrusion-opacity"),f=[i.paint.get("fill-extrusion-ambient-occlusion-intensity"),i.paint.get("fill-extrusion-ambient-occlusion-radius")],m=i.layout.get("fill-extrusion-edge-radius"),_="globe"===c.projection.name?Ml():0,g="globe"===c.projection.name,y=g?_u(c.zoom):0,x=[Io(c.center.lng),Mo(c.center.lat)],v=[];g&&(v.push("PROJECTION_GLOBE_VIEW"),e.style.terrainSetForDrapingOnly()&&v.push("TERRAIN")),f[0]>0&&v.push("FAUX_AO");for(const b of r){const r=t.getTile(b),w=r.getBucket(i);if(!w||w.projection.name!==c.projection.name)continue;const T=w.programConfigurations.get(i.id),E=e.useProgram(h?"fillExtrusionPattern":"fillExtrusion",T,v);if(e.terrain){const n=e.terrain;if(e.style.terrainSetForDrapingOnly())n.setupElevationDraw(r,E,{useMeterToDem:!0});else{if(!w.enableTerrain)continue;if(n.setupElevationDraw(r,E,{useMeterToDem:!0}),pf(s,t,b,w,i,n),!w.centroidVertexBuffer){const e=E.attributes.a_centroid_pos;void 0!==e&&l.vertexAttrib2f(e,0,0)}}}h&&(e.context.activeTexture.set(l.TEXTURE0),r.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),T.updatePaintBuffers(p));const S=u.constantOr(null);if(S&&r.imageAtlas){const e=r.imageAtlas,t=e.patternPositions[S.to.toString()],i=e.patternPositions[S.from.toString()];t&&i&&T.setConstantPatternPositions(t,i)}const A=e.translatePosMatrix(b.projMatrix,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),C=c.projection.createInversionMatrix(c,b.canonical),I=i.paint.get("fill-extrusion-vertical-gradient"),M=h?Md(A,e,I,d,f,m,b,p,r,_,y,x,C):Id(A,e,I,d,f,m,b,_,y,x,C);e.prepareDrawProgram(s,E,b.toUnwrapped());const P=[];e.terrain&&P.push(w.centroidVertexBuffer),g&&P.push(w.layoutVertexExtBuffer),E.draw(s,s.gl.TRIANGLES,n,o,a,CullFaceMode.backCCW,M,i.id,w.layoutVertexBuffer,w.indexBuffer,w.segments,i.paint,e.transform.zoom,T,P)}}function pf(e,t,i,n,o,a){const s=[e=>{let t=e.canonical.x-1,i=e.wrap;return t<0&&(t=(1<<e.canonical.z)-1,i--),new OverscaledTileID(e.overscaledZ,i,e.canonical.z,t,e.canonical.y)},e=>{let t=e.canonical.x+1,i=e.wrap;return t===1<<e.canonical.z&&(t=0,i++),new OverscaledTileID(e.overscaledZ,i,e.canonical.z,t,e.canonical.y)},e=>new OverscaledTileID(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<<e.canonical.z:e.canonical.y)-1),e=>new OverscaledTileID(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<<e.canonical.z)-1?0:e.canonical.y+1)],l=e=>{const i=t.getSource().minzoom,r=e=>{const i=t.getTileByID(e);if(i&&i.hasData())return i.getBucket(o)},n=[0,-1,1];for(const t of n){if(e.overscaledZ+t<i)continue;const n=r(e.calculateScaledKey(e.overscaledZ+t));if(n)return n}},c=[0,0,0],u=(e,t)=>(c[0]=Math.min(e.min.y,t.min.y),c[1]=Math.max(e.max.y,t.max.y),c[2]=Eo-t.min.x>e.max.x?t.min.x-Eo:e.max.x,c),h=(e,t)=>(c[0]=Math.min(e.min.x,t.min.x),c[1]=Math.max(e.max.x,t.max.x),c[2]=Eo-t.min.y>e.max.y?t.min.y-Eo:e.max.y,c),p=[(e,t)=>u(e,t),(e,t)=>u(t,e),(e,t)=>h(e,t),(e,t)=>h(t,e)],d=new r(0,0);let f,m,_;const g=(e,t,r,n,o)=>{const s=[[n?r:e,n?e:r,0],[n?r:t,n?t:r,0]],l=o<0?Eo+o:o,c=[n?l:(e+t)/2,n?(e+t)/2:l,0];return 0===r&&o<0||0!==r&&o>0?a.getForTilePoints(_,[c],!0,m):s.push(c),a.getForTilePoints(i,s,!0,f),Math.max(s[0][2],s[1][2],c[2])/a.exaggeration()};for(let e=0;e<4;e++){const t=(e<2?1:5)-e,r=n.borders[e];if(0===r.length)continue;const o=_=s[e](i),c=l(o);if(!(c&&c instanceof FillExtrusionBucket&&c.enableTerrain))continue;if(n.borderDoneWithNeighborZ[e]===c.canonical.z&&c.borderDoneWithNeighborZ[t]===n.canonical.z)continue;if(m=a.findDEMTileFor(o),!m||!m.dem)continue;if(!f){const e=a.findDEMTileFor(i);if(!e||!e.dem)return;f=e}const u=c.borders[t];let h=0;const y=c.borderDoneWithNeighborZ[t]!==n.canonical.z;if(n.canonical.z===c.canonical.z){for(let i=0;i<r.length;i++){const o=n.featuresOnBorder[r[i]],a=o.borders[e];let s;for(;h<u.length&&(s=c.featuresOnBorder[u[h]],!(s.borders[t][1]>a[0]+3));)y&&c.encodeCentroid(void 0,s,!1),h++;if(s&&h<u.length){const i=h;let r=0;for(;!(s.borders[t][0]>a[1]-3)&&(r++,++h!==u.length);)s=c.featuresOnBorder[u[h]];if(s=c.featuresOnBorder[u[i]],o.intersectsCount()>1||s.intersectsCount()>1||1!==r){1!==r&&(h=i),n.encodeCentroid(void 0,o,!1),y&&c.encodeCentroid(void 0,s,!1);continue}const l=p[e](o,s),f=e%2?8191:0;d.x=g(l[0],Math.min(8191,l[1]),f,e<2,l[2]),d.y=0,n.encodeCentroid(d,o,!1),y&&c.encodeCentroid(d,s,!1)}else n.encodeCentroid(void 0,o,!1)}n.borderDoneWithNeighborZ[e]=c.canonical.z,n.needsCentroidUpdate=!0,y&&(c.borderDoneWithNeighborZ[t]=n.canonical.z,c.needsCentroidUpdate=!0)}else{for(const e of r)n.encodeCentroid(void 0,n.featuresOnBorder[e],!1);if(y){for(const e of u)c.encodeCentroid(void 0,c.featuresOnBorder[e],!1);c.borderDoneWithNeighborZ[t]=n.canonical.z,c.needsCentroidUpdate=!0}n.borderDoneWithNeighborZ[e]=c.canonical.z,n.needsCentroidUpdate=!0}}(n.needsCentroidUpdate||!n.centroidVertexBuffer&&0!==n.centroidVertexArray.length)&&n.uploadCentroid(e)}const df=new Lt(1,0,0,1),ff=new Lt(0,1,0,1),mf=new Lt(0,0,1,1),_f=new Lt(1,0,1,1),gf=new Lt(0,1,1,1);function yf(e,t,i){const r=e.context,n=e.transform,o=r.gl,a="globe"===n.projection.name,s=a?["PROJECTION_GLOBE_VIEW"]:null;let l=i.projMatrix;if(a&&_u(n.zoom)>0){const e=du(iu(i.canonical,n));l=va(new Float32Array(16),n.globeMatrix,e),va(l,n.projMatrix,l)}const c=e.useProgram("debug",null,s),u=t.getTileByID(i.key);e.terrain&&e.terrain.setupElevationDraw(u,c);const h=DepthMode.disabled,p=StencilMode.disabled,d=e.colorModeForRenderPass(),f="$debug";r.activeTexture.set(o.TEXTURE0),e.emptyTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE),a?u._makeGlobeTileDebugBuffers(e.context,n):u._makeDebugTileBoundsBuffers(e.context,n.projection);const m=u._tileDebugBuffer||e.debugBuffer,_=u._tileDebugIndexBuffer||e.debugIndexBuffer,g=u._tileDebugSegments||e.debugSegments;c.draw(r,o.LINE_STRIP,h,p,d,CullFaceMode.disabled,Od(l,Lt.red),f,m,_,g,null,null,null,[u._globeTileDebugBorderBuffer]);const y=u.latestRawTileData,x=Math.floor((y&&y.byteLength||0)/1024),v=t.getTile(i).tileSize,b=512/Math.min(v,512)*(i.overscaledZ/n.zoom)*.5;let w=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(w+=` => ${i.overscaledZ}`),w+=` ${x}kb`,function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,r=e.context.gl,n=e.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,i.width,i.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(t,5,5),n.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(e,w);const T=u._tileDebugTextBuffer||e.debugBuffer,E=u._tileDebugTextIndexBuffer||e.quadTriangleIndexBuffer,S=u._tileDebugTextSegments||e.debugSegments;c.draw(r,o.TRIANGLES,h,p,ColorMode.alphaBlended,CullFaceMode.disabled,Od(l,Lt.transparent,b),f,T,E,S,null,null,null,[u._globeTileDebugTextBuffer])}function xf(e,t,i,r){bf(e,0,t+i/2,e.transform.width,i,r)}function vf(e,t,i,r){bf(e,t-i/2,0,i,e.transform.height,r)}function bf(e,t,i,r,n,o){const a=e.context,s=a.gl;s.enable(s.SCISSOR_TEST),s.scissor(t*ee.devicePixelRatio,i*ee.devicePixelRatio,r*ee.devicePixelRatio,n*ee.devicePixelRatio),a.clear({color:o}),s.disable(s.SCISSOR_TEST)}const wf=eo([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Tf}=wf;function Ef(e,t,i,r){e.emplaceBack(t,i,r)}class SkyboxGeometry{constructor(e){this.vertexArray=new StructArrayLayout3f12,this.indices=new StructArrayLayout3ui6,Ef(this.vertexArray,-1,-1,1),Ef(this.vertexArray,1,-1,1),Ef(this.vertexArray,-1,1,1),Ef(this.vertexArray,1,1,1),Ef(this.vertexArray,-1,-1,-1),Ef(this.vertexArray,1,-1,-1),Ef(this.vertexArray,-1,1,-1),Ef(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=e.createVertexBuffer(this.vertexArray,Tf),this.indexBuffer=e.createIndexBuffer(this.indices),this.segment=SegmentVector.simpleSegment(0,0,36,12)}}function Sf(e,t,i,r,n,o){const a=e.gl,s=t.paint.get("sky-atmosphere-color"),l=t.paint.get("sky-atmosphere-halo-color"),c=t.paint.get("sky-atmosphere-sun-intensity"),u=((e,t,i,r,n)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:i,u_color_tint_r:[r.r,r.g,r.b,r.a],u_color_tint_m:[n.r,n.g,n.b,n.a],u_luminance:5e-5}))(((h=fa())[0]=(p=r)[0],h[1]=p[1],h[2]=p[2],h[3]=p[4],h[4]=p[5],h[5]=p[6],h[6]=p[8],h[7]=p[9],h[8]=p[10],h),n,c,s,l);var h,p;a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+o,t.skyboxTexture,0),i.draw(e,a.TRIANGLES,DepthMode.disabled,StencilMode.disabled,ColorMode.unblended,CullFaceMode.frontCW,u,"skyboxCapture",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}const Af=eo([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class AtmosphereBuffer{constructor(e){const t=new StructArrayLayout5f20;t.emplaceBack(-1,1,1,0,0),t.emplaceBack(1,1,1,1,0),t.emplaceBack(1,-1,1,1,1),t.emplaceBack(-1,-1,1,0,1);const i=new StructArrayLayout3ui6;i.emplaceBack(0,1,2),i.emplaceBack(2,3,0),this.vertexBuffer=e.createVertexBuffer(t,Af.members),this.indexBuffer=e.createIndexBuffer(i),this.segments=SegmentVector.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const Cf={symbol:function(e,t,i,r,n){if("translucent"!==e.renderPass)return;const o=StencilMode.disabled,a=e.colorModeForRenderPass();i.layout.get("text-variable-anchor")&&function(e,t,i,r,n,o,a){const s=t.transform,l="map"===n,c="map"===o;for(const t of e){const e=r.getTile(t),n=e.getBucket(i);if(!n||!n.text||!n.text.segments.get().length)continue;const o=oc(n.textSizeData,s.zoom),u=Bp(t,n.getProjection(),s),h=s.calculatePixelsToTileUnitsMatrix(e),p=mp(u,e.tileID.canonical,c,l,s,n.getProjection(),h),d="none"!==i.layout.get("icon-text-fit")&&n.hasIconData();if(o){const i=Math.pow(2,s.zoom-e.tileID.overscaledZ);af(n,l,c,a,ac,s,p,t,i,o,d)}}}(r,e,i,t,i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),n),0!==i.paint.get("icon-opacity").constantOr(1)&&lf(e,t,i,r,!1,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),i.layout.get("icon-rotation-alignment"),i.layout.get("icon-pitch-alignment"),i.layout.get("icon-keep-upright"),o,a),0!==i.paint.get("text-opacity").constantOr(1)&&lf(e,t,i,r,!0,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),i.layout.get("text-keep-upright"),o,a),t.map.showCollisionBoxes&&(rf(e,t,i,r,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),!0),rf(e,t,i,r,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),!1))},circle:function(e,t,i,r){if("translucent"!==e.renderPass)return;const n=i.paint.get("circle-opacity"),o=i.paint.get("circle-stroke-width"),a=i.paint.get("circle-stroke-opacity"),s=void 0!==i.layout.get("circle-sort-key").constantOr(1);if(0===n.constantOr(1)&&(0===o.constantOr(1)||0===a.constantOr(1)))return;const l=e.context,c=l.gl,u=e.transform,h=e.depthModeForSublayer(0,DepthMode.ReadOnly),p=StencilMode.disabled,d=e.colorModeForRenderPass(),f="globe"===u.projection.name,m=[Io(u.center.lng),Mo(u.center.lat)],_=[];for(let n=0;n<r.length;n++){const o=r[n],a=t.getTile(o),l=a.getBucket(i);if(!l||l.projection.name!==u.projection.name)continue;const c=l.programConfigurations.get(i.id),h=Rd(i);f&&h.push("PROJECTION_GLOBE_VIEW");const p=e.useProgram("circle",c,h),d=l.layoutVertexBuffer,g=l.globeExtVertexBuffer,y=l.indexBuffer,x=u.projection.createInversionMatrix(u,o.canonical),v={programConfiguration:c,program:p,layoutVertexBuffer:d,globeExtVertexBuffer:g,indexBuffer:y,uniformValues:Bd(e,o,a,x,m,i),tile:a};if(s){const e=l.segments.get();for(const t of e)_.push({segments:new SegmentVector([t]),sortKey:t.sortKey,state:v})}else _.push({segments:l.segments,sortKey:0,state:v})}s&&_.sort(((e,t)=>e.sortKey-t.sortKey));const g={useDepthForOcclusion:!f};for(const t of _){const{programConfiguration:r,program:n,layoutVertexBuffer:o,globeExtVertexBuffer:a,indexBuffer:s,uniformValues:f,tile:m}=t.state,_=t.segments;e.terrain&&e.terrain.setupElevationDraw(m,n,g),e.prepareDrawProgram(l,n,m.tileID.toUnwrapped()),n.draw(l,c.TRIANGLES,h,p,d,CullFaceMode.disabled,f,i.id,o,s,_,i.paint,u.zoom,r,[a])}},heatmap:function(e,t,i,r){if(0!==i.paint.get("heatmap-opacity"))if("offscreen"===e.renderPass){const n=e.context,o=n.gl,a=StencilMode.disabled,s=new ColorMode([o.ONE,o.ONE],Lt.transparent,[!0,!0,!0,!0]);!function(e,t,i,r){const n=e.gl,o=t.width*r,a=t.height*r;e.activeTexture.set(n.TEXTURE1),e.viewport.set([0,0,o,a]);let s=i.heatmapFbo;if(!s||s&&(s.width!==o||s.height!==a)){s&&s.destroy();const t=n.createTexture();n.bindTexture(n.TEXTURE_2D,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),s=i.heatmapFbo=e.createFramebuffer(o,a,!1),function(e,t,i,r,n,o){const a=e.gl;a.texImage2D(a.TEXTURE_2D,0,a.RGBA,n,o,0,a.RGBA,e.extRenderToTextureHalfFloat?e.extTextureHalfFloat.HALF_FLOAT_OES:a.UNSIGNED_BYTE,null),r.colorAttachment.set(i)}(e,0,t,s,o,a)}else n.bindTexture(n.TEXTURE_2D,s.colorAttachment.get()),e.bindFramebuffer.set(s.framebuffer)}(n,e,i,"globe"===e.transform.projection.name?.5:.25),n.clear({color:Lt.transparent});const l=e.transform,c="globe"===l.projection.name,u=c?["PROJECTION_GLOBE_VIEW"]:null,h=c?CullFaceMode.frontCCW:CullFaceMode.disabled,p=[Io(l.center.lng),Mo(l.center.lat)];for(let d=0;d<r.length;d++){const f=r[d];if(t.hasRenderableParent(f))continue;const m=t.getTile(f),_=m.getBucket(i);if(!_||_.projection.name!==l.projection.name)continue;const g=_.programConfigurations.get(i.id),y=e.useProgram("heatmap",g,u),{zoom:x}=e.transform;e.terrain&&e.terrain.setupElevationDraw(m,y),e.prepareDrawProgram(n,y,f.toUnwrapped());const v=l.projection.createInversionMatrix(l,f.canonical);y.draw(n,o.TRIANGLES,DepthMode.disabled,a,s,h,Ud(e,f,m,v,p,x,i.paint.get("heatmap-intensity")),i.id,_.layoutVertexBuffer,_.indexBuffer,_.segments,i.paint,e.transform.zoom,g,c?[_.globeExtVertexBuffer]:null)}n.viewport.set([0,0,e.width,e.height])}else"translucent"===e.renderPass&&(e.context.setColorMode(e.colorModeForRenderPass()),function(e,t){const i=e.context,r=i.gl,n=t.heatmapFbo;if(!n)return;i.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,n.colorAttachment.get()),i.activeTexture.set(r.TEXTURE1);let o=t.colorRampTexture;o||(o=t.colorRampTexture=new Texture(i,t.colorRamp,r.RGBA)),o.bind(r.LINEAR,r.CLAMP_TO_EDGE),e.useProgram("heatmapTexture").draw(i,r.TRIANGLES,DepthMode.disabled,StencilMode.disabled,e.colorModeForRenderPass(),CullFaceMode.disabled,((e,t,i,r)=>({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,t),t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,t.paint,e.transform.zoom)}(e,i))},line:function(e,t,i,r){if("translucent"!==e.renderPass)return;const n=i.paint.get("line-opacity"),o=i.paint.get("line-width");if(0===n.constantOr(1)||0===o.constantOr(1))return;const a=e.depthModeForSublayer(0,DepthMode.ReadOnly),s=e.colorModeForRenderPass(),l=e.terrain&&e.terrain.renderingToTexture?1:ee.devicePixelRatio,c=i.paint.get("line-dasharray"),u=c.constantOr(1),h=i.layout.get("line-cap"),p=i.paint.get("line-pattern"),d=p.constantOr(1),f=i.paint.get("line-gradient"),m=i.getCrossfadeParameters(),g=d?"linePattern":"line",y=e.context,x=y.gl,v=(e=>{const t=[];qd(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");const i=e.paint.get("line-trim-offset");0===i[0]&&0===i[1]||t.push("RENDER_LINE_TRIM_OFFSET");const r=e.paint.get("line-pattern").constantOr(1),n=1!==e.paint.get("line-opacity").constantOr(1);return!r&&n&&t.push("RENDER_LINE_ALPHA_DISCARD"),t})(i);let b=v.includes("RENDER_LINE_ALPHA_DISCARD");e.terrain&&e.terrain.clipOrMaskOverlapStencilType()&&(b=!1);for(const n of r){const r=t.getTile(n);if(d&&!r.patternsLoaded())continue;const o=r.getBucket(i);if(!o)continue;e.prepareDrawTile();const w=o.programConfigurations.get(i.id),T=e.useProgram(g,w,v),E=p.constantOr(null);if(E&&r.imageAtlas){const e=r.imageAtlas,t=e.patternPositions[E.to.toString()],i=e.patternPositions[E.from.toString()];t&&i&&w.setConstantPatternPositions(t,i)}const S=c.constantOr(null),C=h.constantOr(null);if(!d&&S&&C&&r.lineAtlas){const e=r.lineAtlas,t=e.getDash(S.to,C),i=e.getDash(S.from,C);t&&i&&w.setConstantPatternPositions(t,i)}let[I,M]=i.paint.get("line-trim-offset");if("round"===C||"square"===C){const e=1;I!==M&&(0===I&&(I-=e),1===M&&(M+=e))}const P=e.terrain?n.projMatrix:null,D=d?Nd(e,r,i,m,P,l):jd(e,r,i,m,P,o.lineClipsArray.length,l,[I,M]);if(f){const r=o.gradients[i.id];let a=r.texture;if(i.gradientVersion!==r.version){let s=256;if(i.stepInterpolant){const i=t.getSource().maxzoom,r=n.canonical.z===i?Math.ceil(1<<e.transform.maxZoom-n.canonical.z):1;s=_(A(o.maxLineLength/Eo*1024*r),256,y.maxTextureSize)}r.gradient=gs({expression:i.gradientExpression(),evaluationKey:"lineProgress",resolution:s,image:r.gradient||void 0,clips:o.lineClipsArray}),r.texture?r.texture.update(r.gradient):r.texture=new Texture(y,r.gradient,x.RGBA),r.version=i.gradientVersion,a=r.texture}y.activeTexture.set(x.TEXTURE1),a.bind(i.stepInterpolant?x.NEAREST:x.LINEAR,x.CLAMP_TO_EDGE)}u&&(y.activeTexture.set(x.TEXTURE0),r.lineAtlasTexture.bind(x.LINEAR,x.REPEAT),w.updatePaintBuffers(m)),d&&(y.activeTexture.set(x.TEXTURE0),r.imageAtlasTexture.bind(x.LINEAR,x.CLAMP_TO_EDGE),w.updatePaintBuffers(m)),e.prepareDrawProgram(y,T,n.toUnwrapped());const z=t=>{T.draw(y,x.TRIANGLES,a,t,s,CullFaceMode.disabled,D,i.id,o.layoutVertexBuffer,o.indexBuffer,o.segments,i.paint,e.transform.zoom,w,[o.layoutVertexBuffer2])};if(b){const t=e.stencilModeForClipping(n).ref;0===t&&e.terrain&&y.clear({stencil:0});const i={func:x.EQUAL,mask:255};D.u_alpha_discard_threshold=.8,z(new StencilMode(i,t,255,x.KEEP,x.KEEP,x.INVERT)),D.u_alpha_discard_threshold=0,z(new StencilMode(i,t,255,x.KEEP,x.KEEP,x.KEEP))}else z(e.stencilModeForClipping(n))}b&&(e.resetStencilClippingMasks(),e.terrain&&y.clear({stencil:0}))},fill:function(e,t,i,r){const n=i.paint.get("fill-color"),o=i.paint.get("fill-opacity");if(0===o.constantOr(1))return;const a=e.colorModeForRenderPass(),s=i.paint.get("fill-pattern"),l=e.opaquePassEnabledForLayer()&&!s.constantOr(1)&&1===n.constantOr(Lt.transparent).a&&1===o.constantOr(0)?"opaque":"translucent";if(e.renderPass===l){const n=e.depthModeForSublayer(1,"opaque"===e.renderPass?DepthMode.ReadWrite:DepthMode.ReadOnly);uf(e,t,i,r,n,a,!1)}if("translucent"===e.renderPass&&i.paint.get("fill-antialias")){const n=e.depthModeForSublayer(i.getPaintProperty("fill-outline-color")?2:0,DepthMode.ReadOnly);uf(e,t,i,r,n,a,!0)}},"fill-extrusion":function(e,t,i,r){const n=i.paint.get("fill-extrusion-opacity");if(0!==n&&"translucent"===e.renderPass){const o=new DepthMode(e.context.gl.LEQUAL,DepthMode.ReadWrite,e.depthRangeFor3D);if(1!==n||i.paint.get("fill-extrusion-pattern").constantOr(1))hf(e,t,i,r,o,StencilMode.disabled,ColorMode.disabled),hf(e,t,i,r,o,e.stencilModeFor3D(),e.colorModeForRenderPass()),e.resetStencilClippingMasks();else{const n=e.colorModeForRenderPass();hf(e,t,i,r,o,StencilMode.disabled,n)}}},hillshade:function(e,t,i,r){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;const n=e.context,o=e.depthModeForSublayer(0,DepthMode.ReadOnly),a=e.colorModeForRenderPass(),s=e.terrain&&e.terrain.renderingToTexture,[l,c]="translucent"!==e.renderPass||s?[{},r]:e.stencilConfigForOverlap(r);for(const r of c){const n=t.getTile(r);if(n.needsHillshadePrepare&&"offscreen"===e.renderPass)_d(e,n,i,o,StencilMode.disabled,a);else if("translucent"===e.renderPass){const t=s&&e.terrain?e.terrain.stencilModeForRTTOverlap(r):l[r.overscaledZ];fd(e,r,n,i,o,t,a)}}n.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks()},raster:function(e,t,i,r,n,o){if("translucent"!==e.renderPass)return;if(0===i.paint.get("raster-opacity"))return;if(!r.length)return;const a=e.context,s=a.gl,l=t.getSource(),c=e.useProgram("raster"),u=e.colorModeForRenderPass(),h=e.terrain&&e.terrain.renderingToTexture,[p,d]=l instanceof ImageSource||h?[{},r]:e.stencilConfigForOverlap(r),f=d[d.length-1].overscaledZ,m=!e.options.moving;for(const r of d){const n=h?DepthMode.disabled:e.depthModeForSublayer(r.overscaledZ-f,1===i.paint.get("raster-opacity")?DepthMode.ReadWrite:DepthMode.ReadOnly,s.LESS),d=r.toUnwrapped(),_=t.getTile(r);if(h&&(!_||!_.hasData()))continue;const g=h?r.projMatrix:e.transform.calculateProjMatrix(d,m),y=e.terrain&&h?e.terrain.stencilModeForRTTOverlap(r):p[r.overscaledZ],x=o?0:i.paint.get("raster-fade-duration");_.registerFadeDuration(x);const v=t.findLoadedParent(r,0),b=Sd(_,v,t,e.transform,x);let w,T;e.terrain&&e.terrain.prepareDrawTile();const E="nearest"===i.paint.get("raster-resampling")?s.NEAREST:s.LINEAR;a.activeTexture.set(s.TEXTURE0),_.texture.bind(E,s.CLAMP_TO_EDGE),a.activeTexture.set(s.TEXTURE1),v?(v.texture.bind(E,s.CLAMP_TO_EDGE),w=Math.pow(2,v.tileID.overscaledZ-_.tileID.overscaledZ),T=[_.tileID.canonical.x*w%1,_.tileID.canonical.y*w%1]):_.texture.bind(E,s.CLAMP_TO_EDGE);const S=$d(g,T||[0,0],w||1,b,i,l instanceof ImageSource?l.perspectiveTransform:[0,0]);if(e.prepareDrawProgram(a,c,d),l instanceof ImageSource)l.boundsBuffer&&l.boundsSegments&&c.draw(a,s.TRIANGLES,n,StencilMode.disabled,u,CullFaceMode.disabled,S,i.id,l.boundsBuffer,e.quadTriangleIndexBuffer,l.boundsSegments);else{const{tileBoundsBuffer:t,tileBoundsIndexBuffer:r,tileBoundsSegments:o}=e.getTileBoundsBuffers(_);c.draw(a,s.TRIANGLES,n,y,u,CullFaceMode.disabled,S,i.id,t,r,o)}}e.resetStencilClippingMasks()},background:function(e,t,i,r){const n=i.paint.get("background-color"),o=i.paint.get("background-opacity");if(0===o)return;const a=e.context,s=a.gl,l=e.transform,c=l.tileSize,u=i.paint.get("background-pattern");if(e.isPatternMissing(u))return;const h=!u&&1===n.a&&1===o&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(e.renderPass!==h)return;const p=StencilMode.disabled,d=e.depthModeForSublayer(0,"opaque"===h?DepthMode.ReadWrite:DepthMode.ReadOnly),f=e.colorModeForRenderPass(),m=e.useProgram(u?"backgroundPattern":"background");let _,g=r;g||(_=e.getBackgroundTiles(),g=Object.values(_).map((e=>e.tileID))),u&&(a.activeTexture.set(s.TEXTURE0),e.imageManager.bind(e.context));const y=i.getCrossfadeParameters();for(const h of g){const g=h.toUnwrapped(),x=r?h.projMatrix:e.transform.calculateProjMatrix(g);e.prepareDrawTile();const v=t?t.getTile(h):_?_[h.key]:new Tile(h,c,l.zoom,e),b=u?Qd(x,o,e,u,{tileID:h,tileSize:c},y):Yd(x,o,n);e.prepareDrawProgram(a,m,g);const{tileBoundsBuffer:w,tileBoundsIndexBuffer:T,tileBoundsSegments:E}=e.getTileBoundsBuffers(v);m.draw(a,s.TRIANGLES,d,p,f,CullFaceMode.disabled,b,i.id,w,T,E)}},sky:function(e,t,i){const r=e.transform,n="mercator"===r.projection.name||"globe"===r.projection.name?1:g(7,8,r.zoom),o=i.paint.get("sky-opacity")*n;if(0===o)return;const a=e.context,s=i.paint.get("sky-type"),c=new DepthMode(a.gl.LEQUAL,DepthMode.ReadOnly,[0,1]),u=e.frameCounter/1e3%1;"atmosphere"===s?"offscreen"===e.renderPass?i.needsSkyboxCapture(e)&&(function(e,t,i,r){const n=e.context,o=n.gl;let a=t.skyboxFbo;if(!a){a=t.skyboxFbo=n.createFramebuffer(32,32,!1),t.skyboxGeometry=new SkyboxGeometry(n),t.skyboxTexture=n.gl.createTexture(),o.bindTexture(o.TEXTURE_CUBE_MAP,t.skyboxTexture),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_MAG_FILTER,o.LINEAR);for(let e=0;e<6;++e)o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,o.RGBA,32,32,0,o.RGBA,o.UNSIGNED_BYTE,null)}n.bindFramebuffer.set(a.framebuffer),n.viewport.set([0,0,32,32]);const s=t.getCenter(e,!0),l=e.useProgram("skyboxCapture"),c=new Float64Array(16);ya(c),Ea(c,c,.5*-Math.PI),Sf(n,t,l,c,s,0),ya(c),Ea(c,c,.5*Math.PI),Sf(n,t,l,c,s,1),ya(c),Ta(c,c,.5*-Math.PI),Sf(n,t,l,c,s,2),ya(c),Ta(c,c,.5*Math.PI),Sf(n,t,l,c,s,3),ya(c),Sf(n,t,l,c,s,4),ya(c),Ea(c,c,Math.PI),Sf(n,t,l,c,s,5),n.viewport.set([0,0,e.width,e.height])}(e,i),i.markSkyboxValid(e)):"sky"===e.renderPass&&function(e,t,i,r,n){const o=e.context,a=o.gl,s=e.transform,l=e.useProgram("skybox");o.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_CUBE_MAP,t.skyboxTexture);const c=((e,t,i,r,n)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:r,u_temporal_offset:n}))(s.skyboxMatrix,t.getCenter(e,!1),0,r,n);e.prepareDrawProgram(o,l),l.draw(o,a.TRIANGLES,i,StencilMode.disabled,e.colorModeForRenderPass(),CullFaceMode.backCW,c,"skybox",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}(e,i,c,o,u):"gradient"===s&&"sky"===e.renderPass&&function(e,t,i,r,n){const o=e.context,a=o.gl,s=e.transform,c=e.useProgram("skyboxGradient");t.skyboxGeometry||(t.skyboxGeometry=new SkyboxGeometry(o)),o.activeTexture.set(a.TEXTURE0);let u=t.colorRampTexture;u||(u=t.colorRampTexture=new Texture(o,t.colorRamp,a.RGBA)),u.bind(a.LINEAR,a.CLAMP_TO_EDGE);const h=((e,t,i,r,n)=>({u_matrix:e,u_color_ramp:0,u_center_direction:t,u_radius:l(i),u_opacity:r,u_temporal_offset:n}))(s.skyboxMatrix,t.getCenter(e,!1),t.paint.get("sky-gradient-radius"),r,n);e.prepareDrawProgram(o,c),c.draw(o,a.TRIANGLES,i,StencilMode.disabled,e.colorModeForRenderPass(),CullFaceMode.backCW,h,"skyboxGradient",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}(e,i,c,o,u)},debug:function(e,t,i){for(let r=0;r<i.length;r++)yf(e,t,i[r])},custom:function(e,t,i){const r=e.context,n=i.implementation;if(e.transform.projection.unsupportedLayers&&e.transform.projection.unsupportedLayers.includes("custom"))B("Custom layers are not yet supported with non-mercator projections. Use mercator to enable custom layers.");else if("offscreen"===e.renderPass){const t=n.prerender;t&&(e.setCustomLayerDefaults(),r.setColorMode(e.colorModeForRenderPass()),t.call(n,r.gl,e.transform.customLayerMatrix()),r.setDirty(),e.setBaseState())}else if("translucent"===e.renderPass){e.setCustomLayerDefaults(),r.setColorMode(e.colorModeForRenderPass()),r.setStencilMode(StencilMode.disabled);const t="3d"===n.renderingMode?new DepthMode(e.context.gl.LEQUAL,DepthMode.ReadWrite,e.depthRangeFor3D):e.depthModeForSublayer(0,DepthMode.ReadOnly);r.setDepthMode(t),n.render(r.gl,e.transform.customLayerMatrix()),r.setDirty(),e.setBaseState(),r.bindFramebuffer.set(null)}}};class Painter{constructor(e,t){this.context=new Context(e),this.transform=t,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.setup(),this.numSublayers=SourceCache.maxUnderzooming+SourceCache.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new CrossTileSymbolIndex,this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={}}updateTerrain(e,t){const i=!!e&&!!e.terrain&&this.transform.projection.supportsTerrain;if(!(i||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new Terrain(this,e));const r=this._terrain;this.transform.elevation=i?r:null,r.update(e,this.transform,t)}_updateFog(e){const t=e.fog;if(!t||"globe"===this.transform.projection.name||t.getOpacity(this.transform.pitch)<1||t.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[i,r]=t.getFovAdjustedRange(this.transform._fov);if(i>r)return void(this.transform.fogCullDistSq=null);const n=i+.78*(r-i);this.transform.fogCullDistSq=n*n}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(e,t){if(this.width=e*ee.devicePixelRatio,this.height=t*ee.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style.order)this.style._layers[e].resize()}setup(){const t=this.context,i=new StructArrayLayout2i4;i.emplaceBack(0,0),i.emplaceBack(Eo,0),i.emplaceBack(0,Eo),i.emplaceBack(Eo,Eo),this.tileExtentBuffer=t.createVertexBuffer(i,$c.members),this.tileExtentSegments=SegmentVector.simpleSegment(0,0,4,2);const r=new StructArrayLayout2i4;r.emplaceBack(0,0),r.emplaceBack(Eo,0),r.emplaceBack(0,Eo),r.emplaceBack(Eo,Eo),this.debugBuffer=t.createVertexBuffer(r,$c.members),this.debugSegments=SegmentVector.simpleSegment(0,0,4,5);const n=new StructArrayLayout2i4;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(-1,1),n.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(n,$c.members),this.viewportSegments=SegmentVector.simpleSegment(0,0,4,2);const o=new StructArrayLayout4i8;o.emplaceBack(0,0,0,0),o.emplaceBack(Eo,0,Eo,0),o.emplaceBack(0,Eo,0,Eo),o.emplaceBack(Eo,Eo,Eo,Eo),this.mercatorBoundsBuffer=t.createVertexBuffer(o,Ah.members),this.mercatorBoundsSegments=SegmentVector.simpleSegment(0,0,4,2);const a=new StructArrayLayout3ui6;a.emplaceBack(0,1,2),a.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(a);const s=new StructArrayLayout1ui2;for(const e of[0,1,3,2,0])s.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(s),this.emptyTexture=new Texture(t,new RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA),this.identityMat=ga();const l=this.context.gl;this.stencilClearMode=new StencilMode({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(e.performance.now()),this.atmosphereBuffer=new AtmosphereBuffer(this.context)}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(e){return e._makeTileBoundsBuffers(this.context,this.transform.projection),e._tileBoundsBuffer?{tileBoundsBuffer:e._tileBoundsBuffer,tileBoundsIndexBuffer:e._tileBoundsIndexBuffer,tileBoundsSegments:e._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const e=this.context,t=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(e,t.TRIANGLES,DepthMode.disabled,this.stencilClearMode,ColorMode.disabled,CullFaceMode.disabled,Ed(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(e,t,i){if(!t||this.currentStencilSource===t.id||!e.isTileClipped()||!i||0===i.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of i)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=t.id;const r=this.context,n=r.gl;this.nextStencilID+i.length>256&&this.clearStencil(),r.setColorMode(ColorMode.disabled),r.setDepthMode(DepthMode.disabled);const o=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of i){const i=t.getTile(e),a=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:s,tileBoundsIndexBuffer:l,tileBoundsSegments:c}=this.getTileBoundsBuffers(i);o.draw(r,n.TRIANGLES,DepthMode.disabled,new StencilMode({func:n.ALWAYS,mask:0},a,255,n.KEEP,n.KEEP,n.REPLACE),ColorMode.disabled,CullFaceMode.disabled,Ed(e.projMatrix),"$clipping",s,l,c)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new StencilMode({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);const t=this.context.gl;return new StencilMode({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}stencilConfigForOverlap(e){const t=this.context.gl,i=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=i[i.length-1].overscaledZ,n=i[0].overscaledZ-r+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();const e={};for(let i=0;i<n;i++)e[i+r]=new StencilMode({func:t.GEQUAL,mask:255},i+this.nextStencilID,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID+=n,[e,i]}return[{[r]:StencilMode.disabled},i]}colorModeForRenderPass(){const e=this.context.gl;if(this._showOverdrawInspector){const t=1/8;return new ColorMode([e.CONSTANT_COLOR,e.ONE],new Lt(t,t,t,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?ColorMode.unblended:ColorMode.alphaBlended}depthModeForSublayer(e,t,i){if(!this.opaquePassEnabledForLayer())return DepthMode.disabled;const r=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new DepthMode(i||this.context.gl.LEQUAL,t,[r,r])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,i){this.style=t,this.options=i,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(ee.now()),this.imageManager.beginFrame();const r=this.style.order,n=this.style._sourceCaches;for(const e in n){const t=n[e];t.used&&t.prepare(this.context)}const o={},a={},s={};for(const e in n){const t=n[e];o[e]=t.getVisibleCoordinates(),a[e]=o[e].slice().reverse(),s[e]=t.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let e=0;e<r.length;e++)if(this.style._layers[r[e]].is3D()){this.opaquePassCutoff=e;break}if(this.terrain&&(this.terrain.updateTileBinding(s),this.opaquePassCutoff=0),"globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new GlobeSharedBuffers(this.context)),Re.has(this.context.gl)){this.renderPass="offscreen";for(const e of r){const i=this.style._layers[e],r=t._getLayerSourceCache(i);if(!i.hasOffscreenPass()||i.isHidden(this.transform.zoom))continue;const n=r?a[r.id]:void 0;("custom"===i.type||i.isSky()||n&&n.length)&&this.renderLayer(this,r,i,n)}if(this.depthRangeFor3D=[0,1-(t.order.length+2)*this.numSublayers*this.depthEpsilon],this.terrain&&(this.style.hasSymbolLayers()||this.style.hasCircleLayers())&&this.terrain.drawDepth(),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]),this.context.clear({color:i.showOverdrawInspector?Lt.black:Lt.transparent,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.renderPass="opaque",!this.terrain)for(this.currentLayer=r.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[r[this.currentLayer]],i=t._getLayerSourceCache(e);if(e.isSky())continue;const n=i?a[i.id]:void 0;this._renderTileClippingMasks(e,i,n),this.renderLayer(this,i,e,n)}if(this.style.fog&&this.transform.projection.supportsFog&&function(e,t){const i=e.context,r=i.gl,n=e.transform,o=new DepthMode(r.LEQUAL,DepthMode.ReadOnly,[0,1]),a=e.useProgram("globeAtmosphere",null,"globe"===n.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"]),s=_u(n.zoom),c=t.properties.get("color").toArray01(),u=t.properties.get("high-color").toArray01(),h=t.properties.get("space-color").toArray01PremultipliedAlpha(),p=ns([]);as(p,p,-l(n._center.lng)),os(p,p,l(n._center.lat)),ss(p,p,n.angle),os(p,p,-n._pitch);const d=Ia(new Float32Array(16),p),f=k(t.properties.get("star-intensity"),0,1,0,.25),m=5e-4,_=k(t.properties.get("horizon-blend"),0,1,m,.25),g=yu(e,i,n)&&_===m?n.worldSize/(2*Math.PI*1.025)-1:n.globeRadius,y=e.frameCounter/1e3%1,x=La(n.globeCenterInViewSpace),v=Math.sqrt(Math.pow(x,2)-Math.pow(g,2)),b=Math.acos(v/x),w=((e,t,i,r,n,o,a,s,l,c,u,h,p,d)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:i,u_frustum_bl:r,u_horizon:n,u_transition:o,u_fadeout_range:a,u_color:s,u_high_color:l,u_space_color:c,u_star_intensity:u,u_star_size:5*ee.devicePixelRatio,u_star_density:0,u_temporal_offset:h,u_horizon_angle:p,u_rotation_matrix:d}))(n.frustumCorners.TL,n.frustumCorners.TR,n.frustumCorners.BR,n.frustumCorners.BL,n.frustumCorners.horizon,s,_,c,u,h,f,y,b,d);e.prepareDrawProgram(i,a);const T=e.atmosphereBuffer;T&&a.draw(i,r.TRIANGLES,o,StencilMode.disabled,ColorMode.alphaBlended,CullFaceMode.backCW,w,"skybox",T.vertexBuffer,T.indexBuffer,T.segments)}(this,this.style.fog),this.renderPass="sky",(_u(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer<r.length;this.currentLayer++){const e=this.style._layers[r[this.currentLayer]],i=t._getLayerSourceCache(e);e.isSky()&&this.renderLayer(this,i,e,i?a[i.id]:void 0)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<r.length;){const e=this.style._layers[r[this.currentLayer]],i=t._getLayerSourceCache(e);if(e.isSky()){++this.currentLayer;continue}if(this.terrain&&this.style.isLayerDraped(e)){if(e.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer);continue}const n=i?("symbol"===e.type?s:a)[i.id]:void 0;this._renderTileClippingMasks(e,i,i?o[i.id]:void 0),this.renderLayer(this,i,e,n),++this.currentLayer}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry){let e=null;v(this.style._layers).forEach((i=>{const r=t._getLayerSourceCache(i);r&&!i.isHidden(this.transform.zoom)&&(!e||e.getSource().maxzoom<r.getSource().maxzoom)&&(e=r)})),e&&this.options.showTileBoundaries&&Cf.debug(this,e,e.getVisibleCoordinates())}this.options.showPadding&&function(e){const t=e.transform.padding;xf(e,e.transform.height-(t.top||0),3,df),xf(e,t.bottom||0,3,ff),vf(e,t.left||0,3,mf),vf(e,e.transform.width-(t.right||0),3,_f);const i=e.transform.centerPoint;!function(e,t,i,r){bf(e,t-1,i-10,2,20,r),bf(e,t-10,i-1,20,2,r)}(e,i.x,e.transform.height-i.y,gf)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(e.performance.now()),this.saveCanvasCopy())}}renderLayer(e,t,i,r){i.isHidden(this.transform.zoom)||("background"===i.type||"sky"===i.type||"custom"===i.type||r&&r.length)&&(this.id=i.id,this.gpuTimingStart(i),e.transform.projection.unsupportedLayers&&e.transform.projection.unsupportedLayers.includes(i.type)||Cf[i.type](e,t,i,r,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(e){if(!this.options.gpuTiming)return;const t=this.context.extTimerQuery;let i=this.gpuTimers[e.id];i||(i=this.gpuTimers[e.id]={calls:0,cpuTime:0,query:t.createQueryEXT()}),i.calls++,t.beginQueryEXT(t.TIME_ELAPSED_EXT,i.query)}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){const e=this.context.extTimerQuery,t=e.createQueryEXT();this.deferredRenderGpuTimeQueries.push(t),e.beginQueryEXT(e.TIME_ELAPSED_EXT,t)}}gpuTimingDeferredRenderEnd(){if(!this.options.gpuTimingDeferredRender)return;const e=this.context.extTimerQuery;e.endQueryEXT(e.TIME_ELAPSED_EXT)}gpuTimingEnd(){if(!this.options.gpuTiming)return;const e=this.context.extTimerQuery;e.endQueryEXT(e.TIME_ELAPSED_EXT)}collectGpuTimers(){const e=this.gpuTimers;return this.gpuTimers={},e}collectDeferredRenderGpuQueries(){const e=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],e}queryGpuTimers(e){const t={};for(const i in e){const r=e[i],n=this.context.extTimerQuery,o=n.getQueryObjectEXT(r.query,n.QUERY_RESULT_EXT)/1e6;n.deleteQueryEXT(r.query),t[i]=o}return t}queryGpuTimeDeferredRender(e){if(!this.options.gpuTimingDeferredRender)return 0;const t=this.context.extTimerQuery;let i=0;for(const r of e)i+=t.getQueryObjectEXT(r,t.QUERY_RESULT_EXT)/1e6,t.deleteQueryEXT(r);return i}translatePosMatrix(e,t,i,r,n){if(!i[0]&&!i[1])return e;const o=n?"map"===r?this.transform.angle:0:"viewport"===r?-this.transform.angle:0;if(o){const e=Math.sin(o),t=Math.cos(o);i=[i[0]*t-i[1]*e,i[0]*e+i[1]*t]}const a=[n?i[0]:dh(t,i[0],this.transform.zoom),n?i[1]:dh(t,i[1],this.transform.zoom),0],s=new Float32Array(16);return ba(s,e,a),s}saveTileTexture(e){const t=this._tileTextures[e.size[0]];t?t.push(e):this._tileTextures[e.size[0]]=[e]}getTileTexture(e){const t=this._tileTextures[e];return t&&t.length>0?t.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const t=this.imageManager.getPattern(e.from.toString()),i=this.imageManager.getPattern(e.to.toString());return!t||!i}currentGlobalDefines(){const e=this.terrain&&this.terrain.renderingToTexture,t=this.style&&this.style.fog,i=[];return this.terrain&&!this.terrain.renderingToTexture&&i.push("TERRAIN"),t&&!e&&0!==t.getOpacity(this.transform.pitch)&&i.push("FOG"),e&&i.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&i.push("OVERDRAW_INSPECTOR"),i}useProgram(e,t,i){this.cache=this.cache||{};const r=i||[],n=this.currentGlobalDefines().concat(r),o=Program.cacheKey(ud[e],e,n,t);return this.cache[o]||(this.cache[o]=new Program(this.context,e,ud[e],t,ef[e],n)),this.cache[o]}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 e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=e.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new 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(),this.atmosphereBuffer&&this.atmosphereBuffer.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}prepareDrawProgram(e,t,i){if(this.terrain&&this.terrain.renderingToTexture)return;const r=this.style.fog;if(r){const n=r.getOpacity(this.transform.pitch),o=((e,t,i,r,n,o,a,s,l,c,u)=>{const h=e.transform,p=t.properties.get("color").toArray01();p[3]=r;const d=e.frameCounter/1e3%1;return{u_fog_matrix:i?h.calculateFogTileMatrix(i):e.identityMat,u_fog_range:t.getFovAdjustedRange(h._fov),u_fog_color:p,u_fog_horizon_blend:t.properties.get("horizon-blend"),u_fog_temporal_offset:d,u_frustum_tl:n,u_frustum_tr:o,u_frustum_br:a,u_frustum_bl:s,u_globe_pos:l,u_globe_radius:c,u_viewport:u,u_globe_transition:_u(h.zoom),u_is_globe:+("globe"===h.projection.name)}})(this,r,i,n,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*ee.devicePixelRatio,this.transform.height*ee.devicePixelRatio]);t.setFogUniformValues(e,o)}}setTileLoadedFlag(e){this.tileLoaded=e}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const e=this.context.gl,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,0,0,e.drawingBufferWidth,e.drawingBufferHeight,0),t}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const e=this.style&&this.style.fog;return!!e&&0!==e.getOpacity(this.transform.pitch)}getBackgroundTiles(){const e=this._backgroundTiles,t=this._backgroundTiles={},i=this.transform.coveringTiles({tileSize:512});for(const r of i)t[r.key]=e[r.key]||new Tile(r,512,this.transform.tileZoom,this);return t}clearBackgroundTiles(){this._backgroundTiles={}}}class EdgeInsets{constructor(e=0,t=0,i=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=r}interpolate(e,t,i){return null!=t.top&&null!=e.top&&(this.top=xi(e.top,t.top,i)),null!=t.bottom&&null!=e.bottom&&(this.bottom=xi(e.bottom,t.bottom,i)),null!=t.left&&null!=e.left&&(this.left=xi(e.left,t.left,i)),null!=t.right&&null!=e.right&&(this.right=xi(e.right,t.right,i)),this}getCenter(e,t){const i=_((this.left+e-this.right)/2,0,e),n=_((this.top+t-this.bottom)/2,0,t);return new r(i,n)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new EdgeInsets(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function If(e,t){const i=Z(e,3);Ia(e,t),q(e,3,i)}function Mf(e,t){const i=ns([]);return ss(i,i,-t),os(i,i,-e),i}function Pf(e,t){const i=[e[0],e[1],0],r=[t[0],t[1],0];if(La(i)>=1e-15){const e=Za([],i);ja(r,e,qa(r,e)),t[0]=r[0],t[1]=r[1]}const n=$a([],t,e);if(es(n)<1e-15)return null;const o=Math.atan2(-n[1],n[0]);return Mf(Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2]),o)}class FreeCameraOptions{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(e){if(e){const t=e instanceof MercatorCoordinate?e:new MercatorCoordinate(e[0],e[1],e[2]);this._renderWorldCopies&&(t.x=y(t.x,0,1)),this._position=t}else this._position=null}lookAtPoint(e,t){if(this.orientation=null,!this.position)return;const i=this._elevation?this._elevation.getAtPointOrZero(MercatorCoordinate.fromLngLat(e)):0,r=this.position,n=MercatorCoordinate.fromLngLat(e,i),o=[n.x-r.x,n.y-r.y,n.z-r.z];t||(t=[0,0,1]),t[2]=Math.abs(t[2]),this.orientation=Pf(o,t)}setPitchBearing(e,t){this.orientation=Mf(l(e),l(-t))}}class FreeCamera{constructor(e,t){this._transform=ya([]),this.orientation=t,this.position=e}get mercatorPosition(){const e=this.position;return new MercatorCoordinate(e[0],e[1],e[2])}get position(){const e=Z(this._transform,3);return[e[0],e[1],e[2]]}set position(e){var t;e&&q(this._transform,3,[(t=e)[0],t[1],t[2],1])}get orientation(){return this._orientation}set orientation(e){this._orientation=e||ns([]),e&&If(this._transform,this._orientation)}getPitchBearing(){const e=this.forward(),t=this.right();return{bearing:Math.atan2(-t[1],t[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,t){this._orientation=Mf(e,t),If(this._transform,this._orientation)}forward(){const e=Z(this._transform,2);return[-e[0],-e[1],-e[2]]}up(){const e=Z(this._transform,1);return[-e[0],-e[1],-e[2]]}right(){const e=Z(this._transform,0);return[e[0],e[1],e[2]]}getCameraToWorld(e,t){const i=new Float64Array(16);return xa(i,this.getWorldToCamera(e,t)),i}getWorldToCameraPosition(e,t,i){const r=this.position;ja(r,r,-e);const n=new Float64Array(16);return Aa(n,[i,i,i]),ba(n,n,r),n[10]*=t,n}getWorldToCamera(e,t){const i=new Float64Array(16),r=new Float64Array(4),n=this.position;var o,a;return(o=r)[0]=-(a=this._orientation)[0],o[1]=-a[1],o[2]=-a[2],o[3]=a[3],ja(n,n,-e),Ia(i,r),ba(i,i,n),i[1]*=-1,i[5]*=-1,i[9]*=-1,i[13]*=-1,i[8]*=t,i[9]*=t,i[10]*=t,i[11]*=t,i}getCameraToClipPerspective(e,t,i,r){const n=new Float64Array(16);return Ma(n,e,t,i,r),n}getDistanceToElevation(e){const t=0===e?0:Po(e,this.position[1]),i=this.forward();return(t-this.position[2])/i[2]}clone(){return new FreeCamera([...this.position],[...this.orientation])}}function Df(e,t){const i=kf(e.projection,e.zoom,e.width,e.height),r=function(e,t,i,r,n){const o=new LngLat(i.lng-180*Lf,i.lat),a=new LngLat(i.lng+180*Lf,i.lat),s=e.project(o.lng,o.lat),l=e.project(a.lng,a.lat),c=-Math.atan2(l.y-s.y,l.x-s.x),u=MercatorCoordinate.fromLngLat(i);u.y=_(u.y,-.999975,.999975);const h=u.toLngLat(),p=e.project(h.lng,h.lat),d=MercatorCoordinate.fromLngLat(h);d.x+=Lf;const f=d.toLngLat(),m=e.project(f.lng,f.lat),g=Rf(m.x-p.x,m.y-p.y,c),y=MercatorCoordinate.fromLngLat(h);y.y+=Lf;const x=y.toLngLat(),v=e.project(x.lng,x.lat),b=Rf(v.x-p.x,v.y-p.y,c),w=Math.abs(g.x)/Math.abs(b.y),T=ya([]);Sa(T,T,-c*(1-(n?0:r)));const E=ya([]);return wa(E,E,[1,1-(1-w)*r,1]),E[4]=-b.x/b.y*r,Sa(E,E,c),va(E,T,E),E}(e.projection,0,e.center,i,t),n=zf(e);return wa(r,r,[n,n,1]),r}function zf(e){const t=e.projection,i=kf(e.projection,e.zoom,e.width,e.height),r=Bf(t,e.center),n=Bf(t,LngLat.convert(t.center));return Math.pow(2,r*i+(1-i)*n)}function kf(e,t,i,r,n=1/0){const o=e.range;if(!o)return 0;const a=Math.min(n,Math.max(i,r)),s=Math.log(a/1024)/Math.LN2;return g(o[0]+s,o[1]+s,t)}const Lf=1/4e4;function Bf(e,t){const i=_(t.lat,-85.051129,Lo),r=new LngLat(t.lng-180*Lf,i),n=new LngLat(t.lng+180*Lf,i),o=e.project(r.lng,i),a=e.project(n.lng,i),s=MercatorCoordinate.fromLngLat(r),l=MercatorCoordinate.fromLngLat(n),c=a.x-o.x,u=a.y-o.y,h=l.x-s.x,p=l.y-s.y,d=Math.sqrt((h*h+p*p)/(c*c+u*u));return Math.log(d)/Math.LN2}function Rf(e,t,i){const r=Math.cos(i),n=Math.sin(i);return{x:e*r-t*n,y:e*n+t*r}}class Transform{constructor(e,t,i,r,n,o,a){this.tileSize=512,this._renderWorldCopies=void 0===n||n,this._minZoom=e||0,this._maxZoom=t||22,this._minPitch=null==i?0:i,this._maxPitch=null==r?60:r,this.setProjection(o),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new 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 EdgeInsets,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new FreeCamera,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1}clone(){const e=new Transform(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,e.tileSize=this.tileSize,e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._seaLevelZoom=this._seaLevelZoom,e.angle=this.angle,e._fov=this._fov,e._pitch=this._pitch,e._nearZ=this._nearZ,e._farZ=this._farZ,e._averageElevation=this._averageElevation,e._unmodified=this._unmodified,e._edgeInsets=this._edgeInsets.clone(),e._camera=this._camera.clone(),e._calcMatrices(),e.freezeTileCoverage=this.freezeTileCoverage,e.frustumCorners=this.frustumCorners,e}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(e){const t=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||t)&&this._updateCameraOnTerrain(),(e||t)&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return w(this.projection,["name","center","parallels"])}setProjection(e){this.projectionOptions=e||{name:"mercator"};const t=this.projection?this.getProjection():void 0;this.projection=Nu(this.projectionOptions);const i=!o(t,this.getProjection());return i&&this._calcMatrices(),this.mercatorFromTransition=!1,i}setMercatorFromTransition(){const e=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=Nu({name:"mercator"});const t=e!==this.projection.name;return t&&this._calcMatrices(),t}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return Po(this.center.lat,this.cameraWorldSize)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new r(this.width,this.height)}get bearing(){return y(this.rotation,-180,180)}set bearing(e){this.rotation=e}get rotation(){return-this.angle/Math.PI*180}set rotation(e){const t=-e*Math.PI/180;var i;this.angle!==t&&(this._unmodified=!1,this.angle=t,this._calcMatrices(),this.rotationMatrix=(i=new pa(4),pa!=Float32Array&&(i[1]=0,i[2]=0),i[0]=1,i[3]=1,i),function(e,t,i){var r=t[0],n=t[1],o=t[2],a=t[3],s=Math.sin(i),l=Math.cos(i);e[0]=r*l+o*s,e[1]=n*l+a*s,e[2]=r*-s+o*l,e[3]=n*-s+a*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(e){const t=_(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==t&&(this._unmodified=!1,this._pitch=t,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(e){e=Math.max(.01,Math.min(60,e)),this._fov!==e&&(this._unmodified=!1,this._fov=e/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(e){const t=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==t&&(this._unmodified=!1,this._setZoom(t),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom}_updateCameraOnTerrain(){if(!this._elevation||!this._elevation.isDataAvailableAtPoint(this.locationCoordinate(this.center)))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const e=this._elevation;this._centerAltitude=e.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=e.exaggeration(),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const e=this._elevation,t=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],i=this.horizonLineFromTop();let n=0,o=0;for(let a=0;a<t.length;a++){const s=new r(t[a][0]*this.width,i+t[a][1]*(this.height-i)),l=e.pointCoordinate(s);if(!l)continue;const c=1/Math.hypot(l[0]-this._camera.position[0],l[1]-this._camera.position[1]);n+=l[3]*c,o+=c}return 0===o?NaN:n/o}get center(){return this._center}set center(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._terrainEnabled()&&("ground"===this.cameraElevationReference?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(null==this._seaLevelZoom||!this._elevation)return;const e=this._seaLevelZoom,t=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),i=this.pixelsPerMeter/this.worldSize*t,r=this._mercatorZfromZoom(e),n=this._mercatorZfromZoom(this._maxZoom),o=Math.max(r-i,n);this._setZoom(this._zoomFromMercatorZ(o))}get padding(){return this._edgeInsets.toJSON()}set padding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}computeZoomRelativeTo(e){const t=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,e.toAltitude()));let i;i=e.z<this._camera.position[2]?[t.x,t.y,t.z]:[e.x,e.y,e.z];const r=La(Ja([],this._camera.position,i));return _(this._zoomFromMercatorZ(r),this._minZoom,this._maxZoom)}setFreeCameraOptions(e){if(!this.height)return;if(!e.position&&!e.orientation)return;this._updateCameraState();let t=!1;if(e.orientation&&!function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]}(e.orientation,this._camera.orientation)&&(t=this._setCameraOrientation(e.orientation)),e.position){const n=[e.position.x,e.position.y,e.position.z];((i=n)[0]!==(r=this._camera.position)[0]||i[1]!==r[1]||i[2]!==r[2])&&(this._setCameraPosition(n),t=!0)}var i,r;t&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const e=this._camera.position,t=new FreeCameraOptions;return t.position=new MercatorCoordinate(e[0],e[1],e[2]),t.orientation=this._camera.orientation,t._elevation=this.elevation,t._renderWorldCopies=this.renderWorldCopies,t}_setCameraOrientation(e){if(t=e,!Math.hypot(t[0],t[1],t[2],t[3]))return!1;var t;!function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],a=i*i+r*r+n*n+o*o;a>0&&(a=1/Math.sqrt(a)),e[0]=i*a,e[1]=r*a,e[2]=n*a,e[3]=o*a}(e,e);const i=Xa([],[0,0,-1],e),r=Xa([],[0,-1,0],e);if(r[2]<0)return!1;const n=Pf(i,r);return!!n&&(this._camera.orientation=n,!0)}_setCameraPosition(e){const t=this.zoomScale(this.minZoom)*this.tileSize,i=this.zoomScale(this.maxZoom)*this.tileSize,r=this.cameraToCenterDistance;e[2]=_(e[2],r/i,r/t),this._camera.position=e}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this._constrain(),this._calcMatrices()}coveringZoomLevel(e){const t=(e.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/e.tileSize));return Math.max(0,t)}getVisibleUnwrappedCoordinates(e){const t=[new UnwrappedTileID(0,e)];if(this.renderWorldCopies){const i=this.pointCoordinate(new r(0,0)),n=this.pointCoordinate(new r(this.width,0)),o=this.pointCoordinate(new r(this.width,this.height)),a=this.pointCoordinate(new r(0,this.height)),s=Math.floor(Math.min(i.x,n.x,o.x,a.x)),l=Math.floor(Math.max(i.x,n.x,o.x,a.x)),c=1;for(let i=s-c;i<=l+c;i++)0!==i&&t.push(new UnwrappedTileID(i,e))}return t}coveringTiles(e){let t=this.coveringZoomLevel(e);const i=t,r=this.elevation&&!e.isTerrainDEM,n="mercator"===this.projection.name;if(void 0!==e.minzoom&&t<e.minzoom)return[];void 0!==e.maxzoom&&t>e.maxzoom&&(t=e.maxzoom);const o=this.locationCoordinate(this.center),a=this.center.lat,s=1<<t,l=[s*o.x,s*o.y,0],c="globe"===this.projection.name,h=!c,p=Frustum.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,h),d=c?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),f=s*Po(1,this.center.lat),m=this._camera.position[2]/Po(1,this.center.lat),_=[s*d.x,s*d.y,m*(h?1:f)],g=this.cameraToCenterDistance/e.tileSize*(e.roundZoom?1:.502),y=this.pitch<=60&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace?t:0,x=e.isTerrainDEM&&this._elevation?1e4*this._elevation.exaggeration():this._centerAltitude,v=e.isTerrainDEM?-x:this._elevation?this._elevation.getMinElevationBelowMSL():0,b=this.projection.isReprojectedInTileSpace?zf(this):1,w=e=>{const t=1/4e4,i=new MercatorCoordinate(e.x+t,e.y,e.z),r=new MercatorCoordinate(e.x,e.y+t,e.z),n=e.toLngLat(),o=i.toLngLat(),a=r.toLngLat(),s=this.locationCoordinate(n),l=this.locationCoordinate(o),c=this.locationCoordinate(a),u=Math.hypot(l.x-s.x,l.y-s.y),h=Math.hypot(c.x-s.x,c.y-s.y);return Math.sqrt(u*h)*b/t},T=e=>{const t=x,i=v;return{aabb:Mu(this,s,0,0,0,e,i,t,this.projection),zoom:0,x:0,y:0,minZ:i,maxZ:t,wrap:e,fullyVisible:!1}},E=[];let S=[];const A=t,C=e.reparseOverscaled?i:t,I=e=>e*e,M=I((m-this._centerAltitude)*f),P=e=>{if(!this._elevation||!e.tileID||!n)return;const t=this._elevation.getMinMaxForTile(e.tileID),i=e.aabb;t?(i.min[2]=t.min,i.max[2]=t.max,i.center[2]=(i.min[2]+i.max[2])/2):(e.shouldSplit=D(e),e.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude))},D=e=>{if(e.zoom<y)return!0;if(e.zoom===A)return!1;if(null!=e.shouldSplit)return e.shouldSplit;const t=e.aabb.distanceX(_),n=e.aabb.distanceY(_);let o=M,s=1;if(c){o=I(e.aabb.distanceZ(_));const t=Math.pow(2,e.zoom),i=zo((e.y+1)/t),r=zo(e.y/t),n=Math.min(Math.max(a,i),r),l=Co(n)/Co(a);if(s=n===a?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,l/this._mercatorScaleRatio),this.zoom<=5&&e.zoom===A-1&&l>=.9)return!0}else if(r&&(o=I(e.aabb.distanceZ(_)*f)),this.projection.isReprojectedInTileSpace&&i<=5){const t=Math.pow(2,e.zoom),i=w(new MercatorCoordinate((e.x+.5)/t,(e.y+.5)/t));s=i>.85?1:i}const l=t*t+n*n+o;return l<I((1<<A-e.zoom)*g*s*((e,t)=>{if(t*I(.707)<e)return 1;const i=Math.sqrt(t/e);return i/(1.4144271570014144+(Math.pow(1.1,i-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(o,M),l))};if(this.renderWorldCopies)for(let e=1;e<=3;e++)E.push(T(-e)),E.push(T(e));for(E.push(T(0));E.length>0;){const i=E.pop(),o=i.x,a=i.y;let u=i.fullyVisible;if(!u){const e=i.aabb.intersects(p);if(0===e)continue;u=2===e}if(i.zoom!==A&&D(i))for(let e=0;e<4;e++){const t=(o<<1)+e%2,l=(a<<1)+(e>>1),h={aabb:n?i.aabb.quadrant(e):Mu(this,s,i.zoom+1,t,l,i.wrap,i.minZ,i.maxZ,this.projection),zoom:i.zoom+1,x:t,y:l,wrap:i.wrap,fullyVisible:u,tileID:void 0,shouldSplit:void 0,minZ:i.minZ,maxZ:i.maxZ};r&&!c&&(h.tileID=new OverscaledTileID(i.zoom+1===A?C:i.zoom+1,i.wrap,i.zoom+1,t,l),P(h)),E.push(h)}else{const r=i.zoom===A?C:i.zoom;if(e.minzoom&&e.minzoom>r)continue;const n=l[0]-(.5+o+(i.wrap<<i.zoom))*(1<<t-i.zoom),s=l[1]-.5-a,c=i.tileID?i.tileID:new OverscaledTileID(r,i.wrap,i.zoom,o,a);S.push({tileID:c,distanceSq:n*n+s*s})}}if(this.fogCullDistSq){const t=this.fogCullDistSq,i=this.horizonLineFromTop();S=S.filter((r=>{const n=[0,0,0,1],o=[Eo,Eo,0,1],a=this.calculateFogTileMatrix(r.tileID.toUnwrapped());is(n,n,a),is(o,o,a);const s=function(e,t,i){let r=0;for(let i=0;i<2;++i){const n=0;e[i]>n&&(r+=(e[i]-n)*(e[i]-n)),t[i]<n&&(r+=(n-t[i])*(n-t[i]))}return r}(n,o);if(0===s)return!0;let l=!1;const c=this._elevation;if(c&&s>t&&0!==i){const t=this.calculateProjMatrix(r.tileID.toUnwrapped());let n;e.isTerrainDEM||(n=c.getMinMaxForTile(r.tileID)),n||(n={min:v,max:x});const o=function(e){const t=Math.round((e+45+360)%360/90)%4;return u[t]}(this.rotation),a=[o[0]*Eo,o[1]*Eo,n.max];Wa(a,a,t),l=(1-a[1])*this.height*.5<i}return s<t||l}))}return S.sort(((e,t)=>e.distanceSq-t.distanceSq)).map((e=>e.tileID))}resize(e,t){this.width=e,this.height=t,this.pixelsToGLUnits=[2/e,-2/t],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(e){const t=_(e.lat,-85.051129,Lo),i=this.projection.project(e.lng,t);return new r(i.x*this.worldSize,i.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(e,t){let i,r;const n=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;i=(t.x-n.x)/e,r=(t.y-n.y)/e}else{const e=this.pointCoordinate(t),o=this.pointCoordinate(n);i=e.x-o.x,r=e.y-o.y}const o=this.locationCoordinate(e);this.setLocation(new MercatorCoordinate(o.x-i,o.y-r))}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(e){return this.projection.locationPoint(this,e)}locationPoint3D(e){return this.projection.locationPoint(this,e,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e){return this.coordinateLocation(this.pointCoordinate3D(e))}locationCoordinate(e,t){const i=t?Po(t,e.lat):void 0,r=this.projection.project(e.lng,e.lat);return new MercatorCoordinate(r.x,r.y,i)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(e,t){const i=null!=t?t:this._centerAltitude,r=[e.x,e.y,0,1],n=[e.x,e.y,1,1];is(r,r,this.pixelMatrixInverse),is(n,n,this.pixelMatrixInverse);const o=n[3];ts(r,r,1/r[3]),ts(n,n,1/o);const a=r[2],s=n[2];return{p0:r,p1:n,t:a===s?0:(i-a)/(s-a)}}screenPointToMercatorRay(e){const t=[e.x,e.y,0,1],i=[e.x,e.y,1,1];return is(t,t,this.pixelMatrixInverse),is(i,i,this.pixelMatrixInverse),ts(t,t,1/t[3]),ts(i,i,1/i[3]),t[2]=Po(t[2],this._center.lat)*this.worldSize,i[2]=Po(i[2],this._center.lat)*this.worldSize,ts(t,t,1/this.worldSize),ts(i,i,1/this.worldSize),new Ray([t[0],t[1],t[2]],Za([],Ja([],i,t)))}rayIntersectionCoordinate(e){const{p0:t,p1:i,t:r}=e,n=Po(t[2],this._center.lat),o=Po(i[2],this._center.lat);return new MercatorCoordinate(xi(t[0],i[0],r)/this.worldSize,xi(t[1],i[1],r)/this.worldSize,xi(n,o,r))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(e){if(!this.elevation)return this.pointCoordinate(e);let t=this.projection.pointCoordinate3D(this,e.x,e.y);if(t)return new MercatorCoordinate(t[0],t[1],t[2]);let i=0,r=this.horizonLineFromTop();if(e.y>r)return this.pointCoordinate(e);const n=.02*r,o=e.clone();for(let e=0;e<10&&r-i>n;e++){o.y=xi(i,r,.66);const e=this.projection.pointCoordinate3D(this,o.x,o.y);e?(r=o.y,t=e):i=o.y}return t?new MercatorCoordinate(t[0],t[1],t[2]):this.pointCoordinate(e)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}_coordinatePoint(e,t){const i=t&&this.elevation?this.elevation.getAtPointOrZero(e,this._centerAltitude):this._centerAltitude,n=[e.x*this.worldSize,e.y*this.worldSize,i+e.toAltitude(),1];return is(n,n,this.pixelMatrix),n[3]>0?new r(n[0]/n[3],n[1]/n[3]):new r(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(e,t){const i=new r(this._edgeInsets.left,this._edgeInsets.top),n=new r(this.width-this._edgeInsets.right,this._edgeInsets.top),o=new r(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),a=new r(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let s=this.pointCoordinate(i,e),l=this.pointCoordinate(n,e);const c=this.pointCoordinate(o,t),u=this.pointCoordinate(a,t),h=(e,t)=>(t.y-e.y)/(t.x-e.x);return s.y>1&&l.y>=0?s=new MercatorCoordinate((1-u.y)/h(u,s)+u.x,1):s.y<0&&l.y<=1&&(s=new MercatorCoordinate(-u.y/h(u,s)+u.x,0)),l.y>1&&s.y>=0?l=new MercatorCoordinate((1-c.y)/h(c,l)+c.x,1):l.y<0&&s.y<=1&&(l=new MercatorCoordinate(-c.y/h(c,l)+c.x,0)),(new LngLatBounds).extend(this.coordinateLocation(s)).extend(this.coordinateLocation(l)).extend(this.coordinateLocation(u)).extend(this.coordinateLocation(c))}_getBounds3D(){const e=this.elevation;if(!e.visibleDemTiles.length)return this._getBounds(0,0);const t=e.visibleDemTiles.reduce(((e,t)=>{if(t.dem){const i=t.dem.tree;e.min=Math.min(e.min,i.minimums[0]),e.max=Math.max(e.max,i.maximums[0])}return e}),{min:Number.MAX_VALUE,max:0});return this._getBounds(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(e=!0){const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,i=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,i):i}getMaxBounds(){return this.maxBounds}setMaxBounds(e){this.maxBounds=e,this.minLat=-85.051129,this.maxLat=Lo,this.minLng=-180,this.maxLng=180,e&&(this.minLat=e.getSouth(),this.maxLat=e.getNorth(),this.minLng=e.getWest(),this.maxLng=e.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=Io(this.minLng)*this.tileSize,this.worldMaxX=Io(this.maxLng)*this.tileSize,this.worldMinY=Mo(this.maxLat)*this.tileSize,this.worldMaxY=Mo(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(e,t){return this.projection.createTileMatrix(this,t,e)}calculateDistanceTileData(e){const t=e.key,i=this._distanceTileDataCache;if(i[t])return i[t];const r=e.canonical,n=1/this.height,o=this.cameraWorldSize/this.zoomScale(r.z),a=(r.x+Math.pow(2,r.z)*e.wrap)*o,s=r.y*o,l=this.point,c=this.angle,u=Math.sin(-c),h=-Math.cos(-c);return i[t]={bearing:[u,h],center:[(l.x-a)*n,(l.y-s)*n],scale:o/Eo*n},i[t]}calculateFogTileMatrix(e){const t=e.key,i=this._fogTileMatrixCache;if(i[t])return i[t];const r=this.projection.createTileMatrix(this,this.cameraWorldSize,e);return va(r,this.worldToFogMatrix,r),i[t]=new Float32Array(r),i[t]}calculateProjMatrix(e,t=!1){const i=e.key,r=t?this._alignedProjMatrixCache:this._projMatrixCache;if(r[i])return r[i];const n=this.calculatePosMatrix(e,this.worldSize);return va(n,this.projection.isReprojectedInTileSpace?this.mercatorMatrix:t?this.alignedProjMatrix:this.projMatrix,n),r[i]=new Float32Array(n),r[i]}calculatePixelsToTileUnitsMatrix(e){const t=e.tileID.key,i=this._pixelsToTileUnitsCache;if(i[t])return i[t];const r=function(e,t){const{scale:i}=e.tileTransform,r=i*Eo/(e.tileSize*Math.pow(2,t.zoom-e.tileID.overscaledZ+e.tileID.canonical.z));return function(e,t,i){var r=t[1],n=t[2],o=t[3],a=i[0],s=i[1];return e[0]=t[0]*a,e[1]=r*a,e[2]=n*s,e[3]=o*s,e}(new Float32Array(4),t.inverseAdjustmentMatrix,[r,r])}(e,this);return i[t]=r,i[t]}customLayerMatrix(){return this.mercatorMatrix.slice()}recenterOnTerrain(){if(!this._elevation||"globe"===this.projection.name)return;const e=this._elevation;this._updateCameraState();const t=Po(1,this._center.lat)*this.worldSize,i=this._computeCameraPosition(t),r=this._camera.forward(),n=Po(1,this._center.lat);i[2]/=n,r[2]/=n,Za(r,r);const o=e.raycast(i,r,e.exaggeration());if(o){const e=Na([],i,r,o),t=new MercatorCoordinate(e[0],e[1],Po(e[2],zo(e[1]))),a=(t.z+La([t.x-i[0],t.y-i[1],t.z-i[2]*n]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(a),this._centerAltitude=t.toAltitude(),this._center=this.coordinateLocation(t),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCameraAltitude(){if(!this._elevation)return;const e=this._elevation;this._updateCameraState();const t=Po(1,this._center.lat)*this.worldSize,i=this._computeCameraPosition(t),r=e.getAtPointOrZero(new MercatorCoordinate(...i)),n=this._minimumHeightOverTerrain()*Math.cos(l(this._maxPitch)),o=this._camera.position[2]-this.pixelsPerMeter/this.worldSize*r;if(o<n){const e=this.locationCoordinate(this._center,this._centerAltitude),t=[e.x-i[0],e.y-i[1],e.z-i[2]],r=La(t);t[2]-=(n-o)/this._pixelsPerMercatorPixel;const a=La(t);if(0===a)return;ja(t,t,r/a*this._pixelsPerMercatorPixel),this._camera.position=[e.x-t[0],e.y-t[1],e.z*this._pixelsPerMercatorPixel-t[2]],this._camera.orientation=Pf(t,this._camera.up()),this._updateStateFromCamera()}}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const e="globe"===this.projection.name||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||e){const t=this.center;return t.lat=_(t.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!e)&&(t.lng=_(t.lng,this.minLng,this.maxLng)),this.center=t,void(this._constraining=!1)}const t=this._unmodified,{x:i,y:n}=this.point;let o=0,a=i,s=n;const l=this.width/2,c=this.height/2,u=this.worldMinY*this.scale,h=this.worldMaxY*this.scale;if(n-c<u&&(s=u+c),n+c>h&&(s=h-c),h-u<this.height&&(o=Math.max(o,this.height/(h-u)),s=(h+u)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const e=this.worldMinX*this.scale,t=this.worldMaxX*this.scale,r=this.worldSize/2-(e+t)/2;a=(i+r+this.worldSize)%this.worldSize-r,a-l<e&&(a=e+l),a+l>t&&(a=t-l),t-e<this.width&&(o=Math.max(o,this.width/(t-e)),a=(t+e)/2)}a===i&&s===n||(this.center=this.unproject(new r(a,s))),o&&(this.zoom+=this.scaleZoom(o)),this._constrainCameraAltitude(),this._unmodified=t,this._constraining=!1}_minZoomForBounds(){let e=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(e=Math.max(e,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),e}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const e=this.centerOffset,t=this.pixelsPerMeter;"globe"===this.projection.name&&(this._mercatorScaleRatio=Po(1,this.center.lat)/Po(1,45));const i=kf(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,i),this.cameraToCenterDistance=.5/Math.tan(.5*this._fov)*this.height*this._pixelsPerMercatorPixel,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const r=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?t:1),n=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);n[8]=2*-e.x/this.width,n[9]=2*e.y/this.height;let o=Da([],n,r);if(this.projection.isReprojectedInTileSpace){const e=this.locationCoordinate(this.center),t=ya([]);ba(t,t,[e.x*this.worldSize,e.y*this.worldSize,0]),va(t,t,Df(this)),ba(t,t,[-e.x*this.worldSize,-e.y*this.worldSize,0]),va(o,o,t),this.inverseAdjustmentMatrix=function(e){const t=Df(e,!0);return da([],[t[0],t[1],t[4],t[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];this.mercatorMatrix=wa([],o,[this.worldSize,this.worldSize,this.worldSize/t,1]),this.projMatrix=o,this.invProjMatrix=xa(new Float64Array(16),this.projMatrix);const a=xa([],n);this.frustumCorners=FrustumCorners.fromInvProjectionMatrix(a,this.horizonLineFromTop(),this.height);const s=new Float32Array(16);ya(s),wa(s,s,[1,-1,1]),Ta(s,s,this._pitch),Sa(s,s,this.angle);const l=Ma(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ),c=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;l[8]=2*-e.x/this.width,l[9]=2*(e.y+c)/this.height,this.skyboxMatrix=va(s,l,s);const u=this.point,h=u.x,p=u.y,d=this.width%2/2,f=this.height%2/2,m=Math.cos(this.angle),_=Math.sin(this.angle),g=h-Math.round(h)+m*d+_*f,y=p-Math.round(p)+m*f+_*d,x=new Float64Array(o);if(ba(x,x,[g>.5?g-1:g,y>.5?y-1:y,0]),this.alignedProjMatrix=x,o=ga(),wa(o,o,[this.width/2,-this.height/2,1]),ba(o,o,[1,-1,0]),this.labelPlaneMatrix=o,o=ga(),wa(o,o,[1,-1,1]),ba(o,o,[-1,-1,0]),wa(o,o,[2/this.width,2/this.height,1]),this.glCoordMatrix=o,this.pixelMatrix=va(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},o=xa(new Float64Array(16),this.pixelMatrix),!o)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=o,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=function(e){const{x:t,y:i}=e.point,{lng:r,lat:n}=e._center;return mu(t,i,e.worldSize,r,n)}(this);const e=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=Wa(e,e,r),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=o;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const e=this.cameraWorldSize,t=this.cameraPixelsPerMeter,i=this._camera.position,r=1/this.height/this._pixelsPerMercatorPixel,n=[e,e,t];ja(n,n,r),ja(i,i,-1),Oa(i,i,n);const o=ga();ba(o,o,i),wa(o,o,n),this.mercatorFogMatrix=o,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(e,t,r)}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),r=this.point,n=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return[r.x/this.worldSize-i[0]*n,r.y/this.worldSize-i[1]*n,e/this.worldSize*this._centerAltitude-i[2]*n]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(e){const t=this._maxCameraBoundsDistance()*Math.cos(this._pitch),i=e[2];let r=1;i>0&&(r=Math.min((t-this._camera.position[2])/i,1)),this._camera.position=Na([],this._camera.position,e,r),this._updateStateFromCamera(),this.projection.wrap&&(this.center=this.center.wrap())}_updateStateFromCamera(){const e=this._camera.position,t=this._camera.forward(),{pitch:i,bearing:r}=this._camera.getPitchBearing(),n=Po(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,o=this._mercatorZfromZoom(this._maxZoom)*Math.cos(l(this._maxPitch)),a=Math.max((e[2]-n)/Math.cos(i),o),s=this._zoomFromMercatorZ(a);Na(e,e,t,a),this._pitch=_(i,l(this.minPitch),l(this.maxPitch)),this.angle=y(r,-Math.PI,Math.PI),this._setZoom(_(s,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new MercatorCoordinate(e[0],e[1],e[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min((null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(e*this.tileSize))}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(B("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(e,t){const i=Math.min(e.x,t.x),n=Math.max(e.x,t.x),o=Math.min(e.y,t.y),a=Math.max(e.y,t.y);if(o<this.horizonLineFromTop(!1))return!0;if("mercator"!==this.projection.name)return!1;const s=[new r(i,o),new r(n,a),new r(i,a),new r(n,o)],l=this.renderWorldCopies?-3:0,c=this.renderWorldCopies?4:1;for(const e of s){const t=this.pointRayIntersection(e);if(t.t<0)return!0;const i=this.rayIntersectionCoordinate(t);if(i.x<l||i.y<0||i.x>c||i.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+c(this.fovAboveCenter)>88||this.anyCornerOffEdge(new r(0,0),new r(this.width,this.height))}zoomDeltaToMovement(e,t){const i=La(Ja([],this._camera.position,e)),r=this._zoomFromMercatorZ(i)+t;return i-this._mercatorZfromZoom(r)}getCameraPoint(){if("globe"===this.projection.name){const e=function(e,t){const i=[e[0],e[1],e[2],1];is(i,i,t);const r=Math.max(i[3],1e-6);return[i[0]/r,i[1]/r,i[2]/r,r]}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new r(e[0],e[1])}{const e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new r(0,e))}}getCameraToCenterDistance(e){const t=kf(e,this.zoom,this.width,this.height,1024),i=e.pixelSpaceConversion(this.center.lat,this.worldSize,t);return.5/Math.tan(.5*this._fov)*this.height*i}}function Ff(e,t){let i=!1,r=null;const n=()=>{r=null,i&&(e(),r=setTimeout(n,t),i=!1)};return()=>(i=!0,r||n(),r)}class Hash{constructor(e){this._hashName=e&&encodeURIComponent(e),I(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Ff(this._updateHashUnthrottled.bind(this),300)}addTo(t){return this._map=t,e.addEventListener("hashchange",this._onHashChange,!1),t.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),e.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const t=this._map;if(!t)return"";const i=Of(t);if(this._hashName){const t=this._hashName;let r=!1;const n=e.location.hash.slice(1).split("&").map((e=>{const n=e.split("=")[0];return n===t?(r=!0,`${n}=${i}`):e})).filter((e=>e));return r||n.push(`${t}=${i}`),`#${n.join("&")}`}return`#${i}`}_getCurrentHash(){const t=e.location.hash.replace("#","");if(this._hashName){let e;return t.split("&").map((e=>e.split("="))).forEach((t=>{t[0]===this._hashName&&(e=t)})),(e&&e[1]||"").split("/")}return t.split("/")}_onHashChange(){const e=this._map;if(!e)return!1;const t=this._getCurrentHash();if(t.length>=3&&!t.some((e=>isNaN(e)))){const i=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:i,pitch:+(t[4]||0)}),!0}return!1}_updateHashUnthrottled(){const t=e.location.href.replace(/(#.+)?$/,this.getHashString());e.history.replaceState(e.history.state,null,t)}}function Of(e,t){const i=e.getCenter(),r=Math.round(100*e.getZoom())/100,n=Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,n),a=Math.round(i.lng*o)/o,s=Math.round(i.lat*o)/o,l=e.getBearing(),c=e.getPitch();let u=t?`/${a}/${s}/${r}`:`${r}/${s}/${a}`;return(l||c)&&(u+="/"+Math.round(10*l)/10),c&&(u+=`/${Math.round(c)}`),u}const Vf={linearity:.3,easing:f(0,0,.3,1)},Uf=b({deceleration:2500,maxSpeed:1400},Vf),jf=b({deceleration:20,maxSpeed:1400},Vf),Nf=b({deceleration:1e3,maxSpeed:360},Vf),Gf=b({deceleration:1e3,maxSpeed:90},Vf);class HandlerInertia{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:ee.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,t=ee.now();for(;e.length>0&&t-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const t={zoom:0,bearing:0,pitch:0,pan:new r(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)t.zoom+=e.zoomDelta||0,t.bearing+=e.bearingDelta||0,t.pitch+=e.pitchDelta||0,e.panDelta&&t.pan._add(e.panDelta),e.around&&(t.around=e.around),e.pinchAround&&(t.pinchAround=e.pinchAround);const i=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,n={};if(t.pan.mag()){const r=qf(t.pan.mag(),i,b({},Uf,e||{}));n.offset=t.pan.mult(r.amount/t.pan.mag()),n.center=this._map.transform.center,Zf(n,r)}if(t.zoom){const e=qf(t.zoom,i,jf);n.zoom=this._map.transform.zoom+e.amount,Zf(n,e)}if(t.bearing){const e=qf(t.bearing,i,Nf);n.bearing=this._map.transform.bearing+_(e.amount,-179,179),Zf(n,e)}if(t.pitch){const e=qf(t.pitch,i,Gf);n.pitch=this._map.transform.pitch+e.amount,Zf(n,e)}if(n.zoom||n.bearing){const e=void 0===t.pinchAround?t.around:t.pinchAround;n.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),n.noMoveStart=!0,n}}function Zf(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function qf(e,t,i){const{maxSpeed:r,linearity:n,deceleration:o}=i,a=_(e*n/(t/1e3),-r,r),s=Math.abs(a)/(o*n);return{easing:i.easing,duration:1e3*s,amount:a*(s/2)}}class MapMouseEvent extends Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i,r={}){const n=he(t.getCanvasContainer(),i);super(e,b({point:n,lngLat:t.unproject(n),originalEvent:i},r)),this._defaultPrevented=!1,this.target=t}}class MapTouchEvent extends Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){const n="touchend"===e?i.changedTouches:i.touches,o=pe(t.getCanvasContainer(),n),a=o.map((e=>t.unproject(e))),s=o.reduce(((e,t,i,r)=>e.add(t.div(r.length))),new r(0,0));super(e,{points:o,point:s,lngLats:a,lngLat:t.unproject(s),originalEvent:i}),this._defaultPrevented=!1}}class MapWheelEvent extends Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1}}class MapEventHandler{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new MapWheelEvent(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new MapMouseEvent(e.type,this._map,e))}mouseup(e){this._map.fire(new MapMouseEvent(e.type,this._map,e))}preclick(e){const t=b({},e);t.type="preclick",this._map.fire(new MapMouseEvent(t.type,this._map,t))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new MapMouseEvent(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new MapMouseEvent(e.type,this._map,e))}mouseover(e){this._map.fire(new MapMouseEvent(e.type,this._map,e))}mouseout(e){this._map.fire(new MapMouseEvent(e.type,this._map,e))}touchstart(e){return this._firePreventable(new MapTouchEvent(e.type,this._map,e))}touchmove(e){this._map.fire(new MapTouchEvent(e.type,this._map,e))}touchend(e){this._map.fire(new MapTouchEvent(e.type,this._map,e))}touchcancel(e){this._map.fire(new MapTouchEvent(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class BlockableMapEventHandler{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new MapMouseEvent(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new MapMouseEvent("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new MapMouseEvent(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class BoxZoomHandler{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(se(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)<this._clickTolerance)return;const r=this._startPos;this._lastPos=i,this._box||(this._box=te("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",e));const n=Math.min(r.x,i.x),o=Math.max(r.x,i.x),a=Math.min(r.y,i.y),s=Math.max(r.y,i.y);this._map._requestDomTask((()=>{this._box&&(this._box.style.transform=`translate(${n}px,${a}px)`,this._box.style.width=o-n+"px",this._box.style.height=s-a+"px")}))}mouseupWindow(e,t){if(!this._active)return;if(0!==e.button)return;const i=this._startPos,r=t;if(this.reset(),ue(),i.x!==r.x||i.y!==r.y)return this._map.fire(new Event("boxzoomend",{originalEvent:e})),{cameraAnimation:e=>e.fitScreenCoordinates(i,r,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),le(),delete this._startPos,delete this._lastPos}_fireEvent(e,t){return this._map.fire(new Event(e,{originalEvent:t}))}}function $f(e,t){const i={};for(let r=0;r<e.length;r++)i[e[r].identifier]=t[r];return i}class SingleTapRecognizer{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(e,t,i){(this.centroid||i.length>this.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=e.timeStamp),i.length===this.numTouches&&(this.centroid=function(e){const t=new r(0,0);for(const i of e)t._add(i);return t.div(e.length)}(t),this.touches=$f(i,t)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const r=$f(i,t);for(const e in this.touches){const t=this.touches[e],i=r[e];(!i||i.dist(t)>30)&&(this.aborted=!0)}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class TapRecognizer{constructor(e){this.singleTap=new SingleTapRecognizer(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(e,t,i){this.singleTap.touchstart(e,t,i)}touchmove(e,t,i){this.singleTap.touchmove(e,t,i)}touchend(e,t,i){const r=this.singleTap.touchend(e,t,i);if(r){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class TapZoomHandler{constructor(){this._zoomIn=new TapRecognizer({numTouches:1,numTaps:2}),this._zoomOut=new TapRecognizer({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i)}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i)}touchend(e,t,i){const r=this._zoomIn.touchend(e,t,i),n=this._zoomOut.touchend(e,t,i);return r?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(r)},{originalEvent:e})}):n?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(n)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const Wf={0:1,2:2};class MouseHandler{constructor(e){this.reset(),this._clickTolerance=e.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(e,t){return!1}_move(e,t){return{}}mousedown(e,t){if(this._lastPoint)return;const i=de(e);this._correctButton(e,i)&&(this._lastPoint=t,this._eventButton=i)}mousemoveWindow(e,t){const i=this._lastPoint;if(i)if(e.preventDefault(),null!=this._eventButton&&function(e,t){const i=Wf[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(i)<this._clickTolerance))return this._moved=!0,this._lastPoint=t,this._move(i,t)}mouseupWindow(e){this._lastPoint&&de(e)===this._eventButton&&(this._moved&&ue(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class MousePanHandler extends MouseHandler{mousedown(e,t){super.mousedown(e,t),this._lastPoint&&(this._active=!0)}_correctButton(e,t){return 0===t&&!e.ctrlKey}_move(e,t){return{around:t,panDelta:t.sub(e)}}}class MouseRotateHandler extends MouseHandler{_correctButton(e,t){return 0===t&&e.ctrlKey||2===t}_move(e,t){const i=.8*(t.x-e.x);if(i)return this._active=!0,{bearingDelta:i}}contextmenu(e){e.preventDefault()}}class MousePitchHandler extends MouseHandler{_correctButton(e,t){return 0===t&&e.ctrlKey||2===t}_move(e,t){const i=-.5*(t.y-e.y);if(i)return this._active=!0,{pitchDelta:i}}contextmenu(e){e.preventDefault()}}class TouchPanHandler{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._minTouches=1,this._clickTolerance=t.clickTolerance||1,this.reset(),I(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new r(0,0)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active&&!(i.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(1===i.length&&!N())return void this._showTouchPanBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return e.cancelable&&e.preventDefault(),this._calculateTransform(e,t,i)}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&i.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,t,i){i.length>0&&(this._active=!0);const n=$f(i,t),o=new r(0,0),a=new r(0,0);let s=0;for(const e in n){const t=n[e],i=this._touches[e];i&&(o._add(t),a._add(t.sub(i)),s++,n[e]=t)}if(this._touches=n,s<this._minTouches||!a.mag())return;const l=a.div(s);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:o.div(s),panDelta:l}}enable(){this._enabled=!0,this._map._cooperativeGestures&&(this._addTouchPanBlocker(),this._el.classList.add("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page"))}disable(){this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove(),this._el.classList.remove("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page")),this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}_addTouchPanBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=te("div","mapboxgl-touch-pan-blocker",this._map._container),this._alertContainer.textContent=this._map._getUIString("TouchPanBlocker.Message"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showTouchPanBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","null")}),500)}}class TwoTouchHandler{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(e){}_move(e,t,i){return{}}touchstart(e,t,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,i){const r=this._firstTwoTouches;if(!r)return;e.preventDefault();const[n,o]=r,a=Hf(i,t,n),s=Hf(i,t,o);if(!a||!s)return;const l=this._aroundCenter?null:a.add(s).div(2);return this._move([a,s],l,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[r,n]=this._firstTwoTouches,o=Hf(i,t,r),a=Hf(i,t,n);o&&a||(this._active&&ue(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Hf(e,t,i){for(let r=0;r<e.length;r++)if(e[r].identifier===i)return t[r]}function Xf(e,t){return Math.log(e/t)/Math.LN2}class TouchZoomHandler extends TwoTouchHandler{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,t){const i=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(Xf(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Xf(this._distance,i),pinchAround:t}}}function Kf(e,t){return 180*e.angleWith(t)/Math.PI}class TouchRotateHandler extends TwoTouchHandler{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,t){const i=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Kf(this._vector,i),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());const t=25/(Math.PI*this._minDiameter)*360,i=Kf(e,this._startVector);return Math.abs(i)<t}}function Jf(e){return Math.abs(e.y)>Math.abs(e.x)}class TouchPitchHandler extends TwoTouchHandler{constructor(e){super(),this._map=e}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(e){this._lastPoints=e,Jf(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,i){const r=this._lastPoints;if(!r)return;const n=e[0].sub(r[0]),o=e[1].sub(r[1]);return this._map._cooperativeGestures&&i.touches.length<3||(this._valid=this.gestureBeginsVertically(n,o,i.timeStamp),!this._valid)?void 0:(this._lastPoints=e,this._active=!0,{pitchDelta:(n.y+o.y)/2*-.5})}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,n=t.mag()>=2;if(!r&&!n)return;if(!r||!n)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return Jf(e)&&Jf(t)&&o}}const Yf={panStep:100,bearingStep:15,pitchStep:10};class KeyboardHandler{constructor(){const e=Yf;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,r=0,n=0,o=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),n=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),n=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:a=>{const s=a.getZoom();a.easeTo({duration:300,easeId:"keyboardHandler",easing:Qf,zoom:t?Math.round(s)+t*(e.shiftKey?2:1):s,bearing:a.getBearing()+i*this._bearingStep,pitch:a.getPitch()+r*this._pitchStep,offset:[-n*this._panStep,-o*this._panStep],center:a.getCenter()},{originalEvent:e})}}}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 Qf(e){return e*(2-e)}const em=4.000244140625;class ScrollZoomHandler{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._handler=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,I(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(t.ctrlKey||t.metaKey||this.isZooming()||N()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let i=t.deltaMode===e.WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const r=ee.now(),n=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==i&&i%em==0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=i,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(n*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),t.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=t,this._delta-=i,this._active||this._start(t)),t.preventDefault()}_onTimeout(e){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)}_start(e){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 t=he(this._el,e);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:t,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 e=this._map.transform,t=()=>e._terrainEnabled()&&this._aroundCoord?e.computeZoomRelativeTo(this._aroundCoord):e.zoom;if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>em?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==r&&(r=1/r);const n=t(),o=Math.pow(2,n),a="number"==typeof this._targetZoom?e.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,e.scaleZoom(a*r))),"wheel"===this._type&&(this._startZoom=n,this._easing=this._smoothOutEasing(200)),this._delta=0}const i="number"==typeof this._targetZoom?this._targetZoom:t(),r=this._startZoom,n=this._easing;let o,a=!1;if("wheel"===this._type&&r&&n){const e=Math.min((ee.now()-this._lastWheelEventTime)/200,1);o=xi(r,i,n(e)),e<1?this._frameId||(this._frameId=!0):a=!0}else o=i,a=!0;return this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!a,zoomDelta:o-t(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let t=m;if(this._prevEase){const e=this._prevEase,i=(ee.now()-e.start)/e.duration,r=e.easing(i+.01)-e.easing(i),n=.27/Math.sqrt(r*r+1e-4)*.01;t=f(n,Math.sqrt(.0729-n*n),.25,1)}return this._prevEase={start:ee.now(),duration:e,easing:t},t}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=te("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(e.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`)}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","null")}),200)}}class DoubleClickZoomHandler{constructor(e,t){this._clickZoom=e,this._tapZoom=t}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 ClickZoomHandler{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(e.shiftKey?-1:1),around:i.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class TapDragZoomHandler{constructor(){this._tap=new TapRecognizer({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(e,t,i){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=t[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(e,t,i))}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=t[0],n=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(e,t,i)}touchend(e,t,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(e,t,i)&&(this._tapTime=e.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class DragPanHandler{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i}enable(e){this._inertiaOptions=e||{},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 DragRotateHandler{constructor(e,t,i){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=i}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 TouchZoomRotateHandler{constructor(e,t,i,r){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),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 tm=e=>e.zoom||e.drag||e.pitch||e.rotate;class RenderFrameEvent extends Event{}class TrackingEllipsoid{constructor(){this.constants=[1,1,.01],this.radius=0}setup(e,t){const i=Ja([],t,e);this.radius=La(i[2]<0?Qa([],i,this.constants):[i[0],i[1],0])}projectRay(e){Qa(e,e,this.constants),Za(e,e),Ya(e,e,this.constants);const t=ja([],e,this.radius);if(t[2]>0){const e=ja([],[0,0,1],qa(t,[0,0,1])),i=ja([],Za([],[t[0],t[1],0]),this.radius),r=Ra([],t,ja([],Ja([],Ra([],i,e),t),2));t[0]=r[0],t[1]=r[1]}return t}}function im(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class HandlerManager{constructor(t,i){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new HandlerInertia(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new TrackingEllipsoid,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),I(["handleEvent","handleWindowEvent"],this);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[e.document,"mousemove",{capture:!0}],[e.document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[e,"blur",void 0]];for(const[t,i,r]of this._listeners)t.addEventListener(i,t===e.document?this.handleWindowEvent:this.handleEvent,r)}destroy(){for(const[t,i,r]of this._listeners)t.removeEventListener(i,t===e.document?this.handleWindowEvent:this.handleEvent,r)}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new MapEventHandler(t,e));const r=t.boxZoom=new BoxZoomHandler(t,e);this._add("boxZoom",r);const n=new TapZoomHandler,o=new ClickZoomHandler;t.doubleClickZoom=new DoubleClickZoomHandler(o,n),this._add("tapZoom",n),this._add("clickZoom",o);const a=new TapDragZoomHandler;this._add("tapDragZoom",a);const s=t.touchPitch=new TouchPitchHandler(t);this._add("touchPitch",s);const l=new MouseRotateHandler(e),c=new MousePitchHandler(e);t.dragRotate=new DragRotateHandler(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const u=new MousePanHandler(e),h=new TouchPanHandler(t,e);t.dragPan=new DragPanHandler(i,u,h),this._add("mousePan",u),this._add("touchPan",h,["touchZoom","touchRotate"]);const p=new TouchRotateHandler,d=new TouchZoomHandler;t.touchZoomRotate=new TouchZoomRotateHandler(i,d,p,a),this._add("touchRotate",p,["touchPan","touchZoom"]),this._add("touchZoom",d,["touchPan","touchRotate"]),this._add("blockableMapEvent",new BlockableMapEventHandler(t));const f=t.scrollZoom=new ScrollZoomHandler(t,this);this._add("scrollZoom",f,["mousePan"]);const m=t.keyboard=new KeyboardHandler;this._add("keyboard",m);for(const i of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])e.interactive&&e[i]&&t[i].enable(e[i])}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!tm(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,t,i){for(const r in e)if(r!==i&&(!t||t.indexOf(r)<0))return!0;return!1}handleWindowEvent(e){this.handleEvent(e,`${e.type}Window`)}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}handleEvent(e,t){this._updatingCamera=!0;const i="renderFrame"===e.type,r=i?void 0:e,n={needsRenderFrame:!1},o={},a={},s=e.touches?this._getMapTouches(e.touches):void 0,l=s?pe(this._el,s):i?void 0:he(this._el,e);for(const{handlerName:i,handler:c,allowed:u}of this._handlers){if(!c.isEnabled())continue;let h;this._blockedByActive(a,u,i)?c.reset():c[t||e.type]&&(h=c[t||e.type](e,l,s),this.mergeHandlerResult(n,o,h,i,r),h&&h.needsRenderFrame&&this._triggerRenderFrame()),(h||c.isActive())&&(a[i]=c)}const c={};for(const e in this._previousActiveHandlers)a[e]||(c[e]=r);this._previousActiveHandlers=a,(Object.keys(c).length||im(n))&&(this._changes.push([n,o,c]),this._triggerRenderFrame()),(Object.keys(a).length||im(n))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=n;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map))}mergeHandlerResult(e,t,i,r,n){if(!i)return;b(e,i);const o={handlerName:r,originalEvent:i.originalEvent||n};void 0!==i.zoomDelta&&(t.zoom=o),void 0!==i.panDelta&&(t.drag=o),void 0!==i.pitchDelta&&(t.pitch=o),void 0!==i.bearingDelta&&(t.rotate=o)}_applyChanges(){const e={},t={},i={};for(const[n,o,a]of this._changes)n.panDelta&&(e.panDelta=(e.panDelta||new r(0,0))._add(n.panDelta)),n.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+n.zoomDelta),n.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+n.bearingDelta),n.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+n.pitchDelta),void 0!==n.around&&(e.around=n.around),void 0!==n.aroundCoord&&(e.aroundCoord=n.aroundCoord),void 0!==n.pinchAround&&(e.pinchAround=n.pinchAround),n.noInertia&&(e.noInertia=n.noInertia),b(t,o),b(i,a);this._updateMapTransform(e,t,i),this._changes=[]}_updateMapTransform(e,t,i){const r=this._map,n=r.transform,o=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!im(e)){const e=n.zoom;n.cameraElevationReference="sea",n.recenterOnTerrain(),n.cameraElevationReference="ground",e!==n.zoom&&this._map._update(!0)}if(!im(e))return void this._fireEvents(t,i,!0);let{panDelta:a,zoomDelta:s,bearingDelta:l,pitchDelta:c,around:u,aroundCoord:h,pinchAround:p}=e;void 0!==p&&(u=p),(e=>t.drag&&!this._eventsInProgress.drag)()&&u&&(this._dragOrigin=o(n.pointCoordinate3D(u)),this._trackingEllipsoid.setup(n._camera.position,this._dragOrigin)),n.cameraElevationReference="sea",r._stop(!0),u=u||r.transform.centerPoint,l&&(n.bearing+=l),c&&(n.pitch+=c),n._updateCameraState();const d=[0,0,0];if(a)if("mercator"===n.projection.name){const e=this._trackingEllipsoid.projectRay(n.screenPointToMercatorRay(u).dir),t=this._trackingEllipsoid.projectRay(n.screenPointToMercatorRay(u.sub(a)).dir);d[0]=t[0]-e[0],d[1]=t[1]-e[1]}else{const e=n.pointCoordinate(u);if("globe"===n.projection.name){a=a.rotate(-n.angle);const t=n._pixelsPerMercatorPixel/n.worldSize;d[0]=-a.x*Bo(zo(e.y))*t,d[1]=-a.y*Bo(n.center.lat)*t}else{const t=n.pointCoordinate(u.sub(a));e&&t&&(d[0]=t.x-e.x,d[1]=t.y-e.y)}}const f=n.zoom,m=[0,0,0];if(s){const e=o(h||n.pointCoordinate3D(u)),t={dir:Za([],Ja([],e,n._camera.position))};if(t.dir[2]<0){const i=n.zoomDeltaToMovement(e,s);ja(m,t.dir,i)}}const _=Ra(d,d,m);n._translateCameraConstrained(_),s&&Math.abs(n.zoom-f)>1e-4&&n.recenterOnTerrain(),n.cameraElevationReference="ground",this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0)}_fireEvents(e,t,i){const r=tm(this._eventsInProgress),n=tm(e),o={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(o[`${t}start`]=i),this._eventsInProgress[t]=e[t]}!r&&n&&this._fireEvent("movestart",n.originalEvent);for(const e in o)this._fireEvent(e,o[e]);n&&this._fireEvent("move",n.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i)}const a={};let s;for(const e in this._eventsInProgress){const{handlerName:i,originalEvent:r}=this._eventsInProgress[e];this._handlersById[i].isActive()||(delete this._eventsInProgress[e],s=t[i]||r,a[`${e}end`]=s)}for(const e in a)this._fireEvent(e,a[e]);const l=tm(this._eventsInProgress);if(i&&(r||n)&&!l){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),t=e=>0!==e&&-this._bearingSnap<e&&e<this._bearingSnap;e?(t(e.bearing||this._map.getBearing())&&(e.bearing=0),this._map.easeTo(e,{originalEvent:s})):(this._map.fire(new Event("moveend",{originalEvent:s})),t(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(e,t){this._map.fire(new Event(e,t?{originalEvent:t}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((e=>{this._frameId=void 0,this.handleEvent(new RenderFrameEvent("renderFrame",{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const rm="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Camera extends Evented{constructor(e,t){super(),this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=t.bearingSnap,I(["_renderFrameCallback"],this)}getCenter(){return new LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(e,t,i){return e=r.convert(e).mult(-1),this.panTo(this.transform.center,b({offset:e},t),i)}panTo(e,t,i){return this.easeTo(b({center:e},t),i)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,t,i){return this.easeTo(b({zoom:e},t),i)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,t,i){return this.easeTo(b({bearing:e},t),i)}resetNorth(e,t){return this.rotateTo(0,b({duration:1e3},e),t),this}resetNorthPitch(e,t){return this.easeTo(b({bearing:0,pitch:0,duration:1e3},e),t),this}snapToNorth(e,t){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,t):this}getPitch(){return this.transform.pitch}setPitch(e,t){return this.jumpTo({pitch:e},t),this}cameraForBounds(e,t){"globe"===this.transform.projection.name&&B('Globe projection does not support cameraForBounds API, this API may behave unexpectedly."'),e=LngLatBounds.convert(e);const i=t&&t.bearing||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),i,t)}_extendCameraOptions(e){const t={top:0,bottom:0,right:0,left:0};if("number"==typeof(e=b({padding:t,offset:[0,0],maxZoom:this.transform.maxZoom},e)).padding){const t=e.padding;e.padding={top:t,bottom:t,right:t,left:t}}return e.padding=b(t,e.padding),e}_cameraForBoxAndBearing(e,t,i,n){const o=this._extendCameraOptions(n),a=this.transform,s=a.padding,c=a.project(LngLat.convert(e)),u=a.project(LngLat.convert(t)),h=new r(c.x,u.y),p=new r(u.x,c.y),d=-l(i),f=c.rotate(d),m=u.rotate(d),_=h.rotate(d),g=p.rotate(d),y=new r(Math.max(f.x,m.x,_.x,g.x),Math.max(f.y,m.y,_.y,g.y)),x=new r(Math.min(f.x,m.x,_.x,g.x),Math.min(f.y,m.y,_.y,g.y)),v=y.sub(x),b=(a.width-((s.left||0)+(s.right||0)+o.padding.left+o.padding.right))/v.x,w=(a.height-((s.top||0)+(s.bottom||0)+o.padding.top+o.padding.bottom))/v.y;if(w<0||b<0)return void B("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const T=Math.min(a.scaleZoom(a.scale*Math.min(b,w)),o.maxZoom),E="number"==typeof o.offset.x&&"number"==typeof o.offset.y?new r(o.offset.x,o.offset.y):r.convert(o.offset),S=new r((o.padding.left-o.padding.right)/2,(o.padding.top-o.padding.bottom)/2).rotate(i*Math.PI/180),A=E.add(S).mult(a.scale/a.zoomScale(T));return{center:a.unproject(c.add(u).div(2).sub(A)),zoom:T,bearing:i}}_cameraForBox(e,t,i,r,n){const o=this._extendCameraOptions(n);i=i||0,r=r||0,e=LngLat.convert(e),t=LngLat.convert(t);const a=this.transform.clone();a.padding=o.padding;const s=this.getFreeCameraOptions(),l=new LngLat(.5*(e.lng+t.lng),.5*(e.lat+t.lat)),c=.5*(i+r);if(a._camera.position[2]<Po(c,l.lat))return void B("Map cannot fit within canvas with the given bounds, padding, and/or offset.");s.lookAtPoint(l),a.setFreeCameraOptions(s);const u=MercatorCoordinate.fromLngLat(e),h=MercatorCoordinate.fromLngLat(t),p=a.pointRayIntersection(a.centerPoint,c),d=[(f=a.rayIntersectionCoordinate(p)).x,f.y,f.z];var f;const m=a.screenPointToMercatorRay(a.centerPoint),_="globe"!==a.projection.name;let g,y=0;do{const e=Math.floor(a.zoom),t=1<<e,n=Math.min(t*u.x,t*h.x),o=Math.min(t*u.y,t*h.y),s=Math.max(t*u.x,t*h.x),l=Math.max(t*u.y,t*h.y),c=new Aabb([n,o,i],[s,l,r]),p=Frustum.fromInvProjectionMatrix(a.invProjMatrix,a.worldSize,e,_);if(2!==c.intersects(p)){g&&(a._camera.position=Na([],a._camera.position,m.dir,-g),a._updateStateFromCamera());break}g=.5*La(Ja([],a._camera.position,d)),a._camera.position=Na([],a._camera.position,m.dir,g);try{a._updateStateFromCamera()}catch(e){return void B("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}}while(++y<10);return{center:a.center,zoom:a.zoom,bearing:a.bearing,pitch:a.pitch}}fitBounds(e,t,i){return"globe"===this.transform.projection.name&&B("Globe projection does not support fitBounds API, this API may behave unexpectedly."),this._fitInternal(this.cameraForBounds(e,t),t,i)}_raycastElevationBox(e,t){const i=this.transform.elevation;if(!i)return;const n=new r(e.x,t.y),o=new r(t.x,e.y),a=i.pointCoordinate(e);if(!a)return;const s=i.pointCoordinate(t);if(!s)return;const l=i.pointCoordinate(n);if(!l)return;const c=i.pointCoordinate(o);if(!c)return;const u=new MercatorCoordinate(a[0],a[1]).toLngLat(),h=new MercatorCoordinate(s[0],s[1]).toLngLat(),p=new MercatorCoordinate(l[0],l[1]).toLngLat(),d=new MercatorCoordinate(c[0],c[1]).toLngLat(),f=Math.min(u.lng,Math.min(h.lng,Math.min(p.lng,d.lng))),m=Math.min(u.lat,Math.min(h.lat,Math.min(p.lat,d.lat))),_=Math.max(u.lng,Math.max(h.lng,Math.max(p.lng,d.lng))),g=Math.max(u.lat,Math.max(h.lat,Math.max(p.lat,d.lat))),y=Math.min(a[3],Math.min(s[3],Math.min(l[3],c[3]))),x=Math.max(a[3],Math.max(s[3],Math.max(l[3],c[3])));return{minLngLat:new LngLat(f,m),maxLngLat:new LngLat(_,g),minAltitude:y,maxAltitude:x}}fitScreenCoordinates(e,t,i,n,o){let a,s,l,c;"globe"===this.transform.projection.name&&B("Globe projection does not support fitScreenCoordinates API, this API may behave unexpectedly.");const u=r.convert(e),h=r.convert(t),p=this._raycastElevationBox(u,h);if(p)a=p.minLngLat,s=p.maxLngLat,l=p.minAltitude,c=p.maxAltitude;else{if(this.transform.anyCornerOffEdge(u,h))return this;a=this.transform.pointLocation(u),s=this.transform.pointLocation(h)}return this._fitInternal(0===this.transform.pitch?this._cameraForBoxAndBearing(this.transform.pointLocation(r.convert(e)),this.transform.pointLocation(r.convert(t)),i,n):this._cameraForBox(a,s,l,c,n),n,o)}_fitInternal(e,t,i){return e?(delete(t=b(e,t)).padding,t.linear?this.easeTo(t,i):this.flyTo(t,i)):this}jumpTo(e,t){this.stop();const i=e.preloadOnly?this.transform.clone():this.transform;let r=!1,n=!1,o=!1;return"zoom"in e&&i.zoom!==+e.zoom&&(r=!0,i.zoom=+e.zoom),void 0!==e.center&&(i.center=LngLat.convert(e.center)),"bearing"in e&&i.bearing!==+e.bearing&&(n=!0,i.bearing=+e.bearing),"pitch"in e&&i.pitch!==+e.pitch&&(o=!0,i.pitch=+e.pitch),null==e.padding||i.isPaddingEqual(e.padding)||(i.padding=e.padding),e.preloadOnly?(this._preloadTiles(i),this):(this.fire(new Event("movestart",t)).fire(new Event("move",t)),r&&this.fire(new Event("zoomstart",t)).fire(new Event("zoom",t)).fire(new Event("zoomend",t)),n&&this.fire(new Event("rotatestart",t)).fire(new Event("rotate",t)).fire(new Event("rotateend",t)),o&&this.fire(new Event("pitchstart",t)).fire(new Event("pitch",t)).fire(new Event("pitchend",t)),this.fire(new Event("moveend",t)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||B(rm),this.transform.getFreeCameraOptions()}setFreeCameraOptions(e,t){const i=this.transform;if(!i.projection.supportsFreeCamera)return B(rm),this;this.stop();const r=i.zoom,n=i.pitch,o=i.bearing;i.setFreeCameraOptions(e);const a=r!==i.zoom,s=n!==i.pitch,l=o!==i.bearing;return this.fire(new Event("movestart",t)).fire(new Event("move",t)),a&&this.fire(new Event("zoomstart",t)).fire(new Event("zoom",t)).fire(new Event("zoomend",t)),l&&this.fire(new Event("rotatestart",t)).fire(new Event("rotate",t)).fire(new Event("rotateend",t)),s&&this.fire(new Event("pitchstart",t)).fire(new Event("pitch",t)).fire(new Event("pitchend",t)),this.fire(new Event("moveend",t)),this}easeTo(e,t){this._stop(!1,e.easeId),(!1===(e=b({offset:[0,0],duration:500,easing:m},e)).animate||!e.essential&&ee.prefersReducedMotion)&&(e.duration=0);const i=this.transform,n=this.getZoom(),o=this.getBearing(),a=this.getPitch(),s=this.getPadding(),l="zoom"in e?+e.zoom:n,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,u="pitch"in e?+e.pitch:a,h="padding"in e?e.padding:i.padding,p=r.convert(e.offset);let d,f,_;if("globe"===i.projection.name){const t=MercatorCoordinate.fromLngLat(i.center),n=p.rotate(-i.angle);t.x+=n.x/i.worldSize,t.y+=n.y/i.worldSize;const o=t.toLngLat(),a=LngLat.convert(e.center||o);this._normalizeCenter(a),d=i.centerPoint.add(n),f=new r(t.x,t.y).mult(i.worldSize),_=new r(Io(a.lng),Mo(a.lat)).mult(i.worldSize).sub(f)}else{d=i.centerPoint.add(p);const t=i.pointLocation(d),r=LngLat.convert(e.center||t);this._normalizeCenter(r),f=i.project(t),_=i.project(r).sub(f)}const g=i.zoomScale(l-n);let y,x;e.around&&(y=LngLat.convert(e.around),x=i.locationPoint(y));const v=this._zooming||l!==n,w=this._rotating||o!==c,T=this._pitching||u!==a,E=!i.isPaddingEqual(h),S=i=>r=>{if(v&&(i.zoom=xi(n,l,r)),w&&(i.bearing=xi(o,c,r)),T&&(i.pitch=xi(a,u,r)),E&&(i.interpolatePadding(s,h,r),d=i.centerPoint.add(p)),y)i.setLocationAtPoint(y,x);else{const e=i.zoomScale(i.zoom-n),t=l>n?Math.min(2,g):Math.max(.5,g),o=Math.pow(t,1-r),a=i.unproject(f.add(_.mult(r*o)).mult(e));i.setLocationAtPoint(i.renderWorldCopies?a.wrap():a,d)}return e.preloadOnly||this._fireMoveEvents(t),i};if(e.preloadOnly){const t=this._emulate(S,e.duration,i);return this._preloadTiles(t),this}const A={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=v,this._rotating=w,this._pitching=T,this._padding=E,this._easeId=e.easeId,this._prepareEase(t,e.noMoveStart,A),this._ease(S(i),(e=>{i.recenterOnTerrain(),this._afterEase(t,e)}),e),this}_prepareEase(e,t,i={}){this._moving=!0,this.transform.cameraElevationReference="sea",t||i.moving||this.fire(new Event("movestart",e)),this._zooming&&!i.zooming&&this.fire(new Event("zoomstart",e)),this._rotating&&!i.rotating&&this.fire(new Event("rotatestart",e)),this._pitching&&!i.pitching&&this.fire(new Event("pitchstart",e))}_fireMoveEvents(e){this.fire(new Event("move",e)),this._zooming&&this.fire(new Event("zoom",e)),this._rotating&&this.fire(new Event("rotate",e)),this._pitching&&this.fire(new Event("pitch",e))}_afterEase(e,t){if(this._easeId&&t&&this._easeId===t)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const i=this._zooming,r=this._rotating,n=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,i&&this.fire(new Event("zoomend",e)),r&&this.fire(new Event("rotateend",e)),n&&this.fire(new Event("pitchend",e)),this.fire(new Event("moveend",e))}flyTo(e,t){if(!e.essential&&ee.prefersReducedMotion){const i=w(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(i,t)}this.stop(),e=b({offset:[0,0],speed:1.2,curve:1.42,easing:m},e);const i=this.transform,n=this.getZoom(),o=this.getBearing(),a=this.getPitch(),s=this.getPadding(),l="zoom"in e?_(+e.zoom,i.minZoom,i.maxZoom):n,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,u="pitch"in e?+e.pitch:a,h="padding"in e?e.padding:i.padding,p=i.zoomScale(l-n),d=r.convert(e.offset);let f=i.centerPoint.add(d);const g=i.pointLocation(f),y=LngLat.convert(e.center||g);this._normalizeCenter(y);const x=i.project(g),v=i.project(y).sub(x);let T=e.curve;const E=Math.max(i.width,i.height),S=E/p,A=v.mag();if("minZoom"in e){const t=_(Math.min(e.minZoom,n,l),i.minZoom,i.maxZoom),r=E/i.zoomScale(t-n);T=Math.sqrt(r/A*2)}const C=T*T;function I(e){const t=(S*S-E*E+(e?-1:1)*C*C*A*A)/(2*(e?S:E)*C*A);return Math.log(Math.sqrt(t*t+1)-t)}function M(e){return(Math.exp(e)-Math.exp(-e))/2}function P(e){return(Math.exp(e)+Math.exp(-e))/2}const D=I(0);let z=function(e){return P(D)/P(D+T*e)},k=function(e){return E*((P(D)*(M(t=D+T*e)/P(t))-M(D))/C)/A;var t},L=(I(1)-D)/T;if(Math.abs(A)<1e-6||!isFinite(L)){if(Math.abs(E-S)<1e-6)return this.easeTo(e,t);const i=S<E?-1:1;L=Math.abs(Math.log(S/E))/T,k=function(){return 0},z=function(e){return Math.exp(i*T*e)}}e.duration="duration"in e?+e.duration:1e3*L/("screenSpeed"in e?+e.screenSpeed/T:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0);const B=o!==c,R=u!==a,F=!i.isPaddingEqual(h),O=i=>r=>{const p=r*L,m=1/z(p);i.zoom=1===r?l:n+i.scaleZoom(m),B&&(i.bearing=xi(o,c,r)),R&&(i.pitch=xi(a,u,r)),F&&(i.interpolatePadding(s,h,r),f=i.centerPoint.add(d));const _=1===r?y:i.unproject(x.add(v.mult(k(p))).mult(m));return i.setLocationAtPoint(i.renderWorldCopies?_.wrap():_,f),i._updateCameraOnTerrain(),e.preloadOnly||this._fireMoveEvents(t),i};if(e.preloadOnly){const t=this._emulate(O,e.duration,i);return this._preloadTiles(t),this}return this._zooming=!0,this._rotating=B,this._pitching=R,this._padding=F,this._prepareEase(t,!1),this._ease(O(i),(()=>this._afterEase(t)),e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const e=this._onEaseEnd;this._onEaseEnd=void 0,e.call(this,t)}if(!e){const e=this.handlers;e&&e.stop(!1)}return this}_ease(e,t,i){!1===i.animate||0===i.duration?(e(1),t()):(this._easeStart=ee.now(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const e=Math.min((ee.now()-this._easeStart)/this._easeOptions.duration,1),t=this._onEaseFrame;t&&t(this._easeOptions.easing(e)),e<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(e,t){e=y(e,-180,180);const i=Math.abs(e-t);return Math.abs(e-360-t)<i&&(e-=360),Math.abs(e+360-t)<i&&(e+=360),e}_normalizeCenter(e){const t=this.transform;if(!t.renderWorldCopies||t.maxBounds)return;const i=e.lng-t.center.lng;e.lng+=i>180?-360:i<-180?360:0}_emulate(e,t,i){const r=Math.ceil(15*t/1e3),n=[],o=e(i.clone());for(let e=0;e<=r;e++){const t=o(e/r);n.push(t.clone())}return n}}class AttributionControl{constructor(e={}){this.options=e,I(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(e){const t=this.options&&this.options.compact;return this._map=e,this._container=te("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=te("button","mapboxgl-ctrl-attrib-button",this._container),te("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=te("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),t&&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===t&&(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(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.setAttribute("aria-label",i),e.removeAttribute("title"),e.firstElementChild&&e.firstElementChild.setAttribute("title",i)}_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 e=this._editLink;e||(e=this._editLink=this._container.querySelector(".mapbox-improve-map"));const t=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||me.ACCESS_TOKEN}];if(e){const i=t.reduce(((e,i,r)=>(i.value&&(e+=`${i.key}=${i.value}${r<t.length-1?"&":""}`),e)),"?");e.href=`${me.FEEDBACK_URL}/${i}#${Of(this._map,!0)}`,e.rel="noopener nofollow",this._setElementTitle(e,"MapFeedback")}}_updateData(e){!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let e=[];if(this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}const t=this._map.style._sourceCaches;for(const i in t){const r=t[i];if(r.used){const t=r.getSource();t.attribution&&e.indexOf(t.attribution)<0&&e.push(t.attribution)}}e.sort(((e,t)=>e.length-t.length)),e=e.filter(((t,i)=>{for(let r=i+1;r<e.length;r++)if(e[r].indexOf(t)>=0)return!1;return!0})),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[...this.options.customAttribution,...e]:e.unshift(this.options.customAttribution));const i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=i,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 LogoControl{constructor(){I(["_updateLogo","_updateCompact"],this)}onAdd(e){this._map=e,this._container=te("div","mapboxgl-ctrl");const t=te("a","mapboxgl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://www.mapbox.com/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),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(e){e&&"metadata"!==e.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const e=this._map.style._sourceCaches;if(0===Object.entries(e).length)return!0;for(const t in e){const i=e[t].getSource();if(i.hasOwnProperty("mapbox_logo")&&!i.mapbox_logo)return!1}return!0}_updateCompact(){const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<250?t.classList.add("mapboxgl-compact"):t.classList.remove("mapboxgl-compact")}}}class TaskQueue{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function nm(e,t,i){if(e=new LngLat(e.lng,e.lat),t){const r=new LngLat(e.lng-360,e.lat),n=new LngLat(e.lng+360,e.lat),o=360*Math.ceil(Math.abs(e.lng-i.center.lng)/360),a=i.locationPoint(e).distSqr(t),s=t.x<0||t.y<0||t.x>i.width||t.y>i.height;i.locationPoint(r).distSqr(t)<a&&(s||Math.abs(r.lng-i.center.lng)<o)?e=r:i.locationPoint(n).distSqr(t)<a&&(s||Math.abs(n.lng-i.center.lng)<o)&&(e=n)}for(;Math.abs(e.lng-i.center.lng)>180;){const t=i.locationPoint(e);if(t.x>=0&&t.y>=0&&t.x<=i.width&&t.y<=i.height)break;e.lng>i.center.lng?e.lng-=360:e.lng+=360}return e}const om={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 Marker extends Evented{constructor(t,i){if(super(),(t instanceof e.HTMLElement||i)&&(t=b({element:t},i)),I(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),t&&t.element)this._element=t.element,this._offset=r.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=te("div");const e=41,i=27,n=ie("svg",{display:"block",height:e*this._scale+"px",width:i*this._scale+"px",viewBox:`0 0 ${i} ${e}`},this._element),o=ie("radialGradient",{id:"shadowGradient"},ie("defs",{},n));ie("stop",{offset:"10%","stop-opacity":.4},o),ie("stop",{offset:"100%","stop-opacity":.05},o),ie("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},n),ie("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"},n),ie("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"},n),ie("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},n),this._offset=r.convert(t&&t.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",(e=>{e.preventDefault()})),this._element.addEventListener("mousedown",(e=>{e.preventDefault()}));const n=this._element.classList;for(const e in om)n.remove(`mapboxgl-marker-anchor-${e}`);n.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(e){return e===this._map||(this.remove(),this._map=e,e.getCanvasContainer().appendChild(this._element),e.on("move",this._updateMoving),e.on("moveend",this._update),e.on("remove",this._clearFadeTimer),e._addMarker(this),this.setDraggable(this._draggable),this._update(),e.on("click",this._onMapClick)),this}remove(){const e=this._map;return e&&(e.off("click",this._onMapClick),e.off("move",this._updateMoving),e.off("moveend",this._update),e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler),e.off("mouseup",this._onUp),e.off("touchend",this._onUp),e.off("mousemove",this._onMove),e.off("touchmove",this._onMove),e.off("remove",this._clearFadeTimer),e._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=LngLat.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(e){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")),e){if(!("offset"in e.options)){const t=38.1,i=13.5,r=Math.sqrt(Math.pow(i,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[r,-1*(t-i+r)],"bottom-right":[-r,-1*(t-i+r)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset}this._popup=e,e._marker=this,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(e){const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup()}_onMapClick(e){const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const e=this._popup;return e?(e.isOpen()?(e.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(e.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const e=this._map;if(!e)return!1;const t=e.unproject(this._pos),i=e.getFreeCameraOptions();if(!i.position)return!1;const r=i.position.toLngLat();return r.distanceTo(t)<.9*r.distanceTo(this._lngLat)}_evaluateOpacity(){const e=this._map;if(!e)return;const t=this._pos;if(!t||t.x<0||t.x>e.transform.width||t.y<0||t.y>e.transform.height)return void this._clearFadeTimer();const i=e.unproject(t);let r;e._showingGlobe()&&Tu(e.transform,this._lngLat)?r=0:(r=1-e._queryFogOpacity(i),e.transform._terrainEnabled()&&e.getTerrain()&&this._behindTerrain()&&(r*=.2)),this._element.style.opacity=`${r}`,this._element.style.pointerEvents=r>0?"auto":"none",this._popup&&this._popup._setOpacity(r),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const e=this._pos;if(!e||!this._map)return;const t=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${e.x}px,${e.y}px)\n ${om[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `}_calculateXYTransform(){const e=this._pos,t=this._map,i=this.getPitchAlignment();if(!t||!e||"map"!==i)return"";if(!t._showingGlobe()){const e=t.getPitch();return e?`rotateX(${e}deg)`:""}const r=c(wu(t.transform,this._lngLat)),n=e.sub(bu(t.transform)),o=Math.abs(n.x)+Math.abs(n.y);if(0===o)return"";const a=r/o;return`rotateX(${-n.y*a}deg) rotateY(${n.x*a}deg)`}_calculateZTransform(){const e=this._pos,t=this._map;if(!t||!e)return"";let i=0;const r=this.getRotationAlignment();if("map"===r)if(t._showingGlobe()){const e=t.project(new LngLat(this._lngLat.lng,this._lngLat.lat+.001)),r=t.project(new LngLat(this._lngLat.lng,this._lngLat.lat-.001)).sub(e);i=c(Math.atan2(r.y,r.x))-90}else i=-t.getBearing();else if("horizon"===r){const r=g(4,6,t.getZoom()),n=bu(t.transform);n.y+=r*t.transform.height;const o=e.sub(n),a=c(Math.atan2(o.y,o.x));i=(a>90?a-270:a+90)*(1-r)}return i+=this._rotation,i?`rotateZ(${i}deg)`:""}_update(t){e.cancelAnimationFrame(this._updateFrameId);const i=this._map;i&&(i.transform.renderWorldCopies&&(this._lngLat=nm(this._lngLat,this._pos,i.transform)),this._pos=i.project(this._lngLat),!0===t?this._updateFrameId=e.requestAnimationFrame((()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())})):this._pos=this._pos.round(),i._requestDomTask((()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(i._showingGlobe()||i.getTerrain()||i.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))})))}getOffset(){return this._offset}setOffset(e){return this._offset=r.convert(e),this._update(),this}_onMove(e){const t=this._map;if(t){if(!this._isDragging){const i=this._clickTolerance||t._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=i}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=t.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new Event("dragstart"))),this.fire(new Event("drag")))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const e=this._map;e&&(e.off("mousemove",this._onMove),e.off("touchmove",this._onMove)),"active"===this._state&&this.fire(new Event("dragend")),this._state="inactive"}_addDragHandler(e){const t=this._map;t&&this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos),this._pointerdownPos=e.point,this._state="pending",t.on("mousemove",this._onMove),t.on("touchmove",this._onMove),t.once("mouseup",this._onUp),t.once("touchend",this._onUp))}setDraggable(e){this._draggable=!!e;const t=this._map;return t&&(e?(t.on("mousedown",this._addDragHandler),t.on("touchstart",this._addDragHandler)):(t.off("mousedown",this._addDragHandler),t.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return"auto"===this._rotationAlignment||"horizon"===this._rotationAlignment&&this._map&&!this._map._showingGlobe()?"viewport":this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e||"auto",this._update(),this}getPitchAlignment(){return"auto"===this._pitchAlignment?this.getRotationAlignment():this._pitchAlignment}}class EasedVariable{constructor(e){this.jumpTo(e)}getValue(e){if(e<=this._startTime)return this._start;if(e>=this._endTime)return this._end;const t=h((e-this._startTime)/(this._endTime-this._startTime));return this._start*(1-t)+this._end*t}isEasing(e){return e>=this._startTime&&e<=this._endTime}jumpTo(e){this._startTime=-1/0,this._endTime=-1/0,this._start=e,this._end=e}easeTo(e,t,i){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+i}}const am={"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","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","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"},sm={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,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,crossSourceCollisions:!0};function lm(e){e.parentNode&&e.parentNode.removeChild(e)}const cm={showCompass:!0,showZoom:!0,visualizePitch:!1};class MouseRotateWrapper{constructor(e,t,i=!1){this._clickTolerance=10,this.element=t,this.mouseRotate=new MouseRotateHandler({clickTolerance:e.dragRotate._mouseRotate._clickTolerance}),this.map=e,i&&(this.mousePitch=new MousePitchHandler({clickTolerance:e.dragRotate._mousePitch._clickTolerance})),I(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),t.addEventListener("mousedown",this.mousedown),t.addEventListener("touchstart",this.touchstart,{passive:!1}),t.addEventListener("touchmove",this.touchmove),t.addEventListener("touchend",this.touchend),t.addEventListener("touchcancel",this.reset)}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),se()}move(e,t){const i=this.map,r=this.mouseRotate.mousemoveWindow(e,t),n=r&&r.bearingDelta;if(n&&i.setBearing(i.getBearing()+n),this.mousePitch){const r=this.mousePitch.mousemoveWindow(e,t),n=r&&r.pitchDelta;n&&i.setPitch(i.getPitch()+n)}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart,{passive:!1}),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){le(),e.removeEventListener("mousemove",this.mousemove),e.removeEventListener("mouseup",this.mouseup)}mousedown(t){this.down(b({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),he(this.element,t)),e.addEventListener("mousemove",this.mousemove),e.addEventListener("mouseup",this.mouseup)}mousemove(e){this.move(e,he(this.element,e))}mouseup(e){this.mouseRotate.mouseupWindow(e),this.mousePitch&&this.mousePitch.mouseupWindow(e),this.offTemp()}touchstart(e){1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=pe(this.element,e.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>e.preventDefault()},this._startPos))}touchmove(e){1!==e.targetTouches.length?this.reset():(this._lastPos=pe(this.element,e.targetTouches)[0],this.move({preventDefault:()=>e.preventDefault()},this._lastPos))}touchend(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}const um={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},hm={maxWidth:100,unit:"metric"};function pm(e,t,i){const r=dm(t),n=r/t,o={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"}[i];this._map._requestDomTask((()=>{this._container.style.width=e*n+"px",this._container.innerHTML=`${r} ${o}`}))}function dm(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}const fm={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},mm=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function _m(e=new r(0,0),t="bottom"){if("number"==typeof e){const i=Math.round(Math.sqrt(.5*Math.pow(e,2)));switch(t){case"top":return new r(0,e);case"top-left":return new r(i,i);case"top-right":return new r(-i,i);case"bottom":return new r(0,-e);case"bottom-left":return new r(i,-i);case"bottom-right":return new r(-i,-i);case"left":return new r(e,0);case"right":return new r(-e,0)}return new r(0,0)}return e instanceof r||Array.isArray(e)?r.convert(e):r.convert(e[t]||[0,0])}const gm={version:X,supported:$,setRTLTextPlugin:function(e,t,i=!1){if(Zn===Un||Zn===jn||Zn===Nn)throw new Error("setRTLTextPlugin cannot be called multiple times.");qn=ee.resolveURL(e),Zn=Un,Gn=t,Wn(),i||Kn()},getRTLTextPluginStatus:Xn,Map:class Map$1 extends Camera{constructor(t){if(null!=(t=b({},sm,t)).minZoom&&null!=t.maxZoom&&t.minZoom>t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(t.antialias&&function(e){const t=e.navigator?e.navigator.userAgent:null;return!!j(e)&&t&&(t.match("Version/15.4")||t.match("Version/15.5")||t.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))}(e)&&(t.antialias=!1,B("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Transform(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),t),this._interactive=t.interactive,this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=t.collectResourceTiming,this._optimizeForTerrain=t.optimizeForTerrain,this._language="auto"===t.language?e.navigator.language:t.language,this._worldview=t.worldview,this._renderTaskQueue=new TaskQueue,this._domRenderTaskQueue=new TaskQueue,this._controls=[],this._markers=[],this._mapId=E(),this._locale=b({},am,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new EasedVariable(0),this._useExplicitProjection=!1,this._requestManager=new RequestManager(t.transformRequest,t.accessToken,t.testMode),this._silenceAuthErrors=!!t.testMode,"string"==typeof t.container){if(this._container=e.document.getElementById(t.container),!this._container)throw new Error(`Container '${t.container}' not found.`)}else{if(!(t.container instanceof e.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(this._container.childNodes.length>0&&B("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."),t.maxBounds&&this.setMaxBounds(t.maxBounds),I(["_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!==e&&(e.addEventListener("online",this._onWindowOnline,!1),e.addEventListener("resize",this._onWindowResize,!1),e.addEventListener("orientationchange",this._onWindowResize,!1),e.addEventListener("webkitfullscreenchange",this._onWindowResize,!1)),this.handlers=new HandlerManager(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,t.style&&this.setStyle(t.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),t.projection&&this.setProjection(t.projection),this._hash=t.hash&&new Hash("string"==typeof t.hash&&t.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,b({},t.fitBoundsOptions,{duration:0})))),this.resize(),t.attributionControl&&this.addControl(new AttributionControl({customAttribution:t.customAttribution})),this._logoControl=new LogoControl,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new Event(`${e.dataType}data`,e))})),this.on("dataloading",(e=>{this.fire(new Event(`${e.dataType}dataloading`,e))}))}_getMapId(){return this._mapId}addControl(e,t){if(void 0===t&&(t=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const i=e.onAdd(this);this._controls.push(e);const r=this._controlPositions[t];return-1!==t.indexOf("bottom")?r.insertBefore(i,r.firstChild):r.appendChild(i),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const t=this._controls.indexOf(e);return t>-1&&this._controls.splice(t,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(e){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 t=!this._moving;return t&&this.fire(new Event("movestart",e)).fire(new Event("move",e)),this.fire(new Event("resize",e)),t&&this.fire(new Event("moveend",e)),this}getBounds(){return"globe"===this.transform.projection.name&&B('Globe projection does not support getBounds API, this API may behave unexpectedly."'),this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(e){return this.transform.setMaxBounds(LngLatBounds.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.minZoom=e,this._update(),this.getZoom()<e?this.setZoom(e):this.fire(new Event("zoomstart")).fire(new Event("zoom")).fire(new Event("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(e){if((e=null==e?22:e)>=this.transform.minZoom)return this.transform.maxZoom=e,this._update(),this.getZoom()>e?this.setZoom(e):this.fire(new Event("zoomstart")).fire(new Event("zoom")).fire(new Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.minPitch=e,this._update(),this.getPitch()<e?this.setPitch(e):this.fire(new Event("pitchstart")).fire(new Event("pitch")).fire(new Event("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(e){if((e=null==e?85:e)>85)throw new Error("maxPitch must be less than or equal to 85");if(e>=this.transform.minPitch)return this.transform.maxPitch=e,this._update(),this.getPitch()>e?this.setPitch(e):this.fire(new Event("pitchstart")).fire(new Event("pitch")).fire(new Event("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.renderWorldCopies=e,this._update()}getLanguage(){return this._language}setLanguage(t){if(this._language="auto"===t?e.navigator.language:t,this.style)for(const e in this.style._sourceCaches){const t=this.style._sourceCaches[e]._source;t._setLanguage&&t._setLanguage(this._language)}for(const e of this._controls)e._setLanguage&&e._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(e){if(this._worldview=e,this.style)for(const t in this.style._sourceCaches){const i=this.style._sourceCaches[t]._source;i._setWorldview&&i._setWorldview(e)}return this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return"globe"===this.transform.projection.name}setProjection(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._useExplicitProjection=!!e,this._prioritizeAndUpdateProjection(e,this.style.stylesheet?this.style.stylesheet.projection:null)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const e=this.transform,t=e.projection.name;let i;"globe"===t&&e.zoom>=6?(e.setMercatorFromTransition(),i=!0):"mercator"===t&&e.zoom<6&&(e.setProjection({name:"globe"}),i=!0),i&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayerUpdate())}_prioritizeAndUpdateProjection(e,t){return this._updateProjection(e||t||{name:"mercator"})}_updateProjection(e){let t;if(t="globe"===e.name&&this.transform.zoom>=6?this.transform.setMercatorFromTransition():this.transform.setProjection(e),this.style.applyProjectionUpdate(),t){this.painter.clearBackgroundTiles();for(const e in this.style._sourceCaches)this.style._sourceCaches[e].clearTiles();this._update(!0)}return this}project(e){return this.transform.locationPoint3D(LngLat.convert(e))}unproject(e){return this.transform.pointLocation3D(r.convert(e))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let r=!1;const n=n=>{const o=t.filter((e=>this.getLayer(e))),a=o.length?this.queryRenderedFeatures(n.point,{layers:o}):[];a.length?r||(r=!0,i.call(this,new MapMouseEvent(e,this,n.originalEvent,{features:a}))):r=!1},o=()=>{r=!1};return{layers:new Set(t),listener:i,delegates:{mousemove:n,mouseout:o}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const n=n=>{const o=t.filter((e=>this.getLayer(e)));(o.length?this.queryRenderedFeatures(n.point,{layers:o}):[]).length?r=!0:r&&(r=!1,i.call(this,new MapMouseEvent(e,this,n.originalEvent)))},o=t=>{r&&(r=!1,i.call(this,new MapMouseEvent(e,this,t.originalEvent)))};return{layers:new Set(t),listener:i,delegates:{mousemove:n,mouseout:o}}}{const r=e=>{const r=t.filter((e=>this.getLayer(e))),n=r.length?this.queryRenderedFeatures(e.point,{layers:r}):[];n.length&&(e.features=n,i.call(this,e),delete e.features)};return{layers:new Set(t),listener:i,delegates:{[e]:r}}}}on(e,t,i){if(void 0===i)return super.on(e,t);Array.isArray(t)||(t=[t]);const r=this._createDelegatedListener(e,t,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(r);for(const e in r.delegates)this.on(e,r.delegates[e]);return this}once(e,t,i){if(void 0===i)return super.once(e,t);Array.isArray(t)||(t=[t]);const r=this._createDelegatedListener(e,t,i);for(const e in r.delegates)this.once(e,r.delegates[e]);return this}off(e,t,i){if(void 0===i)return super.off(e,t);t=new Set(Array.isArray(t)?t:[t]);const r=(e,t)=>{if(e.size!==t.size)return!1;for(const i of e)if(!t.has(i))return!1;return!0},n=this._delegatedListeners?this._delegatedListeners[e]:void 0;return n&&(e=>{for(let n=0;n<e.length;n++){const o=e[n];if(o.listener===i&&r(o.layers,t)){for(const e in o.delegates)this.off(e,o.delegates[e]);return e.splice(n,1),this}}})(n),this}queryRenderedFeatures(e,t){return this.style?(void 0!==t||void 0===e||e instanceof r||Array.isArray(e)||(t=e,e=void 0),this.style.queryRenderedFeatures(e=e||[[0,0],[this.transform.width,this.transform.height]],t=t||{},this.transform)):[]}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}queryTerrainElevation(e,t){const i=this.transform.elevation;return i?(t=b({},{exaggerated:!0},t),i.getAtPoint(MercatorCoordinate.fromLngLat(e),null,t.exaggerated)):null}setStyle(e,t){return!1!==(t=b({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},t)).diff&&t.localIdeographFontFamily===this._localIdeographFontFamily&&t.localFontFamily===this._localFontFamily&&this.style&&e?(this._diffStyle(e,t),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._localFontFamily=t.localFontFamily,this._updateStyle(e,t))}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){return this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),e&&(this.style=new Style(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e):this.style.loadJSON(e)),this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Style(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,t){if("string"==typeof e){const i=this._requestManager.normalizeStyleURL(e),r=this._requestManager.transformRequest(i,Xe.Style);Ye(r,((e,i)=>{e?this.fire(new ErrorEvent(e)):i&&this._updateDiff(i,t)}))}else"object"==typeof e&&this._updateDiff(e,t)}_updateDiff(e,t){try{this.style.setState(e)&&this._update(!0)}catch(i){B(`Unable to perform style diff: ${i.message||i.error||i}. Rebuilding the style from scratch.`),this._updateStyle(e,t)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(B("There is no style added to the map."),!1)}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){return!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){const e=this.style&&this.style._sourceCaches;for(const t in e){const i=e[t]._tiles;for(const e in i){const t=i[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}}return!0}addSourceType(e,t,i){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,i)}removeSource(e){return this.style.removeSource(e),this._updateTerrain(),this._update(!0)}getSource(e){return this.style.getSource(e)}addImage(t,i,{pixelRatio:r=1,sdf:n=!1,stretchX:o,stretchY:a,content:s}={}){if(this._lazyInitEmptyStyle(),i instanceof e.HTMLImageElement||e.ImageBitmap&&i instanceof e.ImageBitmap){const{width:e,height:l,data:c}=ee.getImageData(i);this.style.addImage(t,{data:new RGBAImage({width:e,height:l},c),pixelRatio:r,stretchX:o,stretchY:a,content:s,sdf:n,version:0})}else if(void 0===i.width||void 0===i.height)this.fire(new 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`")));else{const{width:e,height:l}=i,c=i;this.style.addImage(t,{data:new RGBAImage({width:e,height:l},new Uint8Array(c.data)),pixelRatio:r,stretchX:o,stretchY:a,content:s,sdf:n,version:0,userImage:c}),c.onAdd&&c.onAdd(this,t)}}updateImage(t,i){const r=this.style.getImage(t);if(!r)return void this.fire(new ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const n=i instanceof e.HTMLImageElement||e.ImageBitmap&&i instanceof e.ImageBitmap?ee.getImageData(i):i,{width:o,height:a}=n;void 0!==o&&void 0!==a?o===r.data.width&&a===r.data.height?(r.data.replace(n.data,!(i instanceof e.HTMLImageElement||e.ImageBitmap&&i instanceof e.ImageBitmap)),this.style.updateImage(t,r)):this.fire(new ErrorEvent(new Error(`The width and height of the updated image (${o}, ${a})\n must be that same as the previous version of the image\n (${r.data.width}, ${r.data.height})`))):this.fire(new 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`")))}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(t,i){at(this._requestManager.transformRequest(t,Xe.Image),((t,r)=>{i(t,r instanceof e.HTMLImageElement?ee.getImageData(r):r)}))}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}setLayerZoomRange(e,t,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){return this.style.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,r={}){return this.style.setPaintProperty(e,t,i,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,r={}){return this.style.setLayoutProperty(e,t,i,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(e){return this._lazyInitEmptyStyle(),!e&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(e),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(e){return this._lazyInitEmptyStyle(),this.style.setFog(e),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(e){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(LngLat.convert(e),this.transform):0}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}_updateContainerDimensions(){if(!this._container)return;const t=this._container.getBoundingClientRect().width||400,i=this._container.getBoundingClientRect().height||300;let r,n,o,a=this._container;for(;a&&(!n||!o);){const t=e.getComputedStyle(a).transform;t&&"none"!==t&&(r=t.match(/matrix.*\((.+)\)/)[1].split(", "),r[0]&&"0"!==r[0]&&"1"!==r[0]&&(n=r[0]),r[3]&&"0"!==r[3]&&"1"!==r[3]&&(o=r[3])),a=a.parentElement}this._containerWidth=n?Math.abs(t/n):t,this._containerHeight=o?Math.abs(i/o):i}_detectMissingCSS(){"rgb(250, 128, 114)"!==e.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&B("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 e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=te("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=te("div","mapboxgl-canvas-container",e);this._interactive&&t.classList.add("mapboxgl-interactive"),this._canvas=te("canvas","mapboxgl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const i=this._controlContainer=te("div","mapboxgl-control-container",e),r=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{r[e]=te("div",`mapboxgl-ctrl-${e}`,i)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,t){const i=ee.devicePixelRatio||1;this._canvas.width=i*Math.ceil(e),this._canvas.height=i*Math.ceil(t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`}_addMarker(e){this._markers.push(e)}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1)}_setupPainter(){const e=b({},$.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),t=this._canvas.getContext("webgl",e)||this._canvas.getContext("experimental-webgl",e);t?(Fe(t,!0),this.painter=new Painter(t,this.transform),this.on("data",(e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)})),_e.testSupport(t)):this.fire(new ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(e){e.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new Event("webglcontextlost",{originalEvent:e}))}_contextRestored(e){this._setupPainter(),this.resize(),this._update(),this.fire(new Event("webglcontextrestored",{originalEvent:e}))}_onMapScroll(e){if(e.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(e){return this.style?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_requestDomTask(e){!this.loaded()||this.loaded()&&!this.isMoving()?e():this._domRenderTaskQueue.add(e)}_render(t){let i;const r=this.painter.context.extTimerQuery,n=ee.now();if(this.listens("gpu-timing-frame")&&(i=r.createQueryEXT(),r.beginQueryEXT(r.TIME_ELAPSED_EXT,i)),this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;this._updateProjectionTransition();let o=!1;const a=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,t=this.transform.pitch,i=ee.now();this.style.zoomHistory.update(e,i);const r=new EvaluationParameters(e,{now:i,fadeDuration:a,pitch:t,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),n=r.crossFadingFactor();1===n&&n===this._crossFadingFactor||(o=!0,this._crossFadingFactor=n),this.style.update(r)}this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let s=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),s=this._updateAverageElevation(n),this.style._updateSources(this.transform),this._forceMarkerUpdate()):s=this._updateAverageElevation(n),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,a,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:a,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new Event("load"))),this.style&&(this.style.hasTransitions()||o)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),i){const t=ee.now()-n;r.endQueryEXT(r.TIME_ELAPSED_EXT,i),setTimeout((()=>{const o=r.getQueryObjectEXT(i,r.QUERY_RESULT_EXT)/1e6;r.deleteQueryEXT(i),this.fire(new Event("gpu-timing-frame",{cpuTime:t,gpuTime:o})),e.performance.mark("frame-gpu",{startTime:n,detail:{gpuTime:o}})}),50)}if(this.listens("gpu-timing-layer")){const e=this.painter.collectGpuTimers();setTimeout((()=>{const t=this.painter.queryGpuTimers(e);this.fire(new Event("gpu-timing-layer",{layerTimes:t}))}),50)}if(this.listens("gpu-timing-deferred-render")){const e=this.painter.collectDeferredRenderGpuQueries();setTimeout((()=>{const t=this.painter.queryGpuTimeDeferredRender(e);this.fire(new Event("gpu-timing-deferred-render",{gpuTime:t}))}),50)}const l=this._sourcesDirty||this._styleDirty||this._placementDirty||s;if(l||this._repaint)this.triggerRepaint();else{const e=!this.isMoving()&&this.loaded();if(e&&(s=this._updateAverageElevation(n,!0)),s)this.triggerRepaint();else if(this._triggerFrame(!1),e&&(this.fire(new Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const e=this._calculateSpeedIndex();this.fire(new Event("speedindexcompleted",{speedIndex:e})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||l||(this._fullyLoaded=!0,this._authenticate())}_forceMarkerUpdate(){for(const e of this._markers)e._update()}_updateAverageElevation(e,t=!1){const i=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);if((t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let r=this.transform.sampleAverageElevation(),n=!1;this.transform.elevation&&(n=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(r)?r=0:this._averageElevationLastSampledAt=e;const o=Math.abs(t-r);if(o>1){if(this._isInitialLoad||n)return this._averageElevation.jumpTo(r),i(r);this._averageElevation.easeTo(r,e,300)}else if(o>1e-4)return this._averageElevation.jumpTo(r),i(r)}return!!this._averageElevation.isEasing(e)&&i(this._averageElevation.getValue(e))}_authenticate(){Be(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(e=>{if(e&&(e.message===Te||401===e.status)){const e=this.painter.context.gl;Fe(e,!1),this._logoControl instanceof LogoControl&&this._logoControl._updateLogo(),e&&e.clear(e.DEPTH_BUFFER_BIT|e.COLOR_BUFFER_BIT|e.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new 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/")))}})),ke(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(()=>{}))}_updateTerrain(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){const e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const i=this.painter.context.gl,r=i.createFramebuffer();function n(e){i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0);const t=new Uint8Array(i.drawingBufferWidth*i.drawingBufferHeight*4);return i.readPixels(0,0,i.drawingBufferWidth,i.drawingBufferHeight,i.RGBA,i.UNSIGNED_BYTE,t),t}return i.bindFramebuffer(i.FRAMEBUFFER,r),this._canvasPixelComparison(n(e),t.canvasCopies.map(n),t.timeStamps)}_canvasPixelComparison(e,t,i){let r=i[1]-i[0];const n=e.length/4;for(let o=0;o<t.length;o++){const a=t[o];let s=0;for(let t=0;t<a.length;t+=4)a[t]===e[t]&&a[t+1]===e[t+1]&&a[t+2]===e[t+2]&&a[t+3]===e[t+3]&&(s+=1);r+=(i[o+2]-i[o+1])*(1-s/n)}return r}remove(){this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.painter.destroy(),this.handlers&&this.handlers.destroy(),this.handlers=void 0,this.setStyle(null),void 0!==e&&(e.removeEventListener("resize",this._onWindowResize,!1),e.removeEventListener("orientationchange",this._onWindowResize,!1),e.removeEventListener("webkitfullscreenchange",this._onWindowResize,!1),e.removeEventListener("online",this._onWindowOnline,!1));const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t&&t.loseContext(),lm(this._canvasContainer),lm(this._controlContainer),lm(this._missingCSSCanary),this._container.classList.remove("mapboxgl-map"),Re.delete(this.painter.context.gl),this._removed=!0,this.fire(new Event("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(e){this._renderNextFrame=this._renderNextFrame||e,this.style&&!this._frame&&(this._frame=ee.frame((e=>{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e)})))}_preloadTiles(e){return x(this.style?Object.values(this.style._sourceCaches):[],((t,i)=>t._preloadTiles(e,i)),(()=>{this.triggerRepaint()})),this}_onWindowOnline(){this._update()}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(e){this._speedIndexTiming!==e&&(this._speedIndexTiming=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}_setCacheLimits(e,t){!function(e,t){Ve=e,Ue=t}(e,t)}get version(){return X}},NavigationControl:class NavigationControl{constructor(e){this.options=b({},cm,e),this._container=te("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(I(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",(e=>{this._map&&this._map.zoomIn({},{originalEvent:e})})),te("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",(e=>{this._map&&this._map.zoomOut({},{originalEvent:e})})),te("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(I(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",(e=>{const t=this._map;t&&(this.options.visualizePitch?t.resetNorthPitch({},{originalEvent:e}):t.resetNorth({},{originalEvent:e}))})),this._compassIcon=te("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const e=this._map;if(!e)return;const t=e.getZoom(),i=t===e.getMaxZoom(),r=t===e.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",r.toString())}_rotateCompassArrow(){const e=this._map;if(!e)return;const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(e.transform.pitch*(Math.PI/180)),.5)}) rotateX(${e.transform.pitch}deg) rotateZ(${e.transform.angle*(180/Math.PI)}deg)`:`rotate(${e.transform.angle*(180/Math.PI)}deg)`;e._requestDomTask((()=>{this._compassIcon&&(this._compassIcon.style.transform=t)}))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),e.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&e.on("pitch",this._rotateCompassArrow),e.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new MouseRotateWrapper(e,this._compass,this.options.visualizePitch)),this._container}onRemove(){const e=this._map;e&&(this._container.remove(),this.options.showZoom&&e.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&e.off("pitch",this._rotateCompassArrow),e.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(e,t){const i=te("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_setButtonTitle(e,t){if(!this._map)return;const i=this._map._getUIString(`NavigationControl.${t}`);e.setAttribute("aria-label",i),e.firstElementChild&&e.firstElementChild.setAttribute("title",i)}},GeolocateControl:class GeolocateControl extends Evented{constructor(t){super(),this.options=b({geolocation:e.navigator.geolocation},um,t),I(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Ff(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(e){return this._map=e,this._container=te("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){void 0!==this._geolocationWatchID&&(this.options.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,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(t){void 0!==this._supportsGeolocation?t(this._supportsGeolocation):void 0!==e.navigator.permissions?e.navigator.permissions.query({name:"geolocation"}).then((e=>{this._supportsGeolocation="denied"!==e.state,t(this._supportsGeolocation)})):(this._supportsGeolocation=!!this.options.geolocation,t(this._supportsGeolocation))}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return!!t&&(i.longitude<t.getWest()||i.longitude>t.getEast()||i.latitude<t.getSouth()||i.latitude>t.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(e){if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new Event("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,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(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new Event("geolocate",e)),this._finish()}}_updateCamera(e){const t=new LngLat(e.coords.longitude,e.coords.latitude),i=e.coords.accuracy,r=b({bearing:this._map.getBearing()},this.options.fitBoundsOptions);this._map.fitBounds(t.toBounds(i),r,{geolocateSource:!0})}_updateMarker(e){if(e){const t=new LngLat(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(t).addTo(this._map),this._userLocationDotMarker.setLngLat(t).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const e=this._map.transform,t=Po(1,e._center.lat)*e.worldSize,i=Math.ceil(2*this._accuracy*t);this._circleElement.style.width=`${i}px`,this._circleElement.style.height=`${i}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(e){if(this._map){if(this.options.trackUserLocation)if(1===e.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 e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new Event("error",e)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(e){if(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=te("button","mapboxgl-ctrl-geolocate",this._container),te("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===e){B("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=te("div","mapboxgl-user-location"),this._dotElement.appendChild(te("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(te("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Marker({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=te("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Marker({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",(e=>{e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new Event("trackuserlocationend")))}))}_onDeviceOrientation(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return B("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 Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!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 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 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 e;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(e={maximumAge:6e5,timeout:0},this._noTimeout=!0):(e=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,e),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const t=()=>{e.addEventListener("ondeviceorientationabsolute"in e?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};void 0!==e.DeviceMotionEvent&&"function"==typeof e.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((e=>{"granted"===e&&t()})).catch(console.error):t()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),e.removeEventListener("deviceorientation",this._onDeviceOrientation),e.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),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:AttributionControl,ScaleControl:class ScaleControl{constructor(e){this.options=b({},hm,e),function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"narrow",unit:"meter"}),!0}catch(e){return!1}}()||(this._setScale=pm.bind(this)),I(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,i=t._containerHeight/2,r=t._containerWidth/2-e/2,n=t.unproject([r,i]),o=t.unproject([r+e,i]),a=n.distanceTo(o);if("imperial"===this.options.unit){const t=3.2808*a;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot")}else"nautical"===this.options.unit?this._setScale(e,a/1852,"nautical-mile"):a>=1e3?this._setScale(e,a/1e3,"kilometer"):this._setScale(e,a,"meter")}_setScale(e,t,i){const r=dm(t),n=r/t;this._map._requestDomTask((()=>{this._container.style.width=e*n+"px",this._container.innerHTML="nautical-mile"!==i?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"narrow",unit:i}).format(r):`${r} nm`}))}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=te("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(e){this._language=e,this._update()}setUnit(e){this.options.unit=e,this._update()}},FullscreenControl:class FullscreenControl{constructor(t){this._fullscreen=!1,t&&t.container&&(t.container instanceof e.HTMLElement?this._container=t.container:B("Full screen control 'container' must be a DOM element.")),I(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in e.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in e.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=te("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",B("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,e.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!e.document.fullscreenEnabled&&!e.document.webkitFullscreenEnabled)}_setupUI(){const t=this._fullscreenButton=te("button","mapboxgl-ctrl-fullscreen",this._controlContainer);te("span","mapboxgl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),e.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(){(e.document.fullscreenElement||e.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()?e.document.exitFullscreen?e.document.exitFullscreen():e.document.webkitCancelFullScreen&&e.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class Popup extends Evented{constructor(e){super(),this.options=b(Object.create(fm),e),I(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(e&&e.className?e.className.trim().split(/\s+/):[])}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&e.on("preclick",this._onClose),this.options.closeOnMove&&e.on("move",this._onClose),e.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(e.on("mousemove",this._onMouseEvent),e.on("mouseup",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")):e.on("move",this._update),this.fire(new Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const e=this._map;return e&&(e.off("move",this._update),e.off("move",this._onClose),e.off("preclick",this._onClose),e.off("click",this._onClose),e.off("remove",this.remove),e.off("mousemove",this._onMouseEvent),e.off("mouseup",this._onMouseEvent),e.off("drag",this._onMouseEvent),this._map=void 0),this.fire(new Event("close")),this}getLngLat(){return this._lngLat}setLngLat(e){this._lngLat=LngLat.convert(e),this._pos=null,this._trackPointer=!1,this._update();const t=this._map;return t&&(t.on("move",this._update),t.off("mousemove",this._onMouseEvent),t._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const e=this._map;return e&&(e.off("move",this._update),e.on("mousemove",this._onMouseEvent),e.on("drag",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(e.document.createTextNode(t))}setHTML(t){const i=e.document.createDocumentFragment(),r=e.document.createElement("body");let n;for(r.innerHTML=t;n=r.firstChild,n;)i.appendChild(n);return this.setDOMContent(i)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=te("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=te("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.setAttribute("aria-hidden","true"),e.innerHTML="×",e.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(e){return this._classList.add(e),this._updateClassList(),this}removeClassName(e){return this._classList.delete(e),this._updateClassList(),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){let t;return this._classList.delete(e)?t=!1:(this._classList.add(e),t=!0),this._updateClassList(),t}_onMouseEvent(e){this._update(e.point)}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const t=this._map,i=this._container,r=this._pos;if(!t||!i||!r)return"bottom";const n=i.offsetWidth,o=i.offsetHeight,a=r.x<n/2,s=r.x>t.transform.width-n/2;if(r.y+e<o)return a?"top-left":s?"top-right":"top";if(r.y>t.transform.height-o){if(a)return"bottom-left";if(s)return"bottom-right"}return a?"left":s?"right":"bottom"}_updateClassList(){const e=this._container;if(!e)return;const t=[...this._classList];t.push("mapboxgl-popup"),this._anchor&&t.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),e.className=t.join(" ")}_update(e){const t=this._map,i=this._content;if(!t||!this._lngLat&&!this._trackPointer||!i)return;let r=this._container;if(r||(r=this._container=te("div","mapboxgl-popup",t.getContainer()),this._tip=te("div","mapboxgl-popup-tip",r),r.appendChild(i)),this.options.maxWidth&&r.style.maxWidth!==this.options.maxWidth&&(r.style.maxWidth=this.options.maxWidth),t.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=nm(this._lngLat,this._pos,t.transform)),!this._trackPointer||e){const i=this._pos=this._trackPointer&&e?e:t.project(this._lngLat),r=_m(this.options.offset),n=this._anchor=this._getAnchor(r.y),o=_m(this.options.offset,n),a=i.add(o).round();t._requestDomTask((()=>{this._container&&n&&(this._container.style.transform=`${om[n]} translate(${a.x}px,${a.y}px)`)}))}if(!this._marker&&t._showingGlobe()){const e=Tu(t.transform,this._lngLat)?0:1;this._setOpacity(e)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(mm);e&&e.focus()}_onClose(){this.remove()}_setOpacity(e){this._container&&(this._container.style.opacity=`${e}`),this._content&&(this._content.style.pointerEvents=e?"auto":"none")}},Marker:Marker,Style:Style,LngLat:LngLat,LngLatBounds:LngLatBounds,Point:r,MercatorCoordinate:MercatorCoordinate,FreeCameraOptions:FreeCameraOptions,Evented:Evented,config:me,prewarm:function(){ip().acquire(ep)},clearPrewarmedResources:function(){const e=tp;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(ep),tp=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 me.ACCESS_TOKEN},set accessToken(e){me.ACCESS_TOKEN=e},get baseApiUrl(){return me.API_URL},set baseApiUrl(e){me.API_URL=e},get workerCount(){return WorkerPool.workerCount},set workerCount(e){WorkerPool.workerCount=e},get maxParallelImageRequests(){return me.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(e){me.MAX_PARALLEL_IMAGE_REQUESTS=e},clearStorage(e){!function(e){const t=Ge(),i=[];for(const e in je)t&&i.push(t.delete(e)),delete je[e];e&&Promise.all(i).catch(e).then((()=>e()))}(e)},workerUrl:"",workerClass:null,setNow:ee.setNow,restoreNow:ee.restoreNow};return gm}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).mapboxgl=t()}(this,(function(){"use strict";var e="undefined"!=typeof self?self:{},t=i;function i(e,t,i,r){this.cx=3*e,this.bx=3*(i-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(r-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=r,this.p2x=i,this.p2y=r}i.prototype.sampleCurveX=function(e){return((this.ax*e+this.bx)*e+this.cx)*e},i.prototype.sampleCurveY=function(e){return((this.ay*e+this.by)*e+this.cy)*e},i.prototype.sampleCurveDerivativeX=function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},i.prototype.solveCurveX=function(e,t){var i,r,n,o,a;for(void 0===t&&(t=1e-6),n=e,a=0;a<8;a++){if(o=this.sampleCurveX(n)-e,Math.abs(o)<t)return n;var s=this.sampleCurveDerivativeX(n);if(Math.abs(s)<1e-6)break;n-=o/s}if((n=e)<(i=0))return i;if(n>(r=1))return r;for(;i<r;){if(o=this.sampleCurveX(n),Math.abs(o-e)<t)return n;e>o?i=n:r=n,n=.5*(r-i)+i}return n},i.prototype.solve=function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))};var r=n;function n(e,t){this.x=e,this.y=t}function o(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!o(e[i],t[i]))return!1;return!0}if("object"==typeof e&&null!==e&&null!==t){if("object"!=typeof t)return!1;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const i in e)if(!o(e[i],t[i]))return!1;return!0}return e===t}n.prototype={clone:function(){return new n(this.x,this.y)},add:function(e){return this.clone()._add(e)},sub:function(e){return this.clone()._sub(e)},multByPoint:function(e){return this.clone()._multByPoint(e)},divByPoint:function(e){return this.clone()._divByPoint(e)},mult:function(e){return this.clone()._mult(e)},div:function(e){return this.clone()._div(e)},rotate:function(e){return this.clone()._rotate(e)},rotateAround:function(e,t){return this.clone()._rotateAround(e,t)},matMult:function(e){return this.clone()._matMult(e)},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(e){return this.x===e.x&&this.y===e.y},dist:function(e){return Math.sqrt(this.distSqr(e))},distSqr:function(e){var t=e.x-this.x,i=e.y-this.y;return t*t+i*i},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith:function(e){return this.angleWithSep(e.x,e.y)},angleWithSep:function(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult:function(e){var t=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=t,this},_add:function(e){return this.x+=e.x,this.y+=e.y,this},_sub:function(e){return this.x-=e.x,this.y-=e.y,this},_mult:function(e){return this.x*=e,this.y*=e,this},_div:function(e){return this.x/=e,this.y/=e,this},_multByPoint:function(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint:function(e){return this.x/=e.x,this.y/=e.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var e=this.y;return this.y=this.x,this.x=-e,this},_rotate:function(e){var t=Math.cos(e),i=Math.sin(e),r=i*this.x+t*this.y;return this.x=t*this.x-i*this.y,this.y=r,this},_rotateAround:function(e,t){var i=Math.cos(e),r=Math.sin(e),n=t.y+r*(this.x-t.x)+i*(this.y-t.y);return this.x=t.x+i*(this.x-t.x)-r*(this.y-t.y),this.y=n,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},n.convert=function(e){return e instanceof n?e:Array.isArray(e)?new n(e[0],e[1]):e};const a=Math.PI/180,s=180/Math.PI;function l(e){return e*a}function c(e){return e*s}const u=[[0,0],[1,0],[1,1],[0,1]];function h(e){if(e<=0)return 0;if(e>=1)return 1;const t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}function p(e){let t=1/0,i=1/0,n=-1/0,o=-1/0;for(const r of e)t=Math.min(t,r.x),i=Math.min(i,r.y),n=Math.max(n,r.x),o=Math.max(o,r.y);return{min:new r(t,i),max:new r(n,o)}}function d(e,t,i=0,n=!0){const o=new r(i,i),a=e.sub(o),s=t.add(o),l=[a,new r(s.x,a.y),s,new r(a.x,s.y)];return n&&l.push(a.clone()),l}function f(e,i,r,n){const o=new t(e,i,r,n);return function(e){return o.solve(e)}}const m=f(.25,.1,.25,1);function _(e,t,i){return Math.min(i,Math.max(t,e))}function g(e,t,i){return(i=_((i-e)/(t-e),0,1))*i*(3-2*i)}function y(e,t,i){const r=i-t,n=((e-t)%r+r)%r+t;return n===t?i:n}function x(e,t,i){if(!e.length)return i(null,[]);let r=e.length;const n=new Array(e.length);let o=null;e.forEach(((e,a)=>{t(e,((e,t)=>{e&&(o=e),n[a]=t,0==--r&&i(o,n)}))}))}function v(e){const t=[];for(const i in e)t.push(e[i]);return t}function b(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}function w(e,t){const i={};for(let r=0;r<t.length;r++){const n=t[r];n in e&&(i[n]=e[n])}return i}let T=1;function E(){return T++}function S(){return function e(t){return t?(t^Math.random()*(16>>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()}function A(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function C(e){return!!e&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}function I(e,t){e.forEach((e=>{t[e]&&(t[e]=t[e].bind(t))}))}function M(e,t){return-1!==e.indexOf(t,e.length-t.length)}function P(e,t,i){const r={};for(const n in e)r[n]=t.call(i||this,e[n],n,e);return r}function D(e,t,i){const r={};for(const n in e)t.call(i||this,e[n],n,e)&&(r[n]=e[n]);return r}function z(e){return Array.isArray(e)?e.map(z):"object"==typeof e&&e?P(e,z):e}function k(e,t,i,r,n){return _((e-t)/(i-t)*(n-r)+r,r,n)}const L={};function B(e){L[e]||("undefined"!=typeof console&&console.warn(e),L[e]=!0)}function R(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function F(e){let t=0;for(let i,r,n=0,o=e.length,a=o-1;n<o;a=n++)i=e[n],r=e[a],t+=(r.x-i.x)*(i.y+r.y);return t}function O(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}function V(e){const t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,i,r,n)=>{const o=r||n;return t[i]=!o||o.toLowerCase(),""})),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e}return t}let U=null;function j(e){if(null==U){const t=e.navigator?e.navigator.userAgent:null;U=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return U}function N(){return!!e.document.fullscreenElement||!!e.document.webkitFullscreenElement}function G(t){try{const i=e[t];return i.setItem("_mapbox_test_",1),i.removeItem("_mapbox_test_"),!0}catch(e){return!1}}function Z(e,t){return[e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}function q(e,t,i){e[4*t+0]=i[0],e[4*t+1]=i[1],e[4*t+2]=i[2],e[4*t+3]=i[3]}var $=W;function W(e){return!function(e){return"undefined"==typeof window||"undefined"==typeof document?"not a browser":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 e,t,i=new Blob([""],{type:"text/javascript"}),r=URL.createObjectURL(i);try{t=new Worker(r),e=!0}catch(t){e=!1}return t&&t.terminate(),URL.revokeObjectURL(r),e}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var e=document.createElement("canvas");e.width=e.height=1;var t=e.getContext("2d");if(!t)return!1;var i=t.getImageData(0,0,1,1);return i&&i.width===e.width}()?(void 0===H[t=e&&e.failIfMajorPerformanceCaveat]&&(H[t]=function(e){var t,i=function(e){var t=document.createElement("canvas"),i=Object.create(W.webGLContextAttributes);return i.failIfMajorPerformanceCaveat=e,t.getContext("webgl",i)||t.getContext("experimental-webgl",i)}(e);if(!i)return!1;try{t=i.createShader(i.VERTEX_SHADER)}catch(e){return!1}return!(!t||i.isContextLost())&&(i.shaderSource(t,"void main() {}"),i.compileShader(t),!0===i.getShaderParameter(t,i.COMPILE_STATUS))}(t)),H[t]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var t}(e)}var H={};W.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};var X="2.10.0";let K,J,Y,Q;const ee={now:()=>void 0!==Y?Y:e.performance.now(),setNow(e){Y=e},restoreNow(){Y=void 0},frame(t){const i=e.requestAnimationFrame(t);return{cancel:()=>e.cancelAnimationFrame(i)}},getImageData(t,i=0){const{width:r,height:n}=t;Q||(Q=e.document.createElement("canvas"));const o=Q.getContext("2d");if(!o)throw new Error("failed to create canvas 2d context");return(r>Q.width||n>Q.height)&&(Q.width=r,Q.height=n),o.clearRect(-i,-i,r+2*i,n+2*i),o.drawImage(t,0,0,r,n),o.getImageData(-i,-i,r+2*i,n+2*i)},resolveURL:t=>(K||(K=e.document.createElement("a")),K.href=t,K.href),get devicePixelRatio(){return e.devicePixelRatio},get prefersReducedMotion(){return!!e.matchMedia&&(null==J&&(J=e.matchMedia("(prefers-reduced-motion: reduce)")),J.matches)}};function te(t,i,r){const n=e.document.createElement(t);return void 0!==i&&(n.className=i),r&&r.appendChild(n),n}function ie(t,i,r){const n=e.document.createElementNS("http://www.w3.org/2000/svg",t);for(const e of Object.keys(i))n.setAttributeNS(null,e,i[e]);return r&&r.appendChild(n),n}const re=e.document&&e.document.documentElement.style,ne=re&&void 0!==re.userSelect?"userSelect":"WebkitUserSelect";let oe,ae;function se(){re&&ne&&(oe=re[ne],re[ne]="none")}function le(){re&&ne&&(re[ne]=oe)}function ce(t){t.preventDefault(),t.stopPropagation(),e.removeEventListener("click",ce,!0)}function ue(){e.addEventListener("click",ce,!0),e.setTimeout((()=>{e.removeEventListener("click",ce,!0)}),0)}function he(e,t){const i=e.getBoundingClientRect();return fe(e,i,t)}function pe(e,t){const i=e.getBoundingClientRect(),r=[];for(let n=0;n<t.length;n++)r.push(fe(e,i,t[n]));return r}function de(t){return void 0!==e.InstallTrigger&&2===t.button&&t.ctrlKey&&e.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:t.button}function fe(e,t,i){const n=e.offsetWidth===t.width?1:e.offsetWidth/t.width;return new r((i.clientX-t.left)*n,(i.clientY-t.top)*n)}const me={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==ae){const e=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{ae=null!=process.env.API_URL_REGEX?new RegExp(process.env.API_URL_REGEX):e}catch(t){ae=e}}return ae},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},_e={supported:!1,testSupport:function(e){!xe&&ye&&(ve?be(e):ge=e)}};let ge,ye,xe=!1,ve=!1;function be(e){const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);try{if(e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,ye),e.isContextLost())return;_e.supported=!0}catch(e){}e.deleteTexture(t),xe=!0}e.document&&(ye=e.document.createElement("img"),ye.onload=function(){ge&&be(ge),ge=null,ve=!0},ye.onerror=function(){xe=!0,ge=null},ye.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const we="01",Te="NO_ACCESS_TOKEN";class RequestManager{constructor(e,t,i){this._transformRequestFn=e,this._customAccessToken=t,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const e=function(){let e="";for(let t=0;t<10;t++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",we,e].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=e.token,this._skuTokenExpiresAt=e.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(e,t){if(!Ee(e))return e;const i=Ce(e);return i.path=`/styles/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeGlyphsURL(e,t){if(!Ee(e))return e;const i=Ce(e);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeSourceURL(e,t,i,r){if(!Ee(e))return e;const n=Ce(e);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),i&&n.params.push(`language=${i}`),r&&n.params.push(`worldview=${r}`),this._makeAPIURL(n,this._customAccessToken||t)}normalizeSpriteURL(e,t,i,r){const n=Ce(e);return Ee(e)?(n.path=`/styles/v1${n.path}/sprite${t}${i}`,this._makeAPIURL(n,this._customAccessToken||r)):(n.path+=`${t}${i}`,Ie(n))}normalizeTileURL(e,t,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),e&&!Ee(e))return e;const r=Ce(e);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${t||i&&"raster"!==r.authority&&512===i?"@2x":""}${_e.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${me.RASTER_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${me.TILE_URL_VERSION}${r.path}`);const n=this._customAccessToken||function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null}(r.params)||me.ACCESS_TOKEN;return me.REQUIRE_ACCESS_TOKEN&&n&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,n)}canonicalizeTileURL(e,t){const i=Ce(e);if(!i.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!i.path.match(/\.[\w]+$/))return e;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${me.RASTER_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${me.TILE_URL_VERSION}/`,"")}`;let n=i.params;return t&&(n=n.filter((e=>!e.match(/^access_token=/)))),n.length&&(r+=`?${n.join("&")}`),r}canonicalizeTileset(e,t){const i=!!t&&Ee(t),r=[];for(const t of e.tiles||[])Se(t)?r.push(this.canonicalizeTileURL(t,i)):r.push(t);return r}_makeAPIURL(e,t){const i="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",r=Ce(me.API_URL);if(e.protocol=r.protocol,e.authority=r.authority,"http"===e.protocol){const t=e.params.indexOf("secure");t>=0&&e.params.splice(t,1)}if("/"!==r.path&&(e.path=`${r.path}${e.path}`),!me.REQUIRE_ACCESS_TOKEN)return Ie(e);if(t=t||me.ACCESS_TOKEN,!this._silenceAuthErrors){if(!t)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===t[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return e.params=e.params.filter((e=>-1===e.indexOf("access_token"))),e.params.push(`access_token=${t||""}`),Ie(e)}}function Ee(e){return 0===e.indexOf("mapbox:")}function Se(e){return me.API_URL_REGEX.test(e)}const Ae=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Ce(e){const t=e.match(Ae);if(!t)throw new Error("Unable to parse URL object");return{protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function Ie(e){const t=e.params.length?`?${e.params.join("&")}`:"";return`${e.protocol}://${e.authority}${e.path}${t}`}function Me(t){if(!t)return null;const i=t.split(".");if(!i||3!==i.length)return null;try{return JSON.parse(decodeURIComponent(e.atob(i[1]).split("").map((e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2))).join("")))}catch(e){return null}}class TelemetryEvent{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(t){const i=Me(me.ACCESS_TOKEN);let r="";return r=i&&i.u?e.btoa(encodeURIComponent(i.u).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(Number("0x"+t))))):me.ACCESS_TOKEN||"",t?`mapbox.eventData.${t}:${r}`:`mapbox.eventData:${r}`}fetchEventData(){const t=G("localStorage"),i=this.getStorageKey(),r=this.getStorageKey("uuid");if(t)try{const t=e.localStorage.getItem(i);t&&(this.eventData=JSON.parse(t));const n=e.localStorage.getItem(r);n&&(this.anonId=n)}catch(e){B("Unable to read from LocalStorage")}}saveEventData(){const t=G("localStorage"),i=this.getStorageKey(),r=this.getStorageKey("uuid");if(t)try{e.localStorage.setItem(r,this.anonId),Object.keys(this.eventData).length>=1&&e.localStorage.setItem(i,JSON.stringify(this.eventData))}catch(e){B("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,t,i,r){if(!me.EVENTS_URL)return;const n=Ce(me.EVENTS_URL);n.params.push(`access_token=${r||me.ACCESS_TOKEN||""}`);const o={event:this.type,created:new Date(e).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:X,skuId:we,userId:this.anonId},a=t?b(o,t):o,s={url:Ie(n),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=et(s,(e=>{this.pendingRequest=null,i(e),this.saveEventData(),this.processRequests(r)}))}queueRequest(e,t){this.queue.push(e),this.processRequests(t)}}const Pe=new class TurnstileEvent extends TelemetryEvent{constructor(e){super("appUserTurnstile"),this._customAccessToken=e}postTurnstileEvent(e,t){me.EVENTS_URL&&me.ACCESS_TOKEN&&Array.isArray(e)&&e.some((e=>Ee(e)||Se(e)))&&this.queueRequest(Date.now(),t)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const t=Me(me.ACCESS_TOKEN),i=t?t.u:me.ACCESS_TOKEN;let r=i!==this.eventData.tokenU;C(this.anonId)||(this.anonId=S(),r=!0);const n=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(n),i=(n-this.eventData.lastSuccess)/864e5;r=r||i>=1||i<-1||e.getDate()!==t.getDate()}else r=!0;r?this.postEvent(n,{"enabled.telemetry":!1},(e=>{e||(this.eventData.lastSuccess=n,this.eventData.tokenU=i)}),e):this.processRequests()}},De=Pe.postTurnstileEvent.bind(Pe),ze=new class MapLoadEvent extends TelemetryEvent{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(e,t,i,r){this.skuToken=t,this.errorCb=r,me.EVENTS_URL&&(i||me.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(Te)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:i}=this.queue.shift();t&&this.success[t]||(this.anonId||this.fetchEventData(),C(this.anonId)||(this.anonId=S()),this.postEvent(i,{skuToken:this.skuToken},(e=>{e?this.errorCb(e):t&&(this.success[t]=!0)}),e))}},ke=ze.postMapLoadEvent.bind(ze),Le=new class MapSessionAPI extends TelemetryEvent{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,t,i,r){if(!me.API_URL||!me.SESSION_PATH)return;const n=Ce(me.API_URL+me.SESSION_PATH);n.params.push(`sku=${t||""}`),n.params.push(`access_token=${r||me.ACCESS_TOKEN||""}`);const o={url:Ie(n),headers:{"Content-Type":"text/plain"}};this.pendingRequest=tt(o,(e=>{this.pendingRequest=null,i(e),this.saveEventData(),this.processRequests(r)}))}getSessionAPI(e,t,i,r){this.skuToken=t,this.errorCb=r,me.SESSION_PATH&&me.API_URL&&(i||me.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(Te)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:i}=this.queue.shift();t&&this.success[t]||this.getSession(i,this.skuToken,(e=>{e?this.errorCb(e):t&&(this.success[t]=!0)}),e)}},Be=Le.getSessionAPI.bind(Le),Re=new Set;function Fe(e,t){t?Re.add(e):Re.delete(e)}let Oe,Ve=500,Ue=50,je={};function Ne(e){const t=qe(e);let i,r;t&&t.forEach((e=>{const t=e.split("=");"language"===t[0]?i=t[1]:"worldview"===t[0]&&(r=t[1])}));let n="mapbox-tiles";return i&&(n+=`-${i}`),r&&(n+=`-${r}`),n}function Ge(){try{return e.caches}catch(e){}}function Ze(e){const t=Ge();t&&!je[e]&&(je[e]=t.open(e))}function qe(e){const t=e.indexOf("?");return t>0?e.slice(t+1).split("&"):[]}function $e(e){const t=e.indexOf("?");if(t<0)return e;const i=qe(e).filter((e=>{const t=e.split("=");return"language"===t[0]||"worldview"===t[0]}));return i.length?`${e.slice(0,t)}?${i.join("&")}`:e.slice(0,t)}let We=1/0;function He(e){We++,We>Ue&&(e.getActor().send("enforceCacheSizeLimit",Ve),We=0)}const Xe={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(Xe);class AJAXError extends Error{constructor(e,t,i){401===t&&Se(i)&&(e+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(e),this.status=t,this.url=i}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const Ke=O()?()=>self.worker&&self.worker.referrer:()=>("blob:"===e.location.protocol?e.parent:e).location.href;const Je=function(t,i){if(!(/^file:/.test(r=t.url)||/^file:/.test(Ke())&&!/^\w+:/.test(r))){if(e.fetch&&e.Request&&e.AbortController&&e.Request.prototype.hasOwnProperty("signal"))return function(t,i){const r=new e.AbortController,n=new e.Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:Ke(),signal:r.signal});let o=!1,a=!1;const s=(l=n.url).indexOf("sku=")>0&&Se(l);var l;"json"===t.type&&n.headers.set("Accept","application/json");const c=(r,o,l)=>{if(a)return;if(r&&"SecurityError"!==r.message&&B(r),o&&l)return u(o);const c=Date.now();e.fetch(n).then((e=>{if(e.ok){const t=s?e.clone():null;return u(e,t,c)}return i(new AJAXError(e.statusText,e.status,t.url))})).catch((e=>{20!==e.code&&i(new Error(e.message))}))},u=(r,s,l)=>{("arrayBuffer"===t.type?r.arrayBuffer():"json"===t.type?r.json():r.text()).then((t=>{a||(s&&l&&function(t,i,r){const n=Ne(t.url);if(Ze(n),!je[n])return;const o={status:i.status,statusText:i.statusText,headers:new e.Headers};i.headers.forEach(((e,t)=>o.headers.set(t,e)));const a=V(i.headers.get("Cache-Control")||"");if(a["no-store"])return;a["max-age"]&&o.headers.set("Expires",new Date(r+1e3*a["max-age"]).toUTCString());const s=o.headers.get("Expires");s&&(new Date(s).getTime()-r<42e4||function(e,t){if(void 0===Oe)try{new Response(new ReadableStream),Oe=!0}catch(e){Oe=!1}Oe?t(e.body):e.blob().then(t)}(i,(i=>{const r=new e.Response(i,o);Ze(n),je[n]&&je[n].then((e=>e.put($e(t.url),r))).catch((e=>B(e.message)))})))}(n,s,l),o=!0,i(null,t,r.headers.get("Cache-Control"),r.headers.get("Expires")))})).catch((e=>{a||i(new Error(e.message))}))};return s?function(e,t){const i=Ne(e.url);if(Ze(i),!je[i])return t(null);const r=$e(e.url);je[i].then((e=>{e.match(r).then((i=>{const n=function(e){if(!e)return!1;const t=new Date(e.headers.get("Expires")||0),i=V(e.headers.get("Cache-Control")||"");return t>Date.now()&&!i["no-cache"]}(i);e.delete(r),n&&e.put(r,i.clone()),t(null,i,n)})).catch(t)})).catch(t)}(n,c):c(null,null),{cancel:()=>{a=!0,o||r.abort()}}}(t,i);if(O()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,i,void 0,!0)}var r;return function(t,i){const r=new e.XMLHttpRequest;r.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(r.responseType="arraybuffer");for(const e in t.headers)r.setRequestHeader(e,t.headers[e]);return"json"===t.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===t.credentials,r.onerror=()=>{i(new Error(r.statusText))},r.onload=()=>{if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){let e=r.response;if("json"===t.type)try{e=JSON.parse(r.response)}catch(e){return i(e)}i(null,e,r.getResponseHeader("Cache-Control"),r.getResponseHeader("Expires"))}else i(new AJAXError(r.statusText,r.status,t.url))},r.send(t.body),{cancel:()=>r.abort()}}(t,i)},Ye=function(e,t){return Je(b(e,{type:"json"}),t)},Qe=function(e,t){return Je(b(e,{type:"arrayBuffer"}),t)},et=function(e,t){return Je(b(e,{method:"POST"}),t)},tt=function(e,t){return Je(b(e,{method:"GET"}),t)};function it(t){const i=e.document.createElement("a");return i.href=t,i.protocol===e.document.location.protocol&&i.host===e.document.location.host}const rt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let nt,ot;nt=[],ot=0;const at=function(t,i){if(_e.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),ot>=me.MAX_PARALLEL_IMAGE_REQUESTS){const e={requestParameters:t,callback:i,cancelled:!1,cancel(){this.cancelled=!0}};return nt.push(e),e}ot++;let r=!1;const n=()=>{if(!r)for(r=!0,ot--;nt.length&&ot<me.MAX_PARALLEL_IMAGE_REQUESTS;){const e=nt.shift(),{requestParameters:t,callback:i,cancelled:r}=e;r||(e.cancel=at(t,i).cancel)}},o=Qe(t,((t,r,o,a)=>{n(),t?i(t):r&&(e.createImageBitmap?function(t,i){const r=new e.Blob([new Uint8Array(t)],{type:"image/png"});e.createImageBitmap(r).then((e=>{i(null,e)})).catch((e=>{i(new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))}))}(r,((e,t)=>i(e,t,o,a))):function(t,i){const r=new e.Image,n=e.URL;r.onload=()=>{i(null,r),n.revokeObjectURL(r.src),r.onload=null,e.requestAnimationFrame((()=>{r.src=rt}))},r.onerror=()=>i(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 o=new e.Blob([new Uint8Array(t)],{type:"image/png"});r.src=t.byteLength?n.createObjectURL(o):rt}(r,((e,t)=>i(e,t,o,a))))}));return{cancel:()=>{o.cancel(),n()}}};function st(e,t,i){i[e]&&-1!==i[e].indexOf(t)||(i[e]=i[e]||[],i[e].push(t))}function lt(e,t,i){if(i&&i[e]){const r=i[e].indexOf(t);-1!==r&&i[e].splice(r,1)}}class Event{constructor(e,t={}){b(this,t),this.type=e}}class ErrorEvent extends Event{constructor(e,t={}){super("error",b({error:e},t))}}class Evented{on(e,t){return this._listeners=this._listeners||{},st(e,t,this._listeners),this}off(e,t){return lt(e,t,this._listeners),lt(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},st(e,t,this._oneTimeListeners),this):new Promise((t=>this.once(e,t)))}fire(e,t){"string"==typeof e&&(e=new Event(e,t||{}));const i=e.type;if(this.listens(i)){e.target=this;const t=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of t)i.call(this,e);const r=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const t of r)lt(i,t,this._oneTimeListeners),t.call(this,e);const n=this._eventedParent;n&&(b(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),n.fire(e))}else e instanceof ErrorEvent&&console.error(e.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}var ct=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"},"fill-extrusion-edge-radius":{"type":"number","private":true,"default":0,"minimum":0,"maximum":1,"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},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"star-intensity":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"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":{},"globe":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90],"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,"requires":["source"]}},"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"},"fill-extrusion-ambient-occlusion-intensity":{"property-type":"data-constant","type":"number","private":true,"default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant","type":"number","private":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"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"},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"transition":false,"requires":[{"source":"geojson","has":{"lineMetrics":true}}],"property-type":"constant"}},"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"}}}');function ut(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}function ht(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function pt(e){if(Array.isArray(e))return e.map(pt);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const i in e)t[i]=pt(e[i]);return t}return ht(e)}class ParsingError extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}var dt=ParsingError;class Scope{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,i]of t)this.bindings[e]=i}concat(e){return new Scope(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}var ft=Scope;const mt={kind:"null"},_t={kind:"number"},gt={kind:"string"},yt={kind:"boolean"},xt={kind:"color"},vt={kind:"object"},bt={kind:"value"},wt={kind:"collator"},Tt={kind:"formatted"},Et={kind:"resolvedImage"};function St(e,t){return{kind:"array",itemType:e,N:t}}function Ct(e){if("array"===e.kind){const t=Ct(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const It=[mt,_t,gt,yt,xt,Tt,vt,St(bt),Et];function Mt(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!Mt(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if("value"===e.kind)for(const e of It)if(!Mt(e,t))return null}return`Expected ${Ct(e)} but found ${Ct(t)} instead.`}function Pt(e,t){return t.some((t=>t.kind===e.kind))}function Dt(e,t){return t.some((t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e))}function zt(e){var t={exports:{}};return e(t,t.exports),t.exports}var kt=zt((function(e,t){var i={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 r(e){return(e=Math.round(e))<0?0:e>255?255:e}function n(e){return r("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function o(e){return(t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t}function a(e,t,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?e+(t-e)*i*6:2*i<1?t:3*i<2?e+(t-e)*(2/3-i)*6:e}try{t.parseCSSColor=function(e){var t,s=e.replace(/ /g,"").toLowerCase();if(s in i)return i[s].slice();if("#"===s[0])return 4===s.length?(t=parseInt(s.substr(1),16))>=0&&t<=4095?[(3840&t)>>4|(3840&t)>>8,240&t|(240&t)>>4,15&t|(15&t)<<4,1]:null:7===s.length&&(t=parseInt(s.substr(1),16))>=0&&t<=16777215?[(16711680&t)>>16,(65280&t)>>8,255&t,1]:null;var l=s.indexOf("("),c=s.indexOf(")");if(-1!==l&&c+1===s.length){var u=s.substr(0,l),h=s.substr(l+1,c-(l+1)).split(","),p=1;switch(u){case"rgba":if(4!==h.length)return null;p=o(h.pop());case"rgb":return 3!==h.length?null:[n(h[0]),n(h[1]),n(h[2]),p];case"hsla":if(4!==h.length)return null;p=o(h.pop());case"hsl":if(3!==h.length)return null;var d=(parseFloat(h[0])%360+360)%360/360,f=o(h[1]),m=o(h[2]),_=m<=.5?m*(f+1):m+f-m*f,g=2*m-_;return[r(255*a(g,_,d+1/3)),r(255*a(g,_,d)),r(255*a(g,_,d-1/3)),p];default:return null}}return null}}catch(e){}}));class Color{constructor(e,t,i,r=1){this.r=e,this.g=t,this.b=i,this.a=r}static parse(e){if(!e)return;if(e instanceof Color)return e;if("string"!=typeof e)return;const t=kt.parseCSSColor(e);return t?new Color(t[0]/255*t[3],t[1]/255*t[3],t[2]/255*t[3],t[3]):void 0}toString(){const[e,t,i,r]=this.toArray();return`rgba(${Math.round(e)},${Math.round(t)},${Math.round(i)},${r})`}toArray(){const{r:e,g:t,b:i,a:r}=this;return 0===r?[0,0,0,0]:[255*e/r,255*t/r,255*i/r,r]}toArray01(){const{r:e,g:t,b:i,a:r}=this;return 0===r?[0,0,0,0]:[e/r,t/r,i/r,r]}toArray01PremultipliedAlpha(){const{r:e,g:t,b:i,a:r}=this;return[e,t,i,r]}}Color.black=new Color(0,0,0,1),Color.white=new Color(1,1,1,1),Color.transparent=new Color(0,0,0,0),Color.red=new Color(1,0,0,1),Color.blue=new Color(0,0,1,1);var Lt=Color;class Collator{constructor(e,t,i){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class FormattedSection{constructor(e,t,i,r,n){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=i,this.fontStack=r,this.textColor=n}}class Formatted{constructor(e){this.sections=e}static fromString(e){return new Formatted([new FormattedSection(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((e=>0!==e.text.length||e.image&&0!==e.image.name.length))}static factory(e){return e instanceof Formatted?e:Formatted.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map((e=>e.text)).join("")}serialize(){const e=["format"];for(const t of this.sections){if(t.image){e.push(["image",t.image.name]);continue}e.push(t.text);const i={};t.fontStack&&(i["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(i["font-scale"]=t.scale),t.textColor&&(i["text-color"]=["rgba"].concat(t.textColor.toArray())),e.push(i)}return e}}class ResolvedImage{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new ResolvedImage({name:e,available:!1}):null}serialize(){return["image",this.name]}}function Bt(e,t,i,r){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Rt(e){if(null===e)return!0;if("string"==typeof e)return!0;if("boolean"==typeof e)return!0;if("number"==typeof e)return!0;if(e instanceof Lt)return!0;if(e instanceof Collator)return!0;if(e instanceof Formatted)return!0;if(e instanceof ResolvedImage)return!0;if(Array.isArray(e)){for(const t of e)if(!Rt(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!Rt(e[t]))return!1;return!0}return!1}function Ft(e){if(null===e)return mt;if("string"==typeof e)return gt;if("boolean"==typeof e)return yt;if("number"==typeof e)return _t;if(e instanceof Lt)return xt;if(e instanceof Collator)return wt;if(e instanceof Formatted)return Tt;if(e instanceof ResolvedImage)return Et;if(Array.isArray(e)){const t=e.length;let i;for(const t of e){const e=Ft(t);if(i){if(i===e)continue;i=bt;break}i=e}return St(i||bt,t)}return vt}function Ot(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Lt||e instanceof Formatted||e instanceof ResolvedImage?e.toString():JSON.stringify(e)}class Literal{constructor(e,t){this.type=e,this.value=t}static parse(e,t){if(2!==e.length)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Rt(e[1]))return t.error("invalid value");const i=e[1];let r=Ft(i);const n=t.expectedType;return"array"!==r.kind||0!==r.N||!n||"array"!==n.kind||"number"==typeof n.N&&0!==n.N||(r=n),new Literal(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof Lt?["rgba"].concat(this.value.toArray()):this.value instanceof Formatted?this.value.serialize():this.value}}var Vt=Literal,Ut=class RuntimeError{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}};const jt={string:gt,number:_t,boolean:yt,object:vt};class Assertion{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let i,r=1;const n=e[0];if("array"===n){let n,o;if(e.length>2){const i=e[1];if("string"!=typeof i||!(i in jt)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);n=jt[i],r++}else n=bt;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);o=e[2],r++}i=St(n,o)}else i=jt[n];const o=[];for(;r<e.length;r++){const i=t.parse(e[r],r,bt);if(!i)return null;o.push(i)}return new Assertion(i,o)}evaluate(e){for(let t=0;t<this.args.length;t++){const i=this.args[t].evaluate(e);if(!Mt(this.type,Ft(i)))return i;if(t===this.args.length-1)throw new Ut(`Expected value to be of type ${Ct(this.type)}, but found ${Ct(Ft(i))} instead.`)}return null}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){const e=this.type,t=[e.kind];if("array"===e.kind){const i=e.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){t.push(i.kind);const r=e.N;("number"==typeof r||this.args.length>1)&&t.push(r)}}return t.concat(this.args.map((e=>e.serialize())))}}var Nt=Assertion;class FormatExpression{constructor(e){this.type=Tt,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[1];if(!Array.isArray(i)&&"object"==typeof i)return t.error("First argument must be an image or text section.");const r=[];let n=!1;for(let i=1;i<=e.length-1;++i){const o=e[i];if(n&&"object"==typeof o&&!Array.isArray(o)){n=!1;let e=null;if(o["font-scale"]&&(e=t.parse(o["font-scale"],1,_t),!e))return null;let i=null;if(o["text-font"]&&(i=t.parse(o["text-font"],1,St(gt)),!i))return null;let a=null;if(o["text-color"]&&(a=t.parse(o["text-color"],1,xt),!a))return null;const s=r[r.length-1];s.scale=e,s.font=i,s.textColor=a}else{const o=t.parse(e[i],1,bt);if(!o)return null;const a=o.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,r.push({content:o,scale:null,font:null,textColor:null})}}return new FormatExpression(r)}evaluate(e){return new Formatted(this.sections.map((t=>{const i=t.content.evaluate(e);return Ft(i)===Et?new FormattedSection("",i,null,null,null):new FormattedSection(Ot(i),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null)})))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const t of this.sections){e.push(t.content.serialize());const i={};t.scale&&(i["font-scale"]=t.scale.serialize()),t.font&&(i["text-font"]=t.font.serialize()),t.textColor&&(i["text-color"]=t.textColor.serialize()),e.push(i)}return e}}class ImageExpression{constructor(e){this.type=Et,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,gt);return i?new ImageExpression(i):t.error("No image name provided.")}evaluate(e){const t=this.input.evaluate(e),i=ResolvedImage.fromString(t);return i&&e.availableImages&&(i.available=e.availableImages.indexOf(t)>-1),i}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const Gt={"to-boolean":yt,"to-color":xt,"to-number":_t,"to-string":gt};class Coercion{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[0];if(("to-boolean"===i||"to-string"===i)&&2!==e.length)return t.error("Expected one argument.");const r=Gt[i],n=[];for(let i=1;i<e.length;i++){const r=t.parse(e[i],i,bt);if(!r)return null;n.push(r)}return new Coercion(r,n)}evaluate(e){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(e));if("color"===this.type.kind){let t,i;for(const r of this.args){if(t=r.evaluate(e),i=null,t instanceof Lt)return t;if("string"==typeof t){const i=e.parseColor(t);if(i)return i}else if(Array.isArray(t)&&(i=t.length<3||t.length>4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Bt(t[0],t[1],t[2],t[3]),!i))return new Lt(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Ut(i||`Could not parse color from value '${"string"==typeof t?t:String(JSON.stringify(t))}'`)}if("number"===this.type.kind){let t=null;for(const i of this.args){if(t=i.evaluate(e),null===t)return 0;const r=Number(t);if(!isNaN(r))return r}throw new Ut(`Could not convert ${JSON.stringify(t)} to number.`)}return"formatted"===this.type.kind?Formatted.fromString(Ot(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?ResolvedImage.fromString(Ot(this.args[0].evaluate(e))):Ot(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new FormatExpression([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new ImageExpression(this.args[0]).serialize();const e=[`to-${this.type.kind}`];return this.eachChild((t=>{e.push(t.serialize())})),e}}var Zt=Coercion;const qt=["Unknown","Point","LineString","Polygon"];var $t=class EvaluationContext{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&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?qt[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 e=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:i,y:r}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*t-e[0])+this.featureDistanceData.bearing[1]*(r*t-e[1])}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=Lt.parse(e)),t}};class CompoundExpression{constructor(e,t,i,r){this.name=e,this.type=t,this._evaluate=i,this.args=r}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((e=>e.serialize())))}static parse(e,t){const i=e[0],r=CompoundExpression.definitions[i];if(!r)return t.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const n=Array.isArray(r)?r[0]:r.type,o=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,a=o.filter((([t])=>!Array.isArray(t)||t.length===e.length-1));let s=null;for(const[r,o]of a){s=new mi(t.registry,t.path,null,t.scope);const a=[];let l=!1;for(let t=1;t<e.length;t++){const i=e[t],n=Array.isArray(r)?r[t-1]:r.type,o=s.parse(i,1+a.length,n);if(!o){l=!0;break}a.push(o)}if(!l)if(Array.isArray(r)&&r.length!==a.length)s.error(`Expected ${r.length} arguments, but found ${a.length} instead.`);else{for(let e=0;e<a.length;e++){const t=Array.isArray(r)?r[e]:r.type,i=a[e];s.concat(e+1).checkSubtype(t,i.type)}if(0===s.errors.length)return new CompoundExpression(i,n,o,a)}}if(1===a.length)t.errors.push(...s.errors);else{const i=(a.length?a:o).map((([e])=>{return t=e,Array.isArray(t)?`(${t.map(Ct).join(", ")})`:`(${Ct(t.type)}...)`;var t})).join(" | "),r=[];for(let i=1;i<e.length;i++){const n=t.parse(e[i],1+r.length);if(!n)return null;r.push(Ct(n.type))}t.error(`Expected arguments of type ${i}, but found (${r.join(", ")}) instead.`)}return null}static register(e,t){CompoundExpression.definitions=t;for(const i in t)e[i]=CompoundExpression}}var Wt=CompoundExpression;class CollatorExpression{constructor(e,t,i){this.type=wt,this.locale=i,this.caseSensitive=e,this.diacriticSensitive=t}static parse(e,t){if(2!==e.length)return t.error("Expected one argument.");const i=e[1];if("object"!=typeof i||Array.isArray(i))return t.error("Collator options argument must be an object.");const r=t.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,yt);if(!r)return null;const n=t.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,yt);if(!n)return null;let o=null;return i.locale&&(o=t.parse(i.locale,1,gt),!o)?null:new CollatorExpression(r,n,o)}evaluate(e){return new Collator(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}serialize(){const e={};return e["case-sensitive"]=this.caseSensitive.serialize(),e["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(e.locale=this.locale.serialize()),["collator",e]}}const Ht=8192;function Xt(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[0]),e[3]=Math.max(e[3],t[1])}function Kt(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function Jt(e,t){const i=(180+e[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,n=Math.pow(2,t.z);return[Math.round(i*n*Ht),Math.round(r*n*Ht)]}function Yt(e,t,i){const r=e[0]-t[0],n=e[1]-t[1],o=e[0]-i[0],a=e[1]-i[1];return r*a-o*n==0&&r*o<=0&&n*a<=0}function Qt(e,t){let i=!1;for(let a=0,s=t.length;a<s;a++){const s=t[a];for(let t=0,a=s.length;t<a-1;t++){if(Yt(e,s[t],s[t+1]))return!1;(n=s[t])[1]>(r=e)[1]!=(o=s[t+1])[1]>r[1]&&r[0]<(o[0]-n[0])*(r[1]-n[1])/(o[1]-n[1])+n[0]&&(i=!i)}}var r,n,o;return i}function ei(e,t){for(let i=0;i<t.length;i++)if(Qt(e,t[i]))return!0;return!1}function ti(e,t,i,r){const n=r[0]-i[0],o=r[1]-i[1],a=(e[0]-i[0])*o-n*(e[1]-i[1]),s=(t[0]-i[0])*o-n*(t[1]-i[1]);return a>0&&s<0||a<0&&s>0}function ii(e,t,i){for(const c of i)for(let i=0;i<c.length-1;++i)if(0!=(s=[(a=c[i+1])[0]-(o=c[i])[0],a[1]-o[1]])[0]*(l=[(n=t)[0]-(r=e)[0],n[1]-r[1]])[1]-s[1]*l[0]&&ti(r,n,o,a)&&ti(o,a,r,n))return!0;var r,n,o,a,s,l;return!1}function ri(e,t){for(let i=0;i<e.length;++i)if(!Qt(e[i],t))return!1;for(let i=0;i<e.length-1;++i)if(ii(e[i],e[i+1],t))return!1;return!0}function ni(e,t){for(let i=0;i<t.length;i++)if(ri(e,t[i]))return!0;return!1}function oi(e,t,i){const r=[];for(let n=0;n<e.length;n++){const o=[];for(let r=0;r<e[n].length;r++){const a=Jt(e[n][r],i);Xt(t,a),o.push(a)}r.push(o)}return r}function ai(e,t,i){const r=[];for(let n=0;n<e.length;n++){const o=oi(e[n],t,i);r.push(o)}return r}function si(e,t,i,r){if(e[0]<i[0]||e[0]>i[2]){const t=.5*r;let n=e[0]-i[0]>t?-r:i[0]-e[0]>t?r:0;0===n&&(n=e[0]-i[2]>t?-r:i[2]-e[0]>t?r:0),e[0]+=n}Xt(t,e)}function li(e,t,i,r){const n=Math.pow(2,r.z)*Ht,o=[r.x*Ht,r.y*Ht],a=[];if(!e)return a;for(const r of e)for(const e of r){const r=[e.x+o[0],e.y+o[1]];si(r,t,i,n),a.push(r)}return a}function ci(e,t,i,r){const n=Math.pow(2,r.z)*Ht,o=[r.x*Ht,r.y*Ht],a=[];if(!e)return a;for(const i of e){const e=[];for(const r of i){const i=[r.x+o[0],r.y+o[1]];Xt(t,i),e.push(i)}a.push(e)}if(t[2]-t[0]<=n/2){(s=t)[0]=s[1]=1/0,s[2]=s[3]=-1/0;for(const e of a)for(const r of e)si(r,t,i,n)}var s;return a}class Within{constructor(e,t){this.type=yt,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Rt(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;e<t.features.length;++e){const i=t.features[e].geometry.type;if("Polygon"===i||"MultiPolygon"===i)return new Within(t,t.features[e].geometry)}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Within(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new Within(t,t)}return t.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,t){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if(!n)return!1;if("Polygon"===t.type){const o=oi(t.coordinates,r,n),a=li(e.geometry(),i,r,n);if(!Kt(i,r))return!1;for(const e of a)if(!Qt(e,o))return!1}if("MultiPolygon"===t.type){const o=ai(t.coordinates,r,n),a=li(e.geometry(),i,r,n);if(!Kt(i,r))return!1;for(const e of a)if(!ei(e,o))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if(!n)return!1;if("Polygon"===t.type){const o=oi(t.coordinates,r,n),a=ci(e.geometry(),i,r,n);if(!Kt(i,r))return!1;for(const e of a)if(!ri(e,o))return!1}if("MultiPolygon"===t.type){const o=ai(t.coordinates,r,n),a=ci(e.geometry(),i,r,n);if(!Kt(i,r))return!1;for(const e of a)if(!ni(e,o))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}var ui=Within;function hi(e){if(e instanceof Wt){if("get"===e.name&&1===e.args.length)return!1;if("feature-state"===e.name)return!1;if("has"===e.name&&1===e.args.length)return!1;if("properties"===e.name||"geometry-type"===e.name||"id"===e.name)return!1;if(/^filter-/.test(e.name))return!1}if(e instanceof ui)return!1;let t=!0;return e.eachChild((e=>{t&&!hi(e)&&(t=!1)})),t}function pi(e){if(e instanceof Wt&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild((e=>{t&&!pi(e)&&(t=!1)})),t}function di(e,t){if(e instanceof Wt&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild((e=>{i&&!di(e,t)&&(i=!1)})),i}class Var{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t}static parse(e,t){if(2!==e.length||"string"!=typeof e[1])return t.error("'var' expression requires exactly one string literal argument.");const i=e[1];return t.scope.has(i)?new Var(i,t.scope.get(i)):t.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var fi=Var;class ParsingContext{constructor(e,t=[],i,r=new ft,n=[]){this.registry=e,this.path=t,this.key=t.map((e=>`[${e}]`)).join(""),this.scope=r,this.errors=n,this.expectedType=i}parse(e,t,i,r,n={}){return t?this.concat(t,i,r)._parse(e,n):this._parse(e,n)}_parse(e,t){function i(e,t,i){return"assert"===i?new Nt(t,[e]):"coerce"===i?new Zt(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r=e[0];if("string"!=typeof r)return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const n=this.registry[r];if(n){let r=n.parse(e,this);if(!r)return null;if(this.expectedType){const e=this.expectedType,n=r.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==n.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==n.kind&&"string"!==n.kind){if(this.checkSubtype(e,n))return null}else r=i(r,e,t.typeAnnotation||"coerce");else r=i(r,e,t.typeAnnotation||"assert")}if(!(r instanceof Vt)&&"resolvedImage"!==r.type.kind&&_i(r)){const e=new $t;try{r=new Vt(r.type,r.evaluate(e))}catch(e){return this.error(e.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,t,i){const r="number"==typeof e?this.path.concat(e):this.path,n=i?this.scope.concat(i):this.scope;return new ParsingContext(this.registry,r,t||null,n,this.errors)}error(e,...t){const i=`${this.key}${t.map((e=>`[${e}]`)).join("")}`;this.errors.push(new dt(i,e))}checkSubtype(e,t){const i=Mt(e,t);return i&&this.error(i),i}}var mi=ParsingContext;function _i(e){if(e instanceof fi)return _i(e.boundExpression);if(e instanceof Wt&&"error"===e.name)return!1;if(e instanceof CollatorExpression)return!1;if(e instanceof ui)return!1;const t=e instanceof Zt||e instanceof Nt;let i=!0;return e.eachChild((e=>{i=t?i&&_i(e):i&&e instanceof Vt})),!!i&&hi(e)&&di(e,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function gi(e,t){const i=e.length-1;let r,n,o=0,a=i,s=0;for(;o<=a;)if(s=Math.floor((o+a)/2),r=e[s],n=e[s+1],r<=t){if(s===i||t<n)return s;o=s+1}else{if(!(r>t))throw new Ut("Input is not a number.");a=s-1}return 0}class Step{constructor(e,t,i){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[e,t]of i)this.labels.push(e),this.outputs.push(t)}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const i=t.parse(e[1],1,_t);if(!i)return null;const r=[];let n=null;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);for(let i=1;i<e.length;i+=2){const o=1===i?-1/0:e[i],a=e[i+1],s=i,l=i+1;if("number"!=typeof o)return t.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',s);if(r.length&&r[r.length-1][0]>=o)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',s);const c=t.parse(a,l,n);if(!c)return null;n=n||c.type,r.push([o,c])}return new Step(n,i,r)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;return r>=t[n-1]?i[n-1].evaluate(e):i[gi(t,r)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}serialize(){const e=["step",this.input.serialize()];for(let t=0;t<this.labels.length;t++)t>0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}var yi=Step;function xi(e,t,i){return e*(1-i)+t*i}function vi(e,t,i){return e.map(((e,r)=>xi(e,t[r],i)))}var bi=Object.freeze({__proto__:null,number:xi,color:function(e,t,i){return new Lt(xi(e.r,t.r,i),xi(e.g,t.g,i),xi(e.b,t.b,i),xi(e.a,t.a,i))},array:vi});const wi=.95047,Ti=1.08883,Ei=4/29,Si=6/29,Ai=3*Si*Si,Ci=Math.PI/180,Ii=180/Math.PI;function Mi(e){return e>.008856451679035631?Math.pow(e,1/3):e/Ai+Ei}function Pi(e){return e>Si?e*e*e:Ai*(e-Ei)}function Di(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function zi(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function ki(e){const t=zi(e.r),i=zi(e.g),r=zi(e.b),n=Mi((.4124564*t+.3575761*i+.1804375*r)/wi),o=Mi((.2126729*t+.7151522*i+.072175*r)/1);return{l:116*o-16,a:500*(n-o),b:200*(o-Mi((.0193339*t+.119192*i+.9503041*r)/Ti)),alpha:e.a}}function Li(e){let t=(e.l+16)/116,i=isNaN(e.a)?t:t+e.a/500,r=isNaN(e.b)?t:t-e.b/200;return t=1*Pi(t),i=wi*Pi(i),r=Ti*Pi(r),new Lt(Di(3.2404542*i-1.5371385*t-.4985314*r),Di(-.969266*i+1.8760108*t+.041556*r),Di(.0556434*i-.2040259*t+1.0572252*r),e.alpha)}function Bi(e,t,i){const r=t-e;return e+i*(r>180||r<-180?r-360*Math.round(r/360):r)}const Ri={forward:ki,reverse:Li,interpolate:function(e,t,i){return{l:xi(e.l,t.l,i),a:xi(e.a,t.a,i),b:xi(e.b,t.b,i),alpha:xi(e.alpha,t.alpha,i)}}},Fi={forward:function(e){const{l:t,a:i,b:r}=ki(e),n=Math.atan2(r,i)*Ii;return{h:n<0?n+360:n,c:Math.sqrt(i*i+r*r),l:t,alpha:e.a}},reverse:function(e){const t=e.h*Ci,i=e.c;return Li({l:e.l,a:Math.cos(t)*i,b:Math.sin(t)*i,alpha:e.alpha})},interpolate:function(e,t,i){return{h:Bi(e.h,t.h,i),c:xi(e.c,t.c,i),l:xi(e.l,t.l,i),alpha:xi(e.alpha,t.alpha,i)}}};var Oi=Object.freeze({__proto__:null,lab:Ri,hcl:Fi});class Interpolate{constructor(e,t,i,r,n){this.type=e,this.operator=t,this.interpolation=i,this.input=r,this.labels=[],this.outputs=[];for(const[e,t]of n)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,i,r,n){let o=0;if("exponential"===e.name)o=Vi(i,e.base,r,n);else if("linear"===e.name)o=Vi(i,1,r,n);else if("cubic-bezier"===e.name){const a=e.controlPoints;o=new t(a[0],a[1],a[2],a[3]).solve(Vi(i,1,r,n))}return o}static parse(e,t){let[i,r,n,...o]=e;if(!Array.isArray(r)||0===r.length)return t.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const e=r[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:e}}else{if("cubic-bezier"!==r[0])return t.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const e=r.slice(1);if(4!==e.length||e.some((e=>"number"!=typeof e||e<0||e>1)))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(n=t.parse(n,2,_t),!n)return null;const a=[];let s=null;"interpolate-hcl"===i||"interpolate-lab"===i?s=xt:t.expectedType&&"value"!==t.expectedType.kind&&(s=t.expectedType);for(let e=0;e<o.length;e+=2){const i=o[e],r=o[e+1],n=e+3,l=e+4;if("number"!=typeof i)return t.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',n);if(a.length&&a[a.length-1][0]>=i)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',n);const c=t.parse(r,l,s);if(!c)return null;s=s||c.type,a.push([i,c])}return"number"===s.kind||"color"===s.kind||"array"===s.kind&&"number"===s.itemType.kind&&"number"==typeof s.N?new Interpolate(s,i,r,n,a):t.error(`Type ${Ct(s)} is not interpolatable.`)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;if(r>=t[n-1])return i[n-1].evaluate(e);const o=gi(t,r),a=Interpolate.interpolationFactor(this.interpolation,r,t[o],t[o+1]),s=i[o].evaluate(e),l=i[o+1].evaluate(e);return"interpolate"===this.operator?bi[this.type.kind.toLowerCase()](s,l,a):"interpolate-hcl"===this.operator?Fi.reverse(Fi.interpolate(Fi.forward(s),Fi.forward(l),a)):Ri.reverse(Ri.interpolate(Ri.forward(s),Ri.forward(l),a))}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}serialize(){let e;e="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 t=[this.operator,e,this.input.serialize()];for(let e=0;e<this.labels.length;e++)t.push(this.labels[e],this.outputs[e].serialize());return t}}function Vi(e,t,i,r){const n=r-i,o=e-i;return 0===n?0:1===t?o/n:(Math.pow(t,o)-1)/(Math.pow(t,n)-1)}var Ui=Interpolate;class Coalesce{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expectected at least one argument.");let i=null;const r=t.expectedType;r&&"value"!==r.kind&&(i=r);const n=[];for(const r of e.slice(1)){const e=t.parse(r,1+n.length,i,void 0,{typeAnnotation:"omit"});if(!e)return null;i=i||e.type,n.push(e)}const o=r&&n.some((e=>Mt(r,e.type)));return new Coalesce(o?bt:i,n)}evaluate(e){let t,i=null,r=0;for(const n of this.args){if(r++,i=n.evaluate(e),i&&i instanceof ResolvedImage&&!i.available&&(t||(t=i),i=null,r===this.args.length))return t;if(null!==i)break}return i}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){const e=["coalesce"];return this.eachChild((t=>{e.push(t.serialize())})),e}}var ji=Coalesce;class Let{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result)}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const i=[];for(let r=1;r<e.length-1;r+=2){const n=e[r];if("string"!=typeof n)return t.error(`Expected string, but found ${typeof n} instead.`,r);if(/[^a-zA-Z0-9_]/.test(n))return t.error("Variable names must contain only alphanumeric characters or '_'.",r);const o=t.parse(e[r+1],r+1);if(!o)return null;i.push([n,o])}const r=t.parse(e[e.length-1],e.length-1,t.expectedType,i);return r?new Let(i,r):null}outputDefined(){return this.result.outputDefined()}serialize(){const e=["let"];for(const[t,i]of this.bindings)e.push(t,i.serialize());return e.push(this.result.serialize()),e}}var Ni=Let;class At{constructor(e,t,i){this.type=e,this.index=t,this.input=i}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,_t),r=t.parse(e[2],2,St(t.expectedType||bt));return i&&r?new At(r.type.itemType,i,r):null}evaluate(e){const t=this.index.evaluate(e),i=this.input.evaluate(e);if(t<0)throw new Ut(`Array index out of bounds: ${t} < 0.`);if(t>=i.length)throw new Ut(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t!==Math.floor(t))throw new Ut(`Array index must be an integer, but found ${t} instead.`);return i[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var Gi=At;class In{constructor(e,t){this.type=yt,this.needle=e,this.haystack=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,bt),r=t.parse(e[2],2,bt);return i&&r?Pt(i.type,[yt,gt,_t,mt,bt])?new In(i,r):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ct(i.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(null==i)return!1;if(!Dt(t,["boolean","string","number","null"]))throw new Ut(`Expected first argument to be of type boolean, string, number or null, but found ${Ct(Ft(t))} instead.`);if(!Dt(i,["string","array"]))throw new Ut(`Expected second argument to be of type array or string, but found ${Ct(Ft(i))} instead.`);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var Zi=In;class IndexOf{constructor(e,t,i){this.type=_t,this.needle=e,this.haystack=t,this.fromIndex=i}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,bt),r=t.parse(e[2],2,bt);if(!i||!r)return null;if(!Pt(i.type,[yt,gt,_t,mt,bt]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ct(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,_t);return n?new IndexOf(i,r,n):null}return new IndexOf(i,r)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!Dt(t,["boolean","string","number","null"]))throw new Ut(`Expected first argument to be of type boolean, string, number or null, but found ${Ct(Ft(t))} instead.`);if(!Dt(i,["string","array"]))throw new Ut(`Expected second argument to be of type array or string, but found ${Ct(Ft(i))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(e);return i.indexOf(t,r)}return i.indexOf(t)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var qi=IndexOf;class Match{constructor(e,t,i,r,n,o){this.inputType=e,this.type=t,this.input=i,this.cases=r,this.outputs=n,this.otherwise=o}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let i,r;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);const n={},o=[];for(let a=2;a<e.length-1;a+=2){let s=e[a];const l=e[a+1];Array.isArray(s)||(s=[s]);const c=t.concat(a);if(0===s.length)return c.error("Expected at least one branch label.");for(const e of s){if("number"!=typeof e&&"string"!=typeof e)return c.error("Branch labels must be numbers or strings.");if("number"==typeof e&&Math.abs(e)>Number.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,Ft(e)))return null}else i=Ft(e);if(void 0!==n[String(e)])return c.error("Branch labels must be unique.");n[String(e)]=o.length}const u=t.parse(l,a,r);if(!u)return null;r=r||u.type,o.push(u)}const a=t.parse(e[1],1,bt);if(!a)return null;const s=t.parse(e[e.length-1],e.length-1,r);return s?"value"!==a.type.kind&&t.concat(1).checkSubtype(i,a.type)?null:new Match(i,r,a,n,o,s):null}evaluate(e){const t=this.input.evaluate(e);return(Ft(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],t=Object.keys(this.cases).sort(),i=[],r={};for(const e of t){const t=r[this.cases[e]];void 0===t?(r[this.cases[e]]=i.length,i.push([this.cases[e],[e]])):i[t][1].push(e)}const n=e=>"number"===this.inputType.kind?Number(e):e;for(const[t,r]of i)e.push(1===r.length?n(r[0]):r.map(n)),e.push(this.outputs[t].serialize());return e.push(this.otherwise.serialize()),e}}var $i=Match;class Case{constructor(e,t,i){this.type=e,this.branches=t,this.otherwise=i}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let i;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);const r=[];for(let n=1;n<e.length-1;n+=2){const o=t.parse(e[n],n,yt);if(!o)return null;const a=t.parse(e[n+1],n+1,i);if(!a)return null;r.push([o,a]),i=i||a.type}const n=t.parse(e[e.length-1],e.length-1,i);return n?new Case(i,r,n):null}evaluate(e){for(const[t,i]of this.branches)if(t.evaluate(e))return i.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[t,i]of this.branches)e(t),e(i);e(this.otherwise)}outputDefined(){return this.branches.every((([e,t])=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild((t=>{e.push(t.serialize())})),e}}var Wi=Case;class Slice{constructor(e,t,i,r){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=r}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,bt),r=t.parse(e[2],2,_t);if(!i||!r)return null;if(!Pt(i.type,[St(bt),gt,bt]))return t.error(`Expected first argument to be of type array or string, but found ${Ct(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,_t);return n?new Slice(i.type,i,r,n):null}return new Slice(i.type,i,r)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);if(!Dt(t,["string","array"]))throw new Ut(`Expected first argument to be of type array or string, but found ${Ct(Ft(t))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(e);return t.slice(i,r)}return t.slice(i)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var Hi=Slice;function Xi(e,t){return"=="===e||"!="===e?"boolean"===t.kind||"string"===t.kind||"number"===t.kind||"null"===t.kind||"value"===t.kind:"string"===t.kind||"number"===t.kind||"value"===t.kind}function Ki(e,t,i,r){return 0===r.compare(t,i)}function Ji(e,t,i){const r="=="!==e&&"!="!==e;return class Comparison{constructor(e,t,i){this.type=yt,this.lhs=e,this.rhs=t,this.collator=i,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind}static parse(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");const i=e[0];let n=t.parse(e[1],1,bt);if(!n)return null;if(!Xi(i,n.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${Ct(n.type)}'.`);let o=t.parse(e[2],2,bt);if(!o)return null;if(!Xi(i,o.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${Ct(o.type)}'.`);if(n.type.kind!==o.type.kind&&"value"!==n.type.kind&&"value"!==o.type.kind)return t.error(`Cannot compare types '${Ct(n.type)}' and '${Ct(o.type)}'.`);r&&("value"===n.type.kind&&"value"!==o.type.kind?n=new Nt(o.type,[n]):"value"!==n.type.kind&&"value"===o.type.kind&&(o=new Nt(n.type,[o])));let a=null;if(4===e.length){if("string"!==n.type.kind&&"string"!==o.type.kind&&"value"!==n.type.kind&&"value"!==o.type.kind)return t.error("Cannot use collator to compare non-string types.");if(a=t.parse(e[3],3,wt),!a)return null}return new Comparison(n,o,a)}evaluate(n){const o=this.lhs.evaluate(n),a=this.rhs.evaluate(n);if(r&&this.hasUntypedArgument){const t=Ft(o),i=Ft(a);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new Ut(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const e=Ft(o),i=Ft(a);if("string"!==e.kind||"string"!==i.kind)return t(n,o,a)}return this.collator?i(n,o,a,this.collator.evaluate(n)):t(n,o,a)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}serialize(){const t=[e];return this.eachChild((e=>{t.push(e.serialize())})),t}}}const Yi=Ji("==",(function(e,t,i){return t===i}),Ki),Qi=Ji("!=",(function(e,t,i){return t!==i}),(function(e,t,i,r){return!Ki(0,t,i,r)})),er=Ji("<",(function(e,t,i){return t<i}),(function(e,t,i,r){return r.compare(t,i)<0})),tr=Ji(">",(function(e,t,i){return t>i}),(function(e,t,i,r){return r.compare(t,i)>0})),ir=Ji("<=",(function(e,t,i){return t<=i}),(function(e,t,i,r){return r.compare(t,i)<=0})),rr=Ji(">=",(function(e,t,i){return t>=i}),(function(e,t,i,r){return r.compare(t,i)>=0}));class NumberFormat{constructor(e,t,i,r,n,o){this.type=gt,this.number=e,this.locale=t,this.currency=i,this.unit=r,this.minFractionDigits=n,this.maxFractionDigits=o}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,_t);if(!i)return null;const r=e[2];if("object"!=typeof r||Array.isArray(r))return t.error("NumberFormat options argument must be an object.");let n=null;if(r.locale&&(n=t.parse(r.locale,1,gt),!n))return null;let o=null;if(r.currency&&(o=t.parse(r.currency,1,gt),!o))return null;let a=null;if(r.unit&&(a=t.parse(r.unit,1,gt),!a))return null;let s=null;if(r["min-fraction-digits"]&&(s=t.parse(r["min-fraction-digits"],1,_t),!s))return null;let l=null;return r["max-fraction-digits"]&&(l=t.parse(r["max-fraction-digits"],1,_t),!l)?null:new NumberFormat(i,n,o,a,s,l)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class Length{constructor(e){this.type=_t,this.input=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=t.parse(e[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?t.error(`Expected argument of type string or array, but found ${Ct(i.type)} instead.`):new Length(i):null}evaluate(e){const t=this.input.evaluate(e);if("string"==typeof t)return t.length;if(Array.isArray(t))return t.length;throw new Ut(`Expected value to be of type string or array, but found ${Ct(Ft(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild((t=>{e.push(t.serialize())})),e}}const nr={"==":Yi,"!=":Qi,">":tr,"<":er,">=":rr,"<=":ir,array:Nt,at:Gi,boolean:Nt,case:Wi,coalesce:ji,collator:CollatorExpression,format:FormatExpression,image:ImageExpression,in:Zi,"index-of":qi,interpolate:Ui,"interpolate-hcl":Ui,"interpolate-lab":Ui,length:Length,let:Ni,literal:Vt,match:$i,number:Nt,"number-format":NumberFormat,object:Nt,slice:Hi,step:yi,string:Nt,"to-boolean":Zt,"to-color":Zt,"to-number":Zt,"to-string":Zt,var:fi,within:ui};function or(e,[t,i,r,n]){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);const o=n?n.evaluate(e):1,a=Bt(t,i,r,o);if(a)throw new Ut(a);return new Lt(t/255*o,i/255*o,r/255*o,o)}function ar(e,t){return e in t}function sr(e,t){const i=t[e];return void 0===i?null:i}function lr(e){return{type:e}}Wt.register(nr,{error:[{kind:"error"},[gt],(e,[t])=>{throw new Ut(t.evaluate(e))}],typeof:[gt,[bt],(e,[t])=>Ct(Ft(t.evaluate(e)))],"to-rgba":[St(_t,4),[xt],(e,[t])=>t.evaluate(e).toArray()],rgb:[xt,[_t,_t,_t],or],rgba:[xt,[_t,_t,_t,_t],or],has:{type:yt,overloads:[[[gt],(e,[t])=>ar(t.evaluate(e),e.properties())],[[gt,vt],(e,[t,i])=>ar(t.evaluate(e),i.evaluate(e))]]},get:{type:bt,overloads:[[[gt],(e,[t])=>sr(t.evaluate(e),e.properties())],[[gt,vt],(e,[t,i])=>sr(t.evaluate(e),i.evaluate(e))]]},"feature-state":[bt,[gt],(e,[t])=>sr(t.evaluate(e),e.featureState||{})],properties:[vt,[],e=>e.properties()],"geometry-type":[gt,[],e=>e.geometryType()],id:[bt,[],e=>e.id()],zoom:[_t,[],e=>e.globals.zoom],pitch:[_t,[],e=>e.globals.pitch||0],"distance-from-center":[_t,[],e=>e.distanceFromCenter()],"heatmap-density":[_t,[],e=>e.globals.heatmapDensity||0],"line-progress":[_t,[],e=>e.globals.lineProgress||0],"sky-radial-progress":[_t,[],e=>e.globals.skyRadialProgress||0],accumulated:[bt,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[_t,lr(_t),(e,t)=>{let i=0;for(const r of t)i+=r.evaluate(e);return i}],"*":[_t,lr(_t),(e,t)=>{let i=1;for(const r of t)i*=r.evaluate(e);return i}],"-":{type:_t,overloads:[[[_t,_t],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[_t],(e,[t])=>-t.evaluate(e)]]},"/":[_t,[_t,_t],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[_t,[_t,_t],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[_t,[],()=>Math.LN2],pi:[_t,[],()=>Math.PI],e:[_t,[],()=>Math.E],"^":[_t,[_t,_t],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[_t,[_t],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[_t,[_t],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[_t,[_t],(e,[t])=>Math.log(t.evaluate(e))],log2:[_t,[_t],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[_t,[_t],(e,[t])=>Math.sin(t.evaluate(e))],cos:[_t,[_t],(e,[t])=>Math.cos(t.evaluate(e))],tan:[_t,[_t],(e,[t])=>Math.tan(t.evaluate(e))],asin:[_t,[_t],(e,[t])=>Math.asin(t.evaluate(e))],acos:[_t,[_t],(e,[t])=>Math.acos(t.evaluate(e))],atan:[_t,[_t],(e,[t])=>Math.atan(t.evaluate(e))],min:[_t,lr(_t),(e,t)=>Math.min(...t.map((t=>t.evaluate(e))))],max:[_t,lr(_t),(e,t)=>Math.max(...t.map((t=>t.evaluate(e))))],abs:[_t,[_t],(e,[t])=>Math.abs(t.evaluate(e))],round:[_t,[_t],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[_t,[_t],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[_t,[_t],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[yt,[gt,bt],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[yt,[bt],(e,[t])=>e.id()===t.value],"filter-type-==":[yt,[gt],(e,[t])=>e.geometryType()===t.value],"filter-<":[yt,[gt,bt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r<n}],"filter-id-<":[yt,[bt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i<r}],"filter->":[yt,[gt,bt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>n}],"filter-id->":[yt,[bt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>r}],"filter-<=":[yt,[gt,bt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r<=n}],"filter-id-<=":[yt,[bt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i<=r}],"filter->=":[yt,[gt,bt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>=n}],"filter-id->=":[yt,[bt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>=r}],"filter-has":[yt,[bt],(e,[t])=>t.value in e.properties()],"filter-has-id":[yt,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[yt,[St(gt)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[yt,[St(bt)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[yt,[gt,St(bt)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[yt,[gt,St(bt)],(e,[t,i])=>function(e,t,i,r){for(;i<=r;){const n=i+r>>1;if(t[n]===e)return!0;t[n]>e?r=n-1:i=n+1}return!1}(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:yt,overloads:[[[yt,yt],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[lr(yt),(e,t)=>{for(const i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:yt,overloads:[[[yt,yt],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[lr(yt),(e,t)=>{for(const i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[yt,[yt],(e,[t])=>!t.evaluate(e)],"is-supported-script":[yt,[gt],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[gt,[gt],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[gt,[gt],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[gt,lr(bt),(e,t)=>t.map((t=>Ot(t.evaluate(e)))).join("")],"resolved-locale":[gt,[wt],(e,[t])=>t.evaluate(e).resolvedLocale()]});var cr=nr;function ur(e){return{result:"success",value:e}}function hr(e){return{result:"error",value:e}}function pr(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function dr(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function fr(e){return!!e.expression&&e.expression.interpolated}function mr(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function _r(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function gr(e){return e}function yr(e,t){const i="color"===t.type,r=e.stops&&"object"==typeof e.stops[0][0],n=r||!(r||void 0!==e.property),o=e.type||(fr(t)?"exponential":"interval");if(i&&((e=ut({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],Lt.parse(e[1])]))),e.default=Lt.parse(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==e.colorSpace&&!Oi[e.colorSpace])throw new Error(`Unknown color space: ${e.colorSpace}`);let a,s,l;if("exponential"===o)a=wr;else if("interval"===o)a=br;else if("categorical"===o){a=vr,s=Object.create(null);for(const t of e.stops)s[t[0]]=t[1];l=typeof e.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);a=Tr}if(r){const i={},r=[];for(let t=0;t<e.stops.length;t++){const n=e.stops[t],o=n[0].zoom;void 0===i[o]&&(i[o]={zoom:o,type:e.type,property:e.property,default:e.default,stops:[]},r.push(o)),i[o].stops.push([n[0].value,n[1]])}const n=[];for(const e of r)n.push([i[e].zoom,yr(i[e],t)]);const o={name:"linear"};return{kind:"composite",interpolationType:o,interpolationFactor:Ui.interpolationFactor.bind(void 0,o),zoomStops:n.map((e=>e[0])),evaluate:({zoom:i},r)=>wr({stops:n,base:e.base},t,i).evaluate(i,r)}}if(n){const i="exponential"===o?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:Ui.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map((e=>e[0])),evaluate:({zoom:i})=>a(e,t,i,s,l)}}return{kind:"source",evaluate(i,r){const n=r&&r.properties?r.properties[e.property]:void 0;return void 0===n?xr(e.default,t.default):a(e,t,n,s,l)}}}function xr(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function vr(e,t,i,r,n){return xr(typeof i===n?r[i]:void 0,e.default,t.default)}function br(e,t,i){if("number"!==mr(i))return xr(e.default,t.default);const r=e.stops.length;if(1===r)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[r-1][0])return e.stops[r-1][1];const n=gi(e.stops.map((e=>e[0])),i);return e.stops[n][1]}function wr(e,t,i){const r=void 0!==e.base?e.base:1;if("number"!==mr(i))return xr(e.default,t.default);const n=e.stops.length;if(1===n)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[n-1][0])return e.stops[n-1][1];const o=gi(e.stops.map((e=>e[0])),i),a=function(e,t,i,r){const n=r-i,o=e-i;return 0===n?0:1===t?o/n:(Math.pow(t,o)-1)/(Math.pow(t,n)-1)}(i,r,e.stops[o][0],e.stops[o+1][0]),s=e.stops[o][1],l=e.stops[o+1][1];let c=bi[t.type]||gr;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=Oi[e.colorSpace];c=(e,i)=>t.reverse(t.interpolate(t.forward(e),t.forward(i),a))}return"function"==typeof s.evaluate?{evaluate(...e){const t=s.evaluate.apply(void 0,e),i=l.evaluate.apply(void 0,e);if(void 0!==t&&void 0!==i)return c(t,i,a)}}:c(s,l,a)}function Tr(e,t,i){return"color"===t.type?i=Lt.parse(i):"formatted"===t.type?i=Formatted.fromString(i.toString()):"resolvedImage"===t.type?i=ResolvedImage.fromString(i.toString()):mr(i)===t.type||"enum"===t.type&&t.values[i]||(i=void 0),xr(i,e.default,t.default)}class StyleExpression{constructor(e,t){this.expression=e,this._warningHistory={},this._evaluator=new $t,this._defaultValue=t?function(e){return"color"===e.type&&(_r(e.default)||Array.isArray(e.default))?new Lt(0,0,0,0):"color"===e.type?Lt.parse(e.default)||null:void 0===e.default?null:e.default}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null}evaluateWithoutErrorHandling(e,t,i,r,n,o,a,s){return this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=r||null,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o,this._evaluator.featureTileCoord=a||null,this._evaluator.featureDistanceData=s||null,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,r,n,o,a,s){this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r||null,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o||null,this._evaluator.featureTileCoord=a||null,this._evaluator.featureDistanceData=s||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new Ut(`Expected value to be one of ${Object.keys(this._enumValues).map((e=>JSON.stringify(e))).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(e.message)),this._defaultValue}}}function Er(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in cr}function Sr(e,t){const i=new mi(cr,[],t?function(e){const t={color:xt,string:gt,number:_t,enum:gt,boolean:yt,formatted:Tt,resolvedImage:Et};return"array"===e.type?St(t[e.value]||bt,e.length):t[e.type]}(t):void 0),r=i.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return r?ur(new StyleExpression(r,t)):hr(i.errors)}class ZoomConstantExpression{constructor(e,t){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!pi(t.expression)}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o){return this._styleExpression.evaluate(e,t,i,r,n,o)}}class ZoomDependentExpression{constructor(e,t,i,r){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!pi(t.expression),this.interpolationType=r}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o){return this._styleExpression.evaluate(e,t,i,r,n,o)}interpolationFactor(e,t,i){return this.interpolationType?Ui.interpolationFactor(this.interpolationType,e,t,i):0}}function Ar(e,t){if("error"===(e=Sr(e,t)).result)return e;const i=e.value.expression,r=hi(i);if(!r&&!pr(t))return hr([new dt("","data expressions not supported")]);const n=di(i,["zoom","pitch","distance-from-center"]);if(!n&&!dr(t))return hr([new dt("","zoom expressions not supported")]);const o=Cr(i);return o||n?o instanceof dt?hr([o]):o instanceof Ui&&!fr(t)?hr([new dt("",'"interpolate" expressions cannot be used with this property')]):ur(o?new ZoomDependentExpression(r?"camera":"composite",e.value,o.labels,o instanceof Ui?o.interpolation:void 0):new ZoomConstantExpression(r?"constant":"source",e.value)):hr([new dt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class StylePropertyFunction{constructor(e,t){this._parameters=e,this._specification=t,ut(this,yr(this._parameters,this._specification))}static deserialize(e){return new StylePropertyFunction(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Cr(e){let t=null;if(e instanceof Ni)t=Cr(e.result);else if(e instanceof ji){for(const i of e.args)if(t=Cr(i),t)break}else(e instanceof yi||e instanceof Ui)&&e.input instanceof Wt&&"zoom"===e.input.name&&(t=e);return t instanceof dt||e.eachChild((e=>{const i=Cr(e);i instanceof dt?t=i:!t&&i?t=new dt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&i&&t!==i&&(t=new dt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),t}class ValidationError{constructor(e,t,i,r){this.message=(e?`${e}: `:"")+i,r&&(this.identifier=r),null!=t&&t.__line__&&(this.line=t.__line__)}}function Ir(e){const t=e.key,i=e.value,r=e.valueSpec||{},n=e.objectElementValidators||{},o=e.style,a=e.styleSpec;let s=[];const l=mr(i);if("object"!==l)return[new ValidationError(t,i,`object expected, ${l} found`)];for(const e in i){const l=e.split(".")[0],c=r[l]||r["*"];let u;n[l]?u=n[l]:r[l]?u=ln:n["*"]?u=n["*"]:r["*"]&&(u=ln),u?s=s.concat(u({key:(t?`${t}.`:t)+e,value:i[e],valueSpec:c,style:o,styleSpec:a,object:i,objectKey:e},i)):s.push(new ValidationError(t,i[e],`unknown property "${e}"`))}for(const e in r)n[e]||r[e].required&&void 0===r[e].default&&void 0===i[e]&&s.push(new ValidationError(t,i,`missing required property "${e}"`));return s}function Mr(e){const t=e.value,i=e.valueSpec,r=e.style,n=e.styleSpec,o=e.key,a=e.arrayElementValidator||ln;if("array"!==mr(t))return[new ValidationError(o,t,`array expected, ${mr(t)} found`)];if(i.length&&t.length!==i.length)return[new ValidationError(o,t,`array length ${i.length} expected, length ${t.length} found`)];if(i["min-length"]&&t.length<i["min-length"])return[new ValidationError(o,t,`array length at least ${i["min-length"]} expected, length ${t.length} found`)];let s={type:i.value,values:i.values,minimum:i.minimum,maximum:i.maximum,function:void 0};n.$version<7&&(s.function=i.function),"object"===mr(i.value)&&(s=i.value);let l=[];for(let e=0;e<t.length;e++)l=l.concat(a({array:t,arrayIndex:e,value:t[e],valueSpec:s,style:r,styleSpec:n,key:`${o}[${e}]`}));return l}function Pr(e){const t=e.key,i=e.value,r=e.valueSpec;let n=mr(i);if("number"===n&&i!=i&&(n="NaN"),"number"!==n)return[new ValidationError(t,i,`number expected, ${n} found`)];if("minimum"in r){let n=r.minimum;if("array"===mr(r.minimum)&&(n=r.minimum[e.arrayIndex]),i<n)return[new ValidationError(t,i,`${i} is less than the minimum value ${n}`)]}if("maximum"in r){let n=r.maximum;if("array"===mr(r.maximum)&&(n=r.maximum[e.arrayIndex]),i>n)return[new ValidationError(t,i,`${i} is greater than the maximum value ${n}`)]}return[]}function Dr(e){const t=e.valueSpec,i=ht(e.value.type);let r,n,o,a={};const s="categorical"!==i&&void 0===e.value.property,l=!s,c="array"===mr(e.value.stops)&&"array"===mr(e.value.stops[0])&&"object"===mr(e.value.stops[0][0]),u=Ir({key:e.key,value:e.value,valueSpec:e.styleSpec.function,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===i)return[new ValidationError(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const r=e.value;return t=t.concat(Mr({key:e.key,value:r,valueSpec:e.valueSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:h})),"array"===mr(r)&&0===r.length&&t.push(new ValidationError(e.key,r,"array must have at least one stop")),t},default:function(e){return ln({key:e.key,value:e.value,valueSpec:t,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===i&&s&&u.push(new ValidationError(e.key,e.value,'missing required property "property"')),"identity"===i||e.value.stops||u.push(new ValidationError(e.key,e.value,'missing required property "stops"')),"exponential"===i&&e.valueSpec.expression&&!fr(e.valueSpec)&&u.push(new ValidationError(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!pr(e.valueSpec)?u.push(new ValidationError(e.key,e.value,"property functions not supported")):s&&!dr(e.valueSpec)&&u.push(new ValidationError(e.key,e.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==e.value.property||u.push(new ValidationError(e.key,e.value,'"property" property is required')),u;function h(e){let i=[];const r=e.value,s=e.key;if("array"!==mr(r))return[new ValidationError(s,r,`array expected, ${mr(r)} found`)];if(2!==r.length)return[new ValidationError(s,r,`array length 2 expected, length ${r.length} found`)];if(c){if("object"!==mr(r[0]))return[new ValidationError(s,r,`object expected, ${mr(r[0])} found`)];if(void 0===r[0].zoom)return[new ValidationError(s,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new ValidationError(s,r,"object stop key must have value")];const t=ht(r[0].zoom);if("number"!=typeof t)return[new ValidationError(s,r[0].zoom,"stop zoom values must be numbers")];if(o&&o>t)return[new ValidationError(s,r[0].zoom,"stop zoom values must appear in ascending order")];t!==o&&(o=t,n=void 0,a={}),i=i.concat(Ir({key:`${s}[0]`,value:r[0],valueSpec:{zoom:{}},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:Pr,value:p}}))}else i=i.concat(p({key:`${s}[0]`,value:r[0],valueSpec:{},style:e.style,styleSpec:e.styleSpec},r));return Er(pt(r[1]))?i.concat([new ValidationError(`${s}[1]`,r[1],"expressions are not allowed in function stops.")]):i.concat(ln({key:`${s}[1]`,value:r[1],valueSpec:t,style:e.style,styleSpec:e.styleSpec}))}function p(e,o){const s=mr(e.value),l=ht(e.value),c=null!==e.value?e.value:o;if(r){if(s!==r)return[new ValidationError(e.key,c,`${s} stop domain type must match previous stop domain type ${r}`)]}else r=s;if("number"!==s&&"string"!==s&&"boolean"!==s&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return[new ValidationError(e.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==s&&"categorical"!==i){let r=`number expected, ${s} found`;return pr(t)&&void 0===i&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new ValidationError(e.key,c,r)]}return"categorical"!==i||"number"!==s||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===s&&"number"==typeof l&&"number"==typeof n&&void 0!==n&&l<n?[new ValidationError(e.key,c,"stop domain values must appear in ascending order")]:(n=l,"categorical"===i&&l in a?[new ValidationError(e.key,c,"stop domain values must be unique")]:(a[l]=!0,[])):[new ValidationError(e.key,c,`integer expected, found ${String(l)}`)]}}function zr(e){const t=("property"===e.expressionContext?Ar:Sr)(pt(e.value),e.valueSpec);if("error"===t.result)return t.value.map((t=>new ValidationError(`${e.key}${t.key}`,e.value,t.message)));const i=t.value.expression||t.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!i.outputDefined())return[new ValidationError(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!pi(i))return[new ValidationError(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext)return kr(i,e);if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!di(i,["zoom","feature-state"]))return[new ValidationError(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!hi(i))return[new ValidationError(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function kr(e,t){const i=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(t.valueSpec&&t.valueSpec.expression)for(const e of t.valueSpec.expression.parameters)i.delete(e);if(0===i.size)return[];const r=[];return e instanceof Wt&&i.has(e.name)?[new ValidationError(t.key,t.value,`["${e.name}"] expression is not supported in a filter for a ${t.object.type} layer with id: ${t.object.id}`)]:(e.eachChild((e=>{r.push(...kr(e,t))})),r)}function Lr(e){const t=e.key,i=e.value,r=e.valueSpec,n=[];return Array.isArray(r.values)?-1===r.values.indexOf(ht(i))&&n.push(new ValidationError(t,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(ht(i))&&n.push(new ValidationError(t,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),n}function Br(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const t of e.slice(1))if(!Br(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}function Rr(e,t="fill"){if(null==e)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Br(e)||(e=Gr(e));const i=e;let r=!0;try{r=function(e){if(!Vr(e))return e;let t=pt(e);return Or(t),t=Fr(t),t}(i)}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(i,null,2)}\n `)}const n=ct[`filter_${t}`],o=Sr(r,n);let a=null;if("error"===o.result)throw new Error(o.value.map((e=>`${e.key}: ${e.message}`)).join(", "));a=(e,t,i)=>o.value.evaluate(e,t,{},i);let s=null,l=null;if(r!==i){const e=Sr(i,n);if("error"===e.result)throw new Error(e.value.map((e=>`${e.key}: ${e.message}`)).join(", "));s=(t,i,r,n,o)=>e.value.evaluate(t,i,{},r,void 0,void 0,n,o),l=!hi(e.value.expression)}return a=a,{filter:a,dynamicFilter:s||void 0,needGeometry:Nr(r),needFeature:!!l}}function Fr(e){if(!Array.isArray(e))return e;const t=function(e){if(Ur.has(e[0]))for(let t=1;t<e.length;t++)if(Vr(e[t]))return!0;return e}(e);return!0===t?t:t.map((e=>Fr(e)))}function Or(e){let t=!1;const i=[];if("case"===e[0]){for(let r=1;r<e.length-1;r+=2)t=t||Vr(e[r]),i.push(e[r+1]);i.push(e[e.length-1])}else if("match"===e[0]){t=t||Vr(e[1]);for(let t=2;t<e.length-1;t+=2)i.push(e[t+1]);i.push(e[e.length-1])}else if("step"===e[0]){t=t||Vr(e[1]);for(let t=1;t<e.length-1;t+=2)i.push(e[t+1])}t&&(e.length=0,e.push("any",...i));for(let t=1;t<e.length;t++)Or(e[t])}function Vr(e){if(!Array.isArray(e))return!1;if("pitch"===(t=e[0])||"distance-from-center"===t)return!0;var t;for(let t=1;t<e.length;t++)if(Vr(e[t]))return!0;return!1}const Ur=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function jr(e,t){return e<t?-1:e>t?1:0}function Nr(e){if(!Array.isArray(e))return!1;if("within"===e[0])return!0;for(let t=1;t<e.length;t++)if(Nr(e[t]))return!0;return!1}function Gr(e){if(!e)return!0;const t=e[0];return e.length<=1?"any"!==t:"=="===t?Zr(e[1],e[2],"=="):"!="===t?Wr(Zr(e[1],e[2],"==")):"<"===t||">"===t||"<="===t||">="===t?Zr(e[1],e[2],t):"any"===t?(i=e.slice(1),["any"].concat(i.map(Gr))):"all"===t?["all"].concat(e.slice(1).map(Gr)):"none"===t?["all"].concat(e.slice(1).map(Gr).map(Wr)):"in"===t?qr(e[1],e.slice(2)):"!in"===t?Wr(qr(e[1],e.slice(2))):"has"===t?$r(e[1]):"!has"===t?Wr($r(e[1])):"within"!==t||e;var i}function Zr(e,t,i){switch(e){case"$type":return[`filter-type-${i}`,t];case"$id":return[`filter-id-${i}`,t];default:return[`filter-${i}`,e,t]}}function qr(e,t){if(0===t.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some((e=>typeof e!=typeof t[0]))?["filter-in-large",e,["literal",t.sort(jr)]]:["filter-in-small",e,["literal",t]]}}function $r(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function Wr(e){return["!",e]}function Hr(e){return Br(pt(e.value))?zr(ut({},e,{expressionContext:"filter",valueSpec:e.styleSpec[`filter_${e.layerType||"fill"}`]})):Xr(e)}function Xr(e){const t=e.value,i=e.key;if("array"!==mr(t))return[new ValidationError(i,t,`array expected, ${mr(t)} found`)];const r=e.styleSpec;let n,o=[];if(t.length<1)return[new ValidationError(i,t,"filter array must have at least 1 element")];switch(o=o.concat(Lr({key:`${i}[0]`,value:t[0],valueSpec:r.filter_operator,style:e.style,styleSpec:e.styleSpec})),ht(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===ht(t[1])&&o.push(new ValidationError(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":3!==t.length&&o.push(new ValidationError(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(n=mr(t[1]),"string"!==n&&o.push(new ValidationError(`${i}[1]`,t[1],`string expected, ${n} found`)));for(let a=2;a<t.length;a++)n=mr(t[a]),"$type"===ht(t[1])?o=o.concat(Lr({key:`${i}[${a}]`,value:t[a],valueSpec:r.geometry_type,style:e.style,styleSpec:e.styleSpec})):"string"!==n&&"number"!==n&&"boolean"!==n&&o.push(new ValidationError(`${i}[${a}]`,t[a],`string, number, or boolean expected, ${n} found`));break;case"any":case"all":case"none":for(let r=1;r<t.length;r++)o=o.concat(Xr({key:`${i}[${r}]`,value:t[r],style:e.style,styleSpec:e.styleSpec}));break;case"has":case"!has":n=mr(t[1]),2!==t.length?o.push(new ValidationError(i,t,`filter array for "${t[0]}" operator must have 2 elements`)):"string"!==n&&o.push(new ValidationError(`${i}[1]`,t[1],`string expected, ${n} found`));break;case"within":n=mr(t[1]),2!==t.length?o.push(new ValidationError(i,t,`filter array for "${t[0]}" operator must have 2 elements`)):"object"!==n&&o.push(new ValidationError(`${i}[1]`,t[1],`object expected, ${n} found`))}return o}function Kr(e,t){const i=e.key,r=e.style,n=e.styleSpec,o=e.value,a=e.objectKey,s=n[`${t}_${e.layerType}`];if(!s)return[];const l=a.match(/^(.*)-transition$/);if("paint"===t&&l&&s[l[1]]&&s[l[1]].transition)return ln({key:i,value:o,valueSpec:n.transition,style:r,styleSpec:n});const c=e.valueSpec||s[a];if(!c)return[new ValidationError(i,o,`unknown property "${a}"`)];let u;if("string"===mr(o)&&pr(c)&&!c.tokens&&(u=/^{([^}]+)}$/.exec(o)))return[new ValidationError(i,o,`"${a}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(u[1])} }\`.`)];const h=[];return"symbol"===e.layerType&&("text-field"===a&&r&&!r.glyphs&&h.push(new ValidationError(i,o,'use of "text-field" requires a style "glyphs" property')),"text-font"===a&&_r(pt(o))&&"identity"===ht(o.type)&&h.push(new ValidationError(i,o,'"text-font" does not support identity functions'))),h.concat(ln({key:e.key,value:o,valueSpec:c,style:r,styleSpec:n,expressionContext:"property",propertyType:t,propertyKey:a}))}function Jr(e){return Kr(e,"paint")}function Yr(e){return Kr(e,"layout")}function Qr(e){let t=[];const i=e.value,r=e.key,n=e.style,o=e.styleSpec;i.type||i.ref||t.push(new ValidationError(r,i,'either "type" or "ref" is required'));let a=ht(i.type);const s=ht(i.ref);if(i.id){const o=ht(i.id);for(let a=0;a<e.arrayIndex;a++){const e=n.layers[a];ht(e.id)===o&&t.push(new ValidationError(r,i.id,`duplicate layer id "${i.id}", previously used at line ${e.id.__line__}`))}}if("ref"in i){let e;["type","source","source-layer","filter","layout"].forEach((e=>{e in i&&t.push(new ValidationError(r,i[e],`"${e}" is prohibited for ref layers`))})),n.layers.forEach((t=>{ht(t.id)===s&&(e=t)})),e?e.ref?t.push(new ValidationError(r,i.ref,"ref cannot reference another ref layer")):a=ht(e.type):"string"==typeof s&&t.push(new ValidationError(r,i.ref,`ref layer "${s}" not found`))}else if("background"!==a&&"sky"!==a)if(i.source){const e=n.sources&&n.sources[i.source],o=e&&ht(e.type);e?"vector"===o&&"raster"===a?t.push(new ValidationError(r,i.source,`layer "${i.id}" requires a raster source`)):"raster"===o&&"raster"!==a?t.push(new ValidationError(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==o||i["source-layer"]?"raster-dem"===o&&"hillshade"!==a?t.push(new ValidationError(r,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==a||!i.paint||!i.paint["line-gradient"]&&!i.paint["line-trim-offset"]||"geojson"===o&&e.lineMetrics||t.push(new ValidationError(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new ValidationError(r,i,`layer "${i.id}" must specify a "source-layer"`)):t.push(new ValidationError(r,i.source,`source "${i.source}" not found`))}else t.push(new ValidationError(r,i,'missing required property "source"'));return t=t.concat(Ir({key:r,value:i,valueSpec:o.layer,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":()=>[],type:()=>ln({key:`${r}.type`,value:i.type,valueSpec:o.layer.type,style:e.style,styleSpec:e.styleSpec,object:i,objectKey:"type"}),filter:e=>Hr(ut({layerType:a},e)),layout:e=>Ir({layer:i,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>Yr(ut({layerType:a},e))}}),paint:e=>Ir({layer:i,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>Jr(ut({layerType:a},e))}})}})),t}function en(e){const t=e.value,i=e.key,r=mr(t);return"string"!==r?[new ValidationError(i,t,`string expected, ${r} found`)]:[]}const tn={promoteId:function({key:e,value:t}){if("string"===mr(t))return en({key:e,value:t});{const i=[];for(const r in t)i.push(...en({key:`${e}.${r}`,value:t[r]}));return i}}};function rn(e){const t=e.value,i=e.key,r=e.styleSpec,n=e.style;if(!t.type)return[new ValidationError(i,t,'"type" is required')];const o=ht(t.type);let a;switch(o){case"vector":case"raster":case"raster-dem":return a=Ir({key:i,value:t,valueSpec:r[`source_${o.replace("-","_")}`],style:e.style,styleSpec:r,objectElementValidators:tn}),a;case"geojson":if(a=Ir({key:i,value:t,valueSpec:r.source_geojson,style:n,styleSpec:r,objectElementValidators:tn}),t.cluster)for(const e in t.clusterProperties){const[r,n]=t.clusterProperties[e],o="string"==typeof r?[r,["accumulated"],["get",e]]:r;a.push(...zr({key:`${i}.${e}.map`,value:n,expressionContext:"cluster-map"})),a.push(...zr({key:`${i}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return a;case"video":return Ir({key:i,value:t,valueSpec:r.source_video,style:n,styleSpec:r});case"image":return Ir({key:i,value:t,valueSpec:r.source_image,style:n,styleSpec:r});case"canvas":return[new ValidationError(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Lr({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:n,styleSpec:r})}}function nn(e){const t=e.value,i=e.styleSpec,r=i.light,n=e.style;let o=[];const a=mr(t);if(void 0===t)return o;if("object"!==a)return o=o.concat([new ValidationError("light",t,`object expected, ${a} found`)]),o;for(const e in t){const a=e.match(/^(.*)-transition$/);o=o.concat(a&&r[a[1]]&&r[a[1]].transition?ln({key:e,value:t[e],valueSpec:i.transition,style:n,styleSpec:i}):r[e]?ln({key:e,value:t[e],valueSpec:r[e],style:n,styleSpec:i}):[new ValidationError(e,t[e],`unknown property "${e}"`)])}return o}function on(e){const t=e.value,i=e.key,r=e.style,n=e.styleSpec,o=n.terrain;let a=[];const s=mr(t);if(void 0===t)return a;if("object"!==s)return a=a.concat([new ValidationError("terrain",t,`object expected, ${s} found`)]),a;for(const e in t){const i=e.match(/^(.*)-transition$/);a=a.concat(i&&o[i[1]]&&o[i[1]].transition?ln({key:e,value:t[e],valueSpec:n.transition,style:r,styleSpec:n}):o[e]?ln({key:e,value:t[e],valueSpec:o[e],style:r,styleSpec:n}):[new ValidationError(e,t[e],`unknown property "${e}"`)])}if(t.source){const e=r.sources&&r.sources[t.source],n=e&&ht(e.type);e?"raster-dem"!==n&&a.push(new ValidationError(i,t.source,`terrain cannot be used with a source of type ${String(n)}, it only be used with a "raster-dem" source type`)):a.push(new ValidationError(i,t.source,`source "${t.source}" not found`))}else a.push(new ValidationError(i,t,'terrain is missing required property "source"'));return a}function an(e){const t=e.value,i=e.style,r=e.styleSpec,n=r.fog;let o=[];const a=mr(t);if(void 0===t)return o;if("object"!==a)return o=o.concat([new ValidationError("fog",t,`object expected, ${a} found`)]),o;for(const e in t){const a=e.match(/^(.*)-transition$/);o=o.concat(a&&n[a[1]]&&n[a[1]].transition?ln({key:e,value:t[e],valueSpec:r.transition,style:i,styleSpec:r}):n[e]?ln({key:e,value:t[e],valueSpec:n[e],style:i,styleSpec:r}):[new ValidationError(e,t[e],`unknown property "${e}"`)])}return o}const sn={"*":()=>[],array:Mr,boolean:function(e){const t=e.value,i=e.key,r=mr(t);return"boolean"!==r?[new ValidationError(i,t,`boolean expected, ${r} found`)]:[]},number:Pr,color:function(e){const t=e.key,i=e.value,r=mr(i);return"string"!==r?[new ValidationError(t,i,`color expected, ${r} found`)]:null===kt.parseCSSColor(i)?[new ValidationError(t,i,`color expected, "${i}" found`)]:[]},enum:Lr,filter:Hr,function:Dr,layer:Qr,object:Ir,source:rn,light:nn,terrain:on,fog:an,string:en,formatted:function(e){return 0===en(e).length?[]:zr(e)},resolvedImage:function(e){return 0===en(e).length?[]:zr(e)},projection:function(e){const t=e.value,i=e.styleSpec,r=i.projection,n=e.style;let o=[];const a=mr(t);if("object"===a)for(const e in t)o=o.concat(ln({key:e,value:t[e],valueSpec:r[e],style:n,styleSpec:i}));else"string"!==a&&(o=o.concat([new ValidationError("projection",t,`object or string expected, ${a} found`)]));return o}};function ln(e){const t=e.value,i=e.valueSpec,r=e.styleSpec;return i.expression&&_r(ht(t))?Dr(e):i.expression&&Er(pt(t))?zr(e):i.type&&sn[i.type]?sn[i.type](e):Ir(ut({},e,{valueSpec:i.type?r[i.type]:i}))}function cn(e){const t=e.value,i=e.key,r=en(e);return r.length||(-1===t.indexOf("{fontstack}")&&r.push(new ValidationError(i,t,'"glyphs" url must include a "{fontstack}" token')),-1===t.indexOf("{range}")&&r.push(new ValidationError(i,t,'"glyphs" url must include a "{range}" token'))),r}function un(e,t=ct){return xn(ln({key:"",value:e,valueSpec:t.$root,styleSpec:t,style:e,objectElementValidators:{glyphs:cn,"*":()=>[]}}))}const hn=e=>xn(rn(e)),pn=e=>xn(nn(e)),dn=e=>xn(on(e)),fn=e=>xn(an(e)),mn=e=>xn(Qr(e)),_n=e=>xn(Hr(e)),gn=e=>xn(Jr(e)),yn=e=>xn(Yr(e));function xn(e){return e.slice().sort(((e,t)=>e.line&&t.line?e.line-t.line:0))}function vn(e,t){let i=!1;if(t&&t.length)for(const r of t)e.fire(new ErrorEvent(new Error(r.message))),i=!0;return i}var bn=wn;function wn(e,t,i){var r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var n=new Int32Array(this.arrayBuffer);e=n[0],this.d=(t=n[1])+2*(i=n[2]);for(var o=0;o<this.d*this.d;o++){var a=n[3+o],s=n[3+o+1];r.push(a===s?null:n.subarray(a,s))}var l=n[3+r.length+1];this.keys=n.subarray(n[3+r.length],l),this.bboxes=n.subarray(l),this.insert=this._insertReadonly}else{this.d=t+2*i;for(var c=0;c<this.d*this.d;c++)r.push([]);this.keys=[],this.bboxes=[]}this.n=t,this.extent=e,this.padding=i,this.scale=t/e,this.uid=0;var u=i/t*e;this.min=-u,this.max=e+u}wn.prototype.insert=function(e,t,i,r,n){this._forEachCell(t,i,r,n,this._insertCell,this.uid++),this.keys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)},wn.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},wn.prototype._insertCell=function(e,t,i,r,n,o){this.cells[n].push(o)},wn.prototype.query=function(e,t,i,r,n){var o=this.min,a=this.max;if(e<=o&&t<=o&&a<=i&&a<=r&&!n)return Array.prototype.slice.call(this.keys);var s=[];return this._forEachCell(e,t,i,r,this._queryCell,s,{},n),s},wn.prototype._queryCell=function(e,t,i,r,n,o,a,s){var l=this.cells[n];if(null!==l)for(var c=this.keys,u=this.bboxes,h=0;h<l.length;h++){var p=l[h];if(void 0===a[p]){var d=4*p;(s?s(u[d+0],u[d+1],u[d+2],u[d+3]):e<=u[d+2]&&t<=u[d+3]&&i>=u[d+0]&&r>=u[d+1])?(a[p]=!0,o.push(c[p])):a[p]=!1}}},wn.prototype._forEachCell=function(e,t,i,r,n,o,a,s){for(var l=this._convertToCellCoord(e),c=this._convertToCellCoord(t),u=this._convertToCellCoord(i),h=this._convertToCellCoord(r),p=l;p<=u;p++)for(var d=c;d<=h;d++){var f=this.d*d+p;if((!s||s(this._convertFromCellCoord(p),this._convertFromCellCoord(d),this._convertFromCellCoord(p+1),this._convertFromCellCoord(d+1)))&&n.call(this,e,t,i,r,f,o,a,s))return}},wn.prototype._convertFromCellCoord=function(e){return(e-this.padding)/this.scale},wn.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},wn.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var e=this.cells,t=3+this.cells.length+1+1,i=0,r=0;r<this.cells.length;r++)i+=this.cells[r].length;var n=new Int32Array(t+i+this.keys.length+this.bboxes.length);n[0]=this.extent,n[1]=this.n,n[2]=this.padding;for(var o=t,a=0;a<e.length;a++){var s=e[a];n[3+a]=o,n.set(s,o),o+=s.length}return n[3+e.length]=o,n.set(this.keys,o),n[3+e.length+1]=o+=this.keys.length,n.set(this.bboxes,o),o+=this.bboxes.length,n.buffer};const Tn={};function En(e,t,i={}){Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),Tn[t]={klass:e,omit:i.omit||[]}}En(Object,"Object"),bn.serialize=function(e,t){const i=e.toArrayBuffer();return t&&t.push(i),{buffer:i}},bn.deserialize=function(e){return new bn(e.buffer)},Object.defineProperty(bn,"name",{value:"Grid"}),En(bn,"Grid"),En(Lt,"Color"),En(Error,"Error"),En(AJAXError,"AJAXError"),En(ResolvedImage,"ResolvedImage"),En(StylePropertyFunction,"StylePropertyFunction"),En(StyleExpression,"StyleExpression",{omit:["_evaluator"]}),En(ZoomDependentExpression,"ZoomDependentExpression"),En(ZoomConstantExpression,"ZoomConstantExpression"),En(Wt,"CompoundExpression",{omit:["_evaluate"]});for(const e in cr)Tn[cr[e]._classRegistryKey]||En(cr[e],`Expression${e}`);function Sn(e){return e&&"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}function An(t){return e.ImageBitmap&&t instanceof e.ImageBitmap}function Cn(t,i){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp)return t;if(Sn(t)||An(t))return i&&i.push(t),t;if(ArrayBuffer.isView(t)){const e=t;return i&&i.push(e.buffer),e}if(t instanceof e.ImageData)return i&&i.push(t.data.buffer),t;if(Array.isArray(t)){const e=[];for(const r of t)e.push(Cn(r,i));return e}if("object"==typeof t){const e=t.constructor,r=e._classRegistryKey;if(!r)throw new Error(`can't serialize object of unregistered class ${r}`);const n=e.serialize?e.serialize(t,i):{};if(!e.serialize){for(const e in t)t.hasOwnProperty(e)&&(Tn[r].omit.indexOf(e)>=0||(n[e]=Cn(t[e],i)));t instanceof Error&&(n.message=t.message)}if(n.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(n.$name=r),n}throw new Error("can't serialize object of type "+typeof t)}function Mn(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||Sn(t)||An(t)||ArrayBuffer.isView(t)||t instanceof e.ImageData)return t;if(Array.isArray(t))return t.map(Mn);if("object"==typeof t){const e=t.$name||"Object",{klass:i}=Tn[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const r=Object.create(i.prototype);for(const e of Object.keys(t))"$name"!==e&&(r[e]=Mn(t[e]));return r}throw new Error("can't deserialize object of type "+typeof t)}class ZoomHistory{constructor(){this.first=!0}update(e,t){const i=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=t):this.lastFloorZoom<i&&(this.lastIntegerZoom=i,this.lastIntegerZoomTime=t),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=i,!0))}}const Pn=e=>e>=12288&&e<=12351,Dn=e=>e>=12352&&e<=12447,zn=e=>e>=12448&&e<=12543,kn=e=>e>=19968&&e<=40959,Ln=e=>e>=44032&&e<=55215;function Bn(e){for(const t of e)if(Rn(t.charCodeAt(0)))return!0;return!1}function Rn(e){return!(746!==e&&747!==e&&(e<4352||!((e=>e>=12704&&e<=12735)(e)||(e=>e>=12544&&e<=12591)(e)||(e=>e>=65072&&e<=65103)(e)&&!(e>=65097&&e<=65103)||(e=>e>=63744&&e<=64255)(e)||(e=>e>=13056&&e<=13311)(e)||(e=>e>=11904&&e<=12031)(e)||(e=>e>=12736&&e<=12783)(e)||!(!Pn(e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||(e=>e>=13312&&e<=19903)(e)||kn(e)||(e=>e>=12800&&e<=13055)(e)||(e=>e>=12592&&e<=12687)(e)||(e=>e>=43360&&e<=43391)(e)||(e=>e>=55216&&e<=55295)(e)||(e=>e>=4352&&e<=4607)(e)||Ln(e)||Dn(e)||(e=>e>=12272&&e<=12287)(e)||(e=>e>=12688&&e<=12703)(e)||(e=>e>=12032&&e<=12255)(e)||(e=>e>=12784&&e<=12799)(e)||zn(e)&&12540!==e||!(!(e=>e>=65280&&e<=65519)(e)||65288===e||65289===e||65293===e||e>=65306&&e<=65310||65339===e||65341===e||65343===e||e>=65371&&e<=65503||65507===e||e>=65512&&e<=65519)||!(!(e=>e>=65104&&e<=65135)(e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||(e=>e>=5120&&e<=5759)(e)||(e=>e>=6320&&e<=6399)(e)||(e=>e>=65040&&e<=65055)(e)||(e=>e>=19904&&e<=19967)(e)||(e=>e>=40960&&e<=42127)(e)||(e=>e>=42128&&e<=42191)(e))))}function Fn(e){return e>=1424&&e<=2303||(e=>e>=64336&&e<=65023)(e)||(e=>e>=65136&&e<=65279)(e)}function On(e,t){return!(!t&&Fn(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||(e=>e>=6016&&e<=6143)(e))}function Vn(e){for(const t of e)if(Fn(t.charCodeAt(0)))return!0;return!1}const Un="deferred",jn="loading",Nn="loaded";let Gn=null,Zn="unavailable",qn=null;const $n=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(Zn="error"),Gn&&Gn(e)};function Wn(){Hn.fire(new Event("pluginStateChange",{pluginStatus:Zn,pluginURL:qn}))}const Hn=new Evented,Xn=function(){return Zn},Kn=function(){if(Zn!==Un||!qn)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Zn=jn,Wn(),qn&&Qe({url:qn},(e=>{e?$n(e):(Zn=Nn,Wn())}))},Jn={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Zn===Nn||null!=Jn.applyArabicShaping,isLoading:()=>Zn===jn,setState(e){Zn=e.pluginStatus,qn=e.pluginURL},isParsed:()=>null!=Jn.applyArabicShaping,getPluginURL:()=>qn};class EvaluationParameters{constructor(e,t){this.zoom=e,t?(this.now=t.now,this.fadeDuration=t.fadeDuration,this.zoomHistory=t.zoomHistory,this.transition=t.transition,this.pitch=t.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new ZoomHistory,this.transition={},this.pitch=0)}isSupportedScript(e){return function(e,t){for(const i of e)if(!On(i.charCodeAt(0),t))return!1;return!0}(e,Jn.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,t=e-Math.floor(e),i=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:t+(1-t)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*t}}}class PropertyValue{constructor(e,t){this.property=e,this.value=t,this.expression=function(e,t){if(_r(e))return new StylePropertyFunction(e,t);if(Er(e)){const i=Ar(e,t);if("error"===i.result)throw new Error(i.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return i.value}{let i=e;return"string"==typeof e&&"color"===t.type&&(i=Lt.parse(e)),{kind:"constant",evaluate:()=>i}}}(void 0===t?e.specification.default:t,e.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,i){return this.property.possiblyEvaluate(this,e,t,i)}}class TransitionablePropertyValue{constructor(e){this.property=e,this.value=new PropertyValue(e,void 0)}transitioned(e,t){return new TransitioningPropertyValue(this.property,this.value,t,b({},e.transition,this.transition),e.now)}untransitioned(){return new TransitioningPropertyValue(this.property,this.value,null,{},0)}}class Transitionable{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return z(this._values[e].value.value)}setValue(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new TransitionablePropertyValue(this._values[e].property)),this._values[e].value=new PropertyValue(this._values[e].property,null===t?void 0:z(t))}getTransition(e){return z(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new TransitionablePropertyValue(this._values[e].property)),this._values[e].transition=z(t)||void 0}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i);const r=this.getTransition(t);void 0!==r&&(e[`${t}-transition`]=r)}return e}transitioned(e,t){const i=new Transitioning(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(e,t._values[r]);return i}untransitioned(){const e=new Transitioning(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class TransitioningPropertyValue{constructor(e,t,i,r,n){const o=r.delay||0,a=r.duration||0;n=n||0,this.property=e,this.value=t,this.begin=n+o,this.end=this.begin+a,e.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(e,t,i){const r=e.now||0,n=this.value.possiblyEvaluate(e,t,i),o=this.prior;if(o){if(r>this.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(r<this.begin)return o.possiblyEvaluate(e,t,i);{const a=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(o.possiblyEvaluate(e,t,i),n,h(a))}}return n}}class Transitioning{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,t,i){const r=new PossiblyEvaluated(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(e,t,i);return r}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class Layout{constructor(e){this._properties=e,this._values=Object.create(e.defaultPropertyValues)}getValue(e){return z(this._values[e].value)}setValue(e,t){this._values[e]=new PropertyValue(this._values[e].property,null===t?void 0:z(t))}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i)}return e}possiblyEvaluate(e,t,i){const r=new PossiblyEvaluated(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(e,t,i);return r}}class PossiblyEvaluatedPropertyValue{constructor(e,t,i){this.property=e,this.value=t,this.parameters=i}isConstant(){return"constant"===this.value.kind}constantOr(e){return"constant"===this.value.kind?this.value.value:e}evaluate(e,t,i,r){return this.property.evaluate(this.value,this.parameters,e,t,i,r)}}class PossiblyEvaluated{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class DataConstantProperty{constructor(e){this.specification=e}possiblyEvaluate(e,t){return e.expression.evaluate(t)}interpolate(e,t,i){const r=bi[this.specification.type];return r?r(e,t,i):e}}class DataDrivenProperty{constructor(e,t){this.specification=e,this.overrides=t}possiblyEvaluate(e,t,i,r){return new PossiblyEvaluatedPropertyValue(this,"constant"===e.expression.kind||"camera"===e.expression.kind?{kind:"constant",value:e.expression.evaluate(t,null,{},i,r)}:e.expression,t)}interpolate(e,t,i){if("constant"!==e.value.kind||"constant"!==t.value.kind)return e;if(void 0===e.value.value||void 0===t.value.value)return new PossiblyEvaluatedPropertyValue(this,{kind:"constant",value:void 0},e.parameters);const r=bi[this.specification.type];return r?new PossiblyEvaluatedPropertyValue(this,{kind:"constant",value:r(e.value.value,t.value.value,i)},e.parameters):e}evaluate(e,t,i,r,n,o){return"constant"===e.kind?e.value:e.evaluate(t,i,r,n,o)}}class CrossFadedDataDrivenProperty extends DataDrivenProperty{possiblyEvaluate(e,t,i,r){if(void 0===e.value)return new PossiblyEvaluatedPropertyValue(this,{kind:"constant",value:void 0},t);if("constant"===e.expression.kind){const n=e.expression.evaluate(t,null,{},i,r),o="resolvedImage"===e.property.specification.type&&"string"!=typeof n?n.name:n,a=this._calculate(o,o,o,t);return new PossiblyEvaluatedPropertyValue(this,{kind:"constant",value:a},t)}if("camera"===e.expression.kind){const i=this._calculate(e.expression.evaluate({zoom:t.zoom-1}),e.expression.evaluate({zoom:t.zoom}),e.expression.evaluate({zoom:t.zoom+1}),t);return new PossiblyEvaluatedPropertyValue(this,{kind:"constant",value:i},t)}return new PossiblyEvaluatedPropertyValue(this,e.expression,t)}evaluate(e,t,i,r,n,o){if("source"===e.kind){const a=e.evaluate(t,i,r,n,o);return this._calculate(a,a,a,t)}return"composite"===e.kind?this._calculate(e.evaluate({zoom:Math.floor(t.zoom)-1},i,r),e.evaluate({zoom:Math.floor(t.zoom)},i,r),e.evaluate({zoom:Math.floor(t.zoom)+1},i,r),t):e.value}_calculate(e,t,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t,other:i}:{from:i,to:t,other:e}}interpolate(e){return e}}class CrossFadedProperty{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,r){if(void 0!==e.value){if("constant"===e.expression.kind){const n=e.expression.evaluate(t,null,{},i,r);return this._calculate(n,n,n,t)}return this._calculate(e.expression.evaluate(new EvaluationParameters(Math.floor(t.zoom-1),t)),e.expression.evaluate(new EvaluationParameters(Math.floor(t.zoom),t)),e.expression.evaluate(new EvaluationParameters(Math.floor(t.zoom+1),t)),t)}}_calculate(e,t,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}}class ColorRampProperty{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,r){return!!e.expression.evaluate(t,null,{},i,r)}interpolate(){return!1}}class Properties{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const t=new EvaluationParameters(0,{});for(const i in e){const r=e[i];r.specification.overridable&&this.overridableProperties.push(i);const n=this.defaultPropertyValues[i]=new PropertyValue(r,void 0),o=this.defaultTransitionablePropertyValues[i]=new TransitionablePropertyValue(r);this.defaultTransitioningPropertyValues[i]=o.untransitioned(),this.defaultPossiblyEvaluatedValues[i]=n.possiblyEvaluate(t)}}}function Yn(e,t){return 256*(e=_(Math.floor(e),0,255))+_(Math.floor(t),0,255)}En(DataDrivenProperty,"DataDrivenProperty"),En(DataConstantProperty,"DataConstantProperty"),En(CrossFadedDataDrivenProperty,"CrossFadedDataDrivenProperty"),En(CrossFadedProperty,"CrossFadedProperty"),En(ColorRampProperty,"ColorRampProperty");const Qn={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Struct{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class StructArray{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}_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(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function eo(e,t=1){let i=0,r=0;return{members:e.map((e=>{const n=Qn[e.type].BYTES_PER_ELEMENT,o=i=to(i,Math.max(t,n)),a=e.components||1;return r=Math.max(r,n),i+=n*a,{name:e.name,type:e.type,components:a,offset:o}})),size:to(i,Math.max(r,t)),alignment:t}}function to(e,t){return Math.ceil(e/t)*t}class StructArrayLayout2i4 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.int16[r+0]=t,this.int16[r+1]=i,e}}StructArrayLayout2i4.prototype.bytesPerElement=4,En(StructArrayLayout2i4,"StructArrayLayout2i4");class StructArrayLayout3i6 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.int16[n+0]=t,this.int16[n+1]=i,this.int16[n+2]=r,e}}StructArrayLayout3i6.prototype.bytesPerElement=6,En(StructArrayLayout3i6,"StructArrayLayout3i6");class StructArrayLayout4i8 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=n,e}}StructArrayLayout4i8.prototype.bytesPerElement=8,En(StructArrayLayout4i8,"StructArrayLayout4i8");class StructArrayLayout2i4ub1f12 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,a){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o,a)}emplace(e,t,i,r,n,o,a,s){const l=6*e,c=12*e,u=3*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.uint8[c+4]=r,this.uint8[c+5]=n,this.uint8[c+6]=o,this.uint8[c+7]=a,this.float32[u+2]=s,e}}StructArrayLayout2i4ub1f12.prototype.bytesPerElement=12,En(StructArrayLayout2i4ub1f12,"StructArrayLayout2i4ub1f12");class StructArrayLayout4f16 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=r,this.float32[o+3]=n,e}}StructArrayLayout4f16.prototype.bytesPerElement=16,En(StructArrayLayout4f16,"StructArrayLayout4f16");class StructArrayLayout10ui20 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,a,s,l,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,t,i,r,n,o,a,s,l,c)}emplace(e,t,i,r,n,o,a,s,l,c,u){const h=10*e;return this.uint16[h+0]=t,this.uint16[h+1]=i,this.uint16[h+2]=r,this.uint16[h+3]=n,this.uint16[h+4]=o,this.uint16[h+5]=a,this.uint16[h+6]=s,this.uint16[h+7]=l,this.uint16[h+8]=c,this.uint16[h+9]=u,e}}StructArrayLayout10ui20.prototype.bytesPerElement=20,En(StructArrayLayout10ui20,"StructArrayLayout10ui20");class StructArrayLayout8ui16 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,a,s){const l=this.length;return this.resize(l+1),this.emplace(l,e,t,i,r,n,o,a,s)}emplace(e,t,i,r,n,o,a,s,l){const c=8*e;return this.uint16[c+0]=t,this.uint16[c+1]=i,this.uint16[c+2]=r,this.uint16[c+3]=n,this.uint16[c+4]=o,this.uint16[c+5]=a,this.uint16[c+6]=s,this.uint16[c+7]=l,e}}StructArrayLayout8ui16.prototype.bytesPerElement=16,En(StructArrayLayout8ui16,"StructArrayLayout8ui16");class StructArrayLayout6i12 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,a){const s=6*e;return this.int16[s+0]=t,this.int16[s+1]=i,this.int16[s+2]=r,this.int16[s+3]=n,this.int16[s+4]=o,this.int16[s+5]=a,e}}StructArrayLayout6i12.prototype.bytesPerElement=12,En(StructArrayLayout6i12,"StructArrayLayout6i12");class StructArrayLayout4i4ui4i24 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,a,s,l,c,u,h){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,i,r,n,o,a,s,l,c,u,h)}emplace(e,t,i,r,n,o,a,s,l,c,u,h,p){const d=12*e;return this.int16[d+0]=t,this.int16[d+1]=i,this.int16[d+2]=r,this.int16[d+3]=n,this.uint16[d+4]=o,this.uint16[d+5]=a,this.uint16[d+6]=s,this.uint16[d+7]=l,this.int16[d+8]=c,this.int16[d+9]=u,this.int16[d+10]=h,this.int16[d+11]=p,e}}StructArrayLayout4i4ui4i24.prototype.bytesPerElement=24,En(StructArrayLayout4i4ui4i24,"StructArrayLayout4i4ui4i24");class StructArrayLayout3i3f20 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,a){const s=10*e,l=5*e;return this.int16[s+0]=t,this.int16[s+1]=i,this.int16[s+2]=r,this.float32[l+2]=n,this.float32[l+3]=o,this.float32[l+4]=a,e}}StructArrayLayout3i3f20.prototype.bytesPerElement=20,En(StructArrayLayout3i3f20,"StructArrayLayout3i3f20");class StructArrayLayout1ul4 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}StructArrayLayout1ul4.prototype.bytesPerElement=4,En(StructArrayLayout1ul4,"StructArrayLayout1ul4");class StructArrayLayout5i4f1i1ul2ui40 extends StructArray{_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(e,t,i,r,n,o,a,s,l,c,u,h,p){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,i,r,n,o,a,s,l,c,u,h,p)}emplace(e,t,i,r,n,o,a,s,l,c,u,h,p,d){const f=20*e,m=10*e;return this.int16[f+0]=t,this.int16[f+1]=i,this.int16[f+2]=r,this.int16[f+3]=n,this.int16[f+4]=o,this.float32[m+3]=a,this.float32[m+4]=s,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=u,this.uint32[m+8]=h,this.uint16[f+18]=p,this.uint16[f+19]=d,e}}StructArrayLayout5i4f1i1ul2ui40.prototype.bytesPerElement=40,En(StructArrayLayout5i4f1i1ul2ui40,"StructArrayLayout5i4f1i1ul2ui40");class StructArrayLayout3i2i2i16 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,a){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o,a)}emplace(e,t,i,r,n,o,a,s){const l=8*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.int16[l+2]=r,this.int16[l+4]=n,this.int16[l+5]=o,this.int16[l+6]=a,this.int16[l+7]=s,e}}StructArrayLayout3i2i2i16.prototype.bytesPerElement=16,En(StructArrayLayout3i2i2i16,"StructArrayLayout3i2i2i16");class StructArrayLayout2f1f2i16 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const a=4*e,s=8*e;return this.float32[a+0]=t,this.float32[a+1]=i,this.float32[a+2]=r,this.int16[s+6]=n,this.int16[s+7]=o,e}}StructArrayLayout2f1f2i16.prototype.bytesPerElement=16,En(StructArrayLayout2f1f2i16,"StructArrayLayout2f1f2i16");class StructArrayLayout2ub2f12 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=12*e,a=3*e;return this.uint8[o+0]=t,this.uint8[o+1]=i,this.float32[a+1]=r,this.float32[a+2]=n,e}}StructArrayLayout2ub2f12.prototype.bytesPerElement=12,En(StructArrayLayout2ub2f12,"StructArrayLayout2ub2f12");class StructArrayLayout3f12 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.float32[n+0]=t,this.float32[n+1]=i,this.float32[n+2]=r,e}}StructArrayLayout3f12.prototype.bytesPerElement=12,En(StructArrayLayout3f12,"StructArrayLayout3f12");class StructArrayLayout3ui6 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.uint16[n+0]=t,this.uint16[n+1]=i,this.uint16[n+2]=r,e}}StructArrayLayout3ui6.prototype.bytesPerElement=6,En(StructArrayLayout3ui6,"StructArrayLayout3ui6");class StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60 extends StructArray{_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(e,t,i,r,n,o,a,s,l,c,u,h,p,d,f,m,_,g,y,x,v){const b=this.length;return this.resize(b+1),this.emplace(b,e,t,i,r,n,o,a,s,l,c,u,h,p,d,f,m,_,g,y,x,v)}emplace(e,t,i,r,n,o,a,s,l,c,u,h,p,d,f,m,_,g,y,x,v,b){const w=30*e,T=15*e,E=60*e;return this.int16[w+0]=t,this.int16[w+1]=i,this.int16[w+2]=r,this.float32[T+2]=n,this.float32[T+3]=o,this.uint16[w+8]=a,this.uint16[w+9]=s,this.uint32[T+5]=l,this.uint32[T+6]=c,this.uint32[T+7]=u,this.uint16[w+16]=h,this.uint16[w+17]=p,this.uint16[w+18]=d,this.float32[T+10]=f,this.float32[T+11]=m,this.uint8[E+48]=_,this.uint8[E+49]=g,this.uint8[E+50]=y,this.uint32[T+13]=x,this.int16[w+28]=v,this.uint8[E+58]=b,e}}StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60.prototype.bytesPerElement=60,En(StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class StructArrayLayout3i2f6i15ui1ul3f76 extends StructArray{_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(e,t,i,r,n,o,a,s,l,c,u,h,p,d,f,m,_,g,y,x,v,b,w,T,E,S,A,C,I,M){const P=this.length;return this.resize(P+1),this.emplace(P,e,t,i,r,n,o,a,s,l,c,u,h,p,d,f,m,_,g,y,x,v,b,w,T,E,S,A,C,I,M)}emplace(e,t,i,r,n,o,a,s,l,c,u,h,p,d,f,m,_,g,y,x,v,b,w,T,E,S,A,C,I,M,P){const D=38*e,z=19*e;return this.int16[D+0]=t,this.int16[D+1]=i,this.int16[D+2]=r,this.float32[z+2]=n,this.float32[z+3]=o,this.int16[D+8]=a,this.int16[D+9]=s,this.int16[D+10]=l,this.int16[D+11]=c,this.int16[D+12]=u,this.int16[D+13]=h,this.uint16[D+14]=p,this.uint16[D+15]=d,this.uint16[D+16]=f,this.uint16[D+17]=m,this.uint16[D+18]=_,this.uint16[D+19]=g,this.uint16[D+20]=y,this.uint16[D+21]=x,this.uint16[D+22]=v,this.uint16[D+23]=b,this.uint16[D+24]=w,this.uint16[D+25]=T,this.uint16[D+26]=E,this.uint16[D+27]=S,this.uint16[D+28]=A,this.uint32[z+15]=C,this.float32[z+16]=I,this.float32[z+17]=M,this.float32[z+18]=P,e}}StructArrayLayout3i2f6i15ui1ul3f76.prototype.bytesPerElement=76,En(StructArrayLayout3i2f6i15ui1ul3f76,"StructArrayLayout3i2f6i15ui1ul3f76");class StructArrayLayout1f4 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}StructArrayLayout1f4.prototype.bytesPerElement=4,En(StructArrayLayout1f4,"StructArrayLayout1f4");class StructArrayLayout5f20 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const a=5*e;return this.float32[a+0]=t,this.float32[a+1]=i,this.float32[a+2]=r,this.float32[a+3]=n,this.float32[a+4]=o,e}}StructArrayLayout5f20.prototype.bytesPerElement=20,En(StructArrayLayout5f20,"StructArrayLayout5f20");class StructArrayLayout1ul3ui12 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=6*e;return this.uint32[3*e+0]=t,this.uint16[o+2]=i,this.uint16[o+3]=r,this.uint16[o+4]=n,e}}StructArrayLayout1ul3ui12.prototype.bytesPerElement=12,En(StructArrayLayout1ul3ui12,"StructArrayLayout1ul3ui12");class StructArrayLayout2ui4 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.uint16[r+0]=t,this.uint16[r+1]=i,e}}StructArrayLayout2ui4.prototype.bytesPerElement=4,En(StructArrayLayout2ui4,"StructArrayLayout2ui4");class StructArrayLayout1ui2 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}StructArrayLayout1ui2.prototype.bytesPerElement=2,En(StructArrayLayout1ui2,"StructArrayLayout1ui2");class StructArrayLayout2f8 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.float32[r+0]=t,this.float32[r+1]=i,e}}StructArrayLayout2f8.prototype.bytesPerElement=8,En(StructArrayLayout2f8,"StructArrayLayout2f8");class FillExtrusionExtStruct extends Struct{get a_pos_30(){return this._structArray.int16[this._pos2+0]}get a_pos_31(){return this._structArray.int16[this._pos2+1]}get a_pos_32(){return this._structArray.int16[this._pos2+2]}get a_pos_normal_30(){return this._structArray.int16[this._pos2+3]}get a_pos_normal_31(){return this._structArray.int16[this._pos2+4]}get a_pos_normal_32(){return this._structArray.int16[this._pos2+5]}}FillExtrusionExtStruct.prototype.size=12;class FillExtrusionExtArray extends StructArrayLayout6i12{get(e){return new FillExtrusionExtStruct(this,e)}}En(FillExtrusionExtArray,"FillExtrusionExtArray");class CollisionBoxStruct extends Struct{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]}}CollisionBoxStruct.prototype.size=40;class CollisionBoxArray extends StructArrayLayout5i4f1i1ul2ui40{get(e){return new CollisionBoxStruct(this,e)}}En(CollisionBoxArray,"CollisionBoxArray");class PlacedSymbolStruct extends Struct{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(e){this._structArray.uint8[this._pos1+49]=e}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(e){this._structArray.uint8[this._pos1+50]=e}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(e){this._structArray.uint32[this._pos4+13]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(e){this._structArray.uint8[this._pos1+58]=e}}PlacedSymbolStruct.prototype.size=60;class PlacedSymbolArray extends StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60{get(e){return new PlacedSymbolStruct(this,e)}}En(PlacedSymbolArray,"PlacedSymbolArray");class SymbolInstanceStruct extends Struct{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(e){this._structArray.uint32[this._pos4+15]=e}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]}}SymbolInstanceStruct.prototype.size=76;class SymbolInstanceArray extends StructArrayLayout3i2f6i15ui1ul3f76{get(e){return new SymbolInstanceStruct(this,e)}}En(SymbolInstanceArray,"SymbolInstanceArray");class GlyphOffsetArray extends StructArrayLayout1f4{getoffsetX(e){return this.float32[1*e+0]}}En(GlyphOffsetArray,"GlyphOffsetArray");class SymbolLineVertexArray extends StructArrayLayout3i6{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}En(SymbolLineVertexArray,"SymbolLineVertexArray");class FeatureIndexStruct extends Struct{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]}}FeatureIndexStruct.prototype.size=12;class FeatureIndexArray extends StructArrayLayout1ul3ui12{get(e){return new FeatureIndexStruct(this,e)}}En(FeatureIndexArray,"FeatureIndexArray");class FillExtrusionCentroidStruct extends Struct{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}FillExtrusionCentroidStruct.prototype.size=4;class FillExtrusionCentroidArray extends StructArrayLayout2ui4{get(e){return new FillExtrusionCentroidStruct(this,e)}}En(FillExtrusionCentroidArray,"FillExtrusionCentroidArray");class CircleGlobeExtStruct extends Struct{get a_pos_30(){return this._structArray.int16[this._pos2+0]}get a_pos_31(){return this._structArray.int16[this._pos2+1]}get a_pos_32(){return this._structArray.int16[this._pos2+2]}get a_pos_normal_30(){return this._structArray.int16[this._pos2+3]}get a_pos_normal_31(){return this._structArray.int16[this._pos2+4]}get a_pos_normal_32(){return this._structArray.int16[this._pos2+5]}}CircleGlobeExtStruct.prototype.size=12;class CircleGlobeExtArray extends StructArrayLayout6i12{get(e){return new CircleGlobeExtStruct(this,e)}}En(CircleGlobeExtArray,"CircleGlobeExtArray");const io=eo([{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"}]),ro=eo([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var no=zt((function(e){e.exports=function(e,t){var i,r,n,o,a,s,l,c;for(r=e.length-(i=3&e.length),n=t,a=3432918353,s=461845907,c=0;c<r;)l=255&e.charCodeAt(c)|(255&e.charCodeAt(++c))<<8|(255&e.charCodeAt(++c))<<16|(255&e.charCodeAt(++c))<<24,++c,n=27492+(65535&(o=5*(65535&(n=(n^=l=(65535&(l=(l=(65535&l)*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&e.charCodeAt(c+2))<<16;case 2:l^=(255&e.charCodeAt(c+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(c)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295}return n^=e.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0}})),oo=zt((function(e){e.exports=function(e,t){for(var i,r=e.length,n=t^r,o=0;r>=4;)i=1540483477*(65535&(i=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(i>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:n^=(255&e.charCodeAt(o+2))<<16;case 2:n^=(255&e.charCodeAt(o+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(o)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}})),ao=no,so=oo;ao.murmur3=no,ao.murmur2=so;class FeaturePositionMap{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,i,r){this.ids.push(lo(e)),this.positions.push(t,i,r)}getPositions(e){const t=lo(e);let i=0,r=this.ids.length-1;for(;i<r;){const e=i+r>>1;this.ids[e]>=t?r=e:i=e+1}const n=[];for(;this.ids[i]===t;)n.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return n}static serialize(e,t){const i=new Float64Array(e.ids),r=new Uint32Array(e.positions);return co(i,r,0,i.length-1),t&&t.push(i.buffer,r.buffer),{ids:i,positions:r}}static deserialize(e){const t=new FeaturePositionMap;return t.ids=e.ids,t.positions=e.positions,t.indexed=!0,t}}function lo(e){const t=+e;return!isNaN(t)&&Number.MIN_SAFE_INTEGER<=t&&t<=Number.MAX_SAFE_INTEGER?t:ao(String(e))}function co(e,t,i,r){for(;i<r;){const n=e[i+r>>1];let o=i-1,a=r+1;for(;;){do{o++}while(e[o]<n);do{a--}while(e[a]>n);if(o>=a)break;uo(e,o,a),uo(t,3*o,3*a),uo(t,3*o+1,3*a+1),uo(t,3*o+2,3*a+2)}a-i<r-a?(co(e,t,i,a),i=a+1):(co(e,t,a+1,r),r=a)}}function uo(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}En(FeaturePositionMap,"FeaturePositionMap");class Uniform{constructor(e){this.gl=e.gl,this.initialized=!1}fetchUniformLocation(e,t){return this.location||this.initialized||(this.location=this.gl.getUniformLocation(e,t),this.initialized=!0),!!this.location}}class Uniform1i extends Uniform{constructor(e){super(e),this.current=0}set(e,t,i){this.fetchUniformLocation(e,t)&&this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}}class Uniform1f extends Uniform{constructor(e){super(e),this.current=0}set(e,t,i){this.fetchUniformLocation(e,t)&&this.current!==i&&(this.current=i,this.gl.uniform1f(this.location,i))}}class Uniform2f extends Uniform{constructor(e){super(e),this.current=[0,0]}set(e,t,i){this.fetchUniformLocation(e,t)&&(i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1])))}}class Uniform3f extends Uniform{constructor(e){super(e),this.current=[0,0,0]}set(e,t,i){this.fetchUniformLocation(e,t)&&(i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2])))}}class Uniform4f extends Uniform{constructor(e){super(e),this.current=[0,0,0,0]}set(e,t,i){this.fetchUniformLocation(e,t)&&(i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]&&i[3]===this.current[3]||(this.current=i,this.gl.uniform4f(this.location,i[0],i[1],i[2],i[3])))}}class UniformColor extends Uniform{constructor(e){super(e),this.current=Lt.transparent}set(e,t,i){this.fetchUniformLocation(e,t)&&(i.r===this.current.r&&i.g===this.current.g&&i.b===this.current.b&&i.a===this.current.a||(this.current=i,this.gl.uniform4f(this.location,i.r,i.g,i.b,i.a)))}}const ho=new Float32Array(16);class UniformMatrix4f extends Uniform{constructor(e){super(e),this.current=ho}set(e,t,i){if(this.fetchUniformLocation(e,t)){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let e=1;e<16;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}}}const po=new Float32Array(9);class UniformMatrix3f extends Uniform{constructor(e){super(e),this.current=po}set(e,t,i){if(this.fetchUniformLocation(e,t))for(let e=0;e<9;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}}const fo=new Float32Array(4);class UniformMatrix2f extends Uniform{constructor(e){super(e),this.current=fo}set(e,t,i){if(this.fetchUniformLocation(e,t))for(let e=0;e<4;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}}function mo(e){return[Yn(255*e.r,255*e.g),Yn(255*e.b,255*e.a)]}class ConstantBinder{constructor(e,t,i){this.value=e,this.uniformNames=t.map((e=>`u_${e}`)),this.type=i}setUniform(e,t,i,r,n){t.set(e,n,r.constantOr(this.value))}getBinding(e,t){return"color"===this.type?new UniformColor(e):new Uniform1f(e)}}class CrossFadedConstantBinder{constructor(e,t){this.uniformNames=t.map((e=>`u_${e}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,t){this.pixelRatioFrom=t.pixelRatio||1,this.pixelRatioTo=e.pixelRatio||1,this.patternFrom=t.tl.concat(t.br),this.patternTo=e.tl.concat(e.br)}setUniform(e,t,i,r,n){const o="u_pattern_to"===n||"u_dash_to"===n?this.patternTo:"u_pattern_from"===n||"u_dash_from"===n?this.patternFrom:"u_pixel_ratio_to"===n?this.pixelRatioTo:"u_pixel_ratio_from"===n?this.pixelRatioFrom:null;o&&t.set(e,n,o)}getBinding(e,t){return"u_pattern_from"===t||"u_pattern_to"===t||"u_dash_from"===t||"u_dash_to"===t?new Uniform4f(e):new Uniform1f(e)}}class SourceExpressionBinder{constructor(e,t,i,r){this.expression=e,this.type=i,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new r}populatePaintArray(e,t,i,r,n,o){const a=this.paintVertexArray.length,s=this.expression.evaluate(new EvaluationParameters(0),t,{},n,r,o);this.paintVertexArray.resize(e),this._setPaintValue(a,e,s)}updatePaintArray(e,t,i,r,n){const o=this.expression.evaluate({zoom:0},i,r,void 0,n);this._setPaintValue(e,t,o)}_setPaintValue(e,t,i){if("color"===this.type){const r=mo(i);for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,r[0],r[1])}else{for(let r=e;r<t;r++)this.paintVertexArray.emplace(r,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class CompositeExpressionBinder{constructor(e,t,i,r,n,o){this.expression=e,this.uniformNames=t.map((e=>`u_${e}_t`)),this.type=i,this.useIntegerZoom=r,this.zoom=n,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new o}populatePaintArray(e,t,i,r,n,o){const a=this.expression.evaluate(new EvaluationParameters(this.zoom),t,{},n,r,o),s=this.expression.evaluate(new EvaluationParameters(this.zoom+1),t,{},n,r,o),l=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(l,e,a,s)}updatePaintArray(e,t,i,r,n){const o=this.expression.evaluate({zoom:this.zoom},i,r,void 0,n),a=this.expression.evaluate({zoom:this.zoom+1},i,r,void 0,n);this._setPaintValue(e,t,o,a)}_setPaintValue(e,t,i,r){if("color"===this.type){const n=mo(i),o=mo(r);for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,n[0],n[1],o[0],o[1])}else{for(let n=e;n<t;n++)this.paintVertexArray.emplace(n,i,r);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(r))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,t,i,r,n){const o=this.useIntegerZoom?Math.floor(i.zoom):i.zoom,a=_(this.expression.interpolationFactor(o,this.zoom,this.zoom+1),0,1);t.set(e,n,a)}getBinding(e,t){return new Uniform1f(e)}}class CrossFadedCompositeBinder{constructor(e,t,i,r,n,o,a){this.expression=e,this.type=i,this.useIntegerZoom=r,this.zoom=n,this.layerId=a,this.paintVertexAttributes=("array"===i?ro:io).members;for(let e=0;e<t.length;++e);this.zoomInPaintVertexArray=new o,this.zoomOutPaintVertexArray=new o}populatePaintArray(e,t,i){const r=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(r,e,t.patterns&&t.patterns[this.layerId],i)}updatePaintArray(e,t,i,r,n,o){this._setPaintValues(e,t,i.patterns&&i.patterns[this.layerId],o)}_setPaintValues(e,t,i,r){if(!r||!i)return;const{min:n,mid:o,max:a}=i,s=r[n],l=r[o],c=r[a];if(s&&l&&c)for(let i=e;i<t;i++)this._setPaintValue(this.zoomInPaintVertexArray,i,l,s),this._setPaintValue(this.zoomOutPaintVertexArray,i,l,c)}_setPaintValue(e,t,i,r){e.emplace(t,i.tl[0],i.tl[1],i.br[0],i.br[1],r.tl[0],r.tl[1],r.br[0],r.br[1],i.pixelRatio,r.pixelRatio)}upload(e){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class ProgramConfiguration{constructor(e,t,i=(()=>!0)){this.binders={},this._buffers=[];const r=[];for(const n in e.paint._values){if(!i(n))continue;const o=e.paint.get(n);if(!(o instanceof PossiblyEvaluatedPropertyValue&&pr(o.property.specification)))continue;const a=go(n,e.type),s=o.value,l=o.property.specification.type,c=o.property.useIntegerZoom,u=o.property.specification["property-type"],h="cross-faded"===u||"cross-faded-data-driven"===u,p="line-dasharray"===String(n)&&"constant"!==e.layout.get("line-cap").value.kind;if("constant"!==s.kind||p)if("source"===s.kind||p||h){const i=vo(n,l,"source");this.binders[n]=h?new CrossFadedCompositeBinder(s,a,l,c,t,i,e.id):new SourceExpressionBinder(s,a,l,i),r.push(`/a_${n}`)}else{const e=vo(n,l,"composite");this.binders[n]=new CompositeExpressionBinder(s,a,l,c,t,e),r.push(`/z_${n}`)}else this.binders[n]=h?new CrossFadedConstantBinder(s.value,a):new ConstantBinder(s.value,a,l),r.push(`/u_${n}`)}this.cacheKey=r.sort().join("")}getMaxValue(e){const t=this.binders[e];return t instanceof SourceExpressionBinder||t instanceof CompositeExpressionBinder?t.maxValue:0}populatePaintArrays(e,t,i,r,n,o){for(const a in this.binders){const s=this.binders[a];(s instanceof SourceExpressionBinder||s instanceof CompositeExpressionBinder||s instanceof CrossFadedCompositeBinder)&&s.populatePaintArray(e,t,i,r,n,o)}}setConstantPatternPositions(e,t){for(const i in this.binders){const r=this.binders[i];r instanceof CrossFadedConstantBinder&&r.setConstantPatternPositions(e,t)}}updatePaintArrays(e,t,i,r,n,o){let a=!1;for(const s in e){const l=t.getPositions(s);for(const t of l){const l=i.feature(t.index);for(const i in this.binders){const c=this.binders[i];if((c instanceof SourceExpressionBinder||c instanceof CompositeExpressionBinder||c instanceof CrossFadedCompositeBinder)&&!0===c.expression.isStateDependent){const u=r.paint.get(i);c.expression=u.value,c.updatePaintArray(t.start,t.end,l,e[s],n,o),a=!0}}}}return a}defines(){const e=[];for(const t in this.binders){const i=this.binders[t];(i instanceof ConstantBinder||i instanceof CrossFadedConstantBinder)&&e.push(...i.uniformNames.map((e=>`#define HAS_UNIFORM_${e}`)))}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof SourceExpressionBinder||i instanceof CompositeExpressionBinder||i instanceof CrossFadedCompositeBinder)for(let t=0;t<i.paintVertexAttributes.length;t++)e.push(i.paintVertexAttributes[t].name)}return e}getBinderUniforms(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof ConstantBinder||i instanceof CrossFadedConstantBinder||i instanceof CompositeExpressionBinder)for(const t of i.uniformNames)e.push(t)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e){const t=[];for(const i in this.binders){const r=this.binders[i];if(r instanceof ConstantBinder||r instanceof CrossFadedConstantBinder||r instanceof CompositeExpressionBinder)for(const n of r.uniformNames)t.push({name:n,property:i,binding:r.getBinding(e,n)})}return t}setUniforms(e,t,i,r,n){for(const{name:t,property:o,binding:a}of i)this.binders[o].setUniform(e,a,n,r.get(o),t)}updatePaintBuffers(e){this._buffers=[];for(const t in this.binders){const i=this.binders[t];if(e&&i instanceof CrossFadedCompositeBinder){const t=2===e.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;t&&this._buffers.push(t)}else(i instanceof SourceExpressionBinder||i instanceof CompositeExpressionBinder)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(e){for(const t in this.binders){const i=this.binders[t];(i instanceof SourceExpressionBinder||i instanceof CompositeExpressionBinder||i instanceof CrossFadedCompositeBinder)&&i.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const t=this.binders[e];(t instanceof SourceExpressionBinder||t instanceof CompositeExpressionBinder||t instanceof CrossFadedCompositeBinder)&&t.destroy()}}}class ProgramConfigurationSet{constructor(e,t,i=(()=>!0)){this.programConfigurations={};for(const r of e)this.programConfigurations[r.id]=new ProgramConfiguration(r,t,i);this.needsUpload=!1,this._featureMap=new FeaturePositionMap,this._bufferOffset=0}populatePaintArrays(e,t,i,r,n,o,a){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(e,t,r,n,o,a);void 0!==t.id&&this._featureMap.add(t.id,i,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,i,r,n){for(const o of i)this.needsUpload=this.programConfigurations[o.id].updatePaintArrays(e,this._featureMap,t,o,r,n)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}const _o={"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 go(e,t){return _o[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}const yo={"line-pattern":{source:StructArrayLayout10ui20,composite:StructArrayLayout10ui20},"fill-pattern":{source:StructArrayLayout10ui20,composite:StructArrayLayout10ui20},"fill-extrusion-pattern":{source:StructArrayLayout10ui20,composite:StructArrayLayout10ui20},"line-dasharray":{source:StructArrayLayout8ui16,composite:StructArrayLayout8ui16}},xo={color:{source:StructArrayLayout2f8,composite:StructArrayLayout4f16},number:{source:StructArrayLayout1f4,composite:StructArrayLayout2f8}};function vo(e,t,i){const r=yo[e];return r&&r[i]||xo[t][i]}En(ConstantBinder,"ConstantBinder"),En(CrossFadedConstantBinder,"CrossFadedConstantBinder"),En(SourceExpressionBinder,"SourceExpressionBinder"),En(CrossFadedCompositeBinder,"CrossFadedCompositeBinder"),En(CompositeExpressionBinder,"CompositeExpressionBinder"),En(ProgramConfiguration,"ProgramConfiguration",{omit:["_buffers"]}),En(ProgramConfigurationSet,"ProgramConfigurationSet");const bo="-transition";class StyleLayer extends Evented{constructor(e,t){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==e.type&&(this.metadata=(e=e).metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&"sky"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),t.layout&&(this._unevaluatedLayout=new Layout(t.layout)),t.paint)){this._transitionablePaint=new Transitionable(t.paint);for(const t in e.paint)this.setPaintProperty(t,e.paint[t],{validate:!1});for(const t in e.layout)this.setLayoutProperty(t,e.layout[t],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new PossiblyEvaluated(t.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t,i={}){null!=t&&this._validate(yn,`layers.${this.id}.layout.${e}`,e,t,i)||("visibility"!==e?this._unevaluatedLayout.setValue(e,t):this.visibility=t)}getPaintProperty(e){return M(e,bo)?this._transitionablePaint.getTransition(e.slice(0,-bo.length)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t,i={}){if(null!=t&&this._validate(gn,`layers.${this.id}.paint.${e}`,e,t,i))return!1;if(M(e,bo))return this._transitionablePaint.setTransition(e.slice(0,-bo.length),t||void 0),!1;{const i=this._transitionablePaint._values[e],r="cross-faded-data-driven"===i.property.specification["property-type"],n=i.value.isDataDriven(),o=i.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);const a=this._transitionablePaint._values[e].value;return a.isDataDriven()||n||r||this._handleOverridablePaintPropertyUpdate(e,o,a)}}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getProgramConfiguration(e){return null}_handleOverridablePaintPropertyUpdate(e,t,i){return!1}isHidden(e){return!!(this.minzoom&&e<this.minzoom)||!!(this.maxzoom&&e>=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){const e={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&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),D(e,((e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length)))}_validate(e,t,i,r,n={}){return(!n||!1!==n.validate)&&vn(this,e.call(un,{key:t,layerType:this.type,objectKey:i,value:r,styleSpec:ct,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof PossiblyEvaluatedPropertyValue&&pr(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=Rr(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const wo=eo([{name:"a_pos",components:2,type:"Int16"}],4),To=eo([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class SegmentVector{constructor(e=[]){this.segments=e}prepareSegment(e,t,i,r){let n=this.segments[this.segments.length-1];return e>SegmentVector.MAX_VERTEX_ARRAY_LENGTH&&B(`Max vertices per segment is ${SegmentVector.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!n||n.vertexLength+e>SegmentVector.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==r)&&(n={vertexOffset:t.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0},void 0!==r&&(n.sortKey=r),this.segments.push(n)),n}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy()}static simpleSegment(e,t,i,r){return new SegmentVector([{vertexOffset:e,primitiveOffset:t,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}SegmentVector.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,En(SegmentVector,"SegmentVector");var Eo=8192;class LngLatBounds{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1]))}setNorthEast(e){return this._ne=e instanceof LngLat?new LngLat(e.lng,e.lat):LngLat.convert(e),this}setSouthWest(e){return this._sw=e instanceof LngLat?new LngLat(e.lng,e.lat):LngLat.convert(e),this}extend(e){const t=this._sw,i=this._ne;let r,n;if(e instanceof LngLat)r=e,n=e;else{if(!(e instanceof LngLatBounds))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(LngLatBounds.convert(e)):this.extend(LngLat.convert(e)):this;if(r=e._sw,n=e._ne,!r||!n)return this}return t||i?(t.lng=Math.min(r.lng,t.lng),t.lat=Math.min(r.lat,t.lat),i.lng=Math.max(n.lng,i.lng),i.lat=Math.max(n.lat,i.lat)):(this._sw=new LngLat(r.lng,r.lat),this._ne=new LngLat(n.lng,n.lat)),this}getCenter(){return new LngLat((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 LngLat(this.getWest(),this.getNorth())}getSouthEast(){return new LngLat(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(e){const{lng:t,lat:i}=LngLat.convert(e);let r=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&r}static convert(e){return!e||e instanceof LngLatBounds?e:new LngLatBounds(e)}}const So=6371008.8;class LngLat{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new LngLat(y(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const t=Math.PI/180,i=this.lat*t,r=e.lat*t,n=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return So*Math.acos(Math.min(n,1))}toBounds(e=0){const t=360*e/40075017,i=t/Math.cos(Math.PI/180*this.lat);return new LngLatBounds(new LngLat(this.lng-i,this.lat-t),new LngLat(this.lng+i,this.lat+t))}static convert(e){if(e instanceof LngLat)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new LngLat(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new LngLat(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const Ao=2*Math.PI*So;function Co(e){return Ao*Math.cos(e*Math.PI/180)}function Io(e){return(180+e)/360}function Mo(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Po(e,t){return e/Co(t)}function Do(e){return 360*e-180}function zo(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function ko(e,t){return e*Co(zo(t))}const Lo=85.051129;function Bo(e){return 1/Math.cos(e*Math.PI/180)}class MercatorCoordinate{constructor(e,t,i=0){this.x=+e,this.y=+t,this.z=+i}static fromLngLat(e,t=0){const i=LngLat.convert(e);return new MercatorCoordinate(Io(i.lng),Mo(i.lat),Po(t,i.lat))}toLngLat(){return new LngLat(Do(this.x),zo(this.y))}toAltitude(){return ko(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Ao*Bo(zo(this.y))}}function Ro(e,t,i,n,o,a,s,l,c){const u=(t+n)/2,h=(i+o)/2,p=new r(u,h);l(p),function(e,t,i,r,n,o){const a=i-n,s=r-o;return Math.abs((r-t)*a-(i-e)*s)/Math.hypot(a,s)}(p.x,p.y,a.x,a.y,s.x,s.y)>=c?(Ro(e,t,i,u,h,a,p,l,c),Ro(e,u,h,n,o,p,s,l,c)):e.push(s)}function Fo(e,t,i){let r=e[0],n=r.x,o=r.y;t(r);const a=[r];for(let s=1;s<e.length;s++){const l=e[s],{x:c,y:u}=l;t(l),Ro(a,n,o,c,u,r,l,t,i),n=c,o=u,r=l}return a}function Oo(e,t,i,r,n){if(n(t,i)){const o=t.add(i).mult(.5);r(o),Oo(e,t,o,r,n),Oo(e,o,i,r,n)}else e.push(i)}function Vo(e,t,i){let r=e[0];t(r);const n=[r];for(let o=1;o<e.length;o++){const a=e[o];t(a),Oo(n,r,a,t,i),r=a}return n}const Uo=Math.pow(2,14)-1,jo=-Uo-1;function No(e,t){const i=Math.round(e.x*t),r=Math.round(e.y*t);return e.x=_(i,jo,Uo),e.y=_(r,jo,Uo),(i<e.x||i>e.x+1||r<e.y||r>e.y+1)&&B("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function Go(e,t,i){const r=e.loadGeometry(),n=e.extent,o=Eo/n;if(t&&i&&i.projection.isReprojectedInTileSpace){const o=1<<t.z,{scale:a,x:s,y:l,projection:c}=i,u=e=>{const i=Do((t.x+e.x/n)/o),r=zo((t.y+e.y/n)/o),u=c.project(i,r);e.x=(u.x*a-s)*n,e.y=(u.y*a-l)*n};for(let t=0;t<r.length;t++)if(1!==e.type)r[t]=Fo(r[t],u,1);else{const e=[];for(const i of r[t])i.x<0||i.x>=n||i.y<0||i.y>=n||(u(i),e.push(i));r[t]=e}}for(const e of r)for(const t of e)No(t,o);return r}function Zo(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Go(e):[]}}function qo(e,t,i,r,n){e.emplaceBack(2*t+(r+1)/2,2*i+(n+1)/2)}function $o(e,t,i){const r=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*r,i[1]*r,i[2]*r)}class CircleBucket{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new StructArrayLayout2i4,this.indexArray=new StructArrayLayout3ui6,this.segments=new SegmentVector,this.programConfigurations=new ProgramConfigurationSet(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,i,r){const n=this.layers[0],o=[];let a=null;"circle"===n.type&&(a=n.layout.get("circle-sort-key"));for(const{feature:t,id:n,index:s,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Zo(t,e);if(!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom),c,i))continue;const u=a?a.evaluate(c,{},i):void 0,h={id:n,properties:t.properties,type:t.type,sourceLayerIndex:l,index:s,geometry:e?c.geometry:Go(t,i,r),patterns:{},sortKey:u};o.push(h)}a&&o.sort(((e,t)=>e.sortKey-t.sortKey));let s=null;"globe"===r.projection.name&&(this.globeExtVertexArray=new CircleGlobeExtArray,s=r.projection);for(const r of o){const{geometry:n,index:o,sourceLayerIndex:a}=r,l=e[o].feature;this.addFeature(r,n,o,t.availableImages,i,s),t.featureIndex.insert(l,n,o,a,this.index)}}update(e,t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,wo.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,To.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(e,t,i,r,n,o){for(const i of t)for(const t of i){const i=t.x,r=t.y;if(i<0||i>=Eo||r<0||r>=Eo)continue;if(o){const e=o.projectTilePoint(i,r,n),t=o.upVector(n,i,r),a=this.globeExtVertexArray;$o(a,e,t),$o(a,e,t),$o(a,e,t),$o(a,e,t)}const a=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),s=a.vertexLength;qo(this.layoutVertexArray,i,r,-1,-1),qo(this.layoutVertexArray,i,r,1,-1),qo(this.layoutVertexArray,i,r,1,1),qo(this.layoutVertexArray,i,r,-1,1),this.indexArray.emplaceBack(s,s+1,s+2),this.indexArray.emplaceBack(s,s+2,s+3),a.vertexLength+=4,a.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{},r,n)}}function Wo(e,t){for(let i=0;i<e.length;i++)if(ia(t,e[i]))return!0;for(let i=0;i<t.length;i++)if(ia(e,t[i]))return!0;return!!Jo(e,t)}function Ho(e,t,i){return!!ia(e,t)||!!Qo(t,e,i)}function Xo(e,t){if(1===e.length)return ta(t,e[0]);for(let i=0;i<t.length;i++){const r=t[i];for(let t=0;t<r.length;t++)if(ia(e,r[t]))return!0}for(let i=0;i<e.length;i++)if(ta(t,e[i]))return!0;for(let i=0;i<t.length;i++)if(Jo(e,t[i]))return!0;return!1}function Ko(e,t,i){if(e.length>1){if(Jo(e,t))return!0;for(let r=0;r<t.length;r++)if(Qo(t[r],e,i))return!0}for(let r=0;r<e.length;r++)if(Qo(e[r],t,i))return!0;return!1}function Jo(e,t){if(0===e.length||0===t.length)return!1;for(let i=0;i<e.length-1;i++){const r=e[i],n=e[i+1];for(let e=0;e<t.length-1;e++)if(Yo(r,n,t[e],t[e+1]))return!0}return!1}function Yo(e,t,i,r){return R(e,i,r)!==R(t,i,r)&&R(e,t,i)!==R(e,t,r)}function Qo(e,t,i){const r=i*i;if(1===t.length)return e.distSqr(t[0])<r;for(let i=1;i<t.length;i++)if(ea(e,t[i-1],t[i])<r)return!0;return!1}function ea(e,t,i){const r=t.distSqr(i);if(0===r)return e.distSqr(t);const n=((e.x-t.x)*(i.x-t.x)+(e.y-t.y)*(i.y-t.y))/r;return e.distSqr(n<0?t:n>1?i:i.sub(t)._mult(n)._add(t))}function ta(e,t){let i,r,n,o=!1;for(let a=0;a<e.length;a++){i=e[a];for(let e=0,a=i.length-1;e<i.length;a=e++)r=i[e],n=i[a],r.y>t.y!=n.y>t.y&&t.x<(n.x-r.x)*(t.y-r.y)/(n.y-r.y)+r.x&&(o=!o)}return o}function ia(e,t){let i=!1;for(let r=0,n=e.length-1;r<e.length;n=r++){const o=e[r],a=e[n];o.y>t.y!=a.y>t.y&&t.x<(a.x-o.x)*(t.y-o.y)/(a.y-o.y)+o.x&&(i=!i)}return i}function ra(e,t,i,n,o){for(const r of e)if(t<=r.x&&i<=r.y&&n>=r.x&&o>=r.y)return!0;const a=[new r(t,i),new r(t,o),new r(n,o),new r(n,i)];if(e.length>2)for(const t of a)if(ia(e,t))return!0;for(let t=0;t<e.length-1;t++)if(na(e[t],e[t+1],a))return!0;return!1}function na(e,t,i){const r=i[0],n=i[2];if(e.x<r.x&&t.x<r.x||e.x>n.x&&t.x>n.x||e.y<r.y&&t.y<r.y||e.y>n.y&&t.y>n.y)return!1;const o=R(e,t,i[0]);return o!==R(e,t,i[1])||o!==R(e,t,i[2])||o!==R(e,t,i[3])}function oa(e,t,i){const r=t.paint.get(e).value;return"constant"===r.kind?r.value:i.programConfigurations.get(t.id).getMaxValue(e)}function aa(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function sa(e,t,i,n,o){if(!t[0]&&!t[1])return e;const a=r.convert(t)._mult(o);"viewport"===i&&a._rotate(-n);const s=[];for(let t=0;t<e.length;t++)s.push(e[t].sub(a));return s}function la(e,t,i,n){const o=r.convert(e)._mult(n);return"viewport"===t&&o._rotate(-i),o}En(CircleBucket,"CircleBucket",{omit:["layers"]});const ca=new Properties({"circle-sort-key":new DataDrivenProperty(ct.layout_circle["circle-sort-key"])});var ua={paint:new Properties({"circle-radius":new DataDrivenProperty(ct.paint_circle["circle-radius"]),"circle-color":new DataDrivenProperty(ct.paint_circle["circle-color"]),"circle-blur":new DataDrivenProperty(ct.paint_circle["circle-blur"]),"circle-opacity":new DataDrivenProperty(ct.paint_circle["circle-opacity"]),"circle-translate":new DataConstantProperty(ct.paint_circle["circle-translate"]),"circle-translate-anchor":new DataConstantProperty(ct.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new DataConstantProperty(ct.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new DataConstantProperty(ct.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new DataDrivenProperty(ct.paint_circle["circle-stroke-width"]),"circle-stroke-color":new DataDrivenProperty(ct.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new DataDrivenProperty(ct.paint_circle["circle-stroke-opacity"])}),layout:ca},ha=1e-6,pa="undefined"!=typeof Float32Array?Float32Array:Array;function da(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],a=i*o-n*r;return a?(e[0]=o*(a=1/a),e[1]=-r*a,e[2]=-n*a,e[3]=i*a,e):null}function fa(){var e=new pa(9);return pa!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function ma(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],a=t[4],s=t[5],l=t[6],c=t[7],u=t[8];return e[0]=a*u-s*c,e[1]=n*c-r*u,e[2]=r*s-n*a,e[3]=s*l-o*u,e[4]=i*u-n*l,e[5]=n*o-i*s,e[6]=o*c-a*l,e[7]=r*l-i*c,e[8]=i*a-r*o,e}function _a(e,t,i){var r=t[0],n=t[1],o=t[2],a=t[3],s=t[4],l=t[5],c=t[6],u=t[7],h=t[8],p=i[0],d=i[1],f=i[2],m=i[3],_=i[4],g=i[5],y=i[6],x=i[7],v=i[8];return e[0]=p*r+d*a+f*c,e[1]=p*n+d*s+f*u,e[2]=p*o+d*l+f*h,e[3]=m*r+_*a+g*c,e[4]=m*n+_*s+g*u,e[5]=m*o+_*l+g*h,e[6]=y*r+x*a+v*c,e[7]=y*n+x*s+v*u,e[8]=y*o+x*l+v*h,e}function ga(){var e=new pa(16);return pa!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function ya(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function xa(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],a=t[4],s=t[5],l=t[6],c=t[7],u=t[8],h=t[9],p=t[10],d=t[11],f=t[12],m=t[13],_=t[14],g=t[15],y=i*s-r*a,x=i*l-n*a,v=i*c-o*a,b=r*l-n*s,w=r*c-o*s,T=n*c-o*l,E=u*m-h*f,S=u*_-p*f,A=u*g-d*f,C=h*_-p*m,I=h*g-d*m,M=p*g-d*_,P=y*M-x*I+v*C+b*A-w*S+T*E;return P?(e[0]=(s*M-l*I+c*C)*(P=1/P),e[1]=(n*I-r*M-o*C)*P,e[2]=(m*T-_*w+g*b)*P,e[3]=(p*w-h*T-d*b)*P,e[4]=(l*A-a*M-c*S)*P,e[5]=(i*M-n*A+o*S)*P,e[6]=(_*v-f*T-g*x)*P,e[7]=(u*T-p*v+d*x)*P,e[8]=(a*I-s*A+c*E)*P,e[9]=(r*A-i*I-o*E)*P,e[10]=(f*w-m*v+g*y)*P,e[11]=(h*v-u*w-d*y)*P,e[12]=(s*S-a*C-l*E)*P,e[13]=(i*C-r*S+n*E)*P,e[14]=(m*x-f*b-_*y)*P,e[15]=(u*b-h*x+p*y)*P,e):null}function va(e,t,i){var r=t[0],n=t[1],o=t[2],a=t[3],s=t[4],l=t[5],c=t[6],u=t[7],h=t[8],p=t[9],d=t[10],f=t[11],m=t[12],_=t[13],g=t[14],y=t[15],x=i[0],v=i[1],b=i[2],w=i[3];return e[0]=x*r+v*s+b*h+w*m,e[1]=x*n+v*l+b*p+w*_,e[2]=x*o+v*c+b*d+w*g,e[3]=x*a+v*u+b*f+w*y,e[4]=(x=i[4])*r+(v=i[5])*s+(b=i[6])*h+(w=i[7])*m,e[5]=x*n+v*l+b*p+w*_,e[6]=x*o+v*c+b*d+w*g,e[7]=x*a+v*u+b*f+w*y,e[8]=(x=i[8])*r+(v=i[9])*s+(b=i[10])*h+(w=i[11])*m,e[9]=x*n+v*l+b*p+w*_,e[10]=x*o+v*c+b*d+w*g,e[11]=x*a+v*u+b*f+w*y,e[12]=(x=i[12])*r+(v=i[13])*s+(b=i[14])*h+(w=i[15])*m,e[13]=x*n+v*l+b*p+w*_,e[14]=x*o+v*c+b*d+w*g,e[15]=x*a+v*u+b*f+w*y,e}function ba(e,t,i){var r,n,o,a,s,l,c,u,h,p,d,f,m=i[0],_=i[1],g=i[2];return t===e?(e[12]=t[0]*m+t[4]*_+t[8]*g+t[12],e[13]=t[1]*m+t[5]*_+t[9]*g+t[13],e[14]=t[2]*m+t[6]*_+t[10]*g+t[14],e[15]=t[3]*m+t[7]*_+t[11]*g+t[15]):(n=t[1],o=t[2],a=t[3],s=t[4],l=t[5],c=t[6],u=t[7],h=t[8],p=t[9],d=t[10],f=t[11],e[0]=r=t[0],e[1]=n,e[2]=o,e[3]=a,e[4]=s,e[5]=l,e[6]=c,e[7]=u,e[8]=h,e[9]=p,e[10]=d,e[11]=f,e[12]=r*m+s*_+h*g+t[12],e[13]=n*m+l*_+p*g+t[13],e[14]=o*m+c*_+d*g+t[14],e[15]=a*m+u*_+f*g+t[15]),e}function wa(e,t,i){var r=i[0],n=i[1],o=i[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Ta(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[4],a=t[5],s=t[6],l=t[7],c=t[8],u=t[9],h=t[10],p=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=o*n+c*r,e[5]=a*n+u*r,e[6]=s*n+h*r,e[7]=l*n+p*r,e[8]=c*n-o*r,e[9]=u*n-a*r,e[10]=h*n-s*r,e[11]=p*n-l*r,e}function Ea(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[0],a=t[1],s=t[2],l=t[3],c=t[8],u=t[9],h=t[10],p=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*n-c*r,e[1]=a*n-u*r,e[2]=s*n-h*r,e[3]=l*n-p*r,e[8]=o*r+c*n,e[9]=a*r+u*n,e[10]=s*r+h*n,e[11]=l*r+p*n,e}function Sa(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[0],a=t[1],s=t[2],l=t[3],c=t[4],u=t[5],h=t[6],p=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*n+c*r,e[1]=a*n+u*r,e[2]=s*n+h*r,e[3]=l*n+p*r,e[4]=c*n-o*r,e[5]=u*n-a*r,e[6]=h*n-s*r,e[7]=p*n-l*r,e}function Aa(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Ca(e,t,i){var r,n,o,a=i[0],s=i[1],l=i[2],c=Math.hypot(a,s,l);return c<ha?null:(a*=c=1/c,s*=c,l*=c,r=Math.sin(t),n=Math.cos(t),e[0]=a*a*(o=1-n)+n,e[1]=s*a*o+l*r,e[2]=l*a*o-s*r,e[3]=0,e[4]=a*s*o-l*r,e[5]=s*s*o+n,e[6]=l*s*o+a*r,e[7]=0,e[8]=a*l*o+s*r,e[9]=s*l*o-a*r,e[10]=l*l*o+n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function Ia(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],a=i+i,s=r+r,l=n+n,c=i*a,u=r*a,h=r*s,p=n*a,d=n*s,f=n*l,m=o*a,_=o*s,g=o*l;return e[0]=1-h-f,e[1]=u+g,e[2]=p-_,e[3]=0,e[4]=u-g,e[5]=1-c-f,e[6]=d+m,e[7]=0,e[8]=p+_,e[9]=d-m,e[10]=1-c-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var Ma=function(e,t,i,r,n){var o,a=1/Math.tan(t/2);return e[0]=a/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=n&&n!==1/0?(e[10]=(n+r)*(o=1/(r-n)),e[14]=2*n*r*o):(e[10]=-1,e[14]=-2*r),e},Pa=function(e,t,i,r,n,o,a){var s=1/(t-i),l=1/(r-n),c=1/(o-a);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+i)*s,e[13]=(n+r)*l,e[14]=(a+o)*c,e[15]=1,e},Da=va;function za(){var e=new pa(3);return pa!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function ka(e){var t=new pa(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function La(e){return Math.hypot(e[0],e[1],e[2])}function Ba(e,t,i){var r=new pa(3);return r[0]=e,r[1]=t,r[2]=i,r}function Ra(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e}function Fa(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}function Oa(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e}function Va(e,t,i){return e[0]=Math.min(t[0],i[0]),e[1]=Math.min(t[1],i[1]),e[2]=Math.min(t[2],i[2]),e}function Ua(e,t,i){return e[0]=Math.max(t[0],i[0]),e[1]=Math.max(t[1],i[1]),e[2]=Math.max(t[2],i[2]),e}function ja(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function Na(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e}function Ga(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2])}function Za(e,t){var i=t[0],r=t[1],n=t[2],o=i*i+r*r+n*n;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function qa(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function $a(e,t,i){var r=t[0],n=t[1],o=t[2],a=i[0],s=i[1],l=i[2];return e[0]=n*l-o*s,e[1]=o*a-r*l,e[2]=r*s-n*a,e}function Wa(e,t,i){var r=t[0],n=t[1],o=t[2],a=i[3]*r+i[7]*n+i[11]*o+i[15];return e[0]=(i[0]*r+i[4]*n+i[8]*o+i[12])/(a=a||1),e[1]=(i[1]*r+i[5]*n+i[9]*o+i[13])/a,e[2]=(i[2]*r+i[6]*n+i[10]*o+i[14])/a,e}function Ha(e,t,i){var r=t[0],n=t[1],o=t[2];return e[0]=r*i[0]+n*i[3]+o*i[6],e[1]=r*i[1]+n*i[4]+o*i[7],e[2]=r*i[2]+n*i[5]+o*i[8],e}function Xa(e,t,i){var r=i[0],n=i[1],o=i[2],a=t[0],s=t[1],l=t[2],c=n*l-o*s,u=o*a-r*l,h=r*s-n*a,p=n*h-o*u,d=o*c-r*h,f=r*u-n*c,m=2*i[3];return u*=m,h*=m,d*=2,f*=2,e[0]=a+(c*=m)+(p*=2),e[1]=s+u+d,e[2]=l+h+f,e}var Ka,Ja=Fa,Ya=Oa,Qa=function(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e[2]=t[2]/i[2],e},es=La;function ts(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e}function is(e,t,i){var r=t[0],n=t[1],o=t[2],a=t[3];return e[0]=i[0]*r+i[4]*n+i[8]*o+i[12]*a,e[1]=i[1]*r+i[5]*n+i[9]*o+i[13]*a,e[2]=i[2]*r+i[6]*n+i[10]*o+i[14]*a,e[3]=i[3]*r+i[7]*n+i[11]*o+i[15]*a,e}function rs(){var e=new pa(4);return pa!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function ns(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function os(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],a=t[3],s=Math.sin(i),l=Math.cos(i);return e[0]=r*l+a*s,e[1]=n*l+o*s,e[2]=o*l-n*s,e[3]=a*l-r*s,e}function as(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],a=t[3],s=Math.sin(i),l=Math.cos(i);return e[0]=r*l-o*s,e[1]=n*l+a*s,e[2]=o*l+r*s,e[3]=a*l-n*s,e}function ss(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],a=t[3],s=Math.sin(i),l=Math.cos(i);return e[0]=r*l+n*s,e[1]=n*l-r*s,e[2]=o*l+a*s,e[3]=a*l-o*s,e}za(),Ka=new pa(4),pa!=Float32Array&&(Ka[0]=0,Ka[1]=0,Ka[2]=0,Ka[3]=0),za(),Ba(1,0,0),Ba(0,1,0),rs(),rs(),fa();class Ray{constructor(e,t){this.pos=e,this.dir=t}intersectsPlane(e,t,i){const r=qa(t,this.dir);if(Math.abs(r)<1e-6)return!1;const n=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1]+(e[2]-this.pos[2])*t[2])/r;return i[0]=this.pos[0]+this.dir[0]*n,i[1]=this.pos[1]+this.dir[1]*n,i[2]=this.pos[2]+this.dir[2]*n,!0}closestPointOnSphere(e,t,i){if(function(e,t){var i=e[0],r=e[1],n=e[2],o=t[0],a=t[1],s=t[2];return Math.abs(i-o)<=ha*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(r-a)<=ha*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(n-s)<=ha*Math.max(1,Math.abs(n),Math.abs(s))}(this.pos,e)||0===t)return i[0]=i[1]=i[2]=0,!1;const[r,n,o]=this.dir,a=this.pos[0]-e[0],s=this.pos[1]-e[1],l=this.pos[2]-e[2],c=r*r+n*n+o*o,u=2*(a*r+s*n+l*o),h=u*u-4*c*(a*a+s*s+l*l-t*t);if(h<0){const e=Math.max(-u/2,0),c=a+r*e,h=s+n*e,p=l+o*e,d=Math.hypot(c,h,p);return i[0]=c*t/d,i[1]=h*t/d,i[2]=p*t/d,!1}{const e=(-u-Math.sqrt(h))/(2*c);if(e<0){const e=Math.hypot(a,s,l);return i[0]=a*t/e,i[1]=s*t/e,i[2]=l*t/e,!1}return i[0]=a+r*e,i[1]=s+n*e,i[2]=l+o*e,!0}}}class FrustumCorners{constructor(e,t,i,r,n){this.TL=e,this.TR=t,this.BR=i,this.BL=r,this.horizon=n}static fromInvProjectionMatrix(e,t,i){const r=[-1,1,1],n=[1,1,1],o=[1,-1,1],a=[-1,-1,1],s=Wa(r,r,e),l=Wa(n,n,e),c=Wa(o,o,e),u=Wa(a,a,e);return new FrustumCorners(s,l,c,u,t/i)}}class Frustum{constructor(e,t){this.points=e,this.planes=t}static fromInvProjectionMatrix(e,t,i,r){const n=Math.pow(2,i),o=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((i=>{const o=is([],i,e),a=1/o[3]/t*n;return function(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e[3]=t[3]*i[3],e}(o,o,[a,a,r?1/o[3]:a,a])})),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const t=Za([],$a([],Ja([],o[e[0]],o[e[1]]),Ja([],o[e[2]],o[e[1]]))),i=-qa(t,o[e[1]]);return t.concat(i)}));return new Frustum(o,a)}}class Aabb{static fromPoints(e){const t=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],i=[Number.MIN_VALUE,Number.MIN_VALUE,Number.MIN_VALUE];for(const r of e)t[0]=Math.min(t[0],r[0]),t[1]=Math.min(t[1],r[1]),t[2]=Math.min(t[2],r[2]),i[0]=Math.max(i[0],r[0]),i[1]=Math.max(i[1],r[1]),i[2]=Math.max(i[2],r[2]);return new Aabb(t,i)}constructor(e,t){this.min=e,this.max=t,this.center=ja([],Ra([],this.min,this.max),.5)}quadrant(e){const t=[e%2==0,e<2],i=ka(this.min),r=ka(this.max);for(let e=0;e<t.length;e++)i[e]=t[e]?this.min[e]:this.center[e],r[e]=t[e]?this.center[e]:this.max[e];return r[2]=this.max[2],new Aabb(i,r)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}distanceZ(e){return Math.max(Math.min(this.max[2],e[2]),this.min[2])-e[2]}getCorners(){const e=this.min,t=this.max;return[[e[0],e[1],e[2]],[t[0],e[1],e[2]],[t[0],t[1],e[2]],[e[0],t[1],e[2]],[e[0],e[1],t[2]],[t[0],e[1],t[2]],[t[0],t[1],t[2]],[e[0],t[1],t[2]]]}intersects(e){const t=this.getCorners();let i=!0;for(let r=0;r<e.planes.length;r++){const n=e.planes[r];let o=0;for(let e=0;e<t.length;e++)o+=qa(n,t[e])+n[3]>=0;if(0===o)return 0;o!==t.length&&(i=!1)}if(i)return 2;for(let t=0;t<3;t++){let i=Number.MAX_VALUE,r=-Number.MAX_VALUE;for(let n=0;n<e.points.length;n++){const o=e.points[n][t]-this.min[t];i=Math.min(i,o),r=Math.max(r,o)}if(r<0||i>this.max[t]-this.min[t])return 0}return 1}}function ls(e,t,i,r,n,o,a,s,l){if(o&&e.queryGeometry.isAboveHorizon)return!1;o&&(l*=e.pixelToTileUnitsFactor);const c=e.tileID.canonical,u=i.projection.upVectorScale(c,i.center.lat,i.worldSize).metersToTile;for(const h of t)for(const t of h){const h=t.add(s),p=n&&i.elevation?i.elevation.exaggeration()*n.getElevationAt(h.x,h.y,!0):0,d=i.projection.projectTilePoint(h.x,h.y,c);if(p>0){const e=i.projection.upVector(c,h.x,h.y);d.x+=e[0]*u*p,d.y+=e[1]*u*p,d.z+=e[2]*u*p}const f=o?h:cs(d.x,d.y,d.z,r),m=o?e.tilespaceRays.map((e=>ps(e,p))):e.queryGeometry.screenGeometry,_=is([],[d.x,d.y,d.z,1],r);if(!a&&o?l*=_[3]/i.cameraToCenterDistance:a&&!o&&(l*=i.cameraToCenterDistance/_[3]),o){const e=zo((t.y/Eo+c.y)/(1<<c.z));l/=i.projection.pixelsPerMeter(e,1)/Po(1,e)}if(Ho(m,f,l))return!0}return!1}function cs(e,t,i,n){const o=is([],[e,t,i,1],n);return new r(o[0]/o[3],o[1]/o[3])}const us=Ba(0,0,0),hs=Ba(0,0,1);function ps(e,t){const i=za();return us[2]=t,e.intersectsPlane(us,hs,i),new r(i[0],i[1])}class HeatmapBucket extends CircleBucket{}function ds(e,{width:t,height:i},r,n){if(n){if(n instanceof Uint8ClampedArray)n=new Uint8Array(n.buffer);else if(n.length!==t*i*r)throw new RangeError("mismatched image size")}else n=new Uint8Array(t*i*r);return e.width=t,e.height=i,e.data=n,e}function fs(e,t,i){const{width:r,height:n}=t;r===e.width&&n===e.height||(ms(e,t,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,r),height:Math.min(e.height,n)},i),e.width=r,e.height=n,e.data=t.data)}function ms(e,t,i,r,n,o){if(0===n.width||0===n.height)return t;if(n.width>e.width||n.height>e.height||i.x>e.width-n.width||i.y>e.height-n.height)throw new RangeError("out of range source coordinates for image copy");if(n.width>t.width||n.height>t.height||r.x>t.width-n.width||r.y>t.height-n.height)throw new RangeError("out of range destination coordinates for image copy");const a=e.data,s=t.data;for(let l=0;l<n.height;l++){const c=((i.y+l)*e.width+i.x)*o,u=((r.y+l)*t.width+r.x)*o;for(let e=0;e<n.width*o;e++)s[u+e]=a[c+e]}return t}En(HeatmapBucket,"HeatmapBucket",{omit:["layers"]});class AlphaImage{constructor(e,t){ds(this,e,1,t)}resize(e){fs(this,new AlphaImage(e),1)}clone(){return new AlphaImage({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,r,n){ms(e,t,i,r,n,1)}}class RGBAImage{constructor(e,t){ds(this,e,4,t)}resize(e){fs(this,new RGBAImage(e),4)}replace(e,t){t?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new RGBAImage({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,r,n){ms(e,t,i,r,n,4)}}En(AlphaImage,"AlphaImage"),En(RGBAImage,"RGBAImage");var _s={paint:new Properties({"heatmap-radius":new DataDrivenProperty(ct.paint_heatmap["heatmap-radius"]),"heatmap-weight":new DataDrivenProperty(ct.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new DataConstantProperty(ct.paint_heatmap["heatmap-intensity"]),"heatmap-color":new ColorRampProperty(ct.paint_heatmap["heatmap-color"]),"heatmap-opacity":new DataConstantProperty(ct.paint_heatmap["heatmap-opacity"])})};function gs(e){const t={},i=e.resolution||256,r=e.clips?e.clips.length:1,n=e.image||new RGBAImage({width:i,height:r}),o=(i,r,o)=>{t[e.evaluationKey]=o;const a=e.expression.evaluate(t);n.data[i+r+0]=Math.floor(255*a.r/a.a),n.data[i+r+1]=Math.floor(255*a.g/a.a),n.data[i+r+2]=Math.floor(255*a.b/a.a),n.data[i+r+3]=Math.floor(255*a.a)};if(e.clips)for(let t=0,n=0;t<r;++t,n+=4*i)for(let r=0,a=0;r<i;r++,a+=4){const s=r/(i-1),{start:l,end:c}=e.clips[t];o(n,a,l*(1-s)+c*s)}else for(let e=0,t=0;e<i;e++,t+=4)o(0,t,e/(i-1));return n}var ys={paint:new Properties({"hillshade-illumination-direction":new DataConstantProperty(ct.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new DataConstantProperty(ct.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new DataConstantProperty(ct.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new DataConstantProperty(ct.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new DataConstantProperty(ct.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new DataConstantProperty(ct.paint_hillshade["hillshade-accent-color"])})};const xs=eo([{name:"a_pos",components:2,type:"Int16"}],4),{members:vs}=xs;var bs=Ts,ws=Ts;function Ts(e,t,i){i=i||2;var r,n,o,a,s,l,c,u=t&&t.length,h=u?t[0]*i:e.length,p=Es(e,0,h,i,!0),d=[];if(!p||p.next===p.prev)return d;if(u&&(p=function(e,t,i,r){var n,o,a,s=[];for(n=0,o=t.length;n<o;n++)(a=Es(e,t[n]*r,n<o-1?t[n+1]*r:e.length,r,!1))===a.next&&(a.steiner=!0),s.push(Bs(a));for(s.sort(Ds),n=0;n<s.length;n++)i=zs(s[n],i);return i}(e,t,p,i)),e.length>80*i){r=o=e[0],n=a=e[1];for(var f=i;f<h;f+=i)(s=e[f])<r&&(r=s),(l=e[f+1])<n&&(n=l),s>o&&(o=s),l>a&&(a=l);c=0!==(c=Math.max(o-r,a-n))?32767/c:0}return As(p,d,i,r,n,c,0),d}function Es(e,t,i,r,n){var o,a;if(n===Hs(e,t,i,r)>0)for(o=t;o<i;o+=r)a=qs(o,e[o],e[o+1],a);else for(o=i-r;o>=t;o-=r)a=qs(o,e[o],e[o+1],a);return a&&Vs(a,a.next)&&($s(a),a=a.next),a}function Ss(e,t){if(!e)return e;t||(t=e);var i,r=e;do{if(i=!1,r.steiner||!Vs(r,r.next)&&0!==Os(r.prev,r,r.next))r=r.next;else{if($s(r),(r=t=r.prev)===r.next)break;i=!0}}while(i||r!==t);return t}function As(e,t,i,r,n,o,a){if(e){!a&&o&&function(e,t,i,r){var n=e;do{0===n.z&&(n.z=Ls(n.x,n.y,t,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,function(e){var t,i,r,n,o,a,s,l,c=1;do{for(i=e,e=null,o=null,a=0;i;){for(a++,r=i,s=0,t=0;t<c&&(s++,r=r.nextZ);t++);for(l=c;s>0||l>0&&r;)0!==s&&(0===l||!r||i.z<=r.z)?(n=i,i=i.nextZ,s--):(n=r,r=r.nextZ,l--),o?o.nextZ=n:e=n,n.prevZ=o,o=n;i=r}o.nextZ=null,c*=2}while(a>1)}(n)}(e,r,n,o);for(var s,l,c=e;e.prev!==e.next;)if(s=e.prev,l=e.next,o?Is(e,r,n,o):Cs(e))t.push(s.i/i|0),t.push(e.i/i|0),t.push(l.i/i|0),$s(e),e=l.next,c=l.next;else if((e=l)===c){a?1===a?As(e=Ms(Ss(e),t,i),t,i,r,n,o,2):2===a&&Ps(e,t,i,r,n,o):As(Ss(e),t,i,r,n,o,1);break}}}function Cs(e){var t=e.prev,i=e,r=e.next;if(Os(t,i,r)>=0)return!1;for(var n=t.x,o=i.x,a=r.x,s=t.y,l=i.y,c=r.y,u=n<o?n<a?n:a:o<a?o:a,h=s<l?s<c?s:c:l<c?l:c,p=n>o?n>a?n:a:o>a?o:a,d=s>l?s>c?s:c:l>c?l:c,f=r.next;f!==t;){if(f.x>=u&&f.x<=p&&f.y>=h&&f.y<=d&&Rs(n,s,o,l,a,c,f.x,f.y)&&Os(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Is(e,t,i,r){var n=e.prev,o=e,a=e.next;if(Os(n,o,a)>=0)return!1;for(var s=n.x,l=o.x,c=a.x,u=n.y,h=o.y,p=a.y,d=s<l?s<c?s:c:l<c?l:c,f=u<h?u<p?u:p:h<p?h:p,m=s>l?s>c?s:c:l>c?l:c,_=u>h?u>p?u:p:h>p?h:p,g=Ls(d,f,t,i,r),y=Ls(m,_,t,i,r),x=e.prevZ,v=e.nextZ;x&&x.z>=g&&v&&v.z<=y;){if(x.x>=d&&x.x<=m&&x.y>=f&&x.y<=_&&x!==n&&x!==a&&Rs(s,u,l,h,c,p,x.x,x.y)&&Os(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,v.x>=d&&v.x<=m&&v.y>=f&&v.y<=_&&v!==n&&v!==a&&Rs(s,u,l,h,c,p,v.x,v.y)&&Os(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;x&&x.z>=g;){if(x.x>=d&&x.x<=m&&x.y>=f&&x.y<=_&&x!==n&&x!==a&&Rs(s,u,l,h,c,p,x.x,x.y)&&Os(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;v&&v.z<=y;){if(v.x>=d&&v.x<=m&&v.y>=f&&v.y<=_&&v!==n&&v!==a&&Rs(s,u,l,h,c,p,v.x,v.y)&&Os(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Ms(e,t,i){var r=e;do{var n=r.prev,o=r.next.next;!Vs(n,o)&&Us(n,r,r.next,o)&&Gs(n,o)&&Gs(o,n)&&(t.push(n.i/i|0),t.push(r.i/i|0),t.push(o.i/i|0),$s(r),$s(r.next),r=e=o),r=r.next}while(r!==e);return Ss(r)}function Ps(e,t,i,r,n,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&Fs(a,s)){var l=Zs(a,s);return a=Ss(a,a.next),l=Ss(l,l.next),As(a,t,i,r,n,o,0),void As(l,t,i,r,n,o,0)}s=s.next}a=a.next}while(a!==e)}function Ds(e,t){return e.x-t.x}function zs(e,t){var i=function(e,t){var i,r=t,n=e.x,o=e.y,a=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var s=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=n&&s>a&&(a=s,i=r.x<r.next.x?r:r.next,s===n))return i}r=r.next}while(r!==t);if(!i)return null;var l,c=i,u=i.x,h=i.y,p=1/0;r=i;do{n>=r.x&&r.x>=u&&n!==r.x&&Rs(o<h?n:a,o,u,h,o<h?a:n,o,r.x,r.y)&&(l=Math.abs(o-r.y)/(n-r.x),Gs(r,e)&&(l<p||l===p&&(r.x>i.x||r.x===i.x&&ks(i,r)))&&(i=r,p=l)),r=r.next}while(r!==c);return i}(e,t);if(!i)return t;var r=Zs(i,e);return Ss(r,r.next),Ss(i,i.next)}function ks(e,t){return Os(e.prev,e,t.prev)<0&&Os(t.next,e,e.next)<0}function Ls(e,t,i,r,n){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Bs(e){var t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function Rs(e,t,i,r,n,o,a,s){return(n-a)*(t-s)>=(e-a)*(o-s)&&(e-a)*(r-s)>=(i-a)*(t-s)&&(i-a)*(o-s)>=(n-a)*(r-s)}function Fs(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&Us(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(Gs(e,t)&&Gs(t,e)&&function(e,t){var i=e,r=!1,n=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==e);return r}(e,t)&&(Os(e.prev,e,t.prev)||Os(e,t.prev,t))||Vs(e,t)&&Os(e.prev,e,e.next)>0&&Os(t.prev,t,t.next)>0)}function Os(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Vs(e,t){return e.x===t.x&&e.y===t.y}function Us(e,t,i,r){var n=Ns(Os(e,t,i)),o=Ns(Os(e,t,r)),a=Ns(Os(i,r,e)),s=Ns(Os(i,r,t));return n!==o&&a!==s||!(0!==n||!js(e,i,t))||!(0!==o||!js(e,r,t))||!(0!==a||!js(i,e,r))||!(0!==s||!js(i,t,r))}function js(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Ns(e){return e>0?1:e<0?-1:0}function Gs(e,t){return Os(e.prev,e,e.next)<0?Os(e,t,e.next)>=0&&Os(e,e.prev,t)>=0:Os(e,t,e.prev)<0||Os(e,e.next,t)<0}function Zs(e,t){var i=new Ws(e.i,e.x,e.y),r=new Ws(t.i,t.x,t.y),n=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function qs(e,t,i,r){var n=new Ws(e,t,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function $s(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Ws(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Hs(e,t,i,r){for(var n=0,o=t,a=i-r;o<i;o+=r)n+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return n}function Xs(e,t,i,r,n){Ks(e,t,i||0,r||e.length-1,n||Ys)}function Ks(e,t,i,r,n){for(;r>i;){if(r-i>600){var o=r-i+1,a=t-i+1,s=Math.log(o),l=.5*Math.exp(2*s/3),c=.5*Math.sqrt(s*l*(o-l)/o)*(a-o/2<0?-1:1);Ks(e,t,Math.max(i,Math.floor(t-a*l/o+c)),Math.min(r,Math.floor(t+(o-a)*l/o+c)),n)}var u=e[t],h=i,p=r;for(Js(e,i,t),n(e[r],u)>0&&Js(e,i,r);h<p;){for(Js(e,h,p),h++,p--;n(e[h],u)<0;)h++;for(;n(e[p],u)>0;)p--}0===n(e[i],u)?Js(e,i,p):Js(e,++p,r),p<=t&&(i=p+1),t<=p&&(r=p-1)}}function Js(e,t,i){var r=e[t];e[t]=e[i],e[i]=r}function Ys(e,t){return e<t?-1:e>t?1:0}function Qs(e,t){const i=e.length;if(i<=1)return[e];const r=[];let n,o;for(let t=0;t<i;t++){const i=F(e[t]);0!==i&&(e[t].area=Math.abs(i),void 0===o&&(o=i<0),o===i<0?(n&&r.push(n),n=[e[t]]):n.push(e[t]))}if(n&&r.push(n),t>1)for(let e=0;e<r.length;e++)r[e].length<=t||(Xs(r[e],t,1,r[e].length-1,el),r[e]=r[e].slice(0,t));return r}function el(e,t){return t.area-e.area}function tl(e,t,i){const r=i.patternDependencies;let n=!1;for(const i of t){const t=i.paint.get(`${e}-pattern`);t.isConstant()||(n=!0);const o=t.constantOr(null);o&&(n=!0,r[o.to]=!0,r[o.from]=!0)}return n}function il(e,t,i,r,n){const o=n.patternDependencies;for(const a of t){const t=a.paint.get(`${e}-pattern`).value;if("constant"!==t.kind){let e=t.evaluate({zoom:r-1},i,{},n.availableImages),s=t.evaluate({zoom:r},i,{},n.availableImages),l=t.evaluate({zoom:r+1},i,{},n.availableImages);e=e&&e.name?e.name:e,s=s&&s.name?s.name:s,l=l&&l.name?l.name:l,o[e]=!0,o[s]=!0,o[l]=!0,i.patterns[a.id]={min:e,mid:s,max:l}}}return i}Ts.deviation=function(e,t,i,r){var n=t&&t.length,o=Math.abs(Hs(e,0,n?t[0]*i:e.length,i));if(n)for(var a=0,s=t.length;a<s;a++)o-=Math.abs(Hs(e,t[a]*i,a<s-1?t[a+1]*i:e.length,i));var l=0;for(a=0;a<r.length;a+=3){var c=r[a]*i,u=r[a+1]*i,h=r[a+2]*i;l+=Math.abs((e[c]-e[h])*(e[u+1]-e[c+1])-(e[c]-e[u])*(e[h+1]-e[c+1]))}return 0===o&&0===l?0:Math.abs((l-o)/o)},Ts.flatten=function(e){for(var t=e[0][0].length,i={vertices:[],holes:[],dimensions:t},r=0,n=0;n<e.length;n++){for(var o=0;o<e[n].length;o++)for(var a=0;a<t;a++)i.vertices.push(e[n][o][a]);n>0&&i.holes.push(r+=e[n-1].length)}return i},bs.default=ws;class FillBucket{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new StructArrayLayout2i4,this.indexArray=new StructArrayLayout3ui6,this.indexArray2=new StructArrayLayout2ui4,this.programConfigurations=new ProgramConfigurationSet(e.layers,e.zoom),this.segments=new SegmentVector,this.segments2=new SegmentVector,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.projection=e.projection}populate(e,t,i,r){this.hasPattern=tl("fill",this.layers,t);const n=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:a,id:s,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Zo(a,e);if(!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom),u,i))continue;const h=n?n.evaluate(u,{},i,t.availableImages):void 0,p={id:s,properties:a.properties,type:a.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:Go(a,i,r),patterns:{},sortKey:h};o.push(p)}n&&o.sort(((e,t)=>e.sortKey-t.sortKey));for(const r of o){const{geometry:n,index:o,sourceLayerIndex:a}=r;if(this.hasPattern){const e=il("fill",this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,n,o,i,{},t.availableImages);t.featureIndex.insert(e[o].feature,n,o,a,this.index)}}update(e,t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i,r)}addFeatures(e,t,i,r,n){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,vs),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),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(e,t,i,r,n,o=[]){for(const e of Qs(t,500)){let t=0;for(const i of e)t+=i.length;const i=this.segments.prepareSegment(t,this.layoutVertexArray,this.indexArray),r=i.vertexLength,n=[],o=[];for(const t of e){if(0===t.length)continue;t!==e[0]&&o.push(n.length/2);const i=this.segments2.prepareSegment(t.length,this.layoutVertexArray,this.indexArray2),r=i.vertexLength;this.layoutVertexArray.emplaceBack(t[0].x,t[0].y),this.indexArray2.emplaceBack(r+t.length-1,r),n.push(t[0].x),n.push(t[0].y);for(let e=1;e<t.length;e++)this.layoutVertexArray.emplaceBack(t[e].x,t[e].y),this.indexArray2.emplaceBack(r+e-1,r+e),n.push(t[e].x),n.push(t[e].y);i.vertexLength+=t.length,i.primitiveLength+=t.length}const a=bs(n,o);for(let e=0;e<a.length;e+=3)this.indexArray.emplaceBack(r+a[e],r+a[e+1],r+a[e+2]);i.vertexLength+=t,i.primitiveLength+=a.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,n,o,r)}}En(FillBucket,"FillBucket",{omit:["layers","patternFeatures"]});const rl=new Properties({"fill-sort-key":new DataDrivenProperty(ct.layout_fill["fill-sort-key"])});var nl={paint:new Properties({"fill-antialias":new DataConstantProperty(ct.paint_fill["fill-antialias"]),"fill-opacity":new DataDrivenProperty(ct.paint_fill["fill-opacity"]),"fill-color":new DataDrivenProperty(ct.paint_fill["fill-color"]),"fill-outline-color":new DataDrivenProperty(ct.paint_fill["fill-outline-color"]),"fill-translate":new DataConstantProperty(ct.paint_fill["fill-translate"]),"fill-translate-anchor":new DataConstantProperty(ct.paint_fill["fill-translate-anchor"]),"fill-pattern":new CrossFadedDataDrivenProperty(ct.paint_fill["fill-pattern"])}),layout:rl};const ol=eo([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),al=eo([{name:"a_centroid_pos",components:2,type:"Uint16"}]),sl=eo([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:ll}=ol;var cl=ul;function ul(e,t,i,r,n){this.properties={},this.extent=i,this.type=0,this._pbf=e,this._geometry=-1,this._keys=r,this._values=n,e.readFields(hl,this,t)}function hl(e,t,i){1==e?t.id=i.readVarint():2==e?function(e,t){for(var i=e.readVarint()+e.pos;e.pos<i;){var r=t._keys[e.readVarint()],n=t._values[e.readVarint()];t.properties[r]=n}}(i,t):3==e?t.type=i.readVarint():4==e&&(t._geometry=i.pos)}function pl(e){for(var t,i,r=0,n=0,o=e.length,a=o-1;n<o;a=n++)r+=((i=e[a]).x-(t=e[n]).x)*(t.y+i.y);return r}ul.types=["Unknown","Point","LineString","Polygon"],ul.prototype.loadGeometry=function(){var e=this._pbf;e.pos=this._geometry;for(var t,i=e.readVarint()+e.pos,n=1,o=0,a=0,s=0,l=[];e.pos<i;){if(o<=0){var c=e.readVarint();n=7&c,o=c>>3}if(o--,1===n||2===n)a+=e.readSVarint(),s+=e.readSVarint(),1===n&&(t&&l.push(t),t=[]),t.push(new r(a,s));else{if(7!==n)throw new Error("unknown command "+n);t&&t.push(t[0].clone())}}return t&&l.push(t),l},ul.prototype.bbox=function(){var e=this._pbf;e.pos=this._geometry;for(var t=e.readVarint()+e.pos,i=1,r=0,n=0,o=0,a=1/0,s=-1/0,l=1/0,c=-1/0;e.pos<t;){if(r<=0){var u=e.readVarint();i=7&u,r=u>>3}if(r--,1===i||2===i)(n+=e.readSVarint())<a&&(a=n),n>s&&(s=n),(o+=e.readSVarint())<l&&(l=o),o>c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[a,l,s,c]},ul.prototype.toGeoJSON=function(e,t,i){var r,n,o=this.extent*Math.pow(2,i),a=this.extent*e,s=this.extent*t,l=this.loadGeometry(),c=ul.types[this.type];function u(e){for(var t=0;t<e.length;t++){var i=e[t];e[t]=[360*(i.x+a)/o-180,360/Math.PI*Math.atan(Math.exp((180-360*(i.y+s)/o)*Math.PI/180))-90]}}switch(this.type){case 1:var h=[];for(r=0;r<l.length;r++)h[r]=l[r][0];u(l=h);break;case 2:for(r=0;r<l.length;r++)u(l[r]);break;case 3:for(l=function(e){var t=e.length;if(t<=1)return[e];for(var i,r,n=[],o=0;o<t;o++){var a=pl(e[o]);0!==a&&(void 0===r&&(r=a<0),r===a<0?(i&&n.push(i),i=[e[o]]):i.push(e[o]))}return i&&n.push(i),n}(l),r=0;r<l.length;r++)for(n=0;n<l[r].length;n++)u(l[r][n])}1===l.length?l=l[0]:c="Multi"+c;var p={type:"Feature",geometry:{type:c,coordinates:l},properties:this.properties};return"id"in this&&(p.id=this.id),p};var dl=fl;function fl(e,t){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(ml,this,t),this.length=this._features.length}function ml(e,t,i){15===e?t.version=i.readVarint():1===e?t.name=i.readString():5===e?t.extent=i.readVarint():2===e?t._features.push(i.pos):3===e?t._keys.push(i.readString()):4===e&&t._values.push(function(e){for(var t=null,i=e.readVarint()+e.pos;e.pos<i;){var r=e.readVarint()>>3;t=1===r?e.readString():2===r?e.readFloat():3===r?e.readDouble():4===r?e.readVarint64():5===r?e.readVarint():6===r?e.readSVarint():7===r?e.readBoolean():null}return t}(i))}function _l(e,t,i){if(3===e){var r=new dl(i,i.readVarint()+i.pos);r.length&&(t[r.name]=r)}}fl.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var t=this._pbf.readVarint()+this._pbf.pos;return new cl(this._pbf,t,this.extent,this._keys,this._values)};var gl={VectorTile:function(e,t){this.layers=e.readFields(_l,{},t)},VectorTileFeature:cl,VectorTileLayer:dl};function yl(e,t,i,n){const o=[],a=0===n?(e,t,i,n,o,a)=>{e.push(new r(a,i+(a-t)/(n-t)*(o-i)))}:(e,t,i,n,o,a)=>{e.push(new r(t+(a-i)/(o-i)*(n-t),a))};for(const r of e){const e=[];for(const o of r){if(o.length<=2)continue;const r=[];for(let e=0;e<o.length-1;e++){const s=o[e].x,l=o[e].y,c=o[e+1].x,u=o[e+1].y,h=0===n?s:l,p=0===n?c:u;h<t?p>t&&a(r,s,l,c,u,t):h>i?p<i&&a(r,s,l,c,u,i):r.push(o[e]),p<t&&h>=t&&a(r,s,l,c,u,t),p>i&&h<=i&&a(r,s,l,c,u,i)}let s=o[o.length-1];const l=0===n?s.x:s.y;l>=t&&l<=i&&r.push(s),r.length&&(s=r[r.length-1],r[0].x===s.x&&r[0].y===s.y||r.push(r[0]),e.push(r))}e.length&&o.push(e)}return o}const xl=gl.VectorTileFeature.types,vl=Math.pow(2,13);function bl(e,t,i,r,n,o,a,s){e.emplaceBack((t<<1)+a,(i<<1)+o,(Math.floor(r*vl)<<1)+n,Math.round(s))}function wl(e,t,i){const r=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*r,i[1]*r,i[2]*r)}class PartMetadata{constructor(){this.acc=new r(0,0),this.polyCount=[]}startRing(e){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new r(e.x,e.y),this.max=new r(e.x,e.y))}append(e,t){this.currentPolyCount.edges++,this.acc._add(e);const i=this.min,r=this.max;e.x<i.x?i.x=e.x:e.x>r.x&&(r.x=e.x),e.y<i.y?i.y=e.y:e.y>r.y&&(r.y=e.y),((0===e.x||e.x===Eo)&&e.x===t.x)!=((0===e.y||e.y===Eo)&&e.y===t.y)&&this.processBorderOverlap(e,t),t.x<0!=e.x<0&&this.addBorderIntersection(0,xi(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>Eo!=e.x>Eo&&this.addBorderIntersection(1,xi(t.y,e.y,(Eo-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,xi(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>Eo!=e.y>Eo&&this.addBorderIntersection(3,xi(t.x,e.x,(Eo-t.y)/(e.y-t.y)))}addBorderIntersection(e,t){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 i=this.borders[e];t<i[0]&&(i[0]=t),t>i[1]&&(i[1]=t)}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const i=0===e.x?0:1;this.addBorderIntersection(i,t.y),this.addBorderIntersection(i,e.y)}else{const i=0===e.y?2:3;this.addBorderIntersection(i,t.x),this.addBorderIntersection(i,e.x)}}centroid(){const e=this.polyCount.reduce(((e,t)=>e+t.edges),0);return 0!==e?this.acc.div(e)._round():new r(0,0)}span(){return new r(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce(((e,t)=>e+ +(t[0]!==Number.MAX_VALUE)),0)}}class FillExtrusionBucket{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.layoutVertexArray=new StructArrayLayout4i8,this.centroidVertexArray=new FillExtrusionCentroidArray,this.indexArray=new StructArrayLayout3ui6,this.programConfigurations=new ProgramConfigurationSet(e.layers,e.zoom),this.segments=new SegmentVector,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.enableTerrain=e.enableTerrain}populate(e,t,i,r){this.features=[],this.hasPattern=tl("fill-extrusion",this.layers,t),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(e){const t=Math.exp(Math.PI*(1-e.y/(1<<e.z)*2));return 80150034*t/(t*t+1)/Eo/(1<<e.z)}(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:n,id:o,index:a,sourceLayerIndex:s}of e){const e=this.layers[0]._featureFilter.needGeometry,l=Zo(n,e);if(!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:s,index:a,geometry:e?l.geometry:Go(n,i,r),properties:n.properties,type:n.type,patterns:{}},u=this.layoutVertexArray.length;this.hasPattern?this.features.push(il("fill-extrusion",this.layers,c,this.zoom,t)):this.addFeature(c,c.geometry,a,i,{},t.availableImages,r),t.featureIndex.insert(n,c.geometry,a,s,this.index,u)}this.sortBorders()}addFeatures(e,t,i,r,n){for(const e of this.features){const{geometry:o}=e;this.addFeature(e,o,e.index,t,i,r,n)}this.sortBorders()}update(e,t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ll),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,sl.members,!0))),this.programConfigurations.upload(e),this.uploaded=!0}uploadCentroid(e){0!==this.centroidVertexArray.length&&(this.centroidVertexBuffer?this.needsCentroidUpdate&&this.centroidVertexBuffer.updateData(this.centroidVertexArray):this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,al.members,!0),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,t,i,n,o,a,s){const l=[new r(0,0),new r(Eo,Eo)],c=s.projection,u="globe"===c.name,h=this.enableTerrain&&!u?new PartMetadata:null,p="Polygon"===xl[e.type];u&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new FillExtrusionExtArray);const d=Qs(t,500);for(let e=d.length-1;e>=0;e--){const t=d[e];(0===t.length||(f=t[0]).every((e=>e.x<=0))||f.every((e=>e.x>=Eo))||f.every((e=>e.y<=0))||f.every((e=>e.y>=Eo)))&&d.splice(e,1)}var f;let m;if(u)m=Pl(d,l,n);else{m=[];for(const e of d)m.push({polygon:e,bounds:l})}const _=p?this.edgeRadius:0;for(const{polygon:e,bounds:t}of m){let i=0,r=0;for(const t of e)p&&!t[0].equals(t[t.length-1])&&t.push(t[0]),r+=p?t.length-1:t.length;const o=this.segments.prepareSegment((p?5:4)*r,this.layoutVertexArray,this.indexArray);if(p){const t=[],r=[];i=o.vertexLength;for(const i of e){let a,s;i.length&&i!==e[0]&&r.push(t.length/2),a=i[1].sub(i[0])._perp()._unit();for(let e=1;e<i.length;e++){const r=i[e],l=i[e===i.length-1?1:e+1];let{x:h,y:p}=r;if(_){s=l.sub(r)._perp()._unit();const e=a.add(s)._unit(),t=_*Math.min(4,1/(a.x*e.x+a.y*e.y));h+=t*e.x,p+=t*e.y,a=s}bl(this.layoutVertexArray,h,p,0,0,1,1,0),o.vertexLength++,t.push(r.x,r.y),u&&wl(this.layoutVertexExtArray,c.projectTilePoint(h,p,n),c.upVector(n,h,p))}}const a=bs(t,r);for(let e=0;e<a.length;e+=3)this.indexArray.emplaceBack(i+a[e],i+a[e+2],i+a[e+1]),o.primitiveLength++}for(const r of e){h&&r.length&&h.startRing(r[0]);let e,a,s,l=r.length>4&&Cl(r[r.length-2],r[0],r[1]),d=_?El(r[r.length-2],r[0],r[1],_):0;a=r[1].sub(r[0])._perp()._unit();for(let f=1,m=0;f<r.length;f++){let g=r[f-1],y=r[f];const x=r[f===r.length-1?1:f+1];if(h&&p&&h.currentPolyCount.top++,Al(y,g,t)){_&&(a=x.sub(y)._perp()._unit());continue}h&&h.append(y,g);const v=y.sub(g)._perp(),b=v.x/(Math.abs(v.x)+Math.abs(v.y)),w=v.y>0?1:0,T=g.dist(y);if(m+T>32768&&(m=0),_){s=x.sub(y)._perp()._unit();let e=Sl(g,y,x,Tl(a,s),_);isNaN(e)&&(e=0);const t=y.sub(g)._unit();g=g.add(t.mult(d))._round(),y=y.add(t.mult(-e))._round(),d=e,a=s}const E=o.vertexLength,S=r.length>4&&Cl(g,y,x);let A=Il(m,l,!0);if(bl(this.layoutVertexArray,g.x,g.y,b,w,0,0,A),bl(this.layoutVertexArray,g.x,g.y,b,w,0,1,A),m+=T,A=Il(m,S,!1),l=S,bl(this.layoutVertexArray,y.x,y.y,b,w,0,0,A),bl(this.layoutVertexArray,y.x,y.y,b,w,0,1,A),o.vertexLength+=4,this.indexArray.emplaceBack(E+0,E+1,E+2),this.indexArray.emplaceBack(E+1,E+3,E+2),o.primitiveLength+=2,_){const n=i+(1===f?r.length-2:f-2),a=1===f?i:n+1;if(this.indexArray.emplaceBack(E+1,n,E+3),this.indexArray.emplaceBack(n,a,E+3),o.primitiveLength+=2,void 0===e&&(e=E),!Al(x,r[f],t)){const t=f===r.length-1?e:o.vertexLength;this.indexArray.emplaceBack(E+2,E+3,t),this.indexArray.emplaceBack(E+3,t+1,t),this.indexArray.emplaceBack(E+3,a,t+1),o.primitiveLength+=3}}if(u){const e=this.layoutVertexExtArray,t=c.projectTilePoint(g.x,g.y,n),i=c.projectTilePoint(y.x,y.y,n),r=c.upVector(n,g.x,g.y),o=c.upVector(n,y.x,y.y);wl(e,t,r),wl(e,t,r),wl(e,i,o),wl(e,i,o)}}p&&(i+=r.length-1)}}if(h&&h.polyCount.length>0){if(h.borders){h.vertexArrayOffset=this.centroidVertexArray.length;const e=h.borders,t=this.featuresOnBorder.push(h)-1;for(let i=0;i<4;i++)e[i][0]!==Number.MAX_VALUE&&this.borders[i].push(t)}this.encodeCentroid(h.borders?void 0:h.centroid(),h)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,o,a,n)}sortBorders(){for(let e=0;e<4;e++)this.borders[e].sort(((t,i)=>this.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[i].borders[e][0]))}encodeCentroid(e,t,i=!0){let r,n;if(e)if(0!==e.y){const i=t.span()._mult(this.tileToMeter);r=(Math.max(e.x,1)<<3)+Math.min(7,Math.round(i.x/10)),n=(Math.max(e.y,1)<<3)+Math.min(7,Math.round(i.y/10))}else r=Math.ceil(7*(e.x+450)),n=0;else r=0,n=+i;let o=i?this.centroidVertexArray.length:t.vertexArrayOffset;for(const e of t.polyCount){i&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*e.edges+e.top);for(let t=0;t<e.top;t++)this.centroidVertexArray.emplace(o++,r,n);for(let t=0;t<2*e.edges;t++)this.centroidVertexArray.emplace(o++,0,n),this.centroidVertexArray.emplace(o++,r,n)}}}function Tl(e,t){const i=e.add(t)._unit();return e.x*i.x+e.y*i.y}function El(e,t,i,r){const n=t.sub(e)._perp()._unit(),o=i.sub(t)._perp()._unit();return Sl(e,t,i,Tl(n,o),r)}function Sl(e,t,i,r,n){const o=Math.sqrt(1-r*r);return Math.min(e.dist(t)/3,t.dist(i)/3,n*o/r)}function Al(e,t,i){return e.x<i[0].x&&t.x<i[0].x||e.x>i[1].x&&t.x>i[1].x||e.y<i[0].y&&t.y<i[0].y||e.y>i[1].y&&t.y>i[1].y}function Cl(e,t,i){if(e.x<0||e.x>=Eo||t.x<0||t.x>=Eo||i.x<0||i.x>=Eo)return!1;const r=i.sub(t),n=r.perp(),o=e.sub(t);return(r.x*o.x+r.y*o.y)/Math.sqrt((r.x*r.x+r.y*r.y)*(o.x*o.x+o.y*o.y))>-.866&&n.x*o.x+n.y*o.y<0}function Il(e,t,i){const r=t?2|e:-3&e;return i?1|r:-2&r}function Ml(){const e=Math.PI/32,t=Math.tan(e),i=So;return i*Math.sqrt(1+2*t*t)-i}function Pl(e,t,i){const n=1<<i.z,o=Do(i.x/n),a=Do((i.x+1)/n),s=zo(i.y/n),l=zo((i.y+1)/n);return function(e,t,i,n,o=0,a){const s=[];if(!e.length||!i||!n)return s;const l=(e,t)=>{for(const i of e)s.push({polygon:i,bounds:t})},c=Math.ceil(Math.log2(i)),u=Math.ceil(Math.log2(n)),h=c-u,p=[];for(let e=0;e<Math.abs(h);e++)p.push(h>0?0:1);for(let e=0;e<Math.min(c,u);e++)p.push(0),p.push(1);let d=e;if(d=yl(d,t[0].y-o,t[1].y+o,1),d=yl(d,t[0].x-o,t[1].x+o,0),!d.length)return s;const f=[];for(p.length?f.push({polygons:d,bounds:t,depth:0}):l(d,t);f.length;){const e=f.pop(),t=e.depth,i=p[t],n=e.bounds[0],s=e.bounds[1],c=0===i?n.x:n.y,u=0===i?s.x:s.y,h=a?a(i,c,u):.5*(c+u),d=yl(e.polygons,c-o,h+o,i),m=yl(e.polygons,h-o,u+o,i);if(d.length){const e=[n,new r(0===i?h:s.x,1===i?h:s.y)];p.length>t+1?f.push({polygons:d,bounds:e,depth:t+1}):l(d,e)}if(m.length){const e=[new r(0===i?h:n.x,1===i?h:n.y),s];p.length>t+1?f.push({polygons:m,bounds:e,depth:t+1}):l(m,e)}}return s}(e,t,Math.ceil((a-o)/11.25),Math.ceil((s-l)/11.25),1,((e,t,r)=>{if(0===e)return.5*(t+r);{const e=zo((i.y+t/Eo)/n);return(Mo(.5*(zo((i.y+r/Eo)/n)+e))*n-i.y)*Eo}}))}En(FillExtrusionBucket,"FillExtrusionBucket",{omit:["layers","features"]}),En(PartMetadata,"PartMetadata");const Dl=new Properties({"fill-extrusion-edge-radius":new DataConstantProperty(ct["layout_fill-extrusion"]["fill-extrusion-edge-radius"])});var zl={paint:new Properties({"fill-extrusion-opacity":new DataConstantProperty(ct["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new DataDrivenProperty(ct["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new DataConstantProperty(ct["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new DataConstantProperty(ct["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new CrossFadedDataDrivenProperty(ct["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new DataDrivenProperty(ct["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new DataDrivenProperty(ct["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new DataConstantProperty(ct["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new DataConstantProperty(ct["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new DataConstantProperty(ct["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"])}),layout:Dl};function kl(e,t,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return[e*r-2*Math.PI*6378137/2,t*r-2*Math.PI*6378137/2]}class CanonicalTileID{constructor(e,t,i){this.z=e,this.x=t,this.y=i,this.key=Ll(0,e,e,t,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t){const i=function(e,t,i){var r=kl(256*e,256*(t=Math.pow(2,i)-t-1),i),n=kl(256*(e+1),256*(t+1),i);return r[0]+","+r[1]+","+n[0]+","+n[1]}(this.x,this.y,this.z),r=function(e,t,i){let r,n="";for(let o=e;o>0;o--)r=1<<o-1,n+=(t&r?1:0)+(i&r?2:0);return n}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace("{prefix}",(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String("tms"===t?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",r).replace("{bbox-epsg-3857}",i)}toString(){return`${this.z}/${this.x}/${this.y}`}}class UnwrappedTileID{constructor(e,t){this.wrap=e,this.canonical=t,this.key=Ll(e,t.z,t.z,t.x,t.y)}}class OverscaledTileID{constructor(e,t,i,r,n){this.overscaledZ=e,this.wrap=t,this.canonical=new CanonicalTileID(i,+r,+n),this.key=0===t&&e===i?this.canonical.key:Ll(t,e,i,r,n)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){const t=this.canonical.z-e;return e>this.canonical.z?new OverscaledTileID(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new OverscaledTileID(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e,t=!0){if(this.overscaledZ===e&&t)return this.key;if(e>this.canonical.z)return Ll(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-e;return Ll(this.wrap*+t,e,e,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const t=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ<this.overscaledZ&&e.canonical.x===this.canonical.x>>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new OverscaledTileID(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new OverscaledTileID(t,this.wrap,t,i,r),new OverscaledTileID(t,this.wrap,t,i+1,r),new OverscaledTileID(t,this.wrap,t,i,r+1),new OverscaledTileID(t,this.wrap,t,i+1,r+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new OverscaledTileID(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new OverscaledTileID(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new UnwrappedTileID(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function Ll(e,t,i,r,n){const o=1<<Math.min(i,22);let a=o*(n%o)+r%o;return e&&i<22&&(a+=o*o*((e<0?-2*e-1:2*e)%(1<<2*(22-i)))),16*(32*a+i)+(t-i)}function Bl(e,t){return e.x*t.x+e.y*t.y}function Rl(e,t){if(1===e.length){let i=0;const r=t[i++];let n;for(;!n||r.equals(n);)if(n=t[i++],!n)return 1/0;for(;i<t.length;i++){const o=t[i],a=e[0],s=n.sub(r),l=o.sub(r),c=a.sub(r),u=Bl(s,s),h=Bl(s,l),p=Bl(l,l),d=Bl(c,s),f=Bl(c,l),m=u*p-h*h,_=(p*d-h*f)/m,g=(u*f-h*d)/m,y=r.z*(1-_-g)+n.z*_+o.z*g;if(isFinite(y))return y}return 1/0}{let e=1/0;for(const i of t)e=Math.min(e,i.z);return e}}function Fl(e){const t=new r(e[0],e[1]);return t.z=e[2],t}function Ol(e,t,i,r,n,o,a,s){const l=a*n.getElevationAt(e,t,!0,!0),c=0!==o[0],u=c?0===o[1]?a*(o[0]/7-450):a*function(e,t,i){const r=Math.floor(t[0]/8),n=Math.floor(t[1]/8),o=10*(t[0]-8*r),a=10*(t[1]-8*n),s=e.getElevationAt(r,n,!0,!0),l=e.getMeterToDEM(i),c=Math.floor(.5*(o*l-1)),u=Math.floor(.5*(a*l-1)),h=e.tileCoordToPixel(r,n),p=2*c+1,d=2*u+1,f=function(e,t,i,r,n){return[e.getElevationAtPixel(t,i,!0),e.getElevationAtPixel(t+n,i,!0),e.getElevationAtPixel(t,i+n,!0),e.getElevationAtPixel(t+r,i+n,!0)]}(e,h.x-c,h.y-u,p,d),m=Math.abs(f[0]-f[1]),_=Math.abs(f[2]-f[3]),g=Math.abs(f[0]-f[2])+Math.abs(f[1]-f[3]),y=Math.min(.25,.5*l*(m+_)/p),x=Math.min(.25,.5*l*g/d);return s+Math.max(y*o,x*a)}(n,o,s):l;return{base:l+(0===i)?-1:i,top:c?Math.max(u+r,l+i+2):l+r}}En(CanonicalTileID,"CanonicalTileID"),En(OverscaledTileID,"OverscaledTileID",{omit:["projMatrix"]});const Vl=eo([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:Ul}=Vl,jl=eo([{name:"a_packed",components:4,type:"Float32"}]),{members:Nl}=jl,Gl=gl.VectorTileFeature.types,Zl=Math.cos(Math.PI/180*37.5);class LineBucket{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((e=>{this.gradients[e.id]={}})),this.layoutVertexArray=new StructArrayLayout2i4ub1f12,this.layoutVertexArray2=new StructArrayLayout4f16,this.indexArray=new StructArrayLayout3ui6,this.programConfigurations=new ProgramConfigurationSet(e.layers,e.zoom),this.segments=new SegmentVector,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,i,r){this.hasPattern=tl("line",this.layers,t);const n=this.layers[0].layout.get("line-sort-key"),o=[];for(const{feature:t,id:a,index:s,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Zo(t,e);if(!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom),c,i))continue;const u=n?n.evaluate(c,{},i):void 0,h={id:a,properties:t.properties,type:t.type,sourceLayerIndex:l,index:s,geometry:e?c.geometry:Go(t,i,r),patterns:{},sortKey:u};o.push(h)}n&&o.sort(((e,t)=>e.sortKey-t.sortKey));const{lineAtlas:a,featureIndex:s}=t,l=this.addConstantDashes(a);for(const r of o){const{geometry:n,index:o,sourceLayerIndex:c}=r;if(l&&this.addFeatureDashes(r,a),this.hasPattern){const e=il("line",this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,n,o,i,a.positions,t.availableImages);s.insert(e[o].feature,n,o,c,this.index)}}addConstantDashes(e){let t=!1;for(const i of this.layers){const r=i.paint.get("line-dasharray").value,n=i.layout.get("line-cap").value;if("constant"!==r.kind||"constant"!==n.kind)t=!0;else{const t=n.value,i=r.value;if(!i)continue;e.addDash(i.from,t),e.addDash(i.to,t),i.other&&e.addDash(i.other,t)}}return t}addFeatureDashes(e,t){const i=this.zoom;for(const r of this.layers){const n=r.paint.get("line-dasharray").value,o=r.layout.get("line-cap").value;if("constant"===n.kind&&"constant"===o.kind)continue;let a,s,l,c,u,h;if("constant"===n.kind){const e=n.value;if(!e)continue;a=e.other||e.to,s=e.to,l=e.from}else a=n.evaluate({zoom:i-1},e),s=n.evaluate({zoom:i},e),l=n.evaluate({zoom:i+1},e);"constant"===o.kind?c=u=h=o.value:(c=o.evaluate({zoom:i-1},e),u=o.evaluate({zoom:i},e),h=o.evaluate({zoom:i+1},e)),t.addDash(a,c),t.addDash(s,u),t.addDash(l,h);const p=t.getKey(a,c),d=t.getKey(s,u),f=t.getKey(l,h);e.patterns[r.id]={min:p,mid:d,max:f}}}update(e,t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i,r)}addFeatures(e,t,i,r,n){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Nl)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ul),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&e.properties.hasOwnProperty("mapbox_clip_start")&&e.properties.hasOwnProperty("mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,t,i,r,n,o){const a=this.layers[0].layout,s=a.get("line-join").evaluate(e,{}),l=a.get("line-cap").evaluate(e,{}),c=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const i of t)this.addLine(i,e,s,l,c,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,n,o,r)}addLine(e,t,i,r,n,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t<e.length-1;t++)this.totalDistance+=e[t].dist(e[t+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const a="Polygon"===Gl[t.type];let s=e.length;for(;s>=2&&e[s-1].equals(e[s-2]);)s--;let l=0;for(;l<s-1&&e[l].equals(e[l+1]);)l++;if(s<(a?3:2))return;"bevel"===i&&(n=1.05);const c=this.overscaling<=16?122880/(512*this.overscaling):0,u=this.segments.prepareSegment(10*s,this.layoutVertexArray,this.indexArray);let h,p,d,f,m;this.e1=this.e2=-1,a&&(h=e[s-2],m=e[l].sub(h)._unit()._perp());for(let t=l;t<s;t++){if(d=t===s-1?a?e[l+1]:void 0:e[t+1],d&&e[t].equals(d))continue;m&&(f=m),h&&(p=h),h=e[t],m=d?d.sub(h)._unit()._perp():f,f=f||m;let _=f.add(m);0===_.x&&0===_.y||_._unit();const g=f.x*m.x+f.y*m.y,y=_.x*m.x+_.y*m.y,x=0!==y?1/y:1/0,v=2*Math.sqrt(2-2*y),b=y<Zl&&p&&d,w=f.x*m.y-f.y*m.x>0;if(b&&t>l){const e=h.dist(p);if(e>2*c){const t=h.sub(h.sub(p)._mult(c/e)._round());this.updateDistance(p,t),this.addCurrentVertex(t,f,0,0,u),p=t}}const T=p&&d;let E=T?i:a?"butt":r;if(T&&"round"===E&&(x<o?E="miter":x<=2&&(E="fakeround")),"miter"===E&&x>n&&(E="bevel"),"bevel"===E&&(x>2&&(E="flipbevel"),x<n&&(E="miter")),p&&this.updateDistance(p,h),"miter"===E)_._mult(x),this.addCurrentVertex(h,_,0,0,u);else if("flipbevel"===E){if(x>100)_=m.mult(-1);else{const e=x*f.add(m).mag()/f.sub(m).mag();_._perp()._mult(e*(w?-1:1))}this.addCurrentVertex(h,_,0,0,u),this.addCurrentVertex(h,_.mult(-1),0,0,u)}else if("bevel"===E||"fakeround"===E){const e=-Math.sqrt(x*x-1),t=w?e:0,i=w?0:e;if(p&&this.addCurrentVertex(h,f,t,i,u),"fakeround"===E){const e=Math.round(180*v/Math.PI/20);for(let t=1;t<e;t++){let i=t/e;if(.5!==i){const e=i-.5;i+=i*e*(i-1)*((1.0904+g*(g*(3.55645-1.43519*g)-3.2452))*e*e+(.848013+g*(.215638*g-1.06021)))}const r=m.sub(f)._mult(i)._add(f)._unit()._mult(w?-1:1);this.addHalfVertex(h,r.x,r.y,!1,w,0,u)}}d&&this.addCurrentVertex(h,m,-t,-i,u)}else if("butt"===E)this.addCurrentVertex(h,_,0,0,u);else if("square"===E){const e=p?1:-1;p||this.addCurrentVertex(h,_,e,e,u),this.addCurrentVertex(h,_,0,0,u),p&&this.addCurrentVertex(h,_,e,e,u)}else"round"===E&&(p&&(this.addCurrentVertex(h,f,0,0,u),this.addCurrentVertex(h,f,1,1,u,!0)),d&&(this.addCurrentVertex(h,m,-1,-1,u,!0),this.addCurrentVertex(h,m,0,0,u)));if(b&&t<s-1){const e=h.dist(d);if(e>2*c){const t=h.add(d.sub(h)._mult(c/e)._round());this.updateDistance(h,t),this.addCurrentVertex(t,m,0,0,u),h=t}}}}addCurrentVertex(e,t,i,r,n,o=!1){const a=t.y*r-t.x,s=-t.y-t.x*r;this.addHalfVertex(e,t.x+t.y*i,t.y-t.x*i,o,!1,i,n),this.addHalfVertex(e,a,s,o,!0,-r,n)}addHalfVertex({x:e,y:t},i,r,n,o,a,s){this.layoutVertexArray.emplaceBack((e<<1)+(n?1:0),(t<<1)+(o?1:0),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===a?0:a<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const l=s.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,l),s.primitiveLength++),o?this.e2=l:this.e1=l}updateScaledDistance(){if(this.lineClips){const e=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}}En(LineBucket,"LineBucket",{omit:["layers","patternFeatures"]});const ql=new Properties({"line-cap":new DataDrivenProperty(ct.layout_line["line-cap"]),"line-join":new DataDrivenProperty(ct.layout_line["line-join"]),"line-miter-limit":new DataConstantProperty(ct.layout_line["line-miter-limit"]),"line-round-limit":new DataConstantProperty(ct.layout_line["line-round-limit"]),"line-sort-key":new DataDrivenProperty(ct.layout_line["line-sort-key"])});var $l={paint:new Properties({"line-opacity":new DataDrivenProperty(ct.paint_line["line-opacity"]),"line-color":new DataDrivenProperty(ct.paint_line["line-color"]),"line-translate":new DataConstantProperty(ct.paint_line["line-translate"]),"line-translate-anchor":new DataConstantProperty(ct.paint_line["line-translate-anchor"]),"line-width":new DataDrivenProperty(ct.paint_line["line-width"]),"line-gap-width":new DataDrivenProperty(ct.paint_line["line-gap-width"]),"line-offset":new DataDrivenProperty(ct.paint_line["line-offset"]),"line-blur":new DataDrivenProperty(ct.paint_line["line-blur"]),"line-dasharray":new CrossFadedDataDrivenProperty(ct.paint_line["line-dasharray"]),"line-pattern":new CrossFadedDataDrivenProperty(ct.paint_line["line-pattern"]),"line-gradient":new ColorRampProperty(ct.paint_line["line-gradient"]),"line-trim-offset":new DataConstantProperty(ct.paint_line["line-trim-offset"])}),layout:ql};const Wl=new class LineFloorwidthProperty extends DataDrivenProperty{possiblyEvaluate(e,t){return t=new EvaluationParameters(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,r){return t=b({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,r)}}($l.paint.properties["line-width"].specification);function Hl(e,t){return t>0?t+2*e:e}Wl.useIntegerZoom=!0;const Xl=eo([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Kl=eo([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Jl=eo([{name:"a_projected_pos",components:4,type:"Float32"}],4);eo([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Yl=eo([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),Ql=eo([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);eo([{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 ec=eo([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),tc=eo([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);eo([{name:"triangle",components:3,type:"Uint16"}]),eo([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),eo([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),eo([{type:"Float32",name:"offsetX"}]),eo([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);const ic=128;function rc(e,t){const{expression:i}=t;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new EvaluationParameters(e+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:r}=i;let n=0;for(;n<t.length&&t[n]<=e;)n++;n=Math.max(0,n-1);let o=n;for(;o<t.length&&t[o]<e+1;)o++;o=Math.min(t.length-1,o);const a=t[n],s=t[o];return"composite"===i.kind?{kind:"composite",minZoom:a,maxZoom:s,interpolationType:r}:{kind:"camera",minZoom:a,maxZoom:s,minSize:i.evaluate(new EvaluationParameters(a)),maxSize:i.evaluate(new EvaluationParameters(s)),interpolationType:r}}}function nc(e,{uSize:t,uSizeT:i},{lowerSize:r,upperSize:n}){return"source"===e.kind?r/ic:"composite"===e.kind?xi(r/ic,n/ic,i):t}function oc(e,t){let i=0,r=0;if("constant"===e.kind)r=e.layoutSize;else if("source"!==e.kind){const{interpolationType:n,minZoom:o,maxZoom:a}=e,s=n?_(Ui.interpolationFactor(n,t,o,a),0,1):0;"camera"===e.kind?r=xi(e.minSize,e.maxSize,s):i=s}return{uSizeT:i,uSize:r}}var ac=Object.freeze({__proto__:null,getSizeData:rc,evaluateSizeForFeature:nc,evaluateSizeForZoom:oc,SIZE_PACK_FACTOR:ic});function sc(e,t,i){return e.sections.forEach((e=>{e.text=function(e,t,i){const r=t.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?e=e.toLocaleUpperCase():"lowercase"===r&&(e=e.toLocaleLowerCase()),e}(e.text,t,i)})),e}const lc={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var cc=function(e,t,i,r,n){var o,a,s=8*n-r-1,l=(1<<s)-1,c=l>>1,u=-7,h=i?n-1:0,p=i?-1:1,d=e[t+h];for(h+=p,o=d&(1<<-u)-1,d>>=-u,u+=s;u>0;o=256*o+e[t+h],h+=p,u-=8);for(a=o&(1<<-u)-1,o>>=-u,u+=r;u>0;a=256*a+e[t+h],h+=p,u-=8);if(0===o)o=1-c;else{if(o===l)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,r),o-=c}return(d?-1:1)*a*Math.pow(2,o-r)},uc=function(e,t,i,r,n,o){var a,s,l,c=8*o-n-1,u=(1<<c)-1,h=u>>1,p=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,f=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=u):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),(t+=a+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(a++,l/=2),a+h>=u?(s=0,a=u):a+h>=1?(s=(t*l-1)*Math.pow(2,n),a+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,n),a=0));n>=8;e[i+d]=255&s,d+=f,s/=256,n-=8);for(a=a<<n|s,c+=n;c>0;e[i+d]=255&a,d+=f,a/=256,c-=8);e[i+d-f]|=128*m},hc=pc;function pc(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}pc.Varint=0,pc.Fixed64=1,pc.Bytes=2,pc.Fixed32=5;var dc=4294967296,fc=1/dc,mc="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function _c(e){return e.type===pc.Bytes?e.readVarint()+e.pos:e.pos+1}function gc(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function yc(e,t,i){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(r);for(var n=i.pos-1;n>=e;n--)i.buf[n+r]=i.buf[n]}function xc(e,t){for(var i=0;i<e.length;i++)t.writeVarint(e[i])}function vc(e,t){for(var i=0;i<e.length;i++)t.writeSVarint(e[i])}function bc(e,t){for(var i=0;i<e.length;i++)t.writeFloat(e[i])}function wc(e,t){for(var i=0;i<e.length;i++)t.writeDouble(e[i])}function Tc(e,t){for(var i=0;i<e.length;i++)t.writeBoolean(e[i])}function Ec(e,t){for(var i=0;i<e.length;i++)t.writeFixed32(e[i])}function Sc(e,t){for(var i=0;i<e.length;i++)t.writeSFixed32(e[i])}function Ac(e,t){for(var i=0;i<e.length;i++)t.writeFixed64(e[i])}function Cc(e,t){for(var i=0;i<e.length;i++)t.writeSFixed64(e[i])}function Ic(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+16777216*e[t+3]}function Mc(e,t,i){e[i]=t,e[i+1]=t>>>8,e[i+2]=t>>>16,e[i+3]=t>>>24}function Pc(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function Dc(e,t,i){t.glyphs=[],1===e&&i.readMessage(zc,t)}function zc(e,t,i){if(3===e){const{id:e,bitmap:r,width:n,height:o,left:a,top:s,advance:l}=i.readMessage(kc,{});t.glyphs.push({id:e,bitmap:new AlphaImage({width:n+6,height:o+6},r),metrics:{width:n,height:o,left:a,top:s,advance:l}})}else 4===e?t.ascender=i.readSVarint():5===e&&(t.descender=i.readSVarint())}function kc(e,t,i){1===e?t.id=i.readVarint():2===e?t.bitmap=i.readBytes():3===e?t.width=i.readVarint():4===e?t.height=i.readVarint():5===e?t.left=i.readSVarint():6===e?t.top=i.readSVarint():7===e&&(t.advance=i.readVarint())}function Lc(e){let t=0,i=0;for(const r of e)t+=r.w*r.h,i=Math.max(i,r.w);e.sort(((e,t)=>t.h-e.h));const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let n=0,o=0;for(const t of e)for(let e=r.length-1;e>=0;e--){const i=r[e];if(!(t.w>i.w||t.h>i.h)){if(t.x=i.x,t.y=i.y,o=Math.max(o,t.y+t.h),n=Math.max(n,t.x+t.w),t.w===i.w&&t.h===i.h){const t=r.pop();e<r.length&&(r[e]=t)}else t.h===i.h?(i.x+=t.w,i.w-=t.w):t.w===i.w?(i.y+=t.h,i.h-=t.h):(r.push({x:i.x+t.w,y:i.y,w:i.w-t.w,h:t.h}),i.y+=t.h,i.h-=t.h);break}}return{w:n,h:o,fill:t/(n*o)||0}}pc.prototype={destroy:function(){this.buf=null},readFields:function(e,t,i){for(i=i||this.length;this.pos<i;){var r=this.readVarint(),n=r>>3,o=this.pos;this.type=7&r,e(n,t,this),this.pos===o&&this.skip(r)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=Ic(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=Pc(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=Ic(this.buf,this.pos)+Ic(this.buf,this.pos+4)*dc;return this.pos+=8,e},readSFixed64:function(){var e=Ic(this.buf,this.pos)+Pc(this.buf,this.pos+4)*dc;return this.pos+=8,e},readFloat:function(){var e=cc(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=cc(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t,i,r=this.buf;return t=127&(i=r[this.pos++]),i<128?t:(t|=(127&(i=r[this.pos++]))<<7,i<128?t:(t|=(127&(i=r[this.pos++]))<<14,i<128?t:(t|=(127&(i=r[this.pos++]))<<21,i<128?t:function(e,t,i){var r,n,o=i.buf;if(r=(112&(n=o[i.pos++]))>>4,n<128)return gc(e,r,t);if(r|=(127&(n=o[i.pos++]))<<3,n<128)return gc(e,r,t);if(r|=(127&(n=o[i.pos++]))<<10,n<128)return gc(e,r,t);if(r|=(127&(n=o[i.pos++]))<<17,n<128)return gc(e,r,t);if(r|=(127&(n=o[i.pos++]))<<24,n<128)return gc(e,r,t);if(r|=(1&(n=o[i.pos++]))<<31,n<128)return gc(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(i=r[this.pos]))<<28,e,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&mc?function(e,t,i){return mc.decode(e.subarray(t,i))}(this.buf,t,e):function(e,t,i){for(var r="",n=t;n<i;){var o,a,s,l=e[n],c=null,u=l>239?4:l>223?3:l>191?2:1;if(n+u>i)break;1===u?l<128&&(c=l):2===u?128==(192&(o=e[n+1]))&&(c=(31&l)<<6|63&o)<=127&&(c=null):3===u?(a=e[n+2],128==(192&(o=e[n+1]))&&128==(192&a)&&((c=(15&l)<<12|(63&o)<<6|63&a)<=2047||c>=55296&&c<=57343)&&(c=null)):4===u&&(a=e[n+2],s=e[n+3],128==(192&(o=e[n+1]))&&128==(192&a)&&128==(192&s)&&((c=(15&l)<<18|(63&o)<<12|(63&a)<<6|63&s)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,u=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),n+=u}return r}(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==pc.Bytes)return e.push(this.readVarint(t));var i=_c(this);for(e=e||[];this.pos<i;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==pc.Bytes)return e.push(this.readSVarint());var t=_c(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==pc.Bytes)return e.push(this.readBoolean());var t=_c(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==pc.Bytes)return e.push(this.readFloat());var t=_c(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==pc.Bytes)return e.push(this.readDouble());var t=_c(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==pc.Bytes)return e.push(this.readFixed32());var t=_c(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==pc.Bytes)return e.push(this.readSFixed32());var t=_c(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==pc.Bytes)return e.push(this.readFixed64());var t=_c(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==pc.Bytes)return e.push(this.readSFixed64());var t=_c(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var t=7&e;if(t===pc.Varint)for(;this.buf[this.pos++]>127;);else if(t===pc.Bytes)this.pos=this.readVarint()+this.pos;else if(t===pc.Fixed32)this.pos+=4;else{if(t!==pc.Fixed64)throw new Error("Unimplemented type: "+t);this.pos+=8}},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t<this.pos+e;)t*=2;if(t!==this.length){var i=new Uint8Array(t);i.set(this.buf),this.buf=i,this.length=t}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(e){this.realloc(4),Mc(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),Mc(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),Mc(this.buf,-1&e,this.pos),Mc(this.buf,Math.floor(e*fc),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),Mc(this.buf,-1&e,this.pos),Mc(this.buf,Math.floor(e*fc),this.pos+4),this.pos+=8},writeVarint:function(e){(e=+e||0)>268435455||e<0?function(e,t){var i,r;if(e>=0?(i=e%4294967296|0,r=e/4294967296|0):(r=~(-e/4294967296),4294967295^(i=~(-e%4294967296))?i=i+1|0:(i=0,r=r+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,i){i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,i.buf[i.pos]=127&(e>>>=7)}(i,0,t),function(e,t){var i=(7&e)<<4;t.buf[t.pos++]|=i|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))))}(r,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))},writeSVarint:function(e){this.writeVarint(e<0?2*-e-1:2*e)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(4*e.length),this.pos++;var t=this.pos;this.pos=function(e,t,i){for(var r,n,o=0;o<t.length;o++){if((r=t.charCodeAt(o))>55295&&r<57344){if(!n){r>56319||o+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):n=r;continue}if(r<56320){e[i++]=239,e[i++]=191,e[i++]=189,n=r;continue}r=n-55296<<10|r-56320|65536,n=null}else n&&(e[i++]=239,e[i++]=191,e[i++]=189,n=null);r<128?e[i++]=r:(r<2048?e[i++]=r>>6|192:(r<65536?e[i++]=r>>12|224:(e[i++]=r>>18|240,e[i++]=r>>12&63|128),e[i++]=r>>6&63|128),e[i++]=63&r|128)}return i}(this.buf,e,this.pos);var i=this.pos-t;i>=128&&yc(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),uc(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),uc(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var i=0;i<t;i++)this.buf[this.pos++]=e[i]},writeRawMessage:function(e,t){this.pos++;var i=this.pos;e(t,this);var r=this.pos-i;r>=128&&yc(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,t,i){this.writeTag(e,pc.Bytes),this.writeRawMessage(t,i)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,xc,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,vc,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,Tc,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,bc,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,wc,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,Ec,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,Sc,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,Ac,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,Cc,t)},writeBytesField:function(e,t){this.writeTag(e,pc.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,pc.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,pc.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,pc.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,pc.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,pc.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,pc.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,pc.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,pc.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,pc.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};class ImagePosition{constructor(e,{pixelRatio:t,version:i,stretchX:r,stretchY:n,content:o}){this.paddedRect=e,this.pixelRatio=t,this.stretchX=r,this.stretchY=n,this.content=o,this.version=i}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]}}En(ImagePosition,"ImagePosition"),En(class ImageAtlas{constructor(e,t){const i={},r={};this.haveRenderCallbacks=[];const n=[];this.addImages(e,i,n),this.addImages(t,r,n);const{w:o,h:a}=Lc(n),s=new RGBAImage({width:o||1,height:a||1});for(const t in e){const r=e[t],n=i[t].paddedRect;RGBAImage.copy(r.data,s,{x:0,y:0},{x:n.x+1,y:n.y+1},r.data)}for(const e in t){const i=t[e],n=r[e].paddedRect,o=n.x+1,a=n.y+1,l=i.data.width,c=i.data.height;RGBAImage.copy(i.data,s,{x:0,y:0},{x:o,y:a},i.data),RGBAImage.copy(i.data,s,{x:0,y:c-1},{x:o,y:a-1},{width:l,height:1}),RGBAImage.copy(i.data,s,{x:0,y:0},{x:o,y:a+c},{width:l,height:1}),RGBAImage.copy(i.data,s,{x:l-1,y:0},{x:o-1,y:a},{width:1,height:c}),RGBAImage.copy(i.data,s,{x:0,y:0},{x:o+l,y:a},{width:1,height:c})}this.image=s,this.iconPositions=i,this.patternPositions=r}addImages(e,t,i){for(const r in e){const n=e[r],o={x:0,y:0,w:n.data.width+2,h:n.data.height+2};i.push(o),t[r]=new ImagePosition(o,n),n.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(e,t){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((t=>e.hasImage(t))),e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const i in e.updatedImages)this.patchUpdatedImage(this.iconPositions[i],e.getImage(i),t),this.patchUpdatedImage(this.patternPositions[i],e.getImage(i),t)}patchUpdatedImage(e,t,i){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[r,n]=e.tl;i.update(t.data,void 0,{x:r,y:n})}},"ImageAtlas");const Bc={horizontal:1,vertical:2,horizontalOnly:3};function Rc(e){let t=.5,i=.5;switch(e){case"right":case"top-right":case"bottom-right":t=1;break;case"left":case"top-left":case"bottom-left":t=0}switch(e){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:t,verticalAlign:i}}class Anchor extends r{constructor(e,t,i,r,n){super(e,t),this.angle=r,this.z=i,void 0!==n&&(this.segment=n)}clone(){return new Anchor(this.x,this.y,this.z,this.angle,this.segment)}}En(Anchor,"Anchor");const Fc=1e20;function Oc(e,t,i,r,n,o,a,s,l){for(let c=t;c<t+r;c++)Vc(e,i*o+c,o,n,a,s,l);for(let c=i;c<i+n;c++)Vc(e,c*o+t,1,r,a,s,l)}function Vc(e,t,i,r,n,o,a){o[0]=0,a[0]=-Fc,a[1]=Fc,n[0]=e[t];for(let s=1,l=0,c=0;s<r;s++){n[s]=e[t+s*i];const r=s*s;do{const e=o[l];c=(n[s]-n[e]+r-e*e)/(s-e)/2}while(c<=a[l]&&--l>-1);l++,o[l]=s,a[l]=c,a[l+1]=Fc}for(let s=0,l=0;s<r;s++){for(;a[l+1]<s;)l++;const r=o[l],c=s-r;e[t+s*i]=n[r]+c*c}}class GlyphManager{constructor(e,t,i){this.requestManager=e,this.localGlyphMode=t,this.localFontFamily=i,this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(e){this.url=e}getGlyphs(e,t){const i=[];for(const t in e)for(const r of e[t])i.push({stack:t,id:r});x(i,(({stack:e,id:t},i)=>{let r=this.entries[e];r||(r=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let n=r.glyphs[t];if(void 0!==n)return void i(null,{stack:e,id:t,glyph:n});if(n=this._tinySDF(r,e,t),n)return r.glyphs[t]=n,void i(null,{stack:e,id:t,glyph:n});const o=Math.floor(t/256);if(256*o>65535)return void i(new Error("glyphs > 65535 not supported"));if(r.ranges[o])return void i(null,{stack:e,id:t,glyph:n});let a=r.requests[o];a||(a=r.requests[o]=[],GlyphManager.loadGlyphRange(e,o,this.url,this.requestManager,((e,t)=>{if(t){r.ascender=t.ascender,r.descender=t.descender;for(const e in t.glyphs)this._doesCharSupportLocalGlyph(+e)||(r.glyphs[+e]=t.glyphs[+e]);r.ranges[o]=!0}for(const i of a)i(e,t);delete r.requests[o]}))),a.push(((r,n)=>{r?i(r):n&&i(null,{stack:e,id:t,glyph:n.glyphs[t]||null})}))}),((e,i)=>{if(e)t(e);else if(i){const e={};for(const{stack:t,id:r,glyph:n}of i)void 0===e[t]&&(e[t]={}),void 0===e[t].glyphs&&(e[t].glyphs={}),e[t].glyphs[r]=n&&{id:n.id,bitmap:n.bitmap.clone(),metrics:n.metrics},e[t].ascender=this.entries[t].ascender,e[t].descender=this.entries[t].descender;t(null,e)}}))}_doesCharSupportLocalGlyph(e){return 0!==this.localGlyphMode&&(2===this.localGlyphMode?!!this.localFontFamily:!!this.localFontFamily&&(kn(e)||Ln(e)||Dn(e)||zn(e)||Pn(e)))}_tinySDF(e,t,i){const r=this.localFontFamily;if(!r||!this._doesCharSupportLocalGlyph(i))return;let n=e.tinySDF;if(!n){let i="400";/bold/i.test(t)?i="900":/medium/i.test(t)?i="500":/light/i.test(t)&&(i="200"),n=e.tinySDF=new GlyphManager.TinySDF({fontFamily:r,fontWeight:i,fontSize:48,buffer:6,radius:16}),n.fontWeight=i}if(this.localGlyphs[n.fontWeight][i])return this.localGlyphs[n.fontWeight][i];const o=String.fromCharCode(i),{data:a,width:s,height:l,glyphWidth:c,glyphHeight:u,glyphLeft:h,glyphTop:p,glyphAdvance:d}=n.draw(o);return this.localGlyphs[n.fontWeight][i]={id:i,bitmap:new AlphaImage({width:s,height:l},a),metrics:{width:c/2,height:u/2,left:h/2,top:p/2-27,advance:d/2,localGlyph:!0}}}}GlyphManager.loadGlyphRange=function(e,t,i,r,n){const o=256*t,a=o+255,s=r.transformRequest(r.normalizeGlyphsURL(i).replace("{fontstack}",e).replace("{range}",`${o}-${a}`),Xe.Glyphs);Qe(s,((e,t)=>{if(e)n(e);else if(t){const e={},i=function(e){return new hc(e).readFields(Dc,{})}(t);for(const t of i.glyphs)e[t.id]=t;n(null,{glyphs:e,ascender:i.ascender,descender:i.descender})}}))},GlyphManager.TinySDF=class TinySDF{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:n="sans-serif",fontWeight:o="normal",fontStyle:a="normal"}={}){this.buffer=t,this.cutoff=r,this.radius=i;const s=this.size=e+4*t,l=this._createCanvas(s),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${a} ${o} ${e}px ${n}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(s*s),this.gridInner=new Float64Array(s*s),this.f=new Float64Array(s),this.z=new Float64Array(s+1),this.v=new Uint16Array(s)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:n,actualBoundingBoxRight:o}=this.ctx.measureText(e),a=Math.ceil(i),s=Math.min(this.size-this.buffer,Math.ceil(o-n)),l=Math.min(this.size-this.buffer,a+Math.ceil(r)),c=s+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),p=new Uint8ClampedArray(h),d={data:p,width:c,height:u,glyphWidth:s,glyphHeight:l,glyphTop:a,glyphLeft:0,glyphAdvance:t};if(0===s||0===l)return d;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,s,l),f.fillText(e,m,m+a);const y=f.getImageData(m,m,s,l);g.fill(Fc,0,h),_.fill(0,0,h);for(let e=0;e<l;e++)for(let t=0;t<s;t++){const i=y.data[4*(e*s+t)+3]/255;if(0===i)continue;const r=(e+m)*c+t+m;if(1===i)g[r]=0,_[r]=Fc;else{const e=.5-i;g[r]=e>0?e*e:0,_[r]=e<0?e*e:0}}Oc(g,0,0,c,u,c,this.f,this.v,this.z),Oc(_,m,m,s,l,c,this.f,this.v,this.z);for(let e=0;e<h;e++){const t=Math.sqrt(g[e])-Math.sqrt(_[e]);p[e]=Math.round(255-255*(t/this.radius+this.cutoff))}return d}};const Uc=Number.POSITIVE_INFINITY,jc=Math.sqrt(2);function Nc(e,t){return t[1]!==Uc?function(e,t,i){let r=0,n=0;switch(t=Math.abs(t),i=Math.abs(i),e){case"top-right":case"top-left":case"top":n=i-7;break;case"bottom-right":case"bottom-left":case"bottom":n=7-i}switch(e){case"top-right":case"bottom-right":case"right":r=-t;break;case"top-left":case"bottom-left":case"left":r=t}return[r,n]}(e,t[0],t[1]):function(e,t){let i=0,r=0;t<0&&(t=0);const n=t/jc;switch(e){case"top-right":case"top-left":r=n-7;break;case"bottom-right":case"bottom-left":r=7-n;break;case"bottom":r=7-t;break;case"top":r=t-7}switch(e){case"top-right":case"bottom-right":i=-n;break;case"top-left":case"bottom-left":i=n;break;case"left":i=t;break;case"right":i=-t}return[i,r]}(e,t[0])}const Gc=eo([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:Zc}=Gc,qc=eo([{name:"a_pos_3",components:3,type:"Int16"}]);var $c=eo([{name:"a_pos",type:"Int16",components:2}]);const Wc=Eo/Math.PI/2,Hc=2*Po(1,0)*Wc*Math.PI,Xc=[64,32,16],Kc=-Wc,Jc=Wc,Yc=[new Aabb([Kc,Kc,Kc],[Jc,Jc,Jc]),new Aabb([Kc,Kc,Kc],[0,0,Jc]),new Aabb([0,Kc,Kc],[Jc,0,Jc]),new Aabb([Kc,0,Kc],[0,Jc,Jc]),new Aabb([0,0,Kc],[Jc,Jc,Jc])];function Qc(e,t,i,r=!0){const n=ja([],e._camera.position,e.worldSize),o=[t,i,1,1];is(o,o,e.pixelMatrixInverse),ts(o,o,1/o[3]);const a=Za([],Ja([],o,n)),s=e.globeMatrix,l=[s[12],s[13],s[14]],u=Ja([],l,n),h=La(u),p=Za([],u),d=e.worldSize/(2*Math.PI),f=qa(p,a),m=Math.asin(d/h);if(m<Math.acos(f)){if(!r)return null;const e=[],t=[];ja(e,a,h/f),Za(t,Ja(t,e,u)),Za(a,Ra(a,u,ja(a,t,Math.tan(m)*h)))}const g=[];new Ray(n,a).closestPointOnSphere(l,d,g);const y=Za([],Z(s,0)),x=Za([],Z(s,1)),v=Za([],Z(s,2)),b=qa(y,g),w=qa(x,g),T=qa(v,g),E=c(Math.asin(-w/d));let S=c(Math.atan2(b,T));S=e.center.lng+function(e,t){const i=(t-e+180)%360-180;return i<-180?i+360:i}(e.center.lng,S);const A=Io(S),C=_(Mo(E),0,1);return new MercatorCoordinate(A,C)}class Arc{constructor(e,t,i){this.a=Ja([],e,i),this.b=Ja([],t,i),this.center=i;const r=Za([],this.a),n=Za([],this.b);this.angle=Math.acos(qa(r,n))}}function eu(e,t){if(0===e.angle)return null;let i;return i=0===e.a[t]?1/e.angle*.5*Math.PI:1/e.angle*Math.atan(e.b[t]/e.a[t]/Math.sin(e.angle)-1/Math.tan(e.angle)),i<0||i>1?null:function(e,t,i,r){const n=Math.sin(i);return e*(Math.sin((1-r)*i)/n)+t*(Math.sin(r*i)/n)}(e.a[t],e.b[t],e.angle,_(i,0,1))+e.center[t]}function tu(e){if(e.z<=1)return Yc[e.z+2*e.y+e.x];const t=au(ou(e));return Aabb.fromPoints(t)}function iu(e,t){const i=_u(t.zoom);if(0===i)return tu(e);const r=ou(e),n=au(r),o=Io(r.getWest())*t.worldSize,a=Io(r.getEast())*t.worldSize,s=Mo(r.getNorth())*t.worldSize,l=Mo(r.getSouth())*t.worldSize,c=[o,s,0],u=[a,s,0],h=[o,l,0],p=[a,l,0],d=xa([],t.globeMatrix);return Wa(c,c,d),Wa(u,u,d),Wa(h,h,d),Wa(p,p,d),n[0]=vi(n[0],h,i),n[1]=vi(n[1],p,i),n[2]=vi(n[2],u,i),n[3]=vi(n[3],c,i),Aabb.fromPoints(n)}function ru(e,t,i,r,n){for(const o of i)Wa(o,o,r),ja(o,o,n),Va(e,e,o),Ua(t,t,o)}function nu(e,t,i){const r=t/e.worldSize,n=Number.MAX_VALUE,o=[-n,-n,-n],a=[n,n,n],s=e.globeMatrix;if(i.z<=1)return ru(a,o,tu(i).getCorners(),s,r),new Aabb(a,o);const c=ou(i),u=au(c);if(ru(a,o,u,s,r),c.contains(e.center)){o[2]=0;const t=e.point,i=[t.x*r,t.y*r,0];return Va(a,a,i),Ua(o,o,i),new Aabb(a,o)}const h=[s[12]*r,s[13]*r,s[14]*r],p=c.getCenter(),d=_(e.center.lat,-85.051129,Lo),f=_(p.lat,-85.051129,Lo),m=Io(e.center.lng),g=Mo(d);let y=m-Io(p.lng);const x=g-Mo(f);y>.5?y-=1:y<-.5&&(y+=1);let v=0;Math.abs(y)>Math.abs(x)?v=y>=0?1:3:(v=x>=0?0:2,Na(h,h,[s[4]*r,s[5]*r,s[6]*r],-Math.sin(l(x>=0?c.getSouth():c.getNorth()))*Wc));const b=u[v],w=u[(v+1)%4],T=new Arc(b,w,h),E=[eu(T,0)||b[0],eu(T,1)||b[1],eu(T,2)||b[2]];return a[2]=Math.min(b[2],w[2]),Va(a,a,E),Ua(o,o,E),new Aabb(a,o)}function ou({x:e,y:t,z:i}){const r=1/(1<<i),n=new LngLat(Do(e*r),zo((t+1)*r)),o=new LngLat(Do((e+1)*r),zo(t*r));return new LngLatBounds(n,o)}function au(e){const t=l(e.getNorth()),i=l(e.getSouth()),r=Math.cos(t),n=Math.cos(i),o=Math.sin(t),a=Math.sin(i),s=e.getWest(),c=e.getEast();return[su(n,a,s),su(n,a,c),su(r,o,c),su(r,o,s)]}function su(e,t,i,r=Wc){return i=l(i),[e*Math.sin(i)*r,-t*r,e*Math.cos(i)*r]}function lu(e,t,i){return su(Math.cos(l(e)),Math.sin(l(e)),t,i)}function cu(e,t,i,r){const n=1<<i.z,o=(e/Eo+i.x)/n;return lu(zo((t/Eo+i.y)/n),Do(o),r)}function uu({min:e,max:t}){return 16383/Math.max(t[0]-e[0],t[1]-e[1],t[2]-e[2])}const hu=new Float64Array(16);function pu(e){const t=uu(e),i=Aa(hu,[t,t,t]);return ba(i,i,((r=[])[0]=-(n=e.min)[0],r[1]=-n[1],r[2]=-n[2],r));var r,n}function du(e){const t=(r=e.min,(i=hu)[0]=1,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=1,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=1,i[11]=0,i[12]=r[0],i[13]=r[1],i[14]=r[2],i[15]=1,i);var i,r;const n=1/uu(e);return wa(t,t,[n,n,n])}function fu(e,t){return Eo/(512*Math.pow(2,e))*uu(tu(t))}function mu(e,t,i,r,n){const o=function(e){const t=Eo/(2*Math.PI);return e/(2*Math.PI)/t}(i),a=[e,t,-i/(2*Math.PI)],s=ya(new Float64Array(16));return ba(s,s,a),wa(s,s,[o,o,o]),Ta(s,s,l(-n)),Ea(s,s,l(-r)),s}function _u(e){return g(5,6,e)}function gu(e,t,i){const r=ya(new Float64Array(16)),n=(t/(1<<e)-.5)*Math.PI*2;return Ea(r,i.globeMatrix,n),Float32Array.from(r)}function yu(e,t,i){const r=_u(i.zoom),n=e.style.map._antialias,o=!!t.extStandardDerivatives,a=t.extStandardDerivativesForceOff||e.terrain&&e.terrain.exaggeration()>0;return 0===r&&!n&&!a&&o}function xu(e,t,i){const r=t.getNorth(),n=t.getSouth(),o=t.getWest(),a=.015625;return[0,(t.getEast()-o)*a,1<<e.z,(n-r)/Xc[i],0,e.y,r,o,a]}function vu(e){const t=80.051129;e=_(e,-80.051129,t)/t*90;const i=Math.pow(Math.abs(Math.sin(l(e))),3);return Math.round(i*(Xc.length-1))}function bu(e){const t=[0,0,0],i=ya(new Float64Array(16));return va(i,e.pixelMatrix,e.globeMatrix),Wa(t,t,i),new r(t[0],t[1])}function wu(e,t){const i=lu(t.lat,t.lng);return o=(r=Fa([],function(e){const t=lu(e._center.lat,e._center.lng);let i=$a([],Ba(0,1,0),t);const r=Ca([],-e.angle,t);i=Wa(i,i,r),Ca(r,-e._pitch,i);const n=Za([],t);return ja(n,n,e.cameraToCenterDistance/e.pixelsPerMeter*Hc),Wa(n,n,r),Ra([],t,n)}(e),i))[0],a=r[1],s=r[2],l=(n=i)[0],c=n[1],u=n[2],p=(h=Math.sqrt(o*o+a*a+s*s)*Math.sqrt(l*l+c*c+u*u))&&qa(r,n)/h,Math.acos(Math.min(Math.max(p,-1),1));var r,n,o,a,s,l,c,u,h,p}function Tu(e,t){return wu(e,t)>Math.PI/2*1.01}const Eu=l(85),Su=Math.cos(Eu),Au=Math.sin(Eu);class GlobeSharedBuffers{constructor(e){this._createGrid(e),this._createPoles(e)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const e of this._poleSegments)e.destroy();for(const e of this._gridSegments)e.destroy();if(this._wireframeIndexBuffer){this._wireframeIndexBuffer.destroy();for(const e of this._wireframeSegments)e.destroy()}}_createGrid(e){const t=new StructArrayLayout2i4,i=new StructArrayLayout3ui6,r=65;for(let e=0;e<r;e++)for(let i=0;i<r;i++)t.emplaceBack(i,e);this._gridSegments=[];for(let e=0,t=0;e<Xc.length;e++){const n=Xc[e];for(let e=0;e<n;e++)for(let t=0;t<64;t++){const n=e*r+t;i.emplaceBack(n+1,n,n+r),i.emplaceBack(n+r,n+r+1,n+1)}const o=64*n*2;this._gridSegments.push(SegmentVector.simpleSegment(0,t,(n+1)*r,o)),t+=o}this._gridBuffer=e.createVertexBuffer(t,$c.members),this._gridIndexBuffer=e.createIndexBuffer(i,!0)}_createPoles(e){const t=new StructArrayLayout3ui6;for(let e=0;e<=64;e++)t.emplaceBack(0,e+1,e+2);this._poleIndexBuffer=e.createIndexBuffer(t,!0);const i=new StructArrayLayout5f20,r=new StructArrayLayout5f20;this._poleSegments=[];for(let e=0,t=0;e<5;e++){const n=360/(1<<e);i.emplaceBack(0,-Wc,0,.5,0),r.emplaceBack(0,-Wc,0,.5,1);for(let e=0;e<=64;e++){const t=e/64,o=xi(0,n,t),[a,s,l]=su(Su,Au,o,Wc);i.emplaceBack(a,s,l,t,0),r.emplaceBack(a,s,l,t,1)}this._poleSegments.push(SegmentVector.simpleSegment(t,0,66,64)),t+=66}this._poleNorthVertexBuffer=e.createVertexBuffer(i,Zc,!1),this._poleSouthVertexBuffer=e.createVertexBuffer(r,Zc,!1)}getGridBuffers(e){return[this._gridBuffer,this._gridIndexBuffer,this._gridSegments[e]]}getPoleBuffers(e){return[this._poleNorthVertexBuffer,this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[e]]}getWirefameBuffers(e,t){if(!this._wireframeSegments){const t=new StructArrayLayout2ui4,i=64,r=i+1;this._wireframeSegments=[];for(let e=0,n=0;e<Xc.length;e++){const o=Xc[e];for(let e=0;e<o;e++)for(let n=0;n<i;n++){const i=e*r+n;t.emplaceBack(i,i+1),t.emplaceBack(i,i+r),t.emplaceBack(i,i+r+1)}const a=o*i*3;this._wireframeSegments.push(SegmentVector.simpleSegment(0,n,(o+1)*r,a)),n+=a}this._wireframeIndexBuffer=e.createIndexBuffer(t)}return[this._gridBuffer,this._wireframeIndexBuffer,this._wireframeSegments[t]]}}function Cu(e,t){const i=e.fovAboveCenter,r=e.elevation?e.elevation.getMinElevationBelowMSL()*t:0,n=(e._camera.position[2]*e.worldSize-r)/Math.cos(e._pitch),o=Math.sin(i)*n/Math.sin(Math.max(Math.PI/2-e._pitch-i,.01)),a=Math.sin(e._pitch)*o+n;return Math.min(1.01*a,n*(1/e._horizonShift))}function Iu(e,t){if(!t.isReprojectedInTileSpace)return{scale:1<<e.z,x:e.x,y:e.y,x2:e.x+1,y2:e.y+1,projection:t};const i=Math.pow(2,-e.z),r=e.x*i,n=(e.x+1)*i,o=e.y*i,a=(e.y+1)*i,s=Do(r),l=Do(n),c=zo(o),u=zo(a),h=t.project(s,c),p=t.project(l,c),d=t.project(l,u),f=t.project(s,u);let m=Math.min(h.x,p.x,d.x,f.x),_=Math.min(h.y,p.y,d.y,f.y),g=Math.max(h.x,p.x,d.x,f.x),y=Math.max(h.y,p.y,d.y,f.y);const x=i/16;function v(e,i,r,n,o,a){const s=(r+o)/2,l=(n+a)/2,c=t.project(Do(s),zo(l)),u=Math.max(0,m-c.x,_-c.y,c.x-g,c.y-y);m=Math.min(m,c.x),g=Math.max(g,c.x),_=Math.min(_,c.y),y=Math.max(y,c.y),u>x&&(v(e,c,r,n,s,l),v(c,i,s,l,o,a))}v(h,p,r,o,n,o),v(p,d,n,o,n,a),v(d,f,n,a,r,a),v(f,h,r,a,r,o),m-=x,_-=x,g+=x,y+=x;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:t}}function Mu(e,t,i,r,n,o,a,s,l){if("globe"===l.name)return nu(e,t,new CanonicalTileID(i,r,n));const c=Iu({z:i,x:r,y:n},l);return new Aabb([(o+c.x/c.scale)*t,t*(c.y/c.scale),a],[(o+c.x2/c.scale)*t,t*(c.y2/c.scale),s])}function Pu(e,{x:t,y:i},n=0){return new r(((t-n)*e.scale-e.x)*Eo,(i*e.scale-e.y)*Eo)}function Du(e,t,i=0){return Ba(((t.x-i)*e.scale-e.x)*Eo,(t.y*e.scale-e.y)*Eo,ko(t.z,t.y))}const zu=ya(new Float32Array(16));class Projection{constructor(e){this.spec=e,this.name=e.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(e,t){return{x:0,y:0,z:0}}unproject(e,t){return new LngLat(0,0)}projectTilePoint(e,t,i){return{x:e,y:t,z:0}}locationPoint(e,t,i=!0){return e._coordinatePoint(e.locationCoordinate(t),i)}pixelsPerMeter(e,t){return Po(1,e)*t}pixelSpaceConversion(e,t,i){return 1}farthestPixelDistance(e){return Cu(e,e.pixelsPerMeter)}pointCoordinate(e,t,i,n){const o=e.horizonLineFromTop(!1),a=new r(t,Math.max(o,i));return e.rayIntersectionCoordinate(e.pointRayIntersection(a,n))}pointCoordinate3D(e,t,i){const n=new r(t,i);if(e.elevation)return e.elevation.pointCoordinate(n);{const t=this.pointCoordinate(e,n.x,n.y,0);return[t.x,t.y,t.z]}}isPointAboveHorizon(e,t){if(e.elevation)return!this.pointCoordinate3D(e,t.x,t.y);const i=e.horizonLineFromTop();return t.y<i}createInversionMatrix(e,t){return zu}createTileMatrix(e,t,i){let r,n,o;const a=i.canonical,s=ya(new Float64Array(16));if(this.isReprojectedInTileSpace){const l=Iu(a,this);r=1,n=l.x+i.wrap*l.scale,o=l.y,wa(s,s,[r/l.scale,r/l.scale,e.pixelsPerMeter/t])}else r=t/e.zoomScale(a.z),n=(a.x+Math.pow(2,a.z)*i.wrap)*r,o=a.y*r;return ba(s,s,[n,o,0]),wa(s,s,[r/Eo,r/Eo,1]),s}upVector(e,t,i){return[0,0,1]}upVectorScale(e,t,i){return{metersToTile:1}}}class Albers extends Projection{constructor(e){super(e),this.range=[4,7],this.center=e.center||[-96,37.5];const[t,i]=this.parallels=e.parallels||[29.5,45.5],r=Math.sin(l(t));this.n=(r+Math.sin(l(i)))/2,this.c=1+r*(2*this.n-r),this.r0=Math.sqrt(this.c)/this.n}project(e,t){const{n:i,c:r,r0:n}=this,o=l(e-this.center[0]),a=l(t),s=Math.sqrt(r-2*i*Math.sin(a))/i;return{x:s*Math.sin(o*i),y:s*Math.cos(o*i)-n,z:0}}unproject(e,t){const{n:i,c:r,r0:n}=this,o=n+t;let a=Math.atan2(e,Math.abs(o))*Math.sign(o);o*i<0&&(a-=Math.PI*Math.sign(e)*Math.sign(o));const s=l(this.center[0])*i;a=y(a,-Math.PI-s,Math.PI-s);const u=c(a/i)+this.center[0],h=Math.asin(_((r-(e*e+o*o)*i*i)/(2*i),-1,1)),p=_(c(h),-85.051129,Lo);return new LngLat(u,p)}}const ku=1.340264,Lu=-.081106,Bu=893e-6,Ru=.003796,Fu=Math.sqrt(3)/2;class EqualEarth extends Projection{project(e,t){t=t/180*Math.PI,e=e/180*Math.PI;const i=Math.asin(Fu*Math.sin(t)),r=i*i,n=r*r*r;return{x:.5*(e*Math.cos(i)/(Fu*(ku+3*Lu*r+n*(7*Bu+9*Ru*r)))/Math.PI+.5),y:1-.5*(i*(ku+Lu*r+n*(Bu+Ru*r))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,r=i*i,n=r*r*r;for(let e,o,a,s=0;s<12&&(o=i*(ku+Lu*r+n*(Bu+Ru*r))-t,a=ku+3*Lu*r+n*(7*Bu+9*Ru*r),e=o/a,i=_(i-e,-Math.PI/3,Math.PI/3),r=i*i,n=r*r*r,!(Math.abs(e)<1e-12));++s);const o=Fu*e*(ku+3*Lu*r+n*(7*Bu+9*Ru*r))/Math.cos(i),a=Math.asin(Math.sin(i)/Fu),s=_(180*o/Math.PI,-180,180),l=_(180*a/Math.PI,-85.051129,Lo);return new LngLat(s,l)}}class Equirectangular extends Projection{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0}project(e,t){return{x:.5+e/360,y:.5-t/360,z:0}}unproject(e,t){const i=360*(e-.5),r=_(360*(.5-t),-85.051129,Lo);return new LngLat(i,r)}}const Ou=Math.PI/2;function Vu(e){return Math.tan((Ou+e)/2)}class LambertConformalConic extends Projection{constructor(e){super(e),this.center=e.center||[0,30];const[t,i]=this.parallels=e.parallels||[30,30],r=l(t),n=l(i),o=Math.cos(r);this.n=r===n?Math.sin(r):Math.log(o/Math.cos(n))/Math.log(Vu(n)/Vu(r)),this.f=o*Math.pow(Vu(r),this.n)/this.n}project(e,t){t=l(t),e=l(e-this.center[0]);const i=1e-6,{n:r,f:n}=this;n>0?t<-Ou+i&&(t=-Ou+i):t>Ou-i&&(t=Ou-i);const o=n/Math.pow(Vu(t),r),a=o*Math.sin(r*e),s=n-o*Math.cos(r*e);return{x:.5*(a/Math.PI+.5),y:1-.5*(s/Math.PI+.5),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI,t=(2*(1-t)-.5)*Math.PI;const{n:i,f:r}=this,n=r-t,o=Math.sign(n),a=Math.sign(i)*Math.sqrt(e*e+n*n);let s=Math.atan2(e,Math.abs(n))*o;n*i<0&&(s-=Math.PI*Math.sign(e)*o);const l=_(c(s/i)+this.center[0],-180,180),u=_(c(2*Math.atan(Math.pow(r/a,1/i))-Ou),-85.051129,Lo);return new LngLat(l,u)}}class Mercator extends Projection{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(e,t){return{x:Io(e),y:Mo(t),z:0}}unproject(e,t){const i=Do(e),r=zo(t);return new LngLat(i,r)}}const Uu=l(Lo);class NaturalEarth extends Projection{project(e,t){const i=(t=l(t))*t,r=i*i;return{x:.5*((e=l(e))*(.8707-.131979*i+r*(r*(.003971*i-.001529*r)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+i*(.015085+r*(.028874*i-.044475-.005916*r)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,r=25,n=0,o=i*i;do{o=i*i;const e=o*o;n=(i*(1.007226+o*(.015085+e*(.028874*o-.044475-.005916*e)))-t)/(1.007226+o*(.045255+e*(.259866*o-.311325-.005916*11*e))),i=_(i-n,-Uu,Uu)}while(Math.abs(n)>1e-6&&--r>0);o=i*i;const a=_(c(e/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),s=c(i);return new LngLat(a,s)}}const ju=l(Lo);class WinkelTripel extends Projection{project(e,t){t=l(t),e=l(e);const i=Math.cos(t),r=2/Math.PI,n=Math.acos(i*Math.cos(e/2)),o=Math.sin(n)/n,a=.5*(e*r+2*i*Math.sin(e/2)/o)||0,s=.5*(t+Math.sin(t)/o)||0;return{x:.5*(a/Math.PI+.5),y:1-.5*(s/Math.PI+1),z:0}}unproject(e,t){let i=e=(2*e-.5)*Math.PI,r=t=(2*(1-t)-1)*Math.PI,n=25;const o=1e-6;let a=0,s=0;do{const n=Math.cos(r),o=Math.sin(r),l=2*o*n,c=o*o,u=n*n,h=Math.cos(i/2),p=Math.sin(i/2),d=2*h*p,f=p*p,m=1-u*h*h,g=m?1/m:0,y=m?Math.acos(n*h)*Math.sqrt(1/m):0,x=.5*(2*y*n*p+2*i/Math.PI)-e,v=.5*(y*o+r)-t,b=.5*g*(u*f+y*n*h*c)+1/Math.PI,w=g*(d*l/4-y*o*p),T=.125*g*(l*p-y*o*u*d),E=.5*g*(c*h+y*f*n)+.5,S=w*T-E*b;a=(v*w-x*E)/S,s=(x*T-v*b)/S,i=_(i-a,-Math.PI,Math.PI),r=_(r-s,-ju,ju)}while((Math.abs(a)>o||Math.abs(s)>o)&&--n>0);return new LngLat(c(i),c(r))}}class CylindricalEqualArea extends Projection{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(l(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,t){const{scale:i,cosPhi:r}=this;return{x:l(e)*r*i+.5,y:-Math.sin(l(t))/r*i+.5,z:0}}unproject(e,t){const{scale:i,cosPhi:r}=this,n=-(t-.5)/i,o=_(c((e-.5)/i)/r,-180,180),a=Math.asin(_(n*r,-1,1)),s=_(c(a),-85.051129,Lo);return new LngLat(o,s)}}class Globe extends Mercator{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug","custom"],this.range=[3,5]}projectTilePoint(e,t,i){const r=cu(e,t,i);return Wa(r,r,pu(tu(i))),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,t){const i=lu(t.lat,t.lng),n=Za([],i),o=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude;Na(i,i,n,Po(1,0)*Eo*o);const a=ya(new Float64Array(16));return va(a,e.pixelMatrix,e.globeMatrix),Wa(i,i,a),new r(i[0],i[1])}pixelsPerMeter(e,t){return Po(1,0)*t}pixelSpaceConversion(e,t,i){const r=xi(Po(1,45)*t,Po(1,e)*t,i);return this.pixelsPerMeter(e,t)/r}createTileMatrix(e,t,i){const r=du(tu(i.canonical));return va(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,t){const{center:i}=e,r=pu(tu(t));return Ea(r,r,l(i.lng)),Ta(r,r,l(i.lat)),wa(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(e,t,i,r){return Qc(e,t,i,!0)||new MercatorCoordinate(0,0)}pointCoordinate3D(e,t,i){const r=this.pointCoordinate(e,t,i,0);return[r.x,r.y,r.z]}isPointAboveHorizon(e,t){return!Qc(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(e,t){const i=e.cameraToCenterDistance,r=e._centerAltitude*t,n=e._camera,o=e._camera.forward(),a=Ra([],ja([],o,-i),[0,0,r]),s=e.worldSize/(2*Math.PI),l=[0,0,-s],c=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=ja([],n.up(),u),p=ja([],n.right(),u*c),d=Za([],Ra([],Ra([],o,h),p)),f=[];let m;if(new Ray(a,d).closestPointOnSphere(l,s,f)){const t=Ra([],f,l),i=Ja([],t,a);m=Math.cos(e.fovAboveCenter)*La(i)}else{const e=Ja([],a,l),t=Ja([],l,a);Za(t,t);const i=La(e)-s;m=Math.sqrt(i*(i+2*s));const r=Math.acos(m/(s+i))-Math.acos(qa(o,t));m*=Math.cos(r)}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),i=_u(e.zoom);if(i>0){const r=Cu(e,Po(1,e.center.lat)*e.worldSize),n=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return xi(t,r+n*(1-Math.cos(o)),Math.pow(i,10))}return t}upVector(e,t,i){return cu(t,i,e,1)}upVectorScale(e){return{metersToTile:Hc*uu(tu(e))}}}function Nu(e){const t=e.parallels,i=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case"mercator":return new Mercator(e);case"equirectangular":return new Equirectangular(e);case"naturalEarth":return new NaturalEarth(e);case"equalEarth":return new EqualEarth(e);case"winkelTripel":return new WinkelTripel(e);case"albers":return i?new CylindricalEqualArea(e):new Albers(e);case"lambertConformalConic":return i?new CylindricalEqualArea(e):new LambertConformalConic(e);case"globe":return new Globe(e)}throw new Error(`Invalid projection name: ${e.name}`)}const Gu=gl.VectorTileFeature.types,Zu=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function qu(e,t,i,r,n,o,a,s,l,c,u,h,p){const d=s?Math.min(32640,Math.round(s[0])):0,f=s?Math.min(32640,Math.round(s[1])):0;e.emplaceBack(t,i,Math.round(32*r),Math.round(32*n),o,a,(d<<1)+(l?1:0),f,16*c,16*u,256*h,256*p)}function $u(e,t,i,r,n,o,a){e.emplaceBack(t,i,r,n,o,a)}function Wu(e,t,i,r,n){const o=5*t+2;e.float32[o+0]=i,e.float32[o+1]=r,e.float32[o+2]=n}function Hu(e,t,i,r,n){e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n)}function Xu(e){for(const t of e.sections)if(Vn(t.text))return!0;return!1}class SymbolBuffers{constructor(e){this.layoutVertexArray=new StructArrayLayout4i4ui4i24,this.indexArray=new StructArrayLayout3ui6,this.programConfigurations=e,this.segments=new SegmentVector,this.dynamicLayoutVertexArray=new StructArrayLayout4f16,this.opacityVertexArray=new StructArrayLayout1ul4,this.placedSymbolArray=new PlacedSymbolArray,this.globeExtVertexArray=new StructArrayLayout3i3f20}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(e,t,i,r){this.isEmpty()||(i&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Xl.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Jl.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,Zu,!0),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Kl.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}}En(SymbolBuffers,"SymbolBuffers");class CollisionBuffers{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new SegmentVector,this.collisionVertexArray=new StructArrayLayout2ub2f12,this.collisionVertexArrayExt=new StructArrayLayout3f12}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Yl.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,Ql.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}En(CollisionBuffers,"CollisionBuffers");class SymbolBucket{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=ya([]),this.placementViewportMatrix=ya([]);const t=this.layers[0]._unevaluatedLayout._values;this.textSizeData=rc(this.zoom,t["text-size"]),this.iconSizeData=rc(this.zoom,t["icon-size"]);const i=this.layers[0].layout,r=i.get("symbol-sort-key"),n=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==n&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===n||"auto"===n&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((e=>Bc[e])),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.sourceID=e.sourceID,this.projection=e.projection}createArrays(){this.text=new SymbolBuffers(new ProgramConfigurationSet(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new SymbolBuffers(new ProgramConfigurationSet(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new GlyphOffsetArray,this.lineVertexArray=new SymbolLineVertexArray,this.symbolInstances=new SymbolInstanceArray}calculateGlyphDependencies(e,t,i,r,n){for(let i=0;i<e.length;i++)if(t[e.charCodeAt(i)]=!0,r&&n){const r=lc[e.charAt(i)];r&&(t[r.charCodeAt(0)]=!0)}}populate(e,t,i,r){const n=this.layers[0],o=n.layout,a="globe"===this.projection.name,s=o.get("text-font"),l=o.get("text-field"),c=o.get("icon-image"),u=("constant"!==l.value.kind||l.value.value instanceof Formatted&&!l.value.value.isEmpty()||l.value.value.toString().length>0)&&("constant"!==s.value.kind||s.value.value.length>0),h="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,p=o.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const d=t.iconDependencies,f=t.glyphDependencies,m=t.availableImages,_=new EvaluationParameters(this.zoom);for(const{feature:t,id:l,index:c,sourceLayerIndex:g}of e){const e=n._featureFilter.needGeometry,y=Zo(t,e);if(!n._featureFilter.filter(_,y,i))continue;if(e||(y.geometry=Go(t,i,r)),a&&1!==t.type&&i.z<=5){const e=y.geometry,t=.98078528056;for(let r=0;r<e.length;r++)e[r]=Vo(e[r],(e=>e),((e,r)=>qa(cu(e.x,e.y,i,1),cu(r.x,r.y,i,1))<t))}let x,v;if(u){const e=n.getValueAndResolveTokens("text-field",y,i,m),t=Formatted.factory(e);Xu(t)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===Xn()||this.hasRTLText&&Jn.isParsed())&&(x=sc(t,n,y))}if(h){const e=n.getValueAndResolveTokens("icon-image",y,i,m);v=e instanceof ResolvedImage?e:ResolvedImage.fromString(e)}if(!x&&!v)continue;const b=this.sortFeaturesByKey?p.evaluate(y,{},i):void 0;if(this.features.push({id:l,text:x,icon:v,index:c,sourceLayerIndex:g,geometry:y.geometry,properties:t.properties,type:Gu[t.type],sortKey:b}),v&&(d[v.name]=!0),x){const e=s.evaluate(y,{},i).join(","),t="map"===o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(Bc.vertical)>=0;for(const i of x.sections)if(i.image)d[i.image.name]=!0;else{const r=Bn(x.toString()),n=i.fontStack||e,o=f[n]=f[n]||{};this.calculateGlyphDependencies(i.text,o,t,this.allowVerticalPlacement,r)}}}"line"===o.get("symbol-placement")&&(this.features=function(e){const t={},i={},r=[];let n=0;function o(t){r.push(e[t]),n++}function a(e,t,n){const o=i[e];return delete i[e],i[t]=o,r[o].geometry[0].pop(),r[o].geometry[0]=r[o].geometry[0].concat(n[0]),o}function s(e,i,n){const o=t[i];return delete t[i],t[e]=o,r[o].geometry[0].shift(),r[o].geometry[0]=n[0].concat(r[o].geometry[0]),o}function l(e,t,i){const r=i?t[0][t[0].length-1]:t[0][0];return`${e}:${r.x}:${r.y}`}for(let c=0;c<e.length;c++){const u=e[c],h=u.geometry,p=u.text?u.text.toString():null;if(!p){o(c);continue}const d=l(p,h),f=l(p,h,!0);if(d in i&&f in t&&i[d]!==t[f]){const e=s(d,f,h),n=a(d,f,r[e].geometry);delete t[d],delete i[f],i[l(p,r[n].geometry,!0)]=n,r[e].geometry=null}else d in i?a(d,f,h):f in t?s(d,f,h):(o(c),t[d]=n-1,i[f]=n-1)}return r.filter((e=>e.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((e,t)=>e.sortKey-t.sortKey))}update(e,t,i,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,i,r),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,i,r))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Nu(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const i=this.lineVertexArray.length,r=e.segment;if(void 0!==r){let i=e.dist(t[r+1]),n=e.dist(t[r]);const o={};for(let e=r+1;e<t.length;e++)o[e]={x:t[e].x,y:t[e].y,tileUnitDistanceFromAnchor:i},e<t.length-1&&(i+=t[e+1].dist(t[e]));for(let e=r||0;e>=0;e--)o[e]={x:t[e].x,y:t[e].y,tileUnitDistanceFromAnchor:n},e>0&&(n+=t[e-1].dist(t[e]));for(let e=0;e<t.length;e++){const t=o[e];this.lineVertexArray.emplaceBack(t.x,t.y,t.tileUnitDistanceFromAnchor)}}return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(e,t,i,r,n,o,a,s,l,c,u,h,p,d){const f=e.indexArray,m=e.layoutVertexArray,_=e.globeExtVertexArray,g=e.segments.prepareSegment(4*t.length,m,f,this.canOverlap?o.sortKey:void 0),y=this.glyphOffsetArray.length,x=g.vertexLength,v=this.allowVerticalPlacement&&a===Bc.vertical?Math.PI/2:0,b=o.text&&o.text.sections;for(let r=0;r<t.length;r++){const{tl:n,tr:a,bl:c,br:u,tex:h,pixelOffsetTL:y,pixelOffsetBR:x,minFontScaleX:w,minFontScaleY:T,glyphOffset:E,isSDF:S,sectionIndex:A}=t[r],C=g.vertexLength,I=E[1];if(qu(m,l.x,l.y,n.x,I+n.y,h.x,h.y,i,S,y.x,y.y,w,T),qu(m,l.x,l.y,a.x,I+a.y,h.x+h.w,h.y,i,S,x.x,y.y,w,T),qu(m,l.x,l.y,c.x,I+c.y,h.x,h.y+h.h,i,S,y.x,x.y,w,T),qu(m,l.x,l.y,u.x,I+u.y,h.x+h.w,h.y+h.h,i,S,x.x,x.y,w,T),s){const t=s.anchor,i=s.up;$u(_,t.x,t.y,t.z,i[0],i[1],i[2]),$u(_,t.x,t.y,t.z,i[0],i[1],i[2]),$u(_,t.x,t.y,t.z,i[0],i[1],i[2]),$u(_,t.x,t.y,t.z,i[0],i[1],i[2]),Hu(e.dynamicLayoutVertexArray,t.x,t.y,t.z,v)}else Hu(e.dynamicLayoutVertexArray,l.x,l.y,l.z,v);f.emplaceBack(C,C+1,C+2),f.emplaceBack(C+1,C+2,C+3),g.vertexLength+=4,g.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(E[0]),r!==t.length-1&&A===t[r+1].sectionIndex||e.programConfigurations.populatePaintArrays(m.length,o,o.index,{},p,d,b&&b[A])}const w=s?s.anchor:l;e.placedSymbolArray.emplaceBack(w.x,w.y,w.z,l.x,l.y,y,this.glyphOffsetArray.length-y,x,c,u,l.segment,i?i[0]:0,i?i[1]:0,r[0],r[1],a,0,!1,0,h,0)}_commitLayoutVertex(e,t,i,r,n,o,a){e.emplaceBack(t,i,r,n,o,Math.round(a.x),Math.round(a.y))}_addCollisionDebugVertices(e,t,i,n,o,a,s){const l=i.segments.prepareSegment(4,i.layoutVertexArray,i.indexArray),c=l.vertexLength,u=s.tileAnchorX,h=s.tileAnchorY;for(let e=0;e<4;e++)i.collisionVertexArray.emplaceBack(0,0,0,0);i.collisionVertexArrayExt.emplaceBack(t,-e.padding,-e.padding),i.collisionVertexArrayExt.emplaceBack(t,e.padding,-e.padding),i.collisionVertexArrayExt.emplaceBack(t,e.padding,e.padding),i.collisionVertexArrayExt.emplaceBack(t,-e.padding,e.padding),this._commitLayoutVertex(i.layoutVertexArray,n,o,a,u,h,new r(e.x1,e.y1)),this._commitLayoutVertex(i.layoutVertexArray,n,o,a,u,h,new r(e.x2,e.y1)),this._commitLayoutVertex(i.layoutVertexArray,n,o,a,u,h,new r(e.x2,e.y2)),this._commitLayoutVertex(i.layoutVertexArray,n,o,a,u,h,new r(e.x1,e.y2)),l.vertexLength+=4;const p=i.indexArray;p.emplaceBack(c,c+1),p.emplaceBack(c+1,c+2),p.emplaceBack(c+2,c+3),p.emplaceBack(c+3,c),l.primitiveLength+=4}_addTextDebugCollisionBoxes(e,t,i,r,n,o){for(let a=r;a<n;a++){const r=i.get(a),n=this.getSymbolInstanceTextSize(e,o,t,a);this._addCollisionDebugVertices(r,n,this.textCollisionBox,r.projectedAnchorX,r.projectedAnchorY,r.projectedAnchorZ,o)}}_addIconDebugCollisionBoxes(e,t,i,r,n,o){for(let a=r;a<n;a++){const r=i.get(a),n=this.getSymbolInstanceIconSize(e,t,a);this._addCollisionDebugVertices(r,n,this.iconCollisionBox,r.projectedAnchorX,r.projectedAnchorY,r.projectedAnchorZ,o)}}generateCollisionDebugBuffers(e,t){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new CollisionBuffers(StructArrayLayout3i2i2i16,ec.members,StructArrayLayout2ui4),this.iconCollisionBox=new CollisionBuffers(StructArrayLayout3i2i2i16,ec.members,StructArrayLayout2ui4);const i=oc(this.iconSizeData,e),r=oc(this.textSizeData,e);for(let n=0;n<this.symbolInstances.length;n++){const o=this.symbolInstances.get(n);this._addTextDebugCollisionBoxes(r,e,t,o.textBoxStartIndex,o.textBoxEndIndex,o),this._addTextDebugCollisionBoxes(r,e,t,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._addIconDebugCollisionBoxes(i,e,t,o.iconBoxStartIndex,o.iconBoxEndIndex,o),this._addIconDebugCollisionBoxes(i,e,t,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex,o)}}getSymbolInstanceTextSize(e,t,i,r){const n=this.text.placedSymbolArray.get(t.rightJustifiedTextSymbolIndex>=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:r),o=nc(this.textSizeData,e,n)/24;return this.tilePixelRatio*o}getSymbolInstanceIconSize(e,t,i){const r=this.icon.placedSymbolArray.get(i),n=nc(this.iconSizeData,e,r);return this.tilePixelRatio*n}_commitDebugCollisionVertexUpdate(e,t,i){e.emplaceBack(t,-i,-i),e.emplaceBack(t,i,-i),e.emplaceBack(t,i,i),e.emplaceBack(t,-i,i)}_updateTextDebugCollisionBoxes(e,t,i,r,n,o){for(let a=r;a<n;a++){const r=i.get(a),n=this.getSymbolInstanceTextSize(e,o,t,a);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,n,r.padding)}}_updateIconDebugCollisionBoxes(e,t,i,r,n){for(let o=r;o<n;o++){const r=i.get(o),n=this.getSymbolInstanceIconSize(e,t,o);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,n,r.padding)}}updateCollisionDebugBuffers(e,t){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const i=oc(this.iconSizeData,e),r=oc(this.textSizeData,e);for(let n=0;n<this.symbolInstances.length;n++){const o=this.symbolInstances.get(n);this._updateTextDebugCollisionBoxes(r,e,t,o.textBoxStartIndex,o.textBoxEndIndex,o),this._updateTextDebugCollisionBoxes(r,e,t,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._updateIconDebugCollisionBoxes(i,e,t,o.iconBoxStartIndex,o.iconBoxEndIndex),this._updateIconDebugCollisionBoxes(i,e,t,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex)}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt)}_deserializeCollisionBoxesForSymbol(e,t,i,r,n,o,a,s,l){const c={};for(let r=t;r<i;r++){const t=e.get(r);c.textBox={x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,padding:t.padding,projectedAnchorX:t.projectedAnchorX,projectedAnchorY:t.projectedAnchorY,projectedAnchorZ:t.projectedAnchorZ,tileAnchorX:t.tileAnchorX,tileAnchorY:t.tileAnchorY},c.textFeatureIndex=t.featureIndex;break}for(let t=r;t<n;t++){const i=e.get(t);c.verticalTextBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,padding:i.padding,projectedAnchorX:i.projectedAnchorX,projectedAnchorY:i.projectedAnchorY,projectedAnchorZ:i.projectedAnchorZ,tileAnchorX:i.tileAnchorX,tileAnchorY:i.tileAnchorY},c.verticalTextFeatureIndex=i.featureIndex;break}for(let t=o;t<a;t++){const i=e.get(t);c.iconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,padding:i.padding,projectedAnchorX:i.projectedAnchorX,projectedAnchorY:i.projectedAnchorY,projectedAnchorZ:i.projectedAnchorZ,tileAnchorX:i.tileAnchorX,tileAnchorY:i.tileAnchorY},c.iconFeatureIndex=i.featureIndex;break}for(let t=s;t<l;t++){const i=e.get(t);c.verticalIconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,padding:i.padding,projectedAnchorX:i.projectedAnchorX,projectedAnchorY:i.projectedAnchorY,projectedAnchorZ:i.projectedAnchorZ,tileAnchorX:i.tileAnchorX,tileAnchorY:i.tileAnchorY},c.verticalIconFeatureIndex=i.featureIndex;break}return c}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let t=0;t<this.symbolInstances.length;t++){const i=this.symbolInstances.get(t);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}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(e,t){const i=e.placedSymbolArray.get(t),r=i.vertexStartIndex+4*i.numGlyphs;for(let t=i.vertexStartIndex;t<r;t+=4)e.indexArray.emplaceBack(t,t+1,t+2),e.indexArray.emplaceBack(t+1,t+2,t+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const t=Math.sin(e),i=Math.cos(e),r=[],n=[],o=[];for(let e=0;e<this.symbolInstances.length;++e){o.push(e);const a=this.symbolInstances.get(e);r.push(0|Math.round(t*a.tileAnchorX+i*a.tileAnchorY)),n.push(a.featureIndex)}return o.sort(((e,t)=>r[e]-r[t]||n[t]-n[e])),o}addToSortKeyRanges(e,t){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===t?i.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex),[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex].forEach(((e,t,i)=>{e>=0&&i.indexOf(e)===t&&this.addIndicesForPlacedSymbol(this.text,e)})),t.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,t.verticalPlacedTextSymbolIndex),t.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.placedIconSymbolIndex),t.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}En(SymbolBucket,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),SymbolBucket.MAX_GLYPHS=65535,SymbolBucket.addDynamicAttributes=Hu;const Ku=new Properties({"symbol-placement":new DataConstantProperty(ct.layout_symbol["symbol-placement"]),"symbol-spacing":new DataConstantProperty(ct.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new DataConstantProperty(ct.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new DataDrivenProperty(ct.layout_symbol["symbol-sort-key"]),"symbol-z-order":new DataConstantProperty(ct.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new DataConstantProperty(ct.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new DataConstantProperty(ct.layout_symbol["icon-ignore-placement"]),"icon-optional":new DataConstantProperty(ct.layout_symbol["icon-optional"]),"icon-rotation-alignment":new DataConstantProperty(ct.layout_symbol["icon-rotation-alignment"]),"icon-size":new DataDrivenProperty(ct.layout_symbol["icon-size"]),"icon-text-fit":new DataConstantProperty(ct.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new DataConstantProperty(ct.layout_symbol["icon-text-fit-padding"]),"icon-image":new DataDrivenProperty(ct.layout_symbol["icon-image"]),"icon-rotate":new DataDrivenProperty(ct.layout_symbol["icon-rotate"]),"icon-padding":new DataConstantProperty(ct.layout_symbol["icon-padding"]),"icon-keep-upright":new DataConstantProperty(ct.layout_symbol["icon-keep-upright"]),"icon-offset":new DataDrivenProperty(ct.layout_symbol["icon-offset"]),"icon-anchor":new DataDrivenProperty(ct.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new DataConstantProperty(ct.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new DataConstantProperty(ct.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new DataConstantProperty(ct.layout_symbol["text-rotation-alignment"]),"text-field":new DataDrivenProperty(ct.layout_symbol["text-field"]),"text-font":new DataDrivenProperty(ct.layout_symbol["text-font"]),"text-size":new DataDrivenProperty(ct.layout_symbol["text-size"]),"text-max-width":new DataDrivenProperty(ct.layout_symbol["text-max-width"]),"text-line-height":new DataDrivenProperty(ct.layout_symbol["text-line-height"]),"text-letter-spacing":new DataDrivenProperty(ct.layout_symbol["text-letter-spacing"]),"text-justify":new DataDrivenProperty(ct.layout_symbol["text-justify"]),"text-radial-offset":new DataDrivenProperty(ct.layout_symbol["text-radial-offset"]),"text-variable-anchor":new DataConstantProperty(ct.layout_symbol["text-variable-anchor"]),"text-anchor":new DataDrivenProperty(ct.layout_symbol["text-anchor"]),"text-max-angle":new DataConstantProperty(ct.layout_symbol["text-max-angle"]),"text-writing-mode":new DataConstantProperty(ct.layout_symbol["text-writing-mode"]),"text-rotate":new DataDrivenProperty(ct.layout_symbol["text-rotate"]),"text-padding":new DataConstantProperty(ct.layout_symbol["text-padding"]),"text-keep-upright":new DataConstantProperty(ct.layout_symbol["text-keep-upright"]),"text-transform":new DataDrivenProperty(ct.layout_symbol["text-transform"]),"text-offset":new DataDrivenProperty(ct.layout_symbol["text-offset"]),"text-allow-overlap":new DataConstantProperty(ct.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new DataConstantProperty(ct.layout_symbol["text-ignore-placement"]),"text-optional":new DataConstantProperty(ct.layout_symbol["text-optional"])});var Ju={paint:new Properties({"icon-opacity":new DataDrivenProperty(ct.paint_symbol["icon-opacity"]),"icon-color":new DataDrivenProperty(ct.paint_symbol["icon-color"]),"icon-halo-color":new DataDrivenProperty(ct.paint_symbol["icon-halo-color"]),"icon-halo-width":new DataDrivenProperty(ct.paint_symbol["icon-halo-width"]),"icon-halo-blur":new DataDrivenProperty(ct.paint_symbol["icon-halo-blur"]),"icon-translate":new DataConstantProperty(ct.paint_symbol["icon-translate"]),"icon-translate-anchor":new DataConstantProperty(ct.paint_symbol["icon-translate-anchor"]),"text-opacity":new DataDrivenProperty(ct.paint_symbol["text-opacity"]),"text-color":new DataDrivenProperty(ct.paint_symbol["text-color"],{runtimeType:xt,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new DataDrivenProperty(ct.paint_symbol["text-halo-color"]),"text-halo-width":new DataDrivenProperty(ct.paint_symbol["text-halo-width"]),"text-halo-blur":new DataDrivenProperty(ct.paint_symbol["text-halo-blur"]),"text-translate":new DataConstantProperty(ct.paint_symbol["text-translate"]),"text-translate-anchor":new DataConstantProperty(ct.paint_symbol["text-translate-anchor"])}),layout:Ku};class FormatSectionOverride{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:mt,this.defaultValue=e}evaluate(e){if(e.formattedSection){const t=this.defaultValue.property.overrides;if(t&&t.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}En(FormatSectionOverride,"FormatSectionOverride",{omit:["defaultValue"]});class SymbolStyleLayer extends StyleLayer{constructor(e){super(e,Ju)}recalculate(e,t){super.recalculate(e,t),"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 i=this.layout.get("text-writing-mode");if(i){const e=[];for(const t of i)e.indexOf(t)<0&&e.push(t);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(e,t,i,r){const n=this.layout.get(e).evaluate(t,{},i,r),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||Er(o.value)||!n?n:function(e,t){return t.replace(/{([^{}]+)}/g,((t,i)=>i in e?String(e[i]):""))}(t.properties,n)}createBucket(e){return new SymbolBucket(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of Ju.paint.overridableProperties){if(!SymbolStyleLayer.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new FormatSectionOverride(t),r=new StyleExpression(i,t.property.specification);let n=null;n="constant"===t.value.kind||"source"===t.value.kind?new ZoomConstantExpression("source",r):new ZoomDependentExpression("composite",r,t.value.zoomStops,t.value._interpolationType),this.paint._values[e]=new PossiblyEvaluatedPropertyValue(t.property,n,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven())&&SymbolStyleLayer.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),r=Ju.paint.properties[t];let n=!1;const o=e=>{for(const t of e)if(r.overrides&&r.overrides.hasOverride(t))return void(n=!0)};if("constant"===i.value.kind&&i.value.value instanceof Formatted)o(i.value.value.sections);else if("source"===i.value.kind){const e=t=>{n||(t instanceof Vt&&Ft(t.value)===Tt?o(t.value.sections):t instanceof FormatExpression?o(t.sections):t.eachChild(e))},t=i.value;t._styleExpression&&e(t._styleExpression.expression)}return n}getProgramConfiguration(e){return new ProgramConfiguration(this,e)}}var Yu={paint:new Properties({"background-color":new DataConstantProperty(ct.paint_background["background-color"]),"background-pattern":new CrossFadedProperty(ct.paint_background["background-pattern"]),"background-opacity":new DataConstantProperty(ct.paint_background["background-opacity"])})},Qu={paint:new Properties({"raster-opacity":new DataConstantProperty(ct.paint_raster["raster-opacity"]),"raster-hue-rotate":new DataConstantProperty(ct.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new DataConstantProperty(ct.paint_raster["raster-brightness-min"]),"raster-brightness-max":new DataConstantProperty(ct.paint_raster["raster-brightness-max"]),"raster-saturation":new DataConstantProperty(ct.paint_raster["raster-saturation"]),"raster-contrast":new DataConstantProperty(ct.paint_raster["raster-contrast"]),"raster-resampling":new DataConstantProperty(ct.paint_raster["raster-resampling"]),"raster-fade-duration":new DataConstantProperty(ct.paint_raster["raster-fade-duration"])})};class CustomStyleLayer extends StyleLayer{constructor(e){super(e,{}),this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)}}var eh={paint:new Properties({"sky-type":new DataConstantProperty(ct.paint_sky["sky-type"]),"sky-atmosphere-sun":new DataConstantProperty(ct.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new DataConstantProperty(ct.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new DataConstantProperty(ct.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new DataConstantProperty(ct.paint_sky["sky-gradient-radius"]),"sky-gradient":new ColorRampProperty(ct.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new DataConstantProperty(ct.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new DataConstantProperty(ct.paint_sky["sky-atmosphere-color"]),"sky-opacity":new DataConstantProperty(ct.paint_sky["sky-opacity"])})};function th(e,t,i){const r=[0,0,1],n=ns([]);return as(n,n,i?-l(e)+Math.PI:l(e)),os(n,n,-l(t)),Xa(r,r,n),Za(r,r)}const ih={circle:class CircleStyleLayer extends StyleLayer{constructor(e){super(e,ua)}createBucket(e){return new CircleBucket(e)}queryRadius(e){const t=e;return oa("circle-radius",this,t)+oa("circle-stroke-width",this,t)+aa(this.paint.get("circle-translate"))}queryIntersectsFeature(e,t,i,r,n,o,a,s){const l=la(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),c=this.paint.get("circle-radius").evaluate(t,i)+this.paint.get("circle-stroke-width").evaluate(t,i);return ls(e,r,o,a,s,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,c)}getProgramIds(){return["circle"]}getProgramConfiguration(e){return new ProgramConfiguration(this,e)}},heatmap:class HeatmapStyleLayer extends StyleLayer{createBucket(e){return new HeatmapBucket(e)}constructor(e){super(e,_s),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=gs({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(e){return oa("heatmap-radius",this,e)}queryIntersectsFeature(e,t,i,n,o,a,s,l){const c=this.paint.get("heatmap-radius").evaluate(t,i);return ls(e,n,a,s,l,!0,!0,new r(0,0),c)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(e){return new ProgramConfiguration(this,e)}},hillshade:class HillshadeStyleLayer extends StyleLayer{constructor(e){super(e,ys)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class FillStyleLayer extends StyleLayer{constructor(e){super(e,nl)}getProgramIds(){const e=this.paint.get("fill-pattern"),t=e&&e.constantOr(1),i=[t?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&i.push(t&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),i}getProgramConfiguration(e){return new ProgramConfiguration(this,e)}recalculate(e,t){super.recalculate(e,t);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new FillBucket(e)}queryRadius(){return aa(this.paint.get("fill-translate"))}queryIntersectsFeature(e,t,i,r,n,o){return!e.queryGeometry.isAboveHorizon&&Xo(sa(e.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),r)}isTileClipped(){return!0}},"fill-extrusion":class FillExtrusionStyleLayer extends StyleLayer{constructor(e){super(e,zl)}createBucket(e){return new FillExtrusionBucket(e)}queryRadius(){return aa(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(e){return new ProgramConfiguration(this,e)}queryIntersectsFeature(e,t,i,n,o,a,s,l,c){const u=la(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,e.pixelToTileUnitsFactor),h=this.paint.get("fill-extrusion-height").evaluate(t,i),p=this.paint.get("fill-extrusion-base").evaluate(t,i),d=[0,0],f=l&&a.elevation,m=a.elevation?a.elevation.exaggeration():1,_=e.tile.getBucket(this);if(f&&_ instanceof FillExtrusionBucket){const e=_.centroidVertexArray,t=c+1;if(t<e.length){const i=e.get(t);d[0]=i.a_centroid_pos0,d[1]=i.a_centroid_pos1}}if(0===d[0]&&1===d[1])return!1;"globe"===a.projection.name&&(n=Pl([n],[new r(0,0),new r(Eo,Eo)],e.tileID.canonical).map((e=>e.polygon)).flat());const g=function(e,t,i,n,o,a,s,l,c,u,h){return"globe"===e.projection.name?function(e,t,i,r,n,o,a,s,l,c,u){const h=[],p=[],d=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(e,t,i,r)=>{e[0]=t,e[1]=i,e[2]=r,e[3]=1},g=Ml();i>0&&(i+=g),r+=g;for(const g of t){const t=[],y=[];for(const h of g){const p=h.x+n.x,g=h.y+n.y,x=e.projection.projectTilePoint(p,g,u),v=e.projection.upVector(u,h.x,h.y);let b=i,w=r;if(a){const e=Ol(p,g,i,r,a,s,l,c);b+=e.base,w+=e.top}0!==i?_(f,x.x+v[0]*d*b,x.y+v[1]*d*b,x.z+v[2]*d*b):_(f,x.x,x.y,x.z),_(m,x.x+v[0]*d*w,x.y+v[1]*d*w,x.z+v[2]*d*w),Wa(f,f,o),Wa(m,m,o),t.push(Fl(f)),y.push(Fl(m))}h.push(t),p.push(y)}return[h,p]}(e,t,i,n,o,a,s,l,c,u,h):s?function(e,t,i,r,n,o,a,s,l){const c=[],u=[],h=[0,0,0,1];for(const p of e){const e=[],d=[];for(const c of p){const u=c.x+r.x,p=c.y+r.y,f=Ol(u,p,t,i,o,a,s,l);h[0]=u,h[1]=p,h[2]=f.base,h[3]=1,is(h,h,n),h[3]=Math.max(h[3],1e-5);const m=Fl([h[0]/h[3],h[1]/h[3],h[2]/h[3]]);h[0]=u,h[1]=p,h[2]=f.top,h[3]=1,is(h,h,n),h[3]=Math.max(h[3],1e-5);const _=Fl([h[0]/h[3],h[1]/h[3],h[2]/h[3]]);e.push(m),d.push(_)}c.push(e),u.push(d)}return[c,u]}(t,i,n,o,a,s,l,c,u):function(e,t,i,n,o){const a=[],s=[],l=o[8]*t,c=o[9]*t,u=o[10]*t,h=o[11]*t,p=o[8]*i,d=o[9]*i,f=o[10]*i,m=o[11]*i;for(const t of e){const e=[],i=[];for(const a of t){const t=a.x+n.x,s=a.y+n.y,_=o[0]*t+o[4]*s+o[12],g=o[1]*t+o[5]*s+o[13],y=o[2]*t+o[6]*s+o[14],x=o[3]*t+o[7]*s+o[15],v=_+l,b=g+c,w=y+u,T=Math.max(x+h,1e-5),E=_+p,S=g+d,A=y+f,C=Math.max(x+m,1e-5),I=new r(v/T,b/T);I.z=w/T,e.push(I);const M=new r(E/C,S/C);M.z=A/C,i.push(M)}a.push(e),s.push(i)}return[a,s]}(t,i,n,o,a)}(a,n,p,h,u,s,f?l:null,d,m,a.center.lat,e.tileID.canonical),y=e.queryGeometry;return function(e,t,i){let r=1/0;Xo(i,t)&&(r=Rl(i,t[0]));for(let n=0;n<t.length;n++){const o=t[n],a=e[n];for(let e=0;e<o.length-1;e++){const t=o[e],n=[t,o[e+1],a[e+1],a[e],t];Wo(i,n)&&(r=Math.min(r,Rl(i,n)))}}return r!==1/0&&r}(g[0],g[1],y.isPointQuery()?y.screenBounds:y.screenGeometry)}},line:class LineStyleLayer extends StyleLayer{constructor(e){super(e,$l),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof yi,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=Wl.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new LineBucket(e)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getProgramConfiguration(e){return new ProgramConfiguration(this,e)}queryRadius(e){const t=e,i=Hl(oa("line-width",this,t),oa("line-gap-width",this,t)),r=oa("line-offset",this,t);return i/2+Math.abs(r)+aa(this.paint.get("line-translate"))}queryIntersectsFeature(e,t,i,n,o,a){if(e.queryGeometry.isAboveHorizon)return!1;const s=sa(e.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),a.angle,e.pixelToTileUnitsFactor),l=e.pixelToTileUnitsFactor/2*Hl(this.paint.get("line-width").evaluate(t,i),this.paint.get("line-gap-width").evaluate(t,i)),c=this.paint.get("line-offset").evaluate(t,i);return c&&(n=function(e,t){const i=[],n=new r(0,0);for(let r=0;r<e.length;r++){const o=e[r],a=[];for(let e=0;e<o.length;e++){const i=o[e-1],r=o[e],s=o[e+1],l=0===e?n:r.sub(i)._unit()._perp(),c=e===o.length-1?n:s.sub(r)._unit()._perp(),u=l._add(c)._unit();u._mult(1/(u.x*c.x+u.y*c.y)),a.push(u._mult(t)._add(r))}i.push(a)}return i}(n,c*e.pixelToTileUnitsFactor)),function(e,t,i){for(let r=0;r<t.length;r++){const n=t[r];if(e.length>=3)for(let t=0;t<n.length;t++)if(ia(e,n[t]))return!0;if(Ko(e,n,i))return!0}return!1}(s,n,l)}isTileClipped(){return!0}},symbol:SymbolStyleLayer,background:class BackgroundStyleLayer extends StyleLayer{constructor(e){super(e,Yu)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}},raster:class RasterStyleLayer extends StyleLayer{constructor(e){super(e,Qu)}getProgramIds(){return["raster"]}},sky:class SkyLayer extends StyleLayer{constructor(e){super(e,eh),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"sky-gradient"===e?this._updateColorRamp():"sky-atmosphere-sun"!==e&&"sky-atmosphere-halo-color"!==e&&"sky-atmosphere-color"!==e&&"sky-atmosphere-sun-intensity"!==e||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=gs({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(e){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const t=e.style.light.properties.get("position");return this._lightPosition.azimuthal!==t.azimuthal||this._lightPosition.polar!==t.polar}return!1}getCenter(e,t){if("atmosphere"===this.paint.get("sky-type")){const i=this.paint.get("sky-atmosphere-sun"),r=!i,n=e.style.light,o=n.properties.get("position");return r&&"viewport"===n.properties.get("anchor")&&B("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),r?th(o.azimuthal,90-o.polar,t):th(i[0],90-i[1],t)}const i=this.paint.get("sky-gradient-center");return th(i[0],90-i[1],t)}is3D(){return!1}isSky(){return!0}markSkyboxValid(e){this._skyboxInvalidated=!1,this._lightPosition=e.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const e=this.paint.get("sky-type");return"atmosphere"===e?["skyboxCapture","skybox"]:"gradient"===e?["skyboxGradient"]:null}}};function rh(e){return"custom"===e.type?new CustomStyleLayer(e):new ih[e.type](e)}class Texture{constructor(e,t,i,r){this.context=e,this.format=i,this.texture=e.gl.createTexture(),this.update(t,r)}update(t,i,r){const{width:n,height:o}=t,{context:a}=this,{gl:s}=a,{HTMLImageElement:l,HTMLCanvasElement:c,HTMLVideoElement:u,ImageData:h,ImageBitmap:p}=e;if(s.bindTexture(s.TEXTURE_2D,this.texture),a.pixelStoreUnpackFlipY.set(!1),a.pixelStoreUnpack.set(1),a.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!i||!1!==i.premultiply)),r||this.size&&this.size[0]===n&&this.size[1]===o){const{x:e,y:i}=r||{x:0,y:0};t instanceof l||t instanceof c||t instanceof u||t instanceof h||p&&t instanceof p?s.texSubImage2D(s.TEXTURE_2D,0,e,i,s.RGBA,s.UNSIGNED_BYTE,t):s.texSubImage2D(s.TEXTURE_2D,0,e,i,n,o,s.RGBA,s.UNSIGNED_BYTE,t.data)}else this.size=[n,o],t instanceof l||t instanceof c||t instanceof u||t instanceof h||p&&t instanceof p?s.texImage2D(s.TEXTURE_2D,0,this.format,this.format,s.UNSIGNED_BYTE,t):s.texImage2D(s.TEXTURE_2D,0,this.format,n,o,0,this.format,s.UNSIGNED_BYTE,t.data);this.useMipmap=Boolean(i&&i.useMipmap&&this.isSizePowerOfTwo()),this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(e,t){const{context:i}=this,{gl:r}=i;r.bindTexture(r.TEXTURE_2D,this.texture),e!==this.filter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap?e===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_NEAREST:e),this.filter=e),t!==this.wrap&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,t),this.wrap=t)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}function nh(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class ImageManager extends Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,callback:t}of this.requestors)this._notify(e,t);this.requestors=[]}}hasImage(e){return!!this.getImage(e)}getImage(e){return this.images[e]}addImage(e,t){this._validate(e,t)&&(this.images[e]=t)}_validate(e,t){let i=!0;return this._validateStretch(t.stretchX,t.data&&t.data.width)||(this.fire(new ErrorEvent(new Error(`Image "${e}" has invalid "stretchX" value`))),i=!1),this._validateStretch(t.stretchY,t.data&&t.data.height)||(this.fire(new ErrorEvent(new Error(`Image "${e}" has invalid "stretchY" value`))),i=!1),this._validateContent(t.content,t)||(this.fire(new ErrorEvent(new Error(`Image "${e}" has invalid "content" value`))),i=!1),i}_validateStretch(e,t){if(!e)return!0;let i=0;for(const r of e){if(r[0]<i||r[1]<r[0]||t<r[1])return!1;i=r[1]}return!0}_validateContent(e,t){return!(e&&(4!==e.length||e[0]<0||t.data.width<e[0]||e[1]<0||t.data.height<e[1]||e[2]<0||t.data.width<e[2]||e[3]<0||t.data.height<e[3]||e[2]<e[0]||e[3]<e[1]))}updateImage(e,t){t.version=this.images[e].version+1,this.images[e]=t,this.updatedImages[e]=!0}removeImage(e){const t=this.images[e];delete this.images[e],delete this.patterns[e],t.userImage&&t.userImage.onRemove&&t.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(e,t){let i=!0;if(!this.isLoaded())for(const t of e)this.images[t]||(i=!1);this.isLoaded()||i?this._notify(e,t):this.requestors.push({ids:e,callback:t})}_notify(e,t){const i={};for(const t of e){this.images[t]||this.fire(new Event("styleimagemissing",{id:t}));const e=this.images[t];e?i[t]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:B(`Image "${t}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}t(null,i)}getPixelSize(){const{width:e,height:t}=this.atlasImage;return{width:e,height:t}}getPattern(e){const t=this.patterns[e],i=this.getImage(e);if(!i)return null;if(t&&t.position.version===i.version)return t.position;if(t)t.position.version=i.version;else{const t={w:i.data.width+2,h:i.data.height+2,x:0,y:0},r=new ImagePosition(t,i);this.patterns[e]={bin:t,position:r}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const t=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new Texture(e,this.atlasImage,t.RGBA),this.atlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const t in this.patterns)e.push(this.patterns[t].bin);const{w:t,h:i}=Lc(e),r=this.atlasImage;r.resize({width:t||1,height:i||1});for(const e in this.patterns){const{bin:t}=this.patterns[e],i=t.x+1,n=t.y+1,o=this.images[e].data,a=o.width,s=o.height;RGBAImage.copy(o,r,{x:0,y:0},{x:i,y:n},{width:a,height:s}),RGBAImage.copy(o,r,{x:0,y:s-1},{x:i,y:n-1},{width:a,height:1}),RGBAImage.copy(o,r,{x:0,y:0},{x:i,y:n+s},{width:a,height:1}),RGBAImage.copy(o,r,{x:a-1,y:0},{x:i-1,y:n},{width:1,height:s}),RGBAImage.copy(o,r,{x:0,y:0},{x:i+a,y:n},{width:1,height:s})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const t of e){if(this.callbackDispatchedThisFrame[t])continue;this.callbackDispatchedThisFrame[t]=!0;const e=this.images[t];nh(e)&&this.updateImage(t,e)}}}const oh=new Properties({anchor:new DataConstantProperty(ct.light.anchor),position:new class LightPositionProperty{constructor(){this.specification=ct.light.position}possiblyEvaluate(e,t){return function([e,t,i]){const r=l(t+90),n=l(i);return{x:e*Math.cos(r)*Math.sin(n),y:e*Math.sin(r)*Math.sin(n),z:e*Math.cos(n),azimuthal:t,polar:i}}(e.expression.evaluate(t))}interpolate(e,t,i){return{x:xi(e.x,t.x,i),y:xi(e.y,t.y,i),z:xi(e.z,t.z,i),azimuthal:xi(e.azimuthal,t.azimuthal,i),polar:xi(e.polar,t.polar,i)}}},color:new DataConstantProperty(ct.light.color),intensity:new DataConstantProperty(ct.light.intensity)}),ah="-transition";class Light extends Evented{constructor(e){super(),this._transitionable=new Transitionable(oh),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,t={}){if(!this._validate(pn,e,t))for(const t in e){const i=e[t];M(t,ah)?this._transitionable.setTransition(t.slice(0,-ah.length),i):this._transitionable.setValue(t,i)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,i){return(!i||!1!==i.validate)&&vn(this,e.call(un,b({value:t,style:{glyphs:!0,sprite:!0},styleSpec:ct})))}}const sh=new Properties({source:new DataConstantProperty(ct.terrain.source),exaggeration:new DataConstantProperty(ct.terrain.exaggeration)}),lh="-transition";class Terrain$1 extends Evented{constructor(e,t){super(),this._transitionable=new Transitionable(sh),this.set(e),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=t}get(){return this._transitionable.serialize()}set(e){for(const t in e){const i=e[t];M(t,lh)?this._transitionable.setTransition(t.slice(0,-lh.length),i):this._transitionable.setValue(t,i)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}}function ch(e,t,i,r){const n=g(45,65,i),[o,a]=uh(e,r),s=La(t);let l=1-Math.min(1,Math.exp((s-o)/(a-o)*-6));return l*=l*l,l=Math.min(1,1.00747*l),l*n*e.alpha}function uh(e,t){const i=.5/Math.tan(.5*t);return[e.range[0]+i,e.range[1]+i]}const hh=new Properties({range:new DataConstantProperty(ct.fog.range),color:new DataConstantProperty(ct.fog.color),"high-color":new DataConstantProperty(ct.fog["high-color"]),"space-color":new DataConstantProperty(ct.fog["space-color"]),"horizon-blend":new DataConstantProperty(ct.fog["horizon-blend"]),"star-intensity":new DataConstantProperty(ct.fog["star-intensity"])}),ph="-transition";class Fog extends Evented{constructor(e,t){super(),this._transitionable=new Transitionable(hh),this.set(e),this._transitioning=this._transitionable.untransitioned(),this._transform=t}get state(){const e=this._transform,t="globe"===e.projection.name,i=_u(e.zoom),r=this.properties.get("range"),n=[.5,3];return{range:t?[xi(n[0],r[0],i),xi(n[1],r[1],i)]:r,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(e,t={}){if(!this._validate(fn,e,t)){for(const t of Object.keys(ct.fog))e&&void 0===e[t]&&(e[t]=ct.fog[t].default);for(const t in e){const i=e[t];M(t,ph)?this._transitionable.setTransition(t.slice(0,-ph.length),i):this._transitionable.setValue(t,i)}}}getOpacity(e){if(!this._transform.projection.supportsFog)return 0;const t=this.properties&&this.properties.get("color")||1;return("globe"===this._transform.projection.name?1:g(45,65,e))*t.a}getOpacityAtLatLng(e,t){return this._transform.projection.supportsFog?function(e,t,i){const r=MercatorCoordinate.fromLngLat(t),n=i.elevation?i.elevation.getAtPointOrZero(r):0,o=[r.x,r.y,n];return Wa(o,o,i.mercatorFogMatrix),ch(e,o,i.pitch,i._fov)}(this.state,e,t):0}getFovAdjustedRange(e){return this._transform.projection.supportsFog?uh(this.state,e):[0,1]}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,i){return(!i||!1!==i.validate)&&vn(this,e.call(un,b({value:t,style:{glyphs:!0,sprite:!0},styleSpec:ct})))}}class LineAtlas{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.image=new AlphaImage({width:e,height:t}),this.positions={},this.uploaded=!1}getDash(e,t){const i=this.getKey(e,t);return this.positions[i]}trim(){const e=this.width,t=this.height=A(this.nextRow);this.image.resize({width:e,height:t})}getKey(e,t){return e.join(",")+t}getDashRanges(e,t,i){const r=[];let n=e.length%2==1?-e[e.length-1]*i:0,o=e[0]*i,a=!0;r.push({left:n,right:o,isDash:a,zeroLength:0===e[0]});let s=e[0];for(let t=1;t<e.length;t++){a=!a;const l=e[t];n=s*i,s+=l,o=s*i,r.push({left:n,right:o,isDash:a,zeroLength:0===l})}return r}addRoundDash(e,t,i){const r=t/2;for(let t=-i;t<=i;t++){const n=this.width*(this.nextRow+i+t);let o=0,a=e[o];for(let s=0;s<this.width;s++){s/a.right>1&&(a=e[++o]);const l=Math.abs(s-a.left),c=Math.abs(s-a.right),u=Math.min(l,c);let h;const p=t/i*(r+1);if(a.isDash){const e=r-Math.abs(p);h=Math.sqrt(u*u+e*e)}else h=r-Math.sqrt(u*u+p*p);this.image.data[n+s]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(e,t){for(let t=e.length-1;t>=0;--t){const i=e[t],r=e[t+1];i.zeroLength?e.splice(t,1):r&&r.isDash===i.isDash&&(r.left=i.left,e.splice(t,1))}const i=e[0],r=e[e.length-1];i.isDash===r.isDash&&(i.left=r.left-this.width,r.right=i.right+this.width);const n=this.width*this.nextRow;let o=0,a=e[o];for(let i=0;i<this.width;i++){i/a.right>1&&(a=e[++o]);const r=Math.abs(i-a.left),s=Math.abs(i-a.right),l=Math.min(r,s);this.image.data[n+i]=Math.max(0,Math.min(255,(a.isDash?l:-l)+t+128))}}addDash(e,t){const i=this.getKey(e,t);if(this.positions[i])return this.positions[i];const r="round"===t,n=r?7:0,o=2*n+1;if(this.nextRow+o>this.height)return B("LineAtlas out of space"),null;0===e.length&&e.push(1);let a=0;for(let t=0;t<e.length;t++)e[t]<0&&(B("Negative value is found in line dasharray, replacing values with 0"),e[t]=0),a+=e[t];if(0!==a){const i=this.width/a,o=this.getDashRanges(e,this.width,i);r?this.addRoundDash(o,i,n):this.addRegularDash(o,"square"===t?.5*i:0)}const s=this.nextRow+n;this.nextRow+=o;const l={tl:[s,n],br:[a,0]};return this.positions[i]=l,l}}En(LineAtlas,"LineAtlas");class ThrottledInvoker{constructor(e){this._callback=e,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(){this._channel=void 0,this._callback=()=>{}}}class Scheduler{constructor(){this.tasks={},this.taskQueue=[],I(["process"],this),this.invoker=new ThrottledInvoker(this.process),this.nextId=0}add(e,t){const i=this.nextId++,r=function({type:e,isSymbolTile:t,zoom:i}){return i=i||0,"message"===e?0:"maybePrepare"!==e||t?"parseTile"!==e||t?"parseTile"===e&&t?300-i:"maybePrepare"===e&&t?400-i:500:200-i:100-i}(t);if(0===r){O();try{e()}finally{}return{cancel:()=>{}}}return this.tasks[i]={fn:e,metadata:t,priority:r,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){O();try{if(this.taskQueue=this.taskQueue.filter((e=>!!this.tasks[e])),!this.taskQueue.length)return;const e=this.pick();if(null===e)return;const t=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!t)return;t.fn()}finally{}}pick(){let e=null,t=1/0;for(let i=0;i<this.taskQueue.length;i++){const r=this.tasks[this.taskQueue[i]];r.priority<t&&(t=r.priority,e=i)}if(null===e)return null;const i=this.taskQueue[e];return this.taskQueue.splice(e,1),i}remove(){this.invoker.remove()}}class Dispatcher{constructor(e,t){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=E();const i=this.workerPool.acquire(this.id);for(let e=0;e<i.length;e++){const r=new Dispatcher.Actor(i[e],t,this.id);r.name=`Worker ${e}`,this.actors.push(r)}this.ready=!1,this.broadcast("checkIfReady",null,(()=>{this.ready=!0}))}broadcast(e,t,i){x(this.actors,((i,r)=>{i.send(e,t,r)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((e=>{e.remove()})),this.actors=[],this.workerPool.release(this.id)}}function dh(e,t,i){return t*(Eo/(e.tileSize*Math.pow(2,i-e.tileID.overscaledZ)))}Dispatcher.Actor=class Actor{constructor(t,i,r){this.target=t,this.parent=i,this.mapId=r,this.callbacks={},this.cancelCallbacks={},I(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=O()?t:e,this.scheduler=new Scheduler}send(e,t,i,r,n=!1,o){const a=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=o,this.callbacks[a]=i);const s=j(this.globalScope)?void 0:[];return this.target.postMessage({id:a,type:e,hasCallback:!!i,targetMapId:r,mustQueue:n,sourceMapId:this.mapId,data:Cn(t,s)},s),{cancel:()=>{i&&delete this.callbacks[a],this.target.postMessage({id:a,type:"<cancel>",targetMapId:r,sourceMapId:this.mapId})}}}receive(e){const t=e.data,i=t.id;if(i&&(!t.targetMapId||this.mapId===t.targetMapId))if("<cancel>"===t.type){const e=this.cancelCallbacks[i];delete this.cancelCallbacks[i],e&&e.cancel()}else if(t.mustQueue||O()){const e=this.callbacks[i];this.cancelCallbacks[i]=this.scheduler.add((()=>this.processTask(i,t)),e&&e.metadata||{type:"message"})}else this.processTask(i,t)}processTask(e,t){if("<response>"===t.type){const i=this.callbacks[e];delete this.callbacks[e],i&&(t.error?i(Mn(t.error)):i(null,Mn(t.data)))}else{const i=j(this.globalScope)?void 0:[],r=t.hasCallback?(t,r)=>{delete this.cancelCallbacks[e],this.target.postMessage({id:e,type:"<response>",sourceMapId:this.mapId,error:t?Cn(t):null,data:Cn(r,i)},i)}:e=>{},n=Mn(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,n,r);else if(this.parent.getWorkerSource){const e=t.type.split(".");this.parent.getWorkerSource(t.sourceMapId,e[0],n.source)[e[1]](n,r)}else r(new Error(`Could not find function ${t.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}};class QueryGeometry{constructor(e,t,i,r){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,r)}static createFromScreenPoints(e,t){let i,n;if(e instanceof r||"number"==typeof e[0]){const o=r.convert(e);i=[r.convert(e)],n=t.isPointAboveHorizon(o)}else{const o=r.convert(e[0]),a=r.convert(e[1]);i=[o,a],n=d(o,a).every((e=>t.isPointAboveHorizon(e)))}return new QueryGeometry(i,t.getCameraPoint(),n,t)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(e){return d(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],e)}bufferedCameraGeometry(e){const t=this.screenBounds[0],i=1===this.screenBounds.length?this.screenBounds[0].add(new r(1,1)):this.screenBounds[1],n=d(t,i,0,!1);return this.cameraPoint.y>i.y&&(this.cameraPoint.x>t.x&&this.cameraPoint.x<i.x?n.splice(3,0,this.cameraPoint):this.cameraPoint.x>=i.x?n[2]=this.cameraPoint:this.cameraPoint.x<=t.x&&(n[3]=this.cameraPoint)),function(e,t){const i=[];for(let r=0;r<e.length;r++){const n=y(r-1,-1,e.length-1),o=y(r+1,-1,e.length-1),a=e[r],s=e[o],l=e[n].sub(a).unit(),c=s.sub(a).unit(),u=c.angleWithSep(l.x,l.y),h=l.add(c).unit().mult(-1*t/Math.sin(u/2));i.push(a.add(h))}return i}(n,e)}bufferedCameraGeometryGlobe(e){const t=this.screenBounds[0],i=1===this.screenBounds.length?this.screenBounds[0].add(new r(1,1)):this.screenBounds[1],n=d(t,i,e),o=this.cameraPoint.clone();switch(3*((o.y>t.y)+(o.y>i.y))+((o.x>t.x)+(o.x>i.x))){case 0:n[0]=o,n[4]=o.clone();break;case 1:n.splice(1,0,o);break;case 2:n[1]=o;break;case 3:n.splice(4,0,o);break;case 5:n.splice(2,0,o);break;case 6:n[3]=o;break;case 7:n.splice(3,0,o);break;case 8:n[2]=o}return n}containsTile(e,t,i,n=0){const o=e.queryPadding/t._pixelsPerMercatorPixel+1,a=i?this._bufferedCameraMercator(o,t):this._bufferedScreenMercator(o,t);let s=e.tileID.wrap+(a.unwrapped?n:0);const l=a.polygon.map((t=>Pu(e.tileTransform,t,s)));if(!ra(l,0,0,Eo,Eo))return;s=e.tileID.wrap+(this.screenGeometryMercator.unwrapped?n:0);const c=this.screenGeometryMercator.polygon.map((t=>Du(e.tileTransform,t,s))),u=c.map((e=>new r(e[0],e[1]))),h=t.getFreeCameraOptions().position||new MercatorCoordinate(0,0,0),d=Du(e.tileTransform,h,s),f=c.map((e=>{const t=Ja(e,e,d);return Za(t,t),new Ray(d,t)})),m=dh(e,1,t.zoom)*t._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:f,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(g=p(l),g.min.x=_(g.min.x,0,Eo),g.min.y=_(g.min.y,0,Eo),g.max.x=_(g.max.x,0,Eo),g.max.y=_(g.max.y,0,Eo),g),tile:e,tileID:e.tileID,pixelToTileUnitsFactor:m};var g}_bufferedScreenMercator(e,t){const i=_h(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._screenRaycastCache[i]=r,r}}_bufferedCameraMercator(e,t){const i=_h(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._cameraRaycastCache[i]=r,r}}_projectAndResample(e,t){const i=function(e,t){const i=va([],t.pixelMatrix,t.globeMatrix),n=[0,-Wc,0,1],o=[0,Wc,0,1],a=[0,0,0,1];is(n,n,i),is(o,o,i),is(a,a,i);const s=new r(n[0]/n[3],n[1]/n[3]),l=new r(o[0]/o[3],o[1]/o[3]),c=ia(e,s)&&n[3]<a[3],u=ia(e,l)&&o[3]<a[3];if(!c&&!u)return null;const h=function(e,t,i){for(let r=1;r<e.length;r++){const n=mh(t.pointCoordinate3D(e[r-1]).x),o=mh(t.pointCoordinate3D(e[r]).x);if(i<0){if(n<o)return{idx:r,t:-n/(o-1-n)}}else if(o<n)return{idx:r,t:(1-n)/(o+1-n)}}return null}(e,t,c?-1:1);if(!h)return null;const{idx:p,t:d}=h;let f=p>1?fh(e.slice(0,p),t):[],m=p<e.length?fh(e.slice(p),t):[];f=f.map((e=>new r(mh(e.x),e.y))),m=m.map((e=>new r(mh(e.x),e.y)));const _=[...f];0===_.length&&_.push(m[m.length-1]);const g=xi(_[_.length-1].y,(0===m.length?f[0]:m[0]).y,d);let y;return y=c?[new r(0,g),new r(0,0),new r(1,0),new r(1,g)]:[new r(1,g),new r(1,1),new r(0,1),new r(0,g)],_.push(...y),0===m.length?_.push(f[0]):_.push(...m),{polygon:_.map((e=>new MercatorCoordinate(e.x,e.y))),unwrapped:!1}}(e,t);if(i)return i;const n=function(e,t){let i=!1,r=-1/0,n=0;for(let t=0;t<e.length-1;t++)e[t].x>r&&(r=e[t].x,n=t);for(let t=0;t<e.length-1;t++){const r=(n+t)%(e.length-1),o=e[r],a=e[r+1];Math.abs(o.x-a.x)>.5&&(o.x<a.x?(o.x+=1,0===r&&(e[e.length-1].x+=1)):(a.x+=1,r+1===e.length-1&&(e[0].x+=1)),i=!0)}const o=Io(t.center.lng);return i&&o<Math.abs(o-1)&&e.forEach((e=>{e.x-=1})),{polygon:e,unwrapped:i}}(fh(e,t).map((e=>new r(mh(e.x),e.y))),t);return{polygon:n.polygon.map((e=>new MercatorCoordinate(e.x,e.y))),unwrapped:n.unwrapped}}}function fh(e,t){return Fo(e,(e=>{const i=t.pointCoordinate3D(e);e.x=i.x,e.y=i.y}),1/256)}function mh(e){return e<0?1+e%1:e%1}function _h(e){return 100*e|0}function gh(e,t,i,r,n){const o=function(i,r){if(i)return n(i);if(r){const i=w(b(r,e),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);r.vector_layers&&(i.vectorLayers=r.vector_layers,i.vectorLayerIds=i.vectorLayers.map((e=>e.id))),r.language_options&&(i.languageOptions=r.language_options),r.language&&r.language[r.id]&&(i.language=r.language[r.id]),r.worldview_options&&(i.worldviewOptions=r.worldview_options),r.worldview?i.worldview=r.worldview[r.id]:r.worldview_default&&(i.worldview=r.worldview_default),i.tiles=t.canonicalizeTileset(i,e.url),n(null,i)}};return e.url?Ye(t.transformRequest(t.normalizeSourceURL(e.url,null,i,r),Xe.Source),o):ee.frame((()=>o(null,e)))}class TileBounds{constructor(e,t,i){this.bounds=LngLatBounds.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=i||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const t=Math.pow(2,e.z),i=Math.floor(Io(this.bounds.getWest())*t),r=Math.floor(Mo(this.bounds.getNorth())*t),n=Math.ceil(Io(this.bounds.getEast())*t),o=Math.ceil(Mo(this.bounds.getSouth())*t);return e.x>=i&&e.x<n&&e.y>=r&&e.y<o}}class DictionaryCoder{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t<e.length;t++){const i=e[t];this._stringToNumber[i]=t,this._numberToString[t]=i}}encode(e){return this._stringToNumber[e]}decode(e){return this._numberToString[e]}}const yh=["tile","layer","source","sourceLayer","state"];class Feature{constructor(e,t,i,r,n){this.type="Feature",this._vectorTileFeature=e,this._z=t,this._x=i,this._y=r,this.properties=e.properties,this.id=n}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={type:"Feature",geometry:this.geometry,properties:this.properties};void 0!==this.id&&(e.id=this.id);for(const t of yh)void 0!==this[t]&&(e[t]=this[t]);return e}}const xh=32,vh=33,bh=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,i=0,r=0,n=0,o=0,a=0,s=0;for(1&t?n=o=a=xh:i=r=s=xh;(t>>=1)>1;){const e=i+n>>1,l=r+o>>1;1&t?(n=i,o=r,i=a,r=s):(i=n,r=o,n=a,o=s),a=e,s=l}const l=4*e;bh[l+0]=i,bh[l+1]=r,bh[l+2]=n,bh[l+3]=o}const wh=new Uint16Array(2178),Th=new Uint8Array(1089),Eh=new Uint16Array(1089);function Sh(e){return 0===e?-.03125:32===e?.03125:0}var Ah=eo([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const Ch={type:2,extent:Eo,loadGeometry:()=>[[new r(0,0),new r(8193,0),new r(8193,8193),new r(0,8193),new r(0,0)]]};class Tile{constructor(e,t,i,r,n){this.tileID=e,this.uid=E(),this.uses=0,this.tileSize=t,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=n,this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection)}registerFadeDuration(e){const t=e+this.timeAdded;t<ee.now()||this.fadeEndTime&&t<this.fadeEndTime||(this.fadeEndTime=t)}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}get tileTransform(){return this._tileTransform||(this._tileTransform=Iu(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(e,t,i){if(this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(e,t){const i={};if(!t)return i;for(const r of e){const e=r.layerIds.map((e=>t.getLayer(e))).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(const t of e)i[t.id]=r}}return i}(e.buckets,t.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const t=this.buckets[e];if(t instanceof SymbolBucket){if(this.hasSymbolBuckets=!0,!i)break;t.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const t=this.buckets[e];if(t instanceof SymbolBucket&&t.hasRTLText){this.hasRTLText=!0,Jn.isLoading()||Jn.isLoaded()||"deferred"!==Xn()||Kn();break}}this.queryPadding=0;for(const e in this.buckets){const i=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,t.style.getLayer(e).queryRadius(i))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas)}else this.collisionBoxArray=new CollisionBoxArray}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].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._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const i=this.buckets[t];i.uploadPending()&&i.upload(e)}const t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Texture(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Texture(e,this.glyphAtlasImage,t.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Texture(e,this.lineAtlas.image,t.ALPHA),this.lineAtlas.uploaded=!0)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,i,r,n,o,a,s){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:r,pixelPosMatrix:a,transform:o,params:n,tileTransform:this.tileTransform},e,t,i):{}}querySourceFeatures(e,t){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const r=i.loadVTLayers(),n=t?t.sourceLayer:"",o=r._geojsonTileLayer||r[n];if(!o)return;const a=Rr(t&&t.filter),{z:s,x:l,y:c}=this.tileID.canonical,u={z:s,x:l,y:c};for(let t=0;t<o.length;t++){const r=o.feature(t);if(a.needGeometry){const e=Zo(r,!0);if(!a.filter(new EvaluationParameters(this.tileID.overscaledZ),e,this.tileID.canonical))continue}else if(!a.filter(new EvaluationParameters(this.tileID.overscaledZ),r))continue;const h=i.getId(r,n),p=new Feature(r,s,l,c,h);p.tile=u,e.push(p)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return!!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){const t=this.expirationTime;if(e.cacheControl){const t=V(e.cacheControl);t["max-age"]&&(this.expirationTime=Date.now()+1e3*t["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){const e=Date.now();let i=!1;if(this.expirationTime>e)i=!1;else if(t)if(this.expirationTime<t)i=!0;else{const r=this.expirationTime-t;r?this.expirationTime=e+Math.max(r,3e4):i=!0}else i=!0;i?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-(new Date).getTime(),Math.pow(2,31)-1)}setFeatureState(e,t){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||0===Object.keys(e).length||!t)return;const i=this.latestFeatureIndex.loadVTLayers(),r=t.style.listImages();for(const n in this.buckets){if(!t.style.hasLayer(n))continue;const o=this.buckets[n],a=o.layers[0].sourceLayer||"_geojsonTileLayer",s=i[a],l=e[a];if(!s||!l||0===Object.keys(l).length)continue;if(o.update(l,s,r,this.imageAtlas&&this.imageAtlas.patternPositions||{}),o instanceof LineBucket||o instanceof FillBucket){const e=t.style._getSourceCache(o.layers[0].source);t._terrain&&t._terrain.enabled&&e&&o.programConfigurations.needsUpload&&t._terrain._clearRenderCacheForTile(e.id,this.tileID)}const c=t&&t.style&&t.style.getLayer(n);c&&(this.queryPadding=Math.max(this.queryPadding,c.queryRadius(o)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<ee.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(e){this.symbolFadeHoldUntil=ee.now()+e}setTexture(e,t){const i=t.context,r=i.gl;this.texture=t.getTileTexture(e.width),this.texture?this.texture.update(e,{useMipmap:!0}):(this.texture=new Texture(i,e,r.RGBA,{useMipmap:!0}),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),i.extTextureFilterAnisotropic&&r.texParameterf(r.TEXTURE_2D,i.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,i.extTextureFilterAnisotropicMax))}setDependencies(e,t){const i={};for(const e of t)i[e]=!0;this.dependencies[e]=i}hasDependency(e,t){for(const i of e){const e=this.dependencies[i];if(e)for(const i of t)if(e[i])return!0}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(e,t){if(!t||"mercator"===t.name||this._tileDebugBuffer)return;const i=Go(Ch,this.tileID.canonical,this.tileTransform)[0],r=new StructArrayLayout2i4,n=new StructArrayLayout1ui2;for(let e=0;e<i.length;e++){const{x:t,y:o}=i[e];r.emplaceBack(t,o),n.emplaceBack(e)}n.emplaceBack(0),this._tileDebugIndexBuffer=e.createIndexBuffer(n),this._tileDebugBuffer=e.createVertexBuffer(r,$c.members),this._tileDebugSegments=SegmentVector.simpleSegment(0,0,r.length,n.length)}_makeTileBoundsBuffers(e,t){if(this._tileBoundsBuffer||!t||"mercator"===t.name)return;const i=Go(Ch,this.tileID.canonical,this.tileTransform)[0];let r,n;if(this.isRaster){const e=function(e,t){const i=Iu(e,t),r=Math.pow(2,e.z);for(let n=0;n<vh;n++)for(let o=0;o<vh;o++){const a=Do((e.x+(o+Sh(o))/xh)/r),s=zo((e.y+(n+Sh(n))/xh)/r),l=t.project(a,s),c=n*vh+o;wh[2*c+0]=Math.round((l.x*i.scale-i.x)*Eo),wh[2*c+1]=Math.round((l.y*i.scale-i.y)*Eo)}Th.fill(0),Eh.fill(0);for(let e=2045;e>=0;e--){const t=4*e,i=bh[t+0],r=bh[t+1],n=bh[t+2],o=bh[t+3],a=i+n>>1,s=r+o>>1,l=a+s-r,c=s+i-a,u=r*vh+i,h=o*vh+n,p=s*vh+a,d=Math.hypot((wh[2*u+0]+wh[2*h+0])/2-wh[2*p+0],(wh[2*u+1]+wh[2*h+1])/2-wh[2*p+1])>=16;if(Th[p]=Th[p]||(d?1:0),e<1022){const e=(r+c>>1)*vh+(i+l>>1),t=(o+c>>1)*vh+(n+l>>1);Th[p]=Th[p]||Th[e]||Th[t]}}const n=new StructArrayLayout4i8,o=new StructArrayLayout3ui6;let a=0;function s(e,t){const i=t*vh+e;return 0===Eh[i]&&(n.emplaceBack(wh[2*i+0],wh[2*i+1],e*Eo/xh,t*Eo/xh),Eh[i]=++a),Eh[i]-1}function l(e,t,i,r,n,a){const c=e+i>>1,u=t+r>>1;if(Math.abs(e-n)+Math.abs(t-a)>1&&Th[u*vh+c])l(n,a,e,t,c,u),l(i,r,n,a,c,u);else{const l=s(e,t),c=s(i,r),u=s(n,a);o.emplaceBack(l,c,u)}}return l(0,0,xh,xh,xh,0),l(xh,xh,0,0,0,xh),{vertices:n,indices:o}}(this.tileID.canonical,t);r=e.vertices,n=e.indices}else{r=new StructArrayLayout4i8,n=new StructArrayLayout3ui6;for(const{x:e,y:t}of i)r.emplaceBack(e,t,0,0);const e=bs(r.int16,void 0,4);for(let t=0;t<e.length;t+=3)n.emplaceBack(e[t],e[t+1],e[t+2])}this._tileBoundsBuffer=e.createVertexBuffer(r,Ah.members),this._tileBoundsIndexBuffer=e.createIndexBuffer(n),this._tileBoundsSegments=SegmentVector.simpleSegment(0,0,r.length,n.length)}_makeGlobeTileDebugBuffers(e,t){const i=t.projection;if(!i||"globe"!==i.name||t.freezeTileCoverage)return;const r=this.tileID.canonical,n=pu(iu(r,t)),o=_u(t.zoom);let a;o>0&&(a=xa(new Float64Array(16),t.globeMatrix));const s=(r.x+.5)/(1<<r.z)-Io(t.center.lng);let l=0;s>.5?l=-1:s<-.5&&(l=1),this._makeGlobeTileDebugBorderBuffer(e,r,t,n,a,o,l),this._makeGlobeTileDebugTextBuffer(e,r,t,n,a,o,l)}_globePoint(e,t,i,r,n,o,a,s){let l=cu(e,t,i);if(o){const n=1<<i.z,c=[((e/Eo+i.x)/n+s)*r,(t/Eo+i.y)/n*r,0];Wa(c,c,o),l=vi(l,c,a)}return Wa(l,l,n)}_makeGlobeTileDebugBorderBuffer(e,t,i,r,n,o,a){const s=new StructArrayLayout2i4,l=new StructArrayLayout1ui2,c=new StructArrayLayout3i6,u=(e,u,h,p,d)=>{const f=(h-e)/(d-1),m=(p-u)/(d-1),_=s.length;for(let h=0;h<d;h++){const p=e+h*f,d=u+h*m;s.emplaceBack(p,d);const g=this._globePoint(p,d,t,i.worldSize,r,n,o,a);c.emplaceBack(g[0],g[1],g[2]),l.emplaceBack(_+h)}},h=Eo;u(0,0,h,0,16),u(h,0,h,h,16),u(h,h,0,h,16),u(0,h,0,0,16),this._tileDebugIndexBuffer=e.createIndexBuffer(l),this._tileDebugBuffer=e.createVertexBuffer(s,$c.members),this._globeTileDebugBorderBuffer=e.createVertexBuffer(c,qc.members),this._tileDebugSegments=SegmentVector.simpleSegment(0,0,s.length,l.length)}_makeGlobeTileDebugTextBuffer(e,t,i,r,n,o,a){const s=new StructArrayLayout2i4,l=new StructArrayLayout3ui6,c=new StructArrayLayout3i6,u=25;l.reserve(32),s.reserve(u),c.reserve(u);const h=(e,t)=>u*e+t;for(let e=0;e<u;e++){const l=2048*e;for(let e=0;e<u;e++){const u=2048*e;s.emplaceBack(u,l);const h=this._globePoint(u,l,t,i.worldSize,r,n,o,a);c.emplaceBack(h[0],h[1],h[2])}}for(let e=0;e<4;e++)for(let t=0;t<4;t++){const i=h(e,t),r=h(e,t+1),n=h(e+1,t),o=h(e+1,t+1);l.emplaceBack(i,r,n),l.emplaceBack(n,r,o)}this._tileDebugTextIndexBuffer=e.createIndexBuffer(l),this._tileDebugTextBuffer=e.createVertexBuffer(s,$c.members),this._globeTileDebugTextBuffer=e.createVertexBuffer(c,qc.members),this._tileDebugTextSegments=SegmentVector.simpleSegment(0,0,u,32)}}class SourceFeatureState{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,t,i){const r=String(t);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][r]=this.stateChanges[e][r]||{},b(this.stateChanges[e][r],i),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==r&&(this.deletedStates[e][t]=null)}else if(this.deletedStates[e]&&null===this.deletedStates[e][r]){this.deletedStates[e][r]={};for(const t in this.state[e][r])i[t]||(this.deletedStates[e][r][t]=null)}else for(const t in i)this.deletedStates[e]&&this.deletedStates[e][r]&&null===this.deletedStates[e][r][t]&&delete this.deletedStates[e][r][t]}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const r=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][r]&&(this.deletedStates[e][r]=this.deletedStates[e][r]||{},this.deletedStates[e][r][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][r])for(i in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][i]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null}getState(e,t){const i=String(t),r=b({},(this.state[e]||{})[i],(this.stateChanges[e]||{})[i]);if(null===this.deletedStates[e])return{};if(this.deletedStates[e]){const i=this.deletedStates[e][t];if(null===i)return{};for(const e in i)delete r[e]}return r}initializeTileState(e,t){e.setFeatureState(this.state,t)}coalesceChanges(e,t){const i={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const t={};for(const i in this.stateChanges[e])this.state[e][i]||(this.state[e][i]={}),b(this.state[e][i],this.stateChanges[e][i]),t[i]=this.state[e][i];i[e]=t}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const t={};if(null===this.deletedStates[e])for(const i in this.state[e])t[i]={},this.state[e][i]={};else for(const i in this.deletedStates[e]){if(null===this.deletedStates[e][i])this.state[e][i]={};else for(const t of Object.keys(this.deletedStates[e][i]))delete this.state[e][i][t];t[i]=this.state[e][i]}i[e]=i[e]||{},b(i[e],t)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const r in e)e[r].setFeatureState(i,t)}}class MipLevel{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(e,t){const i=this.toIdx(e,t);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(e,t){return this.leaves[this.toIdx(e,t)]}toIdx(e,t){return t*this.size+e}}function Ih(e,t,i,r){let n=0,o=Number.MAX_VALUE;for(let a=0;a<3;a++)if(Math.abs(r[a])<1e-15){if(i[a]<e[a]||i[a]>t[a])return null}else{const s=1/r[a];let l=(e[a]-i[a])*s,c=(t[a]-i[a])*s;if(l>c){const e=l;l=c,c=e}if(l>n&&(n=l),c<o&&(o=c),n>o)return null}return n}function Mh(e,t,i,r,n,o,a,s,l,c,u){const h=r-e,p=n-t,d=o-i,f=a-e,m=s-t,_=l-i,g=u[1]*_-u[2]*m,y=u[2]*f-u[0]*_,x=u[0]*m-u[1]*f,v=h*g+p*y+d*x;if(Math.abs(v)<1e-15)return null;const b=1/v,w=c[0]-e,T=c[1]-t,E=c[2]-i,S=(w*g+T*y+E*x)*b;if(S<0||S>1)return null;const A=T*d-E*p,C=E*h-w*d,I=w*p-T*h,M=(u[0]*A+u[1]*C+u[2]*I)*b;return M<0||S+M>1?null:(f*A+m*C+_*I)*b}function Ph(e,t,i){return(e-t)/(i-t)}function Dh(e,t,i,r,n,o,a,s,l){const c=1<<i,u=o-r,h=a-n,p=(e+1)/c*u+r,d=(t+0)/c*h+n,f=(t+1)/c*h+n;s[0]=(e+0)/c*u+r,s[1]=d,l[0]=p,l[1]=f}class DemMinMaxQuadTree{constructor(e){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=e,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;const t=function(e){const t=Math.ceil(Math.log2(e.dim/8)),i=[];let r=Math.ceil(Math.pow(2,t));const n=1/r,o=(e,t,i,r,n)=>{const o=r?1:0,a=(e+1)*i-o,s=t*i,l=(t+1)*i-o;n[0]=e*i,n[1]=s,n[2]=a,n[3]=l};let a=new MipLevel(r);const s=[];for(let t=0;t<r*r;t++){o(t%r,Math.floor(t/r),n,!1,s);const i=kh(s[0],s[1],e),l=kh(s[2],s[1],e),c=kh(s[2],s[3],e),u=kh(s[0],s[3],e);a.minimums.push(Math.min(i,l,c,u)),a.maximums.push(Math.max(i,l,c,u)),a.leaves.push(1)}for(i.push(a),r/=2;r>=1;r/=2){const e=i[i.length-1];a=new MipLevel(r);for(let t=0;t<r*r;t++){o(t%r,Math.floor(t/r),2,!0,s);const i=e.getElevation(s[0],s[1]),n=e.getElevation(s[2],s[1]),l=e.getElevation(s[2],s[3]),c=e.getElevation(s[0],s[3]),u=e.isLeaf(s[0],s[1]),h=e.isLeaf(s[2],s[1]),p=e.isLeaf(s[2],s[3]),d=e.isLeaf(s[0],s[3]),f=Math.min(i.min,n.min,l.min,c.min),m=Math.max(i.max,n.max,l.max,c.max),_=u&&h&&p&&d;a.maximums.push(m),a.minimums.push(f),a.leaves.push(m-f<=5&&_?1:0)}i.push(a)}return i}(this.dem),i=t.length-1,r=t[i];this._addNode(r.minimums[0],r.maximums[0],r.leaves[0]),this._construct(t,0,0,i,0)}raycastRoot(e,t,i,r,n,o,a=1){return Ih([e,t,-100],[i,r,this.maximums[0]*a],n,o)}raycast(e,t,i,r,n,o,a=1){if(!this.nodeCount)return null;const s=this.raycastRoot(e,t,i,r,n,o,a);if(null==s)return null;const l=[],c=[],u=[],h=[],p=[{idx:0,t:s,nodex:0,nodey:0,depth:0}];for(;p.length>0;){const{idx:s,t:d,nodex:f,nodey:m,depth:_}=p.pop();if(this.leaves[s]){Dh(f,m,_,e,t,i,r,u,h);const s=1<<_,l=(f+0)/s,c=(f+1)/s,p=(m+0)/s,g=(m+1)/s,y=kh(l,p,this.dem)*a,x=kh(c,p,this.dem)*a,v=kh(c,g,this.dem)*a,b=kh(l,g,this.dem)*a,w=Mh(u[0],u[1],y,h[0],u[1],x,h[0],h[1],v,n,o),T=Mh(h[0],h[1],v,u[0],h[1],b,u[0],u[1],y,n,o),E=Math.min(null!==w?w:Number.MAX_VALUE,null!==T?T:Number.MAX_VALUE);if(E!==Number.MAX_VALUE)return E;{const e=Na([],n,o,d);if(zh(y,x,b,v,Ph(e[0],u[0],h[0]),Ph(e[1],u[1],h[1]))>=e[2])return d}continue}let g=0;for(let p=0;p<this._siblingOffset.length;p++){Dh((f<<1)+this._siblingOffset[p][0],(m<<1)+this._siblingOffset[p][1],_+1,e,t,i,r,u,h),u[2]=-100,h[2]=this.maximums[this.childOffsets[s]+p]*a;const d=Ih(u,h,n,o);if(null!=d){const e=d;l[p]=e;let t=!1;for(let i=0;i<g&&!t;i++)e>=l[c[i]]&&(c.splice(i,0,p),t=!0);t||(c[g]=p),g++}}for(let e=0;e<g;e++){const t=c[e];p.push({idx:this.childOffsets[s]+t,t:l[t],nodex:(f<<1)+this._siblingOffset[t][0],nodey:(m<<1)+this._siblingOffset[t][1],depth:_+1})}}return null}_addNode(e,t,i){return this.minimums.push(e),this.maximums.push(t),this.leaves.push(i),this.childOffsets.push(0),this.nodeCount++}_construct(e,t,i,r,n){if(1===e[r].isLeaf(t,i))return;this.childOffsets[n]||(this.childOffsets[n]=this.nodeCount);const o=r-1,a=e[o];let s=0,l=0;for(let e=0;e<this._siblingOffset.length;e++){const r=2*t+this._siblingOffset[e][0],n=2*i+this._siblingOffset[e][1],o=a.getElevation(r,n),c=a.isLeaf(r,n),u=this._addNode(o.min,o.max,c);c&&(s|=1<<e),l||(l=u)}for(let r=0;r<this._siblingOffset.length;r++)s&1<<r||this._construct(e,2*t+this._siblingOffset[r][0],2*i+this._siblingOffset[r][1],o,l+r)}}function zh(e,t,i,r,n,o){return xi(xi(e,i,o),xi(t,r,o),n)}function kh(e,t,i){const r=i.dim,n=_(e*r-.5,0,r-1),o=_(t*r-.5,0,r-1),a=Math.floor(n),s=Math.floor(o),l=Math.min(a+1,r-1),c=Math.min(s+1,r-1);return zh(i.get(a,s),i.get(l,s),i.get(a,c),i.get(l,c),n-a,o-s)}const Lh={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};class DEMData{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,t,i,r=!1,n=!1){if(this.uid=e,t.height!==t.width)throw new RangeError("DEM tiles must be square");if(i&&"mapbox"!==i&&"terrarium"!==i)return B(`"${i}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=t.height;const o=this.dim=t.height-2,a=new Uint32Array(t.data.buffer);if(this.pixels=new Uint8Array(t.data.buffer),this.encoding=i||"mapbox",this.borderReady=r,!r){for(let e=0;e<o;e++)a[this._idx(-1,e)]=a[this._idx(0,e)],a[this._idx(o,e)]=a[this._idx(o-1,e)],a[this._idx(e,-1)]=a[this._idx(e,0)],a[this._idx(e,o)]=a[this._idx(e,o-1)];a[this._idx(-1,-1)]=a[this._idx(0,0)],a[this._idx(o,-1)]=a[this._idx(o-1,0)],a[this._idx(-1,o)]=a[this._idx(0,o-1)],a[this._idx(o,o)]=a[this._idx(o-1,o-1)],n&&this._buildQuadTree()}}_buildQuadTree(){this._tree=new DemMinMaxQuadTree(this)}get(e,t,i=!1){i&&(e=_(e,-1,this.dim),t=_(t,-1,this.dim));const r=4*this._idx(e,t);return("terrarium"===this.encoding?this._unpackTerrarium:this._unpackMapbox)(this.pixels[r],this.pixels[r+1],this.pixels[r+2])}static getUnpackVector(e){return Lh[e]}get unpackVector(){return Lh[this.encoding]}_idx(e,t){if(e<-1||e>=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(t+1)*this.stride+(e+1)}_unpackMapbox(e,t,i){return(256*e*256+256*t+i)/10-1e4}_unpackTerrarium(e,t,i){return 256*e+t+i/256-32768}static pack(e,t){const i=[0,0,0,0],r=DEMData.getUnpackVector(t);let n=Math.floor((e+r[3])/r[2]);return i[2]=n%256,n=Math.floor(n/256),i[1]=n%256,n=Math.floor(n/256),i[0]=n,i}getPixels(){return new RGBAImage({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let r=t*this.dim,n=t*this.dim+this.dim,o=i*this.dim,a=i*this.dim+this.dim;switch(t){case-1:r=n-1;break;case 1:n=r+1}switch(i){case-1:o=a-1;break;case 1:a=o+1}const s=-t*this.dim,l=-i*this.dim;for(let t=o;t<a;t++)for(let i=r;i<n;i++){const r=4*this._idx(i,t),n=4*this._idx(i+s,t+l);this.pixels[r+0]=e.pixels[n+0],this.pixels[r+1]=e.pixels[n+1],this.pixels[r+2]=e.pixels[n+2],this.pixels[r+3]=e.pixels[n+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}En(DEMData,"DEMData"),En(DemMinMaxQuadTree,"DemMinMaxQuadTree",{omit:["dem"]});class TileCache{constructor(e,t){this.max=e,this.onRemove=t,this.reset()}reset(){for(const e in this.data)for(const t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,i){const r=e.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);const n={value:t,timeout:void 0};if(void 0!==i&&(n.timeout=setTimeout((()=>{this.remove(e,n)}),i)),this.data[r].push(n),this.order.push(r),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const i=e.wrapped().key,r=void 0===t?0:this.data[i].indexOf(t),n=this.data[i][r];return this.data[i].splice(r,1),n.timeout&&clearTimeout(n.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(n.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){const t=[];for(const i in this.data)for(const r of this.data[i])e(r.value)||t.push(r);for(const e of t)this.remove(e.value.tileID,e)}}class IndexBuffer{constructor(e,t,i){this.context=e;const r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||t.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Bh={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class VertexBuffer{constructor(e,t,i,r){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.context=e;const n=e.gl;this.buffer=n.createBuffer(),e.bindVertexBuffer.set(this.buffer),n.bufferData(n.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||t.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let i=0;i<this.attributes.length;i++){const r=t.attributes[this.attributes[i].name];void 0!==r&&e.enableVertexAttribArray(r)}}setVertexAttribPointers(e,t,i){for(let r=0;r<this.attributes.length;r++){const n=this.attributes[r],o=t.attributes[n.name];void 0!==o&&e.vertexAttribPointer(o,n.components,e[Bh[n.type]],!1,this.itemSize,n.offset+this.itemSize*(i||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class BaseValue{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class ClearColor extends BaseValue{getDefault(){return Lt.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class ClearDepth extends BaseValue{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class ClearStencil extends BaseValue{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class ColorMask extends BaseValue{getDefault(){return[!0,!0,!0,!0]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class DepthMask extends BaseValue{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class StencilMask extends BaseValue{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class StencilFunc extends BaseValue{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}}class StencilOp extends BaseValue{getDefault(){const e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}}class StencilTest extends BaseValue{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1}}class DepthRange extends BaseValue{getDefault(){return[0,1]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}}class DepthTest extends BaseValue{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1}}class DepthFunc extends BaseValue{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class Blend extends BaseValue{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1}}class BlendFunc extends BaseValue{getDefault(){const e=this.gl;return[e.ONE,e.ZERO]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.blendFunc(e[0],e[1]),this.current=e,this.dirty=!1)}}class BlendColor extends BaseValue{getDefault(){return Lt.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class BlendEquation extends BaseValue{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}}class CullFace extends BaseValue{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1}}class CullFaceSide extends BaseValue{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class FrontFace extends BaseValue{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}class Program$1 extends BaseValue{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}}class ActiveTextureUnit extends BaseValue{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class Viewport extends BaseValue{getDefault(){const e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class BindFramebuffer extends BaseValue{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class BindRenderbuffer extends BaseValue{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class BindTexture extends BaseValue{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class BindVertexBuffer extends BaseValue{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class BindElementBuffer extends BaseValue{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class BindVertexArrayOES extends BaseValue{constructor(e){super(e),this.vao=e.extVertexArrayObject}getDefault(){return null}set(e){this.vao&&(e!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(e),this.current=e,this.dirty=!1)}}class PixelStoreUnpack extends BaseValue{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class PixelStoreUnpackPremultiplyAlpha extends BaseValue{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class PixelStoreUnpackFlipY extends BaseValue{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class FramebufferAttachment extends BaseValue{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class ColorAttachment extends FramebufferAttachment{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class DepthAttachment extends FramebufferAttachment{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,this.attachment(),t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class DepthStencilAttachment extends DepthAttachment{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class Framebuffer{constructor(e,t,i,r){this.context=e,this.width=t,this.height=i;const n=this.framebuffer=e.gl.createFramebuffer();this.colorAttachment=new ColorAttachment(e,n),r&&(this.depthAttachment=new DepthAttachment(e,n))}destroy(){const e=this.context.gl,t=this.colorAttachment.get();if(t&&e.deleteTexture(t),this.depthAttachment){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t)}e.deleteFramebuffer(this.framebuffer)}}class DepthMode{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}}DepthMode.ReadOnly=!1,DepthMode.ReadWrite=!0,DepthMode.disabled=new DepthMode(519,DepthMode.ReadOnly,[0,1]);const Rh=7680;class StencilMode{constructor(e,t,i,r,n,o){this.test=e,this.ref=t,this.mask=i,this.fail=r,this.depthFail=n,this.pass=o}}StencilMode.disabled=new StencilMode({func:519,mask:0},0,0,Rh,Rh,Rh);class ColorMode{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i}}ColorMode.Replace=[1,0],ColorMode.disabled=new ColorMode(ColorMode.Replace,Lt.transparent,[!1,!1,!1,!1]),ColorMode.unblended=new ColorMode(ColorMode.Replace,Lt.transparent,[!0,!0,!0,!0]),ColorMode.alphaBlended=new ColorMode([1,771],Lt.transparent,[!0,!0,!0,!0]);const Fh=1029,Oh=2305;class CullFaceMode{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}}CullFaceMode.disabled=new CullFaceMode(!1,Fh,Oh),CullFaceMode.backCCW=new CullFaceMode(!0,Fh,Oh),CullFaceMode.backCW=new CullFaceMode(!0,Fh,2304),CullFaceMode.frontCW=new CullFaceMode(!0,1028,2304),CullFaceMode.frontCCW=new CullFaceMode(!0,1028,Oh);class Context{constructor(e){this.gl=e,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),this.clearColor=new ClearColor(this),this.clearDepth=new ClearDepth(this),this.clearStencil=new ClearStencil(this),this.colorMask=new ColorMask(this),this.depthMask=new DepthMask(this),this.stencilMask=new StencilMask(this),this.stencilFunc=new StencilFunc(this),this.stencilOp=new StencilOp(this),this.stencilTest=new StencilTest(this),this.depthRange=new DepthRange(this),this.depthTest=new DepthTest(this),this.depthFunc=new DepthFunc(this),this.blend=new Blend(this),this.blendFunc=new BlendFunc(this),this.blendColor=new BlendColor(this),this.blendEquation=new BlendEquation(this),this.cullFace=new CullFace(this),this.cullFaceSide=new CullFaceSide(this),this.frontFace=new FrontFace(this),this.program=new Program$1(this),this.activeTexture=new ActiveTextureUnit(this),this.viewport=new Viewport(this),this.bindFramebuffer=new BindFramebuffer(this),this.bindRenderbuffer=new BindRenderbuffer(this),this.bindTexture=new BindTexture(this),this.bindVertexBuffer=new BindVertexBuffer(this),this.bindElementBuffer=new BindElementBuffer(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new BindVertexArrayOES(this),this.pixelStoreUnpack=new PixelStoreUnpack(this),this.pixelStoreUnpackPremultiplyAlpha=new PixelStoreUnpackPremultiplyAlpha(this),this.pixelStoreUnpackFlipY=new PixelStoreUnpackFlipY(this),this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureFilterAnisotropicForceOff=!1,this.extStandardDerivativesForceOff=!1,this.extTextureHalfFloat=e.getExtension("OES_texture_half_float"),this.extTextureHalfFloat&&(e.getExtension("OES_texture_half_float_linear"),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float")),this.extStandardDerivatives=e.getExtension("OES_standard_derivatives"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE)}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.extVertexArrayObject&&(this.bindVertexArrayOES.dirty=!0),this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(e,t){return new IndexBuffer(this,e,t)}createVertexBuffer(e,t,i){return new VertexBuffer(this,e,t,i)}createRenderbuffer(e,t,i){const r=this.gl,n=r.createRenderbuffer();return this.bindRenderbuffer.set(n),r.renderbufferStorage(r.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),n}createFramebuffer(e,t,i){return new Framebuffer(this,e,t,i)}clear({color:e,depth:t,stencil:i}){const r=this.gl;let n=0;e&&(n|=r.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),void 0!==t&&(n|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(n|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.clear(n)}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(e){o(e.blendFunction,ColorMode.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor)),this.colorMask.set(e.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}class SourceCache extends Evented{constructor(e,t,i){super(),this.id=e,this._onlySymbols=i,t.on("data",(e=>{"source"===e.dataType&&"metadata"===e.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===e.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),t.on("error",(()=>{this._sourceErrored=!0})),this._source=t,this._tiles={},this._cache=new TileCache(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new SourceFeatureState,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(e){this.map=e,this._minTileCacheSize=void 0===this._minTileCacheSize&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&e?e._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const e in this._tiles){const t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(e,t){return e.isSymbolTile=this._onlySymbols,this._source.loadTile(e,t)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e,(()=>{}))}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e,(()=>{}))}serialize(){return this._source.serialize()}prepare(e){if(this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._source.prepareTile)for(const t in this._tiles){const i=this._tiles[t];this._source.prepareTile(i)&&this.map.painter.terrain&&this.map.painter.terrain._clearRenderCacheForTile(this.id,i.tileID),i.upload(e),i.prepare(this.map.style.imageManager)}else for(const t in this._tiles){const i=this._tiles[t];i.upload(e),i.prepare(this.map.style.imageManager)}}getIds(){return v(this._tiles).map((e=>e.tileID)).sort(Vh).map((e=>e.key))}getRenderableIds(e){const t=[];for(const i in this._tiles)this._isIdRenderable(+i,e)&&t.push(this._tiles[i]);return e?t.sort(((e,t)=>{const i=e.tileID,n=t.tileID,o=new r(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),a=new r(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||a.y-o.y||a.x-o.x})).map((e=>e.tileID.key)):t.map((e=>e.tileID)).sort(Vh).map((e=>e.key))}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return!!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const e in this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading")}}_reloadTile(e,t){const i=this._tiles[e];i&&("loading"!==i.state&&(i.state=t),this._loadTile(i,this._tileLoaded.bind(this,i,e,t)))}_tileLoaded(e,t,i,r){if(r)if(e.state="errored",404!==r.status)this._source.fire(new ErrorEvent(r,{tile:e}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id)}else this.update(this.transform);else e.timeAdded=ee.now(),"expired"===i&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(t,e),"raster-dem"===this._source.type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),this._source.fire(new Event("data",{dataType:"source",tile:e,coord:e.tileID,sourceCacheId:this.id}))}_backfillDEM(e){const t=this.getRenderableIds();for(let r=0;r<t.length;r++){const n=t[r];if(e.neighboringTiles&&e.neighboringTiles[n]){const t=this.getTileByID(n);i(e,t),i(t,e)}}function i(e,t){if(!e.dem||e.dem.borderReady)return;e.needsHillshadePrepare=!0,e.needsDEMTextureUpload=!0;let i=t.tileID.canonical.x-e.tileID.canonical.x;const r=t.tileID.canonical.y-e.tileID.canonical.y,n=Math.pow(2,e.tileID.canonical.z),o=t.tileID.key;0===i&&0===r||Math.abs(r)>1||(Math.abs(i)>1&&(1===Math.abs(i+n)?i+=n:1===Math.abs(i-n)&&(i-=n)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,r),e.neighboringTiles&&e.neighboringTiles[o]&&(e.neighboringTiles[o].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,r){for(const n in this._tiles){let o=this._tiles[n];if(r[n]||!o.hasData()||o.tileID.overscaledZ<=t||o.tileID.overscaledZ>i)continue;let a=o.tileID;for(;o&&o.tileID.overscaledZ>t+1;){const e=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[e.key],o&&o.hasData()&&(a=e)}let s=a;for(;s.overscaledZ>t;)if(s=s.scaledTo(s.overscaledZ-1),e[s.key]){r[a.key]=a;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=t?i:null}for(let i=e.overscaledZ-1;i>=t;i--){const t=e.scaledTo(i),r=this._getLoadedTile(t);if(r)return r}}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,t){t=t||this._source.tileSize;const i=Math.ceil(e.width/t)+1,r=Math.ceil(e.height/t)+1,n=Math.floor(i*r*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,n):n,a="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(a)}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(+e,this._tiles[e])}}update(e,t,i){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;this.updateCacheSize(e,t),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new OverscaledTileID(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(r=e.coveringTiles({tileSize:t||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(r=r.filter((e=>this._source.hasTile(e))))):r=[];const n=this._updateRetainedTiles(r);if(Uh(this._source.type)&&0!==r.length){const e={},t={},i=Object.keys(n);for(const r of i){const i=n[r],o=this._tiles[r];if(!o||o.fadeEndTime&&o.fadeEndTime<=ee.now())continue;const a=this.findLoadedParent(i,Math.max(i.overscaledZ-SourceCache.maxOverzooming,this._source.minzoom));a&&(this._addTile(a.tileID),e[a.tileID.key]=a.tileID),t[r]=i}const o=r[r.length-1].overscaledZ;for(const e in this._tiles){const i=this._tiles[e];if(n[e]||!i.hasData())continue;let r=i.tileID;for(;r.overscaledZ>o;){r=r.scaledTo(r.overscaledZ-1);const o=this._tiles[r.key];if(o&&o.hasData()&&t[r.key]){n[e]=i.tileID;break}}}for(const t in e)n[t]||(this._coveredTiles[t]=!0,n[t]=e[t])}for(const e in n)this._tiles[e].clearFadeHold();const o=function(e,t){const i=[];for(const r in e)r in t||i.push(r);return i}(this._tiles,n);for(const e of o){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}_updateRetainedTiles(e){const t={};if(0===e.length)return t;const i={},r=e.reduce(((e,t)=>Math.min(e,t.overscaledZ)),1/0),n=e[0].overscaledZ,o=Math.max(n-SourceCache.maxOverzooming,this._source.minzoom),a=Math.max(n+SourceCache.maxUnderzooming,this._source.minzoom),s={};for(const i of e){const e=this._addTile(i);t[i.key]=i,e.hasData()||r<this._source.maxzoom&&(s[i.key]=i)}this._retainLoadedChildren(s,r,a,t);for(const r of e){let e=this._tiles[r.key];if(e.hasData())continue;if(r.canonical.z>=this._source.maxzoom){const e=r.children(this._source.maxzoom)[0],i=this.getTile(e);if(i&&i.hasData()){t[e.key]=e;continue}}else{const e=r.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let n=e.wasRequested();for(let a=r.overscaledZ-1;a>=o;--a){const o=r.scaledTo(a);if(i[o.key])break;if(i[o.key]=!0,e=this.getTile(o),!e&&n&&(e=this._addTile(o)),e&&(t[o.key]=o,n=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,r=this._tiles[e].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}t.push(r.key);const e=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;r=e}for(const e of t)this._loadedParentTiles[e]=i}}_addTile(e){let t=this._tiles[e.key];if(t)return this._source.prepareTile&&this._source.prepareTile(t),t;t=this._cache.getAndRemove(e),t&&(this._setTileReloadTimer(e.key,t),t.tileID=e,this._state.initializeTileState(t,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,t)));const i=Boolean(t);if(!i){const i=this.map?this.map.painter:null;t=new Tile(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,i,this._isRaster),this._source.prepareTile&&this._source.prepareTile(t)||this._loadTile(t,this._tileLoaded.bind(this,t,e.key,t.state))}return t?(t.uses++,this._tiles[e.key]=t,i||this._source.fire(new Event("dataloading",{tile:t,coord:t.tileID,dataType:"source"})),t):null}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e]}),i))}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(e,t,i){const r=[],n=this.transform;if(!n)return r;const o="globe"===n.projection.name,a=Io(n.center.lng);for(const s in this._tiles){const l=this._tiles[s];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const e=l.tileID.canonical;if(0===e.z){const t=[Math.abs(_(a,...jh(e,-1))-a),Math.abs(_(a,...jh(e,1))-a)];c=[0,2*t.indexOf(Math.min(...t))-1]}else{const t=[Math.abs(_(a,...jh(e,-1))-a),Math.abs(_(a,...jh(e,0))-a),Math.abs(_(a,...jh(e,1))-a)];c=[t.indexOf(Math.min(...t))-1]}}else c=[0];for(const i of c){const o=e.containsTile(l,n,t,i);o&&r.push(o)}}return r}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map((e=>this._tiles[e].tileID));for(const e of t)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped());return t}hasTransition(){if(this._source.hasTransition())return!0;if(Uh(this._source.type))for(const e in this._tiles){const t=this._tiles[e];if(void 0!==t.fadeEndTime&&t.fadeEndTime>=ee.now())return!0}return!1}setFeatureState(e,t,i){this._state.updateState(e=e||"_geojsonTileLayer",t,i)}removeFeatureState(e,t,i){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,i)}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,i){const r=this._tiles[e];r&&r.setDependencies(t,i)}reloadTilesForDependencies(e,t){for(const i in this._tiles)this._tiles[i].hasDependency(e,t)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(e,t)))}_preloadTiles(e,t){const i=new Map,r=Array.isArray(e)?e:[e],n=this.map.painter.terrain,o=this.usedForTerrain&&n?n.getScaledDemTileSize():this._source.tileSize;for(const e of r){const t=e.coveringTiles({tileSize:o,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 t)i.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1)}x(Array.from(i.values()),((e,t)=>{const i=new Tile(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(e=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),t(e,i)}))}),t)}}function Vh(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function Uh(e){return"raster"===e||"image"===e||"video"===e}function jh(e,t){const i=1<<e.z;return[e.x/i+t,(e.x+1)/i+t]}SourceCache.maxOverzooming=10,SourceCache.maxUnderzooming=3;class DEMSampler{constructor(e,t,i){this._demTile=e,this._dem=this._demTile.dem,this._scale=t,this._offset=i}static create(e,t,i){const r=i||e.findDEMTileFor(t);if(!r||!r.dem)return;const n=r.dem,o=r.tileID,a=1<<t.canonical.z-o.canonical.z;return new DEMSampler(r,r.tileSize/Eo/a,[(t.canonical.x/a-o.canonical.x)*n.dim,(t.canonical.y/a-o.canonical.y)*n.dim])}tileCoordToPixel(e,t){const i=t*this._scale+this._offset[1],n=Math.floor(e*this._scale+this._offset[0]),o=Math.floor(i);return new r(n,o)}getElevationAt(e,t,i,r){const n=e*this._scale+this._offset[0],o=t*this._scale+this._offset[1],a=Math.floor(n),s=Math.floor(o),l=this._dem;return r=!!r,i?xi(xi(l.get(a,s,r),l.get(a,s+1,r),o-s),xi(l.get(a+1,s,r),l.get(a+1,s+1,r),o-s),n-a):l.get(a,s,r)}getElevationAtPixel(e,t,i){return this._dem.get(e,t,!!i)}getMeterToDEM(e){return(1<<this._demTile.tileID.canonical.z)*Po(1,e)*this._dem.stride}}function Nh(e,t,i,r,n){return P(e,((e,o)=>{const a=t instanceof PossiblyEvaluated?t.get(o):null;return a&&a.evaluate?a.evaluate(i,r,n):a}))}function Gh(e,t){return t-e}En(class FeatureIndex{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new bn(Eo,16,0),this.featureIndexArray=new FeatureIndexArray,this.promoteId=t}insert(e,t,i,r,n,o=0){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,n,o);const s=this.grid;for(let e=0;e<t.length;e++){const i=t[e],r=[1/0,1/0,-1/0,-1/0];for(let e=0;e<i.length;e++){const t=i[e];r[0]=Math.min(r[0],t.x),r[1]=Math.min(r[1],t.y),r[2]=Math.max(r[2],t.x),r[3]=Math.max(r[3],t.y)}r[0]<Eo&&r[1]<Eo&&r[2]>=0&&r[3]>=0&&s.insert(a,r[0],r[1],r[2],r[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new gl.VectorTile(new hc(this.rawTileData)).layers,this.sourceLayerCoder=new DictionaryCoder(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,t,i,r){this.loadVTLayers();const n=e.params||{},o=Rr(n.filter),a=e.tileResult,s=e.transform,l=a.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((e,t,i,r)=>ra(a.bufferedTilespaceGeometry,e,t,i,r)));c.sort(Gh);let u=null;s.elevation&&c.length>0&&(u=DEMSampler.create(s.elevation,this.tileID));const h={};let p;for(let s=0;s<c.length;s++){const l=c[s];if(l===p)continue;p=l;const d=this.featureIndexArray.get(l);let f=null;this.loadMatchingFeature(h,d,o,n.layers,n.availableImages,t,i,r,((t,i,r,n=0)=>(f||(f=Go(t,this.tileID.canonical,e.tileTransform)),i.queryIntersectsFeature(a,t,r,f,this.z,e.transform,e.pixelPosMatrix,u,n))))}return h}loadMatchingFeature(e,t,i,r,n,o,a,s,l){const{featureIndex:c,bucketIndex:u,sourceLayerIndex:h,layoutVertexArrayOffset:p}=t,d=this.bucketLayerIDs[u];if(r&&!function(e,t){for(let i=0;i<e.length;i++)if(t.indexOf(e[i])>=0)return!0;return!1}(r,d))return;const f=this.sourceLayerCoder.decode(h),m=this.vtLayers[f].feature(c);if(i.needGeometry){const e=Zo(m,!0);if(!i.filter(new EvaluationParameters(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!i.filter(new EvaluationParameters(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let t=0;t<d.length;t++){const i=d[t];if(r&&r.indexOf(i)<0)continue;const u=o[i];if(!u)continue;let h={};void 0!==_&&s&&(h=s.getState(u.sourceLayer||"_geojsonTileLayer",_));const f=b({},a[i]);f.paint=Nh(f.paint,u.paint,m,h,n),f.layout=Nh(f.layout,u.layout,m,h,n);const g=!l||l(m,u,h,p);if(!g)continue;const y=new Feature(m,this.z,this.x,this.y,_);y.layer=f;let x=e[i];void 0===x&&(x=e[i]=[]),x.push({featureIndex:c,feature:y,intersectionZ:g})}}lookupSymbolFeatures(e,t,i,r,n,o,a,s){const l={};this.loadVTLayers();const c=Rr(n);for(const n of e)this.loadMatchingFeature(l,{bucketIndex:i,sourceLayerIndex:r,featureIndex:n,layoutVertexArrayOffset:0},c,o,a,s,t);return l}loadFeature(e){const{featureIndex:t,sourceLayerIndex:i}=e;this.loadVTLayers();const r=this.sourceLayerCoder.decode(i),n=this.vtFeatures[r];if(n[t])return n[t];const o=this.vtLayers[r].feature(t);return n[t]=o,o}hasLayer(e){for(const t of this.bucketLayerIDs)for(const i of t)if(e===i)return!0;return!1}getId(e,t){let i=e.id;return this.promoteId&&(i=e.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[t]],"boolean"==typeof i&&(i=Number(i))),i}},"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]}),En(class GlyphAtlas{constructor(e){const t={},i=[];for(const r in e){const n=e[r],o=t[r]={};for(const e in n.glyphs){const t=n.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const r=t.metrics.localGlyph?2:1,a={x:0,y:0,w:t.bitmap.width+2*r,h:t.bitmap.height+2*r};i.push(a),o[e]=a}}const{w:r,h:n}=Lc(i),o=new AlphaImage({width:r||1,height:n||1});for(const i in e){const r=e[i];for(const e in r.glyphs){const n=r.glyphs[+e];if(!n||0===n.bitmap.width||0===n.bitmap.height)continue;const a=t[i][e],s=n.metrics.localGlyph?2:1;AlphaImage.copy(n.bitmap,o,{x:0,y:0},{x:a.x+s,y:a.y+s},n.bitmap)}}this.image=o,this.positions=t}},"GlyphAtlas");class DedupedRequest{constructor(e){this.entries={},this.scheduler=e}request(e,t,i,r){const n=this.entries[e]=this.entries[e]||{callbacks:[]};if(n.result){const[e,i]=n.result;return this.scheduler?this.scheduler.add((()=>{r(e,i)}),t):r(e,i),()=>{}}return n.callbacks.push(r),n.cancel||(n.cancel=i(((i,r)=>{n.result=[i,r];for(const e of n.callbacks)this.scheduler?this.scheduler.add((()=>{e(i,r)}),t):e(i,r);setTimeout((()=>delete this.entries[e]),3e3)}))),()=>{n.result||(n.callbacks=n.callbacks.filter((e=>e!==r)),n.callbacks.length||(n.cancel(),delete this.entries[e]))}}}function Zh(e,t,i){const r=JSON.stringify(e.request);return e.data&&(this.deduped.entries[r]={result:[null,e.data]}),this.deduped.request(r,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom},(t=>{const r=Qe(e.request,((e,r,n,o)=>{e?t(e):r&&t(null,{vectorTile:i?void 0:new gl.VectorTile(new hc(r)),rawData:r,cacheControl:n,expires:o})}));return()=>{r.cancel(),t()}}),t)}class RasterTileSource extends Evented{constructor(e,t,i,r){super(),this.id=e,this.dispatcher=i,this.setEventedParent(r),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=b({type:"raster"},t),b(this,w(t,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new Event("dataloading",{dataType:"source"})),this._tileJSONRequest=gh(this._options,this.map._requestManager,null,null,((e,t)=>{this._tileJSONRequest=null,this._loaded=!0,e?this.fire(new ErrorEvent(e)):t&&(b(this,t),t.bounds&&(this.tileBounds=new TileBounds(t.bounds,this.minzoom,this.maxzoom)),De(t.tiles),this.fire(new Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new Event("data",{dataType:"source",sourceDataType:"content"})))}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return b({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,t){const i=ee.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),i,this.tileSize);e.request=at(this.map._requestManager.transformRequest(r,Xe.Tile),((i,r,n,o)=>(delete e.request,e.aborted?(e.state="unloaded",t(null)):i?(e.state="errored",t(i)):r?(this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:n,expires:o}),e.setTexture(r,this.map.painter),e.state="loaded",He(this.dispatcher),void t(null)):t(null))))}static loadTileData(e,t,i){e.setTexture(t,i)}static unloadTileData(e,t){e.texture&&t.saveTileTexture(e.texture)}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t()}unloadTile(e,t){e.texture&&this.map.painter.saveTileTexture(e.texture),t()}hasTransition(){return!1}}let qh;function $h(e,t,i,r,n,o,a,s){const l=[e,i,n,t,r,o,1,1,1],c=[a,s,1],u=ma([],l),[h,p,d]=Ha(c,c,function(e,t){if(e===t){var i=t[1],r=t[2],n=t[5];e[1]=t[3],e[2]=t[6],e[3]=i,e[5]=t[7],e[6]=r,e[7]=n}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e}(u,u));return _a(l,[h,0,0,0,p,0,0,0,d],l)}class ImageSource extends Evented{constructor(e,t,i,r){super(),this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=t}load(t,i){this._loaded=i||!1,this.fire(new Event("dataloading",{dataType:"source"})),this.url=this.options.url,at(this.map._requestManager.transformRequest(this.url,Xe.Image),((i,r)=>{if(this._loaded=!0,i)this.fire(new ErrorEvent(i));else if(r){const{HTMLImageElement:i}=e;this.image=r instanceof i?ee.getImageData(r):r,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading()}}))}loaded(){return this._loaded}updateImage(e){return this.image&&e.url?(this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this.texture&&this.texture.destroy()}setCoordinates(e){this.coordinates=e,this._boundsArray=void 0;const t=e.map(MercatorCoordinate.fromLngLat);return this.tileID=function(e){let t=1/0,i=1/0,r=-1/0,n=-1/0;for(const o of e)t=Math.min(t,o.x),i=Math.min(i,o.y),r=Math.max(r,o.x),n=Math.max(n,o.y);const o=Math.max(r-t,n-i),a=Math.max(0,Math.floor(-Math.log(o)/Math.LN2)),s=Math.pow(2,a);return new CanonicalTileID(a,Math.floor((t+r)/2*s),Math.floor((i+n)/2*s))}(t),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(e){for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture)}if(this._boundsArray)return;const t=Iu(this.tileID,this.map.transform.projection),[i,r,n,o]=this.coordinates.map((e=>{const i=t.projection.project(e[0],e[1]);return Pu(t,i)._round()}));this.perspectiveTransform=function(e,t,i,r,n,o,a,s,l,c){const u=$h(0,0,e,0,0,t,e,t),h=$h(i,r,n,o,a,s,l,c);return _a(h,ma(u,u),h),[h[6]/h[8]*e/Eo,h[7]/h[8]*t/Eo]}(this.width,this.height,i.x,i.y,r.x,r.y,o.x,o.y,n.x,n.y);const a=this._boundsArray=new StructArrayLayout4i8;a.emplaceBack(i.x,i.y,0,0),a.emplaceBack(r.x,r.y,Eo,0),a.emplaceBack(o.x,o.y,0,Eo),a.emplaceBack(n.x,n.y,Eo,Eo),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=e.createVertexBuffer(a,Ah.members),this.boundsSegments=SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,t=e.gl;this.texture?this.texture.update(this.image):(this.texture=new Texture(e,this.image,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE)),this._prepareData(e)}loadTile(e,t){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={},t(null)):(e.state="errored",t(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const Wh={vector:class VectorTileSource extends Evented{constructor(e,t,i,r){if(super(),this.id=e,this.dispatcher=i,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,b(this,w(t,["url","scheme","tileSize","promoteId"])),this._options=b({type:"vector"},t),this._collectResourceTiming=t.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r),this._tileWorkers={},this._deduped=new DedupedRequest}load(e){this._loaded=!1,this.fire(new Event("dataloading",{dataType:"source"}));const t=this.language||this.map._language,i=this.worldview||this.map._worldview;this._tileJSONRequest=gh(this._options,this.map._requestManager,t,i,((r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?(t&&console.warn(`Ensure that your requested language string is a valid BCP-47 code. Found: ${t}`),i&&2!==i.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${i}`),this.fire(new ErrorEvent(r))):n&&(b(this,n),n.bounds&&(this.tileBounds=new TileBounds(n.bounds,this.minzoom,this.maxzoom)),De(n.tiles,this.map._requestManager._customAccessToken),this.fire(new Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new Event("data",{dataType:"source",sourceDataType:"content"}))),e&&e(r)}))}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}setSourceProperty(e){this._tileJSONRequest&&this._tileJSONRequest.cancel(),e(),this.load((()=>{const e=this.map.style._getSourceCaches(this.id);for(const t of e)t.clearTiles()}))}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e})),this}_setLanguage(e){return e===this.language||this.setSourceProperty((()=>{this.language=e})),this}_setWorldview(e){return e===this.worldview?this:this.worldviewOptions&&e&&!this.worldviewOptions[e]?(console.warn(`Vector tile source "${this.id}" does not support worldview "${e}".`),this):(this.setSourceProperty((()=>{this.worldview=e})),this)}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return b({},this._options)}loadTile(e,t){const i=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(i,Xe.Tile),data:void 0,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:ee.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:e.isSymbolTile};if(r.request.collectResourceTiming=this._collectResourceTiming,e.actor&&"expired"!==e.state)"loading"===e.state?e.reloadCallback=t:e.request=e.actor.send("reloadTile",r,n.bind(this));else if(e.actor=this._tileWorkers[i]=this._tileWorkers[i]||this.dispatcher.getActor(),this.dispatcher.ready)e.request=e.actor.send("loadTile",r,n.bind(this),void 0,!0);else{const t=Zh.call({deduped:this._deduped},r,((t,i)=>{t||!i?n.call(this,t):(r.data={cacheControl:i.cacheControl,expires:i.expires,rawData:i.rawData.slice(0)},e.actor&&e.actor.send("loadTile",r,n.bind(this),void 0,!0))}),!0);e.request={cancel:t}}function n(i,r){return delete e.request,e.aborted?t(null):i&&404!==i.status?t(i):(r&&r.resourceTiming&&(e.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&e.setExpiryData(r),e.loadVectorData(r,this.map.painter),He(this.dispatcher),t(null),void(e.reloadCallback&&(this.loadTile(e,e.reloadCallback),e.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id})}unloadTile(e){e.unloadVectorData(),e.actor&&e.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:RasterTileSource,"raster-dem":class RasterDEMTileSource extends RasterTileSource{constructor(e,t,i,r){super(e,t,i,r),this.type="raster-dem",this.maxzoom=22,this._options=b({type:"raster-dem"},t),this.encoding=t.encoding||"mapbox"}loadTile(t,i){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function n(e,r){e&&(t.state="errored",i(e)),r&&(t.dem=r,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state="loaded",i(null))}t.request=at(this.map._requestManager.transformRequest(r,Xe.Tile),function(r,o,a,s){if(delete t.request,t.aborted)t.state="unloaded",i(null);else if(r)t.state="errored",i(r);else if(o){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:a,expires:s});const i=e.ImageBitmap&&o instanceof e.ImageBitmap&&(null==qh&&(qh=e.OffscreenCanvas&&new e.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof e.createImageBitmap),qh),r=1-(o.width-((l=o.width)<=1?1:Math.pow(2,Math.floor(Math.log(l)/Math.LN2))))/2;r<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));const c=i?o:ee.getImageData(o,r),u={uid:t.uid,coord:t.tileID,source:this.id,rawImageData:c,encoding:this.encoding,padding:r};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",u,n.bind(this),void 0,!0))}var l}.bind(this))}_getNeighboringTiles(e){const t=e.canonical,i=Math.pow(2,t.z),r=(t.x-1+i)%i,n=0===t.x?e.wrap-1:e.wrap,o=(t.x+1+i)%i,a=t.x+1===i?e.wrap+1:e.wrap,s={};return s[new OverscaledTileID(e.overscaledZ,n,t.z,r,t.y).key]={backfilled:!1},s[new OverscaledTileID(e.overscaledZ,a,t.z,o,t.y).key]={backfilled:!1},t.y>0&&(s[new OverscaledTileID(e.overscaledZ,n,t.z,r,t.y-1).key]={backfilled:!1},s[new OverscaledTileID(e.overscaledZ,e.wrap,t.z,t.x,t.y-1).key]={backfilled:!1},s[new OverscaledTileID(e.overscaledZ,a,t.z,o,t.y-1).key]={backfilled:!1}),t.y+1<i&&(s[new OverscaledTileID(e.overscaledZ,n,t.z,r,t.y+1).key]={backfilled:!1},s[new OverscaledTileID(e.overscaledZ,e.wrap,t.z,t.x,t.y+1).key]={backfilled:!1},s[new OverscaledTileID(e.overscaledZ,a,t.z,o,t.y+1).key]={backfilled:!1}),s}unloadTile(e){e.demTexture&&this.map.painter.saveTileTexture(e.demTexture),e.fbo&&(e.fbo.destroy(),delete e.fbo),e.dem&&delete e.dem,delete e.neighboringTiles,e.state="unloaded"}},geojson:class GeoJSONSource extends Evented{constructor(e,t,i,r){super(),this.id=e,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=i.getActor(),this.setEventedParent(r),this._data=t.data,this._options=b({},t),this._collectResourceTiming=t.collectResourceTiming,void 0!==t.maxzoom&&(this.maxzoom=t.maxzoom),t.type&&(this.type=t.type),t.attribution&&(this.attribution=t.attribution),this.promoteId=t.promoteId;const n=Eo/this.tileSize;this.workerOptions=b({source:this.id,cluster:t.cluster||!1,geojsonVtOptions:{buffer:(void 0!==t.buffer?t.buffer:128)*n,tolerance:(void 0!==t.tolerance?t.tolerance:.375)*n,extent:Eo,maxZoom:this.maxzoom,lineMetrics:t.lineMetrics||!1,generateId:t.generateId||!1},superclusterOptions:{maxZoom:void 0!==t.clusterMaxZoom?t.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,t.clusterMinPoints||2),extent:Eo,radius:(void 0!==t.clusterRadius?t.clusterRadius:50)*n,log:!1,generateId:t.generateId||!1},clusterProperties:t.clusterProperties,filter:t.filter},t.workerOptions)}onAdd(e){this.map=e,this.setData(this._data)}setData(e){return this._data=e,this._updateWorkerData(),this}getClusterExpansionZoom(e,t){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:e,source:this.id},t),this}getClusterChildren(e,t){return this.actor.send("geojson.getClusterChildren",{clusterId:e,source:this.id},t),this}getClusterLeaves(e,t,i,r){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:e,limit:t,offset:i},r),this}_updateWorkerData(){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new Event("dataloading",{dataType:"source"})),this._loaded=!1;const e=b({},this.workerOptions),t=this._data;"string"==typeof t?(e.request=this.map._requestManager.transformRequest(ee.resolveURL(t),Xe.Source),e.request.collectResourceTiming=this._collectResourceTiming):e.data=JSON.stringify(t),this._pendingLoad=this.actor.send(`${this.type}.loadData`,e,((e,t)=>{if(this._loaded=!0,this._pendingLoad=null,e)this.fire(new ErrorEvent(e));else{const e={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&t&&t.resourceTiming&&t.resourceTiming[this.id]&&(e.resourceTiming=t.resourceTiming[this.id]),this.fire(new Event("data",e)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)}))}loaded(){return this._loaded}loadTile(e,t){const i=e.actor?"reloadTile":"loadTile";e.actor=this.actor,e.request=this.actor.send(i,{type:this.type,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:ee.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},((r,n)=>(delete e.request,e.unloadVectorData(),e.aborted?t(null):r?t(r):(e.loadVectorData(n,this.map.painter,"reloadTile"===i),t(null)))),void 0,"loadTile"===i)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}unloadTile(e){e.unloadVectorData(),this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return b({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class VideoSource extends ImageSource{constructor(e,t,i,r){super(e,t,i,r),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const e of t.urls)this.urls.push(this.map._requestManager.transformRequest(e,Xe.Source).url);!function(t,i){const r=e.document.createElement("video");r.muted=!0,r.onloadstart=function(){i(null,r)};for(let i=0;i<t.length;i++){const n=e.document.createElement("source");it(t[i])||(r.crossOrigin="Anonymous"),n.src=t[i],r.appendChild(n)}}(this.urls,((e,t)=>{this._loaded=!0,e?this.fire(new ErrorEvent(e)):t&&(this.video=t,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(e){if(this.video){const t=this.video.seekable;e<t.start(0)||e>t.end(0)?this.fire(new ErrorEvent(new ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${t.start(0)} and ${t.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,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 e=this.map.painter.context,t=e.gl;this.texture?this.video.paused||(this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,this.video)):(this.texture=new Texture(e,this.video,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(e)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:ImageSource,canvas:class CanvasSource extends ImageSource{constructor(t,i,r,n){super(t,i,r,n),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new ErrorEvent(new ValidationError(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new ErrorEvent(new ValidationError(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new ErrorEvent(new ValidationError(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof e.HTMLCanvasElement||this.fire(new ErrorEvent(new ValidationError(`sources.${t}`,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 ErrorEvent(new ValidationError(`sources.${t}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof e.HTMLCanvasElement?this.options.canvas:e.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new 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(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const t=this.map.painter.context;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new Texture(t,this.canvas,t.gl.RGBA,{premultiply:!0}),this._prepareData(t)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}},custom:class CustomSource extends Evented{constructor(e,t,i,r){super(),this.id=e,this.type="custom",this._dataType="raster",this._dispatcher=i,this._implementation=t,this.setEventedParent(r),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new TileBounds(this._implementation.bounds,this.minzoom,this.maxzoom)),t.update=this._update.bind(this),t.coveringTiles=this._coveringTiles.bind(this),b(this,w(t,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return w(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(e){this._map=e,this._loaded=!1,this.fire(new Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(e),this.load()}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e)}hasTile(e){if(this._implementation.hasTile){const{x:t,y:i,z:r}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:r})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const{x:r,y:n,z:o}=t.tileID.canonical,a=new e.AbortController,s=this._implementation.loadTile({x:r,y:n,z:o},{signal:a.signal});if(!s)return this.loadTileData(t,{width:this.tileSize,height:this.tileSize,data:null}),t.state="loaded",i(null);s.cancel=()=>a.abort(),t.request=s.then(function(r){return delete t.request,t.aborted?(t.state="unloaded",i(null)):r?function(t){return t instanceof e.ImageData||t instanceof e.ImageBitmap||t instanceof e.HTMLCanvasElement}(r)?(this.loadTileData(t,r),t.state="loaded",void i(null)):(t.state="errored",i(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`))):(this.loadTileData(t,{width:this.tileSize,height:this.tileSize,data:null}),t.state="loaded",i(null))}.bind(this)).catch((e=>{20!==e.code&&(t.state="errored",i(e))}))}loadTileData(e,t){RasterTileSource.loadTileData(e,t,this._map.painter)}unloadTileData(e){RasterTileSource.unloadTileData(e,this._map.painter)}prepareTile(e){if(!this._implementation.prepareTile)return null;const{x:t,y:i,z:r}=e.tileID.canonical,n=this._implementation.prepareTile({x:t,y:i,z:r});return n?(this.loadTileData(e,n),e.state="loaded",n):null}unloadTile(e,t){if(this.unloadTileData(e),this._implementation.unloadTile){const{x:t,y:i,z:r}=e.tileID.canonical;this._implementation.unloadTile({x:t,y:i,z:r})}t()}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map((e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z})))}_update(){this.fire(new Event("data",{dataType:"source",sourceDataType:"content"}))}}},Hh=function(e,t,i,r){const n=new Wh[t.type](e,t,i,r);if(n.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${n.id}`);return I(["load","abort","unload","serialize","prepare"],n),n};function Xh(e,t){const i=ya([]);return wa(i,i,[.5*e.width,.5*-e.height,1]),ba(i,i,[1,-1,0]),va(i,i,e.calculateProjMatrix(t.toUnwrapped())),Float32Array.from(i)}function Kh(e,t,i,r,n,o,a,s=!1){const l=e.tilesIn(r,a,s);l.sort(Yh);const c=[];for(const r of l)c.push({wrappedTileID:r.tile.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(t,i,e._state,r,n,o,Xh(e.transform,r.tile.tileID),s)});const u=function(e){const t={},i={};for(const r of e){const e=r.queryResults,n=r.wrappedTileID,o=i[n]=i[n]||{};for(const i in e){const r=e[i],n=o[i]=o[i]||{},a=t[i]=t[i]||[];for(const e of r)n[e.featureIndex]||(n[e.featureIndex]=!0,a.push(e))}}return t}(c);for(const t in u)u[t].forEach((t=>{const i=t.feature,r=i.layer;r&&"background"!==r.type&&"sky"!==r.type&&(i.source=r.source,r["source-layer"]&&(i.sourceLayer=r["source-layer"]),i.state=void 0!==i.id?e.getFeatureState(r["source-layer"],i.id):{})}));return u}function Jh(e,t){const i=e.getRenderableIds().map((t=>e.getTileByID(t))),r=[],n={};for(let e=0;e<i.length;e++){const o=i[e],a=o.tileID.canonical.key;n[a]||(n[a]=!0,o.querySourceFeatures(r,t))}return r}function Yh(e,t){const i=e.tileID,r=t.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function Qh(){return null!=gm.workerClass?new gm.workerClass:new e.Worker(gm.workerUrl)}const ep="mapboxgl_preloaded_worker_pool";class WorkerPool{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length<WorkerPool.workerCount;)this.workers.push(new Qh);return this.active[e]=!0,this.workers.slice()}release(e){delete this.active[e],0===this.numActive()&&(this.workers.forEach((e=>{e.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[ep]}numActive(){return Object.keys(this.active).length}}let tp;function ip(){return tp||(tp=new WorkerPool),tp}WorkerPool.workerCount=2;var rp=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function np(e,t){const i={};for(const t in e)"ref"!==t&&(i[t]=e[t]);return rp.forEach((e=>{e in t&&(i[e]=t[e])})),i}function op(e){e=e.slice();const t=Object.create(null);for(let i=0;i<e.length;i++)t[e[i].id]=e[i];for(let i=0;i<e.length;i++)"ref"in e[i]&&(e[i]=np(e[i],t[e[i].ref]));return e}const ap={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setProjection:"setProjection"};function sp(e,t,i){i.push({command:ap.addSource,args:[e,t[e]]})}function lp(e,t,i){t.push({command:ap.removeSource,args:[e]}),i[e]=!0}function cp(e,t,i,r){lp(e,i,r),sp(e,t,i)}function up(e,t,i){let r;for(r in e[i])if(e[i].hasOwnProperty(r)&&"data"!==r&&!o(e[i][r],t[i][r]))return!1;for(r in t[i])if(t[i].hasOwnProperty(r)&&"data"!==r&&!o(e[i][r],t[i][r]))return!1;return!0}function hp(e,t,i,r,n,a){let s;for(s in t=t||{},e=e||{})e.hasOwnProperty(s)&&(o(e[s],t[s])||i.push({command:a,args:[r,s,t[s],n]}));for(s in t)t.hasOwnProperty(s)&&!e.hasOwnProperty(s)&&(o(e[s],t[s])||i.push({command:a,args:[r,s,t[s],n]}))}function pp(e){return e.id}function dp(e,t){return e[t.id]=t,e}class PathInterpolator{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e<this.points.length;e++)this._distances[e]=this._distances[e-1]+this.points[e].dist(this.points[e-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(t||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(e){if(1===this.points.length)return this.points[0];e=_(e,0,1);let t=1,i=this._distances[t];const r=e*this.paddedLength+this.padding;for(;i<r&&t<this._distances.length;)i=this._distances[++t];const n=t-1,o=this._distances[n],a=i-o,s=a>0?(r-o)/a:0;return this.points[n].mult(1-s).add(this.points[t].mult(s))}}class GridIndex{constructor(e,t,i){const r=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;e<this.xCellCount*this.yCellCount;e++)r.push([]),n.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=t,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/t,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,t,i,r,n){this._forEachCell(t,i,r,n,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)}insertCircle(e,t,i,r){this._forEachCell(t-r,i-r,t+r,i+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(i),this.circles.push(r)}_insertBoxCell(e,t,i,r,n,o){this.boxCells[n].push(o)}_insertCircleCell(e,t,i,r,n,o){this.circleCells[n].push(o)}_query(e,t,i,r,n,o){if(i<0||e>this.width||r<0||t>this.height)return!n&&[];const a=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(n)return!0;for(let e=0;e<this.boxKeys.length;e++)a.push({key:this.boxKeys[e],x1:this.bboxes[4*e],y1:this.bboxes[4*e+1],x2:this.bboxes[4*e+2],y2:this.bboxes[4*e+3]});for(let e=0;e<this.circleKeys.length;e++){const t=this.circles[3*e],i=this.circles[3*e+1],r=this.circles[3*e+2];a.push({key:this.circleKeys[e],x1:t-r,y1:i-r,x2:t+r,y2:i+r})}return o?a.filter(o):a}return this._forEachCell(e,t,i,r,this._queryCell,a,{hitTest:n,seenUids:{box:{},circle:{}}},o),n?a.length>0:a}_queryCircle(e,t,i,r,n){const o=e-i,a=e+i,s=t-i,l=t+i;if(a<0||o>this.width||l<0||s>this.height)return!r&&[];const c=[];return this._forEachCell(o,s,a,l,this._queryCellCircle,c,{hitTest:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},n),r?c.length>0:c}query(e,t,i,r,n){return this._query(e,t,i,r,!1,n)}hitTest(e,t,i,r,n){return this._query(e,t,i,r,!0,n)}hitTestCircle(e,t,i,r){return this._queryCircle(e,t,i,!0,r)}_queryCell(e,t,i,r,n,o,a,s){const l=a.seenUids,c=this.boxCells[n];if(null!==c){const n=this.bboxes;for(const u of c)if(!l.box[u]){l.box[u]=!0;const c=4*u;if(e<=n[c+2]&&t<=n[c+3]&&i>=n[c+0]&&r>=n[c+1]&&(!s||s(this.boxKeys[u]))){if(a.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[u],x1:n[c],y1:n[c+1],x2:n[c+2],y2:n[c+3]})}}}const u=this.circleCells[n];if(null!==u){const n=this.circles;for(const c of u)if(!l.circle[c]){l.circle[c]=!0;const u=3*c;if(this._circleAndRectCollide(n[u],n[u+1],n[u+2],e,t,i,r)&&(!s||s(this.circleKeys[c]))){if(a.hitTest)return o.push(!0),!0;{const e=n[u],t=n[u+1],i=n[u+2];o.push({key:this.circleKeys[c],x1:e-i,y1:t-i,x2:e+i,y2:t+i})}}}}}_queryCellCircle(e,t,i,r,n,o,a,s){const l=a.circle,c=a.seenUids,u=this.boxCells[n];if(null!==u){const e=this.bboxes;for(const t of u)if(!c.box[t]){c.box[t]=!0;const i=4*t;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!s||s(this.boxKeys[t])))return o.push(!0),!0}}const h=this.circleCells[n];if(null!==h){const e=this.circles;for(const t of h)if(!c.circle[t]){c.circle[t]=!0;const i=3*t;if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!s||s(this.circleKeys[t])))return o.push(!0),!0}}}_forEachCell(e,t,i,r,n,o,a,s){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),u=this._convertToXCellCoord(i),h=this._convertToYCellCoord(r);for(let p=l;p<=u;p++)for(let l=c;l<=h;l++)if(n.call(this,e,t,i,r,this.xCellCount*l+p,o,a,s))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,r,n,o){const a=r-e,s=n-t,l=i+o;return l*l>a*a+s*s}_circleAndRectCollide(e,t,i,r,n,o,a){const s=(o-r)/2,l=Math.abs(e-(r+s));if(l>s+i)return!1;const c=(a-n)/2,u=Math.abs(t-(n+c));if(u>c+i)return!1;if(l<=s||u<=c)return!0;const h=l-s,p=u-c;return h*h+p*p<=i*i}}const fp=Math.tan(85*Math.PI/180);function mp(e,t,i,r,n,o,a){const s=ga();if(i)if("globe"===o.name){const e=function(e,t){const{x:i,y:r}=e.point,n=mu(i,r,e.worldSize/e._pixelsPerMercatorPixel,0,0);return va(n,n,du(tu(t)))}(n,t);va(s,s,e)}else{const e=da([],a);s[0]=e[0],s[1]=e[1],s[4]=e[2],s[5]=e[3],r||Sa(s,s,n.angle)}else va(s,n.labelPlaneMatrix,e);return s}function _p(e,t,i,r,n,o,a){const s=mp(e,t,i,r,n,o,a);return"globe"===o.name&&i||(s[2]=s[6]=s[10]=s[14]=0),s}function gp(e,t,i,r,n,o,a){if(i){if("globe"===o.name){const s=mp(e,t,i,r,n,o,a);return xa(s,s),va(s,e,s),s}{const t=(s=e,(l=new pa(16))[0]=s[0],l[1]=s[1],l[2]=s[2],l[3]=s[3],l[4]=s[4],l[5]=s[5],l[6]=s[6],l[7]=s[7],l[8]=s[8],l[9]=s[9],l[10]=s[10],l[11]=s[11],l[12]=s[12],l[13]=s[13],l[14]=s[14],l[15]=s[15],l),i=ya([]);return i[0]=a[0],i[1]=a[1],i[4]=a[2],i[5]=a[3],va(t,t,i),r||Sa(t,t,-n.angle),t}}return n.glCoordMatrix;var s,l}function yp(e,t,i=0){const r=[e.x,e.y,i,1];i?is(r,r,t):Dp(r,r,t);const n=r[3];return{point:[r[0]/n,r[1]/n,r[2]/n],signedDistanceFromCamera:n}}function xp(e,t){const i=[e[0],e[1],e[2],1];is(i,i,t);const r=i[3];return{point:[i[0]/r,i[1]/r,i[2]/r],signedDistanceFromCamera:r}}function vp(e,t){return Math.min(.5+e/t*.5,1.5)}function bp(e,t){const i=e[0]/e[3],r=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&r>=-t[1]&&r<=t[1]}function wp(e,t,i,n,o,a,s,l,c,u){const h=i.transform,p=n?e.textSizeData:e.iconSizeData,d=oc(p,i.transform.zoom),f="globe"===h.projection.name,m=[256/i.width*2+1,256/i.height*2+1],_=n?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;_.clear();let g=null;f&&(g=n?e.text.globeExtVertexArray:e.icon.globeExtVertexArray);const y=e.lineVertexArray,x=n?e.text.placedSymbolArray:e.icon.placedSymbolArray,v=i.transform.width/i.transform.height;let b=!1;for(let n=0;n<x.length;n++){const f=x.get(n);if(f.writingMode!==Bc.vertical||b||0!==n&&x.get(n-1).writingMode===Bc.horizontal||(b=!0),(f.hidden||f.writingMode===Bc.vertical)&&!b){Pp(f.numGlyphs,_);continue}b=!1;const w=new r(f.tileAnchorX,f.tileAnchorY),T=c?c(w):[0,0,0],E=h.projection.projectTilePoint(w.x,w.y,u.canonical),S=[E.x+T[0],E.y+T[1],E.z+T[2]],A=[...S,1];if(is(A,A,t),!bp(A,m)){Pp(f.numGlyphs,_);continue}const C=vp(i.transform.cameraToCenterDistance,A[3]),I=nc(p,d,f),M=s?I/C:I*C,P=yp(new r(S[0],S[1]),o,S[2]);if(P.signedDistanceFromCamera<=0){Pp(f.numGlyphs,_);continue}let D={};const z=s?null:c,k=Sp(f,M,!1,l,t,o,a,e.glyphOffsetArray,y,_,g,P.point,w,D,v,z,h.projection,u,s);b=k.useVertical,z&&k.needsFlipping&&(D={}),(k.notEnoughRoom||b||k.needsFlipping&&Sp(f,M,!0,l,t,o,a,e.glyphOffsetArray,y,_,g,P.point,w,D,v,z,h.projection,u,s).notEnoughRoom)&&Pp(f.numGlyphs,_)}n?(e.text.dynamicLayoutVertexBuffer.updateData(_),g&&e.text.globeExtVertexBuffer.updateData(g)):(e.icon.dynamicLayoutVertexBuffer.updateData(_),g&&e.icon.globeExtVertexBuffer.updateData(g))}function Tp(e,t,i,r,n,o,a,s,l,c,u,h,p,d,f,m){const _=s.glyphStartIndex+s.numGlyphs,g=s.lineStartIndex,y=s.lineStartIndex+s.lineLength,x=t.getoffsetX(s.glyphStartIndex),v=t.getoffsetX(_-1),b=Ip(e*x,i,r,n,o,a,s.segment,g,y,l,c,u,h,p,!0,d,f,m);if(!b)return null;const w=Ip(e*v,i,r,n,o,a,s.segment,g,y,l,c,u,h,p,!0,d,f,m);return w?{first:b,last:w}:null}function Ep(e,t,i,r){return e.writingMode===Bc.horizontal&&Math.abs(i.y-t.y)>Math.abs(i.x-t.x)*r?{useVertical:!0}:e.writingMode===Bc.vertical?t.y<i.y?{needsFlipping:!0}:null:0!==e.flipState&&function(e,t,i){const r=(t.x-e.x)*i;return 0===r||Math.abs((t.y-e.y)/r)>fp}(t,i,r)?1===e.flipState?{needsFlipping:!0}:null:t.x>i.x?{needsFlipping:!0}:null}function Sp(e,t,i,n,o,a,s,l,c,u,h,p,d,f,m,_,g,y,x){const v=t/24,b=e.lineOffsetX*v,w=e.lineOffsetY*v;let T;if(e.numGlyphs>1){const t=e.glyphStartIndex+e.numGlyphs,o=e.lineStartIndex,u=e.lineStartIndex+e.lineLength,h=Tp(v,l,b,w,i,p,d,e,c,a,f,_,!1,g,y,x);if(!h)return{notEnoughRoom:!0};const E=xp(h.first.point,s).point,S=xp(h.last.point,s).point,A=new r(E[0],E[1]),C=new r(S[0],S[1]);if(n&&!i){const t=Ep(e,A,C,m);if(e.flipState=t&&t.needsFlipping?1:2,t)return t}T=[h.first];for(let r=e.glyphStartIndex+1;r<t-1;r++)T.push(Ip(v*l.getoffsetX(r),b,w,i,p,d,e.segment,o,u,c,a,f,_,!1,!1,g,y,x));T.push(h.last)}else{if(n&&!i){const t=yp(d,o).point,i=e.lineStartIndex+e.segment+1,n=new r(c.getx(i),c.gety(i)),a=yp(n,o),s=a.signedDistanceFromCamera>0?a.point:Cp(d,n,t,1,o,void 0,g,y.canonical),l=Ep(e,new r(t[0],t[1]),new r(s[0],s[1]),m);if(e.flipState=l&&l.needsFlipping?1:2,l)return l}const t=Ip(v*l.getoffsetX(e.glyphStartIndex),b,w,i,p,d,e.segment,e.lineStartIndex,e.lineStartIndex+e.lineLength,c,a,f,_,!1,!1,g,y,x);if(!t)return{notEnoughRoom:!0};T=[t]}if(h)for(const e of T)Wu(h,u.length+0,e.up[0],e.up[1],e.up[2]),Wu(h,u.length+1,e.up[0],e.up[1],e.up[2]),Wu(h,u.length+2,e.up[0],e.up[1],e.up[2]),Wu(h,u.length+3,e.up[0],e.up[1],e.up[2]),Hu(u,e.point[0],e.point[1],e.point[2],e.angle);else for(const e of T)Hu(u,e.point[0],e.point[1],e.point[2],e.angle);return{}}function Ap(e,t,i,n,o){const a=n.projectTilePoint(e.x,e.y,t);if(!o)return yp(a,i,a.z);const s=o(e);return yp(new r(a.x+s[0],a.y+s[1]),i,a.z+s[2])}function Cp(e,t,i,r,n,o,a,s){const l=Ap(e.add(e.sub(t)._unit()),s,n,a,o).point,c=Ja([],i,l);return Na([],i,c,r/La(c))}function Ip(e,t,i,n,o,a,s,l,c,u,h,p,d,f,m,_,g,y){const x=n?e-t:e+t;let v=x>0?1:-1,b=0;n&&(v*=-1,b=Math.PI),v<0&&(b+=Math.PI);let w=v>0?l+s:l+s+1,T=o,E=o,S=0,A=0;const C=Math.abs(x),I=[],M=[];let P=a;const D=()=>{const e=w-v;return 0===S?a:new r(u.getx(e),u.gety(e))},z=()=>Cp(D(),P,E,C-S+1,h,d,_,g.canonical);for(;S+A<=C;){if(w+=v,w<l||w>=c)return null;if(E=T,I.push(T),f&&M.push(P||D()),T=p[w],void 0===T){P=new r(u.getx(w),u.gety(w));const e=Ap(P,g.canonical,h,_,d);T=e.signedDistanceFromCamera>0?p[w]=e.point:z()}else P=null;S+=A,A=Ga(E,T)}P=P||new r(u.getx(w),u.gety(w));const k=D();m&&d&&(p[w]=T=void 0===p[w]?T:z(),A=Ga(E,T));const L=(C-S)/A,B=P.sub(k).mult(L)._add(k),R=Ja([],T,E),F=Na([],E,R,L);let O=[0,0,1],V=R[0],U=R[1];if(y&&(O=_.upVector(g.canonical,B.x,B.y),0!==O[0]||0!==O[1]||1!==O[2])){const e=[1,0,0],t=[0,1,0];e[0]=O[2],e[1]=0,e[2]=-O[0],$a(t,O,e),Za(e,e),Za(t,t),V=qa(R,e),U=qa(R,t)}if(i){const e=$a([],O,R);Za(e,e),Na(F,F,e,i*v)}const j=b+Math.atan2(U,V);return I.push(F),f&&M.push(B),{point:F,angle:j,path:I,tilePath:M,up:O}}const Mp=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Pp(e,t){for(let i=0;i<e;i++){const e=t.length;t.resize(e+4),t.float32.set(Mp,4*e)}}function Dp(e,t,i){const r=t[0],n=t[1];return e[0]=i[0]*r+i[4]*n+i[12],e[1]=i[1]*r+i[5]*n+i[13],e[3]=i[3]*r+i[7]*n+i[15],e}const zp=100;class CollisionIndex{constructor(e,t,i=new GridIndex(e.width+200,e.height+200,25),r=new GridIndex(e.width+200,e.height+200,25)){this.transform=e,this.grid=i,this.ignoredGrid=r,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+zp,this.screenBottomBoundary=e.height+zp,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=t}placeCollisionBox(e,t,i,r,n,o,a,s){let l=i.projectedAnchorX,c=i.projectedAnchorY,u=i.projectedAnchorZ;const h=i.elevation,p=i.tileID;if(h&&p){const t=e.getProjection().upVector(p.canonical,i.tileAnchorX,i.tileAnchorY),r=e.getProjection().upVectorScale(p.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=t[0]*h*r,c+=t[1]*h*r,u+=t[2]*h*r}const d=this.projectAndGetPerspectiveRatio(a,[l,c,u],i.tileID,"globe"===e.projection.name||!!h||this.transform.pitch>0,e.getProjection()),f=o*d.perspectiveRatio,m=(i.x1*t+r.x-i.padding)*f+d.point.x,_=(i.y1*t+r.y-i.padding)*f+d.point.y,g=(i.x2*t+r.x+i.padding)*f+d.point.x,y=(i.y2*t+r.y+i.padding)*f+d.point.y,x=d.perspectiveRatio<=.55||d.occluded;return!this.isInsideGrid(m,_,g,y)||!n&&this.grid.hitTest(m,_,g,y,s)||x?{box:[],offscreen:!1,occluded:d.occluded}:{box:[m,_,g,y],offscreen:this.isOffscreen(m,_,g,y),occluded:!1}}placeCollisionCircles(e,t,i,n,o,a,s,l,c,u,h,p,d,f,m){const _=[],g=this.transform.elevation,y=g?g.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,e.getProjection()):e=>[0,0,0],x=new r(i.tileAnchorX,i.tileAnchorY),v=e.getProjection().projectTilePoint(i.tileAnchorX,i.tileAnchorY,m.canonical),b=y(x),w=[v.x+b[0],v.y+b[1],v.z+b[2]],T="globe"===e.projection.name,E=this.projectAndGetPerspectiveRatio(s,[w[0],w[1],w[2]],m,T||!!g||this.transform.pitch>0,e.getProjection()),{perspectiveRatio:S}=E,A=(h?a/S:a*S)/24,C=yp(new r(w[0],w[1]),l,w[2]).point,I=E.signedDistanceFromCamera>0?Tp(A,o,i.lineOffsetX*A,i.lineOffsetY*A,!1,C,x,i,n,l,{},g&&!h?y:null,h&&!!g,e.getProjection(),m,h):null;let M=!1,P=!1,D=!0;if(I&&!E.occluded){const e=.5*d*S+f,i=new r(-100,-100),n=new r(this.screenRightBoundary,this.screenBottomBoundary),o=new PathInterpolator,a=I.first,s=I.last;let l=[];for(let e=a.path.length-1;e>=1;e--)l.push(a.path[e]);for(let e=1;e<s.path.length;e++)l.push(s.path[e]);const h=2.5*e;if(c){const e=l.map(g&&!T?(e,t)=>{const i=y(t<a.path.length-1?a.tilePath[a.path.length-1-t]:s.tilePath[t-a.path.length+2]);return e[2]=i[2],xp(e,c)}:e=>xp(e,c));l=e.some((e=>e.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point))}let m=[];if(l.length>0){const e=l.map((e=>new r(e[0],e[1])));let t=1/0,o=-1/0,a=1/0,s=-1/0;for(let i=0;i<e.length;i++)t=Math.min(t,e[i].x),a=Math.min(a,e[i].y),o=Math.max(o,e[i].x),s=Math.max(s,e[i].y);m=t>=i.x&&o<=n.x&&a>=i.y&&s<=n.y?[e]:o<i.x||t>n.x||s<i.y||a>n.y?[]:function(e,t,i,n,o){const a=[];for(let s=0;s<e.length;s++){const l=e[s];let c;for(let e=0;e<l.length-1;e++){let s=l[e],u=l[e+1];s.x<t&&u.x<t||(s.x<t?s=new r(t,s.y+(t-s.x)/(u.x-s.x)*(u.y-s.y))._round():u.x<t&&(u=new r(t,s.y+(t-s.x)/(u.x-s.x)*(u.y-s.y))._round()),s.y<i&&u.y<i||(s.y<i?s=new r(s.x+(i-s.y)/(u.y-s.y)*(u.x-s.x),i)._round():u.y<i&&(u=new r(s.x+(i-s.y)/(u.y-s.y)*(u.x-s.x),i)._round()),s.x>=n&&u.x>=n||(s.x>=n?s=new r(n,s.y+(n-s.x)/(u.x-s.x)*(u.y-s.y))._round():u.x>=n&&(u=new r(n,s.y+(n-s.x)/(u.x-s.x)*(u.y-s.y))._round()),s.y>=o&&u.y>=o||(s.y>=o?s=new r(s.x+(o-s.y)/(u.y-s.y)*(u.x-s.x),o)._round():u.y>=o&&(u=new r(s.x+(o-s.y)/(u.y-s.y)*(u.x-s.x),o)._round()),c&&s.equals(c[c.length-1])||(c=[s],a.push(c)),c.push(u)))))}}return a}([e],i.x,i.y,n.x,n.y)}for(const i of m){o.reset(i,.25*e);let r=0;r=o.length<=.5*e?1:Math.ceil(o.paddedLength/h)+1;for(let i=0;i<r;i++){const n=i/Math.max(r-1,1),a=o.lerp(n),s=a.x+zp,l=a.y+zp;_.push(s,l,e,0);const c=s-e,h=l-e,d=s+e,f=l+e;if(D=D&&this.isOffscreen(c,h,d,f),P=P||this.isInsideGrid(c,h,d,f),!t&&this.grid.hitTestCircle(s,l,e,p)&&(M=!0,!u))return{circles:[],offscreen:!1,collisionDetected:M,occluded:!1}}}}return{circles:!u&&M||!P?[]:_,offscreen:D,collisionDetected:M,occluded:E.occluded}}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const t=[];let i=1/0,n=1/0,o=-1/0,a=-1/0;for(const s of e){const e=new r(s.x+zp,s.y+zp);i=Math.min(i,e.x),n=Math.min(n,e.y),o=Math.max(o,e.x),a=Math.max(a,e.y),t.push(e)}const s=this.grid.query(i,n,o,a).concat(this.ignoredGrid.query(i,n,o,a)),l={},c={};for(const e of s){const i=e.key;void 0===l[i.bucketInstanceId]&&(l[i.bucketInstanceId]={}),l[i.bucketInstanceId][i.featureIndex]||Wo(t,[new r(e.x1,e.y1),new r(e.x2,e.y1),new r(e.x2,e.y2),new r(e.x1,e.y2)])&&(l[i.bucketInstanceId][i.featureIndex]=!0,void 0===c[i.bucketInstanceId]&&(c[i.bucketInstanceId]=[]),c[i.bucketInstanceId].push(i.featureIndex))}return c}insertCollisionBox(e,t,i,r,n){(t?this.ignoredGrid:this.grid).insert({bucketInstanceId:i,featureIndex:r,collisionGroupID:n},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,i,r,n){const o=t?this.ignoredGrid:this.grid,a={bucketInstanceId:i,featureIndex:r,collisionGroupID:n};for(let t=0;t<e.length;t+=4)o.insertCircle(a,e[t],e[t+1],e[t+2])}projectAndGetPerspectiveRatio(e,t,i,n,o){const a=[t[0],t[1],t[2],1];let s=!1;if(t[2]||this.transform.pitch>0){is(a,a,e);const r="globe"===o.name;this.fogState&&i&&!r&&(s=function(e,t,i,r,n,o){const a=[t,i,r];return Wa(a,a,o.calculateFogTileMatrix(n)),ch(e,a,o.pitch,o._fov)}(this.fogState,t[0],t[1],t[2],i.toUnwrapped(),this.transform)>.9)}else Dp(a,a,e);return{point:new r((a[0]/a[3]+1)/2*this.transform.width+zp,(-a[1]/a[3]+1)/2*this.transform.height+zp),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(o)/a[3]*.5,1.5),signedDistanceFromCamera:a[3],occluded:n&&a[2]>a[3]||s}}isOffscreen(e,t,i,r){return i<zp||e>=this.screenRightBoundary||r<zp||t>this.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e<this.gridRightBoundary&&r>=0&&t<this.gridBottomBoundary}getViewportMatrix(){const e=ya([]);return ba(e,e,[-100,-100,0]),e}}function kp(e,t,i){const r=t.createTileMatrix(e,e.worldSize,i.toUnwrapped());return va(new Float32Array(16),e.projMatrix,r)}function Lp(e,t,i){if(t.projection.name===i.projection.name)return e.projMatrix;const r=i.clone();return r.setProjection(t.projection),kp(r,t.getProjection(),e)}function Bp(e,t,i){return t.name===i.projection.name?e.projMatrix:kp(i,t,e)}class OpacityState{constructor(e,t,i,r){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):r&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class JointOpacityState{constructor(e,t,i,r,n,o=!1){this.text=new OpacityState(e?e.text:null,t,i,n),this.icon=new OpacityState(e?e.icon:null,t,r,n),this.clipped=o}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class JointPlacement{constructor(e,t,i,r=!1){this.text=e,this.icon=t,this.skipFade=i,this.clipped=r}}class CollisionCircleArray{constructor(){this.invProjMatrix=ga(),this.viewportMatrix=ga(),this.circles=[]}}class RetainedQueryData{constructor(e,t,i,r,n){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=n}}class CollisionGroups{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){const t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t}}return this.collisionGroups[e]}}function Rp(e,t,i,n,o){const{horizontalAlign:a,verticalAlign:s}=Rc(e),l=-(a-.5)*t,c=-(s-.5)*i,u=Nc(e,n);return new r(l+u[0]*o,c+u[1]*o)}function Fp(e,t,i,n,o){const a=new r(e,t);return i&&a._rotate(n?o:-o),a}class Placement{constructor(e,t,i,r,n){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new CollisionIndex(this.transform,n),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new CollisionGroups(i),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(e,t,i,r){const n=i.getBucket(t),o=i.latestFeatureIndex;if(!n||!o||t.id!==n.layerIds[0])return;const a=n.layers[0].layout,s=i.collisionBoxArray,l=Math.pow(2,this.transform.zoom-i.tileID.overscaledZ),c=i.tileSize/Eo,u=i.tileID.toUnwrapped();this.transform.setProjection(n.projection);const h=(p=i.tileID,d=n.getProjection(),f=this.transform,d.name===this.projection?f.calculateProjMatrix(p.toUnwrapped()):kp(f,d,p));var p,d,f;const m="map"===a.get("text-pitch-alignment"),_="map"===a.get("text-rotation-alignment");t.compileFilter();const g=t.dynamicFilter(),y=t.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(i),v=_p(h,i.tileID.canonical,m,_,this.transform,n.getProjection(),x);let b=null;if(m){const e=gp(h,i.tileID.canonical,m,_,this.transform,n.getProjection(),x);b=va([],this.transform.labelPlaneMatrix,e)}let w=null;g&&i.latestFeatureIndex&&(w={unwrappedTileID:u,dynamicFilter:g,dynamicFilterNeedsFeature:y,featureIndex:i.latestFeatureIndex}),this.retainedQueryData[n.bucketInstanceId]=new RetainedQueryData(n.bucketInstanceId,o,n.sourceLayerIndex,n.index,i.tileID);const T={bucket:n,layout:a,posMatrix:h,textLabelPlaneMatrix:v,labelToScreenMatrix:b,clippingData:w,scale:l,textPixelRatio:c,holdingForFade:i.holdingForFade(),collisionBoxArray:s,partiallyEvaluatedTextSize:oc(n.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:oc(n.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(n.sourceID)};if(r)for(const t of n.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n}=t;e.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n,parameters:T})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:n.symbolInstances.length,parameters:T})}attemptAnchorPlacement(e,t,i,r,n,o,a,s,l,c,u,h,p,d,f,m,_,g){const y=[h.textOffset0,h.textOffset1],x=Rp(e,i,r,y,n),v=this.collisionIndex.placeCollisionBox(d,n,t,Fp(x.x,x.y,o,a,this.transform.angle),u,s,l,c.predicate);if((!m||0!==this.collisionIndex.placeCollisionBox(d,d.getSymbolInstanceIconSize(g,this.transform.zoom,p),m,Fp(x.x,x.y,o,a,this.transform.angle),u,s,l,c.predicate).box.length)&&v.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[h.crossTileID]&&this.prevPlacement.placements[h.crossTileID]&&this.prevPlacement.placements[h.crossTileID].text&&(t=this.prevPlacement.variableOffsets[h.crossTileID].anchor),this.variableOffsets[h.crossTileID]={textOffset:y,width:i,height:r,anchor:e,textScale:n,prevAnchor:t},this.markUsedJustification(d,e,h,f),d.allowVerticalPlacement&&(this.markUsedOrientation(d,f,h),this.placedOrientations[h.crossTileID]=f),{shift:x,placedGlyphBoxes:v}}}placeLayerBucketPart(e,t,i,n){const{bucket:o,layout:a,posMatrix:s,textLabelPlaneMatrix:l,labelToScreenMatrix:c,clippingData:u,textPixelRatio:h,holdingForFade:p,collisionBoxArray:d,partiallyEvaluatedTextSize:f,partiallyEvaluatedIconSize:m,collisionGroup:_}=e.parameters,g=a.get("text-optional"),y=a.get("icon-optional"),x=a.get("text-allow-overlap"),v=a.get("icon-allow-overlap"),b="map"===a.get("text-rotation-alignment"),w="map"===a.get("text-pitch-alignment"),T="none"!==a.get("icon-text-fit"),E="viewport-y"===a.get("symbol-z-order");this.transform.setProjection(o.projection);let S=x&&(v||!o.hasIconData()||y),A=v&&(x||!o.hasTextData()||g);!o.collisionArrays&&d&&o.deserializeCollisionBoxes(d),i&&n&&o.updateCollisionDebugBuffers(this.transform.zoom,d);const C=(e,n,d)=>{if(u){const i={zoom:this.transform.zoom,pitch:this.transform.pitch};let n=null;if(u.dynamicFilterNeedsFeature){const t=this.retainedQueryData[o.bucketInstanceId];n=u.featureIndex.loadFeature({featureIndex:e.featureIndex,bucketIndex:t.bucketIndex,sourceLayerIndex:t.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,u.dynamicFilter)(i,n,this.retainedQueryData[o.bucketInstanceId].tileID.canonical,new r(e.tileAnchorX,e.tileAnchorY),this.transform.calculateDistanceTileData(u.unwrappedTileID)))return this.placements[e.crossTileID]=new JointPlacement(!1,!1,!1,!0),void(t[e.crossTileID]=!0)}if(t[e.crossTileID])return;if(p)return void(this.placements[e.crossTileID]=new JointPlacement(!1,!1,!1));let E=!1,C=!1,I=!0,M=!1,P=!1,D=null,z={box:null,offscreen:null,occluded:null},k={box:null,offscreen:null,occluded:null},L=null,B=null,R=null,F=0,O=0,V=0;d.textFeatureIndex?F=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(F=e.featureIndex),d.verticalTextFeatureIndex&&(O=d.verticalTextFeatureIndex);const U=e=>{e.tileID=this.retainedQueryData[o.bucketInstanceId].tileID,(this.transform.elevation||e.elevation)&&(e.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[o.bucketInstanceId].tileID,e.tileAnchorX,e.tileAnchorY):0)},j=d.textBox;if(j){U(j);const t=t=>{let i=Bc.horizontal;if(o.allowVerticalPlacement&&!t&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,i=t,this.markUsedOrientation(o,i,e))}return i},i=(t,i)=>{if(o.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const e of o.writingModes)if(e===Bc.vertical?(z=i(),k=z):z=t(),z&&z.box&&z.box.length)break}else z=t()};if(a.get("text-variable-anchor")){let r=a.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[e.crossTileID]){const t=this.prevPlacement.variableOffsets[e.crossTileID];r.indexOf(t.anchor)>0&&(r=r.filter((e=>e!==t.anchor)),r.unshift(t.anchor))}const l=(t,i,a)=>{const l=o.getSymbolInstanceTextSize(f,e,this.transform.zoom,n),c=(t.x2-t.x1)*l+2*t.padding,u=(t.y2-t.y1)*l+2*t.padding,p=T&&!v?i:null;p&&U(p);let d={box:[],offscreen:!1,occluded:!1};const g=x?2*r.length:r.length;for(let i=0;i<g;++i){const g=this.attemptAnchorPlacement(r[i%r.length],t,c,u,l,b,w,h,s,_,i>=r.length,e,n,o,a,p,f,m);if(g&&(d=g.placedGlyphBoxes,d&&d.box&&d.box.length)){E=!0,D=g.shift;break}}return d};i((()=>l(j,d.iconBox,Bc.horizontal)),(()=>{const t=d.verticalTextBox;return t&&U(t),o.allowVerticalPlacement&&!(z&&z.box&&z.box.length)&&e.numVerticalGlyphVertices>0&&t?l(t,d.verticalIconBox,Bc.vertical):{box:null,offscreen:null,occluded:null}})),z&&(E=z.box,I=z.offscreen,M=z.occluded);const c=t(z&&z.box);if(!E&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(o,t.anchor,e,c))}}else{const a=(t,i)=>{const a=o.getSymbolInstanceTextSize(f,e,this.transform.zoom,n),l=this.collisionIndex.placeCollisionBox(o,a,t,new r(0,0),x,h,s,_.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(o,i,e),this.placedOrientations[e.crossTileID]=i),l};i((()=>a(j,Bc.horizontal)),(()=>{const t=d.verticalTextBox;return o.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&t?(U(t),a(t,Bc.vertical)):{box:null,offscreen:null,occluded:null}})),t(z&&z.box&&z.box.length)}}if(L=z,E=L&&L.box&&L.box.length>0,I=L&&L.offscreen,M=L&&L.occluded,e.useRuntimeCollisionCircles){const t=o.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex),r=nc(o.textSizeData,f,t),n=a.get("text-padding");B=this.collisionIndex.placeCollisionCircles(o,x,t,o.lineVertexArray,o.glyphOffsetArray,r,s,l,c,i,w,_.predicate,e.collisionCircleDiameter*r/24,n,this.retainedQueryData[o.bucketInstanceId].tileID),E=x||B.circles.length>0&&!B.collisionDetected,I=I&&B.offscreen,M=B.occluded}if(d.iconFeatureIndex&&(V=d.iconFeatureIndex),d.iconBox){const e=e=>{U(e);const t=T&&D?Fp(D.x,D.y,b,w,this.transform.angle):new r(0,0),i=o.getSymbolInstanceIconSize(m,this.transform.zoom,n);return this.collisionIndex.placeCollisionBox(o,i,e,t,v,h,s,_.predicate)};k&&k.box&&k.box.length&&d.verticalIconBox?(R=e(d.verticalIconBox),C=R.box.length>0):(R=e(d.iconBox),C=R.box.length>0),I=I&&R.offscreen,P=R.occluded}const N=g||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,G=y||0===e.numIconVertices;if(N||G?G?N||(C=C&&E):E=C&&E:C=E=C&&E,E&&L&&L.box&&this.collisionIndex.insertCollisionBox(L.box,a.get("text-ignore-placement"),o.bucketInstanceId,k&&k.box&&O?O:F,_.ID),C&&R&&this.collisionIndex.insertCollisionBox(R.box,a.get("icon-ignore-placement"),o.bucketInstanceId,V,_.ID),B&&(E&&this.collisionIndex.insertCollisionCircles(B.circles,a.get("text-ignore-placement"),o.bucketInstanceId,F,_.ID),i)){const e=o.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new CollisionCircleArray);for(let e=0;e<B.circles.length;e+=4)t.circles.push(B.circles[e+0]),t.circles.push(B.circles[e+1]),t.circles.push(B.circles[e+2]),t.circles.push(B.collisionDetected?1:0)}const Z="globe"!==o.projection.name;S=S&&(Z||!M),A=A&&(Z||!P),this.placements[e.crossTileID]=new JointPlacement(E||S,C||A,I||o.justReloaded),t[e.crossTileID]=!0};if(E){const e=o.getSortedSymbolIndexes(this.transform.angle);for(let t=e.length-1;t>=0;--t){const i=e[t];C(o.symbolInstances.get(i),i,o.collisionArrays[i])}}else for(let t=e.symbolInstanceStart;t<e.symbolInstanceEnd;t++)C(o.symbolInstances.get(t),t,o.collisionArrays[t]);if(i&&o.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[o.bucketInstanceId];xa(e.invProjMatrix,s),e.viewportMatrix=this.collisionIndex.getViewportMatrix()}o.justReloaded=!1}markUsedJustification(e,t,i,r){let n;n=r===Bc.vertical?i.verticalPlacedTextSymbolIndex:{left:i.leftJustifiedTextSymbolIndex,center:i.centerJustifiedTextSymbolIndex,right:i.rightJustifiedTextSymbolIndex}[function(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}(t)];const o=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex,i.verticalPlacedTextSymbolIndex];for(const t of o)t>=0&&(e.text.placedSymbolArray.get(t).crossTileID=n>=0&&t!==n?0:i.crossTileID)}markUsedOrientation(e,t,i){const r=t===Bc.horizontal||t===Bc.horizontalOnly?t:0,n=t===Bc.vertical?t:0,o=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex];for(const t of o)e.text.placedSymbolArray.get(t).placedOrientation=r;i.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(i.verticalPlacedTextSymbolIndex).placedOrientation=n)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const r=t?t.symbolFadeChange(e):1,n=t?t.opacities:{},o=t?t.variableOffsets:{},a=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=n[e];o?(this.opacities[e]=new JointOpacityState(o,r,t.text,t.icon,null,t.clipped),i=i||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new JointOpacityState(null,r,t.text,t.icon,t.skipFade,t.clipped),i=i||t.text||t.icon)}for(const e in n){const t=n[e];if(!this.opacities[e]){const n=new JointOpacityState(t,r,!1,!1);n.isHidden()||(this.opacities[e]=n,i=i||t.text.placed||t.icon.placed)}}for(const e in o)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=o[e]);for(const e in a)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=a[e]);i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){const i={};for(const r of t){const t=r.getBucket(e);t&&r.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,i,r.collisionBoxArray)}}updateBucketOpacities(e,t,i){e.hasTextData()&&e.text.opacityVertexArray.clear(),e.hasIconData()&&e.icon.opacityVertexArray.clear(),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const n=e.layers[0].layout,o=!!e.layers[0].dynamicFilter(),a=new JointOpacityState(null,0,!1,!1,!0),s=n.get("text-allow-overlap"),l=n.get("icon-allow-overlap"),c=n.get("text-variable-anchor"),u="map"===n.get("text-rotation-alignment"),h="map"===n.get("text-pitch-alignment"),p="none"!==n.get("icon-text-fit"),d=new JointOpacityState(null,0,s&&(l||!e.hasIconData()||n.get("icon-optional")),l&&(s||!e.hasTextData()||n.get("text-optional")),!0);!e.collisionArrays&&i&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(i);const f=(e,t,i)=>{for(let r=0;r<t/4;r++)e.opacityVertexArray.emplaceBack(i)};let m=0;for(let i=0;i<e.symbolInstances.length;i++){const n=e.symbolInstances.get(i),{numHorizontalGlyphVertices:s,numVerticalGlyphVertices:l,crossTileID:_}=n;let g=this.opacities[_];t[_]?g=a:g||(g=d,this.opacities[_]=g),t[_]=!0;const y=s>0||l>0,x=n.numIconVertices>0,v=this.placedOrientations[n.crossTileID],b=v===Bc.vertical,w=v===Bc.horizontal||v===Bc.horizontalOnly;if(!y&&!x||g.isHidden()||m++,y){const t=$p(g.text);f(e.text,s,b?Wp:t),f(e.text,l,w?Wp:t);const i=g.text.isHidden();[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex].forEach((t=>{t>=0&&(e.text.placedSymbolArray.get(t).hidden=i||b?1:0)})),n.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(n.verticalPlacedTextSymbolIndex).hidden=i||w?1:0);const r=this.variableOffsets[n.crossTileID];r&&this.markUsedJustification(e,r.anchor,n,v);const o=this.placedOrientations[n.crossTileID];o&&(this.markUsedJustification(e,"left",n,o),this.markUsedOrientation(e,o,n))}if(x){const t=$p(g.icon);n.placedIconSymbolIndex>=0&&(f(e.icon,n.numIconVertices,b?Wp:t),e.icon.placedSymbolArray.get(n.placedIconSymbolIndex).hidden=g.icon.isHidden()),n.verticalPlacedIconSymbolIndex>=0&&(f(e.icon,n.numVerticalIconVertices,w?Wp:t),e.icon.placedSymbolArray.get(n.verticalPlacedIconSymbolIndex).hidden=g.icon.isHidden())}if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const t=e.collisionArrays[i];if(t){let i=new r(0,0),n=!0;if(t.textBox||t.verticalTextBox){if(c){const e=this.variableOffsets[_];e?(i=Rp(e.anchor,e.width,e.height,e.textOffset,e.textScale),u&&i._rotate(h?this.transform.angle:-this.transform.angle)):n=!1}o&&(n=!g.clipped),t.textBox&&Op(e.textCollisionBox.collisionVertexArray,g.text.placed,!n||b,i.x,i.y),t.verticalTextBox&&Op(e.textCollisionBox.collisionVertexArray,g.text.placed,!n||w,i.x,i.y)}const a=n&&Boolean(!w&&t.verticalIconBox);t.iconBox&&Op(e.iconCollisionBox.collisionVertexArray,g.icon.placed,a,p?i.x:0,p?i.y:0),t.verticalIconBox&&Op(e.iconCollisionBox.collisionVertexArray,g.icon.placed,!a,p?i.x:0,p?i.y:0)}}}if(e.fullyClipped=0===m,e.sortFeatures(this.transform.angle),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[e.bucketInstanceId];e.placementInvProjMatrix=t.invProjMatrix,e.placementViewportMatrix=t.viewportMatrix,e.collisionCircleArray=t.circles,delete this.collisionCircleArrays[e.bucketInstanceId]}}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,t){const i=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*i>e}setStale(){this.stale=!0}}function Op(e,t,i,r,n){e.emplaceBack(t?1:0,i?1:0,r||0,n||0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0)}const Vp=Math.pow(2,25),Up=Math.pow(2,24),jp=Math.pow(2,17),Np=Math.pow(2,16),Gp=Math.pow(2,9),Zp=Math.pow(2,8),qp=Math.pow(2,1);function $p(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,i=Math.floor(127*e.opacity);return i*Vp+t*Up+i*jp+t*Np+i*Gp+t*Zp+i*qp+t}const Wp=0;class LayerPlacement{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&void 0!==e.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,i,r,n){const o=this._bucketParts;for(;this._currentTileIndex<e.length;)if(t.getBucketParts(o,r,e[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,n())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,o.sort(((e,t)=>e.sortKey-t.sortKey)));this._currentPartIndex<o.length;){const e=o[this._currentPartIndex];if(t.placeLayerBucketPart(e,this._seenCrossTileIDs,i,0===e.symbolInstanceStart),this._currentPartIndex++,n())return!0}return!1}}class PauseablePlacement{constructor(e,t,i,r,n,o,a,s){this.placement=new Placement(e,n,o,a,s),this._currentPlacementIndex=t.length-1,this._forceFullPlacement=i,this._showCollisionBoxes=r,this._done=!1}isDone(){return this._done}continuePlacement(e,t,i){const r=ee.now(),n=()=>{const e=ee.now()-r;return!this._forceFullPlacement&&e>2};for(;this._currentPlacementIndex>=0;){const r=t[e[this._currentPlacementIndex]],o=this.placement.collisionIndex.transform.zoom;if("symbol"===r.type&&(!r.minzoom||r.minzoom<=o)&&(!r.maxzoom||r.maxzoom>o)){if(this._inProgressLayer||(this._inProgressLayer=new LayerPlacement(r)),this._inProgressLayer.continuePlacement(i[r.source],this.placement,this._showCollisionBoxes,r,n))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}class TileLayerIndex{constructor(e,t,i){this.tileID=e,this.indexedSymbolInstances={},this.bucketInstanceId=i;for(let i=0;i<t.length;i++){const r=t.get(i),n=r.key;this.indexedSymbolInstances[n]||(this.indexedSymbolInstances[n]=[]),this.indexedSymbolInstances[n].push({crossTileID:r.crossTileID,coord:this.getScaledCoordinates(r,e)})}}getScaledCoordinates(e,t){const i=.03125/Math.pow(2,t.canonical.z-this.tileID.canonical.z);return{x:Math.floor((t.canonical.x*Eo+e.tileAnchorX)*i),y:Math.floor((t.canonical.y*Eo+e.tileAnchorY)*i)}}findMatches(e,t,i){const r=this.tileID.canonical.z<t.canonical.z?1:Math.pow(2,this.tileID.canonical.z-t.canonical.z);for(let n=0;n<e.length;n++){const o=e.get(n);if(o.crossTileID)continue;const a=this.indexedSymbolInstances[o.key];if(!a)continue;const s=this.getScaledCoordinates(o,t);for(const e of a)if(Math.abs(e.coord.x-s.x)<=r&&Math.abs(e.coord.y-s.y)<=r&&!i[e.crossTileID]){i[e.crossTileID]=!0,o.crossTileID=e.crossTileID;break}}}}class CrossTileIDs{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class CrossTileSymbolLayerIndex{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const e in this.indexes){const i=this.indexes[e],r={};for(const e in i){const n=i[e];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),r[n.tileID.key]=n}this.indexes[e]=r}this.lng=e}addBucket(e,t,i){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let e=0;e<t.symbolInstances.length;e++)t.symbolInstances.get(e).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||(this.usedCrossTileIDs[e.overscaledZ]={});const r=this.usedCrossTileIDs[e.overscaledZ];for(const i in this.indexes){const n=this.indexes[i];if(Number(i)>e.overscaledZ)for(const i in n){const o=n[i];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,r)}else{const o=n[e.scaledTo(Number(i)).key];o&&o.findMatches(t.symbolInstances,e,r)}}for(let e=0;e<t.symbolInstances.length;e++){const n=t.symbolInstances.get(e);n.crossTileID||(n.crossTileID=i.generate(),r[n.crossTileID]=!0)}return void 0===this.indexes[e.overscaledZ]&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new TileLayerIndex(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(const i in t.indexedSymbolInstances)for(const r of t.indexedSymbolInstances[i])delete this.usedCrossTileIDs[e][r.crossTileID]}removeStaleBuckets(e){let t=!1;for(const i in this.indexes){const r=this.indexes[i];for(const n in r)e[r[n].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,r[n]),delete r[n],t=!0)}return t}}class CrossTileSymbolIndex{constructor(){this.layerIndexes={},this.crossTileIDs=new CrossTileIDs,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,i,r){let n=this.layerIndexes[e.id];void 0===n&&(n=this.layerIndexes[e.id]=new CrossTileSymbolLayerIndex);let o=!1;const a={};"globe"!==r.name&&n.handleWrapJump(i);for(const i of t){const t=i.getBucket(e);t&&e.id===t.layerIds[0]&&(t.bucketInstanceId||(t.bucketInstanceId=++this.maxBucketInstanceId),n.addBucket(i.tileID,t,this.crossTileIDs)&&(o=!0),a[t.bucketInstanceId]=!0)}return n.removeStaleBuckets(a)&&(o=!0),o}pruneUnusedLayers(e){const t={};e.forEach((e=>{t[e]=!0}));for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}const Hp=(e,t)=>vn(e,t&&t.filter((e=>"source.canvas"!==e.identifier))),Xp=w(ap,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Kp=w(ap,["setCenter","setZoom","setBearing","setPitch"]),Jp={version:8,layers:[],sources:{}},Yp={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class Style extends Evented{constructor(e,t={}){super(),this.map=e,this.dispatcher=new Dispatcher(ip(),this),this.imageManager=new ImageManager,this.imageManager.setEventedParent(this),this.glyphManager=new GlyphManager(e._requestManager,t.localFontFamily?2:t.localIdeographFontFamily?1:0,t.localFontFamily||t.localIdeographFontFamily),this.lineAtlas=new LineAtlas(256,512),this.crossTileSymbolIndex=new CrossTileSymbolIndex,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",Ke());const i=this;this._rtlTextPluginCallback=Style.registerForPluginStateChange((e=>{i.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:e.pluginStatus,pluginURL:e.pluginURL},((e,t)=>{if($n(e),t&&t.every((e=>e)))for(const e in i._sourceCaches){const t=i._sourceCaches[e],r=t.getSource().type;"vector"!==r&&"geojson"!==r||t.reload()}}))})),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getSource(e.sourceId);if(t&&t.vectorLayerIds)for(const e in this._layers){const i=this._layers[e];i.source===t.id&&this._validateLayer(i)}}))}loadURL(e,t={}){this.fire(new Event("dataloading",{dataType:"style"}));const i="boolean"==typeof t.validate?t.validate:!Ee(e);e=this.map._requestManager.normalizeStyleURL(e,t.accessToken);const r=this.map._requestManager.transformRequest(e,Xe.Style);this._request=Ye(r,((e,t)=>{this._request=null,e?this.fire(new ErrorEvent(e)):t&&this._load(t,i)}))}loadJSON(e,t={}){this.fire(new Event("dataloading",{dataType:"style"})),this._request=ee.frame((()=>{this._request=null,this._load(e,!1!==t.validate)}))}loadEmpty(){this.fire(new Event("dataloading",{dataType:"style"})),this._load(Jp,!1)}_updateLayerCount(e,t){const i=t?1:-1;e.is3D()&&(this._num3DLayers+=i),"circle"===e.type&&(this._numCircleLayers+=i),"symbol"===e.type&&(this._numSymbolLayers+=i)}_load(e,t){if(t&&Hp(this,un(e)))return;this._loaded=!0,this.stylesheet=z(e),this._updateMapProjection();for(const t in e.sources)this.addSource(t,e.sources[t],{validate:!1});this._changed=!1,e.sprite?this._loadSprite(e.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(e.glyphs);const i=op(this.stylesheet.layers);this._order=i.map((e=>e.id)),this._layers={},this._serializedLayers={};for(let e of i)e=rh(e),e.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=e,this._serializedLayers[e.id]=e.serialize(),this._updateLayerCount(e,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new Light(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 Event("data",{dataType:"style"})),this.fire(new Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}setProjection(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null))}_updateMapProjection(){this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.stylesheet.projection)}_loadSprite(e){this._spriteRequest=function(e,t,i){let r,n,o;const a=ee.devicePixelRatio>1?"@2x":"";let s=Ye(t.transformRequest(t.normalizeSpriteURL(e,a,".json"),Xe.SpriteJSON),((e,t)=>{s=null,o||(o=e,r=t,c())})),l=at(t.transformRequest(t.normalizeSpriteURL(e,a,".png"),Xe.SpriteImage),((e,t)=>{l=null,o||(o=e,n=t,c())}));function c(){if(o)i(o);else if(r&&n){const e=ee.getImageData(n),t={};for(const i in r){const{width:n,height:o,x:a,y:s,sdf:l,pixelRatio:c,stretchX:u,stretchY:h,content:p}=r[i],d=new RGBAImage({width:n,height:o});RGBAImage.copy(e,d,{x:a,y:s},{x:0,y:0},{width:n,height:o}),t[i]={data:d,pixelRatio:c,sdf:l,stretchX:u,stretchY:h,content:p}}i(null,t)}}return{cancel(){s&&(s.cancel(),s=null),l&&(l.cancel(),l=null)}}}(e,this.map._requestManager,((e,t)=>{if(this._spriteRequest=null,e)this.fire(new ErrorEvent(e));else if(t)for(const e in t)this.imageManager.addImage(e,t[e]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new Event("data",{dataType:"style"}))}))}_validateLayer(e){const t=this.getSource(e.source);if(!t)return;const i=e.sourceLayer;i&&("geojson"===t.type||t.vectorLayerIds&&-1===t.vectorLayerIds.indexOf(i))&&this.fire(new ErrorEvent(new Error(`Source layer "${i}" does not exist on source "${t.id}" as specified by style layer "${e.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(e){const t=[];for(const i of e){const e=this._layers[i];"custom"!==e.type&&t.push(e.serialize())}return t}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;if(this.fog&&this.fog.hasTransition())return!0;for(const e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(e){return!!this.terrain&&Yp[e.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(e){if(!this._loaded)return;const t=this._changed;if(this._changed){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const e in this._updatedSources){const t=this._updatedSources[e];"reload"===t?this._reloadSource(e):"clear"===t&&this._clearSource(e)}this._updateTilesForChangedImages();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.fog&&this.fog.updateTransitions(e),this._resetUpdates()}const i={};for(const e in this._sourceCaches){const t=this._sourceCaches[e];i[e]=t.used,t.used=!1}for(const t of this._order){const i=this._layers[t];if(i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)){const e=this._getLayerSourceCache(i);e&&(e.used=!0)}const r=this.map.painter;if(r){const t=i.getProgramIds();if(!t)continue;const n=i.getProgramConfiguration(e.zoom);for(const e of t)r.useProgram(e,n)}}for(const e in i){const t=this._sourceCaches[e];i[e]!==t.used&&t.getSource().fire(new Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:t.getSource().id}))}this.light.recalculate(e),this.terrain&&this.terrain.recalculate(e),this.fog&&this.fog.recalculate(e),this.z=e.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),t&&this.fire(new Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this._sourceCaches)this._sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(e),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(e){if(this._checkLoaded(),Hp(this,un(e)))return!1;(e=z(e)).layers=op(e.layers);const t=function(e,t){if(!e)return[{command:ap.setStyle,args:[t]}];let i=[];try{if(!o(e.version,t.version))return[{command:ap.setStyle,args:[t]}];o(e.center,t.center)||i.push({command:ap.setCenter,args:[t.center]}),o(e.zoom,t.zoom)||i.push({command:ap.setZoom,args:[t.zoom]}),o(e.bearing,t.bearing)||i.push({command:ap.setBearing,args:[t.bearing]}),o(e.pitch,t.pitch)||i.push({command:ap.setPitch,args:[t.pitch]}),o(e.sprite,t.sprite)||i.push({command:ap.setSprite,args:[t.sprite]}),o(e.glyphs,t.glyphs)||i.push({command:ap.setGlyphs,args:[t.glyphs]}),o(e.transition,t.transition)||i.push({command:ap.setTransition,args:[t.transition]}),o(e.light,t.light)||i.push({command:ap.setLight,args:[t.light]}),o(e.fog,t.fog)||i.push({command:ap.setFog,args:[t.fog]}),o(e.projection,t.projection)||i.push({command:ap.setProjection,args:[t.projection]});const r={},n=[];!function(e,t,i,r){let n;for(n in t=t||{},e=e||{})e.hasOwnProperty(n)&&(t.hasOwnProperty(n)||lp(n,i,r));for(n in t)t.hasOwnProperty(n)&&(e.hasOwnProperty(n)?o(e[n],t[n])||("geojson"===e[n].type&&"geojson"===t[n].type&&up(e,t,n)?i.push({command:ap.setGeoJSONSourceData,args:[n,t[n].data]}):cp(n,t,i,r)):sp(n,t,i))}(e.sources,t.sources,n,r);const a=[];e.layers&&e.layers.forEach((e=>{e.source&&r[e.source]?i.push({command:ap.removeLayer,args:[e.id]}):a.push(e)}));let s=e.terrain;s&&r[s.source]&&(i.push({command:ap.setTerrain,args:[void 0]}),s=void 0),i=i.concat(n),o(s,t.terrain)||i.push({command:ap.setTerrain,args:[t.terrain]}),function(e,t,i){t=t||[];const r=(e=e||[]).map(pp),n=t.map(pp),a=e.reduce(dp,{}),s=t.reduce(dp,{}),l=r.slice(),c=Object.create(null);let u,h,p,d,f,m,_;for(u=0,h=0;u<r.length;u++)p=r[u],s.hasOwnProperty(p)?h++:(i.push({command:ap.removeLayer,args:[p]}),l.splice(l.indexOf(p,h),1));for(u=0,h=0;u<n.length;u++)p=n[n.length-1-u],l[l.length-1-u]!==p&&(a.hasOwnProperty(p)?(i.push({command:ap.removeLayer,args:[p]}),l.splice(l.lastIndexOf(p,l.length-h),1)):h++,m=l[l.length-u],i.push({command:ap.addLayer,args:[s[p],m]}),l.splice(l.length-u,0,p),c[p]=!0);for(u=0;u<n.length;u++)if(p=n[u],d=a[p],f=s[p],!c[p]&&!o(d,f))if(o(d.source,f.source)&&o(d["source-layer"],f["source-layer"])&&o(d.type,f.type)){for(_ in hp(d.layout,f.layout,i,p,null,ap.setLayoutProperty),hp(d.paint,f.paint,i,p,null,ap.setPaintProperty),o(d.filter,f.filter)||i.push({command:ap.setFilter,args:[p,f.filter]}),o(d.minzoom,f.minzoom)&&o(d.maxzoom,f.maxzoom)||i.push({command:ap.setLayerZoomRange,args:[p,f.minzoom,f.maxzoom]}),d)d.hasOwnProperty(_)&&"layout"!==_&&"paint"!==_&&"filter"!==_&&"metadata"!==_&&"minzoom"!==_&&"maxzoom"!==_&&(0===_.indexOf("paint.")?hp(d[_],f[_],i,p,_.slice(6),ap.setPaintProperty):o(d[_],f[_])||i.push({command:ap.setLayerProperty,args:[p,_,f[_]]}));for(_ in f)f.hasOwnProperty(_)&&!d.hasOwnProperty(_)&&"layout"!==_&&"paint"!==_&&"filter"!==_&&"metadata"!==_&&"minzoom"!==_&&"maxzoom"!==_&&(0===_.indexOf("paint.")?hp(d[_],f[_],i,p,_.slice(6),ap.setPaintProperty):o(d[_],f[_])||i.push({command:ap.setLayerProperty,args:[p,_,f[_]]}))}else i.push({command:ap.removeLayer,args:[p]}),m=l[l.lastIndexOf(p)+1],i.push({command:ap.addLayer,args:[f,m]})}(a,t.layers,i)}catch(e){console.warn("Unable to compute style diff:",e),i=[{command:ap.setStyle,args:[t]}]}return i}(this.serialize(),e).filter((e=>!(e.command in Kp)));if(0===t.length)return!1;const i=t.filter((e=>!(e.command in Xp)));if(i.length>0)throw new Error(`Unimplemented: ${i.map((e=>e.command)).join(", ")}.`);return t.forEach((e=>{"setTransition"!==e.command&&"setProjection"!==e.command&&this[e.command].apply(this,e.args)})),this.stylesheet=e,this._updateMapProjection(),!0}addImage(e,t){return this.getImage(e)?this.fire(new ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(e,t),this._afterImageUpdated(e),this)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){return this.getImage(e)?(this.imageManager.removeImage(e),this._afterImageUpdated(e),this):this.fire(new ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(e,t,i={}){if(this._checkLoaded(),void 0!==this.getSource(e))throw new Error("There is already a source with this ID");if(!t.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(t).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(t.type)>=0&&this._validate(hn,`sources.${e}`,t,null,i))return;this.map&&this.map._collectResourceTiming&&(t.collectResourceTiming=!0);const r=Hh(e,t,this.dispatcher,this);r.setEventedParent(this,(()=>({isSourceLoaded:this._isSourceCacheLoaded(e),source:r.serialize(),sourceId:e})));const n=t=>{const i=(t?"symbol:":"other:")+e,n=this._sourceCaches[i]=new SourceCache(i,r,t);(t?this._symbolSourceCaches:this._otherSourceCaches)[e]=n,n.style=this,n.onAdd(this.map)};n(!1),"vector"!==t.type&&"geojson"!==t.type||n(!0),r.onAdd&&r.onAdd(this.map),this._changed=!0}removeSource(e){this._checkLoaded();const t=this.getSource(e);if(!t)throw new Error("There is no source with this ID");for(const t in this._layers)if(this._layers[t].source===e)return this.fire(new ErrorEvent(new Error(`Source "${e}" cannot be removed while layer "${t}" is using it.`)));if(this.terrain&&this.terrain.get().source===e)return this.fire(new ErrorEvent(new Error(`Source "${e}" cannot be removed while terrain is using it.`)));const i=this._getSourceCaches(e);for(const e of i)delete this._sourceCaches[e.id],delete this._updatedSources[e.id],e.fire(new Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:e.getSource().id})),e.setEventedParent(null),e.clearTiles();return delete this._otherSourceCaches[e],delete this._symbolSourceCaches[e],t.setEventedParent(null),t.onRemove&&t.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(e,t){this._checkLoaded(),this.getSource(e).setData(t),this._changed=!0}getSource(e){const t=this._getSourceCache(e);return t&&t.getSource()}addLayer(e,t,i={}){this._checkLoaded();const r=e.id;if(this.getLayer(r))return void this.fire(new ErrorEvent(new Error(`Layer with id "${r}" already exists on this map`)));let n;if("custom"===e.type){if(Hp(this,function(e){const t=[],i=e.id;return void 0===i&&t.push({message:`layers.${i}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${i}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),t}(e)))return;n=rh(e)}else{if("object"==typeof e.source&&(this.addSource(r,e.source),e=b(e=z(e),{source:r})),this._validate(mn,`layers.${r}`,e,{arrayIndex:-1},i))return;n=rh(e),this._validateLayer(n),n.setEventedParent(this,{layer:{id:r}}),this._serializedLayers[n.id]=n.serialize(),this._updateLayerCount(n,!0)}const o=t?this._order.indexOf(t):this._order.length;if(t&&-1===o)return void this.fire(new ErrorEvent(new Error(`Layer with id "${t}" does not exist on this map.`)));this._order.splice(o,0,r),this._layerOrderChanged=!0,this._layers[r]=n;const a=this._getLayerSourceCache(n);if(this._removedLayers[r]&&n.source&&a&&"custom"!==n.type){const e=this._removedLayers[r];delete this._removedLayers[r],e.type!==n.type?this._updatedSources[n.source]="clear":(this._updatedSources[n.source]="reload",a.pause())}this._updateLayer(n),n.onAdd&&n.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(e,t){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===t)return;const i=this._order.indexOf(e);this._order.splice(i,1);const r=t?this._order.indexOf(t):this._order.length;t&&-1===r?this.fire(new ErrorEvent(new Error(`Layer with id "${t}" does not exist on this map.`))):(this._order.splice(r,0,e),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(e){this._checkLoaded();const t=this._layers[e];if(!t)return void this.fire(new ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be removed.`)));t.setEventedParent(null),this._updateLayerCount(t,!1);const i=this._order.indexOf(e);this._order.splice(i,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=t,delete this._layers[e],delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],t.onRemove&&t.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(e){return this._layers[e]}hasLayer(e){return e in this._layers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return!0;return!1}setLayerZoomRange(e,t,i){this._checkLoaded();const r=this.getLayer(e);r?r.minzoom===t&&r.maxzoom===i||(null!=t&&(r.minzoom=t),null!=i&&(r.maxzoom=i),this._updateLayer(r)):this.fire(new ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(e,t,i={}){this._checkLoaded();const r=this.getLayer(e);if(r){if(!o(r.filter,t))return null==t?(r.filter=void 0,void this._updateLayer(r)):void(this._validate(_n,`layers.${r.id}.filter`,t,{layerType:r.type},i)||(r.filter=z(t),this._updateLayer(r)))}else this.fire(new ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be filtered.`)))}getFilter(e){const t=this.getLayer(e);return t&&z(t.filter)}setLayoutProperty(e,t,i,r={}){this._checkLoaded();const n=this.getLayer(e);n?o(n.getLayoutProperty(t),i)||(n.setLayoutProperty(t,i,r),this._updateLayer(n)):this.fire(new ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(e,t){const i=this.getLayer(e);if(i)return i.getLayoutProperty(t);this.fire(new ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style.`)))}setPaintProperty(e,t,i,r={}){this._checkLoaded();const n=this.getLayer(e);n?o(n.getPaintProperty(t),i)||(n.setPaintProperty(t,i,r)&&this._updateLayer(n),this._changed=!0,this._updatedPaintProps[e]=!0):this.fire(new ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(e,t){const i=this.getLayer(e);return i&&i.getPaintProperty(t)}setFeatureState(e,t){this._checkLoaded();const i=e.source,r=e.sourceLayer,n=this.getSource(i);if(!n)return void this.fire(new ErrorEvent(new Error(`The source '${i}' does not exist in the map's style.`)));const o=n.type;if("geojson"===o&&r)return void this.fire(new ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===o&&!r)return void this.fire(new ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===e.id&&this.fire(new ErrorEvent(new Error("The feature id parameter must be provided.")));const a=this._getSourceCaches(i);for(const i of a)i.setFeatureState(r,e.id,t)}removeFeatureState(e,t){this._checkLoaded();const i=e.source,r=this.getSource(i);if(!r)return void this.fire(new ErrorEvent(new Error(`The source '${i}' does not exist in the map's style.`)));const n=r.type,o="vector"===n?e.sourceLayer:void 0;if("vector"===n&&!o)return void this.fire(new ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(t&&"string"!=typeof e.id&&"number"!=typeof e.id)return void this.fire(new ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const a=this._getSourceCaches(i);for(const i of a)i.removeFeatureState(o,e.id,t)}getFeatureState(e){this._checkLoaded();const t=e.source,i=e.sourceLayer,r=this.getSource(t);if(r){if("vector"!==r.type||i)return void 0===e.id&&this.fire(new ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(t)[0].getFeatureState(i,e.id);this.fire(new ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new ErrorEvent(new Error(`The source '${t}' does not exist in the map's style.`)))}getTransition(){return b({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const e={};for(const t in this._sourceCaches){const i=this._sourceCaches[t].getSource();e[i.id]||(e[i.id]=i.serialize())}return D({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:e,layers:this._serializeLayers(this._order)},(e=>void 0!==e))}_updateLayer(e){this._updatedLayers[e.id]=!0;const t=this._getLayerSourceCache(e);e.source&&!this._updatedSources[e.source]&&t&&"raster"!==t.getSource().type&&(this._updatedSources[e.source]="reload",t.pause()),this._changed=!0,e.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._layers[e].type,i={},r=[];for(let n=this._order.length-1;n>=0;n--){const o=this._order[n];if(t(o)){i[o]=n;for(const t of e){const e=t[o];if(e)for(const t of e)r.push(t)}}}r.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const n=[];for(let o=this._order.length-1;o>=0;o--){const a=this._order[o];if(t(a))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(i[t.layer.id]<o)break;n.push(t),r.pop()}else for(const t of e){const e=t[a];if(e)for(const t of e)n.push(t.feature)}}return n}queryRenderedFeatures(e,t,i){t&&t.filter&&this._validate(_n,"queryRenderedFeatures.filter",t.filter,null,t);const r={};if(t&&t.layers){if(!Array.isArray(t.layers))return this.fire(new ErrorEvent(new Error("parameters.layers must be an Array."))),[];for(const e of t.layers){const t=this._layers[e];if(!t)return this.fire(new ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be queried for features.`))),[];r[t.source]=!0}}const n=[];t.availableImages=this._availableImages;const o=t&&t.layers?t.layers.some((e=>{const t=this.getLayer(e);return t&&t.is3D()})):this.has3DLayers(),a=QueryGeometry.createFromScreenPoints(e,i);for(const e in this._sourceCaches){const s=this._sourceCaches[e].getSource().id;t.layers&&!r[s]||n.push(Kh(this._sourceCaches[e],this._layers,this._serializedLayers,a,t,i,o,!!this.map._showQueryGeometry))}return this.placement&&n.push(function(e,t,i,r,n,o,a){const s={},l=o.queryRenderedSymbols(r),c=[];for(const e of Object.keys(l).map(Number))c.push(a[e]);c.sort(Yh);for(const i of c){const r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,n.filter,n.layers,n.availableImages,e);for(const e in r){const t=s[e]=s[e]||[],n=r[e];n.sort(((e,t)=>{const r=i.featureSortOrder;if(r){const i=r.indexOf(e.featureIndex);return r.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex}));for(const e of n)t.push(e)}}for(const t in s)s[t].forEach((r=>{const n=r.feature,o=i(e[t]).getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=o}));return s}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),a.screenGeometry,t,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(n)}querySourceFeatures(e,t){t&&t.filter&&this._validate(_n,"querySourceFeatures.filter",t.filter,null,t);const i=this._getSourceCaches(e);let r=[];for(const e of i)r=r.concat(Jh(e,t));return r}addSourceType(e,t,i){return Style.getSourceType(e)?i(new Error(`A source type called "${e}" already exists.`)):(Style.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},i):i(null,null))}getLight(){return this.light.getLight()}setLight(e,t={}){this._checkLoaded();const i=this.light.getLight();let r=!1;for(const t in e)if(!o(e[t],i[t])){r=!0;break}if(!r)return;const n=this._setTransitionParameters({duration:300,delay:0});this.light.setLight(e,t),this.light.updateTransitions(n)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(e,t=1){if(this._checkLoaded(),!e)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(1===t){if("object"==typeof e.source){const t="terrain-dem-src";this.addSource(t,e.source),e=b(e=z(e),{source:t})}if(this._validate(dn,"terrain",e))return}if(!this.terrain||this.terrain&&t!==this.terrain.drapeRenderMode)this._createTerrain(e,t);else{const t=this.terrain,i=t.get();for(const t of Object.keys(ct.terrain))!e.hasOwnProperty(t)&&ct.terrain[t].default&&(e[t]=ct.terrain[t].default);for(const r in e)if(!o(e[r],i[r])){t.set(e),this.stylesheet.terrain=e;const i=this._setTransitionParameters({duration:0});t.updateTransitions(i);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){const t=this.fog=new Fog(e,this.map.transform);this.stylesheet.fog=e;const i=this._setTransitionParameters({duration:0});t.updateTransitions(i)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask((()=>{for(const e of this.map._markers)e._evaluateOpacity()}))}getFog(){return this.fog?this.fog.get():null}setFog(e){if(this._checkLoaded(),!e)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const t=this.fog,i=t.get();0===Object.keys(e).length&&t.set(e);for(const r in e)if(!o(e[r],i[r])){t.set(e),this.stylesheet.fog=e;const i=this._setTransitionParameters({duration:0});t.updateTransitions(i);break}}else this._createFog(e);this._markersNeedUpdate=!0}_setTransitionParameters(e){return{now:ee.now(),transition:b(e,this.stylesheet.transition)}}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const e=this._order.filter((e=>this.isLayerDraped(this._layers[e]))),t=this._order.filter((e=>!this.isLayerDraped(this._layers[e])));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t)}_createTerrain(e,t){const i=this.terrain=new Terrain$1(e,t);this.stylesheet.terrain=e,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const r=this._setTransitionParameters({duration:0});i.updateTransitions(r)}_force3DLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"fill-extrusion"===t.type&&this._updateLayer(t)}}_forceSymbolLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"symbol"===t.type&&this._updateLayer(t)}}_validate(e,t,i,r,n={}){return(!n||!1!==n.validate)&&Hp(this,e.call(un,b({key:t,style:this.serialize(),value:i,styleSpec:ct},r)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),Hn.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._layers)this._layers[e].setEventedParent(null);for(const e in this._sourceCaches)this._sourceCaches[e].clearTiles(),this._sourceCaches[e].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(e){const t=this._getSourceCaches(e);for(const e of t)e.clearTiles()}_reloadSource(e){const t=this._getSourceCaches(e);for(const e of t)e.resume(),e.reload()}_updateSources(e){for(const t in this._sourceCaches)this._sourceCaches[t].update(e)}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload()}}_updatePlacement(e,t,i,r,n=!1){let o=!1,a=!1;const s={};for(const t of this._order){const i=this._layers[t];if("symbol"!==i.type)continue;if(!s[i.source]){const e=this._getLayerSourceCache(i);if(!e)continue;s[i.source]=e.getRenderableIds(!0).map((t=>e.getTileByID(t))).sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)))}const r=this.crossTileSymbolIndex.addLayer(i,s[i.source],e.center.lng,e.projection);o=o||r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),n=n||this._layerOrderChanged||0===i,this._layerOrderChanged&&this.fire(new Event("neworder")),(n||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(ee.now(),e.zoom))&&(this.pauseablePlacement=new PauseablePlacement(e,this._order,n,t,i,r,this.placement,this.fog&&e.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,s),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(ee.now()),a=!0),o&&this.pauseablePlacement.placement.setStale()),a||o)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,s[t.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(ee.now())}_releaseSymbolFadeTiles(){for(const e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles()}getImages(e,t,i){this.imageManager.getImages(t.icons,i),this._updateTilesForChangedImages();const r=e=>{e&&e.setDependencies(t.tileID.key,t.type,t.icons)};r(this._otherSourceCaches[t.source]),r(this._symbolSourceCaches[t.source])}getGlyphs(e,t,i){this.glyphManager.getGlyphs(t.stacks,i)}getResource(e,t,i){return Je(t,i)}_getSourceCache(e){return this._otherSourceCaches[e]}_getLayerSourceCache(e){return"symbol"===e.type?this._symbolSourceCaches[e.source]:this._otherSourceCaches[e.source]}_getSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),t}_isSourceCacheLoaded(e){const t=this._getSourceCaches(e);return 0===t.length?(this.fire(new ErrorEvent(new Error(`There is no source with ID '${e}'`))),!1):t.every((e=>e.loaded()))}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)}}Style.getSourceType=function(e){return Wh[e]},Style.setSourceType=function(e,t){Wh[e]=t},Style.registerForPluginStateChange=function(e){return e({pluginStatus:Zn,pluginURL:qn}),Hn.on("pluginStateChange",e),e};var Qp="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#define EXTENT 8192.0\n#define HALF_PI PI/2.0\n#define QUARTER_PI PI/4.0\n#define RAD_TO_DEG 180.0/PI\n#define DEG_TO_RAD PI/180.0\n#define GLOBE_RADIUS EXTENT/PI/2.0",ed="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;}",td="\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\nhighp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.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",id="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;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);}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",rd="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump float u_fog_temporal_offset;varying vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;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);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}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;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {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";let nd={},od={};const ad=[];hd(Qp,ad),hd(td,ad),hd(id,ad),hd(rd,ad),nd=pd("",td),od=pd(rd,id);const sd=pd("\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;}highp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}","\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;}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#ifndef 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) {return mix(globe,mercator,t);}mat3 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."),ld=Qp,cd="\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";var ud={background:pd("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:pd("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:pd("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;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\nvec3 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(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\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:pd("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:pd("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\nif (u_is_globe==0) {gl_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;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\nvec3 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:pd("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:pd("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:pd("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:pd("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:pd("#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:pd("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:pd("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:pd("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:pd("uniform lowp vec3 u_lightpos;varying vec4 v_color;\n#ifdef RENDER_SHADOWS\nvarying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;varying highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\nvoid main() {vec4 color=v_color;\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);color.rgb=color.rgb*shade;\n#endif\n#ifdef RENDER_SHADOWS\ncolor.xyz=shadowed_color_normal(color.xyz,normalize(v_normal),v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#endif\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;uniform float u_edge_radius;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#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying highp vec3 v_normal;varying float v_depth;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\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\nvec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;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,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : 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\nfloat ele=0.0;float h=0.0;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;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\nh=t > 0.0 ? height : base;vec3 pos=vec3(pos_nx.xy,h);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=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*h);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);\n#ifdef RENDER_SHADOWS\nv_pos_light_view_0=u_light_matrix_0*vec4(pos,1);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1);v_normal=normal;v_depth=gl_Position.w;\n#endif\nfloat 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)));}\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);directional*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\nv_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:pd("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\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;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 FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;\n#endif\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#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\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;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;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\nfloat ele=0.0;float h=z;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;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;h+=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)));}\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);directional*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\nv_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:pd("#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:pd("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:pd("uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec4 v_uv;\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;\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\nhighp vec4 out_color=texture2D(u_gradient_image,v_uv.xy);\n#else\nvec4 out_color=color;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {out_color=vec4(0,0,0,0);}}\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#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nattribute highp vec4 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\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;varying highp vec4 v_uv;\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;\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#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];\n#ifdef RENDER_LINE_GRADIENT\nhighp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);\n#else\nv_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\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:pd("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:pd("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:pd("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_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform 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 bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;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;uniform vec3 u_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying 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_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];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;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(tile_anchor,0)+h;float globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.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 font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);vec4 offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\nvec4 offsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetProjected_point.xy/offsetProjected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,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_min_font_scale,font_scale)+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(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat 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:pd("#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_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform 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 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_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying 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[3];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;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(tile_anchor,0)+h;float globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.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) {\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);vec4 offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\nvec4 offsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,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(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat 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:pd("#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_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform 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 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_up_vector;uniform vec2 u_texsize_icon;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying 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[3];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;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(tile_anchor,0)+h;float globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.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 font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,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*font_scale);\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(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat 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:pd("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nvarying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef RENDER_SHADOWS\ncolor.xyz=shadowed_color(color.xyz,v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#endif\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\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;\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#ifdef RENDER_SHADOWS\nvec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);v_depth=gl_Position.w;\n#endif\n}"),terrainDepth:pd("#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:pd("\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}",ed),skyboxGradient:pd("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}",ed),skyboxCapture:pd("\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:pd("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifndef FOG\nuniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;\n#endif\nvoid main() {\n#ifdef CUSTOM_ANTIALIASING\nvec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture2D(u_image0,v_pos0);vec4 color=vec4(raster.rgb*antialias,raster.a*antialias);\n#else\nvec4 color=texture2D(u_image0,v_pos0);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\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_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;\n#ifdef GLOBE_POLES\nattribute vec3 a_globe_pos;attribute vec2 a_uv;\n#else\nattribute vec2 a_pos;\n#endif\nvarying vec2 v_pos0;const float wireframeOffset=1e3;float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(QUARTER_PI+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}void main() {\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;vec2 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idy=u_grid_matrix[1][2];float S=u_grid_matrix[2][2];vec3 latLng=u_grid_matrix*vec3(a_pos,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=a_pos[0]*S;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;vec2 tile_pos=uv*EXTENT;\n#ifdef GLOBE_POLES\nvec3 up_vector=normalize(globe_pos)*u_tile_up_scale;\n#else\nvec3 up_vector=elevationVector(tile_pos);\n#endif\nfloat height=elevation(tile_pos);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nglobe_pos+=up_vector*height;\n#ifdef GLOBE_POLES\nvec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);\n#else\nvec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);\n#endif\ngl_Position=u_proj_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}"),globeAtmosphere:pd("uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec3 u_start_color;uniform vec4 u_color;uniform vec4 u_space_color;uniform vec4 u_high_color;uniform float u_star_intensity;uniform float u_star_size;uniform float u_star_density;uniform float u_horizon_angle;uniform mat4 u_rotation_matrix;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;highp float random(highp vec3 p) {p=fract(p*vec3(23.2342,97.1231,91.2342));p+=dot(p.zxy,p.yxz+123.1234);return fract(p.x*p.y);}float stars(vec3 p,float scale,vec2 offset) {vec2 uv_scale=(u_viewport/u_star_size)*scale;vec3 position=vec3(p.xy*uv_scale+offset*u_viewport,p.z);vec3 q=fract(position)-0.5;vec3 id=floor(position);float random_visibility=step(random(id),u_star_density);float circle=smoothstep(0.5+u_star_intensity,0.5,length(q));return circle*random_visibility;}void main() {highp vec3 dir=normalize(v_ray_dir);\n#ifdef PROJECTION_GLOBE_VIEW\nfloat globe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {discard;return;}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(dot(dir,horizon_dir)),0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nhighp vec3 closest_point=globe_pos_dot_dir*dir;float closest_point_to_center=length(closest_point-u_globe_pos);float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));float horizon_angle=globe_pos_dot_dir < 0.0 ?\nPI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);\n#else\nfloat horizon_angle=horizon_angle_mercator;\n#endif\nhorizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;vec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c =mix(color_stop_2,c2,t);float a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);vec2 uv=gl_FragCoord.xy/u_viewport-0.5;float aspect_ratio=u_viewport.x/u_viewport.y;vec4 uv_dir=vec4(normalize(vec3(uv.x*aspect_ratio,uv.y,1.0)),1.0);uv_dir=u_rotation_matrix*uv_dir;vec3 n=abs(uv_dir.xyz);vec2 uv_remap=(n.x > n.y && n.x > n.z) ? uv_dir.yz/uv_dir.x:\n(n.y > n.x && n.y > n.z) ? uv_dir.zx/uv_dir.y:\nuv_dir.xy/uv_dir.z;uv_remap.x/=aspect_ratio;vec3 D=vec3(uv_remap,1.0);highp float star_field=0.0;if (u_star_intensity > 0.0) {star_field+=stars(D,1.2,vec2(0.0,0.0));star_field+=stars(D,1.0,vec2(1.0,0.0));star_field+=stars(D,0.8,vec2(0.0,1.0));star_field+=stars(D,0.6,vec2(1.0,1.0));star_field*=(1.0-pow(t,0.25+(1.0-u_high_color.a)*0.75));c+=star_field*alpha_2;}c=dither(c,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=vec4(c,a);}","attribute vec3 a_pos;attribute vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(\nmix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}")};function hd(e,t){const i=e.replace(/\s*\/\/[^\n]*\n/g,"\n").split("\n");for(let e of i)if(e=e.trim(),"#"===e[0]&&e.includes("if")&&!e.includes("endif")){e=e.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const i=e.split(" ");for(const e of i)t.includes(e)||t.push(e)}}function pd(e,t){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),n={},o=[...ad];return hd(e,o),hd(t,o),{fragmentSource:e=e.replace(i,((e,t,i,r,o)=>(n[o]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nvarying ${i} ${r} ${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = u_${o};\n#endif\n`))),vertexSource:t=t.replace(i,((e,t,i,r,o)=>{const a="float"===r?"vec2":"vec4",s=o.match(/color/)?"color":a;return n[o]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nattribute ${i} ${a} a_${o};\nvarying ${i} ${r} ${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = a_${o};\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nattribute ${i} ${a} a_${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = a_${o};\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`})),staticAttributes:r,usedDefines:o}}class VertexArrayObject{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(e,t,i,r,n,o,a){this.context=e;let s=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!s&&e<r.length;e++)this.boundPaintVertexBuffers[e]!==r[e]&&(s=!0);let l=this.boundDynamicVertexBuffers.length!==a.length;for(let e=0;!l&&e<a.length;e++)this.boundDynamicVertexBuffers[e]!==a[e]&&(l=!0);if(!e.extVertexArrayObject||!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==i||s||l||this.boundIndexBuffer!==n||this.boundVertexOffset!==o)this.freshBind(t,i,r,n,o,a);else{e.bindVertexArrayOES.set(this.vao);for(const e of a)e&&e.bind();n&&n.dynamicDraw&&n.bind()}}freshBind(e,t,i,r,n,o){let a;const s=e.numAttributes,l=this.context,c=l.gl;if(l.extVertexArrayObject)this.vao&&this.destroy(),this.vao=l.extVertexArrayObject.createVertexArrayOES(),l.bindVertexArrayOES.set(this.vao),a=0,this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=r,this.boundVertexOffset=n,this.boundDynamicVertexBuffers=o;else{a=l.currentNumAttributes||0;for(let e=s;e<a;e++)c.disableVertexAttribArray(e)}t.enableAttributes(c,e),t.bind(),t.setVertexAttribPointers(c,e,n);for(const t of i)t.enableAttributes(c,e),t.bind(),t.setVertexAttribPointers(c,e,n);for(const t of o)t&&(t.enableAttributes(c,e),t.bind(),t.setVertexAttribPointers(c,e,n));r&&r.bind(),l.currentNumAttributes=s}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}function dd(e,t){const i=Math.pow(2,t.canonical.z),r=t.canonical.y;return[new MercatorCoordinate(0,r/i).toLngLat().lat,new MercatorCoordinate(0,(r+1)/i).toLngLat().lat]}function fd(e,t,i,r,n,o,a){const s=e.context,l=s.gl,c=i.fbo;if(!c)return;e.prepareDrawTile();const u=e.useProgram("hillshade");s.activeTexture.set(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,c.colorAttachment.get());const h=((e,t,i,r)=>{const n=i.paint.get("hillshade-shadow-color"),o=i.paint.get("hillshade-highlight-color"),a=i.paint.get("hillshade-accent-color");let s=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===i.paint.get("hillshade-illumination-anchor")&&(s-=e.transform.angle);const l=!e.options.moving;return{u_matrix:r||e.transform.calculateProjMatrix(t.tileID.toUnwrapped(),l),u_image:0,u_latrange:dd(0,t.tileID),u_light:[i.paint.get("hillshade-exaggeration"),s],u_shadow:n,u_highlight:o,u_accent:a}})(e,i,r,e.terrain?t.projMatrix:null);e.prepareDrawProgram(s,u,t.toUnwrapped());const{tileBoundsBuffer:p,tileBoundsIndexBuffer:d,tileBoundsSegments:f}=e.getTileBoundsBuffers(i);u.draw(s,l.TRIANGLES,n,o,a,CullFaceMode.disabled,h,r.id,p,d,f)}function md(e,t,i){if(!t.needsDEMTextureUpload)return;const r=e.context,n=r.gl;r.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||e.getTileTexture(i.stride);const o=i.getPixels();t.demTexture?t.demTexture.update(o,{premultiply:!1}):t.demTexture=new Texture(r,o,n.RGBA,{premultiply:!1}),t.needsDEMTextureUpload=!1}function _d(e,t,i,r,n,o){const a=e.context,s=a.gl;if(!t.dem)return;const l=t.dem;if(a.activeTexture.set(s.TEXTURE1),md(e,t,l),!t.demTexture)return;t.demTexture.bind(s.NEAREST,s.CLAMP_TO_EDGE);const c=l.dim;a.activeTexture.set(s.TEXTURE0);let u=t.fbo;if(!u){const e=new Texture(a,{width:c,height:c,data:null},s.RGBA);e.bind(s.LINEAR,s.CLAMP_TO_EDGE),u=t.fbo=a.createFramebuffer(c,c,!0),u.colorAttachment.set(e.texture)}a.bindFramebuffer.set(u.framebuffer),a.viewport.set([0,0,c,c]);const{tileBoundsBuffer:h,tileBoundsIndexBuffer:p,tileBoundsSegments:d}=e.getMercatorTileBoundsBuffers();e.useProgram("hillshadePrepare").draw(a,s.TRIANGLES,r,n,o,CullFaceMode.disabled,((e,t)=>{const i=t.stride,r=ga();return Pa(r,0,Eo,-8192,0,0,1),ba(r,r,[0,-8192,0]),{u_matrix:r,u_image:1,u_dimension:[i,i],u_zoom:e.overscaledZ,u_unpack:t.unpackVector}})(t.tileID,l),i.id,h,p,d),t.needsHillshadePrepare=!1}const gd=e=>({u_matrix:new UniformMatrix4f(e),u_image0:new Uniform1i(e),u_skirt_height:new Uniform1f(e)}),yd=(e,t)=>({u_matrix:e,u_image0:0,u_skirt_height:t}),xd=(e,t,i,r,n,o,a,s,l,c,u,h,p,d)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(r),u_merc_matrix:i,u_zoom_transition:n,u_merc_center:o,u_image0:0,u_frustum_tl:a,u_frustum_tr:s,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:u,u_globe_radius:h,u_viewport:p,u_grid_matrix:d?Float32Array.from(d):new Float32Array(9)});function vd(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const bd=new class VertexMorphing{constructor(){this.operations={}}newMorphing(e,t,i,r,n){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==i.tileID.key&&(t.queued=i)}else this.operations[e]={startTime:r,phase:0,duration:n,from:t,to:i,queued:null}}getMorphValuesForProxy(e){if(!(e in this.operations))return null;const t=this.operations[e];return{from:t.from,to:t.to,phase:t.phase}}update(e){for(const t in this.operations){const i=this.operations[t];for(i.phase=(e-i.startTime)/i.duration;i.phase>=1||!this._validOp(i);)if(!this._nextOp(i,e)){delete this.operations[t];break}}}_nextOp(e,t){return!!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=t,!0)}_validOp(e){return e.from.hasData()&&e.to.hasData()}},wd={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function Td(e,t){const i=1<<e.z;return!t&&(0===e.x||e.x===i-1)||0===e.y||e.y===i-1}const Ed=e=>({u_matrix:e});function Sd(e,t,i,r,n){if(n>0){const o=ee.now(),a=(o-e.timeAdded)/n,s=t?(o-t.timeAdded)/n:-1,l=i.getSource(),c=r.coveringZoomLevel({tileSize:l.tileSize,roundZoom:l.roundZoom}),u=!t||Math.abs(t.tileID.overscaledZ-c)>Math.abs(e.tileID.overscaledZ-c),h=u&&e.refreshedUponExpiration?1:_(u?a:1-s,0,1);return e.refreshedUponExpiration&&a>=1&&(e.refreshedUponExpiration=!1),t?{opacity:1,mix:1-h}:{opacity:h,mix:0}}return{opacity:1,mix:0}}class MockSourceCache extends SourceCache{constructor(e){const t={type:"raster-dem",maxzoom:e.transform.maxZoom},i=new Dispatcher(ip(),null),r=Hh("mock-dem",t,i,e.style);super("mock-dem",r,!1),r.setEventedParent(this),this._sourceLoaded=!0}_loadTile(e,t){e.state="loaded",t(null)}}class ProxySourceCache extends SourceCache{constructor(e){const t=Hh("proxy",{type:"geojson",maxzoom:e.transform.maxZoom},new Dispatcher(ip(),null),e.style);super("proxy",t,!1),t.setEventedParent(this),this.map=this.getSource().map=e,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(e,t,i){if(e.freezeTileCoverage)return;this.transform=e;const r=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce(((t,i)=>{if(t[i.key]="",!this._tiles[i.key]){const t=new Tile(i,this._source.tileSize*i.overscaleFactor(),e.tileZoom);t.state="loaded",this._tiles[i.key]=t}return t}),{});for(const e in this._tiles)e in r||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e])}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const i=Object.values(t);this.renderCachePool.push(...i),delete this.proxyCachedFBO[e]}}deallocRenderCache(){this.renderCache.forEach((e=>e.fb.destroy())),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class ProxiedTileID extends OverscaledTileID{constructor(e,t,i){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=t,this.projMatrix=i}}class Terrain extends class Elevation{isDataAvailableAtPoint(e){const t=this._source();if(!t||e.y<0||e.y>1)return!1;const i=t.getSource().maxzoom,r=1<<i,n=Math.floor(e.x),o=Math.floor((e.x-n)*r),a=Math.floor(e.y*r),s=this.findDEMTileFor(new OverscaledTileID(i,n,i,o,a));return!(!s||!s.dem)}getAtPointOrZero(e,t=0){return this.getAtPoint(e,t)||0}getAtPoint(e,t,i=!0){null==t&&(t=null);const r=this._source();if(!r)return t;if(e.y<0||e.y>1)return t;const n=r.getSource().maxzoom,o=1<<n,a=Math.floor(e.x),s=e.x-a,l=new OverscaledTileID(n,a,n,Math.floor(s*o),Math.floor(e.y*o)),c=this.findDEMTileFor(l);if(!c||!c.dem)return t;const u=c.dem,h=1<<c.tileID.canonical.z,p=(s*h-c.tileID.canonical.x)*u.dim,d=(e.y*h-c.tileID.canonical.y)*u.dim,f=Math.floor(p),m=Math.floor(d);return(i?this.exaggeration():1)*xi(xi(u.get(f,m),u.get(f,m+1),d-m),xi(u.get(f+1,m),u.get(f+1,m+1),d-m),p-f)}getAtTileOffset(e,t,i){const r=1<<e.canonical.z;return this.getAtPointOrZero(new MercatorCoordinate(e.wrap+(e.canonical.x+t/Eo)/r,(e.canonical.y+i/Eo)/r))}getAtTileOffsetFunc(e,t,i,r){return n=>{const o=this.getAtTileOffset(e,n.x,n.y),a=r.upVector(e.canonical,n.x,n.y);return ja(a,a,o*r.upVectorScale(e.canonical,t,i).metersToTile),a}}getForTilePoints(e,t,i,r){const n=DEMSampler.create(this,e,r);return!!n&&(t.forEach((e=>{e[2]=this.exaggeration()*n.getElevationAt(e[0],e[1],i)})),!0)}getMinMaxForTile(e){const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const i=t.dem.tree,r=t.tileID,n=1<<e.canonical.z-r.canonical.z;let o=e.canonical.x/n-r.canonical.x,a=e.canonical.y/n-r.canonical.y,s=0;for(let t=0;t<e.canonical.z-r.canonical.z&&!i.leaves[s];t++){o*=2,a*=2;const e=2*Math.floor(a)+Math.floor(o);s=i.childOffsets[s]+e,o%=1,a%=1}return{min:this.exaggeration()*i.minimums[s],max:this.exaggeration()*i.maximums[s]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(e,t,i){throw new Error("Pure virtual method called.")}pointCoordinate(e){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(e){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}}{constructor(e,t){super(),this.painter=e,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[i,r,n]=function(e){const t=new StructArrayLayout4i8,i=new StructArrayLayout3ui6,r=131;t.reserve(17161),i.reserve(33800);for(let e=-64;e<8288;e+=64)for(let i=-64;i<8288;i+=64){const r=i<0||i>8224||e<0||e>8224?24575:0,n=_(Math.round(i),0,Eo),o=_(Math.round(e),0,Eo);t.emplaceBack(n+r,o,n,o)}const n=(e,t)=>{const n=t*r+e;i.emplaceBack(n+1,n,n+r),i.emplaceBack(n+r,n+r+1,n+1)};for(let e=1;e<129;e++)for(let t=1;t<129;t++)n(t,e);return[0,129].forEach((e=>{for(let t=0;t<130;t++)n(t,e),n(e,t)})),[t,i,32768]}(),o=e.context;this.gridBuffer=o.createVertexBuffer(i,Ah.members),this.gridIndexBuffer=o.createIndexBuffer(r),this.gridSegments=SegmentVector.simpleSegment(0,0,i.length,r.length),this.gridNoSkirtSegments=SegmentVector.simpleSegment(0,0,i.length,n),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new ProxySourceCache(t.map),this.orthoMatrix=ga(),Pa(this.orthoMatrix,0,Eo,0,Eo,0,1);const a=o.gl;this._overlapStencilMode=new StencilMode({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=e.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=t,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new MockSourceCache(t.map)}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),e.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=e,this._checkRenderCacheEfficiency()}update(e,t,i){if(e&&e.terrain){this._style!==e&&(this.style=e),this.enabled=!0;const r=e.terrain.properties;this.sourceCache=0===e.terrain.drapeRenderMode?this._mockSourceCache:e._getSourceCache(r.get("source")),this._exaggeration=r.get("exaggeration");const n=()=>{this.sourceCache.used&&B(`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 e=this.getScaledDemTileSize();this.sourceCache.update(t,e,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,n(),this._initializing=!0),n(),t.updateElevation(!i),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(t),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(e){this._findCoveringTileCache[e]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const e=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||100!==e.efficiency&&B(`Terrain render cache efficiency is not optimal (${e.efficiency}%) and performance\n may be affected negatively, consider placing all background, fill and line layers before layer\n with id '${e.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(e){e.coord&&"source"===e.dataType?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const e in this._style._sourceCaches)this._style._sourceCaches[e].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach((e=>e.fb.destroy())),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0)}_source(){return this.enabled?this.sourceCache:null}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const e=2*this.proxySourceCache.getSource().tileSize;return[e,e]}set useVertexMorphing(e){this._useVertexMorphing=e}updateTileBinding(e){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const t=this.proxySourceCache,i=this.painter.transform;this._initializing&&(this._initializing=0===i._centerAltitude&&-1===this.getAtPointOrZero(MercatorCoordinate.fromLngLat(i.center),-1),this._emptyDEMTextureDirty=!this._initializing);const n=this.proxyCoords=t.getIds().map((e=>{const r=t.getTileByID(e).tileID;return r.projMatrix=i.calculateProjMatrix(r.toUnwrapped()),r}));!function(e,t){const i=t.transform.pointCoordinate(t.transform.getCameraPoint()),n=new r(i.x,i.y);e.sort(((e,t)=>{if(t.overscaledZ-e.overscaledZ)return t.overscaledZ-e.overscaledZ;const i=new r(e.canonical.x+(1<<e.canonical.z)*e.wrap,e.canonical.y),o=new r(t.canonical.x+(1<<t.canonical.z)*t.wrap,t.canonical.y),a=n.mult(1<<e.canonical.z);return a.x-=.5,a.y-=.5,a.distSqr(i)-a.distSqr(o)}))}(n,this.painter),this._previousZoom=i.zoom;const o=this.proxyToSource||{};this.proxyToSource={},n.forEach((e=>{this.proxyToSource[e.key]={}})),this.terrainTileForTile={};const a=this._style._sourceCaches;for(const t in a){const i=a[t];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,e[t],o),i.usedForTerrain)continue;const r=e[t];i.getSource().reparseOverscaled&&this._assignTerrainTiles(r)}this.proxiedCoords[t.id]=n.map((e=>new ProxiedTileID(e,e.key,this.orthoMatrix))),this._assignTerrainTiles(n),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(o),this.renderingToTexture=!1,this._updateTimestamp=ee.now();const s={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const i=t.tileID.key;i in s||(this._visibleDemTiles.push(t),s[i]=i)}}_assignTerrainTiles(e){this._initializing||e.forEach((e=>{if(this.terrainTileForTile[e.key])return;const t=this._findTileCoveringTileID(e,this.sourceCache);t&&(this.terrainTileForTile[e.key]=t)}))}_prepareDEMTextures(){const e=this.painter.context,t=e.gl;for(const i in this.terrainTileForTile){const r=this.terrainTileForTile[i],n=r.dem;!n||r.demTexture&&!r.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),md(this.painter,r,n))}}_prepareDemTileUniforms(e,t,i,r){if(!t||null==t.demTexture)return!1;const n=e.tileID.canonical,o=Math.pow(2,t.tileID.canonical.z-n.z),a=r||"";return i[`u_dem_tl${a}`]=[n.x*o%1,n.y*o%1],i[`u_dem_scale${a}`]=o,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const e=this.painter.context,t=e.gl;if(!this._emptyDepthBufferTexture){const i=new RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new Texture(e,i,t.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let e=0;const t=this._visibleDemTiles.reduce(((t,i)=>{if(!i.dem)return t;const r=i.dem.tree.minimums[0];return r>0&&e++,t+r}),0);return e?t/e:0}_updateEmptyDEMTexture(){const e=this.painter.context,t=e.gl;e.activeTexture.set(t.TEXTURE2);const i=this._getLoadedAreaMinimum(),r=new RGBAImage({width:1,height:1},new Uint8Array(DEMData.pack(i,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let n=this._emptyDEMTexture;return n?n.update(r,{premultiply:!1}):n=this._emptyDEMTexture=new Texture(e,r,t.RGBA,{premultiply:!1}),n}setupElevationDraw(e,t,i){const r=this.painter.context,n=r.gl,o=(a=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:DEMData.getUnpackVector(a),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});var a;o.u_dem_size=this.sourceCache.getSource().tileSize,o.u_exaggeration=this.exaggeration();const s=this.painter.transform,l=s.projection,c=e.tileID.canonical;o.u_tile_tl_up=l.upVector(c,0,0),o.u_tile_tr_up=l.upVector(c,Eo,0),o.u_tile_br_up=l.upVector(c,Eo,Eo),o.u_tile_bl_up=l.upVector(c,0,Eo),o.u_tile_up_scale=i&&i.useDenormalizedUpVectorScale?Hc:l.upVectorScale(c,s.center.lat,s.worldSize).metersToTile;let u=null,h=null,p=1;if(i&&i.morphing&&this._useVertexMorphing){const t=i.morphing.srcDemTile,r=i.morphing.dstDemTile;p=i.morphing.phase,t&&r&&(this._prepareDemTileUniforms(e,t,o,"_prev")&&(h=t),this._prepareDemTileUniforms(e,r,o)&&(u=r))}if(h&&u?(r.activeTexture.set(n.TEXTURE2),u.demTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE,n.NEAREST),r.activeTexture.set(n.TEXTURE4),h.demTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE,n.NEAREST),o.u_dem_lerp=p):(u=this.terrainTileForTile[e.tileID.key],r.activeTexture.set(n.TEXTURE2),(this._prepareDemTileUniforms(e,u,o)?u.demTexture:this.emptyDEMTexture).bind(n.NEAREST,n.CLAMP_TO_EDGE)),r.activeTexture.set(n.TEXTURE3),i&&i.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE),this._depthFBO&&(o.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE),o.u_depth_size_inv=[1,1]),i&&i.useMeterToDem&&u){const e=(1<<u.tileID.canonical.z)*Po(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;o.u_meter_to_dem=e}i&&i.labelPlaneMatrixInv&&(o.u_label_plane_matrix_inv=i.labelPlaneMatrixInv),t.setTerrainUniformValues(r,o)}renderToBackBuffer(e){const t=this.painter,i=this.painter.context;0!==e.length&&(i.bindFramebuffer.set(null),i.viewport.set([0,0,t.width,t.height]),t.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(e,t,i,r,n){if("globe"===e.transform.projection.name)!function(e,t,i,r,n){const o=e.context,a=o.gl;let s,l;const c=e.options.showTerrainWireframe?2:0,u=e.transform,p=yu(e,o,u),d=(t,i)=>{if(l===t)return;const r=[wd[t],"PROJECTION_GLOBE_VIEW"];p&&r.push("CUSTOM_ANTIALIASING"),i&&r.push(wd[c]),s=e.useProgram("globeRaster",null,r),l=t},f=e.colorModeForRenderPass(),m=new DepthMode(a.LEQUAL,DepthMode.ReadWrite,e.depthRangeFor3D);bd.update(n);const _=function(e){const t=e.pixelsPerMeter,i=t/Po(1,e.center.lat),r=ya(new Float64Array(16));return ba(r,r,[e.point.x,e.point.y,0]),wa(r,r,[i,i,t]),Float32Array.from(r)}(u),g=[Io(u.center.lng),Mo(u.center.lat)],y=c?[!1,!0]:[!1],x=e.globeSharedBuffers,v=[u.width*ee.devicePixelRatio,u.height*ee.devicePixelRatio],b=Float32Array.from(u.globeMatrix),w={useDenormalizedUpVectorScale:!0};if(y.forEach((c=>{l=-1;const p=c?a.LINES:a.TRIANGLES;for(const l of r){const r=i.getTile(l),y=StencilMode.disabled,T=t.prevTerrainTileForTile[l.key],E=t.terrainTileForTile[l.key];vd(T,E)&&bd.newMorphing(l.key,T,E,n,250),o.activeTexture.set(a.TEXTURE0),r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const S=bd.getMorphValuesForProxy(l.key),A=S?1:0;S&&ut(w,{morphing:{srcDemTile:S.from,dstDemTile:S.to,phase:h(S.phase)}});const C=ou(l.canonical),I=vu(C.getCenter().lat),M=xu(l.canonical,C,I),P=pu(tu(l.canonical)),D=xd(u.projMatrix,b,_,P,_u(u.zoom),g,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,v,M);if(d(A,c),t.setupElevationDraw(r,s,w),e.prepareDrawProgram(o,s,l.toUnwrapped()),x){const[t,i,r]=c?x.getWirefameBuffers(e.context,I):x.getGridBuffers(I);s.draw(o,p,m,y,f,CullFaceMode.backCCW,D,"globe_raster",t,i,r)}}})),x){const n=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];p&&n.push("CUSTOM_ANTIALIASING"),s=e.useProgram("globeRaster",null,n);for(const n of r){const{x:r,y:l,z:c}=n.canonical,h=0===l,p=l===(1<<c)-1,[d,_,y,b]=x.getPoleBuffers(c);if(b&&(h||p)){const l=i.getTile(n);o.activeTexture.set(a.TEXTURE0),l.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);let x=gu(c,r,u);const T=pu(tu(n.canonical)),E=(e,t)=>e.draw(o,a.TRIANGLES,m,StencilMode.disabled,f,CullFaceMode.disabled,xd(u.projMatrix,x,x,T,0,g,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,v),"globe_pole_raster",t,y,b);t.setupElevationDraw(l,s,w),e.prepareDrawProgram(o,s,n.toUnwrapped()),h&&E(s,d),p&&(x=wa(ga(),x,[1,-1,1]),E(s,_))}}}}(e,t,i,r,n);else{const o=e.context,a=o.gl;let s,l;const c=e.options.showTerrainWireframe?2:0,u=(t,i)=>{if(l===t)return;const r=[wd[t]];i&&r.push(wd[c]),s=e.useProgram("terrainRaster",null,r),l=t},p=e.colorModeForRenderPass(),d=new DepthMode(a.LEQUAL,DepthMode.ReadWrite,e.depthRangeFor3D);bd.update(n);const f=e.transform,m=6*Math.pow(1.5,22-f.zoom)*t.exaggeration();(c?[!1,!0]:[!1]).forEach((c=>{l=-1;const _=c?a.LINES:a.TRIANGLES,[g,y]=c?t.getWirefameBuffer():[t.gridIndexBuffer,t.gridSegments];for(const l of r){const r=i.getTile(l),x=StencilMode.disabled,v=t.prevTerrainTileForTile[l.key],b=t.terrainTileForTile[l.key];vd(v,b)&&bd.newMorphing(l.key,v,b,n,250),o.activeTexture.set(a.TEXTURE0),r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE,a.LINEAR_MIPMAP_NEAREST);const w=bd.getMorphValuesForProxy(l.key),T=w?1:0;let E;w&&(E={morphing:{srcDemTile:w.from,dstDemTile:w.to,phase:h(w.phase)}});const S=yd(l.projMatrix,Td(l.canonical,f.renderWorldCopies)?m/10:m);u(T,c),t.setupElevationDraw(r,s,E),e.prepareDrawProgram(o,s,l.toUnwrapped()),s.draw(o,_,d,x,p,CullFaceMode.backCCW,S,"terrain_raster",t.gridBuffer,g,y)}}))}}(t,this,this.proxySourceCache,e,this._updateTimestamp),this.renderingToTexture=!0,t.gpuTimingDeferredRenderEnd(),e.splice(0,e.length))}renderBatch(e){if(0===this._drapedRenderBatches.length)return e+1;this.renderingToTexture=!0;const t=this.painter,i=this.painter.context,r=this.proxySourceCache,n=this.proxiedCoords[r.id],o=this._drapedRenderBatches.shift(),a=[],s=t.style.order;let l=0;for(const c of n){const n=r.getTileByID(c.proxyTileKey),u=r.proxyCachedFBO[c.key]?r.proxyCachedFBO[c.key][e]:void 0,h=void 0!==u?r.renderCache[u]:this.pool[l++],p=void 0!==u;if(n.texture=h.tex,p&&!h.dirty){a.push(n.tileID);continue}let d;i.bindFramebuffer.set(h.fb.framebuffer),this.renderedToTile=!1,h.dirty&&(i.clear({color:Lt.transparent,stencil:0}),h.dirty=!1);for(let e=o.start;e<=o.end;++e){const r=t.style._layers[s[e]];if(r.isHidden(t.transform.zoom))continue;const n=t.style._getLayerSourceCache(r),o=n?this.proxyToSource[c.key][n.id]:[c];if(!o)continue;const a=o;i.viewport.set([0,0,h.fb.width,h.fb.height]),d!==(n?n.id:null)&&(this._setupStencil(h,o,r,n),d=n?n.id:null),t.renderLayer(t,n,r,a)}this.renderedToTile?(h.dirty=!0,a.push(n.tileID)):p||--l,5===l&&(l=0,this.renderToBackBuffer(a))}return this.renderToBackBuffer(a),this.renderingToTexture=!1,i.bindFramebuffer.set(null),i.viewport.set([0,0,t.width,t.height]),o.end+1}postRender(){}renderCacheEfficiency(e){const t=e.order.length;if(0===t)return{efficiency:100};let i,r=0,n=0,o=!1;for(let a=0;a<t;++a){const t=e._layers[e.order[a]];this._style.isLayerDraped(t)?(o&&++r,++n):o||(o=!0,i=t.id)}return 0===n?{efficiency:100}:{efficiency:100*(1-r/n),firstUndrapedLayer:i}}getMinElevationBelowMSL(){let e=0;return this._visibleDemTiles.filter((e=>e.dem)).forEach((t=>{e=Math.min(e,t.dem.tree.minimums[0])})),0===e?e:(e-30)*this._exaggeration}raycast(e,t,i){if(!this._visibleDemTiles)return null;const r=this._visibleDemTiles.filter((e=>e.dem)).map((r=>{const n=r.tileID,o=1<<n.overscaledZ,{x:a,y:s}=n.canonical,l=a/o,c=(a+1)/o,u=s/o,h=(s+1)/o;return{minx:l,miny:u,maxx:c,maxy:h,t:r.dem.tree.raycastRoot(l,u,c,h,e,t,i),tile:r}}));r.sort(((e,t)=>(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE)));for(const n of r){if(null==n.t)return null;const r=n.tile.dem.tree.raycast(n.minx,n.miny,n.maxx,n.maxy,e,t,i);if(null!=r)return r}return null}_createFBO(){const e=this.painter.context,t=e.gl,i=this.drapeBufferSize;e.activeTexture.set(t.TEXTURE0);const r=new Texture(e,{width:i[0],height:i[1],data:null},t.RGBA);r.bind(t.LINEAR,t.CLAMP_TO_EDGE);const n=e.createFramebuffer(i[0],i[1],!1);return n.colorAttachment.set(r.texture),n.depthAttachment=new DepthStencilAttachment(e,n.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=e.createRenderbuffer(e.gl.DEPTH_STENCIL,i[0],i[1]),this._stencilRef=0,n.depthAttachment.set(this._sharedDepthStencil),e.clear({stencil:0})):n.depthAttachment.set(this._sharedDepthStencil),e.extTextureFilterAnisotropic&&!e.extTextureFilterAnisotropicForceOff&&t.texParameterf(t.TEXTURE_2D,e.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,e.extTextureFilterAnisotropicMax),{fb:n,tex:r,dirty:!1}}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._style.light&&this._style.light.hasTransition())return!0;for(const e in this._style._sourceCaches)if(this._style._sourceCaches[e].hasTransition())return!0;return this._style.order.some((e=>{const t=this._style._layers[e],i=t.isHidden(this.painter.transform.zoom),r=t.getCrossfadeParameters(),n=!!r&&1!==r.t,o=t.hasTransition();return"custom"!==t.type&&!i&&(n||o)}))}_clearRasterFadeFromRenderCache(){let e=!1;for(const t in this._style._sourceCaches)if(this._style._sourceCaches[t]._source instanceof RasterTileSource){e=!0;break}if(e)for(let e=0;e<this._style.order.length;++e){const t=this._style._layers[this._style.order[e]],i=t.isHidden(this.painter.transform.zoom),r=this._style._getLayerSourceCache(t);if("raster"!==t.type||i||!r)continue;const n=t.paint.get("raster-fade-duration");for(const e of this.proxyCoords){const t=this.proxyToSource[e.key][r.id];if(t)for(const e of t){const t=Sd(r.getTile(e),r.findLoadedParent(e,0),r,this.painter.transform,n);(1!==t.opacity||0!==t.mix)&&this._clearRenderCacheForTile(r.id,e)}}}}_setupDrapedRenderBatches(){const e=this._style.order,t=e.length;if(0===t)return;const i=[];let r,n=0,o=this._style._layers[e[n]];for(;!this._style.isLayerDraped(o)&&o.isHidden(this.painter.transform.zoom)&&++n<t;)o=this._style._layers[e[n]];for(;n<t;++n){const t=this._style._layers[e[n]];t.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(t)?void 0===r&&(r=n):void 0!==r&&(i.push({start:r,end:n-1}),r=void 0))}void 0!==r&&i.push({start:r,end:n-1}),this._drapedRenderBatches=i}_setupRenderCache(e){const t=this.proxySourceCache;if(this._shouldDisableRenderCache()||this._invalidateRenderCache){if(this._invalidateRenderCache=!1,t.renderCache.length>t.renderCachePool.length){const e=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(let i=0;i<e.length;++i){const r=Object.values(e[i]);t.renderCachePool.push(...r)}}return}this._clearRasterFadeFromRenderCache();const i=this.proxyCoords,r=this._tilesDirty;for(let n=i.length-1;n>=0;n--){const o=i[n];if(t.getTileByID(o.key),void 0!==t.proxyCachedFBO[o.key]){const i=e[o.key],n=this.proxyToSource[o.key];let a=0;for(const e in n){const t=n[e],o=i[e];if(!o||o.length!==t.length||t.some(((t,i)=>t!==o[i]||r[e]&&r[e].hasOwnProperty(t.key)))){a=-1;break}++a}for(const e in t.proxyCachedFBO[o.key])t.renderCache[t.proxyCachedFBO[o.key][e]].dirty=a<0||a!==Object.values(i).length}}const n=[...this._drapedRenderBatches];n.sort(((e,t)=>t.end-t.start-(e.end-e.start)));for(const e of n)for(const r of i){if(t.proxyCachedFBO[r.key])continue;let i=t.renderCachePool.pop();void 0===i&&t.renderCache.length<50&&(i=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==i&&(t.proxyCachedFBO[r.key]={},t.proxyCachedFBO[r.key][e.start]=i,t.renderCache[i].dirty=!0)}this._tilesDirty={}}_setupStencil(e,t,i,r){if(!r||!this._sourceTilesOverlap[r.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const n=this.painter.context,o=n.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let a;if(i.isTileClipped())a=t.length,this._overlapStencilMode.test={func:o.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);a=1,this._overlapStencilMode.test={func:o.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+a>255&&(n.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=a,this._overlapStencilMode.ref=this._stencilRef,i.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(e){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[e.key]),this._overlapStencilMode):StencilMode.disabled}_renderTileClippingMasks(e,t){const i=this.painter,r=this.painter.context,n=r.gl;i._tileClippingMaskIDs={},r.setColorMode(ColorMode.disabled),r.setDepthMode(DepthMode.disabled);const o=i.useProgram("clippingMask");for(const a of e){const e=i._tileClippingMaskIDs[a.key]=--t;o.draw(r,n.TRIANGLES,DepthMode.disabled,new StencilMode({func:n.ALWAYS,mask:0},e,255,n.KEEP,n.KEEP,n.REPLACE),ColorMode.disabled,CullFaceMode.disabled,Ed(a.projMatrix),"$clipping",i.tileExtentBuffer,i.quadTriangleIndexBuffer,i.tileExtentSegments)}}pointCoordinate(e){const t=this.painter.transform;if(e.x<0||e.x>t.width||e.y<0||e.y>t.height)return null;const i=[e.x,e.y,1,1];is(i,i,t.pixelMatrixInverse),ts(i,i,1/i[3]),i[0]/=t.worldSize,i[1]/=t.worldSize;const r=t._camera.position,n=Po(1,t.center.lat),o=[r[0],r[1],r[2]/n,0],a=Fa([],i.slice(0,3),o);Za(a,a);const s=this.raycast(o,a,this._exaggeration);return null!==s&&s?(Na(o,o,a,s),o[3]=o[2],o[2]*=n,o):null}drawDepth(){const e=this.painter,t=e.context,i=this.proxySourceCache,r=Math.ceil(e.width),n=Math.ceil(e.height);if(!this._depthFBO||this._depthFBO.width===r&&this._depthFBO.height===n||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const e=t.gl,i=t.createFramebuffer(r,n,!0);t.activeTexture.set(e.TEXTURE0);const o=new Texture(t,{width:r,height:n,data:null},e.RGBA);o.bind(e.NEAREST,e.CLAMP_TO_EDGE),i.colorAttachment.set(o.texture);const a=t.createRenderbuffer(t.gl.DEPTH_COMPONENT16,r,n);i.depthAttachment.set(a),this._depthFBO=i,this._depthTexture=o}t.bindFramebuffer.set(this._depthFBO.framebuffer),t.viewport.set([0,0,r,n]),function(e,t,i,r){if("globe"===e.transform.projection.name)return;const n=e.context,o=n.gl;n.clear({depth:1});const a=e.useProgram("terrainDepth"),s=new DepthMode(o.LESS,DepthMode.ReadWrite,e.depthRangeFor3D);for(const e of r){const r=i.getTile(e),l=yd(e.projMatrix,0);t.setupElevationDraw(r,a),a.draw(n,o.TRIANGLES,s,StencilMode.disabled,ColorMode.unblended,CullFaceMode.backCCW,l,"terrain_depth",t.gridBuffer,t.gridIndexBuffer,t.gridNoSkirtSegments)}}(e,this,i,this.proxyCoords)}_setupProxiedCoordsForOrtho(e,t,i){if(e.getSource()instanceof ImageSource)return this._setupProxiedCoordsForImageSource(e,t,i);this._findCoveringTileCache[e.id]=this._findCoveringTileCache[e.id]||{};const r=this.proxiedCoords[e.id]=[],n=this.proxyCoords;for(let t=0;t<n.length;t++){const o=n[t],a=this._findTileCoveringTileID(o,e);if(a){const t=this._createProxiedId(o,a,i[o.key]&&i[o.key][e.id]);r.push(t),this.proxyToSource[o.key][e.id]=[t]}}let o=!1;for(let n=0;n<t.length;n++){const a=e.getTile(t[n]);if(!a||!a.hasData())continue;const s=this._findTileCoveringTileID(a.tileID,this.proxySourceCache);if(s&&s.tileID.canonical.z!==a.tileID.canonical.z){const t=this.proxyToSource[s.tileID.key][e.id],n=this._createProxiedId(s.tileID,a,i[s.tileID.key]&&i[s.tileID.key][e.id]);t?t.splice(t.length-1,0,n):this.proxyToSource[s.tileID.key][e.id]=[n],r.push(n),o=!0}}this._sourceTilesOverlap[e.id]=o}_setupProxiedCoordsForImageSource(e,t,i){if(!e.getSource().loaded())return;const n=this.proxiedCoords[e.id]=[],o=this.proxyCoords,a=e.getSource(),s=new r(a.tileID.x,a.tileID.y)._div(1<<a.tileID.z),l=a.coordinates.map(MercatorCoordinate.fromLngLat).reduce(((e,t)=>(e.min.x=Math.min(e.min.x,t.x-s.x),e.min.y=Math.min(e.min.y,t.y-s.y),e.max.x=Math.max(e.max.x,t.x-s.x),e.max.y=Math.max(e.max.y,t.y-s.y),e)),{min:new r(Number.MAX_VALUE,Number.MAX_VALUE),max:new r(-Number.MAX_VALUE,-Number.MAX_VALUE)}),c=(e,t)=>{const i=e.wrap+e.canonical.x/(1<<e.canonical.z),r=e.canonical.y/(1<<e.canonical.z),n=Eo/(1<<e.canonical.z),o=t.wrap+t.canonical.x/(1<<t.canonical.z),a=t.canonical.y/(1<<t.canonical.z);return i+n<o+l.min.x||i>o+l.max.x||r+n<a+l.min.y||r>a+l.max.y};for(let r=0;r<o.length;r++){const a=o[r];for(let r=0;r<t.length;r++){const o=e.getTile(t[r]);if(!o||!o.hasData())continue;if(c(a,o.tileID))continue;const s=this._createProxiedId(a,o,i[a.key]&&i[a.key][e.id]),l=this.proxyToSource[a.key][e.id];l?l.push(s):this.proxyToSource[a.key][e.id]=[s],n.push(s)}}}_createProxiedId(e,t,i){let r=this.orthoMatrix;if(i){const e=i.find((e=>e.key===t.tileID.key));if(e)return e}if(t.tileID.key!==e.key){const i=e.canonical.z-t.tileID.canonical.z;let n,o,a;r=ga();const s=t.tileID.wrap-e.wrap<<e.overscaledZ;i>0?(n=Eo>>i,o=n*((t.tileID.canonical.x<<i)-e.canonical.x+s),a=n*((t.tileID.canonical.y<<i)-e.canonical.y)):(n=Eo<<-i,o=Eo*(t.tileID.canonical.x-(e.canonical.x+s<<-i)),a=Eo*(t.tileID.canonical.y-(e.canonical.y<<-i))),Pa(r,0,n,0,n,0,1),ba(r,r,[o,a,0])}return new ProxiedTileID(t.tileID,e.key,r)}_findTileCoveringTileID(e,t){let i=t.getTile(e);if(i&&i.hasData())return i;const r=this._findCoveringTileCache[t.id],n=r[e.key];if(i=n?t.getTileByID(n):null,i&&i.hasData()||null===n)return i;let o=i?i.tileID:e,a=o.overscaledZ;const s=t.getSource().minzoom,l=[];if(!n){const r=t.getSource().maxzoom;if(e.canonical.z>=r){const i=e.canonical.z-r;t.getSource().reparseOverscaled?(a=Math.max(e.canonical.z+2,t.transform.tileZoom),o=new OverscaledTileID(a,e.wrap,r,e.canonical.x>>i,e.canonical.y>>i)):0!==i&&(a=r,o=new OverscaledTileID(a,e.wrap,r,e.canonical.x>>i,e.canonical.y>>i))}o.key!==e.key&&(l.push(o.key),i=t.getTile(o))}const c=e=>{l.forEach((t=>{r[t]=e})),l.length=0};for(a-=1;a>=s&&(!i||!i.hasData());a--){i&&c(i.tileID.key);const e=o.calculateScaledKey(a);if(i=t.getTileByID(e),i&&i.hasData())break;const n=r[e];if(null===n)break;void 0===n?l.push(e):i=t.getTileByID(n)}return c(i?i.tileID.key:null),i&&i.hasData()?i:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(e,t){let i=this._tilesDirty[e];i||(i=this._tilesDirty[e]={}),i[t.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const e=function(e){let t=0;const i=new StructArrayLayout2ui4,r=131;for(let e=1;e<129;e++){for(let n=1;n<129;n++)t=e*r+n,i.emplaceBack(t,t+1),i.emplaceBack(t,t+r),i.emplaceBack(t+1,t+r),128===e&&i.emplaceBack(t+r,t+r+1);i.emplaceBack(t+1,t+1+r)}return i}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(e),this.wireframeSegments=SegmentVector.simpleSegment(0,0,this.gridBuffer.length,e.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}class Program{static cacheKey(e,t,i,r){let n=`${t}${r?r.cacheKey:""}`;for(const t of i)e.usedDefines.includes(t)&&(n+=`/${t}`);return n}constructor(e,t,i,r,n,o){const a=e.gl;this.program=a.createProgram();const s=function(e){const t=[];for(let i=0;i<e.length;i++){if(null===e[i])continue;const r=e[i].split(" ");t.push(r.pop())}return t}(i.staticAttributes),l=r?r.getBinderAttributes():[],c=s.concat(l);let u=r?r.defines():[];u=u.concat(o.map((e=>`#define ${e}`)));const h=u.concat(e.extStandardDerivatives?"#extension GL_OES_standard_derivatives : enable\n".concat(cd):cd,cd,ld,sd.fragmentSource,od.fragmentSource,i.fragmentSource).join("\n"),p=u.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",ld,sd.vertexSource,od.vertexSource,nd.vertexSource,i.vertexSource).join("\n"),d=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(d,h),a.compileShader(d),a.attachShader(this.program,d);const f=a.createShader(a.VERTEX_SHADER);if(a.isContextLost())this.failedToCreate=!0;else{a.shaderSource(f,p),a.compileShader(f),a.attachShader(this.program,f),this.attributes={},this.numAttributes=c.length;for(let e=0;e<this.numAttributes;e++)c[e]&&(a.bindAttribLocation(this.program,e,c[e]),this.attributes[c[e]]=e);a.linkProgram(this.program),a.deleteShader(f),a.deleteShader(d),this.fixedUniforms=n(e),this.binderUniforms=r?r.getUniforms(e):[],-1!==o.indexOf("TERRAIN")&&(this.terrainUniforms=(e=>({u_dem:new Uniform1i(e),u_dem_prev:new Uniform1i(e),u_dem_unpack:new Uniform4f(e),u_dem_tl:new Uniform2f(e),u_dem_scale:new Uniform1f(e),u_dem_tl_prev:new Uniform2f(e),u_dem_scale_prev:new Uniform1f(e),u_dem_size:new Uniform1f(e),u_dem_lerp:new Uniform1f(e),u_exaggeration:new Uniform1f(e),u_depth:new Uniform1i(e),u_depth_size_inv:new Uniform2f(e),u_meter_to_dem:new Uniform1f(e),u_label_plane_matrix_inv:new UniformMatrix4f(e),u_tile_tl_up:new Uniform3f(e),u_tile_tr_up:new Uniform3f(e),u_tile_br_up:new Uniform3f(e),u_tile_bl_up:new Uniform3f(e),u_tile_up_scale:new Uniform1f(e)}))(e)),-1!==o.indexOf("FOG")&&(this.fogUniforms=(e=>({u_fog_matrix:new UniformMatrix4f(e),u_fog_range:new Uniform2f(e),u_fog_color:new Uniform4f(e),u_fog_horizon_blend:new Uniform1f(e),u_fog_temporal_offset:new Uniform1f(e),u_frustum_tl:new Uniform3f(e),u_frustum_tr:new Uniform3f(e),u_frustum_br:new Uniform3f(e),u_frustum_bl:new Uniform3f(e),u_globe_pos:new Uniform3f(e),u_globe_radius:new Uniform1f(e),u_globe_transition:new Uniform1f(e),u_is_globe:new Uniform1i(e),u_viewport:new Uniform2f(e)}))(e))}}setTerrainUniformValues(e,t){if(!this.terrainUniforms)return;const i=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e])}}setFogUniformValues(e,t){if(!this.fogUniforms)return;const i=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e])}}draw(e,t,i,r,n,o,a,s,l,c,u,h,p,d,f){const m=e.gl;if(this.failedToCreate)return;e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(r),e.setColorMode(n),e.setCullFace(o);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(this.program,e,a[e]);d&&d.setUniforms(this.program,e,this.binderUniforms,h,{zoom:p});const _={[m.LINES]:2,[m.TRIANGLES]:3,[m.LINE_STRIP]:1}[t];for(const i of u.get()){const r=i.vaos||(i.vaos={});(r[s]||(r[s]=new VertexArrayObject)).bind(e,this,l,d?d.getPaintVertexBuffers():[],c,i.vertexOffset,f||[]),m.drawElements(t,i.primitiveLength*_,m.UNSIGNED_SHORT,i.primitiveOffset*_*2)}}}function Ad(e,t,i){const r=1/dh(i,1,t.transform.tileZoom),n=Math.pow(2,i.tileID.overscaledZ),o=i.tileSize*Math.pow(2,t.transform.tileZoom)/n,a=o*(i.tileID.canonical.x+i.tileID.wrap*n),s=o*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[r,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[a>>16,s>>16],u_pixel_coord_lower:[65535&a,65535&s]}}const Cd=ga(),Id=(e,t,i,r,n,o,a,s,l,c,u)=>{const h=t.style.light,p=h.properties.get("position"),d=[p.x,p.y,p.z],f=fa();var m,_,g,y;"viewport"===h.properties.get("anchor")&&(m=f,_=-t.transform.angle,g=Math.sin(_),y=Math.cos(_),m[0]=y,m[1]=g,m[2]=0,m[3]=-g,m[4]=y,m[5]=0,m[6]=0,m[7]=0,m[8]=1,Ha(d,d,f));const x=h.properties.get("color"),v=t.transform,b={u_matrix:e,u_lightpos:d,u_lightintensity:h.properties.get("intensity"),u_lightcolor:[x.r,x.g,x.b],u_vertical_gradient:+i,u_opacity:r,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Cd,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:n,u_edge_radius:o};return"globe"===v.projection.name&&(b.u_tile_id=[a.canonical.x,a.canonical.y,1<<a.canonical.z],b.u_zoom_transition=l,b.u_inv_rot_matrix=u,b.u_merc_center=c,b.u_up_dir=v.projection.upVector(new CanonicalTileID(0,0,0),c[0]*Eo,c[1]*Eo),b.u_height_lift=s),b},Md=(e,t,i,r,n,o,a,s,l,c,u,h,p)=>{const d=Id(e,t,i,r,n,o,a,c,u,h,p),f={u_height_factor:-Math.pow(2,a.overscaledZ)/l.tileSize/8};return b(d,Ad(s,t,l),f)},Pd=e=>({u_matrix:e}),Dd=(e,t,i,r)=>b(Pd(e),Ad(i,t,r)),zd=(e,t)=>({u_matrix:e,u_world:t}),kd=(e,t,i,r,n)=>b(Dd(e,t,i,r),{u_world:n}),Ld=ga(),Bd=(e,t,i,r,n,o)=>{const a=e.transform,s="globe"===a.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(s){const e=fu(a.zoom,t.canonical)*a._pixelsPerMercatorPixel;l=Float32Array.from([e,0,0,e])}else l=a.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([a.pixelsToGLUnits[0],0,0,a.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:a.cameraToCenterDistance,u_matrix:e.translatePosMatrix(t.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ee.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Ld,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(s){c.u_inv_rot_matrix=r,c.u_merc_center=n,c.u_tile_id=[t.canonical.x,t.canonical.y,1<<t.canonical.z],c.u_zoom_transition=_u(a.zoom);const e=n[0]*Eo,i=n[1]*Eo;c.u_up_dir=a.projection.upVector(new CanonicalTileID(0,0,0),e,i)}return c},Rd=e=>{const t=[];return"map"===e.paint.get("circle-pitch-alignment")&&t.push("PITCH_WITH_MAP"),"map"===e.paint.get("circle-pitch-scale")&&t.push("SCALE_WITH_MAP"),t},Fd=(e,t,i,r)=>{const n=Eo/i.tileSize;return{u_matrix:e,u_camera_to_center_distance:t.getCameraToCenterDistance(r),u_extrude_scale:[t.pixelsToGLUnits[0]/n,t.pixelsToGLUnits[1]/n]}},Od=(e,t,i=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:i}),Vd=ga(),Ud=(e,t,i,r,n,o,a)=>{const s=e.transform,l="globe"===s.projection.name,c=l?fu(s.zoom,t.canonical)*s._pixelsPerMercatorPixel:dh(i,1,o),u={u_matrix:t.projMatrix,u_extrude_scale:c,u_intensity:a,u_inv_rot_matrix:Vd,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(l){u.u_inv_rot_matrix=r,u.u_merc_center=n,u.u_tile_id=[t.canonical.x,t.canonical.y,1<<t.canonical.z],u.u_zoom_transition=_u(s.zoom);const e=n[0]*Eo,i=n[1]*Eo;u.u_up_dir=s.projection.upVector(new CanonicalTileID(0,0,0),e,i)}return u},jd=(e,t,i,r,n,o,a,s)=>{const l=e.transform,c=l.calculatePixelsToTileUnitsMatrix(t),u={u_matrix:Zd(e,t,i,n),u_pixels_to_tile_units:c,u_device_pixel_ratio:a,u_units_to_pixels:[1/l.pixelsToGLUnits[0],1/l.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:o,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0,u_trim_offset:s};if(qd(i)){const i=Gd(t,e.transform);u.u_texsize=t.lineAtlasTexture.size,u.u_scale=[i,r.fromScale,r.toScale],u.u_mix=r.t}return u},Nd=(e,t,i,r,n,o)=>{const a=e.transform,s=Gd(t,a);return{u_matrix:Zd(e,t,i,n),u_texsize:t.imageAtlasTexture.size,u_pixels_to_tile_units:a.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:o,u_image:0,u_scale:[s,r.fromScale,r.toScale],u_fade:r.t,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function Gd(e,t){return 1/dh(e,1,t.tileZoom)}function Zd(e,t,i,r){return e.translatePosMatrix(r||t.tileID.projMatrix,t,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}function qd(e){const t=e.paint.get("line-dasharray").value;return t.value||"constant"!==t.kind}const $d=(e,t,i,r,n,o)=>{return{u_matrix:e,u_tl_parent:t,u_scale_parent:i,u_fade_t:r.mix,u_opacity:r.opacity*n.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:n.paint.get("raster-brightness-min"),u_brightness_high:n.paint.get("raster-brightness-max"),u_saturation_factor:(s=n.paint.get("raster-saturation"),s>0?1-1/(1.001-s):-s),u_contrast_factor:(a=n.paint.get("raster-contrast"),a>0?1/(1-a):1+a),u_spin_weights:Wd(n.paint.get("raster-hue-rotate")),u_perspective_transform:o};var a,s};function Wd(e){e*=Math.PI/180;const t=Math.sin(e),i=Math.cos(e);return[(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}const Hd=ga(),Xd=(e,t,i,r,n,o,a,s,l,c,u,h,p,d,f,m)=>{const _=n.transform,g={u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:_.cameraToCenterDistance,u_rotate_symbol:+i,u_aspect_ratio:_.width/_.height,u_fade_change:n.options.fadeDuration?n.symbolFadeChange:1,u_matrix:o,u_label_plane_matrix:a,u_coord_matrix:s,u_is_text:+l,u_pitch_with_map:+r,u_texsize:c,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Hd,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Hd,u_up_vector:[0,-1,0]};return"globe"===m.name&&(g.u_tile_id=[u.canonical.x,u.canonical.y,1<<u.canonical.z],g.u_zoom_transition=h,g.u_inv_rot_matrix=d,g.u_merc_center=p,g.u_camera_forward=_._camera.forward(),g.u_ecef_origin=function(e,t){const i=[0,0,0];return Wa(i,i,pu(tu(t.canonical))),Wa(i,i,e),i}(_.globeMatrix,u.toUnwrapped()),g.u_tile_matrix=Float32Array.from(_.globeMatrix),g.u_up_vector=f),g},Kd=(e,t,i,r,n,o,a,s,l,c,u,h,p,d,f,m,_)=>b(Xd(e,t,i,r,n,o,a,s,l,c,h,p,d,f,m,_),{u_gamma_scale:r?n.transform.cameraToCenterDistance*Math.cos(n.terrain?0:n.transform._pitch):1,u_device_pixel_ratio:ee.devicePixelRatio,u_is_halo:+u}),Jd=(e,t,i,r,n,o,a,s,l,c,u,h,p,d,f,m)=>b(Kd(e,t,i,r,n,o,a,s,!0,l,!0,u,h,p,d,f,m),{u_texsize_icon:c,u_texture_icon:1}),Yd=(e,t,i)=>({u_matrix:e,u_opacity:t,u_color:i}),Qd=(e,t,i,r,n,o)=>b(function(e,t,i,r){const n=i.imageManager.getPattern(e.from.toString()),o=i.imageManager.getPattern(e.to.toString()),{width:a,height:s}=i.imageManager.getPixelSize(),l=Math.pow(2,r.tileID.overscaledZ),c=r.tileSize*Math.pow(2,i.transform.tileZoom)/l,u=c*(r.tileID.canonical.x+r.tileID.wrap*l),h=c*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:n.tl,u_pattern_br_a:n.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[a,s],u_mix:t.t,u_pattern_size_a:n.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:t.fromScale,u_scale_b:t.toScale,u_tile_units_to_pixels:1/dh(r,1,i.transform.tileZoom),u_pixel_coord_upper:[u>>16,h>>16],u_pixel_coord_lower:[65535&u,65535&h]}}(r,o,i,n),{u_matrix:e,u_opacity:t}),ef={fillExtrusion:e=>({u_matrix:new UniformMatrix4f(e),u_lightpos:new Uniform3f(e),u_lightintensity:new Uniform1f(e),u_lightcolor:new Uniform3f(e),u_vertical_gradient:new Uniform1f(e),u_opacity:new Uniform1f(e),u_edge_radius:new Uniform1f(e),u_ao:new Uniform2f(e),u_tile_id:new Uniform3f(e),u_zoom_transition:new Uniform1f(e),u_inv_rot_matrix:new UniformMatrix4f(e),u_merc_center:new Uniform2f(e),u_up_dir:new Uniform3f(e),u_height_lift:new Uniform1f(e)}),fillExtrusionPattern:e=>({u_matrix:new UniformMatrix4f(e),u_lightpos:new Uniform3f(e),u_lightintensity:new Uniform1f(e),u_lightcolor:new Uniform3f(e),u_vertical_gradient:new Uniform1f(e),u_height_factor:new Uniform1f(e),u_edge_radius:new Uniform1f(e),u_ao:new Uniform2f(e),u_tile_id:new Uniform3f(e),u_zoom_transition:new Uniform1f(e),u_inv_rot_matrix:new UniformMatrix4f(e),u_merc_center:new Uniform2f(e),u_up_dir:new Uniform3f(e),u_height_lift:new Uniform1f(e),u_image:new Uniform1i(e),u_texsize:new Uniform2f(e),u_pixel_coord_upper:new Uniform2f(e),u_pixel_coord_lower:new Uniform2f(e),u_scale:new Uniform3f(e),u_fade:new Uniform1f(e),u_opacity:new Uniform1f(e)}),fill:e=>({u_matrix:new UniformMatrix4f(e)}),fillPattern:e=>({u_matrix:new UniformMatrix4f(e),u_image:new Uniform1i(e),u_texsize:new Uniform2f(e),u_pixel_coord_upper:new Uniform2f(e),u_pixel_coord_lower:new Uniform2f(e),u_scale:new Uniform3f(e),u_fade:new Uniform1f(e)}),fillOutline:e=>({u_matrix:new UniformMatrix4f(e),u_world:new Uniform2f(e)}),fillOutlinePattern:e=>({u_matrix:new UniformMatrix4f(e),u_world:new Uniform2f(e),u_image:new Uniform1i(e),u_texsize:new Uniform2f(e),u_pixel_coord_upper:new Uniform2f(e),u_pixel_coord_lower:new Uniform2f(e),u_scale:new Uniform3f(e),u_fade:new Uniform1f(e)}),circle:e=>({u_camera_to_center_distance:new Uniform1f(e),u_extrude_scale:new UniformMatrix2f(e),u_device_pixel_ratio:new Uniform1f(e),u_matrix:new UniformMatrix4f(e),u_inv_rot_matrix:new UniformMatrix4f(e),u_merc_center:new Uniform2f(e),u_tile_id:new Uniform3f(e),u_zoom_transition:new Uniform1f(e),u_up_dir:new Uniform3f(e)}),collisionBox:e=>({u_matrix:new UniformMatrix4f(e),u_camera_to_center_distance:new Uniform1f(e),u_extrude_scale:new Uniform2f(e)}),collisionCircle:e=>({u_matrix:new UniformMatrix4f(e),u_inv_matrix:new UniformMatrix4f(e),u_camera_to_center_distance:new Uniform1f(e),u_viewport_size:new Uniform2f(e)}),debug:e=>({u_color:new UniformColor(e),u_matrix:new UniformMatrix4f(e),u_overlay:new Uniform1i(e),u_overlay_scale:new Uniform1f(e)}),clippingMask:e=>({u_matrix:new UniformMatrix4f(e)}),heatmap:e=>({u_extrude_scale:new Uniform1f(e),u_intensity:new Uniform1f(e),u_matrix:new UniformMatrix4f(e),u_inv_rot_matrix:new UniformMatrix4f(e),u_merc_center:new Uniform2f(e),u_tile_id:new Uniform3f(e),u_zoom_transition:new Uniform1f(e),u_up_dir:new Uniform3f(e)}),heatmapTexture:e=>({u_image:new Uniform1i(e),u_color_ramp:new Uniform1i(e),u_opacity:new Uniform1f(e)}),hillshade:e=>({u_matrix:new UniformMatrix4f(e),u_image:new Uniform1i(e),u_latrange:new Uniform2f(e),u_light:new Uniform2f(e),u_shadow:new UniformColor(e),u_highlight:new UniformColor(e),u_accent:new UniformColor(e)}),hillshadePrepare:e=>({u_matrix:new UniformMatrix4f(e),u_image:new Uniform1i(e),u_dimension:new Uniform2f(e),u_zoom:new Uniform1f(e),u_unpack:new Uniform4f(e)}),line:e=>({u_matrix:new UniformMatrix4f(e),u_pixels_to_tile_units:new UniformMatrix2f(e),u_device_pixel_ratio:new Uniform1f(e),u_units_to_pixels:new Uniform2f(e),u_dash_image:new Uniform1i(e),u_gradient_image:new Uniform1i(e),u_image_height:new Uniform1f(e),u_texsize:new Uniform2f(e),u_scale:new Uniform3f(e),u_mix:new Uniform1f(e),u_alpha_discard_threshold:new Uniform1f(e),u_trim_offset:new Uniform2f(e)}),linePattern:e=>({u_matrix:new UniformMatrix4f(e),u_texsize:new Uniform2f(e),u_pixels_to_tile_units:new UniformMatrix2f(e),u_device_pixel_ratio:new Uniform1f(e),u_image:new Uniform1i(e),u_units_to_pixels:new Uniform2f(e),u_scale:new Uniform3f(e),u_fade:new Uniform1f(e),u_alpha_discard_threshold:new Uniform1f(e)}),raster:e=>({u_matrix:new UniformMatrix4f(e),u_tl_parent:new Uniform2f(e),u_scale_parent:new Uniform1f(e),u_fade_t:new Uniform1f(e),u_opacity:new Uniform1f(e),u_image0:new Uniform1i(e),u_image1:new Uniform1i(e),u_brightness_low:new Uniform1f(e),u_brightness_high:new Uniform1f(e),u_saturation_factor:new Uniform1f(e),u_contrast_factor:new Uniform1f(e),u_spin_weights:new Uniform3f(e),u_perspective_transform:new Uniform2f(e)}),symbolIcon:e=>({u_is_size_zoom_constant:new Uniform1i(e),u_is_size_feature_constant:new Uniform1i(e),u_size_t:new Uniform1f(e),u_size:new Uniform1f(e),u_camera_to_center_distance:new Uniform1f(e),u_rotate_symbol:new Uniform1i(e),u_aspect_ratio:new Uniform1f(e),u_fade_change:new Uniform1f(e),u_matrix:new UniformMatrix4f(e),u_label_plane_matrix:new UniformMatrix4f(e),u_coord_matrix:new UniformMatrix4f(e),u_is_text:new Uniform1i(e),u_pitch_with_map:new Uniform1i(e),u_texsize:new Uniform2f(e),u_tile_id:new Uniform3f(e),u_zoom_transition:new Uniform1f(e),u_inv_rot_matrix:new UniformMatrix4f(e),u_merc_center:new Uniform2f(e),u_camera_forward:new Uniform3f(e),u_tile_matrix:new UniformMatrix4f(e),u_up_vector:new Uniform3f(e),u_ecef_origin:new Uniform3f(e),u_texture:new Uniform1i(e)}),symbolSDF:e=>({u_is_size_zoom_constant:new Uniform1i(e),u_is_size_feature_constant:new Uniform1i(e),u_size_t:new Uniform1f(e),u_size:new Uniform1f(e),u_camera_to_center_distance:new Uniform1f(e),u_rotate_symbol:new Uniform1i(e),u_aspect_ratio:new Uniform1f(e),u_fade_change:new Uniform1f(e),u_matrix:new UniformMatrix4f(e),u_label_plane_matrix:new UniformMatrix4f(e),u_coord_matrix:new UniformMatrix4f(e),u_is_text:new Uniform1i(e),u_pitch_with_map:new Uniform1i(e),u_texsize:new Uniform2f(e),u_texture:new Uniform1i(e),u_gamma_scale:new Uniform1f(e),u_device_pixel_ratio:new Uniform1f(e),u_tile_id:new Uniform3f(e),u_zoom_transition:new Uniform1f(e),u_inv_rot_matrix:new UniformMatrix4f(e),u_merc_center:new Uniform2f(e),u_camera_forward:new Uniform3f(e),u_tile_matrix:new UniformMatrix4f(e),u_up_vector:new Uniform3f(e),u_ecef_origin:new Uniform3f(e),u_is_halo:new Uniform1i(e)}),symbolTextAndIcon:e=>({u_is_size_zoom_constant:new Uniform1i(e),u_is_size_feature_constant:new Uniform1i(e),u_size_t:new Uniform1f(e),u_size:new Uniform1f(e),u_camera_to_center_distance:new Uniform1f(e),u_rotate_symbol:new Uniform1i(e),u_aspect_ratio:new Uniform1f(e),u_fade_change:new Uniform1f(e),u_matrix:new UniformMatrix4f(e),u_label_plane_matrix:new UniformMatrix4f(e),u_coord_matrix:new UniformMatrix4f(e),u_is_text:new Uniform1i(e),u_pitch_with_map:new Uniform1i(e),u_texsize:new Uniform2f(e),u_texsize_icon:new Uniform2f(e),u_texture:new Uniform1i(e),u_texture_icon:new Uniform1i(e),u_gamma_scale:new Uniform1f(e),u_device_pixel_ratio:new Uniform1f(e),u_is_halo:new Uniform1i(e)}),background:e=>({u_matrix:new UniformMatrix4f(e),u_opacity:new Uniform1f(e),u_color:new UniformColor(e)}),backgroundPattern:e=>({u_matrix:new UniformMatrix4f(e),u_opacity:new Uniform1f(e),u_image:new Uniform1i(e),u_pattern_tl_a:new Uniform2f(e),u_pattern_br_a:new Uniform2f(e),u_pattern_tl_b:new Uniform2f(e),u_pattern_br_b:new Uniform2f(e),u_texsize:new Uniform2f(e),u_mix:new Uniform1f(e),u_pattern_size_a:new Uniform2f(e),u_pattern_size_b:new Uniform2f(e),u_scale_a:new Uniform1f(e),u_scale_b:new Uniform1f(e),u_pixel_coord_upper:new Uniform2f(e),u_pixel_coord_lower:new Uniform2f(e),u_tile_units_to_pixels:new Uniform1f(e)}),terrainRaster:gd,terrainDepth:gd,skybox:e=>({u_matrix:new UniformMatrix4f(e),u_sun_direction:new Uniform3f(e),u_cubemap:new Uniform1i(e),u_opacity:new Uniform1f(e),u_temporal_offset:new Uniform1f(e)}),skyboxGradient:e=>({u_matrix:new UniformMatrix4f(e),u_color_ramp:new Uniform1i(e),u_center_direction:new Uniform3f(e),u_radius:new Uniform1f(e),u_opacity:new Uniform1f(e),u_temporal_offset:new Uniform1f(e)}),skyboxCapture:e=>({u_matrix_3f:new UniformMatrix3f(e),u_sun_direction:new Uniform3f(e),u_sun_intensity:new Uniform1f(e),u_color_tint_r:new Uniform4f(e),u_color_tint_m:new Uniform4f(e),u_luminance:new Uniform1f(e)}),globeRaster:e=>({u_proj_matrix:new UniformMatrix4f(e),u_globe_matrix:new UniformMatrix4f(e),u_normalize_matrix:new UniformMatrix4f(e),u_merc_matrix:new UniformMatrix4f(e),u_zoom_transition:new Uniform1f(e),u_merc_center:new Uniform2f(e),u_image0:new Uniform1i(e),u_grid_matrix:new UniformMatrix3f(e),u_frustum_tl:new Uniform3f(e),u_frustum_tr:new Uniform3f(e),u_frustum_br:new Uniform3f(e),u_frustum_bl:new Uniform3f(e),u_globe_pos:new Uniform3f(e),u_globe_radius:new Uniform1f(e),u_viewport:new Uniform2f(e)}),globeAtmosphere:e=>({u_frustum_tl:new Uniform3f(e),u_frustum_tr:new Uniform3f(e),u_frustum_br:new Uniform3f(e),u_frustum_bl:new Uniform3f(e),u_horizon:new Uniform1f(e),u_transition:new Uniform1f(e),u_fadeout_range:new Uniform1f(e),u_color:new Uniform4f(e),u_high_color:new Uniform4f(e),u_space_color:new Uniform4f(e),u_star_intensity:new Uniform1f(e),u_star_density:new Uniform1f(e),u_star_size:new Uniform1f(e),u_temporal_offset:new Uniform1f(e),u_horizon_angle:new Uniform1f(e),u_rotation_matrix:new UniformMatrix4f(e)})};let tf;function rf(e,t,i,r,n,o,a){const s=e.context,l=s.gl,c=e.transform,u=e.useProgram("collisionBox"),h=[];let p=0,d=0;for(let f=0;f<r.length;f++){const m=r[f],_=t.getTile(m),g=_.getBucket(i);if(!g)continue;const y=Lp(m,g,c);let x=y;0===n[0]&&0===n[1]||(x=e.translatePosMatrix(y,_,n,o));const v=a?g.textCollisionBox:g.iconCollisionBox,b=g.collisionCircleArray;if(b.length>0){const e=ga(),t=x;Da(e,g.placementInvProjMatrix,c.glCoordMatrix),Da(e,e,g.placementViewportMatrix),h.push({circleArray:b,circleOffset:d,transform:t,invTransform:e,projection:g.getProjection()}),p+=b.length/4,d=p}v&&(e.terrain&&e.terrain.setupElevationDraw(_,u),u.draw(s,l.LINES,DepthMode.disabled,StencilMode.disabled,e.colorModeForRenderPass(),CullFaceMode.disabled,Fd(x,c,_,g.getProjection()),i.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,null,c.zoom,null,[v.collisionVertexBuffer,v.collisionVertexBufferExt]))}if(!a||!h.length)return;const f=e.useProgram("collisionCircle"),m=new StructArrayLayout2f1f2i16;m.resize(4*p),m._trim();let _=0;for(const e of h)for(let t=0;t<e.circleArray.length/4;t++){const i=4*t,r=e.circleArray[i+0],n=e.circleArray[i+1],o=e.circleArray[i+2],a=e.circleArray[i+3];m.emplace(_++,r,n,o,a,0),m.emplace(_++,r,n,o,a,1),m.emplace(_++,r,n,o,a,2),m.emplace(_++,r,n,o,a,3)}(!tf||tf.length<2*p)&&(tf=function(e){const t=2*e,i=new StructArrayLayout3ui6;i.resize(t),i._trim();for(let e=0;e<t;e++){const t=6*e;i.uint16[t+0]=4*e+0,i.uint16[t+1]=4*e+1,i.uint16[t+2]=4*e+2,i.uint16[t+3]=4*e+2,i.uint16[t+4]=4*e+3,i.uint16[t+5]=4*e+0}return i}(p));const g=s.createIndexBuffer(tf,!0),y=s.createVertexBuffer(m,tc.members,!0);for(const t of h){const r={u_matrix:t.transform,u_inv_matrix:t.invTransform,u_camera_to_center_distance:(x=c).getCameraToCenterDistance(t.projection),u_viewport_size:[x.width,x.height]};f.draw(s,l.TRIANGLES,DepthMode.disabled,StencilMode.disabled,e.colorModeForRenderPass(),CullFaceMode.disabled,r,i.id,y,g,SegmentVector.simpleSegment(0,2*t.circleOffset,t.circleArray.length,t.circleArray.length/2),null,c.zoom)}var x;y.destroy(),g.destroy()}const nf=ga();function of(e,t,i,n,o,a){const{horizontalAlign:s,verticalAlign:l}=Rc(e),c=-(s-.5)*t,u=-(l-.5)*i,h=Nc(e,n);return new r((c/o+h[0])*a,(u/o+h[1])*a)}function af(e,t,i,n,o,a,s,l,c,u,h){const p=e.text.placedSymbolArray,d=e.text.dynamicLayoutVertexArray,f=e.icon.dynamicLayoutVertexArray,m={},_=Bp(l,e.getProjection(),a),g=a.elevation,y=e.getProjection().upVectorScale(l.canonical,a.center.lat,a.worldSize);d.clear();for(let f=0;f<p.length;f++){const x=p.get(f),v=e.allowVerticalPlacement&&!x.placedOrientation,b=x.hidden||!x.crossTileID||v?null:n[x.crossTileID];if(b){const n=new r(x.tileAnchorX,x.tileAnchorY),p=e.getProjection().upVector(l.canonical,n.x,n.y),f=g?g.getAtTileOffset(l,n.x,n.y):0,v=xp([x.projectedAnchorX+f*p[0]*y.metersToTile,x.projectedAnchorY+f*p[1]*y.metersToTile,x.projectedAnchorZ+f*p[2]*y.metersToTile],i?_:s),w=vp(a.getCameraToCenterDistance(e.getProjection()),v.signedDistanceFromCamera);let T=o.evaluateSizeForFeature(e.textSizeData,u,x)*w/24;i&&(T*=e.tilePixelRatio/c);const{width:E,height:S,anchor:A,textOffset:C,textScale:I}=b,M=of(A,E,S,C,I,T);let P;if(i){const t=n.add(M),{x:i,y:r,z:o}=e.getProjection().projectTilePoint(t.x,t.y,l.canonical);P=xp([i+f*p[0]*y.metersToTile,r+f*p[1]*y.metersToTile,o+f*p[2]*y.metersToTile],s).point}else{const e=t?M.rotate(-a.angle):M;P=[v.point[0]+e.x,v.point[1]+e.y,0]}const D=e.allowVerticalPlacement&&x.placedOrientation===Bc.vertical?Math.PI/2:0;for(let e=0;e<x.numGlyphs;e++)Hu(d,P[0],P[1],P[2],D);h&&x.associatedIconIndex>=0&&(m[x.associatedIconIndex]={shiftedAnchor:P,angle:D})}else Pp(x.numGlyphs,d)}if(h){f.clear();const t=e.icon.placedSymbolArray;for(let e=0;e<t.length;e++){const i=t.get(e);if(i.hidden)Pp(i.numGlyphs,f);else{const t=m[e];if(t)for(let e=0;e<i.numGlyphs;e++)Hu(f,t.shiftedAnchor[0],t.shiftedAnchor[1],t.shiftedAnchor[2],t.angle);else Pp(i.numGlyphs,f)}}e.icon.dynamicLayoutVertexBuffer.updateData(f)}e.text.dynamicLayoutVertexBuffer.updateData(d)}function sf(e,t,i){return i.iconsInText&&t?"symbolTextAndIcon":e?"symbolSDF":"symbolIcon"}function lf(e,t,i,r,n,o,a,s,l,c,u,h){const p=e.context,d=p.gl,f=e.transform,m="map"===s,_="map"===l,g=m&&"point"!==i.layout.get("symbol-placement"),y=m&&!_&&!g,x=void 0!==i.layout.get("symbol-sort-key").constantOr(1);let v=!1;const b=e.depthModeForSublayer(0,DepthMode.ReadOnly),w=[Io(f.center.lng),Mo(f.center.lat)],T=i.layout.get("text-variable-anchor"),E="globe"===f.projection.name,S=[],A=[0,-1,0];let C=A;!E&&!f.mercatorFromTransition||m||(C=function(e){const t=va([],e._camera.getWorldToCamera(e.worldSize,1),e.globeMatrix);xa(t,t);const i=[0,0,0],r=[0,1,0,0];return is(r,r,t),i[0]=r[0],i[1]=r[1],i[2]=r[2],Za(i,i),i}(f));for(const s of r){const r=t.getTile(s),l=r.getBucket(i);if(!l)continue;if("mercator"===l.projection.name&&E)continue;const u=n?l.text:l.icon;if(!u||l.fullyClipped||!u.segments.get().length)continue;const h=u.programConfigurations.get(i.id),p=n||l.sdfIcons,b=n?l.textSizeData:l.iconSizeData,I=_||0!==f.pitch,M=oc(b,f.zoom);let P,D,z,k,L=[0,0],B=null;if(n){if(D=r.glyphAtlasTexture,z=d.LINEAR,P=r.glyphAtlasTexture.size,l.iconsInText){L=r.imageAtlasTexture.size,B=r.imageAtlasTexture;const t="composite"===b.kind||"camera"===b.kind;k=I||e.options.rotating||e.options.zooming||t?d.LINEAR:d.NEAREST}}else{const t=1!==i.layout.get("icon-size").constantOr(0)||l.iconsNeedLinear;D=r.imageAtlasTexture,z=p||e.options.rotating||e.options.zooming||t||I?d.LINEAR:d.NEAREST,P=r.imageAtlasTexture.size}const R="globe"===l.projection.name,F=R?C:A,O=R?_u(f.zoom):0,V=Bp(s,l.getProjection(),f),U=f.calculatePixelsToTileUnitsMatrix(r),j=mp(V,r.tileID.canonical,_,m,f,l.getProjection(),U),N=e.terrain&&_&&g?xa(ga(),j):nf,G=gp(V,r.tileID.canonical,_,m,f,l.getProjection(),U),Z=T&&l.hasTextData(),q="none"!==i.layout.get("icon-text-fit")&&Z&&l.hasIconData();if(g){const t=f.elevation,i=t?t.getAtTileOffsetFunc(s,f.center.lat,f.worldSize,l.getProjection()):e=>[0,0,0],o=_p(V,r.tileID.canonical,_,m,f,l.getProjection(),U);wp(l,V,e,n,o,G,_,c,i,s)}const $=g||n&&T||q,W=e.translatePosMatrix(V,r,o,a),H=$?nf:j,X=e.translatePosMatrix(G,r,o,a,!0),K=l.getProjection().createInversionMatrix(f,s.canonical),J=[];e.terrain&&_&&J.push("PITCH_WITH_MAP_TERRAIN"),R&&J.push("PROJECTION_GLOBE_VIEW"),$&&J.push("PROJECTED_POS_ON_VIEWPORT");const Y=p&&0!==i.paint.get(n?"text-halo-width":"icon-halo-width").constantOr(1);let Q;Q=p?l.iconsInText?Jd(b.kind,M,y,_,e,W,H,X,P,L,s,O,w,K,F,l.getProjection()):Kd(b.kind,M,y,_,e,W,H,X,n,P,!0,s,O,w,K,F,l.getProjection()):Xd(b.kind,M,y,_,e,W,H,X,n,P,s,O,w,K,F,l.getProjection());const ee={program:e.useProgram(sf(p,n,l),h,J),buffers:u,uniformValues:Q,atlasTexture:D,atlasTextureIcon:B,atlasInterpolation:z,atlasInterpolationIcon:k,isSDF:p,hasHalo:Y,tile:r,labelPlaneMatrixInv:N};if(x&&l.canOverlap){v=!0;const e=u.segments.get();for(const t of e)S.push({segments:new SegmentVector([t]),sortKey:t.sortKey,state:ee})}else S.push({segments:u.segments,sortKey:0,state:ee})}v&&S.sort(((e,t)=>e.sortKey-t.sortKey));for(const t of S){const r=t.state;if(e.terrain&&e.terrain.setupElevationDraw(r.tile,r.program,{useDepthForOcclusion:!E,labelPlaneMatrixInv:r.labelPlaneMatrixInv}),p.activeTexture.set(d.TEXTURE0),r.atlasTexture.bind(r.atlasInterpolation,d.CLAMP_TO_EDGE),r.atlasTextureIcon&&(p.activeTexture.set(d.TEXTURE1),r.atlasTextureIcon&&r.atlasTextureIcon.bind(r.atlasInterpolationIcon,d.CLAMP_TO_EDGE)),r.isSDF){const n=r.uniformValues;r.hasHalo&&(n.u_is_halo=1,cf(r.buffers,t.segments,i,e,r.program,b,u,h,n)),n.u_is_halo=0}cf(r.buffers,t.segments,i,e,r.program,b,u,h,r.uniformValues)}}function cf(e,t,i,r,n,o,a,s,l){const c=r.context,u=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.globeExtVertexBuffer];n.draw(c,c.gl.TRIANGLES,o,a,s,CullFaceMode.disabled,l,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,r.transform.zoom,e.programConfigurations.get(i.id),u)}function uf(e,t,i,r,n,o,a){const s=e.context.gl,l=i.paint.get("fill-pattern"),c=l&&l.constantOr(1),u=i.getCrossfadeParameters();let h,p,d,f,m;a?(p=c&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",h=s.LINES):(p=c?"fillPattern":"fill",h=s.TRIANGLES);for(const _ of r){const r=t.getTile(_);if(c&&!r.patternsLoaded())continue;const g=r.getBucket(i);if(!g)continue;e.prepareDrawTile();const y=g.programConfigurations.get(i.id),x=e.useProgram(p,y);c&&(e.context.activeTexture.set(s.TEXTURE0),r.imageAtlasTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE),y.updatePaintBuffers(u));const v=l.constantOr(null);if(v&&r.imageAtlas){const e=r.imageAtlas,t=e.patternPositions[v.to.toString()],i=e.patternPositions[v.from.toString()];t&&i&&y.setConstantPatternPositions(t,i)}const b=e.translatePosMatrix(_.projMatrix,r,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor"));if(a){f=g.indexBuffer2,m=g.segments2;const t=e.terrain&&e.terrain.renderingToTexture?e.terrain.drapeBufferSize:[s.drawingBufferWidth,s.drawingBufferHeight];d="fillOutlinePattern"===p&&c?kd(b,e,u,r,t):zd(b,t)}else f=g.indexBuffer,m=g.segments,d=c?Dd(b,e,u,r):Pd(b);e.prepareDrawProgram(e.context,x,_.toUnwrapped()),x.draw(e.context,h,n,e.stencilModeForClipping(_),o,CullFaceMode.disabled,d,i.id,g.layoutVertexBuffer,f,m,i.paint,e.transform.zoom,y)}}function hf(e,t,i,r,n,o,a){const s=e.context,l=s.gl,c=e.transform,u=i.paint.get("fill-extrusion-pattern"),h=u.constantOr(1),p=i.getCrossfadeParameters(),d=i.paint.get("fill-extrusion-opacity"),f=[i.paint.get("fill-extrusion-ambient-occlusion-intensity"),i.paint.get("fill-extrusion-ambient-occlusion-radius")],m=i.layout.get("fill-extrusion-edge-radius"),_="globe"===c.projection.name?Ml():0,g="globe"===c.projection.name,y=g?_u(c.zoom):0,x=[Io(c.center.lng),Mo(c.center.lat)],v=[];g&&(v.push("PROJECTION_GLOBE_VIEW"),e.style.terrainSetForDrapingOnly()&&v.push("TERRAIN")),f[0]>0&&v.push("FAUX_AO");for(const b of r){const r=t.getTile(b),w=r.getBucket(i);if(!w||w.projection.name!==c.projection.name)continue;const T=w.programConfigurations.get(i.id),E=e.useProgram(h?"fillExtrusionPattern":"fillExtrusion",T,v);if(e.terrain){const n=e.terrain;if(e.style.terrainSetForDrapingOnly())n.setupElevationDraw(r,E,{useMeterToDem:!0});else{if(!w.enableTerrain)continue;if(n.setupElevationDraw(r,E,{useMeterToDem:!0}),pf(s,t,b,w,i,n),!w.centroidVertexBuffer){const e=E.attributes.a_centroid_pos;void 0!==e&&l.vertexAttrib2f(e,0,0)}}}h&&(e.context.activeTexture.set(l.TEXTURE0),r.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),T.updatePaintBuffers(p));const S=u.constantOr(null);if(S&&r.imageAtlas){const e=r.imageAtlas,t=e.patternPositions[S.to.toString()],i=e.patternPositions[S.from.toString()];t&&i&&T.setConstantPatternPositions(t,i)}const A=e.translatePosMatrix(b.projMatrix,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),C=c.projection.createInversionMatrix(c,b.canonical),I=i.paint.get("fill-extrusion-vertical-gradient"),M=h?Md(A,e,I,d,f,m,b,p,r,_,y,x,C):Id(A,e,I,d,f,m,b,_,y,x,C);e.prepareDrawProgram(s,E,b.toUnwrapped());const P=[];e.terrain&&P.push(w.centroidVertexBuffer),g&&P.push(w.layoutVertexExtBuffer),E.draw(s,s.gl.TRIANGLES,n,o,a,CullFaceMode.backCCW,M,i.id,w.layoutVertexBuffer,w.indexBuffer,w.segments,i.paint,e.transform.zoom,T,P)}}function pf(e,t,i,n,o,a){const s=[e=>{let t=e.canonical.x-1,i=e.wrap;return t<0&&(t=(1<<e.canonical.z)-1,i--),new OverscaledTileID(e.overscaledZ,i,e.canonical.z,t,e.canonical.y)},e=>{let t=e.canonical.x+1,i=e.wrap;return t===1<<e.canonical.z&&(t=0,i++),new OverscaledTileID(e.overscaledZ,i,e.canonical.z,t,e.canonical.y)},e=>new OverscaledTileID(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<<e.canonical.z:e.canonical.y)-1),e=>new OverscaledTileID(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<<e.canonical.z)-1?0:e.canonical.y+1)],l=e=>{const i=t.getSource().minzoom,r=e=>{const i=t.getTileByID(e);if(i&&i.hasData())return i.getBucket(o)},n=[0,-1,1];for(const t of n){if(e.overscaledZ+t<i)continue;const n=r(e.calculateScaledKey(e.overscaledZ+t));if(n)return n}},c=[0,0,0],u=(e,t)=>(c[0]=Math.min(e.min.y,t.min.y),c[1]=Math.max(e.max.y,t.max.y),c[2]=Eo-t.min.x>e.max.x?t.min.x-Eo:e.max.x,c),h=(e,t)=>(c[0]=Math.min(e.min.x,t.min.x),c[1]=Math.max(e.max.x,t.max.x),c[2]=Eo-t.min.y>e.max.y?t.min.y-Eo:e.max.y,c),p=[(e,t)=>u(e,t),(e,t)=>u(t,e),(e,t)=>h(e,t),(e,t)=>h(t,e)],d=new r(0,0);let f,m,_;const g=(e,t,r,n,o)=>{const s=[[n?r:e,n?e:r,0],[n?r:t,n?t:r,0]],l=o<0?Eo+o:o,c=[n?l:(e+t)/2,n?(e+t)/2:l,0];return 0===r&&o<0||0!==r&&o>0?a.getForTilePoints(_,[c],!0,m):s.push(c),a.getForTilePoints(i,s,!0,f),Math.max(s[0][2],s[1][2],c[2])/a.exaggeration()};for(let e=0;e<4;e++){const t=(e<2?1:5)-e,r=n.borders[e];if(0===r.length)continue;const o=_=s[e](i),c=l(o);if(!(c&&c instanceof FillExtrusionBucket&&c.enableTerrain))continue;if(n.borderDoneWithNeighborZ[e]===c.canonical.z&&c.borderDoneWithNeighborZ[t]===n.canonical.z)continue;if(m=a.findDEMTileFor(o),!m||!m.dem)continue;if(!f){const e=a.findDEMTileFor(i);if(!e||!e.dem)return;f=e}const u=c.borders[t];let h=0;const y=c.borderDoneWithNeighborZ[t]!==n.canonical.z;if(n.canonical.z===c.canonical.z){for(let i=0;i<r.length;i++){const o=n.featuresOnBorder[r[i]],a=o.borders[e];let s;for(;h<u.length&&(s=c.featuresOnBorder[u[h]],!(s.borders[t][1]>a[0]+3));)y&&c.encodeCentroid(void 0,s,!1),h++;if(s&&h<u.length){const i=h;let r=0;for(;!(s.borders[t][0]>a[1]-3)&&(r++,++h!==u.length);)s=c.featuresOnBorder[u[h]];if(s=c.featuresOnBorder[u[i]],o.intersectsCount()>1||s.intersectsCount()>1||1!==r){1!==r&&(h=i),n.encodeCentroid(void 0,o,!1),y&&c.encodeCentroid(void 0,s,!1);continue}const l=p[e](o,s),f=e%2?8191:0;d.x=g(l[0],Math.min(8191,l[1]),f,e<2,l[2]),d.y=0,n.encodeCentroid(d,o,!1),y&&c.encodeCentroid(d,s,!1)}else n.encodeCentroid(void 0,o,!1)}n.borderDoneWithNeighborZ[e]=c.canonical.z,n.needsCentroidUpdate=!0,y&&(c.borderDoneWithNeighborZ[t]=n.canonical.z,c.needsCentroidUpdate=!0)}else{for(const e of r)n.encodeCentroid(void 0,n.featuresOnBorder[e],!1);if(y){for(const e of u)c.encodeCentroid(void 0,c.featuresOnBorder[e],!1);c.borderDoneWithNeighborZ[t]=n.canonical.z,c.needsCentroidUpdate=!0}n.borderDoneWithNeighborZ[e]=c.canonical.z,n.needsCentroidUpdate=!0}}(n.needsCentroidUpdate||!n.centroidVertexBuffer&&0!==n.centroidVertexArray.length)&&n.uploadCentroid(e)}const df=new Lt(1,0,0,1),ff=new Lt(0,1,0,1),mf=new Lt(0,0,1,1),_f=new Lt(1,0,1,1),gf=new Lt(0,1,1,1);function yf(e,t,i){const r=e.context,n=e.transform,o=r.gl,a="globe"===n.projection.name,s=a?["PROJECTION_GLOBE_VIEW"]:null;let l=i.projMatrix;if(a&&_u(n.zoom)>0){const e=du(iu(i.canonical,n));l=va(new Float32Array(16),n.globeMatrix,e),va(l,n.projMatrix,l)}const c=e.useProgram("debug",null,s),u=t.getTileByID(i.key);e.terrain&&e.terrain.setupElevationDraw(u,c);const h=DepthMode.disabled,p=StencilMode.disabled,d=e.colorModeForRenderPass(),f="$debug";r.activeTexture.set(o.TEXTURE0),e.emptyTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE),a?u._makeGlobeTileDebugBuffers(e.context,n):u._makeDebugTileBoundsBuffers(e.context,n.projection);const m=u._tileDebugBuffer||e.debugBuffer,_=u._tileDebugIndexBuffer||e.debugIndexBuffer,g=u._tileDebugSegments||e.debugSegments;c.draw(r,o.LINE_STRIP,h,p,d,CullFaceMode.disabled,Od(l,Lt.red),f,m,_,g,null,null,null,[u._globeTileDebugBorderBuffer]);const y=u.latestRawTileData,x=Math.floor((y&&y.byteLength||0)/1024),v=t.getTile(i).tileSize,b=512/Math.min(v,512)*(i.overscaledZ/n.zoom)*.5;let w=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(w+=` => ${i.overscaledZ}`),w+=` ${x}kb`,function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,r=e.context.gl,n=e.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,i.width,i.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(t,5,5),n.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(e,w);const T=u._tileDebugTextBuffer||e.debugBuffer,E=u._tileDebugTextIndexBuffer||e.quadTriangleIndexBuffer,S=u._tileDebugTextSegments||e.debugSegments;c.draw(r,o.TRIANGLES,h,p,ColorMode.alphaBlended,CullFaceMode.disabled,Od(l,Lt.transparent,b),f,T,E,S,null,null,null,[u._globeTileDebugTextBuffer])}function xf(e,t,i,r){bf(e,0,t+i/2,e.transform.width,i,r)}function vf(e,t,i,r){bf(e,t-i/2,0,i,e.transform.height,r)}function bf(e,t,i,r,n,o){const a=e.context,s=a.gl;s.enable(s.SCISSOR_TEST),s.scissor(t*ee.devicePixelRatio,i*ee.devicePixelRatio,r*ee.devicePixelRatio,n*ee.devicePixelRatio),a.clear({color:o}),s.disable(s.SCISSOR_TEST)}const wf=eo([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Tf}=wf;function Ef(e,t,i,r){e.emplaceBack(t,i,r)}class SkyboxGeometry{constructor(e){this.vertexArray=new StructArrayLayout3f12,this.indices=new StructArrayLayout3ui6,Ef(this.vertexArray,-1,-1,1),Ef(this.vertexArray,1,-1,1),Ef(this.vertexArray,-1,1,1),Ef(this.vertexArray,1,1,1),Ef(this.vertexArray,-1,-1,-1),Ef(this.vertexArray,1,-1,-1),Ef(this.vertexArray,-1,1,-1),Ef(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=e.createVertexBuffer(this.vertexArray,Tf),this.indexBuffer=e.createIndexBuffer(this.indices),this.segment=SegmentVector.simpleSegment(0,0,36,12)}}function Sf(e,t,i,r,n,o){const a=e.gl,s=t.paint.get("sky-atmosphere-color"),l=t.paint.get("sky-atmosphere-halo-color"),c=t.paint.get("sky-atmosphere-sun-intensity"),u=((e,t,i,r,n)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:i,u_color_tint_r:[r.r,r.g,r.b,r.a],u_color_tint_m:[n.r,n.g,n.b,n.a],u_luminance:5e-5}))(((h=fa())[0]=(p=r)[0],h[1]=p[1],h[2]=p[2],h[3]=p[4],h[4]=p[5],h[5]=p[6],h[6]=p[8],h[7]=p[9],h[8]=p[10],h),n,c,s,l);var h,p;a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+o,t.skyboxTexture,0),i.draw(e,a.TRIANGLES,DepthMode.disabled,StencilMode.disabled,ColorMode.unblended,CullFaceMode.frontCW,u,"skyboxCapture",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}const Af=eo([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class AtmosphereBuffer{constructor(e){const t=new StructArrayLayout5f20;t.emplaceBack(-1,1,1,0,0),t.emplaceBack(1,1,1,1,0),t.emplaceBack(1,-1,1,1,1),t.emplaceBack(-1,-1,1,0,1);const i=new StructArrayLayout3ui6;i.emplaceBack(0,1,2),i.emplaceBack(2,3,0),this.vertexBuffer=e.createVertexBuffer(t,Af.members),this.indexBuffer=e.createIndexBuffer(i),this.segments=SegmentVector.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const Cf={symbol:function(e,t,i,r,n){if("translucent"!==e.renderPass)return;const o=StencilMode.disabled,a=e.colorModeForRenderPass();i.layout.get("text-variable-anchor")&&function(e,t,i,r,n,o,a){const s=t.transform,l="map"===n,c="map"===o;for(const t of e){const e=r.getTile(t),n=e.getBucket(i);if(!n||!n.text||!n.text.segments.get().length)continue;const o=oc(n.textSizeData,s.zoom),u=Bp(t,n.getProjection(),s),h=s.calculatePixelsToTileUnitsMatrix(e),p=mp(u,e.tileID.canonical,c,l,s,n.getProjection(),h),d="none"!==i.layout.get("icon-text-fit")&&n.hasIconData();if(o){const i=Math.pow(2,s.zoom-e.tileID.overscaledZ);af(n,l,c,a,ac,s,p,t,i,o,d)}}}(r,e,i,t,i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),n),0!==i.paint.get("icon-opacity").constantOr(1)&&lf(e,t,i,r,!1,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),i.layout.get("icon-rotation-alignment"),i.layout.get("icon-pitch-alignment"),i.layout.get("icon-keep-upright"),o,a),0!==i.paint.get("text-opacity").constantOr(1)&&lf(e,t,i,r,!0,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),i.layout.get("text-keep-upright"),o,a),t.map.showCollisionBoxes&&(rf(e,t,i,r,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),!0),rf(e,t,i,r,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),!1))},circle:function(e,t,i,r){if("translucent"!==e.renderPass)return;const n=i.paint.get("circle-opacity"),o=i.paint.get("circle-stroke-width"),a=i.paint.get("circle-stroke-opacity"),s=void 0!==i.layout.get("circle-sort-key").constantOr(1);if(0===n.constantOr(1)&&(0===o.constantOr(1)||0===a.constantOr(1)))return;const l=e.context,c=l.gl,u=e.transform,h=e.depthModeForSublayer(0,DepthMode.ReadOnly),p=StencilMode.disabled,d=e.colorModeForRenderPass(),f="globe"===u.projection.name,m=[Io(u.center.lng),Mo(u.center.lat)],_=[];for(let n=0;n<r.length;n++){const o=r[n],a=t.getTile(o),l=a.getBucket(i);if(!l||l.projection.name!==u.projection.name)continue;const c=l.programConfigurations.get(i.id),h=Rd(i);f&&h.push("PROJECTION_GLOBE_VIEW");const p=e.useProgram("circle",c,h),d=l.layoutVertexBuffer,g=l.globeExtVertexBuffer,y=l.indexBuffer,x=u.projection.createInversionMatrix(u,o.canonical),v={programConfiguration:c,program:p,layoutVertexBuffer:d,globeExtVertexBuffer:g,indexBuffer:y,uniformValues:Bd(e,o,a,x,m,i),tile:a};if(s){const e=l.segments.get();for(const t of e)_.push({segments:new SegmentVector([t]),sortKey:t.sortKey,state:v})}else _.push({segments:l.segments,sortKey:0,state:v})}s&&_.sort(((e,t)=>e.sortKey-t.sortKey));const g={useDepthForOcclusion:!f};for(const t of _){const{programConfiguration:r,program:n,layoutVertexBuffer:o,globeExtVertexBuffer:a,indexBuffer:s,uniformValues:f,tile:m}=t.state,_=t.segments;e.terrain&&e.terrain.setupElevationDraw(m,n,g),e.prepareDrawProgram(l,n,m.tileID.toUnwrapped()),n.draw(l,c.TRIANGLES,h,p,d,CullFaceMode.disabled,f,i.id,o,s,_,i.paint,u.zoom,r,[a])}},heatmap:function(e,t,i,r){if(0!==i.paint.get("heatmap-opacity"))if("offscreen"===e.renderPass){const n=e.context,o=n.gl,a=StencilMode.disabled,s=new ColorMode([o.ONE,o.ONE],Lt.transparent,[!0,!0,!0,!0]);!function(e,t,i,r){const n=e.gl,o=t.width*r,a=t.height*r;e.activeTexture.set(n.TEXTURE1),e.viewport.set([0,0,o,a]);let s=i.heatmapFbo;if(!s||s&&(s.width!==o||s.height!==a)){s&&s.destroy();const t=n.createTexture();n.bindTexture(n.TEXTURE_2D,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),s=i.heatmapFbo=e.createFramebuffer(o,a,!1),function(e,t,i,r,n,o){const a=e.gl;a.texImage2D(a.TEXTURE_2D,0,a.RGBA,n,o,0,a.RGBA,e.extRenderToTextureHalfFloat?e.extTextureHalfFloat.HALF_FLOAT_OES:a.UNSIGNED_BYTE,null),r.colorAttachment.set(i)}(e,0,t,s,o,a)}else n.bindTexture(n.TEXTURE_2D,s.colorAttachment.get()),e.bindFramebuffer.set(s.framebuffer)}(n,e,i,"globe"===e.transform.projection.name?.5:.25),n.clear({color:Lt.transparent});const l=e.transform,c="globe"===l.projection.name,u=c?["PROJECTION_GLOBE_VIEW"]:null,h=c?CullFaceMode.frontCCW:CullFaceMode.disabled,p=[Io(l.center.lng),Mo(l.center.lat)];for(let d=0;d<r.length;d++){const f=r[d];if(t.hasRenderableParent(f))continue;const m=t.getTile(f),_=m.getBucket(i);if(!_||_.projection.name!==l.projection.name)continue;const g=_.programConfigurations.get(i.id),y=e.useProgram("heatmap",g,u),{zoom:x}=e.transform;e.terrain&&e.terrain.setupElevationDraw(m,y),e.prepareDrawProgram(n,y,f.toUnwrapped());const v=l.projection.createInversionMatrix(l,f.canonical);y.draw(n,o.TRIANGLES,DepthMode.disabled,a,s,h,Ud(e,f,m,v,p,x,i.paint.get("heatmap-intensity")),i.id,_.layoutVertexBuffer,_.indexBuffer,_.segments,i.paint,e.transform.zoom,g,c?[_.globeExtVertexBuffer]:null)}n.viewport.set([0,0,e.width,e.height])}else"translucent"===e.renderPass&&(e.context.setColorMode(e.colorModeForRenderPass()),function(e,t){const i=e.context,r=i.gl,n=t.heatmapFbo;if(!n)return;i.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,n.colorAttachment.get()),i.activeTexture.set(r.TEXTURE1);let o=t.colorRampTexture;o||(o=t.colorRampTexture=new Texture(i,t.colorRamp,r.RGBA)),o.bind(r.LINEAR,r.CLAMP_TO_EDGE),e.useProgram("heatmapTexture").draw(i,r.TRIANGLES,DepthMode.disabled,StencilMode.disabled,e.colorModeForRenderPass(),CullFaceMode.disabled,((e,t,i,r)=>({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,t),t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,t.paint,e.transform.zoom)}(e,i))},line:function(e,t,i,r){if("translucent"!==e.renderPass)return;const n=i.paint.get("line-opacity"),o=i.paint.get("line-width");if(0===n.constantOr(1)||0===o.constantOr(1))return;const a=e.depthModeForSublayer(0,DepthMode.ReadOnly),s=e.colorModeForRenderPass(),l=e.terrain&&e.terrain.renderingToTexture?1:ee.devicePixelRatio,c=i.paint.get("line-dasharray"),u=c.constantOr(1),h=i.layout.get("line-cap"),p=i.paint.get("line-pattern"),d=p.constantOr(1),f=i.paint.get("line-gradient"),m=i.getCrossfadeParameters(),g=d?"linePattern":"line",y=e.context,x=y.gl,v=(e=>{const t=[];qd(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");const i=e.paint.get("line-trim-offset");0===i[0]&&0===i[1]||t.push("RENDER_LINE_TRIM_OFFSET");const r=e.paint.get("line-pattern").constantOr(1),n=1!==e.paint.get("line-opacity").constantOr(1);return!r&&n&&t.push("RENDER_LINE_ALPHA_DISCARD"),t})(i);let b=v.includes("RENDER_LINE_ALPHA_DISCARD");e.terrain&&e.terrain.clipOrMaskOverlapStencilType()&&(b=!1);for(const n of r){const r=t.getTile(n);if(d&&!r.patternsLoaded())continue;const o=r.getBucket(i);if(!o)continue;e.prepareDrawTile();const w=o.programConfigurations.get(i.id),T=e.useProgram(g,w,v),E=p.constantOr(null);if(E&&r.imageAtlas){const e=r.imageAtlas,t=e.patternPositions[E.to.toString()],i=e.patternPositions[E.from.toString()];t&&i&&w.setConstantPatternPositions(t,i)}const S=c.constantOr(null),C=h.constantOr(null);if(!d&&S&&C&&r.lineAtlas){const e=r.lineAtlas,t=e.getDash(S.to,C),i=e.getDash(S.from,C);t&&i&&w.setConstantPatternPositions(t,i)}let[I,M]=i.paint.get("line-trim-offset");if("round"===C||"square"===C){const e=1;I!==M&&(0===I&&(I-=e),1===M&&(M+=e))}const P=e.terrain?n.projMatrix:null,D=d?Nd(e,r,i,m,P,l):jd(e,r,i,m,P,o.lineClipsArray.length,l,[I,M]);if(f){const r=o.gradients[i.id];let a=r.texture;if(i.gradientVersion!==r.version){let s=256;if(i.stepInterpolant){const i=t.getSource().maxzoom,r=n.canonical.z===i?Math.ceil(1<<e.transform.maxZoom-n.canonical.z):1;s=_(A(o.maxLineLength/Eo*1024*r),256,y.maxTextureSize)}r.gradient=gs({expression:i.gradientExpression(),evaluationKey:"lineProgress",resolution:s,image:r.gradient||void 0,clips:o.lineClipsArray}),r.texture?r.texture.update(r.gradient):r.texture=new Texture(y,r.gradient,x.RGBA),r.version=i.gradientVersion,a=r.texture}y.activeTexture.set(x.TEXTURE1),a.bind(i.stepInterpolant?x.NEAREST:x.LINEAR,x.CLAMP_TO_EDGE)}u&&(y.activeTexture.set(x.TEXTURE0),r.lineAtlasTexture.bind(x.LINEAR,x.REPEAT),w.updatePaintBuffers(m)),d&&(y.activeTexture.set(x.TEXTURE0),r.imageAtlasTexture.bind(x.LINEAR,x.CLAMP_TO_EDGE),w.updatePaintBuffers(m)),e.prepareDrawProgram(y,T,n.toUnwrapped());const z=t=>{T.draw(y,x.TRIANGLES,a,t,s,CullFaceMode.disabled,D,i.id,o.layoutVertexBuffer,o.indexBuffer,o.segments,i.paint,e.transform.zoom,w,[o.layoutVertexBuffer2])};if(b){const t=e.stencilModeForClipping(n).ref;0===t&&e.terrain&&y.clear({stencil:0});const i={func:x.EQUAL,mask:255};D.u_alpha_discard_threshold=.8,z(new StencilMode(i,t,255,x.KEEP,x.KEEP,x.INVERT)),D.u_alpha_discard_threshold=0,z(new StencilMode(i,t,255,x.KEEP,x.KEEP,x.KEEP))}else z(e.stencilModeForClipping(n))}b&&(e.resetStencilClippingMasks(),e.terrain&&y.clear({stencil:0}))},fill:function(e,t,i,r){const n=i.paint.get("fill-color"),o=i.paint.get("fill-opacity");if(0===o.constantOr(1))return;const a=e.colorModeForRenderPass(),s=i.paint.get("fill-pattern"),l=e.opaquePassEnabledForLayer()&&!s.constantOr(1)&&1===n.constantOr(Lt.transparent).a&&1===o.constantOr(0)?"opaque":"translucent";if(e.renderPass===l){const n=e.depthModeForSublayer(1,"opaque"===e.renderPass?DepthMode.ReadWrite:DepthMode.ReadOnly);uf(e,t,i,r,n,a,!1)}if("translucent"===e.renderPass&&i.paint.get("fill-antialias")){const n=e.depthModeForSublayer(i.getPaintProperty("fill-outline-color")?2:0,DepthMode.ReadOnly);uf(e,t,i,r,n,a,!0)}},"fill-extrusion":function(e,t,i,r){const n=i.paint.get("fill-extrusion-opacity");if(0!==n&&"translucent"===e.renderPass){const o=new DepthMode(e.context.gl.LEQUAL,DepthMode.ReadWrite,e.depthRangeFor3D);if(1!==n||i.paint.get("fill-extrusion-pattern").constantOr(1))hf(e,t,i,r,o,StencilMode.disabled,ColorMode.disabled),hf(e,t,i,r,o,e.stencilModeFor3D(),e.colorModeForRenderPass()),e.resetStencilClippingMasks();else{const n=e.colorModeForRenderPass();hf(e,t,i,r,o,StencilMode.disabled,n)}}},hillshade:function(e,t,i,r){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;const n=e.context,o=e.depthModeForSublayer(0,DepthMode.ReadOnly),a=e.colorModeForRenderPass(),s=e.terrain&&e.terrain.renderingToTexture,[l,c]="translucent"!==e.renderPass||s?[{},r]:e.stencilConfigForOverlap(r);for(const r of c){const n=t.getTile(r);if(n.needsHillshadePrepare&&"offscreen"===e.renderPass)_d(e,n,i,o,StencilMode.disabled,a);else if("translucent"===e.renderPass){const t=s&&e.terrain?e.terrain.stencilModeForRTTOverlap(r):l[r.overscaledZ];fd(e,r,n,i,o,t,a)}}n.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks()},raster:function(e,t,i,r,n,o){if("translucent"!==e.renderPass)return;if(0===i.paint.get("raster-opacity"))return;if(!r.length)return;const a=e.context,s=a.gl,l=t.getSource(),c=e.useProgram("raster"),u=e.colorModeForRenderPass(),h=e.terrain&&e.terrain.renderingToTexture,[p,d]=l instanceof ImageSource||h?[{},r]:e.stencilConfigForOverlap(r),f=d[d.length-1].overscaledZ,m=!e.options.moving;for(const r of d){const n=h?DepthMode.disabled:e.depthModeForSublayer(r.overscaledZ-f,1===i.paint.get("raster-opacity")?DepthMode.ReadWrite:DepthMode.ReadOnly,s.LESS),d=r.toUnwrapped(),_=t.getTile(r);if(h&&(!_||!_.hasData()))continue;const g=h?r.projMatrix:e.transform.calculateProjMatrix(d,m),y=e.terrain&&h?e.terrain.stencilModeForRTTOverlap(r):p[r.overscaledZ],x=o?0:i.paint.get("raster-fade-duration");_.registerFadeDuration(x);const v=t.findLoadedParent(r,0),b=Sd(_,v,t,e.transform,x);let w,T;e.terrain&&e.terrain.prepareDrawTile();const E="nearest"===i.paint.get("raster-resampling")?s.NEAREST:s.LINEAR;a.activeTexture.set(s.TEXTURE0),_.texture.bind(E,s.CLAMP_TO_EDGE),a.activeTexture.set(s.TEXTURE1),v?(v.texture.bind(E,s.CLAMP_TO_EDGE),w=Math.pow(2,v.tileID.overscaledZ-_.tileID.overscaledZ),T=[_.tileID.canonical.x*w%1,_.tileID.canonical.y*w%1]):_.texture.bind(E,s.CLAMP_TO_EDGE);const S=$d(g,T||[0,0],w||1,b,i,l instanceof ImageSource?l.perspectiveTransform:[0,0]);if(e.prepareDrawProgram(a,c,d),l instanceof ImageSource)l.boundsBuffer&&l.boundsSegments&&c.draw(a,s.TRIANGLES,n,StencilMode.disabled,u,CullFaceMode.disabled,S,i.id,l.boundsBuffer,e.quadTriangleIndexBuffer,l.boundsSegments);else{const{tileBoundsBuffer:t,tileBoundsIndexBuffer:r,tileBoundsSegments:o}=e.getTileBoundsBuffers(_);c.draw(a,s.TRIANGLES,n,y,u,CullFaceMode.disabled,S,i.id,t,r,o)}}e.resetStencilClippingMasks()},background:function(e,t,i,r){const n=i.paint.get("background-color"),o=i.paint.get("background-opacity");if(0===o)return;const a=e.context,s=a.gl,l=e.transform,c=l.tileSize,u=i.paint.get("background-pattern");if(e.isPatternMissing(u))return;const h=!u&&1===n.a&&1===o&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(e.renderPass!==h)return;const p=StencilMode.disabled,d=e.depthModeForSublayer(0,"opaque"===h?DepthMode.ReadWrite:DepthMode.ReadOnly),f=e.colorModeForRenderPass(),m=e.useProgram(u?"backgroundPattern":"background");let _,g=r;g||(_=e.getBackgroundTiles(),g=Object.values(_).map((e=>e.tileID))),u&&(a.activeTexture.set(s.TEXTURE0),e.imageManager.bind(e.context));const y=i.getCrossfadeParameters();for(const h of g){const g=h.toUnwrapped(),x=r?h.projMatrix:e.transform.calculateProjMatrix(g);e.prepareDrawTile();const v=t?t.getTile(h):_?_[h.key]:new Tile(h,c,l.zoom,e),b=u?Qd(x,o,e,u,{tileID:h,tileSize:c},y):Yd(x,o,n);e.prepareDrawProgram(a,m,g);const{tileBoundsBuffer:w,tileBoundsIndexBuffer:T,tileBoundsSegments:E}=e.getTileBoundsBuffers(v);m.draw(a,s.TRIANGLES,d,p,f,CullFaceMode.disabled,b,i.id,w,T,E)}},sky:function(e,t,i){const r=e.transform,n="mercator"===r.projection.name||"globe"===r.projection.name?1:g(7,8,r.zoom),o=i.paint.get("sky-opacity")*n;if(0===o)return;const a=e.context,s=i.paint.get("sky-type"),c=new DepthMode(a.gl.LEQUAL,DepthMode.ReadOnly,[0,1]),u=e.frameCounter/1e3%1;"atmosphere"===s?"offscreen"===e.renderPass?i.needsSkyboxCapture(e)&&(function(e,t,i,r){const n=e.context,o=n.gl;let a=t.skyboxFbo;if(!a){a=t.skyboxFbo=n.createFramebuffer(32,32,!1),t.skyboxGeometry=new SkyboxGeometry(n),t.skyboxTexture=n.gl.createTexture(),o.bindTexture(o.TEXTURE_CUBE_MAP,t.skyboxTexture),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_MAG_FILTER,o.LINEAR);for(let e=0;e<6;++e)o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,o.RGBA,32,32,0,o.RGBA,o.UNSIGNED_BYTE,null)}n.bindFramebuffer.set(a.framebuffer),n.viewport.set([0,0,32,32]);const s=t.getCenter(e,!0),l=e.useProgram("skyboxCapture"),c=new Float64Array(16);ya(c),Ea(c,c,.5*-Math.PI),Sf(n,t,l,c,s,0),ya(c),Ea(c,c,.5*Math.PI),Sf(n,t,l,c,s,1),ya(c),Ta(c,c,.5*-Math.PI),Sf(n,t,l,c,s,2),ya(c),Ta(c,c,.5*Math.PI),Sf(n,t,l,c,s,3),ya(c),Sf(n,t,l,c,s,4),ya(c),Ea(c,c,Math.PI),Sf(n,t,l,c,s,5),n.viewport.set([0,0,e.width,e.height])}(e,i),i.markSkyboxValid(e)):"sky"===e.renderPass&&function(e,t,i,r,n){const o=e.context,a=o.gl,s=e.transform,l=e.useProgram("skybox");o.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_CUBE_MAP,t.skyboxTexture);const c=((e,t,i,r,n)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:r,u_temporal_offset:n}))(s.skyboxMatrix,t.getCenter(e,!1),0,r,n);e.prepareDrawProgram(o,l),l.draw(o,a.TRIANGLES,i,StencilMode.disabled,e.colorModeForRenderPass(),CullFaceMode.backCW,c,"skybox",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}(e,i,c,o,u):"gradient"===s&&"sky"===e.renderPass&&function(e,t,i,r,n){const o=e.context,a=o.gl,s=e.transform,c=e.useProgram("skyboxGradient");t.skyboxGeometry||(t.skyboxGeometry=new SkyboxGeometry(o)),o.activeTexture.set(a.TEXTURE0);let u=t.colorRampTexture;u||(u=t.colorRampTexture=new Texture(o,t.colorRamp,a.RGBA)),u.bind(a.LINEAR,a.CLAMP_TO_EDGE);const h=((e,t,i,r,n)=>({u_matrix:e,u_color_ramp:0,u_center_direction:t,u_radius:l(i),u_opacity:r,u_temporal_offset:n}))(s.skyboxMatrix,t.getCenter(e,!1),t.paint.get("sky-gradient-radius"),r,n);e.prepareDrawProgram(o,c),c.draw(o,a.TRIANGLES,i,StencilMode.disabled,e.colorModeForRenderPass(),CullFaceMode.backCW,h,"skyboxGradient",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}(e,i,c,o,u)},debug:function(e,t,i){for(let r=0;r<i.length;r++)yf(e,t,i[r])},custom:function(e,t,i){const r=e.context,n=i.implementation;if(e.transform.projection.unsupportedLayers&&e.transform.projection.unsupportedLayers.includes("custom"))B("Custom layers are not yet supported with non-mercator projections. Use mercator to enable custom layers.");else if("offscreen"===e.renderPass){const t=n.prerender;t&&(e.setCustomLayerDefaults(),r.setColorMode(e.colorModeForRenderPass()),t.call(n,r.gl,e.transform.customLayerMatrix()),r.setDirty(),e.setBaseState())}else if("translucent"===e.renderPass){e.setCustomLayerDefaults(),r.setColorMode(e.colorModeForRenderPass()),r.setStencilMode(StencilMode.disabled);const t="3d"===n.renderingMode?new DepthMode(e.context.gl.LEQUAL,DepthMode.ReadWrite,e.depthRangeFor3D):e.depthModeForSublayer(0,DepthMode.ReadOnly);r.setDepthMode(t),n.render(r.gl,e.transform.customLayerMatrix()),r.setDirty(),e.setBaseState(),r.bindFramebuffer.set(null)}}};class Painter{constructor(e,t){this.context=new Context(e),this.transform=t,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.setup(),this.numSublayers=SourceCache.maxUnderzooming+SourceCache.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new CrossTileSymbolIndex,this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={}}updateTerrain(e,t){const i=!!e&&!!e.terrain&&this.transform.projection.supportsTerrain;if(!(i||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new Terrain(this,e));const r=this._terrain;this.transform.elevation=i?r:null,r.update(e,this.transform,t)}_updateFog(e){const t=e.fog;if(!t||"globe"===this.transform.projection.name||t.getOpacity(this.transform.pitch)<1||t.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[i,r]=t.getFovAdjustedRange(this.transform._fov);if(i>r)return void(this.transform.fogCullDistSq=null);const n=i+.78*(r-i);this.transform.fogCullDistSq=n*n}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(e,t){if(this.width=e*ee.devicePixelRatio,this.height=t*ee.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style.order)this.style._layers[e].resize()}setup(){const t=this.context,i=new StructArrayLayout2i4;i.emplaceBack(0,0),i.emplaceBack(Eo,0),i.emplaceBack(0,Eo),i.emplaceBack(Eo,Eo),this.tileExtentBuffer=t.createVertexBuffer(i,$c.members),this.tileExtentSegments=SegmentVector.simpleSegment(0,0,4,2);const r=new StructArrayLayout2i4;r.emplaceBack(0,0),r.emplaceBack(Eo,0),r.emplaceBack(0,Eo),r.emplaceBack(Eo,Eo),this.debugBuffer=t.createVertexBuffer(r,$c.members),this.debugSegments=SegmentVector.simpleSegment(0,0,4,5);const n=new StructArrayLayout2i4;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(-1,1),n.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(n,$c.members),this.viewportSegments=SegmentVector.simpleSegment(0,0,4,2);const o=new StructArrayLayout4i8;o.emplaceBack(0,0,0,0),o.emplaceBack(Eo,0,Eo,0),o.emplaceBack(0,Eo,0,Eo),o.emplaceBack(Eo,Eo,Eo,Eo),this.mercatorBoundsBuffer=t.createVertexBuffer(o,Ah.members),this.mercatorBoundsSegments=SegmentVector.simpleSegment(0,0,4,2);const a=new StructArrayLayout3ui6;a.emplaceBack(0,1,2),a.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(a);const s=new StructArrayLayout1ui2;for(const e of[0,1,3,2,0])s.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(s),this.emptyTexture=new Texture(t,new RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA),this.identityMat=ga();const l=this.context.gl;this.stencilClearMode=new StencilMode({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(e.performance.now()),this.atmosphereBuffer=new AtmosphereBuffer(this.context)}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(e){return e._makeTileBoundsBuffers(this.context,this.transform.projection),e._tileBoundsBuffer?{tileBoundsBuffer:e._tileBoundsBuffer,tileBoundsIndexBuffer:e._tileBoundsIndexBuffer,tileBoundsSegments:e._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const e=this.context,t=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(e,t.TRIANGLES,DepthMode.disabled,this.stencilClearMode,ColorMode.disabled,CullFaceMode.disabled,Ed(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(e,t,i){if(!t||this.currentStencilSource===t.id||!e.isTileClipped()||!i||0===i.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of i)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=t.id;const r=this.context,n=r.gl;this.nextStencilID+i.length>256&&this.clearStencil(),r.setColorMode(ColorMode.disabled),r.setDepthMode(DepthMode.disabled);const o=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of i){const i=t.getTile(e),a=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:s,tileBoundsIndexBuffer:l,tileBoundsSegments:c}=this.getTileBoundsBuffers(i);o.draw(r,n.TRIANGLES,DepthMode.disabled,new StencilMode({func:n.ALWAYS,mask:0},a,255,n.KEEP,n.KEEP,n.REPLACE),ColorMode.disabled,CullFaceMode.disabled,Ed(e.projMatrix),"$clipping",s,l,c)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new StencilMode({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);const t=this.context.gl;return new StencilMode({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}stencilConfigForOverlap(e){const t=this.context.gl,i=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=i[i.length-1].overscaledZ,n=i[0].overscaledZ-r+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();const e={};for(let i=0;i<n;i++)e[i+r]=new StencilMode({func:t.GEQUAL,mask:255},i+this.nextStencilID,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID+=n,[e,i]}return[{[r]:StencilMode.disabled},i]}colorModeForRenderPass(){const e=this.context.gl;if(this._showOverdrawInspector){const t=1/8;return new ColorMode([e.CONSTANT_COLOR,e.ONE],new Lt(t,t,t,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?ColorMode.unblended:ColorMode.alphaBlended}depthModeForSublayer(e,t,i){if(!this.opaquePassEnabledForLayer())return DepthMode.disabled;const r=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new DepthMode(i||this.context.gl.LEQUAL,t,[r,r])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,i){this.style=t,this.options=i,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(ee.now()),this.imageManager.beginFrame();const r=this.style.order,n=this.style._sourceCaches;for(const e in n){const t=n[e];t.used&&t.prepare(this.context)}const o={},a={},s={};for(const e in n){const t=n[e];o[e]=t.getVisibleCoordinates(),a[e]=o[e].slice().reverse(),s[e]=t.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let e=0;e<r.length;e++)if(this.style._layers[r[e]].is3D()){this.opaquePassCutoff=e;break}if(this.terrain&&(this.terrain.updateTileBinding(s),this.opaquePassCutoff=0),"globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new GlobeSharedBuffers(this.context)),Re.has(this.context.gl)){this.renderPass="offscreen";for(const e of r){const i=this.style._layers[e],r=t._getLayerSourceCache(i);if(!i.hasOffscreenPass()||i.isHidden(this.transform.zoom))continue;const n=r?a[r.id]:void 0;("custom"===i.type||i.isSky()||n&&n.length)&&this.renderLayer(this,r,i,n)}if(this.depthRangeFor3D=[0,1-(t.order.length+2)*this.numSublayers*this.depthEpsilon],this.terrain&&(this.style.hasSymbolLayers()||this.style.hasCircleLayers())&&this.terrain.drawDepth(),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]),this.context.clear({color:i.showOverdrawInspector?Lt.black:Lt.transparent,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.renderPass="opaque",!this.terrain)for(this.currentLayer=r.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[r[this.currentLayer]],i=t._getLayerSourceCache(e);if(e.isSky())continue;const n=i?a[i.id]:void 0;this._renderTileClippingMasks(e,i,n),this.renderLayer(this,i,e,n)}if(this.style.fog&&this.transform.projection.supportsFog&&function(e,t){const i=e.context,r=i.gl,n=e.transform,o=new DepthMode(r.LEQUAL,DepthMode.ReadOnly,[0,1]),a=e.useProgram("globeAtmosphere",null,"globe"===n.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"]),s=_u(n.zoom),c=t.properties.get("color").toArray01(),u=t.properties.get("high-color").toArray01(),h=t.properties.get("space-color").toArray01PremultipliedAlpha(),p=ns([]);as(p,p,-l(n._center.lng)),os(p,p,l(n._center.lat)),ss(p,p,n.angle),os(p,p,-n._pitch);const d=Ia(new Float32Array(16),p),f=k(t.properties.get("star-intensity"),0,1,0,.25),m=5e-4,_=k(t.properties.get("horizon-blend"),0,1,m,.25),g=yu(e,i,n)&&_===m?n.worldSize/(2*Math.PI*1.025)-1:n.globeRadius,y=e.frameCounter/1e3%1,x=La(n.globeCenterInViewSpace),v=Math.sqrt(Math.pow(x,2)-Math.pow(g,2)),b=Math.acos(v/x),w=((e,t,i,r,n,o,a,s,l,c,u,h,p,d)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:i,u_frustum_bl:r,u_horizon:n,u_transition:o,u_fadeout_range:a,u_color:s,u_high_color:l,u_space_color:c,u_star_intensity:u,u_star_size:5*ee.devicePixelRatio,u_star_density:0,u_temporal_offset:h,u_horizon_angle:p,u_rotation_matrix:d}))(n.frustumCorners.TL,n.frustumCorners.TR,n.frustumCorners.BR,n.frustumCorners.BL,n.frustumCorners.horizon,s,_,c,u,h,f,y,b,d);e.prepareDrawProgram(i,a);const T=e.atmosphereBuffer;T&&a.draw(i,r.TRIANGLES,o,StencilMode.disabled,ColorMode.alphaBlended,CullFaceMode.backCW,w,"skybox",T.vertexBuffer,T.indexBuffer,T.segments)}(this,this.style.fog),this.renderPass="sky",(_u(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer<r.length;this.currentLayer++){const e=this.style._layers[r[this.currentLayer]],i=t._getLayerSourceCache(e);e.isSky()&&this.renderLayer(this,i,e,i?a[i.id]:void 0)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<r.length;){const e=this.style._layers[r[this.currentLayer]],i=t._getLayerSourceCache(e);if(e.isSky()){++this.currentLayer;continue}if(this.terrain&&this.style.isLayerDraped(e)){if(e.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer);continue}const n=i?("symbol"===e.type?s:a)[i.id]:void 0;this._renderTileClippingMasks(e,i,i?o[i.id]:void 0),this.renderLayer(this,i,e,n),++this.currentLayer}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry){let e=null;v(this.style._layers).forEach((i=>{const r=t._getLayerSourceCache(i);r&&!i.isHidden(this.transform.zoom)&&(!e||e.getSource().maxzoom<r.getSource().maxzoom)&&(e=r)})),e&&this.options.showTileBoundaries&&Cf.debug(this,e,e.getVisibleCoordinates())}this.options.showPadding&&function(e){const t=e.transform.padding;xf(e,e.transform.height-(t.top||0),3,df),xf(e,t.bottom||0,3,ff),vf(e,t.left||0,3,mf),vf(e,e.transform.width-(t.right||0),3,_f);const i=e.transform.centerPoint;!function(e,t,i,r){bf(e,t-1,i-10,2,20,r),bf(e,t-10,i-1,20,2,r)}(e,i.x,e.transform.height-i.y,gf)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(e.performance.now()),this.saveCanvasCopy())}}renderLayer(e,t,i,r){i.isHidden(this.transform.zoom)||("background"===i.type||"sky"===i.type||"custom"===i.type||r&&r.length)&&(this.id=i.id,this.gpuTimingStart(i),e.transform.projection.unsupportedLayers&&e.transform.projection.unsupportedLayers.includes(i.type)||Cf[i.type](e,t,i,r,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(e){if(!this.options.gpuTiming)return;const t=this.context.extTimerQuery;let i=this.gpuTimers[e.id];i||(i=this.gpuTimers[e.id]={calls:0,cpuTime:0,query:t.createQueryEXT()}),i.calls++,t.beginQueryEXT(t.TIME_ELAPSED_EXT,i.query)}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){const e=this.context.extTimerQuery,t=e.createQueryEXT();this.deferredRenderGpuTimeQueries.push(t),e.beginQueryEXT(e.TIME_ELAPSED_EXT,t)}}gpuTimingDeferredRenderEnd(){if(!this.options.gpuTimingDeferredRender)return;const e=this.context.extTimerQuery;e.endQueryEXT(e.TIME_ELAPSED_EXT)}gpuTimingEnd(){if(!this.options.gpuTiming)return;const e=this.context.extTimerQuery;e.endQueryEXT(e.TIME_ELAPSED_EXT)}collectGpuTimers(){const e=this.gpuTimers;return this.gpuTimers={},e}collectDeferredRenderGpuQueries(){const e=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],e}queryGpuTimers(e){const t={};for(const i in e){const r=e[i],n=this.context.extTimerQuery,o=n.getQueryObjectEXT(r.query,n.QUERY_RESULT_EXT)/1e6;n.deleteQueryEXT(r.query),t[i]=o}return t}queryGpuTimeDeferredRender(e){if(!this.options.gpuTimingDeferredRender)return 0;const t=this.context.extTimerQuery;let i=0;for(const r of e)i+=t.getQueryObjectEXT(r,t.QUERY_RESULT_EXT)/1e6,t.deleteQueryEXT(r);return i}translatePosMatrix(e,t,i,r,n){if(!i[0]&&!i[1])return e;const o=n?"map"===r?this.transform.angle:0:"viewport"===r?-this.transform.angle:0;if(o){const e=Math.sin(o),t=Math.cos(o);i=[i[0]*t-i[1]*e,i[0]*e+i[1]*t]}const a=[n?i[0]:dh(t,i[0],this.transform.zoom),n?i[1]:dh(t,i[1],this.transform.zoom),0],s=new Float32Array(16);return ba(s,e,a),s}saveTileTexture(e){const t=this._tileTextures[e.size[0]];t?t.push(e):this._tileTextures[e.size[0]]=[e]}getTileTexture(e){const t=this._tileTextures[e];return t&&t.length>0?t.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const t=this.imageManager.getPattern(e.from.toString()),i=this.imageManager.getPattern(e.to.toString());return!t||!i}currentGlobalDefines(){const e=this.terrain&&this.terrain.renderingToTexture,t=this.style&&this.style.fog,i=[];return this.terrain&&!this.terrain.renderingToTexture&&i.push("TERRAIN"),t&&!e&&0!==t.getOpacity(this.transform.pitch)&&i.push("FOG"),e&&i.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&i.push("OVERDRAW_INSPECTOR"),i}useProgram(e,t,i){this.cache=this.cache||{};const r=i||[],n=this.currentGlobalDefines().concat(r),o=Program.cacheKey(ud[e],e,n,t);return this.cache[o]||(this.cache[o]=new Program(this.context,e,ud[e],t,ef[e],n)),this.cache[o]}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 e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=e.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new 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(),this.atmosphereBuffer&&this.atmosphereBuffer.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}prepareDrawProgram(e,t,i){if(this.terrain&&this.terrain.renderingToTexture)return;const r=this.style.fog;if(r){const n=r.getOpacity(this.transform.pitch),o=((e,t,i,r,n,o,a,s,l,c,u)=>{const h=e.transform,p=t.properties.get("color").toArray01();p[3]=r;const d=e.frameCounter/1e3%1;return{u_fog_matrix:i?h.calculateFogTileMatrix(i):e.identityMat,u_fog_range:t.getFovAdjustedRange(h._fov),u_fog_color:p,u_fog_horizon_blend:t.properties.get("horizon-blend"),u_fog_temporal_offset:d,u_frustum_tl:n,u_frustum_tr:o,u_frustum_br:a,u_frustum_bl:s,u_globe_pos:l,u_globe_radius:c,u_viewport:u,u_globe_transition:_u(h.zoom),u_is_globe:+("globe"===h.projection.name)}})(this,r,i,n,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*ee.devicePixelRatio,this.transform.height*ee.devicePixelRatio]);t.setFogUniformValues(e,o)}}setTileLoadedFlag(e){this.tileLoaded=e}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const e=this.context.gl,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,0,0,e.drawingBufferWidth,e.drawingBufferHeight,0),t}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const e=this.style&&this.style.fog;return!!e&&0!==e.getOpacity(this.transform.pitch)}getBackgroundTiles(){const e=this._backgroundTiles,t=this._backgroundTiles={},i=this.transform.coveringTiles({tileSize:512});for(const r of i)t[r.key]=e[r.key]||new Tile(r,512,this.transform.tileZoom,this);return t}clearBackgroundTiles(){this._backgroundTiles={}}}class EdgeInsets{constructor(e=0,t=0,i=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=r}interpolate(e,t,i){return null!=t.top&&null!=e.top&&(this.top=xi(e.top,t.top,i)),null!=t.bottom&&null!=e.bottom&&(this.bottom=xi(e.bottom,t.bottom,i)),null!=t.left&&null!=e.left&&(this.left=xi(e.left,t.left,i)),null!=t.right&&null!=e.right&&(this.right=xi(e.right,t.right,i)),this}getCenter(e,t){const i=_((this.left+e-this.right)/2,0,e),n=_((this.top+t-this.bottom)/2,0,t);return new r(i,n)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new EdgeInsets(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function If(e,t){const i=Z(e,3);Ia(e,t),q(e,3,i)}function Mf(e,t){const i=ns([]);return ss(i,i,-t),os(i,i,-e),i}function Pf(e,t){const i=[e[0],e[1],0],r=[t[0],t[1],0];if(La(i)>=1e-15){const e=Za([],i);ja(r,e,qa(r,e)),t[0]=r[0],t[1]=r[1]}const n=$a([],t,e);if(es(n)<1e-15)return null;const o=Math.atan2(-n[1],n[0]);return Mf(Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2]),o)}class FreeCameraOptions{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(e){if(e){const t=e instanceof MercatorCoordinate?e:new MercatorCoordinate(e[0],e[1],e[2]);this._renderWorldCopies&&(t.x=y(t.x,0,1)),this._position=t}else this._position=null}lookAtPoint(e,t){if(this.orientation=null,!this.position)return;const i=this._elevation?this._elevation.getAtPointOrZero(MercatorCoordinate.fromLngLat(e)):0,r=this.position,n=MercatorCoordinate.fromLngLat(e,i),o=[n.x-r.x,n.y-r.y,n.z-r.z];t||(t=[0,0,1]),t[2]=Math.abs(t[2]),this.orientation=Pf(o,t)}setPitchBearing(e,t){this.orientation=Mf(l(e),l(-t))}}class FreeCamera{constructor(e,t){this._transform=ya([]),this.orientation=t,this.position=e}get mercatorPosition(){const e=this.position;return new MercatorCoordinate(e[0],e[1],e[2])}get position(){const e=Z(this._transform,3);return[e[0],e[1],e[2]]}set position(e){var t;e&&q(this._transform,3,[(t=e)[0],t[1],t[2],1])}get orientation(){return this._orientation}set orientation(e){this._orientation=e||ns([]),e&&If(this._transform,this._orientation)}getPitchBearing(){const e=this.forward(),t=this.right();return{bearing:Math.atan2(-t[1],t[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,t){this._orientation=Mf(e,t),If(this._transform,this._orientation)}forward(){const e=Z(this._transform,2);return[-e[0],-e[1],-e[2]]}up(){const e=Z(this._transform,1);return[-e[0],-e[1],-e[2]]}right(){const e=Z(this._transform,0);return[e[0],e[1],e[2]]}getCameraToWorld(e,t){const i=new Float64Array(16);return xa(i,this.getWorldToCamera(e,t)),i}getWorldToCameraPosition(e,t,i){const r=this.position;ja(r,r,-e);const n=new Float64Array(16);return Aa(n,[i,i,i]),ba(n,n,r),n[10]*=t,n}getWorldToCamera(e,t){const i=new Float64Array(16),r=new Float64Array(4),n=this.position;var o,a;return(o=r)[0]=-(a=this._orientation)[0],o[1]=-a[1],o[2]=-a[2],o[3]=a[3],ja(n,n,-e),Ia(i,r),ba(i,i,n),i[1]*=-1,i[5]*=-1,i[9]*=-1,i[13]*=-1,i[8]*=t,i[9]*=t,i[10]*=t,i[11]*=t,i}getCameraToClipPerspective(e,t,i,r){const n=new Float64Array(16);return Ma(n,e,t,i,r),n}getDistanceToElevation(e){const t=0===e?0:Po(e,this.position[1]),i=this.forward();return(t-this.position[2])/i[2]}clone(){return new FreeCamera([...this.position],[...this.orientation])}}function Df(e,t){const i=kf(e.projection,e.zoom,e.width,e.height),r=function(e,t,i,r,n){const o=new LngLat(i.lng-180*Lf,i.lat),a=new LngLat(i.lng+180*Lf,i.lat),s=e.project(o.lng,o.lat),l=e.project(a.lng,a.lat),c=-Math.atan2(l.y-s.y,l.x-s.x),u=MercatorCoordinate.fromLngLat(i);u.y=_(u.y,-.999975,.999975);const h=u.toLngLat(),p=e.project(h.lng,h.lat),d=MercatorCoordinate.fromLngLat(h);d.x+=Lf;const f=d.toLngLat(),m=e.project(f.lng,f.lat),g=Rf(m.x-p.x,m.y-p.y,c),y=MercatorCoordinate.fromLngLat(h);y.y+=Lf;const x=y.toLngLat(),v=e.project(x.lng,x.lat),b=Rf(v.x-p.x,v.y-p.y,c),w=Math.abs(g.x)/Math.abs(b.y),T=ya([]);Sa(T,T,-c*(1-(n?0:r)));const E=ya([]);return wa(E,E,[1,1-(1-w)*r,1]),E[4]=-b.x/b.y*r,Sa(E,E,c),va(E,T,E),E}(e.projection,0,e.center,i,t),n=zf(e);return wa(r,r,[n,n,1]),r}function zf(e){const t=e.projection,i=kf(e.projection,e.zoom,e.width,e.height),r=Bf(t,e.center),n=Bf(t,LngLat.convert(t.center));return Math.pow(2,r*i+(1-i)*n)}function kf(e,t,i,r,n=1/0){const o=e.range;if(!o)return 0;const a=Math.min(n,Math.max(i,r)),s=Math.log(a/1024)/Math.LN2;return g(o[0]+s,o[1]+s,t)}const Lf=1/4e4;function Bf(e,t){const i=_(t.lat,-85.051129,Lo),r=new LngLat(t.lng-180*Lf,i),n=new LngLat(t.lng+180*Lf,i),o=e.project(r.lng,i),a=e.project(n.lng,i),s=MercatorCoordinate.fromLngLat(r),l=MercatorCoordinate.fromLngLat(n),c=a.x-o.x,u=a.y-o.y,h=l.x-s.x,p=l.y-s.y,d=Math.sqrt((h*h+p*p)/(c*c+u*u));return Math.log(d)/Math.LN2}function Rf(e,t,i){const r=Math.cos(i),n=Math.sin(i);return{x:e*r-t*n,y:e*n+t*r}}class Transform{constructor(e,t,i,r,n,o,a){this.tileSize=512,this._renderWorldCopies=void 0===n||n,this._minZoom=e||0,this._maxZoom=t||22,this._minPitch=null==i?0:i,this._maxPitch=null==r?60:r,this.setProjection(o),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new 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 EdgeInsets,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new FreeCamera,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1}clone(){const e=new Transform(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,e.tileSize=this.tileSize,e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._seaLevelZoom=this._seaLevelZoom,e.angle=this.angle,e._fov=this._fov,e._pitch=this._pitch,e._nearZ=this._nearZ,e._farZ=this._farZ,e._averageElevation=this._averageElevation,e._unmodified=this._unmodified,e._edgeInsets=this._edgeInsets.clone(),e._camera=this._camera.clone(),e._calcMatrices(),e.freezeTileCoverage=this.freezeTileCoverage,e.frustumCorners=this.frustumCorners,e}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(e){const t=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||t)&&this._updateCameraOnTerrain(),(e||t)&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return w(this.projection,["name","center","parallels"])}setProjection(e){this.projectionOptions=e||{name:"mercator"};const t=this.projection?this.getProjection():void 0;this.projection=Nu(this.projectionOptions);const i=!o(t,this.getProjection());return i&&this._calcMatrices(),this.mercatorFromTransition=!1,i}setMercatorFromTransition(){const e=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=Nu({name:"mercator"});const t=e!==this.projection.name;return t&&this._calcMatrices(),t}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return Po(this.center.lat,this.cameraWorldSize)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new r(this.width,this.height)}get bearing(){return y(this.rotation,-180,180)}set bearing(e){this.rotation=e}get rotation(){return-this.angle/Math.PI*180}set rotation(e){const t=-e*Math.PI/180;var i;this.angle!==t&&(this._unmodified=!1,this.angle=t,this._calcMatrices(),this.rotationMatrix=(i=new pa(4),pa!=Float32Array&&(i[1]=0,i[2]=0),i[0]=1,i[3]=1,i),function(e,t,i){var r=t[0],n=t[1],o=t[2],a=t[3],s=Math.sin(i),l=Math.cos(i);e[0]=r*l+o*s,e[1]=n*l+a*s,e[2]=r*-s+o*l,e[3]=n*-s+a*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(e){const t=_(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==t&&(this._unmodified=!1,this._pitch=t,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(e){e=Math.max(.01,Math.min(60,e)),this._fov!==e&&(this._unmodified=!1,this._fov=e/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(e){const t=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==t&&(this._unmodified=!1,this._setZoom(t),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom}_updateCameraOnTerrain(){if(!this._elevation||!this._elevation.isDataAvailableAtPoint(this.locationCoordinate(this.center)))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const e=this._elevation;this._centerAltitude=e.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=e.exaggeration(),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const e=this._elevation,t=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],i=this.horizonLineFromTop();let n=0,o=0;for(let a=0;a<t.length;a++){const s=new r(t[a][0]*this.width,i+t[a][1]*(this.height-i)),l=e.pointCoordinate(s);if(!l)continue;const c=1/Math.hypot(l[0]-this._camera.position[0],l[1]-this._camera.position[1]);n+=l[3]*c,o+=c}return 0===o?NaN:n/o}get center(){return this._center}set center(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._terrainEnabled()&&("ground"===this.cameraElevationReference?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(null==this._seaLevelZoom||!this._elevation)return;const e=this._seaLevelZoom,t=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),i=this.pixelsPerMeter/this.worldSize*t,r=this._mercatorZfromZoom(e),n=this._mercatorZfromZoom(this._maxZoom),o=Math.max(r-i,n);this._setZoom(this._zoomFromMercatorZ(o))}get padding(){return this._edgeInsets.toJSON()}set padding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}computeZoomRelativeTo(e){const t=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,e.toAltitude()));let i;i=e.z<this._camera.position[2]?[t.x,t.y,t.z]:[e.x,e.y,e.z];const r=La(Ja([],this._camera.position,i));return _(this._zoomFromMercatorZ(r),this._minZoom,this._maxZoom)}setFreeCameraOptions(e){if(!this.height)return;if(!e.position&&!e.orientation)return;this._updateCameraState();let t=!1;if(e.orientation&&!function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]}(e.orientation,this._camera.orientation)&&(t=this._setCameraOrientation(e.orientation)),e.position){const n=[e.position.x,e.position.y,e.position.z];((i=n)[0]!==(r=this._camera.position)[0]||i[1]!==r[1]||i[2]!==r[2])&&(this._setCameraPosition(n),t=!0)}var i,r;t&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const e=this._camera.position,t=new FreeCameraOptions;return t.position=new MercatorCoordinate(e[0],e[1],e[2]),t.orientation=this._camera.orientation,t._elevation=this.elevation,t._renderWorldCopies=this.renderWorldCopies,t}_setCameraOrientation(e){if(t=e,!Math.hypot(t[0],t[1],t[2],t[3]))return!1;var t;!function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],a=i*i+r*r+n*n+o*o;a>0&&(a=1/Math.sqrt(a)),e[0]=i*a,e[1]=r*a,e[2]=n*a,e[3]=o*a}(e,e);const i=Xa([],[0,0,-1],e),r=Xa([],[0,-1,0],e);if(r[2]<0)return!1;const n=Pf(i,r);return!!n&&(this._camera.orientation=n,!0)}_setCameraPosition(e){const t=this.zoomScale(this.minZoom)*this.tileSize,i=this.zoomScale(this.maxZoom)*this.tileSize,r=this.cameraToCenterDistance;e[2]=_(e[2],r/i,r/t),this._camera.position=e}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this._constrain(),this._calcMatrices()}coveringZoomLevel(e){const t=(e.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/e.tileSize));return Math.max(0,t)}getVisibleUnwrappedCoordinates(e){const t=[new UnwrappedTileID(0,e)];if(this.renderWorldCopies){const i=this.pointCoordinate(new r(0,0)),n=this.pointCoordinate(new r(this.width,0)),o=this.pointCoordinate(new r(this.width,this.height)),a=this.pointCoordinate(new r(0,this.height)),s=Math.floor(Math.min(i.x,n.x,o.x,a.x)),l=Math.floor(Math.max(i.x,n.x,o.x,a.x)),c=1;for(let i=s-c;i<=l+c;i++)0!==i&&t.push(new UnwrappedTileID(i,e))}return t}coveringTiles(e){let t=this.coveringZoomLevel(e);const i=t,r=this.elevation&&!e.isTerrainDEM,n="mercator"===this.projection.name;if(void 0!==e.minzoom&&t<e.minzoom)return[];void 0!==e.maxzoom&&t>e.maxzoom&&(t=e.maxzoom);const o=this.locationCoordinate(this.center),a=this.center.lat,s=1<<t,l=[s*o.x,s*o.y,0],c="globe"===this.projection.name,h=!c,p=Frustum.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,h),d=c?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),f=s*Po(1,this.center.lat),m=this._camera.position[2]/Po(1,this.center.lat),_=[s*d.x,s*d.y,m*(h?1:f)],g=this.cameraToCenterDistance/e.tileSize*(e.roundZoom?1:.502),y=this.pitch<=60&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace?t:0,x=e.isTerrainDEM&&this._elevation?1e4*this._elevation.exaggeration():this._centerAltitude,v=e.isTerrainDEM?-x:this._elevation?this._elevation.getMinElevationBelowMSL():0,b=this.projection.isReprojectedInTileSpace?zf(this):1,w=e=>{const t=1/4e4,i=new MercatorCoordinate(e.x+t,e.y,e.z),r=new MercatorCoordinate(e.x,e.y+t,e.z),n=e.toLngLat(),o=i.toLngLat(),a=r.toLngLat(),s=this.locationCoordinate(n),l=this.locationCoordinate(o),c=this.locationCoordinate(a),u=Math.hypot(l.x-s.x,l.y-s.y),h=Math.hypot(c.x-s.x,c.y-s.y);return Math.sqrt(u*h)*b/t},T=e=>{const t=x,i=v;return{aabb:Mu(this,s,0,0,0,e,i,t,this.projection),zoom:0,x:0,y:0,minZ:i,maxZ:t,wrap:e,fullyVisible:!1}},E=[];let S=[];const A=t,C=e.reparseOverscaled?i:t,I=e=>e*e,M=I((m-this._centerAltitude)*f),P=e=>{if(!this._elevation||!e.tileID||!n)return;const t=this._elevation.getMinMaxForTile(e.tileID),i=e.aabb;t?(i.min[2]=t.min,i.max[2]=t.max,i.center[2]=(i.min[2]+i.max[2])/2):(e.shouldSplit=D(e),e.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude))},D=e=>{if(e.zoom<y)return!0;if(e.zoom===A)return!1;if(null!=e.shouldSplit)return e.shouldSplit;const t=e.aabb.distanceX(_),n=e.aabb.distanceY(_);let o=M,s=1;if(c){o=I(e.aabb.distanceZ(_));const t=Math.pow(2,e.zoom),i=zo((e.y+1)/t),r=zo(e.y/t),n=Math.min(Math.max(a,i),r),l=Co(n)/Co(a);if(s=n===a?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,l/this._mercatorScaleRatio),this.zoom<=5&&e.zoom===A-1&&l>=.9)return!0}else if(r&&(o=I(e.aabb.distanceZ(_)*f)),this.projection.isReprojectedInTileSpace&&i<=5){const t=Math.pow(2,e.zoom),i=w(new MercatorCoordinate((e.x+.5)/t,(e.y+.5)/t));s=i>.85?1:i}const l=t*t+n*n+o;return l<I((1<<A-e.zoom)*g*s*((e,t)=>{if(t*I(.707)<e)return 1;const i=Math.sqrt(t/e);return i/(1.4144271570014144+(Math.pow(1.1,i-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(o,M),l))};if(this.renderWorldCopies)for(let e=1;e<=3;e++)E.push(T(-e)),E.push(T(e));for(E.push(T(0));E.length>0;){const i=E.pop(),o=i.x,a=i.y;let u=i.fullyVisible;if(!u){const e=i.aabb.intersects(p);if(0===e)continue;u=2===e}if(i.zoom!==A&&D(i))for(let e=0;e<4;e++){const t=(o<<1)+e%2,l=(a<<1)+(e>>1),h={aabb:n?i.aabb.quadrant(e):Mu(this,s,i.zoom+1,t,l,i.wrap,i.minZ,i.maxZ,this.projection),zoom:i.zoom+1,x:t,y:l,wrap:i.wrap,fullyVisible:u,tileID:void 0,shouldSplit:void 0,minZ:i.minZ,maxZ:i.maxZ};r&&!c&&(h.tileID=new OverscaledTileID(i.zoom+1===A?C:i.zoom+1,i.wrap,i.zoom+1,t,l),P(h)),E.push(h)}else{const r=i.zoom===A?C:i.zoom;if(e.minzoom&&e.minzoom>r)continue;const n=l[0]-(.5+o+(i.wrap<<i.zoom))*(1<<t-i.zoom),s=l[1]-.5-a,c=i.tileID?i.tileID:new OverscaledTileID(r,i.wrap,i.zoom,o,a);S.push({tileID:c,distanceSq:n*n+s*s})}}if(this.fogCullDistSq){const t=this.fogCullDistSq,i=this.horizonLineFromTop();S=S.filter((r=>{const n=[0,0,0,1],o=[Eo,Eo,0,1],a=this.calculateFogTileMatrix(r.tileID.toUnwrapped());is(n,n,a),is(o,o,a);const s=function(e,t,i){let r=0;for(let i=0;i<2;++i){const n=0;e[i]>n&&(r+=(e[i]-n)*(e[i]-n)),t[i]<n&&(r+=(n-t[i])*(n-t[i]))}return r}(n,o);if(0===s)return!0;let l=!1;const c=this._elevation;if(c&&s>t&&0!==i){const t=this.calculateProjMatrix(r.tileID.toUnwrapped());let n;e.isTerrainDEM||(n=c.getMinMaxForTile(r.tileID)),n||(n={min:v,max:x});const o=function(e){const t=Math.round((e+45+360)%360/90)%4;return u[t]}(this.rotation),a=[o[0]*Eo,o[1]*Eo,n.max];Wa(a,a,t),l=(1-a[1])*this.height*.5<i}return s<t||l}))}return S.sort(((e,t)=>e.distanceSq-t.distanceSq)).map((e=>e.tileID))}resize(e,t){this.width=e,this.height=t,this.pixelsToGLUnits=[2/e,-2/t],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(e){const t=_(e.lat,-85.051129,Lo),i=this.projection.project(e.lng,t);return new r(i.x*this.worldSize,i.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(e,t){let i,r;const n=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;i=(t.x-n.x)/e,r=(t.y-n.y)/e}else{const e=this.pointCoordinate(t),o=this.pointCoordinate(n);i=e.x-o.x,r=e.y-o.y}const o=this.locationCoordinate(e);this.setLocation(new MercatorCoordinate(o.x-i,o.y-r))}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(e){return this.projection.locationPoint(this,e)}locationPoint3D(e){return this.projection.locationPoint(this,e,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e){return this.coordinateLocation(this.pointCoordinate3D(e))}locationCoordinate(e,t){const i=t?Po(t,e.lat):void 0,r=this.projection.project(e.lng,e.lat);return new MercatorCoordinate(r.x,r.y,i)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(e,t){const i=null!=t?t:this._centerAltitude,r=[e.x,e.y,0,1],n=[e.x,e.y,1,1];is(r,r,this.pixelMatrixInverse),is(n,n,this.pixelMatrixInverse);const o=n[3];ts(r,r,1/r[3]),ts(n,n,1/o);const a=r[2],s=n[2];return{p0:r,p1:n,t:a===s?0:(i-a)/(s-a)}}screenPointToMercatorRay(e){const t=[e.x,e.y,0,1],i=[e.x,e.y,1,1];return is(t,t,this.pixelMatrixInverse),is(i,i,this.pixelMatrixInverse),ts(t,t,1/t[3]),ts(i,i,1/i[3]),t[2]=Po(t[2],this._center.lat)*this.worldSize,i[2]=Po(i[2],this._center.lat)*this.worldSize,ts(t,t,1/this.worldSize),ts(i,i,1/this.worldSize),new Ray([t[0],t[1],t[2]],Za([],Ja([],i,t)))}rayIntersectionCoordinate(e){const{p0:t,p1:i,t:r}=e,n=Po(t[2],this._center.lat),o=Po(i[2],this._center.lat);return new MercatorCoordinate(xi(t[0],i[0],r)/this.worldSize,xi(t[1],i[1],r)/this.worldSize,xi(n,o,r))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(e){if(!this.elevation)return this.pointCoordinate(e);let t=this.projection.pointCoordinate3D(this,e.x,e.y);if(t)return new MercatorCoordinate(t[0],t[1],t[2]);let i=0,r=this.horizonLineFromTop();if(e.y>r)return this.pointCoordinate(e);const n=.02*r,o=e.clone();for(let e=0;e<10&&r-i>n;e++){o.y=xi(i,r,.66);const e=this.projection.pointCoordinate3D(this,o.x,o.y);e?(r=o.y,t=e):i=o.y}return t?new MercatorCoordinate(t[0],t[1],t[2]):this.pointCoordinate(e)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}_coordinatePoint(e,t){const i=t&&this.elevation?this.elevation.getAtPointOrZero(e,this._centerAltitude):this._centerAltitude,n=[e.x*this.worldSize,e.y*this.worldSize,i+e.toAltitude(),1];return is(n,n,this.pixelMatrix),n[3]>0?new r(n[0]/n[3],n[1]/n[3]):new r(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(e,t){const i=new r(this._edgeInsets.left,this._edgeInsets.top),n=new r(this.width-this._edgeInsets.right,this._edgeInsets.top),o=new r(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),a=new r(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let s=this.pointCoordinate(i,e),l=this.pointCoordinate(n,e);const c=this.pointCoordinate(o,t),u=this.pointCoordinate(a,t),h=(e,t)=>(t.y-e.y)/(t.x-e.x);return s.y>1&&l.y>=0?s=new MercatorCoordinate((1-u.y)/h(u,s)+u.x,1):s.y<0&&l.y<=1&&(s=new MercatorCoordinate(-u.y/h(u,s)+u.x,0)),l.y>1&&s.y>=0?l=new MercatorCoordinate((1-c.y)/h(c,l)+c.x,1):l.y<0&&s.y<=1&&(l=new MercatorCoordinate(-c.y/h(c,l)+c.x,0)),(new LngLatBounds).extend(this.coordinateLocation(s)).extend(this.coordinateLocation(l)).extend(this.coordinateLocation(u)).extend(this.coordinateLocation(c))}_getBounds3D(){const e=this.elevation;if(!e.visibleDemTiles.length)return this._getBounds(0,0);const t=e.visibleDemTiles.reduce(((e,t)=>{if(t.dem){const i=t.dem.tree;e.min=Math.min(e.min,i.minimums[0]),e.max=Math.max(e.max,i.maximums[0])}return e}),{min:Number.MAX_VALUE,max:0});return this._getBounds(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(e=!0){const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,i=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,i):i}getMaxBounds(){return this.maxBounds}setMaxBounds(e){this.maxBounds=e,this.minLat=-85.051129,this.maxLat=Lo,this.minLng=-180,this.maxLng=180,e&&(this.minLat=e.getSouth(),this.maxLat=e.getNorth(),this.minLng=e.getWest(),this.maxLng=e.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=Io(this.minLng)*this.tileSize,this.worldMaxX=Io(this.maxLng)*this.tileSize,this.worldMinY=Mo(this.maxLat)*this.tileSize,this.worldMaxY=Mo(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(e,t){return this.projection.createTileMatrix(this,t,e)}calculateDistanceTileData(e){const t=e.key,i=this._distanceTileDataCache;if(i[t])return i[t];const r=e.canonical,n=1/this.height,o=this.cameraWorldSize/this.zoomScale(r.z),a=(r.x+Math.pow(2,r.z)*e.wrap)*o,s=r.y*o,l=this.point,c=this.angle,u=Math.sin(-c),h=-Math.cos(-c);return i[t]={bearing:[u,h],center:[(l.x-a)*n,(l.y-s)*n],scale:o/Eo*n},i[t]}calculateFogTileMatrix(e){const t=e.key,i=this._fogTileMatrixCache;if(i[t])return i[t];const r=this.projection.createTileMatrix(this,this.cameraWorldSize,e);return va(r,this.worldToFogMatrix,r),i[t]=new Float32Array(r),i[t]}calculateProjMatrix(e,t=!1){const i=e.key,r=t?this._alignedProjMatrixCache:this._projMatrixCache;if(r[i])return r[i];const n=this.calculatePosMatrix(e,this.worldSize);return va(n,this.projection.isReprojectedInTileSpace?this.mercatorMatrix:t?this.alignedProjMatrix:this.projMatrix,n),r[i]=new Float32Array(n),r[i]}calculatePixelsToTileUnitsMatrix(e){const t=e.tileID.key,i=this._pixelsToTileUnitsCache;if(i[t])return i[t];const r=function(e,t){const{scale:i}=e.tileTransform,r=i*Eo/(e.tileSize*Math.pow(2,t.zoom-e.tileID.overscaledZ+e.tileID.canonical.z));return function(e,t,i){var r=t[1],n=t[2],o=t[3],a=i[0],s=i[1];return e[0]=t[0]*a,e[1]=r*a,e[2]=n*s,e[3]=o*s,e}(new Float32Array(4),t.inverseAdjustmentMatrix,[r,r])}(e,this);return i[t]=r,i[t]}customLayerMatrix(){return this.mercatorMatrix.slice()}recenterOnTerrain(){if(!this._elevation||"globe"===this.projection.name)return;const e=this._elevation;this._updateCameraState();const t=Po(1,this._center.lat)*this.worldSize,i=this._computeCameraPosition(t),r=this._camera.forward(),n=Po(1,this._center.lat);i[2]/=n,r[2]/=n,Za(r,r);const o=e.raycast(i,r,e.exaggeration());if(o){const e=Na([],i,r,o),t=new MercatorCoordinate(e[0],e[1],Po(e[2],zo(e[1]))),a=(t.z+La([t.x-i[0],t.y-i[1],t.z-i[2]*n]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(a),this._centerAltitude=t.toAltitude(),this._center=this.coordinateLocation(t),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCameraAltitude(){if(!this._elevation)return;const e=this._elevation;this._updateCameraState();const t=Po(1,this._center.lat)*this.worldSize,i=this._computeCameraPosition(t),r=e.getAtPointOrZero(new MercatorCoordinate(...i)),n=this._minimumHeightOverTerrain()*Math.cos(l(this._maxPitch)),o=this._camera.position[2]-this.pixelsPerMeter/this.worldSize*r;if(o<n){const e=this.locationCoordinate(this._center,this._centerAltitude),t=[e.x-i[0],e.y-i[1],e.z-i[2]],r=La(t);t[2]-=(n-o)/this._pixelsPerMercatorPixel;const a=La(t);if(0===a)return;ja(t,t,r/a*this._pixelsPerMercatorPixel),this._camera.position=[e.x-t[0],e.y-t[1],e.z*this._pixelsPerMercatorPixel-t[2]],this._camera.orientation=Pf(t,this._camera.up()),this._updateStateFromCamera()}}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const e="globe"===this.projection.name||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||e){const t=this.center;return t.lat=_(t.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!e)&&(t.lng=_(t.lng,this.minLng,this.maxLng)),this.center=t,void(this._constraining=!1)}const t=this._unmodified,{x:i,y:n}=this.point;let o=0,a=i,s=n;const l=this.width/2,c=this.height/2,u=this.worldMinY*this.scale,h=this.worldMaxY*this.scale;if(n-c<u&&(s=u+c),n+c>h&&(s=h-c),h-u<this.height&&(o=Math.max(o,this.height/(h-u)),s=(h+u)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const e=this.worldMinX*this.scale,t=this.worldMaxX*this.scale,r=this.worldSize/2-(e+t)/2;a=(i+r+this.worldSize)%this.worldSize-r,a-l<e&&(a=e+l),a+l>t&&(a=t-l),t-e<this.width&&(o=Math.max(o,this.width/(t-e)),a=(t+e)/2)}a===i&&s===n||(this.center=this.unproject(new r(a,s))),o&&(this.zoom+=this.scaleZoom(o)),this._constrainCameraAltitude(),this._unmodified=t,this._constraining=!1}_minZoomForBounds(){let e=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(e=Math.max(e,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),e}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const e=this.centerOffset,t=this.pixelsPerMeter;"globe"===this.projection.name&&(this._mercatorScaleRatio=Po(1,this.center.lat)/Po(1,45));const i=kf(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,i),this.cameraToCenterDistance=.5/Math.tan(.5*this._fov)*this.height*this._pixelsPerMercatorPixel,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const r=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?t:1),n=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);n[8]=2*-e.x/this.width,n[9]=2*e.y/this.height;let o=Da([],n,r);if(this.projection.isReprojectedInTileSpace){const e=this.locationCoordinate(this.center),t=ya([]);ba(t,t,[e.x*this.worldSize,e.y*this.worldSize,0]),va(t,t,Df(this)),ba(t,t,[-e.x*this.worldSize,-e.y*this.worldSize,0]),va(o,o,t),this.inverseAdjustmentMatrix=function(e){const t=Df(e,!0);return da([],[t[0],t[1],t[4],t[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];this.mercatorMatrix=wa([],o,[this.worldSize,this.worldSize,this.worldSize/t,1]),this.projMatrix=o,this.invProjMatrix=xa(new Float64Array(16),this.projMatrix);const a=xa([],n);this.frustumCorners=FrustumCorners.fromInvProjectionMatrix(a,this.horizonLineFromTop(),this.height);const s=new Float32Array(16);ya(s),wa(s,s,[1,-1,1]),Ta(s,s,this._pitch),Sa(s,s,this.angle);const l=Ma(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ),c=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;l[8]=2*-e.x/this.width,l[9]=2*(e.y+c)/this.height,this.skyboxMatrix=va(s,l,s);const u=this.point,h=u.x,p=u.y,d=this.width%2/2,f=this.height%2/2,m=Math.cos(this.angle),_=Math.sin(this.angle),g=h-Math.round(h)+m*d+_*f,y=p-Math.round(p)+m*f+_*d,x=new Float64Array(o);if(ba(x,x,[g>.5?g-1:g,y>.5?y-1:y,0]),this.alignedProjMatrix=x,o=ga(),wa(o,o,[this.width/2,-this.height/2,1]),ba(o,o,[1,-1,0]),this.labelPlaneMatrix=o,o=ga(),wa(o,o,[1,-1,1]),ba(o,o,[-1,-1,0]),wa(o,o,[2/this.width,2/this.height,1]),this.glCoordMatrix=o,this.pixelMatrix=va(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},o=xa(new Float64Array(16),this.pixelMatrix),!o)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=o,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=function(e){const{x:t,y:i}=e.point,{lng:r,lat:n}=e._center;return mu(t,i,e.worldSize,r,n)}(this);const e=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=Wa(e,e,r),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=o;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const e=this.cameraWorldSize,t=this.cameraPixelsPerMeter,i=this._camera.position,r=1/this.height/this._pixelsPerMercatorPixel,n=[e,e,t];ja(n,n,r),ja(i,i,-1),Oa(i,i,n);const o=ga();ba(o,o,i),wa(o,o,n),this.mercatorFogMatrix=o,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(e,t,r)}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),r=this.point,n=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return[r.x/this.worldSize-i[0]*n,r.y/this.worldSize-i[1]*n,e/this.worldSize*this._centerAltitude-i[2]*n]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(e){const t=this._maxCameraBoundsDistance()*Math.cos(this._pitch),i=e[2];let r=1;i>0&&(r=Math.min((t-this._camera.position[2])/i,1)),this._camera.position=Na([],this._camera.position,e,r),this._updateStateFromCamera(),this.projection.wrap&&(this.center=this.center.wrap())}_updateStateFromCamera(){const e=this._camera.position,t=this._camera.forward(),{pitch:i,bearing:r}=this._camera.getPitchBearing(),n=Po(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,o=this._mercatorZfromZoom(this._maxZoom)*Math.cos(l(this._maxPitch)),a=Math.max((e[2]-n)/Math.cos(i),o),s=this._zoomFromMercatorZ(a);Na(e,e,t,a),this._pitch=_(i,l(this.minPitch),l(this.maxPitch)),this.angle=y(r,-Math.PI,Math.PI),this._setZoom(_(s,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new MercatorCoordinate(e[0],e[1],e[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min((null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(e*this.tileSize))}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(B("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(e,t){const i=Math.min(e.x,t.x),n=Math.max(e.x,t.x),o=Math.min(e.y,t.y),a=Math.max(e.y,t.y);if(o<this.horizonLineFromTop(!1))return!0;if("mercator"!==this.projection.name)return!1;const s=[new r(i,o),new r(n,a),new r(i,a),new r(n,o)],l=this.renderWorldCopies?-3:0,c=this.renderWorldCopies?4:1;for(const e of s){const t=this.pointRayIntersection(e);if(t.t<0)return!0;const i=this.rayIntersectionCoordinate(t);if(i.x<l||i.y<0||i.x>c||i.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+c(this.fovAboveCenter)>88||this.anyCornerOffEdge(new r(0,0),new r(this.width,this.height))}zoomDeltaToMovement(e,t){const i=La(Ja([],this._camera.position,e)),r=this._zoomFromMercatorZ(i)+t;return i-this._mercatorZfromZoom(r)}getCameraPoint(){if("globe"===this.projection.name){const e=function(e,t){const i=[e[0],e[1],e[2],1];is(i,i,t);const r=Math.max(i[3],1e-6);return[i[0]/r,i[1]/r,i[2]/r,r]}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new r(e[0],e[1])}{const e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new r(0,e))}}getCameraToCenterDistance(e){const t=kf(e,this.zoom,this.width,this.height,1024),i=e.pixelSpaceConversion(this.center.lat,this.worldSize,t);return.5/Math.tan(.5*this._fov)*this.height*i}}function Ff(e,t){let i=!1,r=null;const n=()=>{r=null,i&&(e(),r=setTimeout(n,t),i=!1)};return()=>(i=!0,r||n(),r)}class Hash{constructor(e){this._hashName=e&&encodeURIComponent(e),I(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Ff(this._updateHashUnthrottled.bind(this),300)}addTo(t){return this._map=t,e.addEventListener("hashchange",this._onHashChange,!1),t.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),e.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const t=this._map;if(!t)return"";const i=Of(t);if(this._hashName){const t=this._hashName;let r=!1;const n=e.location.hash.slice(1).split("&").map((e=>{const n=e.split("=")[0];return n===t?(r=!0,`${n}=${i}`):e})).filter((e=>e));return r||n.push(`${t}=${i}`),`#${n.join("&")}`}return`#${i}`}_getCurrentHash(){const t=e.location.hash.replace("#","");if(this._hashName){let e;return t.split("&").map((e=>e.split("="))).forEach((t=>{t[0]===this._hashName&&(e=t)})),(e&&e[1]||"").split("/")}return t.split("/")}_onHashChange(){const e=this._map;if(!e)return!1;const t=this._getCurrentHash();if(t.length>=3&&!t.some((e=>isNaN(e)))){const i=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:i,pitch:+(t[4]||0)}),!0}return!1}_updateHashUnthrottled(){const t=e.location.href.replace(/(#.+)?$/,this.getHashString());e.history.replaceState(e.history.state,null,t)}}function Of(e,t){const i=e.getCenter(),r=Math.round(100*e.getZoom())/100,n=Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,n),a=Math.round(i.lng*o)/o,s=Math.round(i.lat*o)/o,l=e.getBearing(),c=e.getPitch();let u=t?`/${a}/${s}/${r}`:`${r}/${s}/${a}`;return(l||c)&&(u+="/"+Math.round(10*l)/10),c&&(u+=`/${Math.round(c)}`),u}const Vf={linearity:.3,easing:f(0,0,.3,1)},Uf=b({deceleration:2500,maxSpeed:1400},Vf),jf=b({deceleration:20,maxSpeed:1400},Vf),Nf=b({deceleration:1e3,maxSpeed:360},Vf),Gf=b({deceleration:1e3,maxSpeed:90},Vf);class HandlerInertia{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:ee.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,t=ee.now();for(;e.length>0&&t-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const t={zoom:0,bearing:0,pitch:0,pan:new r(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)t.zoom+=e.zoomDelta||0,t.bearing+=e.bearingDelta||0,t.pitch+=e.pitchDelta||0,e.panDelta&&t.pan._add(e.panDelta),e.around&&(t.around=e.around),e.pinchAround&&(t.pinchAround=e.pinchAround);const i=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,n={};if(t.pan.mag()){const r=qf(t.pan.mag(),i,b({},Uf,e||{}));n.offset=t.pan.mult(r.amount/t.pan.mag()),n.center=this._map.transform.center,Zf(n,r)}if(t.zoom){const e=qf(t.zoom,i,jf);n.zoom=this._map.transform.zoom+e.amount,Zf(n,e)}if(t.bearing){const e=qf(t.bearing,i,Nf);n.bearing=this._map.transform.bearing+_(e.amount,-179,179),Zf(n,e)}if(t.pitch){const e=qf(t.pitch,i,Gf);n.pitch=this._map.transform.pitch+e.amount,Zf(n,e)}if(n.zoom||n.bearing){const e=void 0===t.pinchAround?t.around:t.pinchAround;n.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),n.noMoveStart=!0,n}}function Zf(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function qf(e,t,i){const{maxSpeed:r,linearity:n,deceleration:o}=i,a=_(e*n/(t/1e3),-r,r),s=Math.abs(a)/(o*n);return{easing:i.easing,duration:1e3*s,amount:a*(s/2)}}class MapMouseEvent extends Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i,r={}){const n=he(t.getCanvasContainer(),i);super(e,b({point:n,lngLat:t.unproject(n),originalEvent:i},r)),this._defaultPrevented=!1,this.target=t}}class MapTouchEvent extends Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){const n="touchend"===e?i.changedTouches:i.touches,o=pe(t.getCanvasContainer(),n),a=o.map((e=>t.unproject(e))),s=o.reduce(((e,t,i,r)=>e.add(t.div(r.length))),new r(0,0));super(e,{points:o,point:s,lngLats:a,lngLat:t.unproject(s),originalEvent:i}),this._defaultPrevented=!1}}class MapWheelEvent extends Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1}}class MapEventHandler{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new MapWheelEvent(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new MapMouseEvent(e.type,this._map,e))}mouseup(e){this._map.fire(new MapMouseEvent(e.type,this._map,e))}preclick(e){const t=b({},e);t.type="preclick",this._map.fire(new MapMouseEvent(t.type,this._map,t))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new MapMouseEvent(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new MapMouseEvent(e.type,this._map,e))}mouseover(e){this._map.fire(new MapMouseEvent(e.type,this._map,e))}mouseout(e){this._map.fire(new MapMouseEvent(e.type,this._map,e))}touchstart(e){return this._firePreventable(new MapTouchEvent(e.type,this._map,e))}touchmove(e){this._map.fire(new MapTouchEvent(e.type,this._map,e))}touchend(e){this._map.fire(new MapTouchEvent(e.type,this._map,e))}touchcancel(e){this._map.fire(new MapTouchEvent(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class BlockableMapEventHandler{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new MapMouseEvent(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new MapMouseEvent("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new MapMouseEvent(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class BoxZoomHandler{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(se(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)<this._clickTolerance)return;const r=this._startPos;this._lastPos=i,this._box||(this._box=te("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",e));const n=Math.min(r.x,i.x),o=Math.max(r.x,i.x),a=Math.min(r.y,i.y),s=Math.max(r.y,i.y);this._map._requestDomTask((()=>{this._box&&(this._box.style.transform=`translate(${n}px,${a}px)`,this._box.style.width=o-n+"px",this._box.style.height=s-a+"px")}))}mouseupWindow(e,t){if(!this._active)return;if(0!==e.button)return;const i=this._startPos,r=t;if(this.reset(),ue(),i.x!==r.x||i.y!==r.y)return this._map.fire(new Event("boxzoomend",{originalEvent:e})),{cameraAnimation:e=>e.fitScreenCoordinates(i,r,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),le(),delete this._startPos,delete this._lastPos}_fireEvent(e,t){return this._map.fire(new Event(e,{originalEvent:t}))}}function $f(e,t){const i={};for(let r=0;r<e.length;r++)i[e[r].identifier]=t[r];return i}class SingleTapRecognizer{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(e,t,i){(this.centroid||i.length>this.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=e.timeStamp),i.length===this.numTouches&&(this.centroid=function(e){const t=new r(0,0);for(const i of e)t._add(i);return t.div(e.length)}(t),this.touches=$f(i,t)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const r=$f(i,t);for(const e in this.touches){const t=this.touches[e],i=r[e];(!i||i.dist(t)>30)&&(this.aborted=!0)}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class TapRecognizer{constructor(e){this.singleTap=new SingleTapRecognizer(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(e,t,i){this.singleTap.touchstart(e,t,i)}touchmove(e,t,i){this.singleTap.touchmove(e,t,i)}touchend(e,t,i){const r=this.singleTap.touchend(e,t,i);if(r){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class TapZoomHandler{constructor(){this._zoomIn=new TapRecognizer({numTouches:1,numTaps:2}),this._zoomOut=new TapRecognizer({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i)}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i)}touchend(e,t,i){const r=this._zoomIn.touchend(e,t,i),n=this._zoomOut.touchend(e,t,i);return r?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(r)},{originalEvent:e})}):n?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(n)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const Wf={0:1,2:2};class MouseHandler{constructor(e){this.reset(),this._clickTolerance=e.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(e,t){return!1}_move(e,t){return{}}mousedown(e,t){if(this._lastPoint)return;const i=de(e);this._correctButton(e,i)&&(this._lastPoint=t,this._eventButton=i)}mousemoveWindow(e,t){const i=this._lastPoint;if(i)if(e.preventDefault(),null!=this._eventButton&&function(e,t){const i=Wf[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(i)<this._clickTolerance))return this._moved=!0,this._lastPoint=t,this._move(i,t)}mouseupWindow(e){this._lastPoint&&de(e)===this._eventButton&&(this._moved&&ue(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class MousePanHandler extends MouseHandler{mousedown(e,t){super.mousedown(e,t),this._lastPoint&&(this._active=!0)}_correctButton(e,t){return 0===t&&!e.ctrlKey}_move(e,t){return{around:t,panDelta:t.sub(e)}}}class MouseRotateHandler extends MouseHandler{_correctButton(e,t){return 0===t&&e.ctrlKey||2===t}_move(e,t){const i=.8*(t.x-e.x);if(i)return this._active=!0,{bearingDelta:i}}contextmenu(e){e.preventDefault()}}class MousePitchHandler extends MouseHandler{_correctButton(e,t){return 0===t&&e.ctrlKey||2===t}_move(e,t){const i=-.5*(t.y-e.y);if(i)return this._active=!0,{pitchDelta:i}}contextmenu(e){e.preventDefault()}}class TouchPanHandler{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._minTouches=1,this._clickTolerance=t.clickTolerance||1,this.reset(),I(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new r(0,0)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active&&!(i.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(1===i.length&&!N())return void this._showTouchPanBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return e.cancelable&&e.preventDefault(),this._calculateTransform(e,t,i)}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&i.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,t,i){i.length>0&&(this._active=!0);const n=$f(i,t),o=new r(0,0),a=new r(0,0);let s=0;for(const e in n){const t=n[e],i=this._touches[e];i&&(o._add(t),a._add(t.sub(i)),s++,n[e]=t)}if(this._touches=n,s<this._minTouches||!a.mag())return;const l=a.div(s);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:o.div(s),panDelta:l}}enable(){this._enabled=!0,this._map._cooperativeGestures&&(this._addTouchPanBlocker(),this._el.classList.add("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page"))}disable(){this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove(),this._el.classList.remove("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page")),this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}_addTouchPanBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=te("div","mapboxgl-touch-pan-blocker",this._map._container),this._alertContainer.textContent=this._map._getUIString("TouchPanBlocker.Message"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showTouchPanBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","null")}),500)}}class TwoTouchHandler{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(e){}_move(e,t,i){return{}}touchstart(e,t,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,i){const r=this._firstTwoTouches;if(!r)return;e.preventDefault();const[n,o]=r,a=Hf(i,t,n),s=Hf(i,t,o);if(!a||!s)return;const l=this._aroundCenter?null:a.add(s).div(2);return this._move([a,s],l,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[r,n]=this._firstTwoTouches,o=Hf(i,t,r),a=Hf(i,t,n);o&&a||(this._active&&ue(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Hf(e,t,i){for(let r=0;r<e.length;r++)if(e[r].identifier===i)return t[r]}function Xf(e,t){return Math.log(e/t)/Math.LN2}class TouchZoomHandler extends TwoTouchHandler{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,t){const i=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(Xf(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Xf(this._distance,i),pinchAround:t}}}function Kf(e,t){return 180*e.angleWith(t)/Math.PI}class TouchRotateHandler extends TwoTouchHandler{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,t){const i=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Kf(this._vector,i),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());const t=25/(Math.PI*this._minDiameter)*360,i=Kf(e,this._startVector);return Math.abs(i)<t}}function Jf(e){return Math.abs(e.y)>Math.abs(e.x)}class TouchPitchHandler extends TwoTouchHandler{constructor(e){super(),this._map=e}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(e){this._lastPoints=e,Jf(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,i){const r=this._lastPoints;if(!r)return;const n=e[0].sub(r[0]),o=e[1].sub(r[1]);return this._map._cooperativeGestures&&i.touches.length<3||(this._valid=this.gestureBeginsVertically(n,o,i.timeStamp),!this._valid)?void 0:(this._lastPoints=e,this._active=!0,{pitchDelta:(n.y+o.y)/2*-.5})}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,n=t.mag()>=2;if(!r&&!n)return;if(!r||!n)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return Jf(e)&&Jf(t)&&o}}const Yf={panStep:100,bearingStep:15,pitchStep:10};class KeyboardHandler{constructor(){const e=Yf;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,r=0,n=0,o=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),n=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),n=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:a=>{const s=a.getZoom();a.easeTo({duration:300,easeId:"keyboardHandler",easing:Qf,zoom:t?Math.round(s)+t*(e.shiftKey?2:1):s,bearing:a.getBearing()+i*this._bearingStep,pitch:a.getPitch()+r*this._pitchStep,offset:[-n*this._panStep,-o*this._panStep],center:a.getCenter()},{originalEvent:e})}}}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 Qf(e){return e*(2-e)}const em=4.000244140625;class ScrollZoomHandler{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._handler=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,I(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(t.ctrlKey||t.metaKey||this.isZooming()||N()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let i=t.deltaMode===e.WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const r=ee.now(),n=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==i&&i%em==0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=i,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(n*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),t.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=t,this._delta-=i,this._active||this._start(t)),t.preventDefault()}_onTimeout(e){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)}_start(e){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 t=he(this._el,e);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:t,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 e=this._map.transform,t=()=>e._terrainEnabled()&&this._aroundCoord?e.computeZoomRelativeTo(this._aroundCoord):e.zoom;if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>em?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==r&&(r=1/r);const n=t(),o=Math.pow(2,n),a="number"==typeof this._targetZoom?e.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,e.scaleZoom(a*r))),"wheel"===this._type&&(this._startZoom=n,this._easing=this._smoothOutEasing(200)),this._delta=0}const i="number"==typeof this._targetZoom?this._targetZoom:t(),r=this._startZoom,n=this._easing;let o,a=!1;if("wheel"===this._type&&r&&n){const e=Math.min((ee.now()-this._lastWheelEventTime)/200,1);o=xi(r,i,n(e)),e<1?this._frameId||(this._frameId=!0):a=!0}else o=i,a=!0;return this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!a,zoomDelta:o-t(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let t=m;if(this._prevEase){const e=this._prevEase,i=(ee.now()-e.start)/e.duration,r=e.easing(i+.01)-e.easing(i),n=.27/Math.sqrt(r*r+1e-4)*.01;t=f(n,Math.sqrt(.0729-n*n),.25,1)}return this._prevEase={start:ee.now(),duration:e,easing:t},t}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=te("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(e.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`)}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","null")}),200)}}class DoubleClickZoomHandler{constructor(e,t){this._clickZoom=e,this._tapZoom=t}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 ClickZoomHandler{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(e.shiftKey?-1:1),around:i.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class TapDragZoomHandler{constructor(){this._tap=new TapRecognizer({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(e,t,i){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=t[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(e,t,i))}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=t[0],n=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(e,t,i)}touchend(e,t,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(e,t,i)&&(this._tapTime=e.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class DragPanHandler{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i}enable(e){this._inertiaOptions=e||{},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 DragRotateHandler{constructor(e,t,i){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=i}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 TouchZoomRotateHandler{constructor(e,t,i,r){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),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 tm=e=>e.zoom||e.drag||e.pitch||e.rotate;class RenderFrameEvent extends Event{}class TrackingEllipsoid{constructor(){this.constants=[1,1,.01],this.radius=0}setup(e,t){const i=Ja([],t,e);this.radius=La(i[2]<0?Qa([],i,this.constants):[i[0],i[1],0])}projectRay(e){Qa(e,e,this.constants),Za(e,e),Ya(e,e,this.constants);const t=ja([],e,this.radius);if(t[2]>0){const e=ja([],[0,0,1],qa(t,[0,0,1])),i=ja([],Za([],[t[0],t[1],0]),this.radius),r=Ra([],t,ja([],Ja([],Ra([],i,e),t),2));t[0]=r[0],t[1]=r[1]}return t}}function im(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class HandlerManager{constructor(t,i){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new HandlerInertia(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new TrackingEllipsoid,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),I(["handleEvent","handleWindowEvent"],this);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[e.document,"mousemove",{capture:!0}],[e.document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[e,"blur",void 0]];for(const[t,i,r]of this._listeners)t.addEventListener(i,t===e.document?this.handleWindowEvent:this.handleEvent,r)}destroy(){for(const[t,i,r]of this._listeners)t.removeEventListener(i,t===e.document?this.handleWindowEvent:this.handleEvent,r)}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new MapEventHandler(t,e));const r=t.boxZoom=new BoxZoomHandler(t,e);this._add("boxZoom",r);const n=new TapZoomHandler,o=new ClickZoomHandler;t.doubleClickZoom=new DoubleClickZoomHandler(o,n),this._add("tapZoom",n),this._add("clickZoom",o);const a=new TapDragZoomHandler;this._add("tapDragZoom",a);const s=t.touchPitch=new TouchPitchHandler(t);this._add("touchPitch",s);const l=new MouseRotateHandler(e),c=new MousePitchHandler(e);t.dragRotate=new DragRotateHandler(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const u=new MousePanHandler(e),h=new TouchPanHandler(t,e);t.dragPan=new DragPanHandler(i,u,h),this._add("mousePan",u),this._add("touchPan",h,["touchZoom","touchRotate"]);const p=new TouchRotateHandler,d=new TouchZoomHandler;t.touchZoomRotate=new TouchZoomRotateHandler(i,d,p,a),this._add("touchRotate",p,["touchPan","touchZoom"]),this._add("touchZoom",d,["touchPan","touchRotate"]),this._add("blockableMapEvent",new BlockableMapEventHandler(t));const f=t.scrollZoom=new ScrollZoomHandler(t,this);this._add("scrollZoom",f,["mousePan"]);const m=t.keyboard=new KeyboardHandler;this._add("keyboard",m);for(const i of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])e.interactive&&e[i]&&t[i].enable(e[i])}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!tm(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,t,i){for(const r in e)if(r!==i&&(!t||t.indexOf(r)<0))return!0;return!1}handleWindowEvent(e){this.handleEvent(e,`${e.type}Window`)}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}handleEvent(e,t){this._updatingCamera=!0;const i="renderFrame"===e.type,r=i?void 0:e,n={needsRenderFrame:!1},o={},a={},s=e.touches?this._getMapTouches(e.touches):void 0,l=s?pe(this._el,s):i?void 0:he(this._el,e);for(const{handlerName:i,handler:c,allowed:u}of this._handlers){if(!c.isEnabled())continue;let h;this._blockedByActive(a,u,i)?c.reset():c[t||e.type]&&(h=c[t||e.type](e,l,s),this.mergeHandlerResult(n,o,h,i,r),h&&h.needsRenderFrame&&this._triggerRenderFrame()),(h||c.isActive())&&(a[i]=c)}const c={};for(const e in this._previousActiveHandlers)a[e]||(c[e]=r);this._previousActiveHandlers=a,(Object.keys(c).length||im(n))&&(this._changes.push([n,o,c]),this._triggerRenderFrame()),(Object.keys(a).length||im(n))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=n;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map))}mergeHandlerResult(e,t,i,r,n){if(!i)return;b(e,i);const o={handlerName:r,originalEvent:i.originalEvent||n};void 0!==i.zoomDelta&&(t.zoom=o),void 0!==i.panDelta&&(t.drag=o),void 0!==i.pitchDelta&&(t.pitch=o),void 0!==i.bearingDelta&&(t.rotate=o)}_applyChanges(){const e={},t={},i={};for(const[n,o,a]of this._changes)n.panDelta&&(e.panDelta=(e.panDelta||new r(0,0))._add(n.panDelta)),n.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+n.zoomDelta),n.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+n.bearingDelta),n.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+n.pitchDelta),void 0!==n.around&&(e.around=n.around),void 0!==n.aroundCoord&&(e.aroundCoord=n.aroundCoord),void 0!==n.pinchAround&&(e.pinchAround=n.pinchAround),n.noInertia&&(e.noInertia=n.noInertia),b(t,o),b(i,a);this._updateMapTransform(e,t,i),this._changes=[]}_updateMapTransform(e,t,i){const r=this._map,n=r.transform,o=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!im(e)){const e=n.zoom;n.cameraElevationReference="sea",n.recenterOnTerrain(),n.cameraElevationReference="ground",e!==n.zoom&&this._map._update(!0)}if(!im(e))return void this._fireEvents(t,i,!0);let{panDelta:a,zoomDelta:s,bearingDelta:l,pitchDelta:c,around:u,aroundCoord:h,pinchAround:p}=e;void 0!==p&&(u=p),(e=>t.drag&&!this._eventsInProgress.drag)()&&u&&(this._dragOrigin=o(n.pointCoordinate3D(u)),this._trackingEllipsoid.setup(n._camera.position,this._dragOrigin)),n.cameraElevationReference="sea",r._stop(!0),u=u||r.transform.centerPoint,l&&(n.bearing+=l),c&&(n.pitch+=c),n._updateCameraState();const d=[0,0,0];if(a)if("mercator"===n.projection.name){const e=this._trackingEllipsoid.projectRay(n.screenPointToMercatorRay(u).dir),t=this._trackingEllipsoid.projectRay(n.screenPointToMercatorRay(u.sub(a)).dir);d[0]=t[0]-e[0],d[1]=t[1]-e[1]}else{const e=n.pointCoordinate(u);if("globe"===n.projection.name){a=a.rotate(-n.angle);const t=n._pixelsPerMercatorPixel/n.worldSize;d[0]=-a.x*Bo(zo(e.y))*t,d[1]=-a.y*Bo(n.center.lat)*t}else{const t=n.pointCoordinate(u.sub(a));e&&t&&(d[0]=t.x-e.x,d[1]=t.y-e.y)}}const f=n.zoom,m=[0,0,0];if(s){const e=o(h||n.pointCoordinate3D(u)),t={dir:Za([],Ja([],e,n._camera.position))};if(t.dir[2]<0){const i=n.zoomDeltaToMovement(e,s);ja(m,t.dir,i)}}const _=Ra(d,d,m);n._translateCameraConstrained(_),s&&Math.abs(n.zoom-f)>1e-4&&n.recenterOnTerrain(),n.cameraElevationReference="ground",this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0)}_fireEvents(e,t,i){const r=tm(this._eventsInProgress),n=tm(e),o={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(o[`${t}start`]=i),this._eventsInProgress[t]=e[t]}!r&&n&&this._fireEvent("movestart",n.originalEvent);for(const e in o)this._fireEvent(e,o[e]);n&&this._fireEvent("move",n.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i)}const a={};let s;for(const e in this._eventsInProgress){const{handlerName:i,originalEvent:r}=this._eventsInProgress[e];this._handlersById[i].isActive()||(delete this._eventsInProgress[e],s=t[i]||r,a[`${e}end`]=s)}for(const e in a)this._fireEvent(e,a[e]);const l=tm(this._eventsInProgress);if(i&&(r||n)&&!l){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),t=e=>0!==e&&-this._bearingSnap<e&&e<this._bearingSnap;e?(t(e.bearing||this._map.getBearing())&&(e.bearing=0),this._map.easeTo(e,{originalEvent:s})):(this._map.fire(new Event("moveend",{originalEvent:s})),t(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(e,t){this._map.fire(new Event(e,t?{originalEvent:t}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((e=>{this._frameId=void 0,this.handleEvent(new RenderFrameEvent("renderFrame",{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const rm="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Camera extends Evented{constructor(e,t){super(),this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=t.bearingSnap,I(["_renderFrameCallback"],this)}getCenter(){return new LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(e,t,i){return e=r.convert(e).mult(-1),this.panTo(this.transform.center,b({offset:e},t),i)}panTo(e,t,i){return this.easeTo(b({center:e},t),i)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,t,i){return this.easeTo(b({zoom:e},t),i)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,t,i){return this.easeTo(b({bearing:e},t),i)}resetNorth(e,t){return this.rotateTo(0,b({duration:1e3},e),t),this}resetNorthPitch(e,t){return this.easeTo(b({bearing:0,pitch:0,duration:1e3},e),t),this}snapToNorth(e,t){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,t):this}getPitch(){return this.transform.pitch}setPitch(e,t){return this.jumpTo({pitch:e},t),this}cameraForBounds(e,t){"globe"===this.transform.projection.name&&B('Globe projection does not support cameraForBounds API, this API may behave unexpectedly."'),e=LngLatBounds.convert(e);const i=t&&t.bearing||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),i,t)}_extendCameraOptions(e){const t={top:0,bottom:0,right:0,left:0};if("number"==typeof(e=b({padding:t,offset:[0,0],maxZoom:this.transform.maxZoom},e)).padding){const t=e.padding;e.padding={top:t,bottom:t,right:t,left:t}}return e.padding=b(t,e.padding),e}_cameraForBoxAndBearing(e,t,i,n){const o=this._extendCameraOptions(n),a=this.transform,s=a.padding,c=a.project(LngLat.convert(e)),u=a.project(LngLat.convert(t)),h=new r(c.x,u.y),p=new r(u.x,c.y),d=-l(i),f=c.rotate(d),m=u.rotate(d),_=h.rotate(d),g=p.rotate(d),y=new r(Math.max(f.x,m.x,_.x,g.x),Math.max(f.y,m.y,_.y,g.y)),x=new r(Math.min(f.x,m.x,_.x,g.x),Math.min(f.y,m.y,_.y,g.y)),v=y.sub(x),b=(a.width-((s.left||0)+(s.right||0)+o.padding.left+o.padding.right))/v.x,w=(a.height-((s.top||0)+(s.bottom||0)+o.padding.top+o.padding.bottom))/v.y;if(w<0||b<0)return void B("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const T=Math.min(a.scaleZoom(a.scale*Math.min(b,w)),o.maxZoom),E="number"==typeof o.offset.x&&"number"==typeof o.offset.y?new r(o.offset.x,o.offset.y):r.convert(o.offset),S=new r((o.padding.left-o.padding.right)/2,(o.padding.top-o.padding.bottom)/2).rotate(i*Math.PI/180),A=E.add(S).mult(a.scale/a.zoomScale(T));return{center:a.unproject(c.add(u).div(2).sub(A)),zoom:T,bearing:i}}_cameraForBox(e,t,i,r,n){const o=this._extendCameraOptions(n);i=i||0,r=r||0,e=LngLat.convert(e),t=LngLat.convert(t);const a=this.transform.clone();a.padding=o.padding;const s=this.getFreeCameraOptions(),l=new LngLat(.5*(e.lng+t.lng),.5*(e.lat+t.lat)),c=.5*(i+r);if(a._camera.position[2]<Po(c,l.lat))return void B("Map cannot fit within canvas with the given bounds, padding, and/or offset.");s.lookAtPoint(l),a.setFreeCameraOptions(s);const u=MercatorCoordinate.fromLngLat(e),h=MercatorCoordinate.fromLngLat(t),p=a.pointRayIntersection(a.centerPoint,c),d=[(f=a.rayIntersectionCoordinate(p)).x,f.y,f.z];var f;const m=a.screenPointToMercatorRay(a.centerPoint),_="globe"!==a.projection.name;let g,y=0;do{const e=Math.floor(a.zoom),t=1<<e,n=Math.min(t*u.x,t*h.x),o=Math.min(t*u.y,t*h.y),s=Math.max(t*u.x,t*h.x),l=Math.max(t*u.y,t*h.y),c=new Aabb([n,o,i],[s,l,r]),p=Frustum.fromInvProjectionMatrix(a.invProjMatrix,a.worldSize,e,_);if(2!==c.intersects(p)){g&&(a._camera.position=Na([],a._camera.position,m.dir,-g),a._updateStateFromCamera());break}g=.5*La(Ja([],a._camera.position,d)),a._camera.position=Na([],a._camera.position,m.dir,g);try{a._updateStateFromCamera()}catch(e){return void B("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}}while(++y<10);return{center:a.center,zoom:a.zoom,bearing:a.bearing,pitch:a.pitch}}fitBounds(e,t,i){return"globe"===this.transform.projection.name&&B("Globe projection does not support fitBounds API, this API may behave unexpectedly."),this._fitInternal(this.cameraForBounds(e,t),t,i)}_raycastElevationBox(e,t){const i=this.transform.elevation;if(!i)return;const n=new r(e.x,t.y),o=new r(t.x,e.y),a=i.pointCoordinate(e);if(!a)return;const s=i.pointCoordinate(t);if(!s)return;const l=i.pointCoordinate(n);if(!l)return;const c=i.pointCoordinate(o);if(!c)return;const u=new MercatorCoordinate(a[0],a[1]).toLngLat(),h=new MercatorCoordinate(s[0],s[1]).toLngLat(),p=new MercatorCoordinate(l[0],l[1]).toLngLat(),d=new MercatorCoordinate(c[0],c[1]).toLngLat(),f=Math.min(u.lng,Math.min(h.lng,Math.min(p.lng,d.lng))),m=Math.min(u.lat,Math.min(h.lat,Math.min(p.lat,d.lat))),_=Math.max(u.lng,Math.max(h.lng,Math.max(p.lng,d.lng))),g=Math.max(u.lat,Math.max(h.lat,Math.max(p.lat,d.lat))),y=Math.min(a[3],Math.min(s[3],Math.min(l[3],c[3]))),x=Math.max(a[3],Math.max(s[3],Math.max(l[3],c[3])));return{minLngLat:new LngLat(f,m),maxLngLat:new LngLat(_,g),minAltitude:y,maxAltitude:x}}fitScreenCoordinates(e,t,i,n,o){let a,s,l,c;"globe"===this.transform.projection.name&&B("Globe projection does not support fitScreenCoordinates API, this API may behave unexpectedly.");const u=r.convert(e),h=r.convert(t),p=this._raycastElevationBox(u,h);if(p)a=p.minLngLat,s=p.maxLngLat,l=p.minAltitude,c=p.maxAltitude;else{if(this.transform.anyCornerOffEdge(u,h))return this;a=this.transform.pointLocation(u),s=this.transform.pointLocation(h)}return this._fitInternal(0===this.transform.pitch?this._cameraForBoxAndBearing(this.transform.pointLocation(r.convert(e)),this.transform.pointLocation(r.convert(t)),i,n):this._cameraForBox(a,s,l,c,n),n,o)}_fitInternal(e,t,i){return e?(delete(t=b(e,t)).padding,t.linear?this.easeTo(t,i):this.flyTo(t,i)):this}jumpTo(e,t){this.stop();const i=e.preloadOnly?this.transform.clone():this.transform;let r=!1,n=!1,o=!1;return"zoom"in e&&i.zoom!==+e.zoom&&(r=!0,i.zoom=+e.zoom),void 0!==e.center&&(i.center=LngLat.convert(e.center)),"bearing"in e&&i.bearing!==+e.bearing&&(n=!0,i.bearing=+e.bearing),"pitch"in e&&i.pitch!==+e.pitch&&(o=!0,i.pitch=+e.pitch),null==e.padding||i.isPaddingEqual(e.padding)||(i.padding=e.padding),e.preloadOnly?(this._preloadTiles(i),this):(this.fire(new Event("movestart",t)).fire(new Event("move",t)),r&&this.fire(new Event("zoomstart",t)).fire(new Event("zoom",t)).fire(new Event("zoomend",t)),n&&this.fire(new Event("rotatestart",t)).fire(new Event("rotate",t)).fire(new Event("rotateend",t)),o&&this.fire(new Event("pitchstart",t)).fire(new Event("pitch",t)).fire(new Event("pitchend",t)),this.fire(new Event("moveend",t)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||B(rm),this.transform.getFreeCameraOptions()}setFreeCameraOptions(e,t){const i=this.transform;if(!i.projection.supportsFreeCamera)return B(rm),this;this.stop();const r=i.zoom,n=i.pitch,o=i.bearing;i.setFreeCameraOptions(e);const a=r!==i.zoom,s=n!==i.pitch,l=o!==i.bearing;return this.fire(new Event("movestart",t)).fire(new Event("move",t)),a&&this.fire(new Event("zoomstart",t)).fire(new Event("zoom",t)).fire(new Event("zoomend",t)),l&&this.fire(new Event("rotatestart",t)).fire(new Event("rotate",t)).fire(new Event("rotateend",t)),s&&this.fire(new Event("pitchstart",t)).fire(new Event("pitch",t)).fire(new Event("pitchend",t)),this.fire(new Event("moveend",t)),this}easeTo(e,t){this._stop(!1,e.easeId),(!1===(e=b({offset:[0,0],duration:500,easing:m},e)).animate||!e.essential&&ee.prefersReducedMotion)&&(e.duration=0);const i=this.transform,n=this.getZoom(),o=this.getBearing(),a=this.getPitch(),s=this.getPadding(),l="zoom"in e?+e.zoom:n,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,u="pitch"in e?+e.pitch:a,h="padding"in e?e.padding:i.padding,p=r.convert(e.offset);let d,f,_;if("globe"===i.projection.name){const t=MercatorCoordinate.fromLngLat(i.center),n=p.rotate(-i.angle);t.x+=n.x/i.worldSize,t.y+=n.y/i.worldSize;const o=t.toLngLat(),a=LngLat.convert(e.center||o);this._normalizeCenter(a),d=i.centerPoint.add(n),f=new r(t.x,t.y).mult(i.worldSize),_=new r(Io(a.lng),Mo(a.lat)).mult(i.worldSize).sub(f)}else{d=i.centerPoint.add(p);const t=i.pointLocation(d),r=LngLat.convert(e.center||t);this._normalizeCenter(r),f=i.project(t),_=i.project(r).sub(f)}const g=i.zoomScale(l-n);let y,x;e.around&&(y=LngLat.convert(e.around),x=i.locationPoint(y));const v=this._zooming||l!==n,w=this._rotating||o!==c,T=this._pitching||u!==a,E=!i.isPaddingEqual(h),S=i=>r=>{if(v&&(i.zoom=xi(n,l,r)),w&&(i.bearing=xi(o,c,r)),T&&(i.pitch=xi(a,u,r)),E&&(i.interpolatePadding(s,h,r),d=i.centerPoint.add(p)),y)i.setLocationAtPoint(y,x);else{const e=i.zoomScale(i.zoom-n),t=l>n?Math.min(2,g):Math.max(.5,g),o=Math.pow(t,1-r),a=i.unproject(f.add(_.mult(r*o)).mult(e));i.setLocationAtPoint(i.renderWorldCopies?a.wrap():a,d)}return e.preloadOnly||this._fireMoveEvents(t),i};if(e.preloadOnly){const t=this._emulate(S,e.duration,i);return this._preloadTiles(t),this}const A={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=v,this._rotating=w,this._pitching=T,this._padding=E,this._easeId=e.easeId,this._prepareEase(t,e.noMoveStart,A),this._ease(S(i),(e=>{i.recenterOnTerrain(),this._afterEase(t,e)}),e),this}_prepareEase(e,t,i={}){this._moving=!0,this.transform.cameraElevationReference="sea",t||i.moving||this.fire(new Event("movestart",e)),this._zooming&&!i.zooming&&this.fire(new Event("zoomstart",e)),this._rotating&&!i.rotating&&this.fire(new Event("rotatestart",e)),this._pitching&&!i.pitching&&this.fire(new Event("pitchstart",e))}_fireMoveEvents(e){this.fire(new Event("move",e)),this._zooming&&this.fire(new Event("zoom",e)),this._rotating&&this.fire(new Event("rotate",e)),this._pitching&&this.fire(new Event("pitch",e))}_afterEase(e,t){if(this._easeId&&t&&this._easeId===t)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const i=this._zooming,r=this._rotating,n=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,i&&this.fire(new Event("zoomend",e)),r&&this.fire(new Event("rotateend",e)),n&&this.fire(new Event("pitchend",e)),this.fire(new Event("moveend",e))}flyTo(e,t){if(!e.essential&&ee.prefersReducedMotion){const i=w(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(i,t)}this.stop(),e=b({offset:[0,0],speed:1.2,curve:1.42,easing:m},e);const i=this.transform,n=this.getZoom(),o=this.getBearing(),a=this.getPitch(),s=this.getPadding(),l="zoom"in e?_(+e.zoom,i.minZoom,i.maxZoom):n,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,u="pitch"in e?+e.pitch:a,h="padding"in e?e.padding:i.padding,p=i.zoomScale(l-n),d=r.convert(e.offset);let f=i.centerPoint.add(d);const g=i.pointLocation(f),y=LngLat.convert(e.center||g);this._normalizeCenter(y);const x=i.project(g),v=i.project(y).sub(x);let T=e.curve;const E=Math.max(i.width,i.height),S=E/p,A=v.mag();if("minZoom"in e){const t=_(Math.min(e.minZoom,n,l),i.minZoom,i.maxZoom),r=E/i.zoomScale(t-n);T=Math.sqrt(r/A*2)}const C=T*T;function I(e){const t=(S*S-E*E+(e?-1:1)*C*C*A*A)/(2*(e?S:E)*C*A);return Math.log(Math.sqrt(t*t+1)-t)}function M(e){return(Math.exp(e)-Math.exp(-e))/2}function P(e){return(Math.exp(e)+Math.exp(-e))/2}const D=I(0);let z=function(e){return P(D)/P(D+T*e)},k=function(e){return E*((P(D)*(M(t=D+T*e)/P(t))-M(D))/C)/A;var t},L=(I(1)-D)/T;if(Math.abs(A)<1e-6||!isFinite(L)){if(Math.abs(E-S)<1e-6)return this.easeTo(e,t);const i=S<E?-1:1;L=Math.abs(Math.log(S/E))/T,k=function(){return 0},z=function(e){return Math.exp(i*T*e)}}e.duration="duration"in e?+e.duration:1e3*L/("screenSpeed"in e?+e.screenSpeed/T:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0);const B=o!==c,R=u!==a,F=!i.isPaddingEqual(h),O=i=>r=>{const p=r*L,m=1/z(p);i.zoom=1===r?l:n+i.scaleZoom(m),B&&(i.bearing=xi(o,c,r)),R&&(i.pitch=xi(a,u,r)),F&&(i.interpolatePadding(s,h,r),f=i.centerPoint.add(d));const _=1===r?y:i.unproject(x.add(v.mult(k(p))).mult(m));return i.setLocationAtPoint(i.renderWorldCopies?_.wrap():_,f),i._updateCameraOnTerrain(),e.preloadOnly||this._fireMoveEvents(t),i};if(e.preloadOnly){const t=this._emulate(O,e.duration,i);return this._preloadTiles(t),this}return this._zooming=!0,this._rotating=B,this._pitching=R,this._padding=F,this._prepareEase(t,!1),this._ease(O(i),(()=>this._afterEase(t)),e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const e=this._onEaseEnd;this._onEaseEnd=void 0,e.call(this,t)}if(!e){const e=this.handlers;e&&e.stop(!1)}return this}_ease(e,t,i){!1===i.animate||0===i.duration?(e(1),t()):(this._easeStart=ee.now(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const e=Math.min((ee.now()-this._easeStart)/this._easeOptions.duration,1),t=this._onEaseFrame;t&&t(this._easeOptions.easing(e)),e<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(e,t){e=y(e,-180,180);const i=Math.abs(e-t);return Math.abs(e-360-t)<i&&(e-=360),Math.abs(e+360-t)<i&&(e+=360),e}_normalizeCenter(e){const t=this.transform;if(!t.renderWorldCopies||t.maxBounds)return;const i=e.lng-t.center.lng;e.lng+=i>180?-360:i<-180?360:0}_emulate(e,t,i){const r=Math.ceil(15*t/1e3),n=[],o=e(i.clone());for(let e=0;e<=r;e++){const t=o(e/r);n.push(t.clone())}return n}}class AttributionControl{constructor(e={}){this.options=e,I(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(e){const t=this.options&&this.options.compact;return this._map=e,this._container=te("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=te("button","mapboxgl-ctrl-attrib-button",this._container),te("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=te("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),t&&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===t&&(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(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.setAttribute("aria-label",i),e.removeAttribute("title"),e.firstElementChild&&e.firstElementChild.setAttribute("title",i)}_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 e=this._editLink;e||(e=this._editLink=this._container.querySelector(".mapbox-improve-map"));const t=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||me.ACCESS_TOKEN}];if(e){const i=t.reduce(((e,i,r)=>(i.value&&(e+=`${i.key}=${i.value}${r<t.length-1?"&":""}`),e)),"?");e.href=`${me.FEEDBACK_URL}/${i}#${Of(this._map,!0)}`,e.rel="noopener nofollow",this._setElementTitle(e,"MapFeedback")}}_updateData(e){!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let e=[];if(this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}const t=this._map.style._sourceCaches;for(const i in t){const r=t[i];if(r.used){const t=r.getSource();t.attribution&&e.indexOf(t.attribution)<0&&e.push(t.attribution)}}e.sort(((e,t)=>e.length-t.length)),e=e.filter(((t,i)=>{for(let r=i+1;r<e.length;r++)if(e[r].indexOf(t)>=0)return!1;return!0})),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[...this.options.customAttribution,...e]:e.unshift(this.options.customAttribution));const i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=i,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 LogoControl{constructor(){I(["_updateLogo","_updateCompact"],this)}onAdd(e){this._map=e,this._container=te("div","mapboxgl-ctrl");const t=te("a","mapboxgl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://www.mapbox.com/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),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(e){e&&"metadata"!==e.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const e=this._map.style._sourceCaches;if(0===Object.entries(e).length)return!0;for(const t in e){const i=e[t].getSource();if(i.hasOwnProperty("mapbox_logo")&&!i.mapbox_logo)return!1}return!0}_updateCompact(){const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<250?t.classList.add("mapboxgl-compact"):t.classList.remove("mapboxgl-compact")}}}class TaskQueue{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function nm(e,t,i){if(e=new LngLat(e.lng,e.lat),t){const r=new LngLat(e.lng-360,e.lat),n=new LngLat(e.lng+360,e.lat),o=360*Math.ceil(Math.abs(e.lng-i.center.lng)/360),a=i.locationPoint(e).distSqr(t),s=t.x<0||t.y<0||t.x>i.width||t.y>i.height;i.locationPoint(r).distSqr(t)<a&&(s||Math.abs(r.lng-i.center.lng)<o)?e=r:i.locationPoint(n).distSqr(t)<a&&(s||Math.abs(n.lng-i.center.lng)<o)&&(e=n)}for(;Math.abs(e.lng-i.center.lng)>180;){const t=i.locationPoint(e);if(t.x>=0&&t.y>=0&&t.x<=i.width&&t.y<=i.height)break;e.lng>i.center.lng?e.lng-=360:e.lng+=360}return e}const om={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 Marker extends Evented{constructor(t,i){if(super(),(t instanceof e.HTMLElement||i)&&(t=b({element:t},i)),I(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),t&&t.element)this._element=t.element,this._offset=r.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=te("div");const e=41,i=27,n=ie("svg",{display:"block",height:e*this._scale+"px",width:i*this._scale+"px",viewBox:`0 0 ${i} ${e}`},this._element),o=ie("radialGradient",{id:"shadowGradient"},ie("defs",{},n));ie("stop",{offset:"10%","stop-opacity":.4},o),ie("stop",{offset:"100%","stop-opacity":.05},o),ie("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},n),ie("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"},n),ie("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"},n),ie("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},n),this._offset=r.convert(t&&t.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",(e=>{e.preventDefault()})),this._element.addEventListener("mousedown",(e=>{e.preventDefault()}));const n=this._element.classList;for(const e in om)n.remove(`mapboxgl-marker-anchor-${e}`);n.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(e){return e===this._map||(this.remove(),this._map=e,e.getCanvasContainer().appendChild(this._element),e.on("move",this._updateMoving),e.on("moveend",this._update),e.on("remove",this._clearFadeTimer),e._addMarker(this),this.setDraggable(this._draggable),this._update(),e.on("click",this._onMapClick)),this}remove(){const e=this._map;return e&&(e.off("click",this._onMapClick),e.off("move",this._updateMoving),e.off("moveend",this._update),e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler),e.off("mouseup",this._onUp),e.off("touchend",this._onUp),e.off("mousemove",this._onMove),e.off("touchmove",this._onMove),e.off("remove",this._clearFadeTimer),e._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=LngLat.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(e){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")),e){if(!("offset"in e.options)){const t=38.1,i=13.5,r=Math.sqrt(Math.pow(i,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[r,-1*(t-i+r)],"bottom-right":[-r,-1*(t-i+r)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset}this._popup=e,e._marker=this,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(e){const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup()}_onMapClick(e){const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const e=this._popup;return e?(e.isOpen()?(e.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(e.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const e=this._map;if(!e)return!1;const t=e.unproject(this._pos),i=e.getFreeCameraOptions();if(!i.position)return!1;const r=i.position.toLngLat();return r.distanceTo(t)<.9*r.distanceTo(this._lngLat)}_evaluateOpacity(){const e=this._map;if(!e)return;const t=this._pos;if(!t||t.x<0||t.x>e.transform.width||t.y<0||t.y>e.transform.height)return void this._clearFadeTimer();const i=e.unproject(t);let r;e._showingGlobe()&&Tu(e.transform,this._lngLat)?r=0:(r=1-e._queryFogOpacity(i),e.transform._terrainEnabled()&&e.getTerrain()&&this._behindTerrain()&&(r*=.2)),this._element.style.opacity=`${r}`,this._element.style.pointerEvents=r>0?"auto":"none",this._popup&&this._popup._setOpacity(r),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const e=this._pos;if(!e||!this._map)return;const t=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${e.x}px,${e.y}px)\n ${om[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `}_calculateXYTransform(){const e=this._pos,t=this._map,i=this.getPitchAlignment();if(!t||!e||"map"!==i)return"";if(!t._showingGlobe()){const e=t.getPitch();return e?`rotateX(${e}deg)`:""}const r=c(wu(t.transform,this._lngLat)),n=e.sub(bu(t.transform)),o=Math.abs(n.x)+Math.abs(n.y);if(0===o)return"";const a=r/o;return`rotateX(${-n.y*a}deg) rotateY(${n.x*a}deg)`}_calculateZTransform(){const e=this._pos,t=this._map;if(!t||!e)return"";let i=0;const r=this.getRotationAlignment();if("map"===r)if(t._showingGlobe()){const e=t.project(new LngLat(this._lngLat.lng,this._lngLat.lat+.001)),r=t.project(new LngLat(this._lngLat.lng,this._lngLat.lat-.001)).sub(e);i=c(Math.atan2(r.y,r.x))-90}else i=-t.getBearing();else if("horizon"===r){const r=g(4,6,t.getZoom()),n=bu(t.transform);n.y+=r*t.transform.height;const o=e.sub(n),a=c(Math.atan2(o.y,o.x));i=(a>90?a-270:a+90)*(1-r)}return i+=this._rotation,i?`rotateZ(${i}deg)`:""}_update(t){e.cancelAnimationFrame(this._updateFrameId);const i=this._map;i&&(i.transform.renderWorldCopies&&(this._lngLat=nm(this._lngLat,this._pos,i.transform)),this._pos=i.project(this._lngLat),!0===t?this._updateFrameId=e.requestAnimationFrame((()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())})):this._pos=this._pos.round(),i._requestDomTask((()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(i._showingGlobe()||i.getTerrain()||i.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))})))}getOffset(){return this._offset}setOffset(e){return this._offset=r.convert(e),this._update(),this}_onMove(e){const t=this._map;if(t){if(!this._isDragging){const i=this._clickTolerance||t._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=i}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=t.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new Event("dragstart"))),this.fire(new Event("drag")))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const e=this._map;e&&(e.off("mousemove",this._onMove),e.off("touchmove",this._onMove)),"active"===this._state&&this.fire(new Event("dragend")),this._state="inactive"}_addDragHandler(e){const t=this._map;t&&this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos),this._pointerdownPos=e.point,this._state="pending",t.on("mousemove",this._onMove),t.on("touchmove",this._onMove),t.once("mouseup",this._onUp),t.once("touchend",this._onUp))}setDraggable(e){this._draggable=!!e;const t=this._map;return t&&(e?(t.on("mousedown",this._addDragHandler),t.on("touchstart",this._addDragHandler)):(t.off("mousedown",this._addDragHandler),t.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return"auto"===this._rotationAlignment||"horizon"===this._rotationAlignment&&this._map&&!this._map._showingGlobe()?"viewport":this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e||"auto",this._update(),this}getPitchAlignment(){return"auto"===this._pitchAlignment?this.getRotationAlignment():this._pitchAlignment}}class EasedVariable{constructor(e){this.jumpTo(e)}getValue(e){if(e<=this._startTime)return this._start;if(e>=this._endTime)return this._end;const t=h((e-this._startTime)/(this._endTime-this._startTime));return this._start*(1-t)+this._end*t}isEasing(e){return e>=this._startTime&&e<=this._endTime}jumpTo(e){this._startTime=-1/0,this._endTime=-1/0,this._start=e,this._end=e}easeTo(e,t,i){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+i}}const am={"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","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","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"},sm={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,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,crossSourceCollisions:!0};function lm(e){e.parentNode&&e.parentNode.removeChild(e)}const cm={showCompass:!0,showZoom:!0,visualizePitch:!1};class MouseRotateWrapper{constructor(e,t,i=!1){this._clickTolerance=10,this.element=t,this.mouseRotate=new MouseRotateHandler({clickTolerance:e.dragRotate._mouseRotate._clickTolerance}),this.map=e,i&&(this.mousePitch=new MousePitchHandler({clickTolerance:e.dragRotate._mousePitch._clickTolerance})),I(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),t.addEventListener("mousedown",this.mousedown),t.addEventListener("touchstart",this.touchstart,{passive:!1}),t.addEventListener("touchmove",this.touchmove),t.addEventListener("touchend",this.touchend),t.addEventListener("touchcancel",this.reset)}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),se()}move(e,t){const i=this.map,r=this.mouseRotate.mousemoveWindow(e,t),n=r&&r.bearingDelta;if(n&&i.setBearing(i.getBearing()+n),this.mousePitch){const r=this.mousePitch.mousemoveWindow(e,t),n=r&&r.pitchDelta;n&&i.setPitch(i.getPitch()+n)}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart,{passive:!1}),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){le(),e.removeEventListener("mousemove",this.mousemove),e.removeEventListener("mouseup",this.mouseup)}mousedown(t){this.down(b({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),he(this.element,t)),e.addEventListener("mousemove",this.mousemove),e.addEventListener("mouseup",this.mouseup)}mousemove(e){this.move(e,he(this.element,e))}mouseup(e){this.mouseRotate.mouseupWindow(e),this.mousePitch&&this.mousePitch.mouseupWindow(e),this.offTemp()}touchstart(e){1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=pe(this.element,e.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>e.preventDefault()},this._startPos))}touchmove(e){1!==e.targetTouches.length?this.reset():(this._lastPos=pe(this.element,e.targetTouches)[0],this.move({preventDefault:()=>e.preventDefault()},this._lastPos))}touchend(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}const um={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},hm={maxWidth:100,unit:"metric"};function pm(e,t,i){const r=dm(t),n=r/t,o={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"}[i];this._map._requestDomTask((()=>{this._container.style.width=e*n+"px",this._container.innerHTML=`${r} ${o}`}))}function dm(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}const fm={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},mm=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function _m(e=new r(0,0),t="bottom"){if("number"==typeof e){const i=Math.round(Math.sqrt(.5*Math.pow(e,2)));switch(t){case"top":return new r(0,e);case"top-left":return new r(i,i);case"top-right":return new r(-i,i);case"bottom":return new r(0,-e);case"bottom-left":return new r(i,-i);case"bottom-right":return new r(-i,-i);case"left":return new r(e,0);case"right":return new r(-e,0)}return new r(0,0)}return e instanceof r||Array.isArray(e)?r.convert(e):r.convert(e[t]||[0,0])}const gm={version:X,supported:$,setRTLTextPlugin:function(e,t,i=!1){if(Zn===Un||Zn===jn||Zn===Nn)throw new Error("setRTLTextPlugin cannot be called multiple times.");qn=ee.resolveURL(e),Zn=Un,Gn=t,Wn(),i||Kn()},getRTLTextPluginStatus:Xn,Map:class Map$1 extends Camera{constructor(t){if(null!=(t=b({},sm,t)).minZoom&&null!=t.maxZoom&&t.minZoom>t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(t.antialias&&function(e){const t=e.navigator?e.navigator.userAgent:null;return!!j(e)&&t&&(t.match("Version/15.4")||t.match("Version/15.5")||t.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))}(e)&&(t.antialias=!1,B("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Transform(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),t),this._interactive=t.interactive,this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=t.collectResourceTiming,this._optimizeForTerrain=t.optimizeForTerrain,this._language="auto"===t.language?e.navigator.language:t.language,this._worldview=t.worldview,this._renderTaskQueue=new TaskQueue,this._domRenderTaskQueue=new TaskQueue,this._controls=[],this._markers=[],this._mapId=E(),this._locale=b({},am,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new EasedVariable(0),this._useExplicitProjection=!1,this._requestManager=new RequestManager(t.transformRequest,t.accessToken,t.testMode),this._silenceAuthErrors=!!t.testMode,"string"==typeof t.container){if(this._container=e.document.getElementById(t.container),!this._container)throw new Error(`Container '${t.container}' not found.`)}else{if(!(t.container instanceof e.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(this._container.childNodes.length>0&&B("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."),t.maxBounds&&this.setMaxBounds(t.maxBounds),I(["_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!==e&&(e.addEventListener("online",this._onWindowOnline,!1),e.addEventListener("resize",this._onWindowResize,!1),e.addEventListener("orientationchange",this._onWindowResize,!1),e.addEventListener("webkitfullscreenchange",this._onWindowResize,!1)),this.handlers=new HandlerManager(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,t.style&&this.setStyle(t.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),t.projection&&this.setProjection(t.projection),this._hash=t.hash&&new Hash("string"==typeof t.hash&&t.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,b({},t.fitBoundsOptions,{duration:0})))),this.resize(),t.attributionControl&&this.addControl(new AttributionControl({customAttribution:t.customAttribution})),this._logoControl=new LogoControl,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new Event(`${e.dataType}data`,e))})),this.on("dataloading",(e=>{this.fire(new Event(`${e.dataType}dataloading`,e))}))}_getMapId(){return this._mapId}addControl(e,t){if(void 0===t&&(t=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const i=e.onAdd(this);this._controls.push(e);const r=this._controlPositions[t];return-1!==t.indexOf("bottom")?r.insertBefore(i,r.firstChild):r.appendChild(i),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const t=this._controls.indexOf(e);return t>-1&&this._controls.splice(t,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(e){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 t=!this._moving;return t&&this.fire(new Event("movestart",e)).fire(new Event("move",e)),this.fire(new Event("resize",e)),t&&this.fire(new Event("moveend",e)),this}getBounds(){return"globe"===this.transform.projection.name&&B('Globe projection does not support getBounds API, this API may behave unexpectedly."'),this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(e){return this.transform.setMaxBounds(LngLatBounds.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.minZoom=e,this._update(),this.getZoom()<e?this.setZoom(e):this.fire(new Event("zoomstart")).fire(new Event("zoom")).fire(new Event("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(e){if((e=null==e?22:e)>=this.transform.minZoom)return this.transform.maxZoom=e,this._update(),this.getZoom()>e?this.setZoom(e):this.fire(new Event("zoomstart")).fire(new Event("zoom")).fire(new Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.minPitch=e,this._update(),this.getPitch()<e?this.setPitch(e):this.fire(new Event("pitchstart")).fire(new Event("pitch")).fire(new Event("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(e){if((e=null==e?85:e)>85)throw new Error("maxPitch must be less than or equal to 85");if(e>=this.transform.minPitch)return this.transform.maxPitch=e,this._update(),this.getPitch()>e?this.setPitch(e):this.fire(new Event("pitchstart")).fire(new Event("pitch")).fire(new Event("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.renderWorldCopies=e,this._update()}getLanguage(){return this._language}setLanguage(t){if(this._language="auto"===t?e.navigator.language:t,this.style)for(const e in this.style._sourceCaches){const t=this.style._sourceCaches[e]._source;t._setLanguage&&t._setLanguage(this._language)}for(const e of this._controls)e._setLanguage&&e._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(e){if(this._worldview=e,this.style)for(const t in this.style._sourceCaches){const i=this.style._sourceCaches[t]._source;i._setWorldview&&i._setWorldview(e)}return this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return"globe"===this.transform.projection.name}setProjection(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._useExplicitProjection=!!e,this._prioritizeAndUpdateProjection(e,this.style.stylesheet?this.style.stylesheet.projection:null)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const e=this.transform,t=e.projection.name;let i;"globe"===t&&e.zoom>=6?(e.setMercatorFromTransition(),i=!0):"mercator"===t&&e.zoom<6&&(e.setProjection({name:"globe"}),i=!0),i&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayerUpdate())}_prioritizeAndUpdateProjection(e,t){return this._updateProjection(e||t||{name:"mercator"})}_updateProjection(e){let t;if(t="globe"===e.name&&this.transform.zoom>=6?this.transform.setMercatorFromTransition():this.transform.setProjection(e),this.style.applyProjectionUpdate(),t){this.painter.clearBackgroundTiles();for(const e in this.style._sourceCaches)this.style._sourceCaches[e].clearTiles();this._update(!0)}return this}project(e){return this.transform.locationPoint3D(LngLat.convert(e))}unproject(e){return this.transform.pointLocation3D(r.convert(e))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let r=!1;const n=n=>{const o=t.filter((e=>this.getLayer(e))),a=o.length?this.queryRenderedFeatures(n.point,{layers:o}):[];a.length?r||(r=!0,i.call(this,new MapMouseEvent(e,this,n.originalEvent,{features:a}))):r=!1},o=()=>{r=!1};return{layers:new Set(t),listener:i,delegates:{mousemove:n,mouseout:o}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const n=n=>{const o=t.filter((e=>this.getLayer(e)));(o.length?this.queryRenderedFeatures(n.point,{layers:o}):[]).length?r=!0:r&&(r=!1,i.call(this,new MapMouseEvent(e,this,n.originalEvent)))},o=t=>{r&&(r=!1,i.call(this,new MapMouseEvent(e,this,t.originalEvent)))};return{layers:new Set(t),listener:i,delegates:{mousemove:n,mouseout:o}}}{const r=e=>{const r=t.filter((e=>this.getLayer(e))),n=r.length?this.queryRenderedFeatures(e.point,{layers:r}):[];n.length&&(e.features=n,i.call(this,e),delete e.features)};return{layers:new Set(t),listener:i,delegates:{[e]:r}}}}on(e,t,i){if(void 0===i)return super.on(e,t);Array.isArray(t)||(t=[t]);const r=this._createDelegatedListener(e,t,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(r);for(const e in r.delegates)this.on(e,r.delegates[e]);return this}once(e,t,i){if(void 0===i)return super.once(e,t);Array.isArray(t)||(t=[t]);const r=this._createDelegatedListener(e,t,i);for(const e in r.delegates)this.once(e,r.delegates[e]);return this}off(e,t,i){if(void 0===i)return super.off(e,t);t=new Set(Array.isArray(t)?t:[t]);const r=(e,t)=>{if(e.size!==t.size)return!1;for(const i of e)if(!t.has(i))return!1;return!0},n=this._delegatedListeners?this._delegatedListeners[e]:void 0;return n&&(e=>{for(let n=0;n<e.length;n++){const o=e[n];if(o.listener===i&&r(o.layers,t)){for(const e in o.delegates)this.off(e,o.delegates[e]);return e.splice(n,1),this}}})(n),this}queryRenderedFeatures(e,t){return this.style?(void 0!==t||void 0===e||e instanceof r||Array.isArray(e)||(t=e,e=void 0),this.style.queryRenderedFeatures(e=e||[[0,0],[this.transform.width,this.transform.height]],t=t||{},this.transform)):[]}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}queryTerrainElevation(e,t){const i=this.transform.elevation;return i?(t=b({},{exaggerated:!0},t),i.getAtPoint(MercatorCoordinate.fromLngLat(e),null,t.exaggerated)):null}setStyle(e,t){return!1!==(t=b({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},t)).diff&&t.localIdeographFontFamily===this._localIdeographFontFamily&&t.localFontFamily===this._localFontFamily&&this.style&&e?(this._diffStyle(e,t),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._localFontFamily=t.localFontFamily,this._updateStyle(e,t))}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){return this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),e&&(this.style=new Style(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e):this.style.loadJSON(e)),this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Style(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,t){if("string"==typeof e){const i=this._requestManager.normalizeStyleURL(e),r=this._requestManager.transformRequest(i,Xe.Style);Ye(r,((e,i)=>{e?this.fire(new ErrorEvent(e)):i&&this._updateDiff(i,t)}))}else"object"==typeof e&&this._updateDiff(e,t)}_updateDiff(e,t){try{this.style.setState(e)&&this._update(!0)}catch(i){B(`Unable to perform style diff: ${i.message||i.error||i}. Rebuilding the style from scratch.`),this._updateStyle(e,t)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(B("There is no style added to the map."),!1)}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){return!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){const e=this.style&&this.style._sourceCaches;for(const t in e){const i=e[t]._tiles;for(const e in i){const t=i[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}}return!0}addSourceType(e,t,i){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,i)}removeSource(e){return this.style.removeSource(e),this._updateTerrain(),this._update(!0)}getSource(e){return this.style.getSource(e)}addImage(t,i,{pixelRatio:r=1,sdf:n=!1,stretchX:o,stretchY:a,content:s}={}){if(this._lazyInitEmptyStyle(),i instanceof e.HTMLImageElement||e.ImageBitmap&&i instanceof e.ImageBitmap){const{width:e,height:l,data:c}=ee.getImageData(i);this.style.addImage(t,{data:new RGBAImage({width:e,height:l},c),pixelRatio:r,stretchX:o,stretchY:a,content:s,sdf:n,version:0})}else if(void 0===i.width||void 0===i.height)this.fire(new 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`")));else{const{width:e,height:l}=i,c=i;this.style.addImage(t,{data:new RGBAImage({width:e,height:l},new Uint8Array(c.data)),pixelRatio:r,stretchX:o,stretchY:a,content:s,sdf:n,version:0,userImage:c}),c.onAdd&&c.onAdd(this,t)}}updateImage(t,i){const r=this.style.getImage(t);if(!r)return void this.fire(new ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const n=i instanceof e.HTMLImageElement||e.ImageBitmap&&i instanceof e.ImageBitmap?ee.getImageData(i):i,{width:o,height:a}=n;void 0!==o&&void 0!==a?o===r.data.width&&a===r.data.height?(r.data.replace(n.data,!(i instanceof e.HTMLImageElement||e.ImageBitmap&&i instanceof e.ImageBitmap)),this.style.updateImage(t,r)):this.fire(new ErrorEvent(new Error(`The width and height of the updated image (${o}, ${a})\n must be that same as the previous version of the image\n (${r.data.width}, ${r.data.height})`))):this.fire(new 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`")))}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(t,i){at(this._requestManager.transformRequest(t,Xe.Image),((t,r)=>{i(t,r instanceof e.HTMLImageElement?ee.getImageData(r):r)}))}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}setLayerZoomRange(e,t,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){return this.style.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,r={}){return this.style.setPaintProperty(e,t,i,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,r={}){return this.style.setLayoutProperty(e,t,i,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(e){return this._lazyInitEmptyStyle(),!e&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(e),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(e){return this._lazyInitEmptyStyle(),this.style.setFog(e),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(e){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(LngLat.convert(e),this.transform):0}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}_updateContainerDimensions(){if(!this._container)return;const t=this._container.getBoundingClientRect().width||400,i=this._container.getBoundingClientRect().height||300;let r,n,o,a=this._container;for(;a&&(!n||!o);){const t=e.getComputedStyle(a).transform;t&&"none"!==t&&(r=t.match(/matrix.*\((.+)\)/)[1].split(", "),r[0]&&"0"!==r[0]&&"1"!==r[0]&&(n=r[0]),r[3]&&"0"!==r[3]&&"1"!==r[3]&&(o=r[3])),a=a.parentElement}this._containerWidth=n?Math.abs(t/n):t,this._containerHeight=o?Math.abs(i/o):i}_detectMissingCSS(){"rgb(250, 128, 114)"!==e.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&B("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 e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=te("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=te("div","mapboxgl-canvas-container",e);this._interactive&&t.classList.add("mapboxgl-interactive"),this._canvas=te("canvas","mapboxgl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const i=this._controlContainer=te("div","mapboxgl-control-container",e),r=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{r[e]=te("div",`mapboxgl-ctrl-${e}`,i)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,t){const i=ee.devicePixelRatio||1;this._canvas.width=i*Math.ceil(e),this._canvas.height=i*Math.ceil(t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`}_addMarker(e){this._markers.push(e)}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1)}_setupPainter(){const e=b({},$.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),t=this._canvas.getContext("webgl",e)||this._canvas.getContext("experimental-webgl",e);t?(Fe(t,!0),this.painter=new Painter(t,this.transform),this.on("data",(e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)})),_e.testSupport(t)):this.fire(new ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(e){e.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new Event("webglcontextlost",{originalEvent:e}))}_contextRestored(e){this._setupPainter(),this.resize(),this._update(),this.fire(new Event("webglcontextrestored",{originalEvent:e}))}_onMapScroll(e){if(e.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(e){return this.style?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_requestDomTask(e){!this.loaded()||this.loaded()&&!this.isMoving()?e():this._domRenderTaskQueue.add(e)}_render(t){let i;const r=this.painter.context.extTimerQuery,n=ee.now();if(this.listens("gpu-timing-frame")&&(i=r.createQueryEXT(),r.beginQueryEXT(r.TIME_ELAPSED_EXT,i)),this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;this._updateProjectionTransition();let o=!1;const a=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,t=this.transform.pitch,i=ee.now();this.style.zoomHistory.update(e,i);const r=new EvaluationParameters(e,{now:i,fadeDuration:a,pitch:t,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),n=r.crossFadingFactor();1===n&&n===this._crossFadingFactor||(o=!0,this._crossFadingFactor=n),this.style.update(r)}this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let s=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),s=this._updateAverageElevation(n),this.style._updateSources(this.transform),this._forceMarkerUpdate()):s=this._updateAverageElevation(n),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,a,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:a,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new Event("load"))),this.style&&(this.style.hasTransitions()||o)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),i){const t=ee.now()-n;r.endQueryEXT(r.TIME_ELAPSED_EXT,i),setTimeout((()=>{const o=r.getQueryObjectEXT(i,r.QUERY_RESULT_EXT)/1e6;r.deleteQueryEXT(i),this.fire(new Event("gpu-timing-frame",{cpuTime:t,gpuTime:o})),e.performance.mark("frame-gpu",{startTime:n,detail:{gpuTime:o}})}),50)}if(this.listens("gpu-timing-layer")){const e=this.painter.collectGpuTimers();setTimeout((()=>{const t=this.painter.queryGpuTimers(e);this.fire(new Event("gpu-timing-layer",{layerTimes:t}))}),50)}if(this.listens("gpu-timing-deferred-render")){const e=this.painter.collectDeferredRenderGpuQueries();setTimeout((()=>{const t=this.painter.queryGpuTimeDeferredRender(e);this.fire(new Event("gpu-timing-deferred-render",{gpuTime:t}))}),50)}const l=this._sourcesDirty||this._styleDirty||this._placementDirty||s;if(l||this._repaint)this.triggerRepaint();else{const e=!this.isMoving()&&this.loaded();if(e&&(s=this._updateAverageElevation(n,!0)),s)this.triggerRepaint();else if(this._triggerFrame(!1),e&&(this.fire(new Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const e=this._calculateSpeedIndex();this.fire(new Event("speedindexcompleted",{speedIndex:e})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||l||(this._fullyLoaded=!0,this._authenticate())}_forceMarkerUpdate(){for(const e of this._markers)e._update()}_updateAverageElevation(e,t=!1){const i=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);if((t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let r=this.transform.sampleAverageElevation(),n=!1;this.transform.elevation&&(n=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(r)?r=0:this._averageElevationLastSampledAt=e;const o=Math.abs(t-r);if(o>1){if(this._isInitialLoad||n)return this._averageElevation.jumpTo(r),i(r);this._averageElevation.easeTo(r,e,300)}else if(o>1e-4)return this._averageElevation.jumpTo(r),i(r)}return!!this._averageElevation.isEasing(e)&&i(this._averageElevation.getValue(e))}_authenticate(){Be(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(e=>{if(e&&(e.message===Te||401===e.status)){const e=this.painter.context.gl;Fe(e,!1),this._logoControl instanceof LogoControl&&this._logoControl._updateLogo(),e&&e.clear(e.DEPTH_BUFFER_BIT|e.COLOR_BUFFER_BIT|e.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new 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/")))}})),ke(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(()=>{}))}_updateTerrain(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){const e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const i=this.painter.context.gl,r=i.createFramebuffer();function n(e){i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0);const t=new Uint8Array(i.drawingBufferWidth*i.drawingBufferHeight*4);return i.readPixels(0,0,i.drawingBufferWidth,i.drawingBufferHeight,i.RGBA,i.UNSIGNED_BYTE,t),t}return i.bindFramebuffer(i.FRAMEBUFFER,r),this._canvasPixelComparison(n(e),t.canvasCopies.map(n),t.timeStamps)}_canvasPixelComparison(e,t,i){let r=i[1]-i[0];const n=e.length/4;for(let o=0;o<t.length;o++){const a=t[o];let s=0;for(let t=0;t<a.length;t+=4)a[t]===e[t]&&a[t+1]===e[t+1]&&a[t+2]===e[t+2]&&a[t+3]===e[t+3]&&(s+=1);r+=(i[o+2]-i[o+1])*(1-s/n)}return r}remove(){this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.painter.destroy(),this.handlers&&this.handlers.destroy(),this.handlers=void 0,this.setStyle(null),void 0!==e&&(e.removeEventListener("resize",this._onWindowResize,!1),e.removeEventListener("orientationchange",this._onWindowResize,!1),e.removeEventListener("webkitfullscreenchange",this._onWindowResize,!1),e.removeEventListener("online",this._onWindowOnline,!1));const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t&&t.loseContext(),lm(this._canvasContainer),lm(this._controlContainer),lm(this._missingCSSCanary),this._container.classList.remove("mapboxgl-map"),Re.delete(this.painter.context.gl),this._removed=!0,this.fire(new Event("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(e){this._renderNextFrame=this._renderNextFrame||e,this.style&&!this._frame&&(this._frame=ee.frame((e=>{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e)})))}_preloadTiles(e){return x(this.style?Object.values(this.style._sourceCaches):[],((t,i)=>t._preloadTiles(e,i)),(()=>{this.triggerRepaint()})),this}_onWindowOnline(){this._update()}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(e){this._speedIndexTiming!==e&&(this._speedIndexTiming=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}_setCacheLimits(e,t){!function(e,t){Ve=e,Ue=t}(e,t)}get version(){return X}},NavigationControl:class NavigationControl{constructor(e){this.options=b({},cm,e),this._container=te("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(I(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",(e=>{this._map&&this._map.zoomIn({},{originalEvent:e})})),te("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",(e=>{this._map&&this._map.zoomOut({},{originalEvent:e})})),te("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(I(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",(e=>{const t=this._map;t&&(this.options.visualizePitch?t.resetNorthPitch({},{originalEvent:e}):t.resetNorth({},{originalEvent:e}))})),this._compassIcon=te("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const e=this._map;if(!e)return;const t=e.getZoom(),i=t===e.getMaxZoom(),r=t===e.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",r.toString())}_rotateCompassArrow(){const e=this._map;if(!e)return;const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(e.transform.pitch*(Math.PI/180)),.5)}) rotateX(${e.transform.pitch}deg) rotateZ(${e.transform.angle*(180/Math.PI)}deg)`:`rotate(${e.transform.angle*(180/Math.PI)}deg)`;e._requestDomTask((()=>{this._compassIcon&&(this._compassIcon.style.transform=t)}))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),e.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&e.on("pitch",this._rotateCompassArrow),e.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new MouseRotateWrapper(e,this._compass,this.options.visualizePitch)),this._container}onRemove(){const e=this._map;e&&(this._container.remove(),this.options.showZoom&&e.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&e.off("pitch",this._rotateCompassArrow),e.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(e,t){const i=te("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_setButtonTitle(e,t){if(!this._map)return;const i=this._map._getUIString(`NavigationControl.${t}`);e.setAttribute("aria-label",i),e.firstElementChild&&e.firstElementChild.setAttribute("title",i)}},GeolocateControl:class GeolocateControl extends Evented{constructor(t){super(),this.options=b({geolocation:e.navigator.geolocation},um,t),I(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Ff(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(e){return this._map=e,this._container=te("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){void 0!==this._geolocationWatchID&&(this.options.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,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(t){void 0!==this._supportsGeolocation?t(this._supportsGeolocation):void 0!==e.navigator.permissions?e.navigator.permissions.query({name:"geolocation"}).then((e=>{this._supportsGeolocation="denied"!==e.state,t(this._supportsGeolocation)})):(this._supportsGeolocation=!!this.options.geolocation,t(this._supportsGeolocation))}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return!!t&&(i.longitude<t.getWest()||i.longitude>t.getEast()||i.latitude<t.getSouth()||i.latitude>t.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(e){if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new Event("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,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(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new Event("geolocate",e)),this._finish()}}_updateCamera(e){const t=new LngLat(e.coords.longitude,e.coords.latitude),i=e.coords.accuracy,r=b({bearing:this._map.getBearing()},this.options.fitBoundsOptions);this._map.fitBounds(t.toBounds(i),r,{geolocateSource:!0})}_updateMarker(e){if(e){const t=new LngLat(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(t).addTo(this._map),this._userLocationDotMarker.setLngLat(t).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const e=this._map.transform,t=Po(1,e._center.lat)*e.worldSize,i=Math.ceil(2*this._accuracy*t);this._circleElement.style.width=`${i}px`,this._circleElement.style.height=`${i}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(e){if(this._map){if(this.options.trackUserLocation)if(1===e.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 e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new Event("error",e)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(e){if(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=te("button","mapboxgl-ctrl-geolocate",this._container),te("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===e){B("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=te("div","mapboxgl-user-location"),this._dotElement.appendChild(te("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(te("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Marker({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=te("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Marker({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",(e=>{e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new Event("trackuserlocationend")))}))}_onDeviceOrientation(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return B("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 Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!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 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 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 e;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(e={maximumAge:6e5,timeout:0},this._noTimeout=!0):(e=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,e),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const t=()=>{e.addEventListener("ondeviceorientationabsolute"in e?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};void 0!==e.DeviceMotionEvent&&"function"==typeof e.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((e=>{"granted"===e&&t()})).catch(console.error):t()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),e.removeEventListener("deviceorientation",this._onDeviceOrientation),e.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),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:AttributionControl,ScaleControl:class ScaleControl{constructor(e){this.options=b({},hm,e),function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"narrow",unit:"meter"}),!0}catch(e){return!1}}()||(this._setScale=pm.bind(this)),I(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,i=t._containerHeight/2,r=t._containerWidth/2-e/2,n=t.unproject([r,i]),o=t.unproject([r+e,i]),a=n.distanceTo(o);if("imperial"===this.options.unit){const t=3.2808*a;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot")}else"nautical"===this.options.unit?this._setScale(e,a/1852,"nautical-mile"):a>=1e3?this._setScale(e,a/1e3,"kilometer"):this._setScale(e,a,"meter")}_setScale(e,t,i){const r=dm(t),n=r/t;this._map._requestDomTask((()=>{this._container.style.width=e*n+"px",this._container.innerHTML="nautical-mile"!==i?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"narrow",unit:i}).format(r):`${r} nm`}))}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=te("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(e){this._language=e,this._update()}setUnit(e){this.options.unit=e,this._update()}},FullscreenControl:class FullscreenControl{constructor(t){this._fullscreen=!1,t&&t.container&&(t.container instanceof e.HTMLElement?this._container=t.container:B("Full screen control 'container' must be a DOM element.")),I(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in e.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in e.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=te("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",B("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,e.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!e.document.fullscreenEnabled&&!e.document.webkitFullscreenEnabled)}_setupUI(){const t=this._fullscreenButton=te("button","mapboxgl-ctrl-fullscreen",this._controlContainer);te("span","mapboxgl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),e.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(){(e.document.fullscreenElement||e.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()?e.document.exitFullscreen?e.document.exitFullscreen():e.document.webkitCancelFullScreen&&e.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class Popup extends Evented{constructor(e){super(),this.options=b(Object.create(fm),e),I(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(e&&e.className?e.className.trim().split(/\s+/):[])}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&e.on("preclick",this._onClose),this.options.closeOnMove&&e.on("move",this._onClose),e.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(e.on("mousemove",this._onMouseEvent),e.on("mouseup",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")):e.on("move",this._update),this.fire(new Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const e=this._map;return e&&(e.off("move",this._update),e.off("move",this._onClose),e.off("preclick",this._onClose),e.off("click",this._onClose),e.off("remove",this.remove),e.off("mousemove",this._onMouseEvent),e.off("mouseup",this._onMouseEvent),e.off("drag",this._onMouseEvent),this._map=void 0),this.fire(new Event("close")),this}getLngLat(){return this._lngLat}setLngLat(e){this._lngLat=LngLat.convert(e),this._pos=null,this._trackPointer=!1,this._update();const t=this._map;return t&&(t.on("move",this._update),t.off("mousemove",this._onMouseEvent),t._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const e=this._map;return e&&(e.off("move",this._update),e.on("mousemove",this._onMouseEvent),e.on("drag",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(e.document.createTextNode(t))}setHTML(t){const i=e.document.createDocumentFragment(),r=e.document.createElement("body");let n;for(r.innerHTML=t;n=r.firstChild,n;)i.appendChild(n);return this.setDOMContent(i)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=te("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=te("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.setAttribute("aria-hidden","true"),e.innerHTML="×",e.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(e){return this._classList.add(e),this._updateClassList(),this}removeClassName(e){return this._classList.delete(e),this._updateClassList(),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){let t;return this._classList.delete(e)?t=!1:(this._classList.add(e),t=!0),this._updateClassList(),t}_onMouseEvent(e){this._update(e.point)}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const t=this._map,i=this._container,r=this._pos;if(!t||!i||!r)return"bottom";const n=i.offsetWidth,o=i.offsetHeight,a=r.x<n/2,s=r.x>t.transform.width-n/2;if(r.y+e<o)return a?"top-left":s?"top-right":"top";if(r.y>t.transform.height-o){if(a)return"bottom-left";if(s)return"bottom-right"}return a?"left":s?"right":"bottom"}_updateClassList(){const e=this._container;if(!e)return;const t=[...this._classList];t.push("mapboxgl-popup"),this._anchor&&t.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),e.className=t.join(" ")}_update(e){const t=this._map,i=this._content;if(!t||!this._lngLat&&!this._trackPointer||!i)return;let r=this._container;if(r||(r=this._container=te("div","mapboxgl-popup",t.getContainer()),this._tip=te("div","mapboxgl-popup-tip",r),r.appendChild(i)),this.options.maxWidth&&r.style.maxWidth!==this.options.maxWidth&&(r.style.maxWidth=this.options.maxWidth),t.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=nm(this._lngLat,this._pos,t.transform)),!this._trackPointer||e){const i=this._pos=this._trackPointer&&e?e:t.project(this._lngLat),r=_m(this.options.offset),n=this._anchor=this._getAnchor(r.y),o=_m(this.options.offset,n),a=i.add(o).round();t._requestDomTask((()=>{this._container&&n&&(this._container.style.transform=`${om[n]} translate(${a.x}px,${a.y}px)`)}))}if(!this._marker&&t._showingGlobe()){const e=Tu(t.transform,this._lngLat)?0:1;this._setOpacity(e)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(mm);e&&e.focus()}_onClose(){this.remove()}_setOpacity(e){this._container&&(this._container.style.opacity=`${e}`),this._content&&(this._content.style.pointerEvents=e?"auto":"none")}},Marker:Marker,Style:Style,LngLat:LngLat,LngLatBounds:LngLatBounds,Point:r,MercatorCoordinate:MercatorCoordinate,FreeCameraOptions:FreeCameraOptions,Evented:Evented,config:me,prewarm:function(){ip().acquire(ep)},clearPrewarmedResources:function(){const e=tp;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(ep),tp=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 me.ACCESS_TOKEN},set accessToken(e){me.ACCESS_TOKEN=e},get baseApiUrl(){return me.API_URL},set baseApiUrl(e){me.API_URL=e},get workerCount(){return WorkerPool.workerCount},set workerCount(e){WorkerPool.workerCount=e},get maxParallelImageRequests(){return me.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(e){me.MAX_PARALLEL_IMAGE_REQUESTS=e},clearStorage(e){!function(e){const t=Ge(),i=[];for(const e in je)t&&i.push(t.delete(e)),delete je[e];e&&Promise.all(i).catch(e).then((()=>e()))}(e)},workerUrl:"",workerClass:null,setNow:ee.setNow,restoreNow:ee.restoreNow};return gm}));
|
|
2
2
|
//# sourceMappingURL=mapbox-gl-csp.js.map
|