mapbox-gl 2.8.0-alpha.3 → 2.8.0-alpha.4

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.
@@ -1,2 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).mapboxgl=e()}(this,(function(){"use strict";var t=e;function e(t){return!function(t){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 t,e,i=new Blob([""],{type:"text/javascript"}),r=URL.createObjectURL(i);try{e=new Worker(r),t=!0}catch(e){t=!1}return e&&e.terminate(),URL.revokeObjectURL(r),t}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var t=document.createElement("canvas");t.width=t.height=1;var e=t.getContext("2d");if(!e)return!1;var i=e.getImageData(0,0,1,1);return i&&i.width===t.width}()?(void 0===i[r=t&&t.failIfMajorPerformanceCaveat]&&(i[r]=function(t){var i,r=function(t){var i=document.createElement("canvas"),r=Object.create(e.webGLContextAttributes);return r.failIfMajorPerformanceCaveat=t,i.getContext("webgl",r)||i.getContext("experimental-webgl",r)}(t);if(!r)return!1;try{i=r.createShader(r.VERTEX_SHADER)}catch(t){return!1}return!(!i||r.isContextLost())&&(r.shaderSource(i,"void main() {}"),r.compileShader(i),!0===r.getShaderParameter(i,r.COMPILE_STATUS))}(r)),i[r]?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 r}(t)}var i={};e.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};var r="2.8.0-alpha.3",n=s;function s(t,e,i,r){this.cx=3*t,this.bx=3*(i-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(r-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=r,this.p2x=i,this.p2y=r}s.prototype.sampleCurveX=function(t){return((this.ax*t+this.bx)*t+this.cx)*t},s.prototype.sampleCurveY=function(t){return((this.ay*t+this.by)*t+this.cy)*t},s.prototype.sampleCurveDerivativeX=function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},s.prototype.solveCurveX=function(t,e){var i,r,n,s,o;for(void 0===e&&(e=1e-6),n=t,o=0;o<8;o++){if(s=this.sampleCurveX(n)-t,Math.abs(s)<e)return n;var a=this.sampleCurveDerivativeX(n);if(Math.abs(a)<1e-6)break;n-=s/a}if((n=t)<(i=0))return i;if(n>(r=1))return r;for(;i<r;){if(s=this.sampleCurveX(n),Math.abs(s-t)<e)return n;t>s?i=n:r=n,n=.5*(r-i)+i}return n},s.prototype.solve=function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))};var o=a;function a(t,e){this.x=t,this.y=e}a.prototype={clone:function(){return new a(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},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(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,i=t.y-this.y;return e*e+i*i},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),i=Math.sin(t),r=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=r,this},_rotateAround:function(t,e){var i=Math.cos(t),r=Math.sin(t),n=e.y+r*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-r*(this.y-e.y),this.y=n,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},a.convert=function(t){return t instanceof a?t:Array.isArray(t)?new a(t[0],t[1]):t};var l="undefined"!=typeof self?self:{};function c(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!c(t[i],e[i]))return!1;return!0}if("object"==typeof t&&null!==t&&null!==e){if("object"!=typeof e)return!1;if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const i in t)if(!c(t[i],e[i]))return!1;return!0}return t===e}const h=Math.PI/180,u=180/Math.PI;function p(t){return t*h}function d(t){return t*u}const f=[[0,0],[1,0],[1,1],[0,1]];function m(t){if(t<=0)return 0;if(t>=1)return 1;const e=t*t,i=e*t;return 4*(t<.5?i:3*(t-e)+i-.75)}function _(t){let e=1/0,i=1/0,r=-1/0,n=-1/0;for(const s of t)e=Math.min(e,s.x),i=Math.min(i,s.y),r=Math.max(r,s.x),n=Math.max(n,s.y);return{min:new o(e,i),max:new o(r,n)}}function g(t,e,i=0,r=!0){const n=new o(i,i),s=t.sub(n),a=e.add(n),l=[s,new o(a.x,s.y),a,new o(s.x,a.y)];return r&&l.push(s),l}function y(t,e,i,r){const s=new n(t,e,i,r);return function(t){return s.solve(t)}}const x=y(.25,.1,.25,1);function v(t,e,i){return Math.min(i,Math.max(e,t))}function b(t,e,i){return(i=v((i-t)/(e-t),0,1))*i*(3-2*i)}function w(t,e,i){const r=i-e,n=((t-e)%r+r)%r+e;return n===e?i:n}function T(t,e,i){if(!t.length)return i(null,[]);let r=t.length;const n=new Array(t.length);let s=null;t.forEach(((t,o)=>{e(t,((t,e)=>{t&&(s=t),n[o]=e,0==--r&&i(s,n)}))}))}function E(t){const e=[];for(const i in t)e.push(t[i]);return e}function I(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}function S(t,e){const i={};for(let r=0;r<e.length;r++){const n=e[r];n in t&&(i[n]=t[n])}return i}let A=1;function z(){return A++}function C(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}function M(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function k(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)}function P(t,e){t.forEach((t=>{e[t]&&(e[t]=e[t].bind(e))}))}function D(t,e){return-1!==t.indexOf(e,t.length-e.length)}function B(t,e,i){const r={};for(const n in t)r[n]=e.call(i||this,t[n],n,t);return r}function L(t,e,i){const r={};for(const n in t)e.call(i||this,t[n],n,t)&&(r[n]=t[n]);return r}function R(t){return Array.isArray(t)?t.map(R):"object"==typeof t&&t?B(t,R):t}const F={};function O(t){F[t]||("undefined"!=typeof console&&console.warn(t),F[t]=!0)}function V(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}function j(t){let e=0;for(let i,r,n=0,s=t.length,o=s-1;n<s;o=n++)i=t[n],r=t[o],e+=(r.x-i.x)*(i.y+r.y);return e}function U(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}function N(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,i,r,n)=>{const s=r||n;return e[i]=!s||s.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t}return e}let Z,q,G,$,W=null;function X(t){if(null==W){const e=t.navigator?t.navigator.userAgent:null;W=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return W}function H(t){try{const e=l[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}}function K(t,e){return[t[4*e],t[4*e+1],t[4*e+2],t[4*e+3]]}function Y(t,e,i){t[4*e+0]=i[0],t[4*e+1]=i[1],t[4*e+2]=i[2],t[4*e+3]=i[3]}const J={now:()=>void 0!==G?G:l.performance.now(),setNow(t){G=t},restoreNow(){G=void 0},frame(t){const e=l.requestAnimationFrame(t);return{cancel:()=>l.cancelAnimationFrame(e)}},getImageData(t,e=0){const{width:i,height:r}=t;$||($=l.document.createElement("canvas"));const n=$.getContext("2d");if(!n)throw new Error("failed to create canvas 2d context");return(i>$.width||r>$.height)&&($.width=i,$.height=r),n.clearRect(-e,-e,i+2*e,r+2*e),n.drawImage(t,0,0,i,r),n.getImageData(-e,-e,i+2*e,r+2*e)},resolveURL:t=>(Z||(Z=l.document.createElement("a")),Z.href=t,Z.href),get devicePixelRatio(){return l.devicePixelRatio},get prefersReducedMotion(){return!!l.matchMedia&&(null==q&&(q=l.matchMedia("(prefers-reduced-motion: reduce)")),q.matches)}};function Q(t,e,i){const r=l.document.createElement(t);return void 0!==e&&(r.className=e),i&&i.appendChild(r),r}function tt(t,e,i){const r=l.document.createElementNS("http://www.w3.org/2000/svg",t);for(const t of Object.keys(e))r.setAttributeNS(null,t,e[t]);return i&&i.appendChild(r),r}const et=l.document&&l.document.documentElement.style,it=et&&void 0!==et.userSelect?"userSelect":"WebkitUserSelect";let rt,nt;function st(){et&&it&&(rt=et[it],et[it]="none")}function ot(){et&&it&&(et[it]=rt)}function at(t){t.preventDefault(),t.stopPropagation(),l.removeEventListener("click",at,!0)}function lt(){l.addEventListener("click",at,!0),l.setTimeout((()=>{l.removeEventListener("click",at,!0)}),0)}function ct(t,e){const i=t.getBoundingClientRect();return pt(t,i,e)}function ht(t,e){const i=t.getBoundingClientRect(),r=[];for(let n=0;n<e.length;n++)r.push(pt(t,i,e[n]));return r}function ut(t){return void 0!==l.InstallTrigger&&2===t.button&&t.ctrlKey&&l.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:t.button}function pt(t,e,i){const r=t.offsetWidth===e.width?1:t.offsetWidth/e.width;return new o((i.clientX-e.left)*r,(i.clientY-e.top)*r)}const dt={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==nt){const t=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{nt=null!=process.env.API_URL_REGEX?new RegExp(process.env.API_URL_REGEX):t}catch(e){nt=t}}return nt},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},ft={supported:!1,testSupport:function(t){!gt&&_t&&(yt?xt(t):mt=t)}};let mt,_t,gt=!1,yt=!1;function xt(t){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,_t),t.isContextLost())return;ft.supported=!0}catch(t){}t.deleteTexture(e),gt=!0}l.document&&(_t=l.document.createElement("img"),_t.onload=function(){mt&&xt(mt),mt=null,yt=!0},_t.onerror=function(){gt=!0,mt=null},_t.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const vt="01",bt="NO_ACCESS_TOKEN";class wt{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let t="";for(let e=0;e<10;e++)t+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",vt,t].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=t.token,this._skuTokenExpiresAt=t.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,e){if(!Tt(t))return t;const i=St(t);return i.path=`/styles/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeGlyphsURL(t,e){if(!Tt(t))return t;const i=St(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e){if(!Tt(t))return t;const i=St(t);return i.path=`/v4/${i.authority}.json`,i.params.push("secure"),this._makeAPIURL(i,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,r){const n=St(t);return Tt(t)?(n.path=`/styles/v1${n.path}/sprite${e}${i}`,this._makeAPIURL(n,this._customAccessToken||r)):(n.path+=`${e}${i}`,At(n))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!Tt(t))return t;const r=St(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${ft.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${dt.RASTER_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${dt.TILE_URL_VERSION}${r.path}`);const n=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||dt.ACCESS_TOKEN;return dt.REQUIRE_ACCESS_TOKEN&&n&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,n)}canonicalizeTileURL(t,e){const i=St(t);if(!i.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${dt.RASTER_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${dt.TILE_URL_VERSION}/`,"")}`;let n=i.params;return e&&(n=n.filter((t=>!t.match(/^access_token=/)))),n.length&&(r+=`?${n.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&Tt(e),r=[];for(const e of t.tiles||[])Et(e)?r.push(this.canonicalizeTileURL(e,i)):r.push(e);return r}_makeAPIURL(t,e){const i="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",r=St(dt.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!dt.REQUIRE_ACCESS_TOKEN)return At(t);if(e=e||dt.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),At(t)}}function Tt(t){return 0===t.indexOf("mapbox:")}function Et(t){return dt.API_URL_REGEX.test(t)}const It=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function St(t){const e=t.match(It);if(!e)throw new Error("Unable to parse URL object");return{protocol:e[1],authority:e[2],path:e[3]||"/",params:e[4]?e[4].split("&"):[]}}function At(t){const e=t.params.length?`?${t.params.join("&")}`:"";return`${t.protocol}://${t.authority}${t.path}${e}`}function zt(t){if(!t)return null;const e=t.split(".");if(!e||3!==e.length)return null;try{return JSON.parse(decodeURIComponent(l.atob(e[1]).split("").map((t=>"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join("")))}catch(t){return null}}class Ct{constructor(t){this.type=t,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(t){const e=zt(dt.ACCESS_TOKEN);let i="";return i=e&&e.u?l.btoa(encodeURIComponent(e.u).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e))))):dt.ACCESS_TOKEN||"",t?`mapbox.eventData.${t}:${i}`:`mapbox.eventData:${i}`}fetchEventData(){const t=H("localStorage"),e=this.getStorageKey(),i=this.getStorageKey("uuid");if(t)try{const t=l.localStorage.getItem(e);t&&(this.eventData=JSON.parse(t));const r=l.localStorage.getItem(i);r&&(this.anonId=r)}catch(t){O("Unable to read from LocalStorage")}}saveEventData(){const t=H("localStorage"),e=this.getStorageKey(),i=this.getStorageKey("uuid");if(t)try{l.localStorage.setItem(i,this.anonId),Object.keys(this.eventData).length>=1&&l.localStorage.setItem(e,JSON.stringify(this.eventData))}catch(t){O("Unable to write to LocalStorage")}}processRequests(t){}postEvent(t,e,i,n){if(!dt.EVENTS_URL)return;const s=St(dt.EVENTS_URL);s.params.push(`access_token=${n||dt.ACCESS_TOKEN||""}`);const o={event:this.type,created:new Date(t).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:r,skuId:vt,userId:this.anonId},a=e?I(o,e):o,l={url:At(s),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=Qt(l,(t=>{this.pendingRequest=null,i(t),this.saveEventData(),this.processRequests(n)}))}queueRequest(t,e){this.queue.push(t),this.processRequests(e)}}const Mt=new class extends Ct{constructor(t){super("appUserTurnstile"),this._customAccessToken=t}postTurnstileEvent(t,e){dt.EVENTS_URL&&dt.ACCESS_TOKEN&&Array.isArray(t)&&t.some((t=>Tt(t)||Et(t)))&&this.queueRequest(Date.now(),e)}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const e=zt(dt.ACCESS_TOKEN),i=e?e.u:dt.ACCESS_TOKEN;let r=i!==this.eventData.tokenU;k(this.anonId)||(this.anonId=C(),r=!0);const n=this.queue.shift();if(this.eventData.lastSuccess){const t=new Date(this.eventData.lastSuccess),e=new Date(n),i=(n-this.eventData.lastSuccess)/864e5;r=r||i>=1||i<-1||t.getDate()!==e.getDate()}else r=!0;if(!r)return this.processRequests();this.postEvent(n,{"enabled.telemetry":!1},(t=>{t||(this.eventData.lastSuccess=n,this.eventData.tokenU=i)}),t)}},kt=Mt.postTurnstileEvent.bind(Mt),Pt=new class extends Ct{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(t,e,i,r){this.skuToken=e,this.errorCb=r,dt.EVENTS_URL&&(i||dt.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(bt)))}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:e,timestamp:i}=this.queue.shift();e&&this.success[e]||(this.anonId||this.fetchEventData(),k(this.anonId)||(this.anonId=C()),this.postEvent(i,{skuToken:this.skuToken},(t=>{t?this.errorCb(t):e&&(this.success[e]=!0)}),t))}},Dt=Pt.postMapLoadEvent.bind(Pt),Bt=new class extends Ct{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(t,e,i,r){if(!dt.API_URL||!dt.SESSION_PATH)return;const n=St(dt.API_URL+dt.SESSION_PATH);n.params.push(`sku=${e||""}`),n.params.push(`access_token=${r||dt.ACCESS_TOKEN||""}`);const s={url:At(n),headers:{"Content-Type":"text/plain"}};this.pendingRequest=te(s,(t=>{this.pendingRequest=null,i(t),this.saveEventData(),this.processRequests(r)}))}getSessionAPI(t,e,i,r){this.skuToken=e,this.errorCb=r,dt.SESSION_PATH&&dt.API_URL&&(i||dt.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(bt)))}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:e,timestamp:i}=this.queue.shift();e&&this.success[e]||this.getSession(i,this.skuToken,(t=>{t?this.errorCb(t):e&&(this.success[e]=!0)}),t)}},Lt=Bt.getSessionAPI.bind(Bt),Rt=new Set;function Ft(t,e){e?Rt.add(t):Rt.delete(t)}const Ot="mapbox-tiles";let Vt,jt,Ut=500,Nt=50;function Zt(){l.caches&&!Vt&&(Vt=l.caches.open(Ot))}function qt(t){const e=t.indexOf("?");return e<0?t:t.slice(0,e)}let Gt=1/0;function $t(t){Gt++,Gt>Nt&&(t.getActor().send("enforceCacheSizeLimit",Ut),Gt=0)}const Wt={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(Wt);class Xt extends Error{constructor(t,e,i){401===e&&Et(i)&&(t+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(t),this.status=e,this.url=i}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const Ht=U()?()=>self.worker&&self.worker.referrer:()=>("blob:"===l.location.protocol?l.parent:l).location.href;const Kt=function(t,e){if(!(/^file:/.test(i=t.url)||/^file:/.test(Ht())&&!/^\w+:/.test(i))){if(l.fetch&&l.Request&&l.AbortController&&l.Request.prototype.hasOwnProperty("signal"))return function(t,e){const i=new l.AbortController,r=new l.Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:Ht(),signal:i.signal});let n=!1,s=!1;const o=(a=r.url).indexOf("sku=")>0&&Et(a);var a;"json"===t.type&&r.headers.set("Accept","application/json");const c=(i,n,a)=>{if(s)return;if(i&&"SecurityError"!==i.message&&O(i),n&&a)return h(n);const c=Date.now();l.fetch(r).then((i=>{if(i.ok){const t=o?i.clone():null;return h(i,t,c)}return e(new Xt(i.statusText,i.status,t.url))})).catch((t=>{20!==t.code&&e(new Error(t.message))}))},h=(i,o,a)=>{("arrayBuffer"===t.type?i.arrayBuffer():"json"===t.type?i.json():i.text()).then((t=>{s||(o&&a&&function(t,e,i){if(Zt(),!Vt)return;const r={status:e.status,statusText:e.statusText,headers:new l.Headers};e.headers.forEach(((t,e)=>r.headers.set(e,t)));const n=N(e.headers.get("Cache-Control")||"");if(n["no-store"])return;n["max-age"]&&r.headers.set("Expires",new Date(i+1e3*n["max-age"]).toUTCString());const s=r.headers.get("Expires");s&&(new Date(s).getTime()-i<42e4||function(t,e){if(void 0===jt)try{new Response(new ReadableStream),jt=!0}catch(t){jt=!1}jt?e(t.body):t.blob().then(e)}(e,(e=>{const i=new l.Response(e,r);Zt(),Vt&&Vt.then((e=>e.put(qt(t.url),i))).catch((t=>O(t.message)))})))}(r,o,a),n=!0,e(null,t,i.headers.get("Cache-Control"),i.headers.get("Expires")))})).catch((t=>{s||e(new Error(t.message))}))};return o?function(t,e){if(Zt(),!Vt)return e(null);const i=qt(t.url);Vt.then((t=>{t.match(i).then((r=>{const n=function(t){if(!t)return!1;const e=new Date(t.headers.get("Expires")||0),i=N(t.headers.get("Cache-Control")||"");return e>Date.now()&&!i["no-cache"]}(r);t.delete(i),n&&t.put(i,r.clone()),e(null,r,n)})).catch(e)})).catch(e)}(r,c):c(null,null),{cancel:()=>{s=!0,n||i.abort()}}}(t,e);if(U()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var i;return function(t,e){const i=new l.XMLHttpRequest;i.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(i.responseType="arraybuffer");for(const e in t.headers)i.setRequestHeader(e,t.headers[e]);return"json"===t.type&&(i.responseType="text",i.setRequestHeader("Accept","application/json")),i.withCredentials="include"===t.credentials,i.onerror=()=>{e(new Error(i.statusText))},i.onload=()=>{if((i.status>=200&&i.status<300||0===i.status)&&null!==i.response){let r=i.response;if("json"===t.type)try{r=JSON.parse(i.response)}catch(t){return e(t)}e(null,r,i.getResponseHeader("Cache-Control"),i.getResponseHeader("Expires"))}else e(new Xt(i.statusText,i.status,t.url))},i.send(t.body),{cancel:()=>i.abort()}}(t,e)},Yt=function(t,e){return Kt(I(t,{type:"json"}),e)},Jt=function(t,e){return Kt(I(t,{type:"arrayBuffer"}),e)},Qt=function(t,e){return Kt(I(t,{method:"POST"}),e)},te=function(t,e){return Kt(I(t,{method:"GET"}),e)};function ee(t){const e=l.document.createElement("a");return e.href=t,e.protocol===l.document.location.protocol&&e.host===l.document.location.host}const ie="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let re,ne;re=[],ne=0;const se=function(t,e){if(ft.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),ne>=dt.MAX_PARALLEL_IMAGE_REQUESTS){const i={requestParameters:t,callback:e,cancelled:!1,cancel(){this.cancelled=!0}};return re.push(i),i}ne++;let i=!1;const r=()=>{if(!i)for(i=!0,ne--;re.length&&ne<dt.MAX_PARALLEL_IMAGE_REQUESTS;){const t=re.shift(),{requestParameters:e,callback:i,cancelled:r}=t;r||(t.cancel=se(e,i).cancel)}},n=Jt(t,((t,i,n,s)=>{r(),t?e(t):i&&(l.createImageBitmap?function(t,e){const i=new l.Blob([new Uint8Array(t)],{type:"image/png"});l.createImageBitmap(i).then((t=>{e(null,t)})).catch((t=>{e(new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))}))}(i,((t,i)=>e(t,i,n,s))):function(t,e){const i=new l.Image,r=l.URL;i.onload=()=>{e(null,i),r.revokeObjectURL(i.src),i.onload=null,l.requestAnimationFrame((()=>{i.src=ie}))},i.onerror=()=>e(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const n=new l.Blob([new Uint8Array(t)],{type:"image/png"});i.src=t.byteLength?r.createObjectURL(n):ie}(i,((t,i)=>e(t,i,n,s))))}));return{cancel:()=>{n.cancel(),r()}}};function oe(t,e,i){i[t]&&-1!==i[t].indexOf(e)||(i[t]=i[t]||[],i[t].push(e))}function ae(t,e,i){if(i&&i[t]){const r=i[t].indexOf(e);-1!==r&&i[t].splice(r,1)}}class le{constructor(t,e={}){I(this,e),this.type=t}}class ce extends le{constructor(t,e={}){super("error",I({error:t},e))}}class he{on(t,e){return this._listeners=this._listeners||{},oe(t,e,this._listeners),this}off(t,e){return ae(t,e,this._listeners),ae(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},oe(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new le(t,e||{}));const i=t.type;if(this.listens(i)){t.target=this;const e=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of e)i.call(this,t);const r=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const e of r)ae(i,e,this._oneTimeListeners),e.call(this,t);const n=this._eventedParent;n&&(I(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),n.fire(t))}else t instanceof ce&&console.error(t.error);return this}listens(t){return!!(this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t))}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var ue=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":{},"mapbox":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":{},"line":{},"line-center":{}},"default":"point","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"units":"factor of the original icon size","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":{},"width":{},"height":{},"both":{}},"default":"none","requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"units":"pixels","requires":["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","units":"ems","default":0,"requires":["text-field"],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["text-field",{"!":"text-variable-anchor"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"units":"degrees","requires":["text-field",{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","units":"ems","length":2,"default":[0,0],"requires":["text-field",{"!":"text-radial-offset"}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"geometry_type":{"type":"enum","values":{"Point":{},"LineString":{},"Polygon":{}}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":{},"exponential":{},"interval":{},"categorical":{}},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":{},"lab":{},"hcl":{}},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":0.1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{},"globe":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":true,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"cross-faded"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0,"units":"milliseconds"},"delay":{"type":"number","default":0,"minimum":0,"units":"milliseconds"}},"property-type":{"data-driven":{"type":"property-type"},"cross-faded":{"type":"property-type"},"cross-faded-data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function pe(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}function de(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function fe(t){if(Array.isArray(t))return t.map(fe);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const i in t)e[i]=fe(t[i]);return e}return de(t)}class me extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}class _e{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,i]of e)this.bindings[t]=i}concat(t){return new _e(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}const ge={kind:"null"},ye={kind:"number"},xe={kind:"string"},ve={kind:"boolean"},be={kind:"color"},we={kind:"object"},Te={kind:"value"},Ee={kind:"collator"},Ie={kind:"formatted"},Se={kind:"resolvedImage"};function Ae(t,e){return{kind:"array",itemType:t,N:e}}function ze(t){if("array"===t.kind){const e=ze(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Ce=[ge,ye,xe,ve,be,Ie,we,Ae(Te),Se];function Me(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Me(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of Ce)if(!Me(t,e))return null}return`Expected ${ze(t)} but found ${ze(e)} instead.`}function ke(t,e){return e.some((e=>e.kind===t.kind))}function Pe(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}function De(t){var e={exports:{}};return t(e,e.exports),e.exports}var Be=De((function(t,e){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(t){return(t=Math.round(t))<0?0:t>255?255:t}function n(t){return r("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function s(t){return(e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e}function o(t,e,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?t+(e-t)*i*6:2*i<1?e:3*i<2?t+(e-t)*(2/3-i)*6:t}try{e.parseCSSColor=function(t){var e,a=t.replace(/ /g,"").toLowerCase();if(a in i)return i[a].slice();if("#"===a[0])return 4===a.length?(e=parseInt(a.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:7===a.length&&(e=parseInt(a.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var l=a.indexOf("("),c=a.indexOf(")");if(-1!==l&&c+1===a.length){var h=a.substr(0,l),u=a.substr(l+1,c-(l+1)).split(","),p=1;switch(h){case"rgba":if(4!==u.length)return null;p=s(u.pop());case"rgb":return 3!==u.length?null:[n(u[0]),n(u[1]),n(u[2]),p];case"hsla":if(4!==u.length)return null;p=s(u.pop());case"hsl":if(3!==u.length)return null;var d=(parseFloat(u[0])%360+360)%360/360,f=s(u[1]),m=s(u[2]),_=m<=.5?m*(f+1):m+f-m*f,g=2*m-_;return[r(255*o(g,_,d+1/3)),r(255*o(g,_,d)),r(255*o(g,_,d-1/3)),p];default:return null}}return null}}catch(t){}}));class Le{constructor(t,e,i,r=1){this.r=t,this.g=e,this.b=i,this.a=r}static parse(t){if(!t)return;if(t instanceof Le)return t;if("string"!=typeof t)return;const e=Be.parseCSSColor(t);return e?new Le(e[0]/255*e[3],e[1]/255*e[3],e[2]/255*e[3],e[3]):void 0}toString(){const[t,e,i,r]=this.toArray();return`rgba(${Math.round(t)},${Math.round(e)},${Math.round(i)},${r})`}toArray(){const{r:t,g:e,b:i,a:r}=this;return 0===r?[0,0,0,0]:[255*t/r,255*e/r,255*i/r,r]}}Le.black=new Le(0,0,0,1),Le.white=new Le(1,1,1,1),Le.transparent=new Le(0,0,0,0),Le.red=new Le(1,0,0,1),Le.blue=new Le(0,0,1,1);class Re{constructor(t,e,i){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Fe{constructor(t,e,i,r,n){this.text=t.normalize?t.normalize():t,this.image=e,this.scale=i,this.fontStack=r,this.textColor=n}}class Oe{constructor(t){this.sections=t}static fromString(t){return new Oe([new Fe(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof Oe?t:Oe.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}serialize(){const t=["format"];for(const e of this.sections){if(e.image){t.push(["image",e.image.name]);continue}t.push(e.text);const i={};e.fontStack&&(i["text-font"]=["literal",e.fontStack.split(",")]),e.scale&&(i["font-scale"]=e.scale),e.textColor&&(i["text-color"]=["rgba"].concat(e.textColor.toArray())),t.push(i)}return t}}class Ve{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new Ve({name:t,available:!1}):null}serialize(){return["image",this.name]}}function je(t,e,i,r){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[t,e,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[t,e,i,r]:[t,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Ue(t){if(null===t)return!0;if("string"==typeof t)return!0;if("boolean"==typeof t)return!0;if("number"==typeof t)return!0;if(t instanceof Le)return!0;if(t instanceof Re)return!0;if(t instanceof Oe)return!0;if(t instanceof Ve)return!0;if(Array.isArray(t)){for(const e of t)if(!Ue(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!Ue(t[e]))return!1;return!0}return!1}function Ne(t){if(null===t)return ge;if("string"==typeof t)return xe;if("boolean"==typeof t)return ve;if("number"==typeof t)return ye;if(t instanceof Le)return be;if(t instanceof Re)return Ee;if(t instanceof Oe)return Ie;if(t instanceof Ve)return Se;if(Array.isArray(t)){const e=t.length;let i;for(const e of t){const t=Ne(e);if(i){if(i===t)continue;i=Te;break}i=t}return Ae(i||Te,e)}return we}function Ze(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof Le||t instanceof Oe||t instanceof Ve?t.toString():JSON.stringify(t)}class qe{constructor(t,e){this.type=t,this.value=e}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Ue(t[1]))return e.error("invalid value");const i=t[1];let r=Ne(i);const n=e.expectedType;return"array"!==r.kind||0!==r.N||!n||"array"!==n.kind||"number"==typeof n.N&&0!==n.N||(r=n),new qe(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 Le?["rgba"].concat(this.value.toArray()):this.value instanceof Oe?this.value.serialize():this.value}}class Ge{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}}const $e={string:xe,number:ye,boolean:ve,object:we};class We{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let i,r=1;const n=t[0];if("array"===n){let n,s;if(t.length>2){const i=t[1];if("string"!=typeof i||!(i in $e)||"object"===i)return e.error('The item type argument of "array" must be one of string, number, boolean',1);n=$e[i],r++}else n=Te;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);s=t[2],r++}i=Ae(n,s)}else i=$e[n];const s=[];for(;r<t.length;r++){const i=e.parse(t[r],r,Te);if(!i)return null;s.push(i)}return new We(i,s)}evaluate(t){for(let e=0;e<this.args.length;e++){const i=this.args[e].evaluate(t);if(!Me(this.type,Ne(i)))return i;if(e===this.args.length-1)throw new Ge(`Expected value to be of type ${ze(this.type)}, but found ${ze(Ne(i))} instead.`)}return null}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=this.type,e=[t.kind];if("array"===t.kind){const i=t.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){e.push(i.kind);const r=t.N;("number"==typeof r||this.args.length>1)&&e.push(r)}}return e.concat(this.args.map((t=>t.serialize())))}}class Xe{constructor(t){this.type=Ie,this.sections=t}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[1];if(!Array.isArray(i)&&"object"==typeof i)return e.error("First argument must be an image or text section.");const r=[];let n=!1;for(let i=1;i<=t.length-1;++i){const s=t[i];if(n&&"object"==typeof s&&!Array.isArray(s)){n=!1;let t=null;if(s["font-scale"]&&(t=e.parse(s["font-scale"],1,ye),!t))return null;let i=null;if(s["text-font"]&&(i=e.parse(s["text-font"],1,Ae(xe)),!i))return null;let o=null;if(s["text-color"]&&(o=e.parse(s["text-color"],1,be),!o))return null;const a=r[r.length-1];a.scale=t,a.font=i,a.textColor=o}else{const s=e.parse(t[i],1,Te);if(!s)return null;const o=s.type.kind;if("string"!==o&&"value"!==o&&"null"!==o&&"resolvedImage"!==o)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,r.push({content:s,scale:null,font:null,textColor:null})}}return new Xe(r)}evaluate(t){return new Oe(this.sections.map((e=>{const i=e.content.evaluate(t);return Ne(i)===Se?new Fe("",i,null,null,null):new Fe(Ze(i),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor)}outputDefined(){return!1}serialize(){const t=["format"];for(const e of this.sections){t.push(e.content.serialize());const i={};e.scale&&(i["font-scale"]=e.scale.serialize()),e.font&&(i["text-font"]=e.font.serialize()),e.textColor&&(i["text-color"]=e.textColor.serialize()),t.push(i)}return t}}class He{constructor(t){this.type=Se,this.input=t}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,xe);return i?new He(i):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),i=Ve.fromString(e);return i&&t.availableImages&&(i.available=t.availableImages.indexOf(e)>-1),i}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const Ke={"to-boolean":ve,"to-color":be,"to-number":ye,"to-string":xe};class Ye{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[0];if(("to-boolean"===i||"to-string"===i)&&2!==t.length)return e.error("Expected one argument.");const r=Ke[i],n=[];for(let i=1;i<t.length;i++){const r=e.parse(t[i],i,Te);if(!r)return null;n.push(r)}return new Ye(r,n)}evaluate(t){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(t));if("color"===this.type.kind){let e,i;for(const r of this.args){if(e=r.evaluate(t),i=null,e instanceof Le)return e;if("string"==typeof e){const i=t.parseColor(e);if(i)return i}else if(Array.isArray(e)&&(i=e.length<3||e.length>4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:je(e[0],e[1],e[2],e[3]),!i))return new Le(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new Ge(i||`Could not parse color from value '${"string"==typeof e?e:String(JSON.stringify(e))}'`)}if("number"===this.type.kind){let e=null;for(const i of this.args){if(e=i.evaluate(t),null===e)return 0;const r=Number(e);if(!isNaN(r))return r}throw new Ge(`Could not convert ${JSON.stringify(e)} to number.`)}return"formatted"===this.type.kind?Oe.fromString(Ze(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?Ve.fromString(Ze(this.args[0].evaluate(t))):Ze(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new Xe([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new He(this.args[0]).serialize();const t=[`to-${this.type.kind}`];return this.eachChild((e=>{t.push(e.serialize())})),t}}const Je=["Unknown","Point","LineString","Polygon"];class Qe{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Je[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 t=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:i,y:r}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*e-t[0])+this.featureDistanceData.bearing[1]*(r*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=Le.parse(t)),e}}class ti{constructor(t,e,i,r){this.name=t,this.type=e,this._evaluate=i,this.args=r}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((t=>t.serialize())))}static parse(t,e){const i=t[0],r=ti.definitions[i];if(!r)return e.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const n=Array.isArray(r)?r[0]:r.type,s=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,o=s.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let a=null;for(const[r,s]of o){a=new Ti(e.registry,e.path,null,e.scope);const o=[];let l=!1;for(let e=1;e<t.length;e++){const i=t[e],n=Array.isArray(r)?r[e-1]:r.type,s=a.parse(i,1+o.length,n);if(!s){l=!0;break}o.push(s)}if(!l)if(Array.isArray(r)&&r.length!==o.length)a.error(`Expected ${r.length} arguments, but found ${o.length} instead.`);else{for(let t=0;t<o.length;t++){const e=Array.isArray(r)?r[t]:r.type,i=o[t];a.concat(t+1).checkSubtype(e,i.type)}if(0===a.errors.length)return new ti(i,n,s,o)}}if(1===o.length)e.errors.push(...a.errors);else{const i=(o.length?o:s).map((([t])=>{return e=t,Array.isArray(e)?`(${e.map(ze).join(", ")})`:`(${ze(e.type)}...)`;var e})).join(" | "),r=[];for(let i=1;i<t.length;i++){const n=e.parse(t[i],1+r.length);if(!n)return null;r.push(ze(n.type))}e.error(`Expected arguments of type ${i}, but found (${r.join(", ")}) instead.`)}return null}static register(t,e){ti.definitions=e;for(const i in e)t[i]=ti}}class ei{constructor(t,e,i){this.type=Ee,this.locale=i,this.caseSensitive=t,this.diacriticSensitive=e}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const i=t[1];if("object"!=typeof i||Array.isArray(i))return e.error("Collator options argument must be an object.");const r=e.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,ve);if(!r)return null;const n=e.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,ve);if(!n)return null;let s=null;return i.locale&&(s=e.parse(i.locale,1,xe),!s)?null:new ei(r,n,s)}evaluate(t){return new Re(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}serialize(){const t={};return t["case-sensitive"]=this.caseSensitive.serialize(),t["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(t.locale=this.locale.serialize()),["collator",t]}}const ii=8192;function ri(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1])}function ni(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function si(t,e){const i=(180+t[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,n=Math.pow(2,e.z);return[Math.round(i*n*ii),Math.round(r*n*ii)]}function oi(t,e,i){const r=t[0]-e[0],n=t[1]-e[1],s=t[0]-i[0],o=t[1]-i[1];return r*o-s*n==0&&r*s<=0&&n*o<=0}function ai(t,e){let i=!1;for(let o=0,a=e.length;o<a;o++){const a=e[o];for(let e=0,o=a.length;e<o-1;e++){if(oi(t,a[e],a[e+1]))return!1;(n=a[e])[1]>(r=t)[1]!=(s=a[e+1])[1]>r[1]&&r[0]<(s[0]-n[0])*(r[1]-n[1])/(s[1]-n[1])+n[0]&&(i=!i)}}var r,n,s;return i}function li(t,e){for(let i=0;i<e.length;i++)if(ai(t,e[i]))return!0;return!1}function ci(t,e,i,r){const n=r[0]-i[0],s=r[1]-i[1],o=(t[0]-i[0])*s-n*(t[1]-i[1]),a=(e[0]-i[0])*s-n*(e[1]-i[1]);return o>0&&a<0||o<0&&a>0}function hi(t,e,i){for(const c of i)for(let i=0;i<c.length-1;++i)if(0!=(a=[(o=c[i+1])[0]-(s=c[i])[0],o[1]-s[1]])[0]*(l=[(n=e)[0]-(r=t)[0],n[1]-r[1]])[1]-a[1]*l[0]&&ci(r,n,s,o)&&ci(s,o,r,n))return!0;var r,n,s,o,a,l;return!1}function ui(t,e){for(let i=0;i<t.length;++i)if(!ai(t[i],e))return!1;for(let i=0;i<t.length-1;++i)if(hi(t[i],t[i+1],e))return!1;return!0}function pi(t,e){for(let i=0;i<e.length;i++)if(ui(t,e[i]))return!0;return!1}function di(t,e,i){const r=[];for(let n=0;n<t.length;n++){const s=[];for(let r=0;r<t[n].length;r++){const o=si(t[n][r],i);ri(e,o),s.push(o)}r.push(s)}return r}function fi(t,e,i){const r=[];for(let n=0;n<t.length;n++){const s=di(t[n],e,i);r.push(s)}return r}function mi(t,e,i,r){if(t[0]<i[0]||t[0]>i[2]){const e=.5*r;let n=t[0]-i[0]>e?-r:i[0]-t[0]>e?r:0;0===n&&(n=t[0]-i[2]>e?-r:i[2]-t[0]>e?r:0),t[0]+=n}ri(e,t)}function _i(t,e,i,r){const n=Math.pow(2,r.z)*ii,s=[r.x*ii,r.y*ii],o=[];for(const r of t)for(const t of r){const r=[t.x+s[0],t.y+s[1]];mi(r,e,i,n),o.push(r)}return o}function gi(t,e,i,r){const n=Math.pow(2,r.z)*ii,s=[r.x*ii,r.y*ii],o=[];for(const i of t){const t=[];for(const r of i){const i=[r.x+s[0],r.y+s[1]];ri(e,i),t.push(i)}o.push(t)}if(e[2]-e[0]<=n/2){(a=e)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const t of o)for(const r of t)mi(r,e,i,n)}var a;return o}class yi{constructor(t,e){this.type=ve,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Ue(t[1])){const e=t[1];if("FeatureCollection"===e.type)for(let t=0;t<e.features.length;++t){const i=e.features[t].geometry.type;if("Polygon"===i||"MultiPolygon"===i)return new yi(e,e.features[t].geometry)}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new yi(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new yi(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=t.canonicalID();if("Polygon"===e.type){const s=di(e.coordinates,r,n),o=_i(t.geometry(),i,r,n);if(!ni(i,r))return!1;for(const t of o)if(!ai(t,s))return!1}if("MultiPolygon"===e.type){const s=fi(e.coordinates,r,n),o=_i(t.geometry(),i,r,n);if(!ni(i,r))return!1;for(const t of o)if(!li(t,s))return!1}return!0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=t.canonicalID();if("Polygon"===e.type){const s=di(e.coordinates,r,n),o=gi(t.geometry(),i,r,n);if(!ni(i,r))return!1;for(const t of o)if(!ui(t,s))return!1}if("MultiPolygon"===e.type){const s=fi(e.coordinates,r,n),o=gi(t.geometry(),i,r,n);if(!ni(i,r))return!1;for(const t of o)if(!pi(t,s))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}function xi(t){if(t instanceof ti){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof yi)return!1;let e=!0;return t.eachChild((t=>{e&&!xi(t)&&(e=!1)})),e}function vi(t){if(t instanceof ti&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!vi(t)&&(e=!1)})),e}function bi(t,e){if(t instanceof ti&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!bi(t,e)&&(i=!1)})),i}class wi{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const i=t[1];return e.scope.has(i)?new wi(i,e.scope.get(i)):e.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class Ti{constructor(t,e=[],i,r=new _e,n=[]){this.registry=t,this.path=e,this.key=e.map((t=>`[${t}]`)).join(""),this.scope=r,this.errors=n,this.expectedType=i}parse(t,e,i,r,n={}){return e?this.concat(e,i,r)._parse(t,n):this._parse(t,n)}_parse(t,e){function i(t,e,i){return"assert"===i?new We(e,[t]):"coerce"===i?new Ye(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r=t[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(t,this);if(!r)return null;if(this.expectedType){const t=this.expectedType,n=r.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==n.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==n.kind&&"string"!==n.kind){if(this.checkSubtype(t,n))return null}else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"assert")}if(!(r instanceof qe)&&"resolvedImage"!==r.type.kind&&Ei(r)){const t=new Qe;try{r=new qe(r.type,r.evaluate(t))}catch(t){return this.error(t.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,i){const r="number"==typeof t?this.path.concat(t):this.path,n=i?this.scope.concat(i):this.scope;return new Ti(this.registry,r,e||null,n,this.errors)}error(t,...e){const i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new me(i,t))}checkSubtype(t,e){const i=Me(t,e);return i&&this.error(i),i}}function Ei(t){if(t instanceof wi)return Ei(t.boundExpression);if(t instanceof ti&&"error"===t.name)return!1;if(t instanceof ei)return!1;if(t instanceof yi)return!1;const e=t instanceof Ye||t instanceof We;let i=!0;return t.eachChild((t=>{i=e?i&&Ei(t):i&&t instanceof qe})),!!i&&xi(t)&&bi(t,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function Ii(t,e){const i=t.length-1;let r,n,s=0,o=i,a=0;for(;s<=o;)if(a=Math.floor((s+o)/2),r=t[a],n=t[a+1],r<=e){if(a===i||e<n)return a;s=a+1}else{if(!(r>e))throw new Ge("Input is not a number.");o=a-1}return 0}class Si{constructor(t,e,i){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e)}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const i=e.parse(t[1],1,ye);if(!i)return null;const r=[];let n=null;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);for(let i=1;i<t.length;i+=2){const s=1===i?-1/0:t[i],o=t[i+1],a=i,l=i+1;if("number"!=typeof s)return e.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',a);if(r.length&&r[r.length-1][0]>=s)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=e.parse(o,l,n);if(!c)return null;n=n||c.type,r.push([s,c])}return new Si(n,i,r)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const n=e.length;return r>=e[n-1]?i[n-1].evaluate(t):i[Ii(e,r)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){const t=["step",this.input.serialize()];for(let e=0;e<this.labels.length;e++)e>0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t}}function Ai(t,e,i){return t*(1-i)+e*i}var zi=Object.freeze({__proto__:null,number:Ai,color:function(t,e,i){return new Le(Ai(t.r,e.r,i),Ai(t.g,e.g,i),Ai(t.b,e.b,i),Ai(t.a,e.a,i))},array:function(t,e,i){return t.map(((t,r)=>Ai(t,e[r],i)))}});const Ci=.95047,Mi=1.08883,ki=4/29,Pi=6/29,Di=3*Pi*Pi,Bi=Math.PI/180,Li=180/Math.PI;function Ri(t){return t>.008856451679035631?Math.pow(t,1/3):t/Di+ki}function Fi(t){return t>Pi?t*t*t:Di*(t-ki)}function Oi(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Vi(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function ji(t){const e=Vi(t.r),i=Vi(t.g),r=Vi(t.b),n=Ri((.4124564*e+.3575761*i+.1804375*r)/Ci),s=Ri((.2126729*e+.7151522*i+.072175*r)/1);return{l:116*s-16,a:500*(n-s),b:200*(s-Ri((.0193339*e+.119192*i+.9503041*r)/Mi)),alpha:t.a}}function Ui(t){let e=(t.l+16)/116,i=isNaN(t.a)?e:e+t.a/500,r=isNaN(t.b)?e:e-t.b/200;return e=1*Fi(e),i=Ci*Fi(i),r=Mi*Fi(r),new Le(Oi(3.2404542*i-1.5371385*e-.4985314*r),Oi(-.969266*i+1.8760108*e+.041556*r),Oi(.0556434*i-.2040259*e+1.0572252*r),t.alpha)}function Ni(t,e,i){const r=e-t;return t+i*(r>180||r<-180?r-360*Math.round(r/360):r)}const Zi={forward:ji,reverse:Ui,interpolate:function(t,e,i){return{l:Ai(t.l,e.l,i),a:Ai(t.a,e.a,i),b:Ai(t.b,e.b,i),alpha:Ai(t.alpha,e.alpha,i)}}},qi={forward:function(t){const{l:e,a:i,b:r}=ji(t),n=Math.atan2(r,i)*Li;return{h:n<0?n+360:n,c:Math.sqrt(i*i+r*r),l:e,alpha:t.a}},reverse:function(t){const e=t.h*Bi,i=t.c;return Ui({l:t.l,a:Math.cos(e)*i,b:Math.sin(e)*i,alpha:t.alpha})},interpolate:function(t,e,i){return{h:Ni(t.h,e.h,i),c:Ai(t.c,e.c,i),l:Ai(t.l,e.l,i),alpha:Ai(t.alpha,e.alpha,i)}}};var Gi=Object.freeze({__proto__:null,lab:Zi,hcl:qi});class $i{constructor(t,e,i,r,n){this.type=t,this.operator=e,this.interpolation=i,this.input=r,this.labels=[],this.outputs=[];for(const[t,e]of n)this.labels.push(t),this.outputs.push(e)}static interpolationFactor(t,e,i,r){let s=0;if("exponential"===t.name)s=Wi(e,t.base,i,r);else if("linear"===t.name)s=Wi(e,1,i,r);else if("cubic-bezier"===t.name){const o=t.controlPoints;s=new n(o[0],o[1],o[2],o[3]).solve(Wi(e,1,i,r))}return s}static parse(t,e){let[i,r,n,...s]=t;if(!Array.isArray(r)||0===r.length)return e.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const t=r[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:t}}else{if("cubic-bezier"!==r[0])return e.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const t=r.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:t}}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(n=e.parse(n,2,ye),!n)return null;const o=[];let a=null;"interpolate-hcl"===i||"interpolate-lab"===i?a=be:e.expectedType&&"value"!==e.expectedType.kind&&(a=e.expectedType);for(let t=0;t<s.length;t+=2){const i=s[t],r=s[t+1],n=t+3,l=t+4;if("number"!=typeof i)return e.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',n);if(o.length&&o[o.length-1][0]>=i)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',n);const c=e.parse(r,l,a);if(!c)return null;a=a||c.type,o.push([i,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new $i(a,i,r,n,o):e.error(`Type ${ze(a)} is not interpolatable.`)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const n=e.length;if(r>=e[n-1])return i[n-1].evaluate(t);const s=Ii(e,r),o=$i.interpolationFactor(this.interpolation,r,e[s],e[s+1]),a=i[s].evaluate(t),l=i[s+1].evaluate(t);return"interpolate"===this.operator?zi[this.type.kind.toLowerCase()](a,l,o):"interpolate-hcl"===this.operator?qi.reverse(qi.interpolate(qi.forward(a),qi.forward(l),o)):Zi.reverse(Zi.interpolate(Zi.forward(a),Zi.forward(l),o))}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){let t;t="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 e=[this.operator,t,this.input.serialize()];for(let t=0;t<this.labels.length;t++)e.push(this.labels[t],this.outputs[t].serialize());return e}}function Wi(t,e,i,r){const n=r-i,s=t-i;return 0===n?0:1===e?s/n:(Math.pow(e,s)-1)/(Math.pow(e,n)-1)}class Xi{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expectected at least one argument.");let i=null;const r=e.expectedType;r&&"value"!==r.kind&&(i=r);const n=[];for(const r of t.slice(1)){const t=e.parse(r,1+n.length,i,void 0,{typeAnnotation:"omit"});if(!t)return null;i=i||t.type,n.push(t)}const s=r&&n.some((t=>Me(r,t.type)));return new Xi(s?Te:i,n)}evaluate(t){let e,i=null,r=0;for(const n of this.args){if(r++,i=n.evaluate(t),i&&i instanceof Ve&&!i.available&&(e||(e=i),i=null,r===this.args.length))return e;if(null!==i)break}return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=["coalesce"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class Hi{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const i=[];for(let r=1;r<t.length-1;r+=2){const n=t[r];if("string"!=typeof n)return e.error(`Expected string, but found ${typeof n} instead.`,r);if(/[^a-zA-Z0-9_]/.test(n))return e.error("Variable names must contain only alphanumeric characters or '_'.",r);const s=e.parse(t[r+1],r+1);if(!s)return null;i.push([n,s])}const r=e.parse(t[t.length-1],t.length-1,e.expectedType,i);return r?new Hi(i,r):null}outputDefined(){return this.result.outputDefined()}serialize(){const t=["let"];for(const[e,i]of this.bindings)t.push(e,i.serialize());return t.push(this.result.serialize()),t}}class Ki{constructor(t,e,i){this.type=t,this.index=e,this.input=i}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,ye),r=e.parse(t[2],2,Ae(e.expectedType||Te));return i&&r?new Ki(r.type.itemType,i,r):null}evaluate(t){const e=this.index.evaluate(t),i=this.input.evaluate(t);if(e<0)throw new Ge(`Array index out of bounds: ${e} < 0.`);if(e>=i.length)throw new Ge(`Array index out of bounds: ${e} > ${i.length-1}.`);if(e!==Math.floor(e))throw new Ge(`Array index must be an integer, but found ${e} instead.`);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class Yi{constructor(t,e){this.type=ve,this.needle=t,this.haystack=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Te),r=e.parse(t[2],2,Te);return i&&r?ke(i.type,[ve,xe,ye,ge,Te])?new Yi(i,r):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${ze(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(null==i)return!1;if(!Pe(e,["boolean","string","number","null"]))throw new Ge(`Expected first argument to be of type boolean, string, number or null, but found ${ze(Ne(e))} instead.`);if(!Pe(i,["string","array"]))throw new Ge(`Expected second argument to be of type array or string, but found ${ze(Ne(i))} instead.`);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class Ji{constructor(t,e,i){this.type=ye,this.needle=t,this.haystack=e,this.fromIndex=i}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Te),r=e.parse(t[2],2,Te);if(!i||!r)return null;if(!ke(i.type,[ve,xe,ye,ge,Te]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${ze(i.type)} instead`);if(4===t.length){const n=e.parse(t[3],3,ye);return n?new Ji(i,r,n):null}return new Ji(i,r)}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!Pe(e,["boolean","string","number","null"]))throw new Ge(`Expected first argument to be of type boolean, string, number or null, but found ${ze(Ne(e))} instead.`);if(!Pe(i,["string","array"]))throw new Ge(`Expected second argument to be of type array or string, but found ${ze(Ne(i))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(t);return i.indexOf(e,r)}return i.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class Qi{constructor(t,e,i,r,n,s){this.inputType=t,this.type=e,this.input=i,this.cases=r,this.outputs=n,this.otherwise=s}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let i,r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const n={},s=[];for(let o=2;o<t.length-1;o+=2){let a=t[o];const l=t[o+1];Array.isArray(a)||(a=[a]);const c=e.concat(o);if(0===a.length)return c.error("Expected at least one branch label.");for(const t of a){if("number"!=typeof t&&"string"!=typeof t)return c.error("Branch labels must be numbers or strings.");if("number"==typeof t&&Math.abs(t)>Number.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,Ne(t)))return null}else i=Ne(t);if(void 0!==n[String(t)])return c.error("Branch labels must be unique.");n[String(t)]=s.length}const h=e.parse(l,o,r);if(!h)return null;r=r||h.type,s.push(h)}const o=e.parse(t[1],1,Te);if(!o)return null;const a=e.parse(t[t.length-1],t.length-1,r);return a?"value"!==o.type.kind&&e.concat(1).checkSubtype(i,o.type)?null:new Qi(i,r,o,n,s,a):null}evaluate(t){const e=this.input.evaluate(t);return(Ne(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],e=Object.keys(this.cases).sort(),i=[],r={};for(const t of e){const e=r[this.cases[t]];void 0===e?(r[this.cases[t]]=i.length,i.push([this.cases[t],[t]])):i[e][1].push(t)}const n=t=>"number"===this.inputType.kind?Number(t):t;for(const[e,r]of i)t.push(1===r.length?n(r[0]):r.map(n)),t.push(this.outputs[e].serialize());return t.push(this.otherwise.serialize()),t}}class tr{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let i;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);const r=[];for(let n=1;n<t.length-1;n+=2){const s=e.parse(t[n],n,ve);if(!s)return null;const o=e.parse(t[n+1],n+1,i);if(!o)return null;r.push([s,o]),i=i||o.type}const n=e.parse(t[t.length-1],t.length-1,i);return n?new tr(i,r,n):null}evaluate(t){for(const[e,i]of this.branches)if(e.evaluate(t))return i.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(const[e,i]of this.branches)t(e),t(i);t(this.otherwise)}outputDefined(){return this.branches.every((([t,e])=>e.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class er{constructor(t,e,i,r){this.type=t,this.input=e,this.beginIndex=i,this.endIndex=r}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Te),r=e.parse(t[2],2,ye);if(!i||!r)return null;if(!ke(i.type,[Ae(Te),xe,Te]))return e.error(`Expected first argument to be of type array or string, but found ${ze(i.type)} instead`);if(4===t.length){const n=e.parse(t[3],3,ye);return n?new er(i.type,i,r,n):null}return new er(i.type,i,r)}evaluate(t){const e=this.input.evaluate(t),i=this.beginIndex.evaluate(t);if(!Pe(e,["string","array"]))throw new Ge(`Expected first argument to be of type array or string, but found ${ze(Ne(e))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(t);return e.slice(i,r)}return e.slice(i)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function ir(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function rr(t,e,i,r){return 0===r.compare(e,i)}function nr(t,e,i){const r="=="!==t&&"!="!==t;return class n{constructor(t,e,i){this.type=ve,this.lhs=t,this.rhs=e,this.collator=i,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const i=t[0];let s=e.parse(t[1],1,Te);if(!s)return null;if(!ir(i,s.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${ze(s.type)}'.`);let o=e.parse(t[2],2,Te);if(!o)return null;if(!ir(i,o.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${ze(o.type)}'.`);if(s.type.kind!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return e.error(`Cannot compare types '${ze(s.type)}' and '${ze(o.type)}'.`);r&&("value"===s.type.kind&&"value"!==o.type.kind?s=new We(o.type,[s]):"value"!==s.type.kind&&"value"===o.type.kind&&(o=new We(s.type,[o])));let a=null;if(4===t.length){if("string"!==s.type.kind&&"string"!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,Ee),!a)return null}return new n(s,o,a)}evaluate(n){const s=this.lhs.evaluate(n),o=this.rhs.evaluate(n);if(r&&this.hasUntypedArgument){const e=Ne(s),i=Ne(o);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new Ge(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const t=Ne(s),i=Ne(o);if("string"!==t.kind||"string"!==i.kind)return e(n,s,o)}return this.collator?i(n,s,o,this.collator.evaluate(n)):e(n,s,o)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}serialize(){const e=[t];return this.eachChild((t=>{e.push(t.serialize())})),e}}}const sr=nr("==",(function(t,e,i){return e===i}),rr),or=nr("!=",(function(t,e,i){return e!==i}),(function(t,e,i,r){return!rr(0,e,i,r)})),ar=nr("<",(function(t,e,i){return e<i}),(function(t,e,i,r){return r.compare(e,i)<0})),lr=nr(">",(function(t,e,i){return e>i}),(function(t,e,i,r){return r.compare(e,i)>0})),cr=nr("<=",(function(t,e,i){return e<=i}),(function(t,e,i,r){return r.compare(e,i)<=0})),hr=nr(">=",(function(t,e,i){return e>=i}),(function(t,e,i,r){return r.compare(e,i)>=0}));class ur{constructor(t,e,i,r,n){this.type=xe,this.number=t,this.locale=e,this.currency=i,this.minFractionDigits=r,this.maxFractionDigits=n}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,ye);if(!i)return null;const r=t[2];if("object"!=typeof r||Array.isArray(r))return e.error("NumberFormat options argument must be an object.");let n=null;if(r.locale&&(n=e.parse(r.locale,1,xe),!n))return null;let s=null;if(r.currency&&(s=e.parse(r.currency,1,xe),!s))return null;let o=null;if(r["min-fraction-digits"]&&(o=e.parse(r["min-fraction-digits"],1,ye),!o))return null;let a=null;return r["max-fraction-digits"]&&(a=e.parse(r["max-fraction-digits"],1,ye),!a)?null:new ur(i,n,s,o,a)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class pr{constructor(t){this.type=ye,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=e.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?e.error(`Expected argument of type string or array, but found ${ze(i.type)} instead.`):new pr(i):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new Ge(`Expected value to be of type string or array, but found ${ze(Ne(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){const t=["length"];return this.eachChild((e=>{t.push(e.serialize())})),t}}const dr={"==":sr,"!=":or,">":lr,"<":ar,">=":hr,"<=":cr,array:We,at:Ki,boolean:We,case:tr,coalesce:Xi,collator:ei,format:Xe,image:He,in:Yi,"index-of":Ji,interpolate:$i,"interpolate-hcl":$i,"interpolate-lab":$i,length:pr,let:Hi,literal:qe,match:Qi,number:We,"number-format":ur,object:We,slice:er,step:Si,string:We,"to-boolean":Ye,"to-color":Ye,"to-number":Ye,"to-string":Ye,var:wi,within:yi};function fr(t,[e,i,r,n]){e=e.evaluate(t),i=i.evaluate(t),r=r.evaluate(t);const s=n?n.evaluate(t):1,o=je(e,i,r,s);if(o)throw new Ge(o);return new Le(e/255*s,i/255*s,r/255*s,s)}function mr(t,e){return t in e}function _r(t,e){const i=e[t];return void 0===i?null:i}function gr(t){return{type:t}}function yr(t){return{result:"success",value:t}}function xr(t){return{result:"error",value:t}}function vr(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function br(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function wr(t){return!!t.expression&&t.expression.interpolated}function Tr(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Er(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Ir(t){return t}function Sr(t,e){const i="color"===e.type,r=t.stops&&"object"==typeof t.stops[0][0],n=r||!(r||void 0!==t.property),s=t.type||(wr(e)?"exponential":"interval");if(i&&((t=pe({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],Le.parse(t[1])]))),t.default=Le.parse(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!Gi[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let o,a,l;if("exponential"===s)o=Mr;else if("interval"===s)o=Cr;else if("categorical"===s){o=zr,a=Object.create(null);for(const e of t.stops)a[e[0]]=e[1];l=typeof t.stops[0][0]}else{if("identity"!==s)throw new Error(`Unknown function type "${s}"`);o=kr}if(r){const i={},r=[];for(let e=0;e<t.stops.length;e++){const n=t.stops[e],s=n[0].zoom;void 0===i[s]&&(i[s]={zoom:s,type:t.type,property:t.property,default:t.default,stops:[]},r.push(s)),i[s].stops.push([n[0].value,n[1]])}const n=[];for(const t of r)n.push([i[t].zoom,Sr(i[t],e)]);const s={name:"linear"};return{kind:"composite",interpolationType:s,interpolationFactor:$i.interpolationFactor.bind(void 0,s),zoomStops:n.map((t=>t[0])),evaluate:({zoom:i},r)=>Mr({stops:n,base:t.base},e,i).evaluate(i,r)}}if(n){const i="exponential"===s?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:$i.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:i})=>o(t,e,i,a,l)}}return{kind:"source",evaluate(i,r){const n=r&&r.properties?r.properties[t.property]:void 0;return void 0===n?Ar(t.default,e.default):o(t,e,n,a,l)}}}function Ar(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function zr(t,e,i,r,n){return Ar(typeof i===n?r[i]:void 0,t.default,e.default)}function Cr(t,e,i){if("number"!==Tr(i))return Ar(t.default,e.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[r-1][0])return t.stops[r-1][1];const n=Ii(t.stops.map((t=>t[0])),i);return t.stops[n][1]}function Mr(t,e,i){const r=void 0!==t.base?t.base:1;if("number"!==Tr(i))return Ar(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[n-1][0])return t.stops[n-1][1];const s=Ii(t.stops.map((t=>t[0])),i),o=function(t,e,i,r){const n=r-i,s=t-i;return 0===n?0:1===e?s/n:(Math.pow(e,s)-1)/(Math.pow(e,n)-1)}(i,r,t.stops[s][0],t.stops[s+1][0]),a=t.stops[s][1],l=t.stops[s+1][1];let c=zi[e.type]||Ir;if(t.colorSpace&&"rgb"!==t.colorSpace){const e=Gi[t.colorSpace];c=(t,i)=>e.reverse(e.interpolate(e.forward(t),e.forward(i),o))}return"function"==typeof a.evaluate?{evaluate(...t){const e=a.evaluate.apply(void 0,t),i=l.evaluate.apply(void 0,t);if(void 0!==e&&void 0!==i)return c(e,i,o)}}:c(a,l,o)}function kr(t,e,i){return"color"===e.type?i=Le.parse(i):"formatted"===e.type?i=Oe.fromString(i.toString()):"resolvedImage"===e.type?i=Ve.fromString(i.toString()):Tr(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0),Ar(i,t.default,e.default)}ti.register(dr,{error:[{kind:"error"},[xe],(t,[e])=>{throw new Ge(e.evaluate(t))}],typeof:[xe,[Te],(t,[e])=>ze(Ne(e.evaluate(t)))],"to-rgba":[Ae(ye,4),[be],(t,[e])=>e.evaluate(t).toArray()],rgb:[be,[ye,ye,ye],fr],rgba:[be,[ye,ye,ye,ye],fr],has:{type:ve,overloads:[[[xe],(t,[e])=>mr(e.evaluate(t),t.properties())],[[xe,we],(t,[e,i])=>mr(e.evaluate(t),i.evaluate(t))]]},get:{type:Te,overloads:[[[xe],(t,[e])=>_r(e.evaluate(t),t.properties())],[[xe,we],(t,[e,i])=>_r(e.evaluate(t),i.evaluate(t))]]},"feature-state":[Te,[xe],(t,[e])=>_r(e.evaluate(t),t.featureState||{})],properties:[we,[],t=>t.properties()],"geometry-type":[xe,[],t=>t.geometryType()],id:[Te,[],t=>t.id()],zoom:[ye,[],t=>t.globals.zoom],pitch:[ye,[],t=>t.globals.pitch||0],"distance-from-center":[ye,[],t=>t.distanceFromCenter()],"heatmap-density":[ye,[],t=>t.globals.heatmapDensity||0],"line-progress":[ye,[],t=>t.globals.lineProgress||0],"sky-radial-progress":[ye,[],t=>t.globals.skyRadialProgress||0],accumulated:[Te,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[ye,gr(ye),(t,e)=>{let i=0;for(const r of e)i+=r.evaluate(t);return i}],"*":[ye,gr(ye),(t,e)=>{let i=1;for(const r of e)i*=r.evaluate(t);return i}],"-":{type:ye,overloads:[[[ye,ye],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[ye],(t,[e])=>-e.evaluate(t)]]},"/":[ye,[ye,ye],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[ye,[ye,ye],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[ye,[],()=>Math.LN2],pi:[ye,[],()=>Math.PI],e:[ye,[],()=>Math.E],"^":[ye,[ye,ye],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[ye,[ye],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[ye,[ye],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[ye,[ye],(t,[e])=>Math.log(e.evaluate(t))],log2:[ye,[ye],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[ye,[ye],(t,[e])=>Math.sin(e.evaluate(t))],cos:[ye,[ye],(t,[e])=>Math.cos(e.evaluate(t))],tan:[ye,[ye],(t,[e])=>Math.tan(e.evaluate(t))],asin:[ye,[ye],(t,[e])=>Math.asin(e.evaluate(t))],acos:[ye,[ye],(t,[e])=>Math.acos(e.evaluate(t))],atan:[ye,[ye],(t,[e])=>Math.atan(e.evaluate(t))],min:[ye,gr(ye),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[ye,gr(ye),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[ye,[ye],(t,[e])=>Math.abs(e.evaluate(t))],round:[ye,[ye],(t,[e])=>{const i=e.evaluate(t);return i<0?-Math.round(-i):Math.round(i)}],floor:[ye,[ye],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[ye,[ye],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[ve,[xe,Te],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[ve,[Te],(t,[e])=>t.id()===e.value],"filter-type-==":[ve,[xe],(t,[e])=>t.geometryType()===e.value],"filter-<":[ve,[xe,Te],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r<n}],"filter-id-<":[ve,[Te],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i<r}],"filter->":[ve,[xe,Te],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r>n}],"filter-id->":[ve,[Te],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>r}],"filter-<=":[ve,[xe,Te],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r<=n}],"filter-id-<=":[ve,[Te],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i<=r}],"filter->=":[ve,[xe,Te],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r>=n}],"filter-id->=":[ve,[Te],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>=r}],"filter-has":[ve,[Te],(t,[e])=>e.value in t.properties()],"filter-has-id":[ve,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[ve,[Ae(xe)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[ve,[Ae(Te)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[ve,[xe,Ae(Te)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[ve,[xe,Ae(Te)],(t,[e,i])=>function(t,e,i,r){for(;i<=r;){const n=i+r>>1;if(e[n]===t)return!0;e[n]>t?r=n-1:i=n+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:ve,overloads:[[[ve,ve],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[gr(ve),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:ve,overloads:[[[ve,ve],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[gr(ve),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[ve,[ve],(t,[e])=>!e.evaluate(t)],"is-supported-script":[ve,[xe],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[xe,[xe],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[xe,[xe],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[xe,gr(Te),(t,e)=>e.map((e=>Ze(e.evaluate(t)))).join("")],"resolved-locale":[xe,[Ee],(t,[e])=>e.evaluate(t).resolvedLocale()]});class Pr{constructor(t,e){this.expression=t,this._warningHistory={},this._evaluator=new Qe,this._defaultValue=e?function(t){return"color"===t.type&&Er(t.default)?new Le(0,0,0,0):"color"===t.type?Le.parse(t.default)||null:void 0===t.default?null:t.default}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null}evaluateWithoutErrorHandling(t,e,i,r,n,s,o,a){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=i,this._evaluator.canonical=r,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=s,this._evaluator.featureTileCoord=o||null,this._evaluator.featureDistanceData=a||null,this.expression.evaluate(this._evaluator)}evaluate(t,e,i,r,n,s,o,a){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=s||null,this._evaluator.featureTileCoord=o||null,this._evaluator.featureDistanceData=a||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new Ge(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function Dr(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in dr}function Br(t,e){const i=new Ti(dr,[],e?function(t){const e={color:be,string:xe,number:ye,enum:xe,boolean:ve,formatted:Ie,resolvedImage:Se};return"array"===t.type?Ae(e[t.value]||Te,t.length):e[t.type]}(e):void 0),r=i.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return r?yr(new Pr(r,e)):xr(i.errors)}class Lr{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!vi(e.expression)}evaluateWithoutErrorHandling(t,e,i,r,n,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,n,s)}evaluate(t,e,i,r,n,s){return this._styleExpression.evaluate(t,e,i,r,n,s)}}class Rr{constructor(t,e,i,r){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!vi(e.expression),this.interpolationType=r}evaluateWithoutErrorHandling(t,e,i,r,n,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,n,s)}evaluate(t,e,i,r,n,s){return this._styleExpression.evaluate(t,e,i,r,n,s)}interpolationFactor(t,e,i){return this.interpolationType?$i.interpolationFactor(this.interpolationType,t,e,i):0}}function Fr(t,e){if("error"===(t=Br(t,e)).result)return t;const i=t.value.expression,r=xi(i);if(!r&&!vr(e))return xr([new me("","data expressions not supported")]);const n=bi(i,["zoom","pitch","distance-from-center"]);if(!n&&!br(e))return xr([new me("","zoom expressions not supported")]);const s=Vr(i);return s||n?s instanceof me?xr([s]):s instanceof $i&&!wr(e)?xr([new me("",'"interpolate" expressions cannot be used with this property')]):yr(s?new Rr(r?"camera":"composite",t.value,s.labels,s instanceof $i?s.interpolation:void 0):new Lr(r?"constant":"source",t.value)):xr([new me("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Or{constructor(t,e){this._parameters=t,this._specification=e,pe(this,Sr(this._parameters,this._specification))}static deserialize(t){return new Or(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function Vr(t){let e=null;if(t instanceof Hi)e=Vr(t.result);else if(t instanceof Xi){for(const i of t.args)if(e=Vr(i),e)break}else(t instanceof Si||t instanceof $i)&&t.input instanceof ti&&"zoom"===t.input.name&&(e=t);return e instanceof me||t.eachChild((t=>{const i=Vr(t);i instanceof me?e=i:!e&&i?e=new me("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&i&&e!==i&&(e=new me("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}class jr{constructor(t,e,i,r){this.message=(t?`${t}: `:"")+i,r&&(this.identifier=r),null!=e&&e.__line__&&(this.line=e.__line__)}}function Ur(t){const e=t.key,i=t.value,r=t.valueSpec||{},n=t.objectElementValidators||{},s=t.style,o=t.styleSpec;let a=[];const l=Tr(i);if("object"!==l)return[new jr(e,i,`object expected, ${l} found`)];for(const t in i){const l=t.split(".")[0],c=r[l]||r["*"];let h;if(n[l])h=n[l];else if(r[l])h=bn;else if(n["*"])h=n["*"];else{if(!r["*"]){a.push(new jr(e,i[t],`unknown property "${t}"`));continue}h=bn}a=a.concat(h({key:(e?`${e}.`:e)+t,value:i[t],valueSpec:c,style:s,styleSpec:o,object:i,objectKey:t},i))}for(const t in r)n[t]||r[t].required&&void 0===r[t].default&&void 0===i[t]&&a.push(new jr(e,i,`missing required property "${t}"`));return a}function Nr(t){const e=t.value,i=t.valueSpec,r=t.style,n=t.styleSpec,s=t.key,o=t.arrayElementValidator||bn;if("array"!==Tr(e))return[new jr(s,e,`array expected, ${Tr(e)} found`)];if(i.length&&e.length!==i.length)return[new jr(s,e,`array length ${i.length} expected, length ${e.length} found`)];if(i["min-length"]&&e.length<i["min-length"])return[new jr(s,e,`array length at least ${i["min-length"]} expected, length ${e.length} found`)];let a={type:i.value,values:i.values,minimum:i.minimum,maximum:i.maximum};n.$version<7&&(a.function=i.function),"object"===Tr(i.value)&&(a=i.value);let l=[];for(let t=0;t<e.length;t++)l=l.concat(o({array:e,arrayIndex:t,value:e[t],valueSpec:a,style:r,styleSpec:n,key:`${s}[${t}]`}));return l}function Zr(t){const e=t.key,i=t.value,r=t.valueSpec;let n=Tr(i);if("number"===n&&i!=i&&(n="NaN"),"number"!==n)return[new jr(e,i,`number expected, ${n} found`)];if("minimum"in r){let n=r.minimum;if("array"===Tr(r.minimum)&&(n=r.minimum[t.arrayIndex]),i<n)return[new jr(e,i,`${i} is less than the minimum value ${n}`)]}if("maximum"in r){let n=r.maximum;if("array"===Tr(r.maximum)&&(n=r.maximum[t.arrayIndex]),i>n)return[new jr(e,i,`${i} is greater than the maximum value ${n}`)]}return[]}function qr(t){const e=t.valueSpec,i=de(t.value.type);let r,n,s,o={};const a="categorical"!==i&&void 0===t.value.property,l=!a,c="array"===Tr(t.value.stops)&&"array"===Tr(t.value.stops[0])&&"object"===Tr(t.value.stops[0][0]),h=Ur({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===i)return[new jr(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const r=t.value;return e=e.concat(Nr({key:t.key,value:r,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:u})),"array"===Tr(r)&&0===r.length&&e.push(new jr(t.key,r,"array must have at least one stop")),e},default:function(t){return bn({key:t.key,value:t.value,valueSpec:e,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===i&&a&&h.push(new jr(t.key,t.value,'missing required property "property"')),"identity"===i||t.value.stops||h.push(new jr(t.key,t.value,'missing required property "stops"')),"exponential"===i&&t.valueSpec.expression&&!wr(t.valueSpec)&&h.push(new jr(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!vr(t.valueSpec)?h.push(new jr(t.key,t.value,"property functions not supported")):a&&!br(t.valueSpec)&&h.push(new jr(t.key,t.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==t.value.property||h.push(new jr(t.key,t.value,'"property" property is required')),h;function u(t){let i=[];const r=t.value,a=t.key;if("array"!==Tr(r))return[new jr(a,r,`array expected, ${Tr(r)} found`)];if(2!==r.length)return[new jr(a,r,`array length 2 expected, length ${r.length} found`)];if(c){if("object"!==Tr(r[0]))return[new jr(a,r,`object expected, ${Tr(r[0])} found`)];if(void 0===r[0].zoom)return[new jr(a,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new jr(a,r,"object stop key must have value")];if(s&&s>de(r[0].zoom))return[new jr(a,r[0].zoom,"stop zoom values must appear in ascending order")];de(r[0].zoom)!==s&&(s=de(r[0].zoom),n=void 0,o={}),i=i.concat(Ur({key:`${a}[0]`,value:r[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:Zr,value:p}}))}else i=i.concat(p({key:`${a}[0]`,value:r[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},r));return Dr(fe(r[1]))?i.concat([new jr(`${a}[1]`,r[1],"expressions are not allowed in function stops.")]):i.concat(bn({key:`${a}[1]`,value:r[1],valueSpec:e,style:t.style,styleSpec:t.styleSpec}))}function p(t,s){const a=Tr(t.value),l=de(t.value),c=null!==t.value?t.value:s;if(r){if(a!==r)return[new jr(t.key,c,`${a} stop domain type must match previous stop domain type ${r}`)]}else r=a;if("number"!==a&&"string"!==a&&"boolean"!==a)return[new jr(t.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let r=`number expected, ${a} found`;return vr(e)&&void 0===i&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new jr(t.key,c,r)]}return"categorical"!==i||"number"!==a||isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===a&&void 0!==n&&l<n?[new jr(t.key,c,"stop domain values must appear in ascending order")]:(n=l,"categorical"===i&&l in o?[new jr(t.key,c,"stop domain values must be unique")]:(o[l]=!0,[])):[new jr(t.key,c,`integer expected, found ${l}`)]}}function Gr(t){const e=("property"===t.expressionContext?Fr:Br)(fe(t.value),t.valueSpec);if("error"===e.result)return e.value.map((e=>new jr(`${t.key}${e.key}`,t.value,e.message)));const i=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!i.outputDefined())return[new jr(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!vi(i))return[new jr(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return $r(i,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!bi(i,["zoom","feature-state"]))return[new jr(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!xi(i))return[new jr(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function $r(t,e){const i=new Set(["zoom","feature-state","pitch","distance-from-center"]);for(const t of e.valueSpec.expression.parameters)i.delete(t);if(0===i.size)return[];const r=[];return t instanceof ti&&i.has(t.name)?[new jr(e.key,e.value,`["${t.name}"] expression is not supported in a filter for a ${e.object.type} layer with id: ${e.object.id}`)]:(t.eachChild((t=>{r.push(...$r(t,e))})),r)}function Wr(t){const e=t.key,i=t.value,r=t.valueSpec,n=[];return Array.isArray(r.values)?-1===r.values.indexOf(de(i))&&n.push(new jr(e,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(de(i))&&n.push(new jr(e,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),n}function Xr(t){if(!0===t||!1===t)return!0;if(!Array.isArray(t)||0===t.length)return!1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!Xr(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}function Hr(t,e="fill"){if(null==t)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Xr(t)||(t=rn(t));const i=t;let r=!0;try{r=function(t){if(!Jr(t))return t;let e=fe(t);return Yr(e),e=Kr(e),e}(i)}catch(t){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=ue[`filter_${e}`],s=Br(r,n);let o=null;if("error"===s.result)throw new Error(s.value.map((t=>`${t.key}: ${t.message}`)).join(", "));o=(t,e,i)=>s.value.evaluate(t,e,{},i);let a=null,l=null;if(r!==i){const t=Br(i,n);if("error"===t.result)throw new Error(t.value.map((t=>`${t.key}: ${t.message}`)).join(", "));a=(e,i,r,n,s)=>t.value.evaluate(e,i,{},r,void 0,void 0,n,s),l=!xi(t.value.expression)}return o=o,{filter:o,dynamicFilter:a||void 0,needGeometry:en(r),needFeature:!!l}}function Kr(t){if(!Array.isArray(t))return t;const e=function(t){if(Qr.has(t[0]))for(let e=1;e<t.length;e++)if(Jr(t[e]))return!0;return t}(t);return!0===e?e:e.map((t=>Kr(t)))}function Yr(t){let e=!1;const i=[];if("case"===t[0]){for(let r=1;r<t.length-1;r+=2)e=e||Jr(t[r]),i.push(t[r+1]);i.push(t[t.length-1])}else if("match"===t[0]){e=e||Jr(t[1]);for(let e=2;e<t.length-1;e+=2)i.push(t[e+1]);i.push(t[t.length-1])}else if("step"===t[0]){e=e||Jr(t[1]);for(let e=1;e<t.length-1;e+=2)i.push(t[e+1])}e&&(t.length=0,t.push("any",...i));for(let e=1;e<t.length;e++)Yr(t[e])}function Jr(t){if(!Array.isArray(t))return!1;if("pitch"===(e=t[0])||"distance-from-center"===e)return!0;var e;for(let e=1;e<t.length;e++)if(Jr(t[e]))return!0;return!1}const Qr=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function tn(t,e){return t<e?-1:t>e?1:0}function en(t){if(!Array.isArray(t))return!1;if("within"===t[0])return!0;for(let e=1;e<t.length;e++)if(en(t[e]))return!0;return!1}function rn(t){if(!t)return!0;const e=t[0];return t.length<=1?"any"!==e:"=="===e?nn(t[1],t[2],"=="):"!="===e?an(nn(t[1],t[2],"==")):"<"===e||">"===e||"<="===e||">="===e?nn(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(rn))):"all"===e?["all"].concat(t.slice(1).map(rn)):"none"===e?["all"].concat(t.slice(1).map(rn).map(an)):"in"===e?sn(t[1],t.slice(2)):"!in"===e?an(sn(t[1],t.slice(2))):"has"===e?on(t[1]):"!has"===e?an(on(t[1])):"within"!==e||t;var i}function nn(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function sn(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(tn)]]:["filter-in-small",t,["literal",e]]}}function on(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function an(t){return["!",t]}function ln(t){if(Xr(fe(t.value))){const e=fe(t.layerType);return Gr(pe({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${e||"fill"}`]}))}return cn(t)}function cn(t){const e=t.value,i=t.key;if("array"!==Tr(e))return[new jr(i,e,`array expected, ${Tr(e)} found`)];const r=t.styleSpec;let n,s=[];if(e.length<1)return[new jr(i,e,"filter array must have at least 1 element")];switch(s=s.concat(Wr({key:`${i}[0]`,value:e[0],valueSpec:r.filter_operator,style:t.style,styleSpec:t.styleSpec})),de(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===de(e[1])&&s.push(new jr(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&s.push(new jr(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(n=Tr(e[1]),"string"!==n&&s.push(new jr(`${i}[1]`,e[1],`string expected, ${n} found`)));for(let o=2;o<e.length;o++)n=Tr(e[o]),"$type"===de(e[1])?s=s.concat(Wr({key:`${i}[${o}]`,value:e[o],valueSpec:r.geometry_type,style:t.style,styleSpec:t.styleSpec})):"string"!==n&&"number"!==n&&"boolean"!==n&&s.push(new jr(`${i}[${o}]`,e[o],`string, number, or boolean expected, ${n} found`));break;case"any":case"all":case"none":for(let r=1;r<e.length;r++)s=s.concat(cn({key:`${i}[${r}]`,value:e[r],style:t.style,styleSpec:t.styleSpec}));break;case"has":case"!has":n=Tr(e[1]),2!==e.length?s.push(new jr(i,e,`filter array for "${e[0]}" operator must have 2 elements`)):"string"!==n&&s.push(new jr(`${i}[1]`,e[1],`string expected, ${n} found`));break;case"within":n=Tr(e[1]),2!==e.length?s.push(new jr(i,e,`filter array for "${e[0]}" operator must have 2 elements`)):"object"!==n&&s.push(new jr(`${i}[1]`,e[1],`object expected, ${n} found`))}return s}function hn(t,e){const i=t.key,r=t.style,n=t.styleSpec,s=t.value,o=t.objectKey,a=n[`${e}_${t.layerType}`];if(!a)return[];const l=o.match(/^(.*)-transition$/);if("paint"===e&&l&&a[l[1]]&&a[l[1]].transition)return bn({key:i,value:s,valueSpec:n.transition,style:r,styleSpec:n});const c=t.valueSpec||a[o];if(!c)return[new jr(i,s,`unknown property "${o}"`)];let h;if("string"===Tr(s)&&vr(c)&&!c.tokens&&(h=/^{([^}]+)}$/.exec(s)))return[new jr(i,s,`"${o}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(h[1])} }\`.`)];const u=[];return"symbol"===t.layerType&&("text-field"===o&&r&&!r.glyphs&&u.push(new jr(i,s,'use of "text-field" requires a style "glyphs" property')),"text-font"===o&&Er(fe(s))&&"identity"===de(s.type)&&u.push(new jr(i,s,'"text-font" does not support identity functions'))),u.concat(bn({key:t.key,value:s,valueSpec:c,style:r,styleSpec:n,expressionContext:"property",propertyType:e,propertyKey:o}))}function un(t){return hn(t,"paint")}function pn(t){return hn(t,"layout")}function dn(t){let e=[];const i=t.value,r=t.key,n=t.style,s=t.styleSpec;i.type||i.ref||e.push(new jr(r,i,'either "type" or "ref" is required'));let o=de(i.type);const a=de(i.ref);if(i.id){const s=de(i.id);for(let o=0;o<t.arrayIndex;o++){const t=n.layers[o];de(t.id)===s&&e.push(new jr(r,i.id,`duplicate layer id "${i.id}", previously used at line ${t.id.__line__}`))}}if("ref"in i){let t;["type","source","source-layer","filter","layout"].forEach((t=>{t in i&&e.push(new jr(r,i[t],`"${t}" is prohibited for ref layers`))})),n.layers.forEach((e=>{de(e.id)===a&&(t=e)})),t?t.ref?e.push(new jr(r,i.ref,"ref cannot reference another ref layer")):o=de(t.type):e.push(new jr(r,i.ref,`ref layer "${a}" not found`))}else if("background"!==o&&"sky"!==o)if(i.source){const t=n.sources&&n.sources[i.source],s=t&&de(t.type);t?"vector"===s&&"raster"===o?e.push(new jr(r,i.source,`layer "${i.id}" requires a raster source`)):"raster"===s&&"raster"!==o?e.push(new jr(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==s||i["source-layer"]?"raster-dem"===s&&"hillshade"!==o?e.push(new jr(r,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==o||!i.paint||!i.paint["line-gradient"]||"geojson"===s&&t.lineMetrics||e.push(new jr(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new jr(r,i,`layer "${i.id}" must specify a "source-layer"`)):e.push(new jr(r,i.source,`source "${i.source}" not found`))}else e.push(new jr(r,i,'missing required property "source"'));return e=e.concat(Ur({key:r,value:i,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>bn({key:`${r}.type`,value:i.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,object:i,objectKey:"type"}),filter:t=>ln(pe({layerType:o},t)),layout:t=>Ur({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>pn(pe({layerType:o},t))}}),paint:t=>Ur({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>un(pe({layerType:o},t))}})}})),e}function fn(t){const e=t.value,i=t.key,r=Tr(e);return"string"!==r?[new jr(i,e,`string expected, ${r} found`)]:[]}const mn={promoteId:function({key:t,value:e}){if("string"===Tr(e))return fn({key:t,value:e});{const i=[];for(const r in e)i.push(...fn({key:`${t}.${r}`,value:e[r]}));return i}}};function _n(t){const e=t.value,i=t.key,r=t.styleSpec,n=t.style;if(!e.type)return[new jr(i,e,'"type" is required')];const s=de(e.type);let o;switch(s){case"vector":case"raster":case"raster-dem":return o=Ur({key:i,value:e,valueSpec:r[`source_${s.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:mn}),o;case"geojson":if(o=Ur({key:i,value:e,valueSpec:r.source_geojson,style:n,styleSpec:r,objectElementValidators:mn}),e.cluster)for(const t in e.clusterProperties){const[r,n]=e.clusterProperties[t],s="string"==typeof r?[r,["accumulated"],["get",t]]:r;o.push(...Gr({key:`${i}.${t}.map`,value:n,expressionContext:"cluster-map"})),o.push(...Gr({key:`${i}.${t}.reduce`,value:s,expressionContext:"cluster-reduce"}))}return o;case"video":return Ur({key:i,value:e,valueSpec:r.source_video,style:n,styleSpec:r});case"image":return Ur({key:i,value:e,valueSpec:r.source_image,style:n,styleSpec:r});case"canvas":return[new jr(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Wr({key:`${i}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:n,styleSpec:r})}}function gn(t){const e=t.value,i=t.styleSpec,r=i.light,n=t.style;let s=[];const o=Tr(e);if(void 0===e)return s;if("object"!==o)return s=s.concat([new jr("light",e,`object expected, ${o} found`)]),s;for(const t in e){const o=t.match(/^(.*)-transition$/);s=s.concat(o&&r[o[1]]&&r[o[1]].transition?bn({key:t,value:e[t],valueSpec:i.transition,style:n,styleSpec:i}):r[t]?bn({key:t,value:e[t],valueSpec:r[t],style:n,styleSpec:i}):[new jr(t,e[t],`unknown property "${t}"`)])}return s}function yn(t){const e=t.value,i=t.key,r=t.style,n=t.styleSpec,s=n.terrain;let o=[];const a=Tr(e);if(void 0===e)return o;if("object"!==a)return o=o.concat([new jr("terrain",e,`object expected, ${a} found`)]),o;for(const t in e){const i=t.match(/^(.*)-transition$/);o=o.concat(i&&s[i[1]]&&s[i[1]].transition?bn({key:t,value:e[t],valueSpec:n.transition,style:r,styleSpec:n}):s[t]?bn({key:t,value:e[t],valueSpec:s[t],style:r,styleSpec:n}):[new jr(t,e[t],`unknown property "${t}"`)])}if(e.source){const t=r.sources&&r.sources[e.source],n=t&&de(t.type);t?"raster-dem"!==n&&o.push(new jr(i,e.source,`terrain cannot be used with a source of type ${n}, it only be used with a "raster-dem" source type`)):o.push(new jr(i,e.source,`source "${e.source}" not found`))}else o.push(new jr(i,e,'terrain is missing required property "source"'));return o}function xn(t){const e=t.value,i=t.style,r=t.styleSpec,n=r.fog;let s=[];const o=Tr(e);if(void 0===e)return s;if("object"!==o)return s=s.concat([new jr("fog",e,`object expected, ${o} found`)]),s;for(const t in e){const o=t.match(/^(.*)-transition$/);s=s.concat(o&&n[o[1]]&&n[o[1]].transition?bn({key:t,value:e[t],valueSpec:r.transition,style:i,styleSpec:r}):n[t]?bn({key:t,value:e[t],valueSpec:n[t],style:i,styleSpec:r}):[new jr(t,e[t],`unknown property "${t}"`)])}return s}const vn={"*":()=>[],array:Nr,boolean:function(t){const e=t.value,i=t.key,r=Tr(e);return"boolean"!==r?[new jr(i,e,`boolean expected, ${r} found`)]:[]},number:Zr,color:function(t){const e=t.key,i=t.value,r=Tr(i);return"string"!==r?[new jr(e,i,`color expected, ${r} found`)]:null===Be.parseCSSColor(i)?[new jr(e,i,`color expected, "${i}" found`)]:[]},enum:Wr,filter:ln,function:qr,layer:dn,object:Ur,source:_n,light:gn,terrain:yn,fog:xn,string:fn,formatted:function(t){return 0===fn(t).length?[]:Gr(t)},resolvedImage:function(t){return 0===fn(t).length?[]:Gr(t)},projection:function(t){const e=t.value,i=t.styleSpec,r=i.projection,n=t.style;let s=[];const o=Tr(e);if("object"===o)for(const t in e)s=s.concat(bn({key:t,value:e[t],valueSpec:r[t],style:n,styleSpec:i}));else"string"!==o&&(s=s.concat([new jr("projection",e,`object or string expected, ${o} found`)]));return s}};function bn(t){const e=t.value,i=t.valueSpec,r=t.styleSpec;return i.expression&&Er(de(e))?qr(t):i.expression&&Dr(fe(e))?Gr(t):i.type&&vn[i.type]?vn[i.type](t):Ur(pe({},t,{valueSpec:i.type?r[i.type]:i}))}function wn(t){const e=t.value,i=t.key,r=fn(t);return r.length||(-1===e.indexOf("{fontstack}")&&r.push(new jr(i,e,'"glyphs" url must include a "{fontstack}" token')),-1===e.indexOf("{range}")&&r.push(new jr(i,e,'"glyphs" url must include a "{range}" token'))),r}function Tn(t,e=ue){return Pn(bn({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,objectElementValidators:{glyphs:wn,"*":()=>[]}}))}const En=t=>Pn(_n(t)),In=t=>Pn(gn(t)),Sn=t=>Pn(yn(t)),An=t=>Pn(xn(t)),zn=t=>Pn(dn(t)),Cn=t=>Pn(ln(t)),Mn=t=>Pn(un(t)),kn=t=>Pn(pn(t));function Pn(t){return t.slice().sort(((t,e)=>t.line-e.line))}function Dn(t,e){let i=!1;if(e&&e.length)for(const r of e)t.fire(new ce(new Error(r.message))),i=!0;return i}var Bn=Ln;function Ln(t,e,i){var r=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var n=new Int32Array(this.arrayBuffer);t=n[0],this.d=(e=n[1])+2*(i=n[2]);for(var s=0;s<this.d*this.d;s++){var o=n[3+s],a=n[3+s+1];r.push(o===a?null:n.subarray(o,a))}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=e+2*i;for(var c=0;c<this.d*this.d;c++)r.push([]);this.keys=[],this.bboxes=[]}this.n=e,this.extent=t,this.padding=i,this.scale=e/t,this.uid=0;var h=i/e*t;this.min=-h,this.max=t+h}Ln.prototype.insert=function(t,e,i,r,n){this._forEachCell(e,i,r,n,this._insertCell,this.uid++),this.keys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)},Ln.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},Ln.prototype._insertCell=function(t,e,i,r,n,s){this.cells[n].push(s)},Ln.prototype.query=function(t,e,i,r,n){var s=this.min,o=this.max;if(t<=s&&e<=s&&o<=i&&o<=r&&!n)return Array.prototype.slice.call(this.keys);var a=[];return this._forEachCell(t,e,i,r,this._queryCell,a,{},n),a},Ln.prototype._queryCell=function(t,e,i,r,n,s,o,a){var l=this.cells[n];if(null!==l)for(var c=this.keys,h=this.bboxes,u=0;u<l.length;u++){var p=l[u];if(void 0===o[p]){var d=4*p;(a?a(h[d+0],h[d+1],h[d+2],h[d+3]):t<=h[d+2]&&e<=h[d+3]&&i>=h[d+0]&&r>=h[d+1])?(o[p]=!0,s.push(c[p])):o[p]=!1}}},Ln.prototype._forEachCell=function(t,e,i,r,n,s,o,a){for(var l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),h=this._convertToCellCoord(i),u=this._convertToCellCoord(r),p=l;p<=h;p++)for(var d=c;d<=u;d++){var f=this.d*d+p;if((!a||a(this._convertFromCellCoord(p),this._convertFromCellCoord(d),this._convertFromCellCoord(p+1),this._convertFromCellCoord(d+1)))&&n.call(this,t,e,i,r,f,s,o,a))return}},Ln.prototype._convertFromCellCoord=function(t){return(t-this.padding)/this.scale},Ln.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},Ln.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=3+this.cells.length+1+1,i=0,r=0;r<this.cells.length;r++)i+=this.cells[r].length;var n=new Int32Array(e+i+this.keys.length+this.bboxes.length);n[0]=this.extent,n[1]=this.n,n[2]=this.padding;for(var s=e,o=0;o<t.length;o++){var a=t[o];n[3+o]=s,n.set(a,s),s+=a.length}return n[3+t.length]=s,n.set(this.keys,s),n[3+t.length+1]=s+=this.keys.length,n.set(this.bboxes,s),s+=this.bboxes.length,n.buffer};const Rn={};function Fn(t,e={}){Rn[t.name]={klass:t,omit:e.omit||[]}}Fn(Object),Bn.serialize=function(t,e){const i=t.toArrayBuffer();return e&&e.push(i),{buffer:i}},Bn.deserialize=function(t){return new Bn(t.buffer)},Fn(Bn),Fn(Le),Fn(Error),Fn(Xt),Fn(Ve),Fn(Or),Fn(Pr,{omit:["_evaluator"]}),Fn(Rr),Fn(Lr),Fn(ti,{omit:["_evaluate"]});for(const t in dr)Rn[dr[t].name]||Fn(dr[t]);function On(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}function Vn(t){return l.ImageBitmap&&t instanceof l.ImageBitmap}function jn(t,e){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(On(t)||Vn(t))return e&&e.push(t),t;if(ArrayBuffer.isView(t)){const i=t;return e&&e.push(i.buffer),i}if(t instanceof l.ImageData)return e&&e.push(t.data.buffer),t;if(Array.isArray(t)){const i=[];for(const r of t)i.push(jn(r,e));return i}if("object"==typeof t){const i=t.constructor,r=i.name;if(!Rn[r])throw new Error(`can't serialize object of unregistered class ${r}`);const n=i.serialize?i.serialize(t,e):{};if(!i.serialize){for(const i in t)t.hasOwnProperty(i)&&(Rn[r].omit.indexOf(i)>=0||(n[i]=jn(t[i],e)));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 Un(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||On(t)||Vn(t)||ArrayBuffer.isView(t)||t instanceof l.ImageData)return t;if(Array.isArray(t))return t.map(Un);if("object"==typeof t){const e=t.$name||"Object",{klass:i}=Rn[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]=Un(t[e]));return r}throw new Error("can't deserialize object of type "+typeof t)}class Nn{constructor(){this.first=!0}update(t,e){const i=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=e):this.lastFloorZoom<i&&(this.lastIntegerZoom=i,this.lastIntegerZoomTime=e),t!==this.lastZoom&&(this.lastZoom=t,this.lastFloorZoom=i,!0))}}const Zn=t=>t>=12288&&t<=12351,qn=t=>t>=12352&&t<=12447,Gn=t=>t>=12448&&t<=12543,$n=t=>t>=19968&&t<=40959,Wn=t=>t>=44032&&t<=55215;function Xn(t){for(const e of t)if(Hn(e.charCodeAt(0)))return!0;return!1}function Hn(t){return!(746!==t&&747!==t&&(t<4352||!((t=>t>=12704&&t<=12735)(t)||(t=>t>=12544&&t<=12591)(t)||(t=>t>=65072&&t<=65103)(t)&&!(t>=65097&&t<=65103)||(t=>t>=63744&&t<=64255)(t)||(t=>t>=13056&&t<=13311)(t)||(t=>t>=11904&&t<=12031)(t)||(t=>t>=12736&&t<=12783)(t)||!(!Zn(t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||(t=>t>=13312&&t<=19903)(t)||$n(t)||(t=>t>=12800&&t<=13055)(t)||(t=>t>=12592&&t<=12687)(t)||(t=>t>=43360&&t<=43391)(t)||(t=>t>=55216&&t<=55295)(t)||(t=>t>=4352&&t<=4607)(t)||Wn(t)||qn(t)||(t=>t>=12272&&t<=12287)(t)||(t=>t>=12688&&t<=12703)(t)||(t=>t>=12032&&t<=12255)(t)||(t=>t>=12784&&t<=12799)(t)||Gn(t)&&12540!==t||!(!(t=>t>=65280&&t<=65519)(t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!(t=>t>=65104&&t<=65135)(t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||(t=>t>=5120&&t<=5759)(t)||(t=>t>=6320&&t<=6399)(t)||(t=>t>=65040&&t<=65055)(t)||(t=>t>=19904&&t<=19967)(t)||(t=>t>=40960&&t<=42127)(t)||(t=>t>=42128&&t<=42191)(t))))}function Kn(t){return t>=1424&&t<=2303||(t=>t>=64336&&t<=65023)(t)||(t=>t>=65136&&t<=65279)(t)}function Yn(t,e){return!(!e&&Kn(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||(t=>t>=6016&&t<=6143)(t))}function Jn(t){for(const e of t)if(Kn(e.charCodeAt(0)))return!0;return!1}const Qn="deferred",ts="loading",es="loaded";let is=null,rs="unavailable",ns=null;const ss=function(t){t&&"string"==typeof t&&t.indexOf("NetworkError")>-1&&(rs="error"),is&&is(t)};function os(){as.fire(new le("pluginStateChange",{pluginStatus:rs,pluginURL:ns}))}const as=new he,ls=function(){return rs},cs=function(){if(rs!==Qn||!ns)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");rs=ts,os(),ns&&Jt({url:ns},(t=>{t?ss(t):(rs=es,os())}))},hs={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>rs===es||null!=hs.applyArabicShaping,isLoading:()=>rs===ts,setState(t){rs=t.pluginStatus,ns=t.pluginURL},isParsed:()=>null!=hs.applyArabicShaping&&null!=hs.processBidirectionalText&&null!=hs.processStyledBidirectionalText,getPluginURL:()=>ns};class us{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition,this.pitch=e.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Nn,this.transition={},this.pitch=0)}isSupportedScript(t){return function(t,e){for(const i of t)if(!Yn(i.charCodeAt(0),e))return!1;return!0}(t,hs.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,e=t-Math.floor(t),i=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*e}}}class ps{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Er(t))return new Or(t,e);if(Dr(t)){const i=Fr(t,e);if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return i.value}{let i=t;return"string"==typeof t&&"color"===e.type&&(i=Le.parse(t)),{kind:"constant",evaluate:()=>i}}}(void 0===e?t.specification.default:e,t.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}}class ds{constructor(t){this.property=t,this.value=new ps(t,void 0)}transitioned(t,e){return new ms(this.property,this.value,e,I({},t.transition,this.transition),t.now)}untransitioned(){return new ms(this.property,this.value,null,{},0)}}class fs{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return R(this._values[t].value.value)}setValue(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new ds(this._values[t].property)),this._values[t].value=new ps(this._values[t].property,null===e?void 0:R(e))}getTransition(t){return R(this._values[t].transition)}setTransition(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new ds(this._values[t].property)),this._values[t].transition=R(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i);const r=this.getTransition(e);void 0!==r&&(t[`${e}-transition`]=r)}return t}transitioned(t,e){const i=new _s(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(t,e._values[r]);return i}untransitioned(){const t=new _s(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class ms{constructor(t,e,i,r,n){const s=r.delay||0,o=r.duration||0;n=n||0,this.property=t,this.value=e,this.begin=n+s,this.end=this.begin+o,t.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(t,e,i){const r=t.now||0,n=this.value.possiblyEvaluate(t,e,i),s=this.prior;if(s){if(r>this.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(r<this.begin)return s.possiblyEvaluate(t,e,i);{const o=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(s.possiblyEvaluate(t,e,i),n,m(o))}}return n}}class _s{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,e,i){const r=new xs(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(t,e,i);return r}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class gs{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues)}getValue(t){return R(this._values[t].value)}setValue(t,e){this._values[t]=new ps(this._values[t].property,null===e?void 0:R(e))}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i)}return t}possiblyEvaluate(t,e,i){const r=new xs(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(t,e,i);return r}}class ys{constructor(t,e,i){this.property=t,this.value=e,this.parameters=i}isConstant(){return"constant"===this.value.kind}constantOr(t){return"constant"===this.value.kind?this.value.value:t}evaluate(t,e,i,r){return this.property.evaluate(this.value,this.parameters,t,e,i,r)}}class xs{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class vs{constructor(t){this.specification=t}possiblyEvaluate(t,e){return t.expression.evaluate(e)}interpolate(t,e,i){const r=zi[this.specification.type];return r?r(t,e,i):t}}class bs{constructor(t,e){this.specification=t,this.overrides=e}possiblyEvaluate(t,e,i,r){return new ys(this,"constant"===t.expression.kind||"camera"===t.expression.kind?{kind:"constant",value:t.expression.evaluate(e,null,{},i,r)}:t.expression,e)}interpolate(t,e,i){if("constant"!==t.value.kind||"constant"!==e.value.kind)return t;if(void 0===t.value.value||void 0===e.value.value)return new ys(this,{kind:"constant",value:void 0},t.parameters);const r=zi[this.specification.type];return r?new ys(this,{kind:"constant",value:r(t.value.value,e.value.value,i)},t.parameters):t}evaluate(t,e,i,r,n,s){return"constant"===t.kind?t.value:t.evaluate(e,i,r,n,s)}}class ws extends bs{possiblyEvaluate(t,e,i,r){if(void 0===t.value)return new ys(this,{kind:"constant",value:void 0},e);if("constant"===t.expression.kind){const n=t.expression.evaluate(e,null,{},i,r),s="resolvedImage"===t.property.specification.type&&"string"!=typeof n?n.name:n,o=this._calculate(s,s,s,e);return new ys(this,{kind:"constant",value:o},e)}if("camera"===t.expression.kind){const i=this._calculate(t.expression.evaluate({zoom:e.zoom-1}),t.expression.evaluate({zoom:e.zoom}),t.expression.evaluate({zoom:e.zoom+1}),e);return new ys(this,{kind:"constant",value:i},e)}return new ys(this,t.expression,e)}evaluate(t,e,i,r,n,s){if("source"===t.kind){const o=t.evaluate(e,i,r,n,s);return this._calculate(o,o,o,e)}return"composite"===t.kind?this._calculate(t.evaluate({zoom:Math.floor(e.zoom)-1},i,r),t.evaluate({zoom:Math.floor(e.zoom)},i,r),t.evaluate({zoom:Math.floor(e.zoom)+1},i,r),e):t.value}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e,other:i}:{from:i,to:e,other:t}}interpolate(t){return t}}class Ts{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){if(void 0!==t.value){if("constant"===t.expression.kind){const n=t.expression.evaluate(e,null,{},i,r);return this._calculate(n,n,n,e)}return this._calculate(t.expression.evaluate(new us(Math.floor(e.zoom-1),e)),t.expression.evaluate(new us(Math.floor(e.zoom),e)),t.expression.evaluate(new us(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}}class Es{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){return!!t.expression.evaluate(e,null,{},i,r)}interpolate(){return!1}}class Is{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const e in t){const i=t[e];i.specification.overridable&&this.overridableProperties.push(e);const r=this.defaultPropertyValues[e]=new ps(i,void 0),n=this.defaultTransitionablePropertyValues[e]=new ds(i);this.defaultTransitioningPropertyValues[e]=n.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=r.possiblyEvaluate({})}}}function Ss(t,e){return 256*(t=v(Math.floor(t),0,255))+v(Math.floor(e),0,255)}Fn(bs),Fn(vs),Fn(ws),Fn(Ts),Fn(Es);const As={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class zs{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Cs{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_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(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_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 Ms(t,e=1){let i=0,r=0;return{members:t.map((t=>{const n=As[t.type].BYTES_PER_ELEMENT,s=i=ks(i,Math.max(e,n)),o=t.components||1;return r=Math.max(r,n),i+=n*o,{name:t.name,type:t.type,components:o,offset:s}})),size:ks(i,Math.max(r,e)),alignment:e}}function ks(t,e){return Math.ceil(t/e)*e}class Ps extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.int16[r+0]=e,this.int16[r+1]=i,t}}Ps.prototype.bytesPerElement=4,Fn(Ps);class Ds extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=3*t;return this.int16[n+0]=e,this.int16[n+1]=i,this.int16[n+2]=r,t}}Ds.prototype.bytesPerElement=6,Fn(Ds);class Bs extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r)}emplace(t,e,i,r,n){const s=4*t;return this.int16[s+0]=e,this.int16[s+1]=i,this.int16[s+2]=r,this.int16[s+3]=n,t}}Bs.prototype.bytesPerElement=8,Fn(Bs);class Ls extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s,o){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,n,s,o)}emplace(t,e,i,r,n,s,o,a){const l=6*t,c=12*t,h=3*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.uint8[c+4]=r,this.uint8[c+5]=n,this.uint8[c+6]=s,this.uint8[c+7]=o,this.float32[h+2]=a,t}}Ls.prototype.bytesPerElement=12,Fn(Ls);class Rs extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=3*t;return this.float32[n+0]=e,this.float32[n+1]=i,this.float32[n+2]=r,t}}Rs.prototype.bytesPerElement=12,Fn(Rs);class Fs extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s,o,a,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,t,e,i,r,n,s,o,a,l,c)}emplace(t,e,i,r,n,s,o,a,l,c,h){const u=10*t;return this.uint16[u+0]=e,this.uint16[u+1]=i,this.uint16[u+2]=r,this.uint16[u+3]=n,this.uint16[u+4]=s,this.uint16[u+5]=o,this.uint16[u+6]=a,this.uint16[u+7]=l,this.uint16[u+8]=c,this.uint16[u+9]=h,t}}Fs.prototype.bytesPerElement=20,Fn(Fs);class Os extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s,o,a){const l=this.length;return this.resize(l+1),this.emplace(l,t,e,i,r,n,s,o,a)}emplace(t,e,i,r,n,s,o,a,l){const c=8*t;return this.uint16[c+0]=e,this.uint16[c+1]=i,this.uint16[c+2]=r,this.uint16[c+3]=n,this.uint16[c+4]=s,this.uint16[c+5]=o,this.uint16[c+6]=a,this.uint16[c+7]=l,t}}Os.prototype.bytesPerElement=16,Fn(Os);class Vs extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r,n,s)}emplace(t,e,i,r,n,s,o){const a=6*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=n,this.int16[a+4]=s,this.int16[a+5]=o,t}}Vs.prototype.bytesPerElement=12,Fn(Vs);class js extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m){const _=this.length;return this.resize(_+1),this.emplace(_,t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m)}emplace(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m,_){const g=16*t;return this.int16[g+0]=e,this.int16[g+1]=i,this.int16[g+2]=r,this.int16[g+3]=n,this.uint16[g+4]=s,this.uint16[g+5]=o,this.uint16[g+6]=a,this.uint16[g+7]=l,this.int16[g+8]=c,this.int16[g+9]=h,this.int16[g+10]=u,this.int16[g+11]=p,this.int16[g+12]=d,this.int16[g+13]=f,this.int16[g+14]=m,this.int16[g+15]=_,t}}js.prototype.bytesPerElement=32,Fn(js);class Us extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}Us.prototype.bytesPerElement=4,Fn(Us);class Ns extends Cs{_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(t,e,i,r,n,s,o,a,l,c,h,u,p){const d=this.length;return this.resize(d+1),this.emplace(d,t,e,i,r,n,s,o,a,l,c,h,u,p)}emplace(t,e,i,r,n,s,o,a,l,c,h,u,p,d){const f=20*t,m=10*t;return this.int16[f+0]=e,this.int16[f+1]=i,this.int16[f+2]=r,this.int16[f+3]=n,this.int16[f+4]=s,this.float32[m+3]=o,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=h,this.uint32[m+8]=u,this.uint16[f+18]=p,this.uint16[f+19]=d,t}}Ns.prototype.bytesPerElement=40,Fn(Ns);class Zs extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s,o){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,n,s,o)}emplace(t,e,i,r,n,s,o,a){const l=8*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.int16[l+2]=r,this.int16[l+4]=n,this.int16[l+5]=s,this.int16[l+6]=o,this.int16[l+7]=a,t}}Zs.prototype.bytesPerElement=16,Fn(Zs);class qs extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r,n)}emplace(t,e,i,r,n,s){const o=4*t,a=8*t;return this.float32[o+0]=e,this.float32[o+1]=i,this.float32[o+2]=r,this.int16[a+6]=n,this.int16[a+7]=s,t}}qs.prototype.bytesPerElement=16,Fn(qs);class Gs extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r)}emplace(t,e,i,r,n){const s=12*t,o=3*t;return this.uint8[s+0]=e,this.uint8[s+1]=i,this.float32[o+1]=r,this.float32[o+2]=n,t}}Gs.prototype.bytesPerElement=12,Fn(Gs);class $s extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=3*t;return this.uint16[n+0]=e,this.uint16[n+1]=i,this.uint16[n+2]=r,t}}$s.prototype.bytesPerElement=6,Fn($s);class Ws extends Cs{_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(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m,_,g,y,x,v){const b=this.length;return this.resize(b+1),this.emplace(b,t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m,_,g,y,x,v)}emplace(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m,_,g,y,x,v,b){const w=30*t,T=15*t,E=60*t;return this.int16[w+0]=e,this.int16[w+1]=i,this.int16[w+2]=r,this.float32[T+2]=n,this.float32[T+3]=s,this.uint16[w+8]=o,this.uint16[w+9]=a,this.uint32[T+5]=l,this.uint32[T+6]=c,this.uint32[T+7]=h,this.uint16[w+16]=u,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,t}}Ws.prototype.bytesPerElement=60,Fn(Ws);class Xs extends Cs{_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(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m,_,g,y,x,v,b,w,T,E,I,S,A,z,C){const M=this.length;return this.resize(M+1),this.emplace(M,t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m,_,g,y,x,v,b,w,T,E,I,S,A,z,C)}emplace(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m,_,g,y,x,v,b,w,T,E,I,S,A,z,C,M){const k=38*t,P=19*t;return this.int16[k+0]=e,this.int16[k+1]=i,this.int16[k+2]=r,this.float32[P+2]=n,this.float32[P+3]=s,this.int16[k+8]=o,this.int16[k+9]=a,this.int16[k+10]=l,this.int16[k+11]=c,this.int16[k+12]=h,this.int16[k+13]=u,this.uint16[k+14]=p,this.uint16[k+15]=d,this.uint16[k+16]=f,this.uint16[k+17]=m,this.uint16[k+18]=_,this.uint16[k+19]=g,this.uint16[k+20]=y,this.uint16[k+21]=x,this.uint16[k+22]=v,this.uint16[k+23]=b,this.uint16[k+24]=w,this.uint16[k+25]=T,this.uint16[k+26]=E,this.uint16[k+27]=I,this.uint16[k+28]=S,this.uint32[P+15]=A,this.float32[P+16]=z,this.float32[P+17]=C,this.float32[P+18]=M,t}}Xs.prototype.bytesPerElement=76,Fn(Xs);class Hs extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}Hs.prototype.bytesPerElement=4,Fn(Hs);class Ks extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s,o){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,n,s,o)}emplace(t,e,i,r,n,s,o,a){const l=7*t;return this.float32[l+0]=e,this.float32[l+1]=i,this.float32[l+2]=r,this.float32[l+3]=n,this.float32[l+4]=s,this.float32[l+5]=o,this.float32[l+6]=a,t}}Ks.prototype.bytesPerElement=28,Fn(Ks);class Ys extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r,n)}emplace(t,e,i,r,n,s){const o=5*t;return this.float32[o+0]=e,this.float32[o+1]=i,this.float32[o+2]=r,this.float32[o+3]=n,this.float32[o+4]=s,t}}Ys.prototype.bytesPerElement=20,Fn(Ys);class Js extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r)}emplace(t,e,i,r,n){const s=6*t;return this.uint32[3*t+0]=e,this.uint16[s+2]=i,this.uint16[s+3]=r,this.uint16[s+4]=n,t}}Js.prototype.bytesPerElement=12,Fn(Js);class Qs extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.uint16[r+0]=e,this.uint16[r+1]=i,t}}Qs.prototype.bytesPerElement=4,Fn(Qs);class to extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}to.prototype.bytesPerElement=2,Fn(to);class eo extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.float32[r+0]=e,this.float32[r+1]=i,t}}eo.prototype.bytesPerElement=8,Fn(eo);class io extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r)}emplace(t,e,i,r,n){const s=4*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=r,this.float32[s+3]=n,t}}io.prototype.bytesPerElement=16,Fn(io);class ro extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s,o){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,n,s,o)}emplace(t,e,i,r,n,s,o,a){const l=8*t,c=4*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.int16[l+2]=r,this.int16[l+3]=n,this.int16[l+4]=s,this.int16[l+5]=o,this.float32[c+3]=a,t}}ro.prototype.bytesPerElement=16,Fn(ro);class no extends zs{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]}}no.prototype.size=12;class so extends Vs{get(t){return new no(this,t)}}Fn(so);class oo extends zs{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]}}oo.prototype.size=40;class ao extends Ns{get(t){return new oo(this,t)}}Fn(ao);class lo extends zs{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(t){this._structArray.uint8[this._pos1+49]=t}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(t){this._structArray.uint8[this._pos1+50]=t}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(t){this._structArray.uint32[this._pos4+13]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(t){this._structArray.uint8[this._pos1+58]=t}}lo.prototype.size=60;class co extends Ws{get(t){return new lo(this,t)}}Fn(co);class ho extends zs{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(t){this._structArray.uint32[this._pos4+15]=t}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]}}ho.prototype.size=76;class uo extends Xs{get(t){return new ho(this,t)}}Fn(uo);class po extends Hs{getoffsetX(t){return this.float32[1*t+0]}}Fn(po);class fo extends Ds{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}Fn(fo);class mo extends zs{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]}}mo.prototype.size=12;class _o extends Js{get(t){return new mo(this,t)}}Fn(_o);class go extends zs{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}go.prototype.size=4;class yo extends Qs{get(t){return new go(this,t)}}Fn(yo);class xo extends zs{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]}get a_scale(){return this._structArray.float32[this._pos4+3]}}xo.prototype.size=16;class vo extends ro{get(t){return new xo(this,t)}}Fn(vo);const bo=Ms([{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"}]),wo=Ms([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var To=De((function(t){t.exports=function(t,e){var i,r,n,s,o,a,l,c;for(r=t.length-(i=3&t.length),n=e,o=3432918353,a=461845907,c=0;c<r;)l=255&t.charCodeAt(c)|(255&t.charCodeAt(++c))<<8|(255&t.charCodeAt(++c))<<16|(255&t.charCodeAt(++c))<<24,++c,n=27492+(65535&(s=5*(65535&(n=(n^=l=(65535&(l=(l=(65535&l)*o+(((l>>>16)*o&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(s>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&t.charCodeAt(c+2))<<16;case 2:l^=(255&t.charCodeAt(c+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(c)))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return n^=t.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}})),Eo=De((function(t){t.exports=function(t,e){for(var i,r=t.length,n=e^r,s=0;r>=4;)i=1540483477*(65535&(i=255&t.charCodeAt(s)|(255&t.charCodeAt(++s))<<8|(255&t.charCodeAt(++s))<<16|(255&t.charCodeAt(++s))<<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,++s;switch(r){case 3:n^=(255&t.charCodeAt(s+2))<<16;case 2:n^=(255&t.charCodeAt(s+1))<<8;case 1:n=1540483477*(65535&(n^=255&t.charCodeAt(s)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}})),Io=To,So=Eo;Io.murmur3=To,Io.murmur2=So;class Ao{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,e,i,r){this.ids.push(zo(t)),this.positions.push(e,i,r)}getPositions(t){const e=zo(t);let i=0,r=this.ids.length-1;for(;i<r;){const t=i+r>>1;this.ids[t]>=e?r=t:i=t+1}const n=[];for(;this.ids[i]===e;)n.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return n}static serialize(t,e){const i=new Float64Array(t.ids),r=new Uint32Array(t.positions);return Co(i,r,0,i.length-1),e&&e.push(i.buffer,r.buffer),{ids:i,positions:r}}static deserialize(t){const e=new Ao;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function zo(t){const e=+t;return!isNaN(e)&&Number.MIN_SAFE_INTEGER<=e&&e<=Number.MAX_SAFE_INTEGER?e:Io(String(t))}function Co(t,e,i,r){for(;i<r;){const n=t[i+r>>1];let s=i-1,o=r+1;for(;;){do{s++}while(t[s]<n);do{o--}while(t[o]>n);if(s>=o)break;Mo(t,s,o),Mo(e,3*s,3*o),Mo(e,3*s+1,3*o+1),Mo(e,3*s+2,3*o+2)}o-i<r-o?(Co(t,e,i,o),i=o+1):(Co(t,e,o+1,r),r=o)}}function Mo(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}Fn(Ao);class ko{constructor(t,e){this.gl=t.gl,this.location=e}}class Po extends ko{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t))}}class Do extends ko{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}}class Bo extends ko{constructor(t,e){super(t,e),this.current=[0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]||(this.current=t,this.gl.uniform2f(this.location,t[0],t[1]))}}class Lo extends ko{constructor(t,e){super(t,e),this.current=[0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]||(this.current=t,this.gl.uniform3f(this.location,t[0],t[1],t[2]))}}class Ro extends ko{constructor(t,e){super(t,e),this.current=[0,0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]&&t[3]===this.current[3]||(this.current=t,this.gl.uniform4f(this.location,t[0],t[1],t[2],t[3]))}}class Fo extends ko{constructor(t,e){super(t,e),this.current=Le.transparent}set(t){t.r===this.current.r&&t.g===this.current.g&&t.b===this.current.b&&t.a===this.current.a||(this.current=t,this.gl.uniform4f(this.location,t.r,t.g,t.b,t.a))}}const Oo=new Float32Array(16);class Vo extends ko{constructor(t,e){super(t,e),this.current=Oo}set(t){if(t[12]!==this.current[12]||t[0]!==this.current[0])return this.current=t,void this.gl.uniformMatrix4fv(this.location,!1,t);for(let e=1;e<16;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);break}}}const jo=new Float32Array(9);class Uo extends ko{constructor(t,e){super(t,e),this.current=jo}set(t){for(let e=0;e<9;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix3fv(this.location,!1,t);break}}}const No=new Float32Array(4);class Zo extends ko{constructor(t,e){super(t,e),this.current=No}set(t){for(let e=0;e<4;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix2fv(this.location,!1,t);break}}}function qo(t){return[Ss(255*t.r,255*t.g),Ss(255*t.b,255*t.a)]}class Go{constructor(t,e,i){this.value=t,this.uniformNames=e.map((t=>`u_${t}`)),this.type=i}setUniform(t,e,i){t.set(i.constantOr(this.value))}getBinding(t,e,i){return"color"===this.type?new Fo(t,e):new Do(t,e)}}class $o{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio||1,this.pixelRatioTo=t.pixelRatio||1,this.patternFrom=e.tl.concat(e.br),this.patternTo=t.tl.concat(t.br)}setUniform(t,e,i,r){const n="u_pattern_to"===r||"u_dash_to"===r?this.patternTo:"u_pattern_from"===r||"u_dash_from"===r?this.patternFrom:"u_pixel_ratio_to"===r?this.pixelRatioTo:"u_pixel_ratio_from"===r?this.pixelRatioFrom:null;n&&t.set(n)}getBinding(t,e,i){return"u_pattern_from"===i||"u_pattern_to"===i||"u_dash_from"===i||"u_dash_to"===i?new Ro(t,e):new Do(t,e)}}class Wo{constructor(t,e,i,r){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new r}populatePaintArray(t,e,i,r,n,s){const o=this.paintVertexArray.length,a=this.expression.evaluate(new us(0),e,{},n,r,s);this.paintVertexArray.resize(t),this._setPaintValue(o,t,a)}updatePaintArray(t,e,i,r,n){const s=this.expression.evaluate({zoom:0},i,r,void 0,n);this._setPaintValue(t,e,s)}_setPaintValue(t,e,i){if("color"===this.type){const r=qo(i);for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,r[0],r[1])}else{for(let r=t;r<e;r++)this.paintVertexArray.emplace(r,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Xo{constructor(t,e,i,r,n,s){this.expression=t,this.uniformNames=e.map((t=>`u_${t}_t`)),this.type=i,this.useIntegerZoom=r,this.zoom=n,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new s}populatePaintArray(t,e,i,r,n,s){const o=this.expression.evaluate(new us(this.zoom),e,{},n,r,s),a=this.expression.evaluate(new us(this.zoom+1),e,{},n,r,s),l=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(l,t,o,a)}updatePaintArray(t,e,i,r,n){const s=this.expression.evaluate({zoom:this.zoom},i,r,void 0,n),o=this.expression.evaluate({zoom:this.zoom+1},i,r,void 0,n);this._setPaintValue(t,e,s,o)}_setPaintValue(t,e,i,r){if("color"===this.type){const n=qo(i),s=qo(r);for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,n[0],n[1],s[0],s[1])}else{for(let n=t;n<e;n++)this.paintVertexArray.emplace(n,i,r);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(r))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(t,e){const i=this.useIntegerZoom?Math.floor(e.zoom):e.zoom,r=v(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);t.set(r)}getBinding(t,e,i){return new Do(t,e)}}class Ho{constructor(t,e,i,r,n,s,o){this.expression=t,this.type=i,this.useIntegerZoom=r,this.zoom=n,this.layerId=o,this.paintVertexAttributes=("array"===i?wo:bo).members;for(let t=0;t<e.length;++t);this.zoomInPaintVertexArray=new s,this.zoomOutPaintVertexArray=new s}populatePaintArray(t,e,i){const r=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(r,t,e.patterns&&e.patterns[this.layerId],i)}updatePaintArray(t,e,i,r,n,s){this._setPaintValues(t,e,i.patterns&&i.patterns[this.layerId],s)}_setPaintValues(t,e,i,r){if(!r||!i)return;const{min:n,mid:s,max:o}=i,a=r[n],l=r[s],c=r[o];if(a&&l&&c)for(let i=t;i<e;i++)this._setPaintValue(this.zoomInPaintVertexArray,i,l,a),this._setPaintValue(this.zoomOutPaintVertexArray,i,l,c)}_setPaintValue(t,e,i,r){t.emplace(e,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(t){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=t.createVertexBuffer(this.zoomInPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=t.createVertexBuffer(this.zoomOutPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class Ko{constructor(t,e,i=(()=>!0)){this.binders={},this._buffers=[];const r=[];for(const n in t.paint._values){if(!i(n))continue;const s=t.paint.get(n);if(!(s instanceof ys&&vr(s.property.specification)))continue;const o=Qo(n,t.type),a=s.value,l=s.property.specification.type,c=s.property.useIntegerZoom,h=s.property.specification["property-type"],u="cross-faded"===h||"cross-faded-data-driven"===h,p="line-dasharray"===String(n)&&"constant"!==t.layout.get("line-cap").value.kind;if("constant"!==a.kind||p)if("source"===a.kind||p||u){const i=ia(n,l,"source");this.binders[n]=u?new Ho(a,o,l,c,e,i,t.id):new Wo(a,o,l,i),r.push(`/a_${n}`)}else{const t=ia(n,l,"composite");this.binders[n]=new Xo(a,o,l,c,e,t),r.push(`/z_${n}`)}else this.binders[n]=u?new $o(a.value,o):new Go(a.value,o,l),r.push(`/u_${n}`)}this.cacheKey=r.sort().join("")}getMaxValue(t){const e=this.binders[t];return e instanceof Wo||e instanceof Xo?e.maxValue:0}populatePaintArrays(t,e,i,r,n,s){for(const o in this.binders){const a=this.binders[o];(a instanceof Wo||a instanceof Xo||a instanceof Ho)&&a.populatePaintArray(t,e,i,r,n,s)}}setConstantPatternPositions(t,e){for(const i in this.binders){const r=this.binders[i];r instanceof $o&&r.setConstantPatternPositions(t,e)}}updatePaintArrays(t,e,i,r,n,s){let o=!1;for(const a in t){const l=e.getPositions(a);for(const e of l){const l=i.feature(e.index);for(const i in this.binders){const c=this.binders[i];if((c instanceof Wo||c instanceof Xo||c instanceof Ho)&&!0===c.expression.isStateDependent){const h=r.paint.get(i);c.expression=h.value,c.updatePaintArray(e.start,e.end,l,t[a],n,s),o=!0}}}}return o}defines(){const t=[];for(const e in this.binders){const i=this.binders[e];(i instanceof Go||i instanceof $o)&&t.push(...i.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof Wo||i instanceof Xo||i instanceof Ho)for(let e=0;e<i.paintVertexAttributes.length;e++)t.push(i.paintVertexAttributes[e].name)}return t}getBinderUniforms(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof Go||i instanceof $o||i instanceof Xo)for(const e of i.uniformNames)t.push(e)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,e){const i=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof Go||n instanceof $o||n instanceof Xo)for(const s of n.uniformNames)if(e[s]){const o=n.getBinding(t,e[s],s);i.push({name:s,property:r,binding:o})}}return i}setUniforms(t,e,i,r){for(const{name:t,property:n,binding:s}of e)this.binders[n].setUniform(s,r,i.get(n),t)}updatePaintBuffers(t){this._buffers=[];for(const e in this.binders){const i=this.binders[e];if(t&&i instanceof Ho){const e=2===t.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;e&&this._buffers.push(e)}else(i instanceof Wo||i instanceof Xo)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(t){for(const e in this.binders){const i=this.binders[e];(i instanceof Wo||i instanceof Xo||i instanceof Ho)&&i.upload(t)}this.updatePaintBuffers()}destroy(){for(const t in this.binders){const e=this.binders[t];(e instanceof Wo||e instanceof Xo||e instanceof Ho)&&e.destroy()}}}class Yo{constructor(t,e,i=(()=>!0)){this.programConfigurations={};for(const r of t)this.programConfigurations[r.id]=new Ko(r,e,i);this.needsUpload=!1,this._featureMap=new Ao,this._bufferOffset=0}populatePaintArrays(t,e,i,r,n,s,o){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(t,e,r,n,s,o);void 0!==e.id&&this._featureMap.add(e.id,i,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,i,r,n){for(const s of i)this.needsUpload=this.programConfigurations[s.id].updatePaintArrays(t,this._featureMap,e,s,r,n)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}const Jo={"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 Qo(t,e){return Jo[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}const ta={"line-pattern":{source:Fs,composite:Fs},"fill-pattern":{source:Fs,composite:Fs},"fill-extrusion-pattern":{source:Fs,composite:Fs},"line-dasharray":{source:Os,composite:Os}},ea={color:{source:eo,composite:io},number:{source:Hs,composite:eo}};function ia(t,e,i){const r=ta[t];return r&&r[i]||ea[e][i]}Fn(Go),Fn($o),Fn(Wo),Fn(Ho),Fn(Xo),Fn(Ko,{omit:["_buffers"]}),Fn(Yo);const ra="-transition";class na extends he{constructor(t,e){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==t.type&&(this.metadata=(t=t).metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&"sky"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),e.layout&&(this._unevaluatedLayout=new gs(e.layout)),e.paint)){this._transitionablePaint=new fs(e.paint);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new xs(e.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,i={}){null!=e&&this._validate(kn,`layers.${this.id}.layout.${t}`,t,e,i)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e)}getPaintProperty(t){return D(t,ra)?this._transitionablePaint.getTransition(t.slice(0,-ra.length)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,i={}){if(null!=e&&this._validate(Mn,`layers.${this.id}.paint.${t}`,t,e,i))return!1;if(D(t,ra))return this._transitionablePaint.setTransition(t.slice(0,-ra.length),e||void 0),!1;{const i=this._transitionablePaint._values[t],r="cross-faded-data-driven"===i.property.specification["property-type"],n=i.value.isDataDriven(),s=i.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const o=this._transitionablePaint._values[t].value;return o.isDataDriven()||n||r||this._handleOverridablePaintPropertyUpdate(t,s,o)}}_handleSpecialPaintPropertyUpdate(t){}getProgramIds(){return null}getProgramConfiguration(t){return null}_handleOverridablePaintPropertyUpdate(t,e,i){return!1}isHidden(t){return!!(this.minzoom&&t<this.minzoom)||!!(this.maxzoom&&t>=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){const t={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&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),L(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,i,r,n={}){return(!n||!1!==n.validate)&&Dn(this,t.call(Tn,{key:e,layerType:this.type,objectKey:i,value:r,styleSpec:ue,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof ys&&vr(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=Hr(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const sa=Ms([{name:"a_pos",components:2,type:"Int16"}],4),oa=Ms([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"},{name:"a_scale",components:1,type:"Float32"}]);class aa{constructor(t=[]){this.segments=t}prepareSegment(t,e,i,r){let n=this.segments[this.segments.length-1];return t>aa.MAX_VERTEX_ARRAY_LENGTH&&O(`Max vertices per segment is ${aa.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!n||n.vertexLength+t>aa.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==r)&&(n={vertexOffset:e.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 t of this.segments)for(const e in t.vaos)t.vaos[e].destroy()}static simpleSegment(t,e,i,r){return new aa([{vertexOffset:t,primitiveOffset:e,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}aa.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Fn(aa);var la=8192;class ca{constructor(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1]))}setNorthEast(t){return this._ne=t instanceof ua?new ua(t.lng,t.lat):ua.convert(t),this}setSouthWest(t){return this._sw=t instanceof ua?new ua(t.lng,t.lat):ua.convert(t),this}extend(t){const e=this._sw,i=this._ne;let r,n;if(t instanceof ua)r=t,n=t;else{if(!(t instanceof ca))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(ca.convert(t)):this.extend(ua.convert(t)):this;if(r=t._sw,n=t._ne,!r||!n)return this}return e||i?(e.lng=Math.min(r.lng,e.lng),e.lat=Math.min(r.lat,e.lat),i.lng=Math.max(n.lng,i.lng),i.lat=Math.max(n.lat,i.lat)):(this._sw=new ua(r.lng,r.lat),this._ne=new ua(n.lng,n.lat)),this}getCenter(){return new ua((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 ua(this.getWest(),this.getNorth())}getSouthEast(){return new ua(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(t){const{lng:e,lat:i}=ua.convert(t);let r=this._sw.lng<=e&&e<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&r}static convert(t){return!t||t instanceof ca?t:new ca(t)}}const ha=6371008.8;class ua{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new ua(w(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,i=this.lat*e,r=t.lat*e,n=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((t.lng-this.lng)*e);return ha*Math.acos(Math.min(n,1))}toBounds(t=0){const e=360*t/40075017,i=e/Math.cos(Math.PI/180*this.lat);return new ca(new ua(this.lng-i,this.lat-e),new ua(this.lng+i,this.lat+e))}static convert(t){if(t instanceof ua)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new ua(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new ua(Number("lng"in t?t.lng:t.lon),Number(t.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 pa=2*Math.PI*ha;function da(t){return pa*Math.cos(t*Math.PI/180)}function fa(t){return(180+t)/360}function ma(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function _a(t,e){return t/da(e)}function ga(t){return 360*t-180}function ya(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function xa(t,e){return t*da(ya(e))}const va=85.051129;class ba{constructor(t,e,i=0){this.x=+t,this.y=+e,this.z=+i}static fromLngLat(t,e=0){const i=ua.convert(t);return new ba(fa(i.lng),ma(i.lat),_a(e,i.lat))}toLngLat(){return new ua(ga(this.x),ya(this.y))}toAltitude(){return xa(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/pa*(t=ya(this.y),1/Math.cos(t*Math.PI/180));var t}}function wa(t,e,i,r,n,s,a,l,c){const h=(e+r)/2,u=(i+n)/2,p=new o(h,u);l(p),function(t,e,i,r,n,s){const o=i-n,a=r-s;return Math.abs((r-e)*o-(i-t)*a)/Math.hypot(o,a)}(p.x,p.y,s.x,s.y,a.x,a.y)>=c?(wa(t,e,i,h,u,s,p,l,c),wa(t,h,u,r,n,p,a,l,c)):t.push(a)}function Ta(t,e,i){let r=t[0],n=r.x,s=r.y;e(r);const o=[r];for(let a=1;a<t.length;a++){const l=t[a],{x:c,y:h}=l;e(l),wa(o,n,s,c,h,r,l,e,i),n=c,s=h,r=l}return o}const Ea=Math.pow(2,14)-1,Ia=-Ea-1;function Sa(t,e){const i=Math.round(t.x*e),r=Math.round(t.y*e);return t.x=v(i,Ia,Ea),t.y=v(r,Ia,Ea),(i<t.x||i>t.x+1||r<t.y||r>t.y+1)&&O("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function Aa(t,e,i){const r=t.loadGeometry(),n=t.extent,s=la/n;if(e&&i&&i.projection.isReprojectedInTileSpace){const s=1<<e.z,{scale:o,x:a,y:l,projection:c}=i,h=t=>{const i=ga((e.x+t.x/n)/s),r=ya((e.y+t.y/n)/s),h=c.project(i,r);t.x=(h.x*o-a)*n,t.y=(h.y*o-l)*n};for(let e=0;e<r.length;e++)if(1!==t.type)r[e]=Ta(r[e],h,1);else{const t=[];for(const i of r[e])i.x<0||i.x>=n||i.y<0||i.y>=n||(h(i),t.push(i));r[e]=t}}for(const t of r)for(const e of t)Sa(e,s);return r}function za(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?Aa(t):[]}}function Ca(t,e,i,r,n){t.emplaceBack(2*e+(r+1)/2,2*i+(n+1)/2)}function Ma(t,e,i,r){const n=16384;t.emplaceBack(e.x,e.y,e.z,i[0]*n,i[1]*n,i[2]*n,r)}class ka{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new Ps,this.indexArray=new $s,this.segments=new aa,this.programConfigurations=new Yo(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i,r){const n=this.layers[0],s=[];let o=null;"circle"===n.type&&(o=n.layout.get("circle-sort-key"));for(const{feature:e,id:n,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=za(e,t);if(!this.layers[0]._featureFilter.filter(new us(this.zoom),c,i))continue;const h=o?o.evaluate(c,{},i):void 0,u={id:n,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Aa(e,i,r),patterns:{},sortKey:h};s.push(u)}o&&s.sort(((t,e)=>t.sortKey-e.sortKey));let a=null;"globe"===r.projection.name&&(this.globeExtVertexArray=new vo,a=r.projection);for(const r of s){const{geometry:n,index:s,sourceLayerIndex:o}=r,l=t[s].feature;this.addFeature(r,n,s,e.availableImages,i,a),e.featureIndex.insert(l,n,s,o,this.index)}}update(t,e,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,sa.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,oa.members))),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(t,e,i,r,n,s){for(const i of e)for(const e of i){const i=e.x,r=e.y;if(i<0||i>=la||r<0||r>=la)continue;if(s){const t=s.projectTilePoint(i,r,n),e=s.upVector(n,i,r),o=ya((r/la+n.y)/(1<<n.z)),a=s.pixelsPerMeter(o,1)/_a(1,o),l=this.globeExtVertexArray;Ma(l,t,e,a),Ma(l,t,e,a),Ma(l,t,e,a),Ma(l,t,e,a)}const o=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),a=o.vertexLength;Ca(this.layoutVertexArray,i,r,-1,-1),Ca(this.layoutVertexArray,i,r,1,-1),Ca(this.layoutVertexArray,i,r,1,1),Ca(this.layoutVertexArray,i,r,-1,1),this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+3,a+2),o.vertexLength+=4,o.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{},r,n)}}function Pa(t,e){for(let i=0;i<t.length;i++)if(Ua(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(Ua(t,e[i]))return!0;return!!Ra(t,e)}function Da(t,e,i){return!!Ua(t,e)||!!Oa(e,t,i)}function Ba(t,e){if(1===t.length)return ja(e,t[0]);for(let i=0;i<e.length;i++){const r=e[i];for(let e=0;e<r.length;e++)if(Ua(t,r[e]))return!0}for(let i=0;i<t.length;i++)if(ja(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(Ra(t,e[i]))return!0;return!1}function La(t,e,i){if(t.length>1){if(Ra(t,e))return!0;for(let r=0;r<e.length;r++)if(Oa(e[r],t,i))return!0}for(let r=0;r<t.length;r++)if(Oa(t[r],e,i))return!0;return!1}function Ra(t,e){if(0===t.length||0===e.length)return!1;for(let i=0;i<t.length-1;i++){const r=t[i],n=t[i+1];for(let t=0;t<e.length-1;t++)if(Fa(r,n,e[t],e[t+1]))return!0}return!1}function Fa(t,e,i,r){return V(t,i,r)!==V(e,i,r)&&V(t,e,i)!==V(t,e,r)}function Oa(t,e,i){const r=i*i;if(1===e.length)return t.distSqr(e[0])<r;for(let i=1;i<e.length;i++)if(Va(t,e[i-1],e[i])<r)return!0;return!1}function Va(t,e,i){const r=e.distSqr(i);if(0===r)return t.distSqr(e);const n=((t.x-e.x)*(i.x-e.x)+(t.y-e.y)*(i.y-e.y))/r;return t.distSqr(n<0?e:n>1?i:i.sub(e)._mult(n)._add(e))}function ja(t,e){let i,r,n,s=!1;for(let o=0;o<t.length;o++){i=t[o];for(let t=0,o=i.length-1;t<i.length;o=t++)r=i[t],n=i[o],r.y>e.y!=n.y>e.y&&e.x<(n.x-r.x)*(e.y-r.y)/(n.y-r.y)+r.x&&(s=!s)}return s}function Ua(t,e){let i=!1;for(let r=0,n=t.length-1;r<t.length;n=r++){const s=t[r],o=t[n];s.y>e.y!=o.y>e.y&&e.x<(o.x-s.x)*(e.y-s.y)/(o.y-s.y)+s.x&&(i=!i)}return i}function Na(t,e,i,r,n){for(const s of t)if(e<=s.x&&i<=s.y&&r>=s.x&&n>=s.y)return!0;const s=[new o(e,i),new o(e,n),new o(r,n),new o(r,i)];if(t.length>2)for(const e of s)if(Ua(t,e))return!0;for(let e=0;e<t.length-1;e++)if(Za(t[e],t[e+1],s))return!0;return!1}function Za(t,e,i){const r=i[0],n=i[2];if(t.x<r.x&&e.x<r.x||t.x>n.x&&e.x>n.x||t.y<r.y&&e.y<r.y||t.y>n.y&&e.y>n.y)return!1;const s=V(t,e,i[0]);return s!==V(t,e,i[1])||s!==V(t,e,i[2])||s!==V(t,e,i[3])}function qa(t,e,i){const r=e.paint.get(t).value;return"constant"===r.kind?r.value:i.programConfigurations.get(e.id).getMaxValue(t)}function Ga(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function $a(t,e,i,r,n){if(!e[0]&&!e[1])return t;const s=o.convert(e)._mult(n);"viewport"===i&&s._rotate(-r);const a=[];for(let e=0;e<t.length;e++)a.push(t[e].sub(s));return a}function Wa(t,e,i,r){const n=o.convert(t)._mult(r);return"viewport"===e&&n._rotate(-i),n}Fn(ka,{omit:["layers"]});const Xa=new Is({"circle-sort-key":new bs(ue.layout_circle["circle-sort-key"])});var Ha={paint:new Is({"circle-radius":new bs(ue.paint_circle["circle-radius"]),"circle-color":new bs(ue.paint_circle["circle-color"]),"circle-blur":new bs(ue.paint_circle["circle-blur"]),"circle-opacity":new bs(ue.paint_circle["circle-opacity"]),"circle-translate":new vs(ue.paint_circle["circle-translate"]),"circle-translate-anchor":new vs(ue.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new vs(ue.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new vs(ue.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new bs(ue.paint_circle["circle-stroke-width"]),"circle-stroke-color":new bs(ue.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new bs(ue.paint_circle["circle-stroke-opacity"])}),layout:Xa},Ka=1e-6,Ya="undefined"!=typeof Float32Array?Float32Array:Array;function Ja(t,e){var i=e[0],r=e[1],n=e[2],s=e[3],o=i*s-n*r;return o?(t[0]=s*(o=1/o),t[1]=-r*o,t[2]=-n*o,t[3]=i*o,t):null}function Qa(){var t=new Ya(9);return Ya!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function tl(t,e){var i=e[0],r=e[1],n=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8];return t[0]=o*h-a*c,t[1]=n*c-r*h,t[2]=r*a-n*o,t[3]=a*l-s*h,t[4]=i*h-n*l,t[5]=n*s-i*a,t[6]=s*c-o*l,t[7]=r*l-i*c,t[8]=i*o-r*s,t}function el(t,e,i){var r=e[0],n=e[1],s=e[2],o=e[3],a=e[4],l=e[5],c=e[6],h=e[7],u=e[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 t[0]=p*r+d*o+f*c,t[1]=p*n+d*a+f*h,t[2]=p*s+d*l+f*u,t[3]=m*r+_*o+g*c,t[4]=m*n+_*a+g*h,t[5]=m*s+_*l+g*u,t[6]=y*r+x*o+v*c,t[7]=y*n+x*a+v*h,t[8]=y*s+x*l+v*u,t}function il(){var t=new Ya(16);return Ya!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function rl(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function nl(t,e){var i=e[0],r=e[1],n=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=e[9],p=e[10],d=e[11],f=e[12],m=e[13],_=e[14],g=e[15],y=i*a-r*o,x=i*l-n*o,v=i*c-s*o,b=r*l-n*a,w=r*c-s*a,T=n*c-s*l,E=h*m-u*f,I=h*_-p*f,S=h*g-d*f,A=u*_-p*m,z=u*g-d*m,C=p*g-d*_,M=y*C-x*z+v*A+b*S-w*I+T*E;return M?(t[0]=(a*C-l*z+c*A)*(M=1/M),t[1]=(n*z-r*C-s*A)*M,t[2]=(m*T-_*w+g*b)*M,t[3]=(p*w-u*T-d*b)*M,t[4]=(l*S-o*C-c*I)*M,t[5]=(i*C-n*S+s*I)*M,t[6]=(_*v-f*T-g*x)*M,t[7]=(h*T-p*v+d*x)*M,t[8]=(o*z-a*S+c*E)*M,t[9]=(r*S-i*z-s*E)*M,t[10]=(f*w-m*v+g*y)*M,t[11]=(u*v-h*w-d*y)*M,t[12]=(a*I-o*A-l*E)*M,t[13]=(i*A-r*I+n*E)*M,t[14]=(m*x-f*b-_*y)*M,t[15]=(h*b-u*x+p*y)*M,t):null}function sl(t,e,i){var r=e[0],n=e[1],s=e[2],o=e[3],a=e[4],l=e[5],c=e[6],h=e[7],u=e[8],p=e[9],d=e[10],f=e[11],m=e[12],_=e[13],g=e[14],y=e[15],x=i[0],v=i[1],b=i[2],w=i[3];return t[0]=x*r+v*a+b*u+w*m,t[1]=x*n+v*l+b*p+w*_,t[2]=x*s+v*c+b*d+w*g,t[3]=x*o+v*h+b*f+w*y,t[4]=(x=i[4])*r+(v=i[5])*a+(b=i[6])*u+(w=i[7])*m,t[5]=x*n+v*l+b*p+w*_,t[6]=x*s+v*c+b*d+w*g,t[7]=x*o+v*h+b*f+w*y,t[8]=(x=i[8])*r+(v=i[9])*a+(b=i[10])*u+(w=i[11])*m,t[9]=x*n+v*l+b*p+w*_,t[10]=x*s+v*c+b*d+w*g,t[11]=x*o+v*h+b*f+w*y,t[12]=(x=i[12])*r+(v=i[13])*a+(b=i[14])*u+(w=i[15])*m,t[13]=x*n+v*l+b*p+w*_,t[14]=x*s+v*c+b*d+w*g,t[15]=x*o+v*h+b*f+w*y,t}function ol(t,e,i){var r,n,s,o,a,l,c,h,u,p,d,f,m=i[0],_=i[1],g=i[2];return e===t?(t[12]=e[0]*m+e[4]*_+e[8]*g+e[12],t[13]=e[1]*m+e[5]*_+e[9]*g+e[13],t[14]=e[2]*m+e[6]*_+e[10]*g+e[14],t[15]=e[3]*m+e[7]*_+e[11]*g+e[15]):(n=e[1],s=e[2],o=e[3],a=e[4],l=e[5],c=e[6],h=e[7],u=e[8],p=e[9],d=e[10],f=e[11],t[0]=r=e[0],t[1]=n,t[2]=s,t[3]=o,t[4]=a,t[5]=l,t[6]=c,t[7]=h,t[8]=u,t[9]=p,t[10]=d,t[11]=f,t[12]=r*m+a*_+u*g+e[12],t[13]=n*m+l*_+p*g+e[13],t[14]=s*m+c*_+d*g+e[14],t[15]=o*m+h*_+f*g+e[15]),t}function al(t,e,i){var r=i[0],n=i[1],s=i[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*s,t[9]=e[9]*s,t[10]=e[10]*s,t[11]=e[11]*s,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function ll(t,e,i){var r=Math.sin(i),n=Math.cos(i),s=e[4],o=e[5],a=e[6],l=e[7],c=e[8],h=e[9],u=e[10],p=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=s*n+c*r,t[5]=o*n+h*r,t[6]=a*n+u*r,t[7]=l*n+p*r,t[8]=c*n-s*r,t[9]=h*n-o*r,t[10]=u*n-a*r,t[11]=p*n-l*r,t}function cl(t,e,i){var r=Math.sin(i),n=Math.cos(i),s=e[0],o=e[1],a=e[2],l=e[3],c=e[8],h=e[9],u=e[10],p=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*n-c*r,t[1]=o*n-h*r,t[2]=a*n-u*r,t[3]=l*n-p*r,t[8]=s*r+c*n,t[9]=o*r+h*n,t[10]=a*r+u*n,t[11]=l*r+p*n,t}function hl(t,e,i){var r=Math.sin(i),n=Math.cos(i),s=e[0],o=e[1],a=e[2],l=e[3],c=e[4],h=e[5],u=e[6],p=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*n+c*r,t[1]=o*n+h*r,t[2]=a*n+u*r,t[3]=l*n+p*r,t[4]=c*n-s*r,t[5]=h*n-o*r,t[6]=u*n-a*r,t[7]=p*n-l*r,t}function ul(t,e){var i=e[0],r=e[1],n=e[2],s=e[3],o=i+i,a=r+r,l=n+n,c=i*o,h=r*o,u=r*a,p=n*o,d=n*a,f=n*l,m=s*o,_=s*a,g=s*l;return t[0]=1-u-f,t[1]=h+g,t[2]=p-_,t[3]=0,t[4]=h-g,t[5]=1-c-f,t[6]=d+m,t[7]=0,t[8]=p+_,t[9]=d-m,t[10]=1-c-u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function pl(t,e,i,r,n){var s,o=1/Math.tan(e/2);return t[0]=o/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=n&&n!==1/0?(t[10]=(n+r)*(s=1/(r-n)),t[14]=2*n*r*s):(t[10]=-1,t[14]=-2*r),t}function dl(t,e,i,r,n,s,o){var a=1/(e-i),l=1/(r-n),c=1/(s-o);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+i)*a,t[13]=(n+r)*l,t[14]=(o+s)*c,t[15]=1,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var fl=sl;function ml(){var t=new Ya(3);return Ya!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function _l(t){var e=new Ya(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function gl(t){return Math.hypot(t[0],t[1],t[2])}function yl(t,e,i){var r=new Ya(3);return r[0]=t,r[1]=e,r[2]=i,r}function xl(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t}function vl(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t}function bl(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t[2]=e[2]*i[2],t}function wl(t,e,i){return t[0]=Math.min(e[0],i[0]),t[1]=Math.min(e[1],i[1]),t[2]=Math.min(e[2],i[2]),t}function Tl(t,e,i){return t[0]=Math.max(e[0],i[0]),t[1]=Math.max(e[1],i[1]),t[2]=Math.max(e[2],i[2]),t}function El(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t}function Il(t,e,i,r){return t[0]=e[0]+i[0]*r,t[1]=e[1]+i[1]*r,t[2]=e[2]+i[2]*r,t}function Sl(t,e){var i=e[0],r=e[1],n=e[2],s=i*i+r*r+n*n;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t}function Al(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function zl(t,e,i){var r=e[0],n=e[1],s=e[2],o=i[0],a=i[1],l=i[2];return t[0]=n*l-s*a,t[1]=s*o-r*l,t[2]=r*a-n*o,t}function Cl(t,e,i){var r=e[0],n=e[1],s=e[2],o=i[3]*r+i[7]*n+i[11]*s+i[15];return t[0]=(i[0]*r+i[4]*n+i[8]*s+i[12])/(o=o||1),t[1]=(i[1]*r+i[5]*n+i[9]*s+i[13])/o,t[2]=(i[2]*r+i[6]*n+i[10]*s+i[14])/o,t}function Ml(t,e,i){var r=e[0],n=e[1],s=e[2];return t[0]=r*i[0]+n*i[3]+s*i[6],t[1]=r*i[1]+n*i[4]+s*i[7],t[2]=r*i[2]+n*i[5]+s*i[8],t}function kl(t,e,i){var r=i[0],n=i[1],s=i[2],o=e[0],a=e[1],l=e[2],c=n*l-s*a,h=s*o-r*l,u=r*a-n*o,p=n*u-s*h,d=s*c-r*u,f=r*h-n*c,m=2*i[3];return h*=m,u*=m,d*=2,f*=2,t[0]=o+(c*=m)+(p*=2),t[1]=a+h+d,t[2]=l+u+f,t}var Pl,Dl=vl,Bl=bl,Ll=function(t,e,i){return t[0]=e[0]/i[0],t[1]=e[1]/i[1],t[2]=e[2]/i[2],t},Rl=gl;function Fl(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t}function Ol(t,e,i){var r=e[0],n=e[1],s=e[2],o=e[3];return t[0]=i[0]*r+i[4]*n+i[8]*s+i[12]*o,t[1]=i[1]*r+i[5]*n+i[9]*s+i[13]*o,t[2]=i[2]*r+i[6]*n+i[10]*s+i[14]*o,t[3]=i[3]*r+i[7]*n+i[11]*s+i[15]*o,t}function Vl(){var t=new Ya(4);return Ya!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function jl(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function Ul(t,e,i){i*=.5;var r=e[0],n=e[1],s=e[2],o=e[3],a=Math.sin(i),l=Math.cos(i);return t[0]=r*l+o*a,t[1]=n*l+s*a,t[2]=s*l-n*a,t[3]=o*l-r*a,t}ml(),Pl=new Ya(4),Ya!=Float32Array&&(Pl[0]=0,Pl[1]=0,Pl[2]=0,Pl[3]=0),ml(),yl(1,0,0),yl(0,1,0),Vl(),Vl(),Qa();class Nl{constructor(t,e){this.pos=t,this.dir=e}intersectsPlane(t,e,i){const r=Al(e,this.dir);if(Math.abs(r)<1e-6)return!1;const n=((t[0]-this.pos[0])*e[0]+(t[1]-this.pos[1])*e[1]+(t[2]-this.pos[2])*e[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(t,e,i){if(function(t,e){var i=t[0],r=t[1],n=t[2],s=e[0],o=e[1],a=e[2];return Math.abs(i-s)<=Ka*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(r-o)<=Ka*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(n-a)<=Ka*Math.max(1,Math.abs(n),Math.abs(a))}(this.pos,t)||0===e)return i[0]=i[1]=i[2]=0,!1;const[r,n,s]=this.dir,o=this.pos[0]-t[0],a=this.pos[1]-t[1],l=this.pos[2]-t[2],c=r*r+n*n+s*s,h=2*(o*r+a*n+l*s),u=h*h-4*c*(o*o+a*a+l*l-e*e);if(u<0){const t=Math.max(-h/2,0),c=o+r*t,u=a+n*t,p=l+s*t,d=Math.hypot(c,u,p);return i[0]=c*e/d,i[1]=u*e/d,i[2]=p*e/d,!1}{const t=(-h-Math.sqrt(u))/(2*c);if(t<0){const t=Math.hypot(o,a,l);return i[0]=o*e/t,i[1]=a*e/t,i[2]=l*e/t,!1}return i[0]=o+r*t,i[1]=a+n*t,i[2]=l+s*t,!0}}}class Zl{constructor(t,e){this.points=t,this.planes=e}static fromInvProjectionMatrix(t,e,i,r){const n=Math.pow(2,i),s=[[-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 s=Ol([],i,t),o=1/s[3]/e*n;return function(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t[2]=e[2]*i[2],t[3]=e[3]*i[3],t}(s,s,[o,o,r?1/s[3]:o,o])})),o=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const e=Sl([],zl([],Dl([],s[t[0]],s[t[1]]),Dl([],s[t[2]],s[t[1]]))),i=-Al(e,s[t[1]]);return e.concat(i)}));return new Zl(s,o)}}class ql{constructor(t,e){this.min=t,this.max=e,this.center=El([],xl([],this.min,this.max),.5)}quadrant(t){const e=[t%2==0,t<2],i=_l(this.min),r=_l(this.max);for(let t=0;t<e.length;t++)i[t]=e[t]?this.min[t]:this.center[t],r[t]=e[t]?this.center[t]:this.max[t];return r[2]=this.max[2],new ql(i,r)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}distanceZ(t){return Math.max(Math.min(this.max[2],t[2]),this.min[2])-t[2]}getCorners(){const t=this.min,e=this.max;return[[t[0],t[1],t[2]],[e[0],t[1],t[2]],[e[0],e[1],t[2]],[t[0],e[1],t[2]],[t[0],t[1],e[2]],[e[0],t[1],e[2]],[e[0],e[1],e[2]],[t[0],e[1],e[2]]]}intersects(t){const e=this.getCorners();let i=!0;for(let r=0;r<t.planes.length;r++){const n=t.planes[r];let s=0;for(let t=0;t<e.length;t++)s+=Al(n,e[t])+n[3]>=0;if(0===s)return 0;s!==e.length&&(i=!1)}if(i)return 2;for(let e=0;e<3;e++){let i=Number.MAX_VALUE,r=-Number.MAX_VALUE;for(let n=0;n<t.points.length;n++){const s=t.points[n][e]-this.min[e];i=Math.min(i,s),r=Math.max(r,s)}if(r<0||i>this.max[e]-this.min[e])return 0}return 1}}function Gl(t,e,i,r,n,s,o,a,l){if(s&&t.queryGeometry.isAboveHorizon)return!1;s&&(l*=t.pixelToTileUnitsFactor);for(const c of e)for(const e of c){const c=e.add(a),h=n&&i.elevation?i.elevation.exaggeration()*n.getElevationAt(c.x,c.y,!0):0,u=s?c:$l(c,h,r),p=s?t.tilespaceRays.map((t=>Hl(t,h))):t.queryGeometry.screenGeometry,d=Ol([],[e.x,e.y,h,1],r);if(!o&&s?l*=d[3]/i.cameraToCenterDistance:o&&!s&&(l*=i.cameraToCenterDistance/d[3]),Da(p,u,l))return!0}return!1}function $l(t,e,i){const r=Ol([],[t.x,t.y,e,1],i);return new o(r[0]/r[3],r[1]/r[3])}const Wl=yl(0,0,0),Xl=yl(0,0,1);function Hl(t,e){const i=ml();return Wl[2]=e,t.intersectsPlane(Wl,Xl,i),new o(i[0],i[1])}class Kl extends ka{}function Yl(t,{width:e,height:i},r,n){if(n){if(n instanceof Uint8ClampedArray)n=new Uint8Array(n.buffer);else if(n.length!==e*i*r)throw new RangeError("mismatched image size")}else n=new Uint8Array(e*i*r);return t.width=e,t.height=i,t.data=n,t}function Jl(t,e,i){const{width:r,height:n}=e;r===t.width&&n===t.height||(Ql(t,e,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,r),height:Math.min(t.height,n)},i),t.width=r,t.height=n,t.data=e.data)}function Ql(t,e,i,r,n,s){if(0===n.width||0===n.height)return e;if(n.width>t.width||n.height>t.height||i.x>t.width-n.width||i.y>t.height-n.height)throw new RangeError("out of range source coordinates for image copy");if(n.width>e.width||n.height>e.height||r.x>e.width-n.width||r.y>e.height-n.height)throw new RangeError("out of range destination coordinates for image copy");const o=t.data,a=e.data;for(let l=0;l<n.height;l++){const c=((i.y+l)*t.width+i.x)*s,h=((r.y+l)*e.width+r.x)*s;for(let t=0;t<n.width*s;t++)a[h+t]=o[c+t]}return e}Fn(Kl,{omit:["layers"]});class tc{constructor(t,e){Yl(this,t,1,e)}resize(t){Jl(this,new tc(t),1)}clone(){return new tc({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,n){Ql(t,e,i,r,n,1)}}class ec{constructor(t,e){Yl(this,t,4,e)}resize(t){Jl(this,new ec(t),4)}replace(t,e){e?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new ec({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,n){Ql(t,e,i,r,n,4)}}Fn(tc),Fn(ec);var ic={paint:new Is({"heatmap-radius":new bs(ue.paint_heatmap["heatmap-radius"]),"heatmap-weight":new bs(ue.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new vs(ue.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Es(ue.paint_heatmap["heatmap-color"]),"heatmap-opacity":new vs(ue.paint_heatmap["heatmap-opacity"])})};function rc(t){const e={},i=t.resolution||256,r=t.clips?t.clips.length:1,n=t.image||new ec({width:i,height:r}),s=(i,r,s)=>{e[t.evaluationKey]=s;const o=t.expression.evaluate(e);n.data[i+r+0]=Math.floor(255*o.r/o.a),n.data[i+r+1]=Math.floor(255*o.g/o.a),n.data[i+r+2]=Math.floor(255*o.b/o.a),n.data[i+r+3]=Math.floor(255*o.a)};if(t.clips)for(let e=0,n=0;e<r;++e,n+=4*i)for(let r=0,o=0;r<i;r++,o+=4){const a=r/(i-1),{start:l,end:c}=t.clips[e];s(n,o,l*(1-a)+c*a)}else for(let t=0,e=0;t<i;t++,e+=4)s(0,e,t/(i-1));return n}var nc={paint:new Is({"hillshade-illumination-direction":new vs(ue.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new vs(ue.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new vs(ue.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new vs(ue.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new vs(ue.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new vs(ue.paint_hillshade["hillshade-accent-color"])})};const sc=Ms([{name:"a_pos",components:2,type:"Int16"}],4),{members:oc}=sc;var ac=cc,lc=cc;function cc(t,e,i){i=i||2;var r,n,s,o,a,l,c,h=e&&e.length,u=h?e[0]*i:t.length,p=hc(t,0,u,i,!0),d=[];if(!p||p.next===p.prev)return d;if(h&&(p=function(t,e,i,r){var n,s,o,a=[];for(n=0,s=e.length;n<s;n++)(o=hc(t,e[n]*r,n<s-1?e[n+1]*r:t.length,r,!1))===o.next&&(o.steiner=!0),a.push(bc(o));for(a.sort(gc),n=0;n<a.length;n++)i=uc(i=yc(a[n],i),i.next);return i}(t,e,p,i)),t.length>80*i){r=s=t[0],n=o=t[1];for(var f=i;f<u;f+=i)(a=t[f])<r&&(r=a),(l=t[f+1])<n&&(n=l),a>s&&(s=a),l>o&&(o=l);c=0!==(c=Math.max(s-r,o-n))?1/c:0}return pc(p,d,i,r,n,c),d}function hc(t,e,i,r,n){var s,o;if(n===Bc(t,e,i,r)>0)for(s=e;s<i;s+=r)o=kc(s,t[s],t[s+1],o);else for(s=i-r;s>=e;s-=r)o=kc(s,t[s],t[s+1],o);return o&&Ic(o,o.next)&&(Pc(o),o=o.next),o}function uc(t,e){if(!t)return t;e||(e=t);var i,r=t;do{if(i=!1,r.steiner||!Ic(r,r.next)&&0!==Ec(r.prev,r,r.next))r=r.next;else{if(Pc(r),(r=e=r.prev)===r.next)break;i=!0}}while(i||r!==e);return e}function pc(t,e,i,r,n,s,o){if(t){!o&&s&&function(t,e,i,r){var n=t;do{null===n.z&&(n.z=vc(n.x,n.y,e,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,function(t){var e,i,r,n,s,o,a,l,c=1;do{for(i=t,t=null,s=null,o=0;i;){for(o++,r=i,a=0,e=0;e<c&&(a++,r=r.nextZ);e++);for(l=c;a>0||l>0&&r;)0!==a&&(0===l||!r||i.z<=r.z)?(n=i,i=i.nextZ,a--):(n=r,r=r.nextZ,l--),s?s.nextZ=n:t=n,n.prevZ=s,s=n;i=r}s.nextZ=null,c*=2}while(o>1)}(n)}(t,r,n,s);for(var a,l,c=t;t.prev!==t.next;)if(a=t.prev,l=t.next,s?fc(t,r,n,s):dc(t))e.push(a.i/i),e.push(t.i/i),e.push(l.i/i),Pc(t),t=l.next,c=l.next;else if((t=l)===c){o?1===o?pc(t=mc(uc(t),e,i),e,i,r,n,s,2):2===o&&_c(t,e,i,r,n,s):pc(uc(t),e,i,r,n,s,1);break}}}function dc(t){var e=t.prev,i=t,r=t.next;if(Ec(e,i,r)>=0)return!1;for(var n=t.next.next;n!==t.prev;){if(wc(e.x,e.y,i.x,i.y,r.x,r.y,n.x,n.y)&&Ec(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function fc(t,e,i,r){var n=t.prev,s=t,o=t.next;if(Ec(n,s,o)>=0)return!1;for(var a=n.x>s.x?n.x>o.x?n.x:o.x:s.x>o.x?s.x:o.x,l=n.y>s.y?n.y>o.y?n.y:o.y:s.y>o.y?s.y:o.y,c=vc(n.x<s.x?n.x<o.x?n.x:o.x:s.x<o.x?s.x:o.x,n.y<s.y?n.y<o.y?n.y:o.y:s.y<o.y?s.y:o.y,e,i,r),h=vc(a,l,e,i,r),u=t.prevZ,p=t.nextZ;u&&u.z>=c&&p&&p.z<=h;){if(u!==t.prev&&u!==t.next&&wc(n.x,n.y,s.x,s.y,o.x,o.y,u.x,u.y)&&Ec(u.prev,u,u.next)>=0)return!1;if(u=u.prevZ,p!==t.prev&&p!==t.next&&wc(n.x,n.y,s.x,s.y,o.x,o.y,p.x,p.y)&&Ec(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;u&&u.z>=c;){if(u!==t.prev&&u!==t.next&&wc(n.x,n.y,s.x,s.y,o.x,o.y,u.x,u.y)&&Ec(u.prev,u,u.next)>=0)return!1;u=u.prevZ}for(;p&&p.z<=h;){if(p!==t.prev&&p!==t.next&&wc(n.x,n.y,s.x,s.y,o.x,o.y,p.x,p.y)&&Ec(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function mc(t,e,i){var r=t;do{var n=r.prev,s=r.next.next;!Ic(n,s)&&Sc(n,r,r.next,s)&&Cc(n,s)&&Cc(s,n)&&(e.push(n.i/i),e.push(r.i/i),e.push(s.i/i),Pc(r),Pc(r.next),r=t=s),r=r.next}while(r!==t);return uc(r)}function _c(t,e,i,r,n,s){var o=t;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&Tc(o,a)){var l=Mc(o,a);return o=uc(o,o.next),l=uc(l,l.next),pc(o,e,i,r,n,s),void pc(l,e,i,r,n,s)}a=a.next}o=o.next}while(o!==t)}function gc(t,e){return t.x-e.x}function yc(t,e){var i=function(t,e){var i,r=e,n=t.x,s=t.y,o=-1/0;do{if(s<=r.y&&s>=r.next.y&&r.next.y!==r.y){var a=r.x+(s-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=n&&a>o){if(o=a,a===n){if(s===r.y)return r;if(s===r.next.y)return r.next}i=r.x<r.next.x?r:r.next}}r=r.next}while(r!==e);if(!i)return null;if(n===o)return i;var l,c=i,h=i.x,u=i.y,p=1/0;r=i;do{n>=r.x&&r.x>=h&&n!==r.x&&wc(s<u?n:o,s,h,u,s<u?o:n,s,r.x,r.y)&&(l=Math.abs(s-r.y)/(n-r.x),Cc(r,t)&&(l<p||l===p&&(r.x>i.x||r.x===i.x&&xc(i,r)))&&(i=r,p=l)),r=r.next}while(r!==c);return i}(t,e);if(!i)return e;var r=Mc(i,t),n=uc(i,i.next);return uc(r,r.next),e===i?n:e}function xc(t,e){return Ec(t.prev,t,e.prev)<0&&Ec(e.next,t,t.next)<0}function vc(t,e,i,r,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*n)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*n)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function bc(t){var e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function wc(t,e,i,r,n,s,o,a){return(n-o)*(e-a)-(t-o)*(s-a)>=0&&(t-o)*(r-a)-(i-o)*(e-a)>=0&&(i-o)*(s-a)-(n-o)*(r-a)>=0}function Tc(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Sc(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Cc(t,e)&&Cc(e,t)&&function(t,e){var i=t,r=!1,n=(t.x+e.x)/2,s=(t.y+e.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&n<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==t);return r}(t,e)&&(Ec(t.prev,t,e.prev)||Ec(t,e.prev,e))||Ic(t,e)&&Ec(t.prev,t,t.next)>0&&Ec(e.prev,e,e.next)>0)}function Ec(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Ic(t,e){return t.x===e.x&&t.y===e.y}function Sc(t,e,i,r){var n=zc(Ec(t,e,i)),s=zc(Ec(t,e,r)),o=zc(Ec(i,r,t)),a=zc(Ec(i,r,e));return n!==s&&o!==a||!(0!==n||!Ac(t,i,e))||!(0!==s||!Ac(t,r,e))||!(0!==o||!Ac(i,t,r))||!(0!==a||!Ac(i,e,r))}function Ac(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function zc(t){return t>0?1:t<0?-1:0}function Cc(t,e){return Ec(t.prev,t,t.next)<0?Ec(t,e,t.next)>=0&&Ec(t,t.prev,e)>=0:Ec(t,e,t.prev)<0||Ec(t,t.next,e)<0}function Mc(t,e){var i=new Dc(t.i,t.x,t.y),r=new Dc(e.i,e.x,e.y),n=t.next,s=e.prev;return t.next=e,e.prev=t,i.next=n,n.prev=i,r.next=i,i.prev=r,s.next=r,r.prev=s,r}function kc(t,e,i,r){var n=new Dc(t,e,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 Pc(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Dc(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Bc(t,e,i,r){for(var n=0,s=e,o=i-r;s<i;s+=r)n+=(t[o]-t[s])*(t[s+1]+t[o+1]),o=s;return n}function Lc(t,e,i,r,n){Rc(t,e,i||0,r||t.length-1,n||Oc)}function Rc(t,e,i,r,n){for(;r>i;){if(r-i>600){var s=r-i+1,o=e-i+1,a=Math.log(s),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(s-l)/s)*(o-s/2<0?-1:1);Rc(t,e,Math.max(i,Math.floor(e-o*l/s+c)),Math.min(r,Math.floor(e+(s-o)*l/s+c)),n)}var h=t[e],u=i,p=r;for(Fc(t,i,e),n(t[r],h)>0&&Fc(t,i,r);u<p;){for(Fc(t,u,p),u++,p--;n(t[u],h)<0;)u++;for(;n(t[p],h)>0;)p--}0===n(t[i],h)?Fc(t,i,p):Fc(t,++p,r),p<=e&&(i=p+1),e<=p&&(r=p-1)}}function Fc(t,e,i){var r=t[e];t[e]=t[i],t[i]=r}function Oc(t,e){return t<e?-1:t>e?1:0}function Vc(t,e){const i=t.length;if(i<=1)return[t];const r=[];let n,s;for(let e=0;e<i;e++){const i=j(t[e]);0!==i&&(t[e].area=Math.abs(i),void 0===s&&(s=i<0),s===i<0?(n&&r.push(n),n=[t[e]]):n.push(t[e]))}if(n&&r.push(n),e>1)for(let t=0;t<r.length;t++)r[t].length<=e||(Lc(r[t],e,1,r[t].length-1,jc),r[t]=r[t].slice(0,e));return r}function jc(t,e){return e.area-t.area}function Uc(t,e,i){const r=i.patternDependencies;let n=!1;for(const i of e){const e=i.paint.get(`${t}-pattern`);e.isConstant()||(n=!0);const s=e.constantOr(null);s&&(n=!0,r[s.to]=!0,r[s.from]=!0)}return n}function Nc(t,e,i,r,n){const s=n.patternDependencies;for(const o of e){const e=o.paint.get(`${t}-pattern`).value;if("constant"!==e.kind){let t=e.evaluate({zoom:r-1},i,{},n.availableImages),a=e.evaluate({zoom:r},i,{},n.availableImages),l=e.evaluate({zoom:r+1},i,{},n.availableImages);t=t&&t.name?t.name:t,a=a&&a.name?a.name:a,l=l&&l.name?l.name:l,s[t]=!0,s[a]=!0,s[l]=!0,i.patterns[o.id]={min:t,mid:a,max:l}}}return i}cc.deviation=function(t,e,i,r){var n=e&&e.length,s=Math.abs(Bc(t,0,n?e[0]*i:t.length,i));if(n)for(var o=0,a=e.length;o<a;o++)s-=Math.abs(Bc(t,e[o]*i,o<a-1?e[o+1]*i:t.length,i));var l=0;for(o=0;o<r.length;o+=3){var c=r[o]*i,h=r[o+1]*i,u=r[o+2]*i;l+=Math.abs((t[c]-t[u])*(t[h+1]-t[c+1])-(t[c]-t[h])*(t[u+1]-t[c+1]))}return 0===s&&0===l?0:Math.abs((l-s)/s)},cc.flatten=function(t){for(var e=t[0][0].length,i={vertices:[],holes:[],dimensions:e},r=0,n=0;n<t.length;n++){for(var s=0;s<t[n].length;s++)for(var o=0;o<e;o++)i.vertices.push(t[n][s][o]);n>0&&i.holes.push(r+=t[n-1].length)}return i},ac.default=lc;class Zc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Ps,this.indexArray=new $s,this.indexArray2=new Qs,this.programConfigurations=new Yo(t.layers,t.zoom),this.segments=new aa,this.segments2=new aa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection}populate(t,e,i,r){this.hasPattern=Uc("fill",this.layers,e);const n=this.layers[0].layout.get("fill-sort-key"),s=[];for(const{feature:o,id:a,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,h=za(o,t);if(!this.layers[0]._featureFilter.filter(new us(this.zoom),h,i))continue;const u=n?n.evaluate(h,{},i,e.availableImages):void 0,p={id:a,properties:o.properties,type:o.type,sourceLayerIndex:c,index:l,geometry:t?h.geometry:Aa(o,i,r),patterns:{},sortKey:u};s.push(p)}n&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of s){const{geometry:n,index:s,sourceLayerIndex:o}=r;if(this.hasPattern){const t=Nc("fill",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,n,s,i,{},e.availableImages);e.featureIndex.insert(t[s].feature,n,s,o,this.index)}}update(t,e,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i,r)}addFeatures(t,e,i,r,n){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,oc),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),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(t,e,i,r,n,s=[]){for(const t of Vc(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),r=i.vertexLength,n=[],s=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&s.push(n.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),r=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(r+e.length-1,r),n.push(e[0].x),n.push(e[0].y);for(let t=1;t<e.length;t++)this.layoutVertexArray.emplaceBack(e[t].x,e[t].y),this.indexArray2.emplaceBack(r+t-1,r+t),n.push(e[t].x),n.push(e[t].y);i.vertexLength+=e.length,i.primitiveLength+=e.length}const o=ac(n,s);for(let t=0;t<o.length;t+=3)this.indexArray.emplaceBack(r+o[t],r+o[t+1],r+o[t+2]);i.vertexLength+=e,i.primitiveLength+=o.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,n,s,r)}}Fn(Zc,{omit:["layers","patternFeatures"]});const qc=new Is({"fill-sort-key":new bs(ue.layout_fill["fill-sort-key"])});var Gc={paint:new Is({"fill-antialias":new vs(ue.paint_fill["fill-antialias"]),"fill-opacity":new bs(ue.paint_fill["fill-opacity"]),"fill-color":new bs(ue.paint_fill["fill-color"]),"fill-outline-color":new bs(ue.paint_fill["fill-outline-color"]),"fill-translate":new vs(ue.paint_fill["fill-translate"]),"fill-translate-anchor":new vs(ue.paint_fill["fill-translate-anchor"]),"fill-pattern":new ws(ue.paint_fill["fill-pattern"])}),layout:qc};const $c=Ms([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),Wc=Ms([{name:"a_centroid_pos",components:2,type:"Uint16"}]),Xc=Ms([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:Hc}=$c;var Kc=Yc;function Yc(t,e,i,r,n){this.properties={},this.extent=i,this.type=0,this._pbf=t,this._geometry=-1,this._keys=r,this._values=n,t.readFields(Jc,this,e)}function Jc(t,e,i){1==t?e.id=i.readVarint():2==t?function(t,e){for(var i=t.readVarint()+t.pos;t.pos<i;){var r=e._keys[t.readVarint()],n=e._values[t.readVarint()];e.properties[r]=n}}(i,e):3==t?e.type=i.readVarint():4==t&&(e._geometry=i.pos)}function Qc(t){for(var e,i,r=0,n=0,s=t.length,o=s-1;n<s;o=n++)r+=((i=t[o]).x-(e=t[n]).x)*(e.y+i.y);return r}Yc.types=["Unknown","Point","LineString","Polygon"],Yc.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var e,i=t.readVarint()+t.pos,r=1,n=0,s=0,a=0,l=[];t.pos<i;){if(n<=0){var c=t.readVarint();r=7&c,n=c>>3}if(n--,1===r||2===r)s+=t.readSVarint(),a+=t.readSVarint(),1===r&&(e&&l.push(e),e=[]),e.push(new o(s,a));else{if(7!==r)throw new Error("unknown command "+r);e&&e.push(e[0].clone())}}return e&&l.push(e),l},Yc.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,r=0,n=0,s=0,o=1/0,a=-1/0,l=1/0,c=-1/0;t.pos<e;){if(r<=0){var h=t.readVarint();i=7&h,r=h>>3}if(r--,1===i||2===i)(n+=t.readSVarint())<o&&(o=n),n>a&&(a=n),(s+=t.readSVarint())<l&&(l=s),s>c&&(c=s);else if(7!==i)throw new Error("unknown command "+i)}return[o,l,a,c]},Yc.prototype.toGeoJSON=function(t,e,i){var r,n,s=this.extent*Math.pow(2,i),o=this.extent*t,a=this.extent*e,l=this.loadGeometry(),c=Yc.types[this.type];function h(t){for(var e=0;e<t.length;e++){var i=t[e];t[e]=[360*(i.x+o)/s-180,360/Math.PI*Math.atan(Math.exp((180-360*(i.y+a)/s)*Math.PI/180))-90]}}switch(this.type){case 1:var u=[];for(r=0;r<l.length;r++)u[r]=l[r][0];h(l=u);break;case 2:for(r=0;r<l.length;r++)h(l[r]);break;case 3:for(l=function(t){var e=t.length;if(e<=1)return[t];for(var i,r,n=[],s=0;s<e;s++){var o=Qc(t[s]);0!==o&&(void 0===r&&(r=o<0),r===o<0?(i&&n.push(i),i=[t[s]]):i.push(t[s]))}return i&&n.push(i),n}(l),r=0;r<l.length;r++)for(n=0;n<l[r].length;n++)h(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 th=eh;function eh(t,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(ih,this,e),this.length=this._features.length}function ih(t,e,i){15===t?e.version=i.readVarint():1===t?e.name=i.readString():5===t?e.extent=i.readVarint():2===t?e._features.push(i.pos):3===t?e._keys.push(i.readString()):4===t&&e._values.push(function(t){for(var e=null,i=t.readVarint()+t.pos;t.pos<i;){var r=t.readVarint()>>3;e=1===r?t.readString():2===r?t.readFloat():3===r?t.readDouble():4===r?t.readVarint64():5===r?t.readVarint():6===r?t.readSVarint():7===r?t.readBoolean():null}return e}(i))}function rh(t,e,i){if(3===t){var r=new th(i,i.readVarint()+i.pos);r.length&&(e[r.name]=r)}}eh.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new Kc(this._pbf,e,this.extent,this._keys,this._values)};var nh={VectorTile:function(t,e){this.layers=t.readFields(rh,{},e)},VectorTileFeature:Kc,VectorTileLayer:th};function sh(t,e,i,r){const n=[],s=0===r?(t,e,i,r,n,s)=>{t.push(new o(s,i+(s-e)/(r-e)*(n-i)))}:(t,e,i,r,n,s)=>{t.push(new o(e+(s-i)/(n-i)*(r-e),s))};for(const o of t){const t=[];for(const n of o){if(n.length<=2)continue;const o=[];for(let t=0;t<n.length-1;t++){const a=n[t].x,l=n[t].y,c=n[t+1].x,h=n[t+1].y,u=0===r?a:l,p=0===r?c:h;u<e?p>e&&s(o,a,l,c,h,e):u>i?p<i&&s(o,a,l,c,h,i):o.push(n[t]),p<e&&u>=e&&s(o,a,l,c,h,e),p>i&&u<=i&&s(o,a,l,c,h,i)}let a=n[n.length-1];const l=0===r?a.x:a.y;l>=e&&l<=i&&o.push(a),o.length&&(a=o[o.length-1],o[0].x===a.x&&o[0].y===a.y||o.push(o[0]),t.push(o))}t.length&&n.push(t)}return n}const oh=nh.VectorTileFeature.types,ah=Math.pow(2,13);function lh(t,e,i,r,n,s,o,a){t.emplaceBack((e<<1)+o,(i<<1)+s,(Math.floor(r*ah)<<1)+n,Math.round(a))}function ch(t,e,i){const r=16384;t.emplaceBack(e.x,e.y,e.z,i[0]*r,i[1]*r,i[2]*r)}class hh{constructor(){this.acc=new o(0,0),this.polyCount=[]}startRing(t){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new o(t.x,t.y),this.max=new o(t.x,t.y))}append(t,e){this.currentPolyCount.edges++,this.acc._add(t);const i=this.min,r=this.max;t.x<i.x?i.x=t.x:t.x>r.x&&(r.x=t.x),t.y<i.y?i.y=t.y:t.y>r.y&&(r.y=t.y),((0===t.x||t.x===la)&&t.x===e.x)!=((0===t.y||t.y===la)&&t.y===e.y)&&this.processBorderOverlap(t,e),e.x<0!=t.x<0&&this.addBorderIntersection(0,Ai(e.y,t.y,(0-e.x)/(t.x-e.x))),e.x>la!=t.x>la&&this.addBorderIntersection(1,Ai(e.y,t.y,(la-e.x)/(t.x-e.x))),e.y<0!=t.y<0&&this.addBorderIntersection(2,Ai(e.x,t.x,(0-e.y)/(t.y-e.y))),e.y>la!=t.y>la&&this.addBorderIntersection(3,Ai(e.x,t.x,(la-e.y)/(t.y-e.y)))}addBorderIntersection(t,e){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[t];e<i[0]&&(i[0]=e),e>i[1]&&(i[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const i=0===t.x?0:1;this.addBorderIntersection(i,e.y),this.addBorderIntersection(i,t.y)}else{const i=0===t.y?2:3;this.addBorderIntersection(i,e.x),this.addBorderIntersection(i,t.x)}}centroid(){const t=this.polyCount.reduce(((t,e)=>t+e.edges),0);return 0!==t?this.acc.div(t)._round():new o(0,0)}span(){return new o(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0)}}class uh{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new Bs,this.centroidVertexArray=new yo,this.indexArray=new $s,this.programConfigurations=new Yo(t.layers,t.zoom),this.segments=new aa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.enableTerrain=t.enableTerrain}populate(t,e,i,r){this.features=[],this.hasPattern=Uc("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(t){const e=Math.exp(Math.PI*(1-t.y/(1<<t.z)*2));return 80150034*e/(e*e+1)/la/(1<<t.z)}(i);for(const{feature:n,id:s,index:o,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=za(n,t);if(!this.layers[0]._featureFilter.filter(new us(this.zoom),l,i))continue;const c={id:s,sourceLayerIndex:a,index:o,geometry:t?l.geometry:Aa(n,i,r),properties:n.properties,type:n.type,patterns:{}},h=this.layoutVertexArray.length;this.hasPattern?this.features.push(Nc("fill-extrusion",this.layers,c,this.zoom,e)):this.addFeature(c,c.geometry,o,i,{},e.availableImages,r),e.featureIndex.insert(n,c.geometry,o,a,this.index,h)}this.sortBorders()}addFeatures(t,e,i,r,n){for(const t of this.features){const{geometry:s}=t;this.addFeature(t,s,t.index,e,i,r,n)}this.sortBorders()}update(t,e,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Hc),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,Xc.members,!0))),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){0!==this.centroidVertexArray.length&&(this.centroidVertexBuffer?this.needsCentroidUpdate&&this.centroidVertexBuffer.updateData(this.centroidVertexArray):this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Wc.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(t,e,i,r,n,s,a){const l=[new o(0,0),new o(la,la)],c=a.projection,h="globe"===c.name,u=this.enableTerrain&&!h?new hh:null;h&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new so);const p=Vc(e,500);for(let t=p.length-1;t>=0;t--){const e=p[t];(0===e.length||(d=e[0]).every((t=>t.x<=0))||d.every((t=>t.x>=la))||d.every((t=>t.y<=0))||d.every((t=>t.y>=la)))&&p.splice(t,1)}var d;let f;if(h){const t=11.25,e=1<<r.z,i=ga(r.x/e),n=ga((r.x+1)/e),s=ya(r.y/e),a=ya((r.y+1)/e);f=function(t,e,i,r,n=0,s){const a=[];if(!t.length||!i||!r)return a;const l=(t,e)=>{for(const i of t)a.push({polygon:i,bounds:e})},c=Math.ceil(Math.log2(i)),h=Math.ceil(Math.log2(r)),u=c-h,p=[];for(let t=0;t<Math.abs(u);t++)p.push(u>0?0:1);for(let t=0;t<Math.min(c,h);t++)p.push(0),p.push(1);let d=t;if(d=sh(d,e[0].y-n,e[1].y+n,1),d=sh(d,e[0].x-n,e[1].x+n,0),!d.length)return a;const f=[];for(p.length?f.push({polygons:d,bounds:e,depth:0}):l(d,e);f.length;){const t=f.pop(),e=t.depth,i=p[e],r=t.bounds[0],a=t.bounds[1],c=0===i?r.x:r.y,h=0===i?a.x:a.y,u=s?s(i,c,h):.5*(c+h),d=sh(t.polygons,c-n,u+n,i),m=sh(t.polygons,u-n,h+n,i);if(d.length){const t=[r,new o(0===i?u:a.x,1===i?u:a.y)];p.length>e+1?f.push({polygons:d,bounds:t,depth:e+1}):l(d,t)}if(m.length){const t=[new o(0===i?u:r.x,1===i?u:r.y),a];p.length>e+1?f.push({polygons:m,bounds:t,depth:e+1}):l(m,t)}}return a}(p,l,Math.ceil((n-i)/t),Math.ceil((s-a)/t),1,((t,i,n)=>{if(0===t)return.5*(i+n);{const t=ya((r.y+i/la)/e);return(ma(.5*(ya((r.y+n/la)/e)+t))*e-r.y)*la}}))}else{f=[];for(const t of p)f.push({polygon:t,bounds:l})}for(const e of f){const i=e.polygon;let n=0,s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(let t=0;t<i.length;t++){const o=i[t];if(0===o.length)continue;n+=o.length;let a=0;u&&u.startRing(o[0]);for(let t=0;t<o.length;t++){const i=o[t];if(t>=1){const n=o[t-1];if(!ph(i,n,e.bounds)){u&&u.append(i,n),s.vertexLength+4>aa.MAX_VERTEX_ARRAY_LENGTH&&(s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const t=i.sub(n)._perp(),e=t.x/(Math.abs(t.x)+Math.abs(t.y)),o=t.y>0?1:0,l=n.dist(i);a+l>32768&&(a=0),lh(this.layoutVertexArray,i.x,i.y,e,o,0,0,a),lh(this.layoutVertexArray,i.x,i.y,e,o,0,1,a),a+=l,lh(this.layoutVertexArray,n.x,n.y,e,o,0,0,a),lh(this.layoutVertexArray,n.x,n.y,e,o,0,1,a);const p=s.vertexLength;if(this.indexArray.emplaceBack(p,p+2,p+1),this.indexArray.emplaceBack(p+1,p+2,p+3),s.vertexLength+=4,s.primitiveLength+=2,h){const t=this.layoutVertexExtArray,e=c.projectTilePoint(i.x,i.y,r),s=c.projectTilePoint(n.x,n.y,r),o=c.upVector(r,i.x,i.y),a=c.upVector(r,n.x,n.y);ch(t,e,o),ch(t,e,o),ch(t,s,a),ch(t,s,a)}}}}}if(s.vertexLength+n>aa.MAX_VERTEX_ARRAY_LENGTH&&(s=this.segments.prepareSegment(n,this.layoutVertexArray,this.indexArray)),"Polygon"!==oh[t.type])continue;const o=[],a=[],l=s.vertexLength;for(let t=0;t<i.length;t++){const e=i[t];if(0!==e.length){e!==i[0]&&a.push(o.length/2);for(let t=0;t<e.length;t++){const i=e[t];lh(this.layoutVertexArray,i.x,i.y,0,0,1,1,0),o.push(i.x),o.push(i.y),u&&u.currentPolyCount.top++,h&&ch(this.layoutVertexExtArray,c.projectTilePoint(i.x,i.y,r),c.upVector(r,i.x,i.y))}}}const p=ac(o,a);for(let t=0;t<p.length;t+=3)this.indexArray.emplaceBack(l+p[t],l+p[t+2],l+p[t+1]);s.primitiveLength+=p.length/3,s.vertexLength+=n}if(u&&u.polyCount.length>0){if(u.borders){u.vertexArrayOffset=this.centroidVertexArray.length;const t=u.borders,e=this.featuresOnBorder.push(u)-1;for(let i=0;i<4;i++)t[i][0]!==Number.MAX_VALUE&&this.borders[i].push(e)}this.encodeCentroid(u.borders?void 0:u.centroid(),u)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,n,s,r)}sortBorders(){for(let t=0;t<4;t++)this.borders[t].sort(((e,i)=>this.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[i].borders[t][0]))}encodeCentroid(t,e,i=!0){let r,n;if(t)if(0!==t.y){const i=e.span()._mult(this.tileToMeter);r=(Math.max(t.x,1)<<3)+Math.min(7,Math.round(i.x/10)),n=(Math.max(t.y,1)<<3)+Math.min(7,Math.round(i.y/10))}else r=Math.ceil(7*(t.x+450)),n=0;else r=0,n=+i;let s=i?this.centroidVertexArray.length:e.vertexArrayOffset;for(const t of e.polyCount){i&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*t.edges+t.top);for(let e=0;e<2*t.edges;e++)this.centroidVertexArray.emplace(s++,0,n),this.centroidVertexArray.emplace(s++,r,n);for(let e=0;e<t.top;e++)this.centroidVertexArray.emplace(s++,r,n)}}}function ph(t,e,i){return t.x===e.x&&(t.x<i[0].x||t.x>i[1].x)||t.y===e.y&&(t.y<i[0].y||t.y>i[1].y)}Fn(uh,{omit:["layers","features"]}),Fn(hh);var dh={paint:new Is({"fill-extrusion-opacity":new vs(ue["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new bs(ue["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new vs(ue["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new vs(ue["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new ws(ue["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new bs(ue["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new bs(ue["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new vs(ue["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function fh(t,e){return t.x*e.x+t.y*e.y}function mh(t,e){if(1===t.length){let i=0;const r=e[i++];let n;for(;!n||r.equals(n);)if(n=e[i++],!n)return 1/0;for(;i<e.length;i++){const s=e[i],o=t[0],a=n.sub(r),l=s.sub(r),c=o.sub(r),h=fh(a,a),u=fh(a,l),p=fh(l,l),d=fh(c,a),f=fh(c,l),m=h*p-u*u,_=(p*d-u*f)/m,g=(h*f-u*d)/m,y=r.z*(1-_-g)+n.z*_+s.z*g;if(isFinite(y))return y}return 1/0}{let t=1/0;for(const i of e)t=Math.min(t,i.z);return t}}function _h(t){const e=new o(t[0],t[1]);return e.z=t[2],e}function gh(t,e,i,r,n,s,o,a){const l=o*n.getElevationAt(t,e,!0,!0),c=0!==s[0],h=c?0===s[1]?o*(s[0]/7-450):o*function(t,e,i){const r=Math.floor(e[0]/8),n=Math.floor(e[1]/8),s=10*(e[0]-8*r),o=10*(e[1]-8*n),a=t.getElevationAt(r,n,!0,!0),l=t.getMeterToDEM(i),c=Math.floor(.5*(s*l-1)),h=Math.floor(.5*(o*l-1)),u=t.tileCoordToPixel(r,n),p=2*c+1,d=2*h+1,f=function(t,e,i,r,n){return[t.getElevationAtPixel(e,i,!0),t.getElevationAtPixel(e+n,i,!0),t.getElevationAtPixel(e,i+n,!0),t.getElevationAtPixel(e+r,i+n,!0)]}(t,u.x-c,u.y-h,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 a+Math.max(y*s,x*o)}(n,s,a):l;return{base:l+(0===i)?-1:i,top:c?Math.max(h+r,l+i+2):l+r}}const yh=Ms([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:xh}=yh,vh=Ms([{name:"a_packed",components:3,type:"Float32"}]),{members:bh}=vh,wh=nh.VectorTileFeature.types,Th=Math.cos(Math.PI/180*37.5);class Eh{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new Ls,this.layoutVertexArray2=new Rs,this.indexArray=new $s,this.programConfigurations=new Yo(t.layers,t.zoom),this.segments=new aa,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i,r){this.hasPattern=Uc("line",this.layers,e);const n=this.layers[0].layout.get("line-sort-key"),s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=za(e,t);if(!this.layers[0]._featureFilter.filter(new us(this.zoom),c,i))continue;const h=n?n.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Aa(e,i,r),patterns:{},sortKey:h};s.push(u)}n&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:o,featureIndex:a}=e,l=this.addConstantDashes(o);for(const r of s){const{geometry:n,index:s,sourceLayerIndex:c}=r;if(l&&this.addFeatureDashes(r,o),this.hasPattern){const t=Nc("line",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,n,s,i,o.positions,e.availableImages);a.insert(t[s].feature,n,s,c,this.index)}}addConstantDashes(t){let e=!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)e=!0;else{const e=n.value,i=r.value;if(!i)continue;t.addDash(i.from,e),t.addDash(i.to,e),i.other&&t.addDash(i.other,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const r of this.layers){const n=r.paint.get("line-dasharray").value,s=r.layout.get("line-cap").value;if("constant"===n.kind&&"constant"===s.kind)continue;let o,a,l,c,h,u;if("constant"===n.kind){const t=n.value;if(!t)continue;o=t.other||t.to,a=t.to,l=t.from}else o=n.evaluate({zoom:i-1},t),a=n.evaluate({zoom:i},t),l=n.evaluate({zoom:i+1},t);"constant"===s.kind?c=h=u=s.value:(c=s.evaluate({zoom:i-1},t),h=s.evaluate({zoom:i},t),u=s.evaluate({zoom:i+1},t)),e.addDash(o,c),e.addDash(a,h),e.addDash(l,u);const p=e.getKey(o,c),d=e.getKey(a,h),f=e.getKey(l,u);t.patterns[r.id]={min:p,mid:d,max:f}}}update(t,e,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i,r)}addFeatures(t,e,i,r,n){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,bh)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,xh),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,r,n,s){const o=this.layers[0].layout,a=o.get("line-join").evaluate(t,{}),l=o.get("line-cap").evaluate(t,{}),c=o.get("line-miter-limit"),h=o.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,a,l,c,h);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,n,s,r)}addLine(t,e,i,r,n,s){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e<t.length-1;e++)this.totalDistance+=t[e].dist(t[e+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const o="Polygon"===wh[e.type];let a=t.length;for(;a>=2&&t[a-1].equals(t[a-2]);)a--;let l=0;for(;l<a-1&&t[l].equals(t[l+1]);)l++;if(a<(o?3:2))return;"bevel"===i&&(n=1.05);const c=this.overscaling<=16?122880/(512*this.overscaling):0,h=this.segments.prepareSegment(10*a,this.layoutVertexArray,this.indexArray);let u,p,d,f,m;this.e1=this.e2=-1,o&&(u=t[a-2],m=t[l].sub(u)._unit()._perp());for(let e=l;e<a;e++){if(d=e===a-1?o?t[l+1]:void 0:t[e+1],d&&t[e].equals(d))continue;m&&(f=m),u&&(p=u),u=t[e],m=d?d.sub(u)._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<Th&&p&&d,w=f.x*m.y-f.y*m.x>0;if(b&&e>l){const t=u.dist(p);if(t>2*c){const e=u.sub(u.sub(p)._mult(c/t)._round());this.updateDistance(p,e),this.addCurrentVertex(e,f,0,0,h),p=e}}const T=p&&d;let E=T?i:o?"butt":r;if(T&&"round"===E&&(x<s?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,u),"miter"===E)_._mult(x),this.addCurrentVertex(u,_,0,0,h);else if("flipbevel"===E){if(x>100)_=m.mult(-1);else{const t=x*f.add(m).mag()/f.sub(m).mag();_._perp()._mult(t*(w?-1:1))}this.addCurrentVertex(u,_,0,0,h),this.addCurrentVertex(u,_.mult(-1),0,0,h)}else if("bevel"===E||"fakeround"===E){const t=-Math.sqrt(x*x-1),e=w?t:0,i=w?0:t;if(p&&this.addCurrentVertex(u,f,e,i,h),"fakeround"===E){const t=Math.round(180*v/Math.PI/20);for(let e=1;e<t;e++){let i=e/t;if(.5!==i){const t=i-.5;i+=i*t*(i-1)*((1.0904+g*(g*(3.55645-1.43519*g)-3.2452))*t*t+(.848013+g*(.215638*g-1.06021)))}const r=m.sub(f)._mult(i)._add(f)._unit()._mult(w?-1:1);this.addHalfVertex(u,r.x,r.y,!1,w,0,h)}}d&&this.addCurrentVertex(u,m,-e,-i,h)}else if("butt"===E)this.addCurrentVertex(u,_,0,0,h);else if("square"===E){const t=p?1:-1;p||this.addCurrentVertex(u,_,t,t,h),this.addCurrentVertex(u,_,0,0,h),p&&this.addCurrentVertex(u,_,t,t,h)}else"round"===E&&(p&&(this.addCurrentVertex(u,f,0,0,h),this.addCurrentVertex(u,f,1,1,h,!0)),d&&(this.addCurrentVertex(u,m,-1,-1,h,!0),this.addCurrentVertex(u,m,0,0,h)));if(b&&e<a-1){const t=u.dist(d);if(t>2*c){const e=u.add(d.sub(u)._mult(c/t)._round());this.updateDistance(u,e),this.addCurrentVertex(e,m,0,0,h),u=e}}}}addCurrentVertex(t,e,i,r,n,s=!1){const o=e.y*r-e.x,a=-e.y-e.x*r;this.addHalfVertex(t,e.x+e.y*i,e.y-e.x*i,s,!1,i,n),this.addHalfVertex(t,o,a,s,!0,-r,n)}addHalfVertex({x:t,y:e},i,r,n,s,o,a){this.layoutVertexArray.emplaceBack((t<<1)+(n?1:0),(e<<1)+(s?1:0),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===o?0:o<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const l=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,l),a.primitiveLength++),s?this.e2=l:this.e1=l}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}Fn(Eh,{omit:["layers","patternFeatures"]});const Ih=new Is({"line-cap":new bs(ue.layout_line["line-cap"]),"line-join":new bs(ue.layout_line["line-join"]),"line-miter-limit":new vs(ue.layout_line["line-miter-limit"]),"line-round-limit":new vs(ue.layout_line["line-round-limit"]),"line-sort-key":new bs(ue.layout_line["line-sort-key"])});var Sh={paint:new Is({"line-opacity":new bs(ue.paint_line["line-opacity"]),"line-color":new bs(ue.paint_line["line-color"]),"line-translate":new vs(ue.paint_line["line-translate"]),"line-translate-anchor":new vs(ue.paint_line["line-translate-anchor"]),"line-width":new bs(ue.paint_line["line-width"]),"line-gap-width":new bs(ue.paint_line["line-gap-width"]),"line-offset":new bs(ue.paint_line["line-offset"]),"line-blur":new bs(ue.paint_line["line-blur"]),"line-dasharray":new ws(ue.paint_line["line-dasharray"]),"line-pattern":new ws(ue.paint_line["line-pattern"]),"line-gradient":new Es(ue.paint_line["line-gradient"])}),layout:Ih};const Ah=new class extends bs{possiblyEvaluate(t,e){return e=new us(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,r){return e=I({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,r)}}(Sh.paint.properties["line-width"].specification);function zh(t,e){return e>0?e+2*t:t}Ah.useIntegerZoom=!0;const Ch=Ms([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"},{name:"a_z_tile_anchor",components:4,type:"Int16"}],4),Mh=Ms([{name:"a_projected_pos",components:3,type:"Float32"}],4);Ms([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const kh=Ms([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),Ph=Ms([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);Ms([{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 Dh=Ms([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Bh=Ms([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Ms([{name:"triangle",components:3,type:"Uint16"}]),Ms([{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"}]),Ms([{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"}]),Ms([{type:"Float32",name:"offsetX"}]),Ms([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);const Lh=128;function Rh(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new us(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:r}=i;let n=0;for(;n<e.length&&e[n]<=t;)n++;n=Math.max(0,n-1);let s=n;for(;s<e.length&&e[s]<t+1;)s++;s=Math.min(e.length-1,s);const o=e[n],a=e[s];return"composite"===i.kind?{kind:"composite",minZoom:o,maxZoom:a,interpolationType:r}:{kind:"camera",minZoom:o,maxZoom:a,minSize:i.evaluate(new us(o)),maxSize:i.evaluate(new us(a)),interpolationType:r}}}function Fh(t,{uSize:e,uSizeT:i},{lowerSize:r,upperSize:n}){return"source"===t.kind?r/Lh:"composite"===t.kind?Ai(r/Lh,n/Lh,i):e}function Oh(t,e){let i=0,r=0;if("constant"===t.kind)r=t.layoutSize;else if("source"!==t.kind){const{interpolationType:n,minZoom:s,maxZoom:o}=t,a=n?v($i.interpolationFactor(n,e,s,o),0,1):0;"camera"===t.kind?r=Ai(t.minSize,t.maxSize,a):i=a}return{uSizeT:i,uSize:r}}var Vh=Object.freeze({__proto__:null,getSizeData:Rh,evaluateSizeForFeature:Fh,evaluateSizeForZoom:Oh,SIZE_PACK_FACTOR:Lh});function jh(t,e,i){return t.sections.forEach((t=>{t.text=function(t,e,i){const r=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?t=t.toLocaleUpperCase():"lowercase"===r&&(t=t.toLocaleLowerCase()),hs.applyArabicShaping&&(t=hs.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Uh={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var Nh=function(t,e,i,r,n){var s,o,a=8*n-r-1,l=(1<<a)-1,c=l>>1,h=-7,u=i?n-1:0,p=i?-1:1,d=t[e+u];for(u+=p,s=d&(1<<-h)-1,d>>=-h,h+=a;h>0;s=256*s+t[e+u],u+=p,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=r;h>0;o=256*o+t[e+u],u+=p,h-=8);if(0===s)s=1-c;else{if(s===l)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,r),s-=c}return(d?-1:1)*o*Math.pow(2,s-r)},Zh=function(t,e,i,r,n,s){var o,a,l,c=8*s-n-1,h=(1<<c)-1,u=h>>1,p=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:s-1,f=r?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=h):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+u>=1?p/l:p*Math.pow(2,1-u))*l>=2&&(o++,l/=2),o+u>=h?(a=0,o=h):o+u>=1?(a=(e*l-1)*Math.pow(2,n),o+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,n),o=0));n>=8;t[i+d]=255&a,d+=f,a/=256,n-=8);for(o=o<<n|a,c+=n;c>0;t[i+d]=255&o,d+=f,o/=256,c-=8);t[i+d-f]|=128*m},qh=Gh;function Gh(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}Gh.Varint=0,Gh.Fixed64=1,Gh.Bytes=2,Gh.Fixed32=5;var $h=4294967296,Wh=1/$h,Xh="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function Hh(t){return t.type===Gh.Bytes?t.readVarint()+t.pos:t.pos+1}function Kh(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function Yh(t,e,i){var r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(r);for(var n=i.pos-1;n>=t;n--)i.buf[n+r]=i.buf[n]}function Jh(t,e){for(var i=0;i<t.length;i++)e.writeVarint(t[i])}function Qh(t,e){for(var i=0;i<t.length;i++)e.writeSVarint(t[i])}function tu(t,e){for(var i=0;i<t.length;i++)e.writeFloat(t[i])}function eu(t,e){for(var i=0;i<t.length;i++)e.writeDouble(t[i])}function iu(t,e){for(var i=0;i<t.length;i++)e.writeBoolean(t[i])}function ru(t,e){for(var i=0;i<t.length;i++)e.writeFixed32(t[i])}function nu(t,e){for(var i=0;i<t.length;i++)e.writeSFixed32(t[i])}function su(t,e){for(var i=0;i<t.length;i++)e.writeFixed64(t[i])}function ou(t,e){for(var i=0;i<t.length;i++)e.writeSFixed64(t[i])}function au(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function lu(t,e,i){t[i]=e,t[i+1]=e>>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function cu(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function hu(t,e,i){e.glyphs=[],1===t&&i.readMessage(uu,e)}function uu(t,e,i){if(3===t){const{id:t,bitmap:r,width:n,height:s,left:o,top:a,advance:l}=i.readMessage(pu,{});e.glyphs.push({id:t,bitmap:new tc({width:n+6,height:s+6},r),metrics:{width:n,height:s,left:o,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function pu(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}function du(t){let e=0,i=0;for(const r of t)e+=r.w*r.h,i=Math.max(i,r.w);t.sort(((t,e)=>e.h-t.h));const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let n=0,s=0;for(const e of t)for(let t=r.length-1;t>=0;t--){const i=r[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,s=Math.max(s,e.y+e.h),n=Math.max(n,e.x+e.w),e.w===i.w&&e.h===i.h){const e=r.pop();t<r.length&&(r[t]=e)}else e.h===i.h?(i.x+=e.w,i.w-=e.w):e.w===i.w?(i.y+=e.h,i.h-=e.h):(r.push({x:i.x+e.w,y:i.y,w:i.w-e.w,h:e.h}),i.y+=e.h,i.h-=e.h);break}}return{w:n,h:s,fill:e/(n*s)||0}}Gh.prototype={destroy:function(){this.buf=null},readFields:function(t,e,i){for(i=i||this.length;this.pos<i;){var r=this.readVarint(),n=r>>3,s=this.pos;this.type=7&r,t(n,e,this),this.pos===s&&this.skip(r)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=au(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=cu(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=au(this.buf,this.pos)+au(this.buf,this.pos+4)*$h;return this.pos+=8,t},readSFixed64:function(){var t=au(this.buf,this.pos)+cu(this.buf,this.pos+4)*$h;return this.pos+=8,t},readFloat:function(){var t=Nh(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Nh(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,r=this.buf;return e=127&(i=r[this.pos++]),i<128?e:(e|=(127&(i=r[this.pos++]))<<7,i<128?e:(e|=(127&(i=r[this.pos++]))<<14,i<128?e:(e|=(127&(i=r[this.pos++]))<<21,i<128?e:function(t,e,i){var r,n,s=i.buf;if(r=(112&(n=s[i.pos++]))>>4,n<128)return Kh(t,r,e);if(r|=(127&(n=s[i.pos++]))<<3,n<128)return Kh(t,r,e);if(r|=(127&(n=s[i.pos++]))<<10,n<128)return Kh(t,r,e);if(r|=(127&(n=s[i.pos++]))<<17,n<128)return Kh(t,r,e);if(r|=(127&(n=s[i.pos++]))<<24,n<128)return Kh(t,r,e);if(r|=(1&(n=s[i.pos++]))<<31,n<128)return Kh(t,r,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(i=r[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&Xh?function(t,e,i){return Xh.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var r="",n=e;n<i;){var s,o,a,l=t[n],c=null,h=l>239?4:l>223?3:l>191?2:1;if(n+h>i)break;1===h?l<128&&(c=l):2===h?128==(192&(s=t[n+1]))&&(c=(31&l)<<6|63&s)<=127&&(c=null):3===h?(o=t[n+2],128==(192&(s=t[n+1]))&&128==(192&o)&&((c=(15&l)<<12|(63&s)<<6|63&o)<=2047||c>=55296&&c<=57343)&&(c=null)):4===h&&(o=t[n+2],a=t[n+3],128==(192&(s=t[n+1]))&&128==(192&o)&&128==(192&a)&&((c=(15&l)<<18|(63&s)<<12|(63&o)<<6|63&a)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),n+=h}return r}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==Gh.Bytes)return t.push(this.readVarint(e));var i=Hh(this);for(t=t||[];this.pos<i;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==Gh.Bytes)return t.push(this.readSVarint());var e=Hh(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==Gh.Bytes)return t.push(this.readBoolean());var e=Hh(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==Gh.Bytes)return t.push(this.readFloat());var e=Hh(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==Gh.Bytes)return t.push(this.readDouble());var e=Hh(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==Gh.Bytes)return t.push(this.readFixed32());var e=Hh(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==Gh.Bytes)return t.push(this.readSFixed32());var e=Hh(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==Gh.Bytes)return t.push(this.readFixed64());var e=Hh(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==Gh.Bytes)return t.push(this.readSFixed64());var e=Hh(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=7&t;if(e===Gh.Varint)for(;this.buf[this.pos++]>127;);else if(e===Gh.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Gh.Fixed32)this.pos+=4;else{if(e!==Gh.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var i=new Uint8Array(e);i.set(this.buf),this.buf=i,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),lu(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),lu(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),lu(this.buf,-1&t,this.pos),lu(this.buf,Math.floor(t*Wh),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),lu(this.buf,-1&t,this.pos),lu(this.buf,Math.floor(t*Wh),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(t,e){var i,r;if(t>=0?(i=t%4294967296|0,r=t/4294967296|0):(r=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,r=r+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,i){i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)<<4;e.buf[e.pos++]|=i|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(r,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,i){for(var r,n,s=0;s<e.length;s++){if((r=e.charCodeAt(s))>55295&&r<57344){if(!n){r>56319||s+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):n=r;continue}if(r<56320){t[i++]=239,t[i++]=191,t[i++]=189,n=r;continue}r=n-55296<<10|r-56320|65536,n=null}else n&&(t[i++]=239,t[i++]=191,t[i++]=189,n=null);r<128?t[i++]=r:(r<2048?t[i++]=r>>6|192:(r<65536?t[i++]=r>>12|224:(t[i++]=r>>18|240,t[i++]=r>>12&63|128),t[i++]=r>>6&63|128),t[i++]=63&r|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&Yh(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),Zh(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),Zh(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i<e;i++)this.buf[this.pos++]=t[i]},writeRawMessage:function(t,e){this.pos++;var i=this.pos;t(e,this);var r=this.pos-i;r>=128&&Yh(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r},writeMessage:function(t,e,i){this.writeTag(t,Gh.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,Jh,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,Qh,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,iu,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,tu,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,eu,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,ru,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,nu,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,su,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,ou,e)},writeBytesField:function(t,e){this.writeTag(t,Gh.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,Gh.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,Gh.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,Gh.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,Gh.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,Gh.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,Gh.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,Gh.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,Gh.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,Gh.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};class fu{constructor(t,{pixelRatio:e,version:i,stretchX:r,stretchY:n,content:s}){this.paddedRect=t,this.pixelRatio=e,this.stretchX=r,this.stretchY=n,this.content=s,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]}}Fn(fu),Fn(class{constructor(t,e){const i={},r={};this.haveRenderCallbacks=[];const n=[];this.addImages(t,i,n),this.addImages(e,r,n);const{w:s,h:o}=du(n),a=new ec({width:s||1,height:o||1});for(const e in t){const r=t[e],n=i[e].paddedRect;ec.copy(r.data,a,{x:0,y:0},{x:n.x+1,y:n.y+1},r.data)}for(const t in e){const i=e[t],n=r[t].paddedRect,s=n.x+1,o=n.y+1,l=i.data.width,c=i.data.height;ec.copy(i.data,a,{x:0,y:0},{x:s,y:o},i.data),ec.copy(i.data,a,{x:0,y:c-1},{x:s,y:o-1},{width:l,height:1}),ec.copy(i.data,a,{x:0,y:0},{x:s,y:o+c},{width:l,height:1}),ec.copy(i.data,a,{x:l-1,y:0},{x:s-1,y:o},{width:1,height:c}),ec.copy(i.data,a,{x:0,y:0},{x:s+l,y:o},{width:1,height:c})}this.image=a,this.iconPositions=i,this.patternPositions=r}addImages(t,e,i){for(const r in t){const n=t[r],s={x:0,y:0,w:n.data.width+2,h:n.data.height+2};i.push(s),e[r]=new fu(s,n),n.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e){t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const i in t.updatedImages)this.patchUpdatedImage(this.iconPositions[i],t.getImage(i),e),this.patchUpdatedImage(this.patternPositions[i],t.getImage(i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[r,n]=t.tl;i.update(e.data,void 0,{x:r,y:n})}});const mu={horizontal:1,vertical:2,horizontalOnly:3};function _u(t){let e=.5,i=.5;switch(t){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(t){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:e,verticalAlign:i}}class gu extends o{constructor(t,e,i,r,n){super(t,e),this.angle=r,this.z=i,void 0!==n&&(this.segment=n)}clone(){return new gu(this.x,this.y,this.z,this.angle,this.segment)}}Fn(gu);const yu=1e20;function xu(t,e,i,r,n,s,o,a,l){for(let c=e;c<e+r;c++)vu(t,i*s+c,s,n,o,a,l);for(let c=i;c<i+n;c++)vu(t,c*s+e,1,r,o,a,l)}function vu(t,e,i,r,n,s,o){s[0]=0,o[0]=-yu,o[1]=yu,n[0]=t[e];for(let a=1,l=0,c=0;a<r;a++){n[a]=t[e+a*i];const r=a*a;do{const t=s[l];c=(n[a]-n[t]+r-t*t)/(a-t)/2}while(c<=o[l]&&--l>-1);l++,s[l]=a,o[l]=c,o[l+1]=yu}for(let a=0,l=0;a<r;a++){for(;o[l+1]<a;)l++;const r=s[l],c=a-r;t[e+a*i]=n[r]+c*c}}class bu{constructor(t,e,i){this.requestManager=t,this.localGlyphMode=e,this.localFontFamily=i,this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(t){this.url=t}getGlyphs(t,e){const i=[];for(const e in t)for(const r of t[e])i.push({stack:e,id:r});T(i,(({stack:t,id:e},i)=>{let r=this.entries[t];r||(r=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let n=r.glyphs[e];if(void 0!==n)return void i(null,{stack:t,id:e,glyph:n});if(n=this._tinySDF(r,t,e),n)return r.glyphs[e]=n,void i(null,{stack:t,id:e,glyph:n});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(r.ranges[s])return void i(null,{stack:t,id:e,glyph:n});let o=r.requests[s];o||(o=r.requests[s]=[],bu.loadGlyphRange(t,s,this.url,this.requestManager,((t,e)=>{if(e){r.ascender=e.ascender,r.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(r.glyphs[+t]=e.glyphs[+t]);r.ranges[s]=!0}for(const i of o)i(t,e);delete r.requests[s]}))),o.push(((r,n)=>{r?i(r):n&&i(null,{stack:t,id:e,glyph:n.glyphs[e]||null})}))}),((t,i)=>{if(t)e(t);else if(i){const t={};for(const{stack:e,id:r,glyph:n}of i)void 0===t[e]&&(t[e]={}),void 0===t[e].glyphs&&(t[e].glyphs={}),t[e].glyphs[r]=n&&{id:n.id,bitmap:n.bitmap.clone(),metrics:n.metrics},t[e].ascender=this.entries[e].ascender,t[e].descender=this.entries[e].descender;e(null,t)}}))}_doesCharSupportLocalGlyph(t){return 0!==this.localGlyphMode&&(2===this.localGlyphMode?!!this.localFontFamily:!!this.localFontFamily&&($n(t)||Wn(t)||qn(t)||Gn(t)||Zn(t)))}_tinySDF(t,e,i){const r=this.localFontFamily;if(!r||!this._doesCharSupportLocalGlyph(i))return;let n=t.tinySDF;if(!n){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),n=t.tinySDF=new bu.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 s=String.fromCharCode(i),{data:o,width:a,height:l,glyphWidth:c,glyphHeight:h,glyphLeft:u,glyphTop:p,glyphAdvance:d}=n.draw(s);return this.localGlyphs[n.fontWeight][i]={id:i,bitmap:new tc({width:a,height:l},o),metrics:{width:c/2,height:h/2,left:u/2,top:p/2-27,advance:d/2,localGlyph:!0}}}}bu.loadGlyphRange=function(t,e,i,r,n){const s=256*e,o=s+255,a=r.transformRequest(r.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${s}-${o}`),Wt.Glyphs);Jt(a,((t,e)=>{if(t)n(t);else if(e){const t={},i=function(t){return new qh(t).readFields(hu,{})}(e);for(const e of i.glyphs)t[e.id]=e;n(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},bu.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:r=.25,fontFamily:n="sans-serif",fontWeight:s="normal",fontStyle:o="normal"}){this.buffer=e,this.cutoff=r,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${o} ${s} ${t}px ${n}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:n,actualBoundingBoxRight:s}=this.ctx.measureText(t),o=Math.floor(i),a=Math.min(this.size-this.buffer,Math.ceil(s-n)),l=Math.min(this.size-this.buffer,Math.ceil(i)+Math.ceil(r)),c=a+2*this.buffer,h=l+2*this.buffer,u=c*h,p=new Uint8ClampedArray(u),d={data:p,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:o,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return d;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+o+1);const y=f.getImageData(m,m,a,l);g.fill(yu,0,u),_.fill(0,0,u);for(let t=0;t<l;t++)for(let e=0;e<a;e++){const i=y.data[4*(t*a+e)+3]/255;if(0===i)continue;const r=(t+m)*c+e+m;if(1===i)g[r]=0,_[r]=yu;else{const t=.5-i;g[r]=t>0?t*t:0,_[r]=t<0?t*t:0}}xu(g,0,0,c,h,c,this.f,this.v,this.z),xu(_,m,m,a,l,c,this.f,this.v,this.z);for(let t=0;t<u;t++){const e=Math.sqrt(g[t])-Math.sqrt(_[t]);p[t]=Math.round(255-255*(e/this.radius+this.cutoff))}return d}};const wu=Number.POSITIVE_INFINITY,Tu=Math.sqrt(2);function Eu(t,e){return e[1]!==wu?function(t,e,i){let r=0,n=0;switch(e=Math.abs(e),i=Math.abs(i),t){case"top-right":case"top-left":case"top":n=i-7;break;case"bottom-right":case"bottom-left":case"bottom":n=7-i}switch(t){case"top-right":case"bottom-right":case"right":r=-e;break;case"top-left":case"bottom-left":case"left":r=e}return[r,n]}(t,e[0],e[1]):function(t,e){let i=0,r=0;e<0&&(e=0);const n=e/Tu;switch(t){case"top-right":case"top-left":r=n-7;break;case"bottom-right":case"bottom-left":r=7-n;break;case"bottom":r=7-e;break;case"top":r=e-7}switch(t){case"top-right":case"bottom-right":i=-n;break;case"top-left":case"bottom-left":i=n;break;case"left":i=e;break;case"right":i=-e}return[i,r]}(t,e[0])}const Iu=nh.VectorTileFeature.types,Su=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Au(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m){const _=h?Math.min(32640,Math.round(h[0])):0,g=h?Math.min(32640,Math.round(h[1])):0;t.emplaceBack(e,i,Math.round(32*o),Math.round(32*a),l,c,(_<<1)+(u?1:0),g,16*p,16*d,256*f,256*m,r,n,s,0)}function zu(t,e,i){t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i)}function Cu(t){for(const e of t.sections)if(Jn(e.text))return!0;return!1}class Mu{constructor(t){this.layoutVertexArray=new js,this.indexArray=new $s,this.programConfigurations=t,this.segments=new aa,this.dynamicLayoutVertexArray=new Rs,this.opacityVertexArray=new Us,this.placedSymbolArray=new co}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(t,e,i,r){this.isEmpty()||(i&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ch.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,Mh.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,Su,!0),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}Fn(Mu);class ku{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new aa,this.collisionVertexArray=new Gs,this.collisionVertexArrayExt=new Rs}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,kh.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Ph.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}Fn(ku);class Pu{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=rl([]),this.placementViewportMatrix=rl([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Rh(this.zoom,e["text-size"]),this.iconSizeData=Rh(this.zoom,e["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((t=>mu[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection}createArrays(){this.text=new Mu(new Yo(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new Mu(new Yo(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new po,this.lineVertexArray=new fo,this.symbolInstances=new uo}calculateGlyphDependencies(t,e,i,r,n){for(let i=0;i<t.length;i++)if(e[t.charCodeAt(i)]=!0,r&&n){const r=Uh[t.charAt(i)];r&&(e[r.charCodeAt(0)]=!0)}}populate(t,e,i,r){const n=this.layers[0],s=n.layout,o=s.get("text-font"),a=s.get("text-field"),l=s.get("icon-image"),c=("constant"!==a.value.kind||a.value.value instanceof Oe&&!a.value.value.isEmpty()||a.value.value.toString().length>0)&&("constant"!==o.value.kind||o.value.value.length>0),h="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,u=s.get("symbol-sort-key");if(this.features=[],!c&&!h)return;const p=e.iconDependencies,d=e.glyphDependencies,f=e.availableImages,m=new us(this.zoom);for(const{feature:e,id:a,index:l,sourceLayerIndex:_}of t){const t=n._featureFilter.needGeometry,g=za(e,t);if(!n._featureFilter.filter(m,g,i))continue;let y,x;if(t||(g.geometry=Aa(e,i,r)),c){const t=n.getValueAndResolveTokens("text-field",g,i,f),e=Oe.factory(t);Cu(e)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===ls()||this.hasRTLText&&hs.isParsed())&&(y=jh(e,n,g))}if(h){const t=n.getValueAndResolveTokens("icon-image",g,i,f);x=t instanceof Ve?t:Ve.fromString(t)}if(!y&&!x)continue;const v=this.sortFeaturesByKey?u.evaluate(g,{},i):void 0;if(this.features.push({id:a,text:y,icon:x,index:l,sourceLayerIndex:_,geometry:g.geometry,properties:e.properties,type:Iu[e.type],sortKey:v}),x&&(p[x.name]=!0),y){const t=o.evaluate(g,{},i).join(","),e="map"===s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(mu.vertical)>=0;for(const i of y.sections)if(i.image)p[i.image.name]=!0;else{const r=Xn(y.toString()),n=i.fontStack||t,s=d[n]=d[n]||{};this.calculateGlyphDependencies(i.text,s,e,this.allowVerticalPlacement,r)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},i={},r=[];let n=0;function s(e){r.push(t[e]),n++}function o(t,e,n){const s=i[t];return delete i[t],i[e]=s,r[s].geometry[0].pop(),r[s].geometry[0]=r[s].geometry[0].concat(n[0]),s}function a(t,i,n){const s=e[i];return delete e[i],e[t]=s,r[s].geometry[0].shift(),r[s].geometry[0]=n[0].concat(r[s].geometry[0]),s}function l(t,e,i){const r=i?e[0][e[0].length-1]:e[0][0];return`${t}:${r.x}:${r.y}`}for(let c=0;c<t.length;c++){const h=t[c],u=h.geometry,p=h.text?h.text.toString():null;if(!p){s(c);continue}const d=l(p,u),f=l(p,u,!0);if(d in i&&f in e&&i[d]!==e[f]){const t=a(d,f,u),n=o(d,f,r[t].geometry);delete e[d],delete i[f],i[l(p,r[n].geometry,!0)]=n,r[t].geometry=null}else d in i?o(d,f,u):f in e?a(d,f,u):(s(c),e[d]=n-1,i[f]=n-1)}return r.filter((t=>t.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,i,r),this.icon.programConfigurations.updatePaintArrays(t,e,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(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length,r=t.segment;if(void 0!==r){let i=t.dist(e[r+1]),n=t.dist(e[r]);const s={};for(let t=r+1;t<e.length;t++)s[t]={x:e[t].x,y:e[t].y,tileUnitDistanceFromAnchor:i},t<e.length-1&&(i+=e[t+1].dist(e[t]));for(let t=r||0;t>=0;t--)s[t]={x:e[t].x,y:e[t].y,tileUnitDistanceFromAnchor:n},t>0&&(n+=e[t-1].dist(e[t]));for(let t=0;t<e.length;t++){const e=s[t];this.lineVertexArray.emplaceBack(e.x,e.y,e.tileUnitDistanceFromAnchor)}}return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,r,n,s,o,a,l,c,h,u,p,d){const f=t.indexArray,m=t.layoutVertexArray,_=t.segments.prepareSegment(4*e.length,m,f,this.canOverlap?s.sortKey:void 0),g=this.glyphOffsetArray.length,y=_.vertexLength,x=this.allowVerticalPlacement&&o===mu.vertical?Math.PI/2:0,v=s.text&&s.text.sections;for(let r=0;r<e.length;r++){const{tl:n,tr:o,bl:c,br:h,tex:u,pixelOffsetTL:g,pixelOffsetBR:y,minFontScaleX:b,minFontScaleY:w,glyphOffset:T,isSDF:E,sectionIndex:I}=e[r],S=_.vertexLength,A=T[1];Au(m,a.x,a.y,a.z,l.x,l.y,n.x,A+n.y,u.x,u.y,i,E,g.x,g.y,b,w),Au(m,a.x,a.y,a.z,l.x,l.y,o.x,A+o.y,u.x+u.w,u.y,i,E,y.x,g.y,b,w),Au(m,a.x,a.y,a.z,l.x,l.y,c.x,A+c.y,u.x,u.y+u.h,i,E,g.x,y.y,b,w),Au(m,a.x,a.y,a.z,l.x,l.y,h.x,A+h.y,u.x+u.w,u.y+u.h,i,E,y.x,y.y,b,w),zu(t.dynamicLayoutVertexArray,a,x),f.emplaceBack(S,S+1,S+2),f.emplaceBack(S+1,S+2,S+3),_.vertexLength+=4,_.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(T[0]),r!==e.length-1&&I===e[r+1].sectionIndex||t.programConfigurations.populatePaintArrays(m.length,s,s.index,{},p,d,v&&v[I])}t.placedSymbolArray.emplaceBack(a.x,a.y,a.z,l.x,l.y,g,this.glyphOffsetArray.length-g,y,c,h,l.segment,i?i[0]:0,i?i[1]:0,r[0],r[1],o,0,!1,0,u,0)}_commitLayoutVertex(t,e,i,r,n,s,o){t.emplaceBack(e,i,r,n,s,Math.round(o.x),Math.round(o.y))}_addCollisionDebugVertices(t,e,i,r,n,s,a){const l=i.segments.prepareSegment(4,i.layoutVertexArray,i.indexArray),c=l.vertexLength,h=a.tileAnchorX,u=a.tileAnchorY;for(let t=0;t<4;t++)i.collisionVertexArray.emplaceBack(0,0,0,0);i.collisionVertexArrayExt.emplaceBack(e,-t.padding,-t.padding),i.collisionVertexArrayExt.emplaceBack(e,t.padding,-t.padding),i.collisionVertexArrayExt.emplaceBack(e,t.padding,t.padding),i.collisionVertexArrayExt.emplaceBack(e,-t.padding,t.padding),this._commitLayoutVertex(i.layoutVertexArray,r,n,s,h,u,new o(t.x1,t.y1)),this._commitLayoutVertex(i.layoutVertexArray,r,n,s,h,u,new o(t.x2,t.y1)),this._commitLayoutVertex(i.layoutVertexArray,r,n,s,h,u,new o(t.x2,t.y2)),this._commitLayoutVertex(i.layoutVertexArray,r,n,s,h,u,new o(t.x1,t.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(t,e,i,r,n,s){for(let o=r;o<n;o++){const r=i.get(o),n=this.getSymbolInstanceTextSize(t,s,e,o);this._addCollisionDebugVertices(r,n,this.textCollisionBox,r.projectedAnchorX,r.projectedAnchorY,r.projectedAnchorZ,s)}}_addIconDebugCollisionBoxes(t,e,i,r,n,s){for(let o=r;o<n;o++){const r=i.get(o),n=this.getSymbolInstanceIconSize(t,e,o);this._addCollisionDebugVertices(r,n,this.iconCollisionBox,r.projectedAnchorX,r.projectedAnchorY,r.projectedAnchorZ,s)}}generateCollisionDebugBuffers(t,e){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new ku(Zs,Dh.members,Qs),this.iconCollisionBox=new ku(Zs,Dh.members,Qs);const i=Oh(this.iconSizeData,t),r=Oh(this.textSizeData,t);for(let n=0;n<this.symbolInstances.length;n++){const s=this.symbolInstances.get(n);this._addTextDebugCollisionBoxes(r,t,e,s.textBoxStartIndex,s.textBoxEndIndex,s),this._addTextDebugCollisionBoxes(r,t,e,s.verticalTextBoxStartIndex,s.verticalTextBoxEndIndex,s),this._addIconDebugCollisionBoxes(i,t,e,s.iconBoxStartIndex,s.iconBoxEndIndex,s),this._addIconDebugCollisionBoxes(i,t,e,s.verticalIconBoxStartIndex,s.verticalIconBoxEndIndex,s)}}getSymbolInstanceTextSize(t,e,i,r){const n=this.text.placedSymbolArray.get(e.rightJustifiedTextSymbolIndex>=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:r),s=Fh(this.textSizeData,t,n)/24;return this.tilePixelRatio*s}getSymbolInstanceIconSize(t,e,i){const r=this.icon.placedSymbolArray.get(i),n=Fh(this.iconSizeData,t,r);return this.tilePixelRatio*n}_commitDebugCollisionVertexUpdate(t,e,i){t.emplaceBack(e,-i,-i),t.emplaceBack(e,i,-i),t.emplaceBack(e,i,i),t.emplaceBack(e,-i,i)}_updateTextDebugCollisionBoxes(t,e,i,r,n,s){for(let o=r;o<n;o++){const r=i.get(o),n=this.getSymbolInstanceTextSize(t,s,e,o);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,n,r.padding)}}_updateIconDebugCollisionBoxes(t,e,i,r,n){for(let s=r;s<n;s++){const r=i.get(s),n=this.getSymbolInstanceIconSize(t,e,s);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,n,r.padding)}}updateCollisionDebugBuffers(t,e){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const i=Oh(this.iconSizeData,t),r=Oh(this.textSizeData,t);for(let n=0;n<this.symbolInstances.length;n++){const s=this.symbolInstances.get(n);this._updateTextDebugCollisionBoxes(r,t,e,s.textBoxStartIndex,s.textBoxEndIndex,s),this._updateTextDebugCollisionBoxes(r,t,e,s.verticalTextBoxStartIndex,s.verticalTextBoxEndIndex,s),this._updateIconDebugCollisionBoxes(i,t,e,s.iconBoxStartIndex,s.iconBoxEndIndex),this._updateIconDebugCollisionBoxes(i,t,e,s.verticalIconBoxStartIndex,s.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(t,e,i,r,n,s,o,a,l){const c={};for(let r=e;r<i;r++){const e=t.get(r);c.textBox={x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,padding:e.padding,projectedAnchorX:e.projectedAnchorX,projectedAnchorY:e.projectedAnchorY,projectedAnchorZ:e.projectedAnchorZ,tileAnchorX:e.tileAnchorX,tileAnchorY:e.tileAnchorY},c.textFeatureIndex=e.featureIndex;break}for(let e=r;e<n;e++){const i=t.get(e);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 e=s;e<o;e++){const i=t.get(e);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 e=a;e<l;e++){const i=t.get(e);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(t){this.collisionArrays=[];for(let e=0;e<this.symbolInstances.length;e++){const i=this.symbolInstances.get(e);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,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(t,e){const i=t.placedSymbolArray.get(e),r=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;e<r;e+=4)t.indexArray.emplaceBack(e,e+1,e+2),t.indexArray.emplaceBack(e+1,e+2,e+3)}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const e=Math.sin(t),i=Math.cos(t),r=[],n=[],s=[];for(let t=0;t<this.symbolInstances.length;++t){s.push(t);const o=this.symbolInstances.get(t);r.push(0|Math.round(e*o.tileAnchorX+i*o.tileAnchorY)),n.push(o.featureIndex)}return s.sort(((t,e)=>r[t]-r[e]||n[e]-n[t])),s}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,i)=>{t>=0&&i.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t)})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Fn(Pu,{omit:["layers","collisionBoxArray","features","compareText"]}),Pu.MAX_GLYPHS=65535,Pu.addDynamicAttributes=zu;const Du=new Is({"symbol-placement":new vs(ue.layout_symbol["symbol-placement"]),"symbol-spacing":new vs(ue.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new vs(ue.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new bs(ue.layout_symbol["symbol-sort-key"]),"symbol-z-order":new vs(ue.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new vs(ue.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new vs(ue.layout_symbol["icon-ignore-placement"]),"icon-optional":new vs(ue.layout_symbol["icon-optional"]),"icon-rotation-alignment":new vs(ue.layout_symbol["icon-rotation-alignment"]),"icon-size":new bs(ue.layout_symbol["icon-size"]),"icon-text-fit":new vs(ue.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new vs(ue.layout_symbol["icon-text-fit-padding"]),"icon-image":new bs(ue.layout_symbol["icon-image"]),"icon-rotate":new bs(ue.layout_symbol["icon-rotate"]),"icon-padding":new vs(ue.layout_symbol["icon-padding"]),"icon-keep-upright":new vs(ue.layout_symbol["icon-keep-upright"]),"icon-offset":new bs(ue.layout_symbol["icon-offset"]),"icon-anchor":new bs(ue.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new vs(ue.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new vs(ue.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new vs(ue.layout_symbol["text-rotation-alignment"]),"text-field":new bs(ue.layout_symbol["text-field"]),"text-font":new bs(ue.layout_symbol["text-font"]),"text-size":new bs(ue.layout_symbol["text-size"]),"text-max-width":new bs(ue.layout_symbol["text-max-width"]),"text-line-height":new bs(ue.layout_symbol["text-line-height"]),"text-letter-spacing":new bs(ue.layout_symbol["text-letter-spacing"]),"text-justify":new bs(ue.layout_symbol["text-justify"]),"text-radial-offset":new bs(ue.layout_symbol["text-radial-offset"]),"text-variable-anchor":new vs(ue.layout_symbol["text-variable-anchor"]),"text-anchor":new bs(ue.layout_symbol["text-anchor"]),"text-max-angle":new vs(ue.layout_symbol["text-max-angle"]),"text-writing-mode":new vs(ue.layout_symbol["text-writing-mode"]),"text-rotate":new bs(ue.layout_symbol["text-rotate"]),"text-padding":new vs(ue.layout_symbol["text-padding"]),"text-keep-upright":new vs(ue.layout_symbol["text-keep-upright"]),"text-transform":new bs(ue.layout_symbol["text-transform"]),"text-offset":new bs(ue.layout_symbol["text-offset"]),"text-allow-overlap":new vs(ue.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new vs(ue.layout_symbol["text-ignore-placement"]),"text-optional":new vs(ue.layout_symbol["text-optional"])});var Bu={paint:new Is({"icon-opacity":new bs(ue.paint_symbol["icon-opacity"]),"icon-color":new bs(ue.paint_symbol["icon-color"]),"icon-halo-color":new bs(ue.paint_symbol["icon-halo-color"]),"icon-halo-width":new bs(ue.paint_symbol["icon-halo-width"]),"icon-halo-blur":new bs(ue.paint_symbol["icon-halo-blur"]),"icon-translate":new vs(ue.paint_symbol["icon-translate"]),"icon-translate-anchor":new vs(ue.paint_symbol["icon-translate-anchor"]),"text-opacity":new bs(ue.paint_symbol["text-opacity"]),"text-color":new bs(ue.paint_symbol["text-color"],{runtimeType:be,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new bs(ue.paint_symbol["text-halo-color"]),"text-halo-width":new bs(ue.paint_symbol["text-halo-width"]),"text-halo-blur":new bs(ue.paint_symbol["text-halo-blur"]),"text-translate":new vs(ue.paint_symbol["text-translate"]),"text-translate-anchor":new vs(ue.paint_symbol["text-translate-anchor"])}),layout:Du};class Lu{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:ge,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Fn(Lu,{omit:["defaultValue"]});class Ru extends na{constructor(t){super(t,Bu)}recalculate(t,e){super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)<0&&t.push(e);this.layout._values["text-writing-mode"]=t}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(t,e,i,r){const n=this.layout.get(t).evaluate(e,{},i,r),s=this._unevaluatedLayout._values[t];return s.isDataDriven()||Dr(s.value)||!n?n:function(t,e){return e.replace(/{([^{}]+)}/g,((e,i)=>i in t?String(t[i]):""))}(e.properties,n)}createBucket(t){return new Pu(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of Bu.paint.overridableProperties){if(!Ru.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Lu(e),r=new Pr(i,e.property.specification);let n=null;n="constant"===e.value.kind||"source"===e.value.kind?new Lr("source",r):new Rr("composite",r,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new ys(e.property,n,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Ru.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),r=Bu.paint.properties[e];let n=!1;const s=t=>{for(const e of t)if(r.overrides&&r.overrides.hasOverride(e))return void(n=!0)};if("constant"===i.value.kind&&i.value.value instanceof Oe)s(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{n||(e instanceof qe&&Ne(e.value)===Ie?s(e.value.sections):e instanceof Xe?s(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return n}getProgramConfiguration(t){return new Ko(this,t)}}var Fu={paint:new Is({"background-color":new vs(ue.paint_background["background-color"]),"background-pattern":new Ts(ue.paint_background["background-pattern"]),"background-opacity":new vs(ue.paint_background["background-opacity"])})},Ou={paint:new Is({"raster-opacity":new vs(ue.paint_raster["raster-opacity"]),"raster-hue-rotate":new vs(ue.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new vs(ue.paint_raster["raster-brightness-min"]),"raster-brightness-max":new vs(ue.paint_raster["raster-brightness-max"]),"raster-saturation":new vs(ue.paint_raster["raster-saturation"]),"raster-contrast":new vs(ue.paint_raster["raster-contrast"]),"raster-resampling":new vs(ue.paint_raster["raster-resampling"]),"raster-fade-duration":new vs(ue.paint_raster["raster-fade-duration"])})};class Vu extends na{constructor(t){super(t,{}),this.implementation=t}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(t){this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)}onRemove(t){this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)}}var ju={paint:new Is({"sky-type":new vs(ue.paint_sky["sky-type"]),"sky-atmosphere-sun":new vs(ue.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new vs(ue.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new vs(ue.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new vs(ue.paint_sky["sky-gradient-radius"]),"sky-gradient":new Es(ue.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new vs(ue.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new vs(ue.paint_sky["sky-atmosphere-color"]),"sky-opacity":new vs(ue.paint_sky["sky-opacity"])})};function Uu(t,e,i){const r=[0,0,1],n=jl([]);return function(t,e,i){i*=.5;var r=e[0],n=e[1],s=e[2],o=e[3],a=Math.sin(i),l=Math.cos(i);t[0]=r*l-s*a,t[1]=n*l+o*a,t[2]=s*l+r*a,t[3]=o*l-n*a}(n,n,i?-p(t)+Math.PI:p(t)),Ul(n,n,-p(e)),kl(r,r,n),Sl(r,r)}const Nu={circle:class extends na{constructor(t){super(t,Ha)}createBucket(t){return new ka(t)}queryRadius(t){const e=t;return qa("circle-radius",this,e)+qa("circle-stroke-width",this,e)+Ga(this.paint.get("circle-translate"))}queryIntersectsFeature(t,e,i,r,n,s,o,a){const l=Wa(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),s.angle,t.pixelToTileUnitsFactor),c=this.paint.get("circle-radius").evaluate(e,i)+this.paint.get("circle-stroke-width").evaluate(e,i);return Gl(t,r,s,o,a,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,c)}getProgramIds(){return["circle"]}getProgramConfiguration(t){return new Ko(this,t)}},heatmap:class extends na{createBucket(t){return new Kl(t)}constructor(t){super(t,ic),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=rc({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(t){return qa("heatmap-radius",this,t)}queryIntersectsFeature(t,e,i,r,n,s,a,l){const c=this.paint.get("heatmap-radius").evaluate(e,i);return Gl(t,r,s,a,l,!0,!0,new o(0,0),c)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(t){return new Ko(this,t)}},hillshade:class extends na{constructor(t){super(t,nc)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getProgramConfiguration(t){return new Ko(this,t)}},fill:class extends na{constructor(t){super(t,Gc)}getProgramIds(){const t=this.paint.get("fill-pattern"),e=t&&t.constantOr(1),i=[e?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&i.push(e&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),i}getProgramConfiguration(t){return new Ko(this,t)}recalculate(t,e){super.recalculate(t,e);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(t){return new Zc(t)}queryRadius(){return Ga(this.paint.get("fill-translate"))}queryIntersectsFeature(t,e,i,r,n,s){return!t.queryGeometry.isAboveHorizon&&Ba($a(t.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),s.angle,t.pixelToTileUnitsFactor),r)}isTileClipped(){return!0}},"fill-extrusion":class extends na{constructor(t){super(t,dh)}createBucket(t){return new uh(t)}queryRadius(){return Ga(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(t){return new Ko(this,t)}queryIntersectsFeature(t,e,i,r,n,s,a,l,c){const h=Wa(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),s.angle,t.pixelToTileUnitsFactor),u=this.paint.get("fill-extrusion-height").evaluate(e,i),p=this.paint.get("fill-extrusion-base").evaluate(e,i),d=[0,0],f=l&&s.elevation,m=s.elevation?s.elevation.exaggeration():1,_=t.tile.getBucket(this);if(f&&_ instanceof uh){const t=_.centroidVertexArray,e=c+1;if(e<t.length){const i=t.get(e);d[0]=i.a_centroid_pos0,d[1]=i.a_centroid_pos1}}if(0===d[0]&&1===d[1])return!1;const g=function(t,e,i,r,n,s,a,l,c){return s?function(t,e,i,r,n,s,o,a,l){const c=[],h=[],u=[0,0,0,1];for(const p of t){const t=[],d=[];for(const c of p){const h=c.x+r.x,p=c.y+r.y,f=gh(h,p,e,i,s,o,a,l);u[0]=h,u[1]=p,u[2]=f.base,u[3]=1,Ol(u,u,n),u[3]=Math.max(u[3],1e-5);const m=_h([u[0]/u[3],u[1]/u[3],u[2]/u[3]]);u[0]=h,u[1]=p,u[2]=f.top,u[3]=1,Ol(u,u,n),u[3]=Math.max(u[3],1e-5);const _=_h([u[0]/u[3],u[1]/u[3],u[2]/u[3]]);t.push(m),d.push(_)}c.push(t),h.push(d)}return[c,h]}(t,e,i,r,n,s,a,l,c):function(t,e,i,r,n){const s=[],a=[],l=n[8]*e,c=n[9]*e,h=n[10]*e,u=n[11]*e,p=n[8]*i,d=n[9]*i,f=n[10]*i,m=n[11]*i;for(const e of t){const t=[],i=[];for(const s of e){const e=s.x+r.x,a=s.y+r.y,_=n[0]*e+n[4]*a+n[12],g=n[1]*e+n[5]*a+n[13],y=n[2]*e+n[6]*a+n[14],x=n[3]*e+n[7]*a+n[15],v=_+l,b=g+c,w=y+h,T=Math.max(x+u,1e-5),E=_+p,I=g+d,S=y+f,A=Math.max(x+m,1e-5),z=new o(v/T,b/T);z.z=w/T,t.push(z);const C=new o(E/A,I/A);C.z=S/A,i.push(C)}s.push(t),a.push(i)}return[s,a]}(t,e,i,r,n)}(r,p,u,h,a,f?l:null,d,m,s.center.lat),y=t.queryGeometry;return function(t,e,i){let r=1/0;Ba(i,e)&&(r=mh(i,e[0]));for(let n=0;n<e.length;n++){const s=e[n],o=t[n];for(let t=0;t<s.length-1;t++){const e=s[t],n=[e,s[t+1],o[t+1],o[t],e];Pa(i,n)&&(r=Math.min(r,mh(i,n)))}}return r!==1/0&&r}(g[0],g[1],y.isPointQuery()?y.screenBounds:y.screenGeometry)}},line:class extends na{constructor(t){super(t,Sh),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=t._styleExpression&&t._styleExpression.expression instanceof Si,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=Ah.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new Eh(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getProgramConfiguration(t){return new Ko(this,t)}queryRadius(t){const e=t,i=zh(qa("line-width",this,e),qa("line-gap-width",this,e)),r=qa("line-offset",this,e);return i/2+Math.abs(r)+Ga(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,r,n,s){if(t.queryGeometry.isAboveHorizon)return!1;const a=$a(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),s.angle,t.pixelToTileUnitsFactor),l=t.pixelToTileUnitsFactor/2*zh(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),c=this.paint.get("line-offset").evaluate(e,i);return c&&(r=function(t,e){const i=[],r=new o(0,0);for(let n=0;n<t.length;n++){const s=t[n],o=[];for(let t=0;t<s.length;t++){const i=s[t-1],n=s[t],a=s[t+1],l=0===t?r:n.sub(i)._unit()._perp(),c=t===s.length-1?r:a.sub(n)._unit()._perp(),h=l._add(c)._unit();h._mult(1/(h.x*c.x+h.y*c.y)),o.push(h._mult(e)._add(n))}i.push(o)}return i}(r,c*t.pixelToTileUnitsFactor)),function(t,e,i){for(let r=0;r<e.length;r++){const n=e[r];if(t.length>=3)for(let e=0;e<n.length;e++)if(Ua(t,n[e]))return!0;if(La(t,n,i))return!0}return!1}(a,r,l)}isTileClipped(){return!0}},symbol:Ru,background:class extends na{constructor(t){super(t,Fu)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}},raster:class extends na{constructor(t){super(t,Ou)}getProgramIds(){return["raster"]}},sky:class extends na{constructor(t){super(t,ju),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"sky-gradient"===t?this._updateColorRamp():"sky-atmosphere-sun"!==t&&"sky-atmosphere-halo-color"!==t&&"sky-atmosphere-color"!==t&&"sky-atmosphere-sun-intensity"!==t||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=rc({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(t){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const e=t.style.light.properties.get("position");return this._lightPosition.azimuthal!==e.azimuthal||this._lightPosition.polar!==e.polar}return!1}getCenter(t,e){if("atmosphere"===this.paint.get("sky-type")){const i=this.paint.get("sky-atmosphere-sun"),r=!i,n=t.style.light,s=n.properties.get("position");return r&&"viewport"===n.properties.get("anchor")&&O("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),r?Uu(s.azimuthal,90-s.polar,e):Uu(i[0],90-i[1],e)}const i=this.paint.get("sky-gradient-center");return Uu(i[0],90-i[1],e)}is3D(){return!1}isSky(){return!0}markSkyboxValid(t){this._skyboxInvalidated=!1,this._lightPosition=t.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const t=this.paint.get("sky-type");return"atmosphere"===t?["skyboxCapture","skybox"]:"gradient"===t?["skyboxGradient"]:null}}};function Zu(t){return"custom"===t.type?new Vu(t):new Nu[t.type](t)}class qu{constructor(t,e,i,r){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,r)}update(t,e,i){const{width:r,height:n}=t,{context:s}=this,{gl:o}=s,{HTMLImageElement:a,HTMLCanvasElement:c,HTMLVideoElement:h,ImageData:u,ImageBitmap:p}=l;if(o.bindTexture(o.TEXTURE_2D,this.texture),s.pixelStoreUnpackFlipY.set(!1),s.pixelStoreUnpack.set(1),s.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA&&(!e||!1!==e.premultiply)),i||this.size&&this.size[0]===r&&this.size[1]===n){const{x:e,y:s}=i||{x:0,y:0};t instanceof a||t instanceof c||t instanceof h||t instanceof u||p&&t instanceof p?o.texSubImage2D(o.TEXTURE_2D,0,e,s,o.RGBA,o.UNSIGNED_BYTE,t):o.texSubImage2D(o.TEXTURE_2D,0,e,s,r,n,o.RGBA,o.UNSIGNED_BYTE,t.data)}else this.size=[r,n],t instanceof a||t instanceof c||t instanceof h||t instanceof u||p&&t instanceof p?o.texImage2D(o.TEXTURE_2D,0,this.format,this.format,o.UNSIGNED_BYTE,t):o.texImage2D(o.TEXTURE_2D,0,this.format,r,n,0,this.format,o.UNSIGNED_BYTE,t.data);this.useMipmap=Boolean(e&&e.useMipmap&&this.isSizePowerOfTwo()),this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(t,e){const{context:i}=this,{gl:r}=i;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.filter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_NEAREST:t),this.filter=t),e!==this.wrap&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrap=e)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}function Gu(t){const{userImage:e}=t;return!!(e&&e.render&&e.render())&&(t.data.replace(new Uint8Array(e.data.buffer)),!0)}class $u extends he{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new ec({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:t,callback:e}of this.requestors)this._notify(t,e);this.requestors=[]}}getImage(t){return this.images[t]}addImage(t,e){this._validate(t,e)&&(this.images[t]=e)}_validate(t,e){let i=!0;return this._validateStretch(e.stretchX,e.data&&e.data.width)||(this.fire(new ce(new Error(`Image "${t}" has invalid "stretchX" value`))),i=!1),this._validateStretch(e.stretchY,e.data&&e.data.height)||(this.fire(new ce(new Error(`Image "${t}" has invalid "stretchY" value`))),i=!1),this._validateContent(e.content,e)||(this.fire(new ce(new Error(`Image "${t}" has invalid "content" value`))),i=!1),i}_validateStretch(t,e){if(!t)return!0;let i=0;for(const r of t){if(r[0]<i||r[1]<r[0]||e<r[1])return!1;i=r[1]}return!0}_validateContent(t,e){return!(t&&(4!==t.length||t[0]<0||e.data.width<t[0]||t[1]<0||e.data.height<t[1]||t[2]<0||e.data.width<t[2]||t[3]<0||e.data.height<t[3]||t[2]<t[0]||t[3]<t[1]))}updateImage(t,e){e.version=this.images[t].version+1,this.images[t]=e,this.updatedImages[t]=!0}removeImage(t){const e=this.images[t];delete this.images[t],delete this.patterns[t],e.userImage&&e.userImage.onRemove&&e.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(t,e){let i=!0;if(!this.isLoaded())for(const e of t)this.images[e]||(i=!1);this.isLoaded()||i?this._notify(t,e):this.requestors.push({ids:t,callback:e})}_notify(t,e){const i={};for(const e of t){this.images[e]||this.fire(new le("styleimagemissing",{id:e}));const t=this.images[e];t?i[e]={data:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)}:O(`Image "${e}" 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.`)}e(null,i)}getPixelSize(){const{width:t,height:e}=this.atlasImage;return{width:t,height:e}}getPattern(t){const e=this.patterns[t],i=this.getImage(t);if(!i)return null;if(e&&e.position.version===i.version)return e.position;if(e)e.position.version=i.version;else{const e={w:i.data.width+2,h:i.data.height+2,x:0,y:0},r=new fu(e,i);this.patterns[t]={bin:e,position:r}}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){const e=t.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new qu(t,this.atlasImage,e.RGBA),this.atlasTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE)}_updatePatternAtlas(){const t=[];for(const e in this.patterns)t.push(this.patterns[e].bin);const{w:e,h:i}=du(t),r=this.atlasImage;r.resize({width:e||1,height:i||1});for(const t in this.patterns){const{bin:e}=this.patterns[t],i=e.x+1,n=e.y+1,s=this.images[t].data,o=s.width,a=s.height;ec.copy(s,r,{x:0,y:0},{x:i,y:n},{width:o,height:a}),ec.copy(s,r,{x:0,y:a-1},{x:i,y:n-1},{width:o,height:1}),ec.copy(s,r,{x:0,y:0},{x:i,y:n+a},{width:o,height:1}),ec.copy(s,r,{x:o-1,y:0},{x:i-1,y:n},{width:1,height:a}),ec.copy(s,r,{x:0,y:0},{x:i+o,y:n},{width:1,height:a})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(const e of t){if(this.callbackDispatchedThisFrame[e])continue;this.callbackDispatchedThisFrame[e]=!0;const t=this.images[e];Gu(t)&&this.updateImage(e,t)}}}const Wu=new Is({anchor:new vs(ue.light.anchor),position:new class{constructor(){this.specification=ue.light.position}possiblyEvaluate(t,e){return function([t,e,i]){const r=p(e+90),n=p(i);return{x:t*Math.cos(r)*Math.sin(n),y:t*Math.sin(r)*Math.sin(n),z:t*Math.cos(n),azimuthal:e,polar:i}}(t.expression.evaluate(e))}interpolate(t,e,i){return{x:Ai(t.x,e.x,i),y:Ai(t.y,e.y,i),z:Ai(t.z,e.z,i),azimuthal:Ai(t.azimuthal,e.azimuthal,i),polar:Ai(t.polar,e.polar,i)}}},color:new vs(ue.light.color),intensity:new vs(ue.light.intensity)}),Xu="-transition";class Hu extends he{constructor(t){super(),this._transitionable=new fs(Wu),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,e={}){if(!this._validate(In,t,e))for(const e in t){const i=t[e];D(e,Xu)?this._transitionable.setTransition(e.slice(0,-Xu.length),i):this._transitionable.setValue(e,i)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,e,i){return(!i||!1!==i.validate)&&Dn(this,t.call(Tn,I({value:e,style:{glyphs:!0,sprite:!0},styleSpec:ue})))}}const Ku=new Is({source:new vs(ue.terrain.source),exaggeration:new vs(ue.terrain.exaggeration)}),Yu="-transition";class Ju extends he{constructor(t,e){super(),this._transitionable=new fs(Ku),this.set(t),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=e}get(){return this._transitionable.serialize()}set(t){for(const e in t){const i=t[e];D(e,Yu)?this._transitionable.setTransition(e.slice(0,-Yu.length),i):this._transitionable.setValue(e,i)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}}function Qu(t,e,i,r){const n=b(45,65,i),[s,o]=tp(t,r),a=gl(e);let l=1-Math.min(1,Math.exp((a-s)/(o-s)*-6));return l*=l*l,l=Math.min(1,1.00747*l),l*n*t.alpha}function tp(t,e){const i=.5/Math.tan(.5*e);return[t.range[0]+i,t.range[1]+i]}const ep=new Is({range:new vs(ue.fog.range),color:new vs(ue.fog.color),"horizon-blend":new vs(ue.fog["horizon-blend"])}),ip="-transition";class rp extends he{constructor(t,e){super(),this._transitionable=new fs(ep),this.set(t),this._transitioning=this._transitionable.untransitioned(),this._transform=e}get state(){return{range:this.properties.get("range"),horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(t,e={}){if(!this._validate(An,t,e))for(const e in t){const i=t[e];D(e,ip)?this._transitionable.setTransition(e.slice(0,-ip.length),i):this._transitionable.setValue(e,i)}}getOpacity(t){if(!this._transform.projection.supportsFog)return 0;const e=this.properties&&this.properties.get("color")||1;return b(45,65,t)*e.a}getOpacityAtLatLng(t,e){return this._transform.projection.supportsFog?function(t,e,i){const r=ba.fromLngLat(e),n=i.elevation?i.elevation.getAtPointOrZero(r):0,s=[r.x,r.y,n];return Cl(s,s,i.mercatorFogMatrix),Qu(t,s,i.pitch,i._fov)}(this.state,t,e):0}getFovAdjustedRange(t){return this._transform.projection.supportsFog?tp(this.state,t):[0,1]}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,e,i){return(!i||!1!==i.validate)&&Dn(this,t.call(Tn,I({value:e,style:{glyphs:!0,sprite:!0},styleSpec:ue})))}}class np{constructor(t,e){this.width=t,this.height=e,this.nextRow=0,this.image=new tc({width:t,height:e}),this.positions={},this.uploaded=!1}getDash(t,e){const i=this.getKey(t,e);return this.positions[i]}trim(){const t=this.width,e=this.height=M(this.nextRow);this.image.resize({width:t,height:e})}getKey(t,e){return t.join(",")+e}getDashRanges(t,e,i){const r=[];let n=t.length%2==1?-t[t.length-1]*i:0,s=t[0]*i,o=!0;r.push({left:n,right:s,isDash:o,zeroLength:0===t[0]});let a=t[0];for(let e=1;e<t.length;e++){o=!o;const l=t[e];n=a*i,a+=l,s=a*i,r.push({left:n,right:s,isDash:o,zeroLength:0===l})}return r}addRoundDash(t,e,i){const r=e/2;for(let e=-i;e<=i;e++){const n=this.width*(this.nextRow+i+e);let s=0,o=t[s];for(let a=0;a<this.width;a++){a/o.right>1&&(o=t[++s]);const l=Math.abs(a-o.left),c=Math.abs(a-o.right),h=Math.min(l,c);let u;const p=e/i*(r+1);if(o.isDash){const t=r-Math.abs(p);u=Math.sqrt(h*h+t*t)}else u=r-Math.sqrt(h*h+p*p);this.image.data[n+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],r=t[e+1];i.zeroLength?t.splice(e,1):r&&r.isDash===i.isDash&&(r.left=i.left,t.splice(e,1))}const i=t[0],r=t[t.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 s=0,o=t[s];for(let i=0;i<this.width;i++){i/o.right>1&&(o=t[++s]);const r=Math.abs(i-o.left),a=Math.abs(i-o.right),l=Math.min(r,a);this.image.data[n+i]=Math.max(0,Math.min(255,(o.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const r="round"===e,n=r?7:0,s=2*n+1;if(this.nextRow+s>this.height)return O("LineAtlas out of space"),null;0===t.length&&t.push(1);let o=0;for(let e=0;e<t.length;e++)t[e]<0&&(O("Negative value is found in line dasharray, replacing values with 0"),t[e]=0),o+=t[e];if(0!==o){const i=this.width/o,s=this.getDashRanges(t,this.width,i);r?this.addRoundDash(s,i,n):this.addRegularDash(s,"square"===e?.5*i:0)}const a=this.nextRow+n;this.nextRow+=s;const l={tl:[a,n],br:[o,0]};return this.positions[i]=l,l}}Fn(np);class sp{constructor(t){this._callback=t,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 op{constructor(){this.tasks={},this.taskQueue=[],P(["process"],this),this.invoker=new sp(this.process),this.nextId=0}add(t,e){const i=this.nextId++,r=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===r){U();try{t()}finally{}return{cancel:()=>{}}}return this.tasks[i]={fn:t,metadata:e,priority:r,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){U();try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i<this.taskQueue.length;i++){const r=this.tasks[this.taskQueue[i]];r.priority<e&&(e=r.priority,t=i)}if(null===t)return null;const i=this.taskQueue[t];return this.taskQueue.splice(t,1),i}remove(){this.invoker.remove()}}class ap{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=z();const i=this.workerPool.acquire(this.id);for(let t=0;t<i.length;t++){const r=new ap.Actor(i[t],e,this.id);r.name=`Worker ${t}`,this.actors.push(r)}this.ready=!1,this.broadcast("checkIfReady",null,(()=>{this.ready=!0}))}broadcast(t,e,i){T(this.actors,((i,r)=>{i.send(t,e,r)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}function lp(t,e,i){return e*(la/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}ap.Actor=class{constructor(t,e,i){this.target=t,this.parent=e,this.mapId=i,this.callbacks={},this.cancelCallbacks={},P(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=U()?t:l,this.scheduler=new op}send(t,e,i,r,n=!1,s){const o=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=s,this.callbacks[o]=i);const a=X(this.globalScope)?void 0:[];return this.target.postMessage({id:o,type:t,hasCallback:!!i,targetMapId:r,mustQueue:n,sourceMapId:this.mapId,data:jn(e,a)},a),{cancel:()=>{i&&delete this.callbacks[o],this.target.postMessage({id:o,type:"<cancel>",targetMapId:r,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if("<cancel>"===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||U()){const t=this.callbacks[i];this.cancelCallbacks[i]=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"})}else this.processTask(i,e)}processTask(t,e){if("<response>"===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Un(e.error)):i(null,Un(e.data)))}else{const i=X(this.globalScope)?void 0:[],r=e.hasCallback?(e,r)=>{delete this.cancelCallbacks[t],this.target.postMessage({id:t,type:"<response>",sourceMapId:this.mapId,error:e?jn(e):null,data:jn(r,i)},i)}:t=>{},n=Un(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,n,r);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],n.source)[t[1]](n,r)}else r(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}};const cp=Ms([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_merc_pos",components:2},{type:"Float32",name:"a_uv",components:2}]),hp=Ms([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:up}=cp,pp=la/Math.PI/2,dp=64,fp=-pp,mp=pp,_p=[new ql([fp,fp,fp],[mp,mp,mp]),new ql([fp,fp,fp],[0,0,mp]),new ql([0,fp,fp],[mp,0,mp]),new ql([fp,0,fp],[0,mp,mp]),new ql([0,0,fp],[mp,mp,mp])];class gp{constructor(t,e,i){this.a=Dl([],t,i),this.b=Dl([],e,i),this.center=i;const r=Sl([],this.a),n=Sl([],this.b);this.angle=Math.acos(Al(r,n))}}function yp(t,e){if(0===t.angle)return null;let i;return i=0===t.a[e]?1/t.angle*.5*Math.PI:1/t.angle*Math.atan(t.b[e]/t.a[e]/Math.sin(t.angle)-1/Math.tan(t.angle)),i<0||i>1?null:function(t,e,i,r){const n=Math.sin(i);return t*(Math.sin((1-r)*i)/n)+e*(Math.sin(r*i)/n)}(t.a[e],t.b[e],t.angle,v(i,0,1))+t.center[e]}function xp(t){if(t.z<=1)return _p[t.z+2*t.y+t.x];const[e,i]=bp(t),r=[Tp(e[0],e[1]),Tp(e[0],i[1]),Tp(i[0],e[1]),Tp(i[0],i[1])],n=[mp,mp,mp],s=[fp,fp,fp];for(const t of r)n[0]=Math.min(n[0],t[0]),n[1]=Math.min(n[1],t[1]),n[2]=Math.min(n[2],t[2]),s[0]=Math.max(s[0],t[0]),s[1]=Math.max(s[1],t[1]),s[2]=Math.max(s[2],t[2]);return new ql(n,s)}function vp(t,e,i){const r=e/t.worldSize,n=(t,e)=>{El(t,t,r),El(e,e,r)},s=Number.MAX_VALUE,o=[-s,-s,-s],a=[s,s,s],l=kp(t);if(i.z<=1){const t=xp(i).getCorners();for(let e=0;e<t.length;e++)Cl(t[e],t[e],l),wl(a,a,t[e]),Tl(o,o,t[e]);return n(a,o),new ql(a,o)}const[c,h]=bp(i),u=new ca;u.setSouthWest([c[1],h[0]]),u.setNorthEast([h[1],c[0]]);const d=[Tp(u.getSouth(),u.getWest()),Tp(u.getSouth(),u.getEast()),Tp(u.getNorth(),u.getEast()),Tp(u.getNorth(),u.getWest())];for(let t=0;t<d.length;t++)Cl(d[t],d[t],l),wl(a,a,d[t]),Tl(o,o,d[t]);if(u.contains(t.center))return o[2]=0,n(a,o),new ql(a,o);const f=[l[12],l[13],l[14]],m=t.center.lng,_=v(t.center.lat,-85.051129,va),g=[fa(m),ma(_)],y=u.getCenter().lng,x=v(u.getCenter().lat,-85.051129,va),b=[fa(y),ma(x)];let w=new Array(3),T=0;const E=g[0]-b[0],I=g[1]-b[1];if(Math.abs(E)>Math.abs(I))T=E>=0?1:3,w=f;else{T=I>=0?0:2;const t=[l[4],l[5],l[6]];let e;e=I>=0?-Math.sin(p(u.getSouth()))*pp:-Math.sin(p(u.getNorth()))*pp,w=Il(w,f,t,e)}const S=d[T],A=d[(T+1)%4],z=new gp(S,A,w),C=[yp(z,0)||S[0],yp(z,1)||S[1],yp(z,2)||S[2]];return a[2]=Math.min(S[2],A[2]),wl(a,a,C),Tl(o,o,C),n(a,o),new ql(a,o)}function bp(t){const e=1<<t.z,i=t.x/e,r=(t.x+1)/e,n=(t.y+1)/e;return[[ya(t.y/e),ga(i)],[ya(n),ga(r)]]}function wp(t,e,i,r=pp){return i=p(i),[t*Math.sin(i)*r,-e*r,t*Math.cos(i)*r]}function Tp(t,e,i){return wp(Math.cos(p(t)),Math.sin(p(t)),e,i)}function Ep(t,e,i){const r=Math.pow(2,i.z),n=(t/la+i.x)/r;return Tp(ya((e/la+i.y)/r),ga(n))}function Ip(t){return 16383/Math.max(...Dl([],t.max,t.min))}function Sp(t){const e=rl(new Float64Array(16)),i=Ip(t);var r,n;return al(e,e,[i,i,i]),ol(e,e,((r=[])[0]=-(n=t.min)[0],r[1]=-n[1],r[2]=-n[2],r)),e}function Ap(t){const e=rl(new Float64Array(16)),i=1/Ip(t);return ol(e,e,t.min),al(e,e,[i,i,i]),e}function zp(t){const e=la/(2*Math.PI);return t/(2*Math.PI)/e}function Cp(t,e){return la/(512*Math.pow(2,t))*Ip(xp(e))}function Mp(t,e,i,r,n){const s=zp(i),o=[t,e,-i/(2*Math.PI)],a=rl(new Float64Array(16));return ol(a,a,o),al(a,a,[s,s,s]),ll(a,a,p(-n)),cl(a,a,p(-r)),a}function kp(t){const{x:e,y:i}=t.point,{lng:r,lat:n}=t._center;return Mp(e,i,t.worldSize,r,n)}function Pp(t){return b(5,6,t)}function Dp(t,e,i){const r=t.context;let n=e.globeGridBuffer;if(!n){const t=Vp.createGridVertices(i.canonical);n=e.globeGridBuffer=r.createVertexBuffer(t,up,!1)}return n}function Bp(t,e){const i=Ap(xp(t));return fl(il(),e,i)}function Lp(t,e,i){const r=rl(new Float64Array(16)),n=1<<t,s=360*(e/n-.5),o=i.point,a=i.worldSize/(i.tileSize*n);return ol(r,r,[o.x,o.y,-i.worldSize/Math.PI/2]),al(r,r,[a,a,a]),ll(r,r,p(-i._center.lat)),cl(r,r,p(-i._center.lng+s)),Float32Array.from(r)}const Rp=p(85),Fp=Math.cos(Rp),Op=Math.sin(Rp);class Vp{constructor(t){this._createGrid(t),this._createPoles(t),this._createAtmosphere(t)}destroy(){this.poleIndexBuffer.destroy(),this.gridIndexBuffer.destroy(),this.poleNorthVertexBuffer.destroy(),this.poleSouthVertexBuffer.destroy();for(const t of this.poleSegments)t.destroy();this.gridSegments.destroy(),this.atmosphereVertexBuffer.destroy(),this.atmosphereIndexBuffer.destroy(),this.atmosphereSegments.destroy(),this.wireframeIndexBuffer&&(this.wireframeIndexBuffer.destroy(),this.wireframeSegments.destroy())}_createGrid(t){const e=new $s;for(let t=0;t<64;t++)for(let i=0;i<64;i++){const r=65*t+i;e.emplaceBack(r+1,r,r+65),e.emplaceBack(r+65,r+65+1,r+1)}this.gridIndexBuffer=t.createIndexBuffer(e,!0),this.gridSegments=aa.simpleSegment(0,0,4225,8192)}_createPoles(t){const e=new $s;for(let t=0;t<=dp;t++)e.emplaceBack(0,t+1,t+2);this.poleIndexBuffer=t.createIndexBuffer(e,!0);const i=new Ks,r=new Ks;this.poleSegments=[];for(let t=0,e=0;t<5;t++){const n=1<<t,s=512*n/Math.PI/2,o=360/n;i.emplaceBack(0,-s,0,0,0,.5,0),r.emplaceBack(0,-s,0,0,0,.5,1);for(let t=0;t<=dp;t++){const e=t/dp,n=Ai(0,o,e),[a,l,c]=wp(Fp,Op,n,s);i.emplaceBack(a,l,c,0,0,e,0),r.emplaceBack(a,l,c,0,0,e,1)}this.poleSegments.push(aa.simpleSegment(e,0,66,64)),e+=66}this.poleNorthVertexBuffer=t.createVertexBuffer(i,up,!1),this.poleSouthVertexBuffer=t.createVertexBuffer(r,up,!1)}_createAtmosphere(t){const e=new Ys;e.emplaceBack(-1,1,1,0,0),e.emplaceBack(1,1,1,1,0),e.emplaceBack(1,-1,1,1,1),e.emplaceBack(-1,-1,1,0,1);const i=new $s;i.emplaceBack(0,1,2),i.emplaceBack(2,3,0),this.atmosphereVertexBuffer=t.createVertexBuffer(e,hp.members),this.atmosphereIndexBuffer=t.createIndexBuffer(i),this.atmosphereSegments=aa.simpleSegment(0,0,4,2)}static createGridVertices(t){const e=1<<t.z,[i,r]=bp(t),n=Sp(xp(t)),s=new Ks;s.reserve(4096);for(let o=0;o<65;o++){const a=Ai(i[0],r[0],o/dp),l=ma(a),c=l*e-t.y,h=Math.sin(p(a)),u=Math.cos(p(a));for(let t=0;t<65;t++){const e=t/dp,o=Ai(i[1],r[1],e),a=fa(o),p=wp(u,h,o),[d,f,m]=Cl(p,p,n);s.emplaceBack(d,f,m,a,l,e,c)}}return s}getWirefameBuffer(t){if(!this.wireframeSegments){const e=new Qs,i=dp,r=i+1;for(let t=0;t<i;t++)for(let n=0;n<i;n++){const i=t*r+n;e.emplaceBack(i,i+1),e.emplaceBack(i,i+r),e.emplaceBack(i,i+r+1)}this.wireframeIndexBuffer=t.createIndexBuffer(e),this.wireframeSegments=aa.simpleSegment(0,0,i*i,e.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}function jp(t,e,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return[t*r-2*Math.PI*6378137/2,e*r-2*Math.PI*6378137/2]}class Up{constructor(t,e,i){this.z=t,this.x=e,this.y=i,this.key=qp(0,t,t,e,i)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e){const i=function(t,e,i){var r=jp(256*t,256*(e=Math.pow(2,i)-e-1),i),n=jp(256*(t+1),256*(e+1),i);return r[0]+","+r[1]+","+n[0]+","+n[1]}(this.x,this.y,this.z),r=function(t,e,i){let r,n="";for(let s=t;s>0;s--)r=1<<s-1,n+=(e&r?1:0)+(i&r?2:0);return n}(this.z,this.x,this.y);return t[(this.x+this.y)%t.length].replace("{prefix}",(this.x%16).toString(16)+(this.y%16).toString(16)).replace("{z}",String(this.z)).replace("{x}",String(this.x)).replace("{y}",String("tms"===e?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 Np{constructor(t,e){this.wrap=t,this.canonical=e,this.key=qp(t,e.z,e.z,e.x,e.y)}}class Zp{constructor(t,e,i,r,n){this.overscaledZ=t,this.wrap=e,this.canonical=new Up(i,+r,+n),this.key=0===e&&t===i?this.canonical.key:qp(e,t,i,r,n)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){const e=this.canonical.z-t;return t>this.canonical.z?new Zp(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Zp(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e=!0){if(this.overscaledZ===t&&e)return this.key;if(t>this.canonical.z)return qp(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-t;return qp(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(t){if(t.wrap!==this.wrap)return!1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ<this.overscaledZ&&t.canonical.x===this.canonical.x>>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new Zp(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new Zp(e,this.wrap,e,i,r),new Zp(e,this.wrap,e,i+1,r),new Zp(e,this.wrap,e,i,r+1),new Zp(e,this.wrap,e,i+1,r+1)]}isLessThan(t){return this.wrap<t.wrap||!(this.wrap>t.wrap)&&(this.overscaledZ<t.overscaledZ||!(this.overscaledZ>t.overscaledZ)&&(this.canonical.x<t.canonical.x||!(this.canonical.x>t.canonical.x)&&this.canonical.y<t.canonical.y))}wrapped(){return new Zp(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new Zp(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Np(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function qp(t,e,i,r,n){const s=1<<Math.min(i,22);let o=s*(n%s)+r%s;return t&&i<22&&(o+=s*s*((t<0?-2*t-1:2*t)%(1<<2*(22-i)))),16*(32*o+i)+(e-i)}function Gp(t,e){if(!e.isReprojectedInTileSpace)return{scale:1<<t.z,x:t.x,y:t.y,x2:t.x+1,y2:t.y+1,projection:e};const i=Math.pow(2,-t.z),r=t.x*i,n=(t.x+1)*i,s=t.y*i,o=(t.y+1)*i,a=ga(r),l=ga(n),c=ya(s),h=ya(o),u=e.project(a,c),p=e.project(l,c),d=e.project(l,h),f=e.project(a,h);let m=Math.min(u.x,p.x,d.x,f.x),_=Math.min(u.y,p.y,d.y,f.y),g=Math.max(u.x,p.x,d.x,f.x),y=Math.max(u.y,p.y,d.y,f.y);const x=i/16;function v(t,i,r,n,s,o){const a=(r+s)/2,l=(n+o)/2,c=e.project(ga(a),ya(l)),h=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),h>x&&(v(t,c,r,n,a,l),v(c,i,a,l,s,o))}v(u,p,r,s,n,s),v(p,d,n,s,n,o),v(d,f,n,o,r,o),v(f,u,r,o,r,s),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:e}}function $p(t,e,i,r,n,s,o,a,l){if("globe"===l.name)return vp(t,e,new Up(i,r,n));const c=Gp({z:i,x:r,y:n},l);return new ql([(s+c.x/c.scale)*e,e*(c.y/c.scale),o],[(s+c.x2/c.scale)*e,e*(c.y2/c.scale),a])}function Wp(t,{x:e,y:i},r=0){return new o(((e-r)*t.scale-t.x)*la,(i*t.scale-t.y)*la)}function Xp(t,e,i=0){return yl(((e.x-i)*t.scale-t.x)*la,(e.y*t.scale-t.y)*la,xa(e.z,e.y))}Fn(Up),Fn(Zp,{omit:["projMatrix"]});class Hp{constructor(t,e,i,r){this.screenBounds=t,this.cameraPoint=e,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this.screenGeometry.map((t=>r.pointCoordinate3D(t))),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(t,e){let i,r;if(t instanceof o||"number"==typeof t[0]){const n=o.convert(t);i=[o.convert(t)],r=e.isPointAboveHorizon(n)}else{const n=o.convert(t[0]),s=o.convert(t[1]);i=[n,s],r=g(n,s).every((t=>e.isPointAboveHorizon(t)))}return new Hp(i,e.getCameraPoint(),r,e)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return g(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const e=this.screenBounds[0],i=1===this.screenBounds.length?this.screenBounds[0].add(new o(1,1)):this.screenBounds[1],r=g(e,i,0,!1);return this.cameraPoint.y>i.y&&(this.cameraPoint.x>e.x&&this.cameraPoint.x<i.x?r.splice(3,0,this.cameraPoint):this.cameraPoint.x>=i.x?r[2]=this.cameraPoint:this.cameraPoint.x<=e.x&&(r[3]=this.cameraPoint)),function(t,e){const i=[];for(let r=0;r<t.length;r++){const n=w(r-1,-1,t.length-1),s=w(r+1,-1,t.length-1),o=t[r],a=t[s],l=t[n].sub(o).unit(),c=a.sub(o).unit(),h=c.angleWithSep(l.x,l.y),u=l.add(c).unit().mult(-1*e/Math.sin(h/2));i.push(o.add(u))}return i}(r,t)}containsTile(t,e,i){const r=t.queryPadding+1,n=t.tileID.wrap,s=i?this._bufferedCameraMercator(r,e).map((e=>Wp(t.tileTransform,e,n))):this._bufferedScreenMercator(r,e).map((e=>Wp(t.tileTransform,e,n))),a=this.screenGeometryMercator.map((e=>Xp(t.tileTransform,e,n))),l=a.map((t=>new o(t[0],t[1]))),c=e.getFreeCameraOptions().position||new ba(0,0,0),h=Xp(t.tileTransform,c,n),u=a.map((t=>{const e=Dl(t,t,h);return Sl(e,e),new Nl(h,e)})),p=lp(t,1,e.zoom);if(Na(s,0,0,la,la))return{queryGeometry:this,tilespaceGeometry:l,tilespaceRays:u,bufferedTilespaceGeometry:s,bufferedTilespaceBounds:(d=_(s),d.min.x=v(d.min.x,0,la),d.min.y=v(d.min.y,0,la),d.max.x=v(d.max.x,0,la),d.max.y=v(d.max.y,0,la),d),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:p};var d}_bufferedScreenMercator(t,e){const i=Kp(t);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{const r=this.bufferedScreenGeometry(t).map((t=>e.pointCoordinate3D(t)));return this._screenRaycastCache[i]=r,r}}_bufferedCameraMercator(t,e){const i=Kp(t);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{const r=this.bufferedCameraGeometry(t).map((t=>e.pointCoordinate3D(t)));return this._cameraRaycastCache[i]=r,r}}}function Kp(t){return 100*t|0}function Yp(t,e,i){const r=function(r,n){if(r)return i(r);if(n){const r=S(I(n,t),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);n.vector_layers&&(r.vectorLayers=n.vector_layers,r.vectorLayerIds=r.vectorLayers.map((t=>t.id))),r.tiles=e.canonicalizeTileset(r,t.url),i(null,r)}};return t.url?Yt(e.transformRequest(e.normalizeSourceURL(t.url),Wt.Source),r):J.frame((()=>r(null,t)))}class Jp{constructor(t,e,i){this.bounds=ca.convert(this.validateBounds(t)),this.minzoom=e||0,this.maxzoom=i||24}validateBounds(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(t){const e=Math.pow(2,t.z),i=Math.floor(fa(this.bounds.getWest())*e),r=Math.floor(ma(this.bounds.getNorth())*e),n=Math.ceil(fa(this.bounds.getEast())*e),s=Math.ceil(ma(this.bounds.getSouth())*e);return t.x>=i&&t.x<n&&t.y>=r&&t.y<s}}class Qp{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e<t.length;e++){const i=t[e];this._stringToNumber[i]=e,this._numberToString[e]=i}}encode(t){return this._stringToNumber[t]}decode(t){return this._numberToString[t]}}const td=["tile","layer","source","sourceLayer","state"];class ed{constructor(t,e,i,r,n){this.type="Feature",this._vectorTileFeature=t,this._z=e,this._x=i,this._y=r,this.properties=t.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(t){this._geometry=t}toJSON(){const t={type:"Feature",geometry:this.geometry,properties:this.properties};void 0!==this.id&&(t.id=this.id);for(const e of td)void 0!==this[e]&&(t[e]=this[e]);return t}}const id=Ms([{name:"a_pos_3",components:3,type:"Int16"}]);var rd=Ms([{name:"a_pos",type:"Int16",components:2}]);const nd=32,sd=33,od=new Uint16Array(8184);for(let t=0;t<2046;t++){let e=t+2,i=0,r=0,n=0,s=0,o=0,a=0;for(1&e?n=s=o=nd:i=r=a=nd;(e>>=1)>1;){const t=i+n>>1,l=r+s>>1;1&e?(n=i,s=r,i=o,r=a):(i=n,r=s,n=o,s=a),o=t,a=l}const l=4*t;od[l+0]=i,od[l+1]=r,od[l+2]=n,od[l+3]=s}const ad=new Uint16Array(2178),ld=new Uint8Array(1089),cd=new Uint16Array(1089);function hd(t){return 0===t?-.03125:32===t?.03125:0}var ud=Ms([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const pd={type:2,extent:la,loadGeometry:()=>[[new o(0,0),new o(8193,0),new o(8193,8193),new o(0,8193),new o(0,0)]]};class dd{constructor(t,e,i,r,n){this.tileID=t,this.uid=z(),this.uses=0,this.tileSize=e,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(t){const e=t+this.timeAdded;e<J.now()||this.fadeEndTime&&e<this.fadeEndTime||(this.fadeEndTime=e)}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}get tileTransform(){return this._tileTransform||(this._tileTransform=Gp(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(t,e,i){if(this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestFeatureIndex.rawTileData=t.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=function(t,e){const i={};if(!e)return i;for(const r of t){const t=r.layerIds.map((t=>e.getLayer(t))).filter(Boolean);if(0!==t.length){r.layers=t,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.id]=r}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof Pu){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof Pu&&e.hasRTLText){this.hasRTLText=!0,hs.isLoading()||hs.isLoaded()||"deferred"!==ls()||cs();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,e.style.getLayer(t).queryRadius(i))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas)}else this.collisionBoxArray=new ao}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugIndexBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this.globeGridBuffer&&(this.globeGridBuffer.destroy(),this.globeGridBuffer=null),this._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(t){return this.buckets[t.id]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new qu(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new qu(t,this.glyphAtlasImage,e.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new qu(t,this.lineAtlas.image,e.ALPHA),this.lineAtlas.uploaded=!0)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,e,i,r,n,s,o,a){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:r,pixelPosMatrix:o,transform:s,params:n,tileTransform:this.tileTransform},t,e,i):{}}querySourceFeatures(t,e){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const r=i.loadVTLayers(),n=e?e.sourceLayer:"",s=r._geojsonTileLayer||r[n];if(!s)return;const o=Hr(e&&e.filter),{z:a,x:l,y:c}=this.tileID.canonical,h={z:a,x:l,y:c};for(let e=0;e<s.length;e++){const r=s.feature(e);if(o.needGeometry){const t=za(r,!0);if(!o.filter(new us(this.tileID.overscaledZ),t,this.tileID.canonical))continue}else if(!o.filter(new us(this.tileID.overscaledZ),r))continue;const u=i.getId(r,n),p=new ed(r,a,l,c,u);p.tile=h,t.push(p)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return!!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const e=this.expirationTime;if(t.cacheControl){const e=N(t.cacheControl);e["max-age"]&&(this.expirationTime=Date.now()+1e3*e["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const t=Date.now();let i=!1;if(this.expirationTime>t)i=!1;else if(e)if(this.expirationTime<e)i=!0;else{const r=this.expirationTime-e;r?this.expirationTime=t+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(t,e){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||0===Object.keys(t).length||!e)return;const i=this.latestFeatureIndex.loadVTLayers(),r=e.style.listImages();for(const n in this.buckets){if(!e.style.hasLayer(n))continue;const s=this.buckets[n],o=s.layers[0].sourceLayer||"_geojsonTileLayer",a=i[o],l=t[o];if(!a||!l||0===Object.keys(l).length)continue;if(s.update(l,a,r,this.imageAtlas&&this.imageAtlas.patternPositions||{}),s instanceof Eh||s instanceof Zc){const t=e.style._getSourceCache(s.layers[0].source);e._terrain&&e._terrain.enabled&&t&&s.programConfigurations.needsUpload&&e._terrain._clearRenderCacheForTile(t.id,this.tileID)}const c=e&&e.style&&e.style.getLayer(n);c&&(this.queryPadding=Math.max(this.queryPadding,c.queryRadius(s)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<J.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(t){this.symbolFadeHoldUntil=J.now()+t}setDependencies(t,e){const i={};for(const t of e)i[t]=!0;this.dependencies[t]=i}hasDependency(t,e){for(const i of t){const t=this.dependencies[i];if(t)for(const i of e)if(t[i])return!0}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(t,e){if(!e||"mercator"===e.name||this._tileDebugBuffer)return;const i=Aa(pd,this.tileID.canonical,this.tileTransform)[0],r=new Ps,n=new to;for(let t=0;t<i.length;t++){const{x:e,y:s}=i[t];r.emplaceBack(e,s),n.emplaceBack(t)}n.emplaceBack(0),this._tileDebugIndexBuffer=t.createIndexBuffer(n),this._tileDebugBuffer=t.createVertexBuffer(r,rd.members),this._tileDebugSegments=aa.simpleSegment(0,0,r.length,n.length)}_makeTileBoundsBuffers(t,e){if(this._tileBoundsBuffer||!e||"mercator"===e.name)return;const i=Aa(pd,this.tileID.canonical,this.tileTransform)[0];let r,n;if(this.isRaster){const t=function(t,e){const i=Gp(t,e),r=Math.pow(2,t.z);for(let n=0;n<sd;n++)for(let s=0;s<sd;s++){const o=ga((t.x+(s+hd(s))/nd)/r),a=ya((t.y+(n+hd(n))/nd)/r),l=e.project(o,a),c=n*sd+s;ad[2*c+0]=Math.round((l.x*i.scale-i.x)*la),ad[2*c+1]=Math.round((l.y*i.scale-i.y)*la)}ld.fill(0),cd.fill(0);for(let t=2045;t>=0;t--){const e=4*t,i=od[e+0],r=od[e+1],n=od[e+2],s=od[e+3],o=i+n>>1,a=r+s>>1,l=o+a-r,c=a+i-o,h=r*sd+i,u=s*sd+n,p=a*sd+o,d=Math.hypot((ad[2*h+0]+ad[2*u+0])/2-ad[2*p+0],(ad[2*h+1]+ad[2*u+1])/2-ad[2*p+1])>=16;if(ld[p]=ld[p]||(d?1:0),t<1022){const t=(r+c>>1)*sd+(i+l>>1),e=(s+c>>1)*sd+(n+l>>1);ld[p]=ld[p]||ld[t]||ld[e]}}const n=new Bs,s=new $s;let o=0;function a(t,e){const i=e*sd+t;return 0===cd[i]&&(n.emplaceBack(ad[2*i+0],ad[2*i+1],t*la/nd,e*la/nd),cd[i]=++o),cd[i]-1}function l(t,e,i,r,n,o){const c=t+i>>1,h=e+r>>1;if(Math.abs(t-n)+Math.abs(e-o)>1&&ld[h*sd+c])l(n,o,t,e,c,h),l(i,r,n,o,c,h);else{const l=a(t,e),c=a(i,r),h=a(n,o);s.emplaceBack(l,c,h)}}return l(0,0,nd,nd,nd,0),l(nd,nd,0,0,0,nd),{vertices:n,indices:s}}(this.tileID.canonical,e);r=t.vertices,n=t.indices}else{r=new Bs,n=new $s;for(const{x:t,y:e}of i)r.emplaceBack(t,e,0,0);const t=ac(r.int16,void 0,4);for(let e=0;e<t.length;e+=3)n.emplaceBack(t[e],t[e+1],t[e+2])}this._tileBoundsBuffer=t.createVertexBuffer(r,ud.members),this._tileBoundsIndexBuffer=t.createIndexBuffer(n),this._tileBoundsSegments=aa.simpleSegment(0,0,r.length,n.length)}_makeGlobeTileDebugBuffers(t,e){if(this._globeTileDebugBorderBuffer||this._globeTileDebugTextBuffer||!e||"globe"!==e.name)return;const i=this.tileID.canonical,r=Sp(xp(i));this._makeGlobeTileDebugBorderBuffer(t,i,r),this._makeGlobeTileDebugTextBuffer(t,i,r)}_makeGlobeTileDebugBorderBuffer(t,e,i){const r=new Ps,n=new to,s=new Ds,o=(t,o,a,l,c)=>{const h=(a-t)/(c-1),u=(l-o)/(c-1),p=r.length;for(let a=0;a<c;a++){const l=t+a*h,c=o+a*u;r.emplaceBack(l,c);const d=Ep(l,c,e),f=Cl(d,d,i);s.emplaceBack(f[0],f[1],f[2]),n.emplaceBack(p+a)}},a=la;o(0,0,a,0,16),o(a,0,a,a,16),o(a,a,0,a,16),o(0,a,0,0,16),this._tileDebugIndexBuffer=t.createIndexBuffer(n),this._tileDebugBuffer=t.createVertexBuffer(r,rd.members),this._globeTileDebugBorderBuffer=t.createVertexBuffer(s,id.members),this._tileDebugSegments=aa.simpleSegment(0,0,r.length,n.length)}_makeGlobeTileDebugTextBuffer(t,e,i){const r=new Ps,n=new $s,s=new Ds,o=25;n.reserve(32),r.reserve(o),s.reserve(o);const a=(t,e)=>o*t+e;for(let t=0;t<o;t++){const n=2048*t;for(let t=0;t<o;t++){const o=2048*t;r.emplaceBack(o,n);const a=Ep(o,n,e),l=Cl(a,a,i);s.emplaceBack(l[0],l[1],l[2])}}for(let t=0;t<4;t++)for(let e=0;e<4;e++){const i=a(t,e),r=a(t,e+1),s=a(t+1,e),o=a(t+1,e+1);n.emplaceBack(i,r,s),n.emplaceBack(s,r,o)}this._tileDebugTextIndexBuffer=t.createIndexBuffer(n),this._tileDebugTextBuffer=t.createVertexBuffer(r,rd.members),this._globeTileDebugTextBuffer=t.createVertexBuffer(s,id.members),this._tileDebugTextSegments=aa.simpleSegment(0,0,o,32)}}class fd{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,e,i){const r=String(e);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][r]=this.stateChanges[t][r]||{},I(this.stateChanges[t][r],i),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==r&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][r]){this.deletedStates[t][r]={};for(const e in this.state[t][r])i[e]||(this.deletedStates[t][r][e]=null)}else for(const e in i)this.deletedStates[t]&&this.deletedStates[t][r]&&null===this.deletedStates[t][r][e]&&delete this.deletedStates[t][r][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const r=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][r]&&(this.deletedStates[t][r]=this.deletedStates[t][r]||{},this.deletedStates[t][r][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][r])for(i in this.deletedStates[t][r]={},this.stateChanges[t][r])this.deletedStates[t][r][i]=null;else this.deletedStates[t][r]=null;else this.deletedStates[t]=null}getState(t,e){const i=String(e),r=I({},(this.state[t]||{})[i],(this.stateChanges[t]||{})[i]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const i=this.deletedStates[t][e];if(null===i)return{};for(const t in i)delete r[t]}return r}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,e){const i={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const e={};for(const i in this.stateChanges[t])this.state[t][i]||(this.state[t][i]={}),I(this.state[t][i],this.stateChanges[t][i]),e[i]=this.state[t][i];i[t]=e}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const e={};if(null===this.deletedStates[t])for(const i in this.state[t])e[i]={},this.state[t][i]={};else for(const i in this.deletedStates[t]){if(null===this.deletedStates[t][i])this.state[t][i]={};else for(const e of Object.keys(this.deletedStates[t][i]))delete this.state[t][i][e];e[i]=this.state[t][i]}i[t]=i[t]||{},I(i[t],e)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const r in t)t[r].setFeatureState(i,e)}}class md{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(t,e){const i=this.toIdx(t,e);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(t,e){return this.leaves[this.toIdx(t,e)]}toIdx(t,e){return e*this.size+t}}function _d(t,e,i,r){let n=0,s=Number.MAX_VALUE;for(let o=0;o<3;o++)if(Math.abs(r[o])<1e-15){if(i[o]<t[o]||i[o]>e[o])return null}else{const a=1/r[o];let l=(t[o]-i[o])*a,c=(e[o]-i[o])*a;if(l>c){const t=l;l=c,c=t}if(l>n&&(n=l),c<s&&(s=c),n>s)return null}return n}function gd(t,e,i,r,n,s,o,a,l,c,h){const u=r-t,p=n-e,d=s-i,f=o-t,m=a-e,_=l-i,g=h[1]*_-h[2]*m,y=h[2]*f-h[0]*_,x=h[0]*m-h[1]*f,v=u*g+p*y+d*x;if(Math.abs(v)<1e-15)return null;const b=1/v,w=c[0]-t,T=c[1]-e,E=c[2]-i,I=(w*g+T*y+E*x)*b;if(I<0||I>1)return null;const S=T*d-E*p,A=E*u-w*d,z=w*p-T*u,C=(h[0]*S+h[1]*A+h[2]*z)*b;return C<0||I+C>1?null:(f*S+m*A+_*z)*b}function yd(t,e,i){return(t-e)/(i-e)}function xd(t,e,i,r,n,s,o,a,l){const c=1<<i,h=s-r,u=o-n,p=(t+1)/c*h+r,d=(e+0)/c*u+n,f=(e+1)/c*u+n;a[0]=(t+0)/c*h+r,a[1]=d,l[0]=p,l[1]=f}class vd{constructor(t){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=t,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;const e=function(t){const e=Math.ceil(Math.log2(t.dim/8)),i=[];let r=Math.ceil(Math.pow(2,e));const n=1/r,s=(t,e,i,r,n)=>{const s=r?1:0,o=(t+1)*i-s,a=e*i,l=(e+1)*i-s;n[0]=t*i,n[1]=a,n[2]=o,n[3]=l};let o=new md(r);const a=[];for(let e=0;e<r*r;e++){s(e%r,Math.floor(e/r),n,!1,a);const i=wd(a[0],a[1],t),l=wd(a[2],a[1],t),c=wd(a[2],a[3],t),h=wd(a[0],a[3],t);o.minimums.push(Math.min(i,l,c,h)),o.maximums.push(Math.max(i,l,c,h)),o.leaves.push(1)}for(i.push(o),r/=2;r>=1;r/=2){const t=i[i.length-1];o=new md(r);for(let e=0;e<r*r;e++){s(e%r,Math.floor(e/r),2,!0,a);const i=t.getElevation(a[0],a[1]),n=t.getElevation(a[2],a[1]),l=t.getElevation(a[2],a[3]),c=t.getElevation(a[0],a[3]),h=t.isLeaf(a[0],a[1]),u=t.isLeaf(a[2],a[1]),p=t.isLeaf(a[2],a[3]),d=t.isLeaf(a[0],a[3]),f=Math.min(i.min,n.min,l.min,c.min),m=Math.max(i.max,n.max,l.max,c.max),_=h&&u&&p&&d;o.maximums.push(m),o.minimums.push(f),o.leaves.push(m-f<=5&&_?1:0)}i.push(o)}return i}(this.dem),i=e.length-1,r=e[i];this._addNode(r.minimums[0],r.maximums[0],r.leaves[0]),this._construct(e,0,0,i,0)}raycastRoot(t,e,i,r,n,s,o=1){return _d([t,e,-100],[i,r,this.maximums[0]*o],n,s)}raycast(t,e,i,r,n,s,o=1){if(!this.nodeCount)return null;const a=this.raycastRoot(t,e,i,r,n,s,o);if(null==a)return null;const l=[],c=[],h=[],u=[],p=[{idx:0,t:a,nodex:0,nodey:0,depth:0}];for(;p.length>0;){const{idx:a,t:d,nodex:f,nodey:m,depth:_}=p.pop();if(this.leaves[a]){xd(f,m,_,t,e,i,r,h,u);const a=1<<_,l=(f+0)/a,c=(f+1)/a,p=(m+0)/a,g=(m+1)/a,y=wd(l,p,this.dem)*o,x=wd(c,p,this.dem)*o,v=wd(c,g,this.dem)*o,b=wd(l,g,this.dem)*o,w=gd(h[0],h[1],y,u[0],h[1],x,u[0],u[1],v,n,s),T=gd(u[0],u[1],v,h[0],u[1],b,h[0],h[1],y,n,s),E=Math.min(null!==w?w:Number.MAX_VALUE,null!==T?T:Number.MAX_VALUE);if(E!==Number.MAX_VALUE)return E;{const t=Il([],n,s,d);if(bd(y,x,b,v,yd(t[0],h[0],u[0]),yd(t[1],h[1],u[1]))>=t[2])return d}continue}let g=0;for(let p=0;p<this._siblingOffset.length;p++){xd((f<<1)+this._siblingOffset[p][0],(m<<1)+this._siblingOffset[p][1],_+1,t,e,i,r,h,u),h[2]=-100,u[2]=this.maximums[this.childOffsets[a]+p]*o;const d=_d(h,u,n,s);if(null!=d){const t=d;l[p]=t;let e=!1;for(let i=0;i<g&&!e;i++)t>=l[c[i]]&&(c.splice(i,0,p),e=!0);e||(c[g]=p),g++}}for(let t=0;t<g;t++){const e=c[t];p.push({idx:this.childOffsets[a]+e,t:l[e],nodex:(f<<1)+this._siblingOffset[e][0],nodey:(m<<1)+this._siblingOffset[e][1],depth:_+1})}}return null}_addNode(t,e,i){return this.minimums.push(t),this.maximums.push(e),this.leaves.push(i),this.childOffsets.push(0),this.nodeCount++}_construct(t,e,i,r,n){if(1===t[r].isLeaf(e,i))return;this.childOffsets[n]||(this.childOffsets[n]=this.nodeCount);const s=r-1,o=t[s];let a=0,l=0;for(let t=0;t<this._siblingOffset.length;t++){const r=2*e+this._siblingOffset[t][0],n=2*i+this._siblingOffset[t][1],s=o.getElevation(r,n),c=o.isLeaf(r,n),h=this._addNode(s.min,s.max,c);c&&(a|=1<<t),l||(l=h)}for(let r=0;r<this._siblingOffset.length;r++)a&1<<r||this._construct(t,2*e+this._siblingOffset[r][0],2*i+this._siblingOffset[r][1],s,l+r)}}function bd(t,e,i,r,n,s){return Ai(Ai(t,i,s),Ai(e,r,s),n)}function wd(t,e,i){const r=i.dim,n=v(t*r-.5,0,r-1),s=v(e*r-.5,0,r-1),o=Math.floor(n),a=Math.floor(s),l=Math.min(o+1,r-1),c=Math.min(a+1,r-1);return bd(i.get(o,a),i.get(l,a),i.get(o,c),i.get(l,c),n-o,s-a)}const Td={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};class Ed{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(t,e,i,r=!1,n=!1){if(this.uid=t,e.height!==e.width)throw new RangeError("DEM tiles must be square");if(i&&"mapbox"!==i&&"terrarium"!==i)return O(`"${i}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=e.height;const s=this.dim=e.height-2,o=new Uint32Array(e.data.buffer);if(this.pixels=new Uint8Array(e.data.buffer),this.encoding=i||"mapbox",this.borderReady=r,!r){for(let t=0;t<s;t++)o[this._idx(-1,t)]=o[this._idx(0,t)],o[this._idx(s,t)]=o[this._idx(s-1,t)],o[this._idx(t,-1)]=o[this._idx(t,0)],o[this._idx(t,s)]=o[this._idx(t,s-1)];o[this._idx(-1,-1)]=o[this._idx(0,0)],o[this._idx(s,-1)]=o[this._idx(s-1,0)],o[this._idx(-1,s)]=o[this._idx(0,s-1)],o[this._idx(s,s)]=o[this._idx(s-1,s-1)],n&&this._buildQuadTree()}}_buildQuadTree(){this._tree=new vd(this)}get(t,e,i=!1){i&&(t=v(t,-1,this.dim),e=v(e,-1,this.dim));const r=4*this._idx(t,e);return("terrarium"===this.encoding?this._unpackTerrarium:this._unpackMapbox)(this.pixels[r],this.pixels[r+1],this.pixels[r+2])}static getUnpackVector(t){return Td[t]}get unpackVector(){return Td[this.encoding]}_idx(t,e){if(t<-1||t>=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}_unpackMapbox(t,e,i){return(256*t*256+256*e+i)/10-1e4}_unpackTerrarium(t,e,i){return 256*t+e+i/256-32768}static pack(t,e){const i=[0,0,0,0],r=Ed.getUnpackVector(e);let n=Math.floor((t+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 ec({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let r=e*this.dim,n=e*this.dim+this.dim,s=i*this.dim,o=i*this.dim+this.dim;switch(e){case-1:r=n-1;break;case 1:n=r+1}switch(i){case-1:s=o-1;break;case 1:o=s+1}const a=-e*this.dim,l=-i*this.dim;for(let e=s;e<o;e++)for(let i=r;i<n;i++){const r=4*this._idx(i,e),n=4*this._idx(i+a,e+l);this.pixels[r+0]=t.pixels[n+0],this.pixels[r+1]=t.pixels[n+1],this.pixels[r+2]=t.pixels[n+2],this.pixels[r+3]=t.pixels[n+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}Fn(Ed),Fn(vd,{omit:["dem"]});class Id{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const r=t.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);const n={value:e,timeout:void 0};if(void 0!==i&&(n.timeout=setTimeout((()=>{this.remove(t,n)}),i)),this.data[r].push(n),this.order.push(r),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,r=void 0===e?0:this.data[i].indexOf(e),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(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const r of this.data[i])t(r.value)||e.push(r);for(const t of e)this.remove(t.value.tileID,t)}}class Sd{constructor(t,e,i){this.context=t;const r=t.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||e.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const e=this.context.gl;this.context.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Ad={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class zd{constructor(t,e,i,r){this.length=e.length,this.attributes=i,this.itemSize=e.bytesPerElement,this.dynamicDraw=r,this.context=t;const n=t.gl;this.buffer=n.createBuffer(),t.bindVertexBuffer.set(this.buffer),n.bufferData(n.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||e.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){const e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,e){for(let i=0;i<this.attributes.length;i++){const r=e.attributes[this.attributes[i].name];void 0!==r&&t.enableVertexAttribArray(r)}}setVertexAttribPointers(t,e,i){for(let r=0;r<this.attributes.length;r++){const n=this.attributes[r],s=e.attributes[n.name];void 0!==s&&t.vertexAttribPointer(s,n.components,t[Ad[n.type]],!1,this.itemSize,n.offset+this.itemSize*(i||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Cd{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class Md extends Cd{getDefault(){return Le.transparent}set(t){const e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class kd extends Cd{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class Pd extends Cd{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class Dd extends Cd{getDefault(){return[!0,!0,!0,!0]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Bd extends Cd{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class Ld extends Cd{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class Rd extends Cd{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){const e=this.current;(t.func!==e.func||t.ref!==e.ref||t.mask!==e.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class Fd extends Cd{getDefault(){const t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class Od extends Cd{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this.current=t,this.dirty=!1}}class Vd extends Cd{getDefault(){return[0,1]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class jd extends Cd{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this.current=t,this.dirty=!1}}class Ud extends Cd{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class Nd extends Cd{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.BLEND):e.disable(e.BLEND),this.current=t,this.dirty=!1}}class Zd extends Cd{getDefault(){const t=this.gl;return[t.ONE,t.ZERO]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class qd extends Cd{getDefault(){return Le.transparent}set(t){const e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Gd extends Cd{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class $d extends Cd{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this.current=t,this.dirty=!1}}class Wd extends Cd{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class Xd extends Cd{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class Hd extends Cd{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class Kd extends Cd{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class Yd extends Cd{getDefault(){const t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Jd extends Cd{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class Qd extends Cd{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindRenderbuffer(e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class tf extends Cd{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindTexture(e.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class ef extends Cd{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindBuffer(e.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class rf extends Cd{getDefault(){return null}set(t){const e=this.gl;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class nf extends Cd{constructor(t){super(t),this.vao=t.extVertexArrayObject}getDefault(){return null}set(t){this.vao&&(t!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(t),this.current=t,this.dirty=!1)}}class sf extends Cd{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class of extends Cd{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class af extends Cd{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class lf extends Cd{constructor(t,e){super(t),this.context=t,this.parent=e}getDefault(){return null}}class cf extends lf{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class hf extends lf{attachment(){return this.gl.DEPTH_ATTACHMENT}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,this.attachment(),e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class uf extends hf{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class pf{constructor(t,e,i,r){this.context=t,this.width=e,this.height=i;const n=this.framebuffer=t.gl.createFramebuffer();this.colorAttachment=new cf(t,n),r&&(this.depthAttachment=new hf(t,n))}destroy(){const t=this.context.gl,e=this.colorAttachment.get();if(e&&t.deleteTexture(e),this.depthAttachment){const e=this.depthAttachment.get();e&&t.deleteRenderbuffer(e)}t.deleteFramebuffer(this.framebuffer)}}class df{constructor(t,e,i){this.func=t,this.mask=e,this.range=i}}df.ReadOnly=!1,df.ReadWrite=!0,df.disabled=new df(519,df.ReadOnly,[0,1]);const ff=7680;class mf{constructor(t,e,i,r,n,s){this.test=t,this.ref=e,this.mask=i,this.fail=r,this.depthFail=n,this.pass=s}}mf.disabled=new mf({func:519,mask:0},0,0,ff,ff,ff);class _f{constructor(t,e,i){this.blendFunction=t,this.blendColor=e,this.mask=i}}_f.Replace=[1,0],_f.disabled=new _f(_f.Replace,Le.transparent,[!1,!1,!1,!1]),_f.unblended=new _f(_f.Replace,Le.transparent,[!0,!0,!0,!0]),_f.alphaBlended=new _f([1,771],Le.transparent,[!0,!0,!0,!0]);const gf=1029,yf=2305;class xf{constructor(t,e,i){this.enable=t,this.mode=e,this.frontFace=i}}xf.disabled=new xf(!1,gf,yf),xf.backCCW=new xf(!0,gf,yf),xf.backCW=new xf(!0,gf,2304),xf.frontCW=new xf(!0,1028,2304),xf.frontCCW=new xf(!0,1028,yf);class vf{constructor(t){this.gl=t,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),this.clearColor=new Md(this),this.clearDepth=new kd(this),this.clearStencil=new Pd(this),this.colorMask=new Dd(this),this.depthMask=new Bd(this),this.stencilMask=new Ld(this),this.stencilFunc=new Rd(this),this.stencilOp=new Fd(this),this.stencilTest=new Od(this),this.depthRange=new Vd(this),this.depthTest=new jd(this),this.depthFunc=new Ud(this),this.blend=new Nd(this),this.blendFunc=new Zd(this),this.blendColor=new qd(this),this.blendEquation=new Gd(this),this.cullFace=new $d(this),this.cullFaceSide=new Wd(this),this.frontFace=new Xd(this),this.program=new Hd(this),this.activeTexture=new Kd(this),this.viewport=new Yd(this),this.bindFramebuffer=new Jd(this),this.bindRenderbuffer=new Qd(this),this.bindTexture=new tf(this),this.bindVertexBuffer=new ef(this),this.bindElementBuffer=new rf(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new nf(this),this.pixelStoreUnpack=new sf(this),this.pixelStoreUnpackPremultiplyAlpha=new of(this),this.pixelStoreUnpackFlipY=new af(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureFilterAnisotropicForceOff=!1,this.extTextureHalfFloat=t.getExtension("OES_texture_half_float"),this.extTextureHalfFloat&&(t.getExtension("OES_texture_half_float_linear"),this.extRenderToTextureHalfFloat=t.getExtension("EXT_color_buffer_half_float")),this.extTimerQuery=t.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=t.getParameter(t.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(t,e){return new Sd(this,t,e)}createVertexBuffer(t,e,i){return new zd(this,t,e,i)}createRenderbuffer(t,e,i){const r=this.gl,n=r.createRenderbuffer();return this.bindRenderbuffer.set(n),r.renderbufferStorage(r.RENDERBUFFER,t,e,i),this.bindRenderbuffer.set(null),n}createFramebuffer(t,e,i){return new pf(this,t,e,i)}clear({color:t,depth:e,stencil:i}){const r=this.gl;let n=0;t&&(n|=r.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),void 0!==e&&(n|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(e),this.depthMask.set(!0)),void 0!==i&&(n|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.clear(n)}setCullFace(t){!1===t.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)}setStencilMode(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)}setColorMode(t){c(t.blendFunction,_f.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}class bf extends he{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Id(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=null,this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new fd}onAdd(t){this.map=t,this._minTileCacheSize=t?t._minTileCacheSize:null,this._maxTileCacheSize=t?t._maxTileCacheSize:null}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t,(()=>{}))}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t,(()=>{}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager)}}getIds(){return E(this._tiles).map((t=>t.tileID)).sort(wf).map((t=>t.key))}getRenderableIds(t){const e=[];for(const i in this._tiles)this._isIdRenderable(+i,t)&&e.push(this._tiles[i]);return t?e.sort(((t,e)=>{const i=t.tileID,r=e.tileID,n=new o(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),s=new o(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-r.overscaledZ||s.y-n.y||s.x-n.x})).map((t=>t.tileID.key)):e.map((t=>t.tileID)).sort(wf).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,r){if(r)if(t.state="errored",404!==r.status)this._source.fire(new ce(r,{tile:t}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform);else t.timeAdded=J.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new le("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let r=0;r<e.length;r++){const n=e[r];if(t.neighboringTiles&&t.neighboringTiles[n]){const e=this.getTileByID(n);i(t,e),i(e,t)}}function i(t,e){if(!t.dem||t.dem.borderReady)return;t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0;let i=e.tileID.canonical.x-t.tileID.canonical.x;const r=e.tileID.canonical.y-t.tileID.canonical.y,n=Math.pow(2,t.tileID.canonical.z),s=e.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)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,r),t.neighboringTiles&&t.neighboringTiles[s]&&(t.neighboringTiles[s].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,r){for(const n in this._tiles){let s=this._tiles[n];if(r[n]||!s.hasData()||s.tileID.overscaledZ<=e||s.tileID.overscaledZ>i)continue;let o=s.tileID;for(;s&&s.tileID.overscaledZ>e+1;){const t=s.tileID.scaledTo(s.tileID.overscaledZ-1);s=this._tiles[t.key],s&&s.hasData()&&(o=t)}let a=o;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){r[o.key]=o;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),r=this._getLoadedTile(e);if(r)return r}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,r=Math.ceil(t.height/e)+1,n=Math.floor(i*r*5),s="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,n):n,o="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,s):s;this._cache.setMaxSize(o)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+e),t[r.tileID.key]=r}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new Zp(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(r=t.coveringTiles({tileSize:e||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((t=>this._source.hasTile(t))))):r=[];const n=this._updateRetainedTiles(r);if(Tf(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(n);for(const r of i){const i=n[r],s=this._tiles[r];if(!s||s.fadeEndTime&&s.fadeEndTime<=J.now())continue;const o=this.findLoadedParent(i,Math.max(i.overscaledZ-bf.maxOverzooming,this._source.minzoom));o&&(this._addTile(o.tileID),t[o.tileID.key]=o.tileID),e[r]=i}const s=r[r.length-1].overscaledZ;for(const t in this._tiles){const i=this._tiles[t];if(n[t]||!i.hasData())continue;let r=i.tileID;for(;r.overscaledZ>s;){r=r.scaledTo(r.overscaledZ-1);const s=this._tiles[r.key];if(s&&s.hasData()&&e[r.key]){n[t]=i.tileID;break}}}for(const e in t)n[e]||(this._coveredTiles[e]=!0,n[e]=t[e])}for(const t in n)this._tiles[t].clearFadeHold();const s=function(t,e){const i=[];for(const r in t)r in e||i.push(r);return i}(this._tiles,n);for(const t of s){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},r=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),n=t[0].overscaledZ,s=Math.max(n-bf.maxOverzooming,this._source.minzoom),o=Math.max(n+bf.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||r<this._source.maxzoom&&(a[i.key]=i)}this._retainLoadedChildren(a,r,o,e);for(const r of t){let t=this._tiles[r.key];if(t.hasData())continue;if(r.canonical.z>=this._source.maxzoom){const t=r.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=r.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let n=t.wasRequested();for(let o=r.overscaledZ-1;o>=s;--o){const s=r.scaledTo(o);if(i[s.key])break;if(i[s.key]=!0,t=this.getTile(s),!t&&n&&(t=this._addTile(s)),t&&(e[s.key]=s,n=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,r=this._tiles[t].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}e.push(r.key);const t=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;r=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null,r="raster"===this._source.type||"raster-dem"===this._source.type;e=new dd(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,i,r),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new le("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);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(t,e,i){const r=[],n=this.transform;if(!n)return r;for(const s in this._tiles){const o=this._tiles[s];if(i&&o.clearQueryDebugViz(),o.holdingForFade())continue;const a=t.containsTile(o,n,e);a&&r.push(a)}return r}getVisibleCoordinates(t){const e=this.getRenderableIds(t).map((t=>this._tiles[t].tileID));for(const t of e)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped());return e}hasTransition(){if(this._source.hasTransition())return!0;if(Tf(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=J.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const r=this._tiles[t];r&&r.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){const i=new Map,r=Array.isArray(t)?t:[t],n=this.map.painter.terrain,s=this.usedForTerrain&&n?n.getScaledDemTileSize():this._source.tileSize;for(const t of r){const e=t.coveringTiles({tileSize:s,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}const o=Array.from(i.values()),a="raster"===this._source.type||"raster-dem"===this._source.type;T(o,((t,e)=>{const i=new dd(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,a);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function wf(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap<0),r=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||r-i||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function Tf(t){return"raster"===t||"image"===t||"video"===t}bf.maxOverzooming=10,bf.maxUnderzooming=3;class Ef{constructor(t,e,i){this._demTile=t,this._dem=this._demTile.dem,this._scale=e,this._offset=i}static create(t,e,i){const r=i||t.findDEMTileFor(e);if(!r||!r.dem)return;const n=r.dem,s=r.tileID,o=1<<e.canonical.z-s.canonical.z;return new Ef(r,r.tileSize/la/o,[(e.canonical.x/o-s.canonical.x)*n.dim,(e.canonical.y/o-s.canonical.y)*n.dim])}tileCoordToPixel(t,e){const i=e*this._scale+this._offset[1],r=Math.floor(t*this._scale+this._offset[0]),n=Math.floor(i);return new o(r,n)}getElevationAt(t,e,i,r){const n=t*this._scale+this._offset[0],s=e*this._scale+this._offset[1],o=Math.floor(n),a=Math.floor(s),l=this._dem;return r=!!r,i?Ai(Ai(l.get(o,a,r),l.get(o,a+1,r),s-a),Ai(l.get(o+1,a,r),l.get(o+1,a+1,r),s-a),n-o):l.get(o,a,r)}getElevationAtPixel(t,e,i){return this._dem.get(t,e,!!i)}getMeterToDEM(t){return(1<<this._demTile.tileID.canonical.z)*_a(1,t)*this._dem.stride}}function If(t,e,i,r,n){return B(t,((t,s)=>{const o=e instanceof xs?e.get(s):null;return o&&o.evaluate?o.evaluate(i,r,n):o}))}function Sf(t,e){return e-t}Fn(class{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new Bn(la,16,0),this.featureIndexArray=new _o,this.promoteId=e}insert(t,e,i,r,n,s=0){const o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,n,s);const a=this.grid;for(let t=0;t<e.length;t++){const i=e[t],r=[1/0,1/0,-1/0,-1/0];for(let t=0;t<i.length;t++){const e=i[t];r[0]=Math.min(r[0],e.x),r[1]=Math.min(r[1],e.y),r[2]=Math.max(r[2],e.x),r[3]=Math.max(r[3],e.y)}r[0]<la&&r[1]<la&&r[2]>=0&&r[3]>=0&&a.insert(o,r[0],r[1],r[2],r[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new nh.VectorTile(new qh(this.rawTileData)).layers,this.sourceLayerCoder=new Qp(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[]}return this.vtLayers}query(t,e,i,r){this.loadVTLayers();const n=t.params||{},s=Hr(n.filter),o=t.tileResult,a=t.transform,l=o.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,r)=>Na(o.bufferedTilespaceGeometry,t,e,i,r)));c.sort(Sf);let h=null;a.elevation&&c.length>0&&(h=Ef.create(a.elevation,this.tileID));const u={};let p;for(let a=0;a<c.length;a++){const l=c[a];if(l===p)continue;p=l;const d=this.featureIndexArray.get(l);let f=null;this.loadMatchingFeature(u,d,s,n.layers,n.availableImages,e,i,r,((e,i,r,n=0)=>(f||(f=Aa(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(o,e,r,f,this.z,t.transform,t.pixelPosMatrix,h,n))))}return u}loadMatchingFeature(t,e,i,r,n,s,o,a,l){const{featureIndex:c,bucketIndex:h,sourceLayerIndex:u,layoutVertexArrayOffset:p}=e,d=this.bucketLayerIDs[h];if(r&&!function(t,e){for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>=0)return!0;return!1}(r,d))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=za(m,!0);if(!i.filter(new us(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new us(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e<d.length;e++){const i=d[e];if(r&&r.indexOf(i)<0)continue;const h=s[i];if(!h)continue;let u={};void 0!==_&&a&&(u=a.getState(h.sourceLayer||"_geojsonTileLayer",_));const f=I({},o[i]);f.paint=If(f.paint,h.paint,m,u,n),f.layout=If(f.layout,h.layout,m,u,n);const g=!l||l(m,h,u,p);if(!g)continue;const y=new ed(m,this.z,this.x,this.y,_);y.layer=f;let x=t[i];void 0===x&&(x=t[i]=[]),x.push({featureIndex:c,feature:y,intersectionZ:g})}}lookupSymbolFeatures(t,e,i,r,n,s,o,a){const l={};this.loadVTLayers();const c=Hr(n);for(const n of t)this.loadMatchingFeature(l,{bucketIndex:i,sourceLayerIndex:r,featureIndex:n,layoutVertexArrayOffset:0},c,s,o,a,e);return l}loadFeature(t){const{featureIndex:e,sourceLayerIndex:i}=t;this.loadVTLayers();const r=this.sourceLayerCoder.decode(i),n=this.vtFeatures[r];if(n[e])return n[e];const s=this.vtLayers[r].feature(e);return n[e]=s,s}hasLayer(t){for(const e of this.bucketLayerIDs)for(const i of e)if(t===i)return!0;return!1}getId(t,e){let i=t.id;return this.promoteId&&(i=t.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[e]],"boolean"==typeof i&&(i=Number(i))),i}},{omit:["rawTileData","sourceLayerCoder"]}),Fn(class{constructor(t){const e={},i=[];for(const r in t){const n=t[r],s=e[r]={};for(const t in n.glyphs){const e=n.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const r=e.metrics.localGlyph?2:1,o={x:0,y:0,w:e.bitmap.width+2*r,h:e.bitmap.height+2*r};i.push(o),s[t]=o}}const{w:r,h:n}=du(i),s=new tc({width:r||1,height:n||1});for(const i in t){const r=t[i];for(const t in r.glyphs){const n=r.glyphs[+t];if(!n||0===n.bitmap.width||0===n.bitmap.height)continue;const o=e[i][t],a=n.metrics.localGlyph?2:1;tc.copy(n.bitmap,s,{x:0,y:0},{x:o.x+a,y:o.y+a},n.bitmap)}}this.image=s,this.positions=e}});class Af{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,r){const n=this.entries[t]=this.entries[t]||{callbacks:[]};if(n.result){const[t,i]=n.result;return this.scheduler?this.scheduler.add((()=>{r(t,i)}),e):r(t,i),()=>{}}return n.callbacks.push(r),n.cancel||(n.cancel=i(((i,r)=>{n.result=[i,r];for(const t of n.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,r)}),e):t(i,r);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{n.result||(n.callbacks=n.callbacks.filter((t=>t!==r)),n.callbacks.length||(n.cancel(),delete this.entries[t]))}}}function zf(t,e,i){const r=JSON.stringify(t.request);return t.data&&(this.deduped.entries[r]={result:[null,t.data]}),this.deduped.request(r,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const r=Jt(t.request,((t,r,n,s)=>{t?e(t):r&&e(null,{vectorTile:i?void 0:new nh.VectorTile(new qh(r)),rawData:r,cacheControl:n,expires:s})}));return()=>{r.cancel(),e()}}),e)}class Cf extends he{constructor(t,e,i,r){super(),this.id=t,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=I({type:"raster"},e),I(this,S(e,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new le("dataloading",{dataType:"source"})),this._tileJSONRequest=Yp(this._options,this.map._requestManager,((t,e)=>{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new ce(t)):e&&(I(this,e),e.bounds&&(this.tileBounds=new Jp(e.bounds,this.minzoom,this.maxzoom)),kt(e.tiles),this.fire(new le("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new le("data",{dataType:"source",sourceDataType:"content"})))}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return I({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t,e){const i=J.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),i,this.tileSize);t.request=se(this.map._requestManager.transformRequest(r,Wt.Tile),((i,r,n,s)=>{if(delete t.request,t.aborted)t.state="unloaded",e(null);else if(i)t.state="errored",e(i);else if(r){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:n,expires:s});const i=this.map.painter.context,o=i.gl;t.texture=this.map.painter.getTileTexture(r.width),t.texture?t.texture.update(r,{useMipmap:!0}):(t.texture=new qu(i,r,o.RGBA,{useMipmap:!0}),t.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE),i.extTextureFilterAnisotropic&&o.texParameterf(o.TEXTURE_2D,i.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,i.extTextureFilterAnisotropicMax)),t.state="loaded",$t(this.dispatcher),e(null)}}))}abortTile(t,e){t.request&&(t.request.cancel(),delete t.request),e()}unloadTile(t,e){t.texture&&this.map.painter.saveTileTexture(t.texture),e()}hasTransition(){return!1}}let Mf;function kf(t,e,i,r,n,s,o,a){const l=[t,i,n,e,r,s,1,1,1],c=[o,a,1],h=tl([],l),[u,p,d]=Ml(c,c,function(t,e){if(t===e){var i=e[1],r=e[2],n=e[5];t[1]=e[3],t[2]=e[6],t[3]=i,t[5]=e[7],t[6]=r,t[7]=n}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t}(h,h));return el(l,[u,0,0,0,p,0,0,0,d],l)}class Pf extends he{constructor(t,e,i,r){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=e}load(t){this._loaded=!1,this.fire(new le("dataloading",{dataType:"source"})),this.url=this.options.url,se(this.map._requestManager.transformRequest(this.url,Wt.Image),((e,i)=>{if(this._loaded=!0,e)this.fire(new ce(e));else if(i){const{HTMLImageElement:e}=l;this.image=i instanceof e?J.getImageData(i):i,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading()}}))}loaded(){return this._loaded}updateImage(t){return this.image&&t.url?(this.options.url=t.url,this.load(t.coordinates),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new le("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this.texture&&this.texture.destroy()}setCoordinates(t){this.coordinates=t,this._boundsArray=void 0;const e=t.map(ba.fromLngLat);return this.tileID=function(t){let e=1/0,i=1/0,r=-1/0,n=-1/0;for(const s of t)e=Math.min(e,s.x),i=Math.min(i,s.y),r=Math.max(r,s.x),n=Math.max(n,s.y);const s=Math.max(r-e,n-i),o=Math.max(0,Math.floor(-Math.log(s)/Math.LN2)),a=Math.pow(2,o);return new Up(o,Math.floor((e+r)/2*a),Math.floor((i+n)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new le("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(t){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray)return;const e=Gp(this.tileID,this.map.transform.projection),[i,r,n,s]=this.coordinates.map((t=>{const i=e.projection.project(t[0],t[1]);return Wp(e,i)._round()}));this.perspectiveTransform=function(t,e,i,r,n,s,o,a,l,c){const h=kf(0,0,t,0,0,e,t,e),u=kf(i,r,n,s,o,a,l,c);return el(u,tl(h,h),u),[u[6]/u[8]*t/la,u[7]/u[8]*e/la]}(this.width,this.height,i.x,i.y,r.x,r.y,s.x,s.y,n.x,n.y);const o=this._boundsArray=new Bs;o.emplaceBack(i.x,i.y,0,0),o.emplaceBack(r.x,r.y,la,0),o.emplaceBack(s.x,s.y,0,la),o.emplaceBack(n.x,n.y,la,la),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=t.createVertexBuffer(o,ud.members),this.boundsSegments=aa.simpleSegment(0,0,4,2)}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const t=this.map.painter.context,e=t.gl;this.texture?this.texture.update(this.image):(this.texture=new qu(t,this.image,e.RGBA),this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE)),this._prepareData(t)}loadTile(t,e){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={},e(null)):(t.state="errored",e(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const Df={vector:class extends he{constructor(t,e,i,r){if(super(),this.id=t,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,I(this,S(e,["url","scheme","tileSize","promoteId"])),this._options=I({type:"vector"},e),this._collectResourceTiming=e.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r),this._tileWorkers={},this._deduped=new Af}load(){this._loaded=!1,this.fire(new le("dataloading",{dataType:"source"})),this._tileJSONRequest=Yp(this._options,this.map._requestManager,((t,e)=>{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new ce(t)):e&&(I(this,e),e.bounds&&(this.tileBounds=new Jp(e.bounds,this.minzoom,this.maxzoom)),kt(e.tiles,this.map._requestManager._customAccessToken),this.fire(new le("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new le("data",{dataType:"source",sourceDataType:"content"})))}))}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.cancel(),t();const e=this.map.style._getSourceCaches(this.id);for(const t of e)t.clearTiles();this.load()}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return I({},this._options)}loadTile(t,e){const i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(i,Wt.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:J.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:t.isSymbolTile};if(r.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=e:t.request=t.actor.send("reloadTile",r,n.bind(this));else if(t.actor=this._tileWorkers[i]=this._tileWorkers[i]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send("loadTile",r,n.bind(this),void 0,!0);else{const e=zf.call({deduped:this._deduped},r,((e,i)=>{e||!i?n.call(this,e):(r.data={cacheControl:i.cacheControl,expires:i.expires,rawData:i.rawData.slice(0)},t.actor&&t.actor.send("loadTile",r,n.bind(this),void 0,!0))}),!0);t.request={cancel:e}}function n(i,r){return delete t.request,t.aborted?e(null):i&&404!==i.status?e(i):(r&&r.resourceTiming&&(t.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&t.setExpiryData(r),t.loadVectorData(r,this.map.painter),$t(this.dispatcher),e(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.actor&&t.actor.send("abortTile",{uid:t.uid,type:this.type,source:this.id})}unloadTile(t){t.unloadVectorData(),t.actor&&t.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:Cf,"raster-dem":class extends Cf{constructor(t,e,i,r){super(t,e,i,r),this.type="raster-dem",this.maxzoom=22,this._options=I({type:"raster-dem"},e),this.encoding=e.encoding||"mapbox"}loadTile(t,e){const i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function r(i,r){i&&(t.state="errored",e(i)),r&&(t.dem=r,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state="loaded",e(null))}t.request=se(this.map._requestManager.transformRequest(i,Wt.Tile),function(i,n,s,o){if(delete t.request,t.aborted)t.state="unloaded",e(null);else if(i)t.state="errored",e(i);else if(n){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:s,expires:o});const e=l.ImageBitmap&&n instanceof l.ImageBitmap&&(null==Mf&&(Mf=l.OffscreenCanvas&&new l.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof l.createImageBitmap),Mf),i=1-(n.width-((a=n.width)<=1?1:Math.pow(2,Math.floor(Math.log(a)/Math.LN2))))/2;i<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));const c=e?n:J.getImageData(n,i),h={uid:t.uid,coord:t.tileID,source:this.id,rawImageData:c,encoding:this.encoding,padding:i};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",h,r.bind(this),void 0,!0))}var a}.bind(this))}_getNeighboringTiles(t){const e=t.canonical,i=Math.pow(2,e.z),r=(e.x-1+i)%i,n=0===e.x?t.wrap-1:t.wrap,s=(e.x+1+i)%i,o=e.x+1===i?t.wrap+1:t.wrap,a={};return a[new Zp(t.overscaledZ,n,e.z,r,e.y).key]={backfilled:!1},a[new Zp(t.overscaledZ,o,e.z,s,e.y).key]={backfilled:!1},e.y>0&&(a[new Zp(t.overscaledZ,n,e.z,r,e.y-1).key]={backfilled:!1},a[new Zp(t.overscaledZ,t.wrap,e.z,e.x,e.y-1).key]={backfilled:!1},a[new Zp(t.overscaledZ,o,e.z,s,e.y-1).key]={backfilled:!1}),e.y+1<i&&(a[new Zp(t.overscaledZ,n,e.z,r,e.y+1).key]={backfilled:!1},a[new Zp(t.overscaledZ,t.wrap,e.z,e.x,e.y+1).key]={backfilled:!1},a[new Zp(t.overscaledZ,o,e.z,s,e.y+1).key]={backfilled:!1}),a}unloadTile(t){t.demTexture&&this.map.painter.saveTileTexture(t.demTexture),t.fbo&&(t.fbo.destroy(),delete t.fbo),t.dem&&delete t.dem,delete t.neighboringTiles,t.state="unloaded"}},geojson:class extends he{constructor(t,e,i,r){super(),this.id=t,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=e.data,this._options=I({},e),this._collectResourceTiming=e.collectResourceTiming,void 0!==e.maxzoom&&(this.maxzoom=e.maxzoom),e.type&&(this.type=e.type),e.attribution&&(this.attribution=e.attribution),this.promoteId=e.promoteId;const n=la/this.tileSize;this.workerOptions=I({source:this.id,cluster:e.cluster||!1,geojsonVtOptions:{buffer:(void 0!==e.buffer?e.buffer:128)*n,tolerance:(void 0!==e.tolerance?e.tolerance:.375)*n,extent:la,maxZoom:this.maxzoom,lineMetrics:e.lineMetrics||!1,generateId:e.generateId||!1},superclusterOptions:{maxZoom:void 0!==e.clusterMaxZoom?e.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,e.clusterMinPoints||2),extent:la,radius:(void 0!==e.clusterRadius?e.clusterRadius:50)*n,log:!1,generateId:e.generateId||!1},clusterProperties:e.clusterProperties,filter:e.filter},e.workerOptions)}onAdd(t){this.map=t,this.setData(this._data)}setData(t){return this._data=t,this._updateWorkerData(),this}getClusterExpansionZoom(t,e){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:t,source:this.id},e),this}getClusterChildren(t,e){return this.actor.send("geojson.getClusterChildren",{clusterId:t,source:this.id},e),this}getClusterLeaves(t,e,i,r){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:t,limit:e,offset:i},r),this}_updateWorkerData(){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new le("dataloading",{dataType:"source"})),this._loaded=!1;const t=I({},this.workerOptions),e=this._data;"string"==typeof e?(t.request=this.map._requestManager.transformRequest(J.resolveURL(e),Wt.Source),t.request.collectResourceTiming=this._collectResourceTiming):t.data=JSON.stringify(e),this._pendingLoad=this.actor.send(`${this.type}.loadData`,t,((t,e)=>{if(this._loaded=!0,this._pendingLoad=null,t)this.fire(new ce(t));else{const t={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&e&&e.resourceTiming&&e.resourceTiming[this.id]&&(t.resourceTiming=e.resourceTiming[this.id]),this.fire(new le("data",t)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)}))}loaded(){return this._loaded}loadTile(t,e){const i=t.actor?"reloadTile":"loadTile";t.actor=this.actor,t.request=this.actor.send(i,{type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:J.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},((r,n)=>(delete t.request,t.unloadVectorData(),t.aborted?e(null):r?e(r):(t.loadVectorData(n,this.map.painter,"reloadTile"===i),e(null)))),void 0,"loadTile"===i)}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.aborted=!0}unloadTile(t){t.unloadVectorData(),this.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return I({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends Pf{constructor(t,e,i,r){super(t,e,i,r),this.roundZoom=!0,this.type="video",this.options=e}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const e of t.urls)this.urls.push(this.map._requestManager.transformRequest(e,Wt.Source).url);!function(t,e){const i=l.document.createElement("video");i.muted=!0,i.onloadstart=function(){e(null,i)};for(let e=0;e<t.length;e++){const r=l.document.createElement("source");ee(t[e])||(i.crossOrigin="Anonymous"),r.src=t[e],i.appendChild(r)}}(this.urls,((t,e)=>{this._loaded=!0,t?this.fire(new ce(t)):e&&(this.video=e,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(t){if(this.video){const e=this.video.seekable;t<e.start(0)||t>e.end(0)?this.fire(new ce(new jr(`sources.${this.id}`,null,`Playback for this video can be set only between the ${e.start(0)} and ${e.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,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 t=this.map.painter.context,e=t.gl;this.texture?this.video.paused||(this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE),e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,this.video)):(this.texture=new qu(t,this.video,e.RGBA),this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:Pf,canvas:class extends Pf{constructor(t,e,i,r){super(t,e,i,r),e.coordinates?Array.isArray(e.coordinates)&&4===e.coordinates.length&&!e.coordinates.some((t=>!Array.isArray(t)||2!==t.length||t.some((t=>"number"!=typeof t))))||this.fire(new ce(new jr(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new ce(new jr(`sources.${t}`,null,'missing required property "coordinates"'))),e.animate&&"boolean"!=typeof e.animate&&this.fire(new ce(new jr(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),e.canvas?"string"==typeof e.canvas||e.canvas instanceof l.HTMLCanvasElement||this.fire(new ce(new jr(`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 ce(new jr(`sources.${t}`,null,'missing required property "canvas"'))),this.options=e,this.animate=void 0===e.animate||e.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof l.HTMLCanvasElement?this.options.canvas:l.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new ce(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(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const e=this.map.painter.context;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new qu(e,this.canvas,e.gl.RGBA,{premultiply:!0}),this._prepareData(e)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}}},Bf=function(t,e,i,r){const n=new Df[e.type](t,e,i,r);if(n.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${n.id}`);return P(["load","abort","unload","serialize","prepare"],n),n};function Lf(t,e){const i=rl([]);return al(i,i,[.5*t.width,.5*-t.height,1]),ol(i,i,[1,-1,0]),sl(i,i,t.calculateProjMatrix(e.toUnwrapped())),Float32Array.from(i)}function Rf(t,e,i,r,n,s,o,a=!1){const l=t.tilesIn(r,o,a);l.sort(Of);const c=[];for(const r of l)c.push({wrappedTileID:r.tile.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(e,i,t._state,r,n,s,Lf(t.transform,r.tile.tileID),a)});const h=function(t){const e={},i={};for(const r of t){const t=r.queryResults,n=r.wrappedTileID,s=i[n]=i[n]||{};for(const i in t){const r=t[i],n=s[i]=s[i]||{},o=e[i]=e[i]||[];for(const t of r)n[t.featureIndex]||(n[t.featureIndex]=!0,o.push(t))}}return e}(c);for(const e in h)h[e].forEach((e=>{const i=e.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?t.getFeatureState(r["source-layer"],i.id):{})}));return h}function Ff(t,e){const i=t.getRenderableIds().map((e=>t.getTileByID(e))),r=[],n={};for(let t=0;t<i.length;t++){const s=i[t],o=s.tileID.canonical.key;n[o]||(n[o]=!0,s.querySourceFeatures(r,e))}return r}function Of(t,e){const i=t.tileID,r=e.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function Vf(){return null!=kx.workerClass?new kx.workerClass:new l.Worker(kx.workerUrl)}const jf="mapboxgl_preloaded_worker_pool";class Uf{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<Uf.workerCount;)this.workers.push(new Vf);return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],0===this.numActive()&&(this.workers.forEach((t=>{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[jf]}numActive(){return Object.keys(this.active).length}}let Nf;function Zf(){return Nf||(Nf=new Uf),Nf}Uf.workerCount=2;var qf=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function Gf(t,e){const i={};for(const e in t)"ref"!==e&&(i[e]=t[e]);return qf.forEach((t=>{t in e&&(i[t]=e[t])})),i}function $f(t){t=t.slice();const e=Object.create(null);for(let i=0;i<t.length;i++)e[t[i].id]=t[i];for(let i=0;i<t.length;i++)"ref"in t[i]&&(t[i]=Gf(t[i],e[t[i].ref]));return t}const Wf={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 Xf(t,e,i){i.push({command:Wf.addSource,args:[t,e[t]]})}function Hf(t,e,i){e.push({command:Wf.removeSource,args:[t]}),i[t]=!0}function Kf(t,e,i,r){Hf(t,i,r),Xf(t,e,i)}function Yf(t,e,i){let r;for(r in t[i])if(t[i].hasOwnProperty(r)&&"data"!==r&&!c(t[i][r],e[i][r]))return!1;for(r in e[i])if(e[i].hasOwnProperty(r)&&"data"!==r&&!c(t[i][r],e[i][r]))return!1;return!0}function Jf(t,e,i,r,n,s){let o;for(o in e=e||{},t=t||{})t.hasOwnProperty(o)&&(c(t[o],e[o])||i.push({command:s,args:[r,o,e[o],n]}));for(o in e)e.hasOwnProperty(o)&&!t.hasOwnProperty(o)&&(c(t[o],e[o])||i.push({command:s,args:[r,o,e[o],n]}))}function Qf(t){return t.id}function tm(t,e){return t[e.id]=e,t}class em{constructor(t,e){this.reset(t,e)}reset(t,e){this.points=t||[],this._distances=[0];for(let t=1;t<this.points.length;t++)this._distances[t]=this._distances[t-1]+this.points[t].dist(this.points[t-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(e||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(1===this.points.length)return this.points[0];t=v(t,0,1);let e=1,i=this._distances[e];const r=t*this.paddedLength+this.padding;for(;i<r&&e<this._distances.length;)i=this._distances[++e];const n=e-1,s=this._distances[n],o=i-s,a=o>0?(r-s)/o:0;return this.points[n].mult(1-a).add(this.points[e].mult(a))}}class im{constructor(t,e,i){const r=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(t/i),this.yCellCount=Math.ceil(e/i);for(let t=0;t<this.xCellCount*this.yCellCount;t++)r.push([]),n.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=t,this.height=e,this.xScale=this.xCellCount/t,this.yScale=this.yCellCount/e,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(t,e,i,r,n){this._forEachCell(e,i,r,n,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)}insertCircle(t,e,i,r){this._forEachCell(e-r,i-r,e+r,i+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(e),this.circles.push(i),this.circles.push(r)}_insertBoxCell(t,e,i,r,n,s){this.boxCells[n].push(s)}_insertCircleCell(t,e,i,r,n,s){this.circleCells[n].push(s)}_query(t,e,i,r,n,s){if(i<0||t>this.width||r<0||e>this.height)return!n&&[];const o=[];if(t<=0&&e<=0&&this.width<=i&&this.height<=r){if(n)return!0;for(let t=0;t<this.boxKeys.length;t++)o.push({key:this.boxKeys[t],x1:this.bboxes[4*t],y1:this.bboxes[4*t+1],x2:this.bboxes[4*t+2],y2:this.bboxes[4*t+3]});for(let t=0;t<this.circleKeys.length;t++){const e=this.circles[3*t],i=this.circles[3*t+1],r=this.circles[3*t+2];o.push({key:this.circleKeys[t],x1:e-r,y1:i-r,x2:e+r,y2:i+r})}return s?o.filter(s):o}return this._forEachCell(t,e,i,r,this._queryCell,o,{hitTest:n,seenUids:{box:{},circle:{}}},s),n?o.length>0:o}_queryCircle(t,e,i,r,n){const s=t-i,o=t+i,a=e-i,l=e+i;if(o<0||s>this.width||l<0||a>this.height)return!r&&[];const c=[];return this._forEachCell(s,a,o,l,this._queryCellCircle,c,{hitTest:r,circle:{x:t,y:e,radius:i},seenUids:{box:{},circle:{}}},n),r?c.length>0:c}query(t,e,i,r,n){return this._query(t,e,i,r,!1,n)}hitTest(t,e,i,r,n){return this._query(t,e,i,r,!0,n)}hitTestCircle(t,e,i,r){return this._queryCircle(t,e,i,!0,r)}_queryCell(t,e,i,r,n,s,o,a){const l=o.seenUids,c=this.boxCells[n];if(null!==c){const n=this.bboxes;for(const h of c)if(!l.box[h]){l.box[h]=!0;const c=4*h;if(t<=n[c+2]&&e<=n[c+3]&&i>=n[c+0]&&r>=n[c+1]&&(!a||a(this.boxKeys[h]))){if(o.hitTest)return s.push(!0),!0;s.push({key:this.boxKeys[h],x1:n[c],y1:n[c+1],x2:n[c+2],y2:n[c+3]})}}}const h=this.circleCells[n];if(null!==h){const n=this.circles;for(const c of h)if(!l.circle[c]){l.circle[c]=!0;const h=3*c;if(this._circleAndRectCollide(n[h],n[h+1],n[h+2],t,e,i,r)&&(!a||a(this.circleKeys[c]))){if(o.hitTest)return s.push(!0),!0;{const t=n[h],e=n[h+1],i=n[h+2];s.push({key:this.circleKeys[c],x1:t-i,y1:e-i,x2:t+i,y2:e+i})}}}}}_queryCellCircle(t,e,i,r,n,s,o,a){const l=o.circle,c=o.seenUids,h=this.boxCells[n];if(null!==h){const t=this.bboxes;for(const e of h)if(!c.box[e]){c.box[e]=!0;const i=4*e;if(this._circleAndRectCollide(l.x,l.y,l.radius,t[i+0],t[i+1],t[i+2],t[i+3])&&(!a||a(this.boxKeys[e])))return s.push(!0),!0}}const u=this.circleCells[n];if(null!==u){const t=this.circles;for(const e of u)if(!c.circle[e]){c.circle[e]=!0;const i=3*e;if(this._circlesCollide(t[i],t[i+1],t[i+2],l.x,l.y,l.radius)&&(!a||a(this.circleKeys[e])))return s.push(!0),!0}}}_forEachCell(t,e,i,r,n,s,o,a){const l=this._convertToXCellCoord(t),c=this._convertToYCellCoord(e),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r);for(let p=l;p<=h;p++)for(let l=c;l<=u;l++)if(n.call(this,t,e,i,r,this.xCellCount*l+p,s,o,a))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,e,i,r,n,s){const o=r-t,a=n-e,l=i+s;return l*l>o*o+a*a}_circleAndRectCollide(t,e,i,r,n,s,o){const a=(s-r)/2,l=Math.abs(t-(r+a));if(l>a+i)return!1;const c=(o-n)/2,h=Math.abs(e-(n+c));if(h>c+i)return!1;if(l<=a||h<=c)return!0;const u=l-a,p=h-c;return u*u+p*p<=i*i}}const rm=Math.tan(85*Math.PI/180);function nm(t,e,i,r,n,s){const o=il();if(i){if("globe"===n.projection.name)sl(o,o,function(t,e){const{lng:i,lat:r}=t._center,n=Mp(0,0,t.worldSize/t._projectionScaler,i,r);return sl(n,n,Ap(xp(e)))}(n,e));else{const t=Ja([],s);o[0]=t[0],o[1]=t[1],o[4]=t[2],o[5]=t[3]}r||hl(o,o,n.angle)}else sl(o,n.labelPlaneMatrix,t);return o}function sm(t,e,i,r,n,s){if(i){if("globe"===n.projection.name){const o=nm(t,e,i,r,n,s);return nl(o,o),sl(o,t,o),o}{const e=(o=t,(a=new Ya(16))[0]=o[0],a[1]=o[1],a[2]=o[2],a[3]=o[3],a[4]=o[4],a[5]=o[5],a[6]=o[6],a[7]=o[7],a[8]=o[8],a[9]=o[9],a[10]=o[10],a[11]=o[11],a[12]=o[12],a[13]=o[13],a[14]=o[14],a[15]=o[15],a),i=rl([]);return i[0]=s[0],i[1]=s[1],i[4]=s[2],i[5]=s[3],sl(e,e,i),r||hl(e,e,-n.angle),e}}return n.glCoordMatrix;var o,a}function om(t,e,i=0){const r=[t.x,t.y,i,1];i?Ol(r,r,e):xm(r,r,e);const n=r[3];return{point:new o(r[0]/n,r[1]/n),signedDistanceFromCamera:n}}function am(t,e){const i=[t[0],t[1],t[2],1];Ol(i,i,e);const r=i[3];return{point:new o(i[0]/r,i[1]/r),signedDistanceFromCamera:r}}function lm(t,e){return Math.min(.5+t/e*.5,1.5)}function cm(t,e){const i=t[0]/t[3],r=t[1]/t[3];return i>=-e[0]&&i<=e[0]&&r>=-e[1]&&r<=e[1]}function hm(t,e,i,r,n,s,a,l,c,h){const u=i.transform,p=r?t.textSizeData:t.iconSizeData,d=Oh(p,i.transform.zoom),f=[256/i.width*2+1,256/i.height*2+1],m=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;m.clear();const _=t.lineVertexArray,g=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,y=i.transform.width/i.transform.height;let x=!1;for(let r=0;r<g.length;r++){const v=g.get(r);if(v.writingMode!==mu.vertical||x||0!==r&&g.get(r-1).writingMode===mu.horizontal||(x=!0),(v.hidden||v.writingMode===mu.vertical)&&!x){ym(v.numGlyphs,m);continue}x=!1;const b=new o(v.tileAnchorX,v.tileAnchorY),w=c?c(b):[0,0,0],T=u.projection.projectTilePoint(b.x,b.y,h.canonical),E=[T.x+w[0],T.y+w[1],T.z+w[2]],I=[...E,1];if(Ol(I,I,e),!cm(I,f)){ym(v.numGlyphs,m);continue}const S=lm(i.transform.cameraToCenterDistance,I[3]),A=Fh(p,d,v),z=a?A/S:A*S,C=om(new o(E[0],E[1]),n,E[2]);if(C.signedDistanceFromCamera<=0){ym(v.numGlyphs,m);continue}let M={};const k=a?null:c,P=dm(v,z,!1,l,e,n,s,t.glyphOffsetArray,_,m,C.point,b,M,y,k,u.projection,h);x=P.useVertical,k&&P.needsFlipping&&(M={}),(P.notEnoughRoom||x||P.needsFlipping&&dm(v,z,!0,l,e,n,s,t.glyphOffsetArray,_,m,C.point,b,M,y,k,u.projection,h).notEnoughRoom)&&ym(v.numGlyphs,m)}r?t.text.dynamicLayoutVertexBuffer.updateData(m):t.icon.dynamicLayoutVertexBuffer.updateData(m)}function um(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f){const m=a.glyphStartIndex+a.numGlyphs,_=a.lineStartIndex,g=a.lineStartIndex+a.lineLength,y=e.getoffsetX(a.glyphStartIndex),x=e.getoffsetX(m-1),v=_m(t*y,i,r,n,s,o,a.segment,_,g,l,c,h,u,p,!0,d,f);if(!v)return null;const b=_m(t*x,i,r,n,s,o,a.segment,_,g,l,c,h,u,p,!0,d,f);return b?{first:v,last:b}:null}function pm(t,e,i,r){return t.writingMode===mu.horizontal&&Math.abs(i.y-e.y)>Math.abs(i.x-e.x)*r?{useVertical:!0}:t.writingMode===mu.vertical?e.y<i.y?{needsFlipping:!0}:null:0!==t.flipState&&function(t,e,i){const r=(e.x-t.x)*i;return 0===r||Math.abs((e.y-t.y)/r)>rm}(e,i,r)?1===t.flipState?{needsFlipping:!0}:null:e.x>i.x?{needsFlipping:!0}:null}function dm(t,e,i,r,n,s,a,l,c,h,u,p,d,f,m,_,g){const y=e/24,x=t.lineOffsetX*y,v=t.lineOffsetY*y;let b;if(t.numGlyphs>1){const e=t.glyphStartIndex+t.numGlyphs,n=t.lineStartIndex,o=t.lineStartIndex+t.lineLength,h=um(y,l,x,v,i,u,p,t,c,s,d,m,!1,_,g);if(!h)return{notEnoughRoom:!0};const w=om(h.first.point,a).point,T=om(h.last.point,a).point;if(r&&!i){const e=pm(t,w,T,f);if(t.flipState=e&&e.needsFlipping?1:2,e)return e}b=[h.first];for(let r=t.glyphStartIndex+1;r<e-1;r++)b.push(_m(y*l.getoffsetX(r),x,v,i,u,p,t.segment,n,o,c,s,d,m,!1,!1,_,g));b.push(h.last)}else{if(r&&!i){const e=om(p,n).point,i=t.lineStartIndex+t.segment+1,r=new o(c.getx(i),c.gety(i)),s=om(r,n),a=pm(t,e,s.signedDistanceFromCamera>0?s.point:mm(p,r,e,1,n,void 0,_,g.canonical),f);if(t.flipState=a&&a.needsFlipping?1:2,a)return a}const e=_m(y*l.getoffsetX(t.glyphStartIndex),x,v,i,u,p,t.segment,t.lineStartIndex,t.lineStartIndex+t.lineLength,c,s,d,m,!1,!1,_,g);if(!e)return{notEnoughRoom:!0};b=[e]}for(const t of b)zu(h,t.point,t.angle);return{}}function fm(t,e,i,r,n){const s=r.projectTilePoint(t.x,t.y,e);if(!n)return om(s,i,s.z);const a=n(t);return om(new o(s.x+a[0],s.y+a[1]),i,s.z+a[2])}function mm(t,e,i,r,n,s,o,a){const l=fm(t.add(t.sub(e)._unit()),a,n,o,s).point,c=i.sub(l);return i.add(c._mult(r/c.mag()))}function _m(t,e,i,r,n,s,a,l,c,h,u,p,d,f,m,_,g){const y=r?t-e:t+e;let x=y>0?1:-1,v=0;r&&(x*=-1,v=Math.PI),x<0&&(v+=Math.PI);let b=x>0?l+a:l+a+1,w=n,T=n,E=0,I=0;const S=Math.abs(y),A=[],z=[];let C=s;const M=()=>{const t=b-x;return 0===E?s:new o(h.getx(t),h.gety(t))},k=()=>mm(M(),C,T,S-E+1,u,d,_,g.canonical);for(;E+I<=S;){if(b+=x,b<l||b>=c)return null;if(T=w,A.push(w),f&&z.push(C||M()),w=p[b],void 0===w){C=new o(h.getx(b),h.gety(b));const t=fm(C,g.canonical,u,_,d);w=t.signedDistanceFromCamera>0?p[b]=t.point:k()}else C=null;E+=I,I=T.dist(w)}m&&d&&(C=C||new o(h.getx(b),h.gety(b)),p[b]=w=void 0===p[b]?w:k(),I=T.dist(w));const P=(S-E)/I,D=w.sub(T),B=D.mult(P)._add(T);i&&B._add(D._unit()._perp()._mult(i*x));const L=v+Math.atan2(w.y-T.y,w.x-T.x);return A.push(B),f&&(C=C||new o(h.getx(b),h.gety(b)),z.push(function(t,e,i){const r=1-i;return new o(t.x*r+e.x*i,t.y*r+e.y*i)}(z.length>0?z[z.length-1]:C,C,P))),{point:B,angle:L,path:A,tilePath:z}}const gm=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function ym(t,e){for(let i=0;i<t;i++){const t=e.length;e.resize(t+4),e.float32.set(gm,3*t)}}function xm(t,e,i){const r=e[0],n=e[1];return t[0]=i[0]*r+i[4]*n+i[12],t[1]=i[1]*r+i[5]*n+i[13],t[3]=i[3]*r+i[7]*n+i[15],t}const vm=100;class bm{constructor(t,e,i=new im(t.width+200,t.height+200,25),r=new im(t.width+200,t.height+200,25)){this.transform=t,this.grid=i,this.ignoredGrid=r,this.pitchfactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+vm,this.screenBottomBoundary=t.height+vm,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.fogState=e}placeCollisionBox(t,e,i,r,n,s,o){let a=e.projectedAnchorX,l=e.projectedAnchorY,c=e.projectedAnchorZ;const h=e.elevation,u=e.tileID;if(h&&u){const t=this.transform.projection.upVector(u.canonical,e.tileAnchorX,e.tileAnchorY),i=this.transform.projection.upVectorScale(u.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;a+=t[0]*h*i,l+=t[1]*h*i,c+=t[2]*h*i}const p=this.projectAndGetPerspectiveRatio(s,[a,l,c],e.tileID,"globe"===this.transform.projection.name||!!h||this.transform.pitch>0),d=n*p.perspectiveRatio,f=(e.x1*t+i.x-e.padding)*d+p.point.x,m=(e.y1*t+i.y-e.padding)*d+p.point.y,_=(e.x2*t+i.x+e.padding)*d+p.point.x,g=(e.y2*t+i.y+e.padding)*d+p.point.y,y=p.perspectiveRatio<=.55||p.occluded;return!this.isInsideGrid(f,m,_,g)||!r&&this.grid.hitTest(f,m,_,g,o)||y?{box:[],offscreen:!1,occluded:p.occluded}:{box:[f,m,_,g],offscreen:this.isOffscreen(f,m,_,g),occluded:!1}}placeCollisionCircles(t,e,i,r,n,s,a,l,c,h,u,p,d,f){const m=[],_=this.transform.elevation,g=_?_.getAtTileOffsetFunc(f,this.transform.center.lat,this.transform.worldSize,this.transform.projection):t=>[0,0,0],y=new o(e.tileAnchorX,e.tileAnchorY),x=this.transform.projection.projectTilePoint(e.tileAnchorX,e.tileAnchorY,f.canonical),v=g(y),b=[x.x+v[0],x.y+v[1],x.z+v[2]],w=this.projectAndGetPerspectiveRatio(s,[b[0],b[1],b[2]],f,"globe"===this.transform.projection.name||!!_||this.transform.pitch>0),{perspectiveRatio:T}=w,E=(h?n/T:n*T)/24,I=om(new o(b[0],b[1]),a,b[2]).point,S=w.signedDistanceFromCamera>0?um(E,r,e.lineOffsetX*E,e.lineOffsetY*E,!1,I,y,e,i,a,{},_&&!h?g:null,h&&!!_,this.transform.projection,f):null;let A=!1,z=!1,C=!0;if(S&&!w.occluded){const e=.5*p*T+d,i=new o(-100,-100),r=new o(this.screenRightBoundary,this.screenBottomBoundary),n=new em,s=S.first,a=S.last;let h=[];for(let t=s.path.length-1;t>=1;t--)h.push(s.path[t]);for(let t=1;t<a.path.length;t++)h.push(a.path[t]);const f=2.5*e;if(l){const t=h.map(_?(t,e)=>{const i=g(e<s.path.length-1?s.tilePath[s.path.length-1-e]:a.tilePath[e-s.path.length+2]);return om(t,l,i[2])}:t=>om(t,l));h=t.some((t=>t.signedDistanceFromCamera<=0))?[]:t.map((t=>t.point))}let y=[];if(h.length>0){const t=h[0].clone(),e=h[0].clone();for(let i=1;i<h.length;i++)t.x=Math.min(t.x,h[i].x),t.y=Math.min(t.y,h[i].y),e.x=Math.max(e.x,h[i].x),e.y=Math.max(e.y,h[i].y);y=t.x>=i.x&&e.x<=r.x&&t.y>=i.y&&e.y<=r.y?[h]:e.x<i.x||t.x>r.x||e.y<i.y||t.y>r.y?[]:function(t,e,i,r,n){const s=[];for(let a=0;a<t.length;a++){const l=t[a];let c;for(let t=0;t<l.length-1;t++){let a=l[t],h=l[t+1];a.x<e&&h.x<e||(a.x<e?a=new o(e,a.y+(e-a.x)/(h.x-a.x)*(h.y-a.y))._round():h.x<e&&(h=new o(e,a.y+(e-a.x)/(h.x-a.x)*(h.y-a.y))._round()),a.y<i&&h.y<i||(a.y<i?a=new o(a.x+(i-a.y)/(h.y-a.y)*(h.x-a.x),i)._round():h.y<i&&(h=new o(a.x+(i-a.y)/(h.y-a.y)*(h.x-a.x),i)._round()),a.x>=r&&h.x>=r||(a.x>=r?a=new o(r,a.y+(r-a.x)/(h.x-a.x)*(h.y-a.y))._round():h.x>=r&&(h=new o(r,a.y+(r-a.x)/(h.x-a.x)*(h.y-a.y))._round()),a.y>=n&&h.y>=n||(a.y>=n?a=new o(a.x+(n-a.y)/(h.y-a.y)*(h.x-a.x),n)._round():h.y>=n&&(h=new o(a.x+(n-a.y)/(h.y-a.y)*(h.x-a.x),n)._round()),c&&a.equals(c[c.length-1])||(c=[a],s.push(c)),c.push(h)))))}}return s}([h],i.x,i.y,r.x,r.y)}for(const i of y){n.reset(i,.25*e);let r=0;r=n.length<=.5*e?1:Math.ceil(n.paddedLength/f)+1;for(let i=0;i<r;i++){const s=i/Math.max(r-1,1),o=n.lerp(s),a=o.x+vm,l=o.y+vm;m.push(a,l,e,0);const h=a-e,p=l-e,d=a+e,f=l+e;if(C=C&&this.isOffscreen(h,p,d,f),z=z||this.isInsideGrid(h,p,d,f),!t&&this.grid.hitTestCircle(a,l,e,u)&&(A=!0,!c))return{circles:[],offscreen:!1,collisionDetected:A,occluded:!1}}}}return{circles:!c&&A||!z?[]:m,offscreen:C,collisionDetected:A,occluded:w.occluded}}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const e=[];let i=1/0,r=1/0,n=-1/0,s=-1/0;for(const a of t){const t=new o(a.x+vm,a.y+vm);i=Math.min(i,t.x),r=Math.min(r,t.y),n=Math.max(n,t.x),s=Math.max(s,t.y),e.push(t)}const a=this.grid.query(i,r,n,s).concat(this.ignoredGrid.query(i,r,n,s)),l={},c={};for(const t of a){const i=t.key;void 0===l[i.bucketInstanceId]&&(l[i.bucketInstanceId]={}),l[i.bucketInstanceId][i.featureIndex]||Pa(e,[new o(t.x1,t.y1),new o(t.x2,t.y1),new o(t.x2,t.y2),new o(t.x1,t.y2)])&&(l[i.bucketInstanceId][i.featureIndex]=!0,void 0===c[i.bucketInstanceId]&&(c[i.bucketInstanceId]=[]),c[i.bucketInstanceId].push(i.featureIndex))}return c}insertCollisionBox(t,e,i,r,n){(e?this.ignoredGrid:this.grid).insert({bucketInstanceId:i,featureIndex:r,collisionGroupID:n},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,e,i,r,n){const s=e?this.ignoredGrid:this.grid,o={bucketInstanceId:i,featureIndex:r,collisionGroupID:n};for(let e=0;e<t.length;e+=4)s.insertCircle(o,t[e],t[e+1],t[e+2])}projectAndGetPerspectiveRatio(t,e,i,r){const n=[e[0],e[1],e[2],1];let s=!1;return e[2]||this.transform.pitch>0?(Ol(n,n,t),this.fogState&&i&&(s=function(t,e,i,r,n,s){const o=[e,i,r];return Cl(o,o,s.calculateFogTileMatrix(n)),Qu(t,o,s.pitch,s._fov)}(this.fogState,e[0],e[1],e[2],i.toUnwrapped(),this.transform)>.9)):xm(n,n,t),{point:new o((n[0]/n[3]+1)/2*this.transform.width+vm,(-n[1]/n[3]+1)/2*this.transform.height+vm),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/n[3]*.5,1.5),signedDistanceFromCamera:n[3],occluded:r&&n[2]>n[3]||s}}isOffscreen(t,e,i,r){return i<vm||t>=this.screenRightBoundary||r<vm||e>this.screenBottomBoundary}isInsideGrid(t,e,i,r){return i>=0&&t<this.gridRightBoundary&&r>=0&&e<this.gridBottomBoundary}getViewportMatrix(){const t=rl([]);return ol(t,t,[-100,-100,0]),t}}class wm{constructor(t,e,i,r){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?e:-e))):r&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class Tm{constructor(t,e,i,r,n,s=!1){this.text=new wm(t?t.text:null,e,i,n),this.icon=new wm(t?t.icon:null,e,r,n),this.clipped=s}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Em{constructor(t,e,i,r=!1){this.text=t,this.icon=e,this.skipFade=i,this.clipped=r}}class Im{constructor(){this.invProjMatrix=il(),this.viewportMatrix=il(),this.circles=[]}}class Sm{constructor(t,e,i,r,n){this.bucketInstanceId=t,this.featureIndex=e,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=n}}class Am{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){const e=++this.maxGroupID;this.collisionGroups[t]={ID:e,predicate:t=>t.collisionGroupID===e}}return this.collisionGroups[t]}}function zm(t,e,i,r,n){const{horizontalAlign:s,verticalAlign:a}=_u(t),l=-(s-.5)*e,c=-(a-.5)*i,h=Eu(t,r);return new o(l+h[0]*n,c+h[1]*n)}function Cm(t,e,i,r,n){const s=new o(t,e);return i&&s._rotate(r?n:-n),s}class Mm{constructor(t,e,i,r,n){this.transform=t.clone(),this.collisionIndex=new bm(this.transform,n),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=e,this.retainedQueryData={},this.collisionGroups=new Am(i),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,e,i,r){const n=i.getBucket(e),s=i.latestFeatureIndex;if(!n||!s||e.id!==n.layerIds[0])return;const o=n.layers[0].layout,a=i.collisionBoxArray,l=Math.pow(2,this.transform.zoom-i.tileID.overscaledZ),c=i.tileSize/la,h=i.tileID.toUnwrapped(),u=this.transform.calculateProjMatrix(h),p="map"===o.get("text-pitch-alignment"),d="map"===o.get("text-rotation-alignment");e.compileFilter();const f=e.dynamicFilter(),m=e.dynamicFilterNeedsFeature(),_=this.transform.calculatePixelsToTileUnitsMatrix(i),g=nm(u,i.tileID.canonical,p,d,this.transform,_);let y=null;if(p){const t=sm(u,i.tileID.canonical,p,d,this.transform,_);y=sl([],this.transform.labelPlaneMatrix,t)}let x=null;f&&i.latestFeatureIndex&&(x={unwrappedTileID:h,dynamicFilter:f,dynamicFilterNeedsFeature:m,featureIndex:i.latestFeatureIndex}),this.retainedQueryData[n.bucketInstanceId]=new Sm(n.bucketInstanceId,s,n.sourceLayerIndex,n.index,i.tileID);const v={bucket:n,layout:o,posMatrix:u,textLabelPlaneMatrix:g,labelToScreenMatrix:y,clippingData:x,scale:l,textPixelRatio:c,holdingForFade:i.holdingForFade(),collisionBoxArray:a,partiallyEvaluatedTextSize:Oh(n.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:Oh(n.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(n.sourceID)};if(r)for(const e of n.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n}=e;t.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n,parameters:v})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:n.symbolInstances.length,parameters:v})}attemptAnchorPlacement(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m,_,g){const y=[u.textOffset0,u.textOffset1],x=zm(t,i,r,y,n),v=this.collisionIndex.placeCollisionBox(n,e,Cm(x.x,x.y,s,o,this.transform.angle),h,a,l,c.predicate);if((!m||0!==this.collisionIndex.placeCollisionBox(d.getSymbolInstanceIconSize(g,this.transform.zoom,p),m,Cm(x.x,x.y,s,o,this.transform.angle),h,a,l,c.predicate).box.length)&&v.box.length>0){let e;return this.prevPlacement&&this.prevPlacement.variableOffsets[u.crossTileID]&&this.prevPlacement.placements[u.crossTileID]&&this.prevPlacement.placements[u.crossTileID].text&&(e=this.prevPlacement.variableOffsets[u.crossTileID].anchor),this.variableOffsets[u.crossTileID]={textOffset:y,width:i,height:r,anchor:t,textScale:n,prevAnchor:e},this.markUsedJustification(d,t,u,f),d.allowVerticalPlacement&&(this.markUsedOrientation(d,f,u),this.placedOrientations[u.crossTileID]=f),{shift:x,placedGlyphBoxes:v}}}placeLayerBucketPart(t,e,i,r){const{bucket:n,layout:s,posMatrix:a,textLabelPlaneMatrix:l,labelToScreenMatrix:c,clippingData:h,textPixelRatio:u,holdingForFade:p,collisionBoxArray:d,partiallyEvaluatedTextSize:f,partiallyEvaluatedIconSize:m,collisionGroup:_}=t.parameters,g=s.get("text-optional"),y=s.get("icon-optional"),x=s.get("text-allow-overlap"),v=s.get("icon-allow-overlap"),b="map"===s.get("text-rotation-alignment"),w="map"===s.get("text-pitch-alignment"),T="none"!==s.get("icon-text-fit"),E="viewport-y"===s.get("symbol-z-order");let I=x&&(v||!n.hasIconData()||y),S=v&&(x||!n.hasTextData()||g);!n.collisionArrays&&d&&n.deserializeCollisionBoxes(d),i&&r&&n.updateCollisionDebugBuffers(this.transform.zoom,d);const A=(t,r,d)=>{if(h){const i={zoom:this.transform.zoom,pitch:this.transform.pitch};let r=null;if(h.dynamicFilterNeedsFeature){const e=this.retainedQueryData[n.bucketInstanceId];r=h.featureIndex.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,h.dynamicFilter)(i,r,this.retainedQueryData[n.bucketInstanceId].tileID.canonical,new o(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(h.unwrappedTileID)))return this.placements[t.crossTileID]=new Em(!1,!1,!1,!0),void(e[t.crossTileID]=!0)}if(e[t.crossTileID])return;if(p)return void(this.placements[t.crossTileID]=new Em(!1,!1,!1));let E=!1,A=!1,z=!0,C=!1,M=!1,k=null,P={box:null,offscreen:null,occluded:null},D={box:null,offscreen:null,occluded:null},B=null,L=null,R=null,F=0,O=0,V=0;d.textFeatureIndex?F=d.textFeatureIndex:t.useRuntimeCollisionCircles&&(F=t.featureIndex),d.verticalTextFeatureIndex&&(O=d.verticalTextFeatureIndex);const j=t=>{t.tileID=this.retainedQueryData[n.bucketInstanceId].tileID,(this.transform.elevation||t.elevation)&&(t.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[n.bucketInstanceId].tileID,t.tileAnchorX,t.tileAnchorY):0)},U=d.textBox;if(U){j(U);const e=e=>{let i=mu.horizontal;if(n.allowVerticalPlacement&&!e&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[t.crossTileID];e&&(this.placedOrientations[t.crossTileID]=e,i=e,this.markUsedOrientation(n,i,t))}return i},i=(e,i)=>{if(n.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const t of n.writingModes)if(t===mu.vertical?(P=i(),D=P):P=e(),P&&P.box&&P.box.length)break}else P=e()};if(s.get("text-variable-anchor")){let o=s.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[t.crossTileID]){const e=this.prevPlacement.variableOffsets[t.crossTileID];o.indexOf(e.anchor)>0&&(o=o.filter((t=>t!==e.anchor)),o.unshift(e.anchor))}const l=(e,i,s)=>{const l=n.getSymbolInstanceTextSize(f,t,this.transform.zoom,r),c=(e.x2-e.x1)*l+2*e.padding,h=(e.y2-e.y1)*l+2*e.padding,p=T&&!v?i:null;p&&j(p);let d={box:[],offscreen:!1,occluded:!1};const g=x?2*o.length:o.length;for(let i=0;i<g;++i){const g=this.attemptAnchorPlacement(o[i%o.length],e,c,h,l,b,w,u,a,_,i>=o.length,t,r,n,s,p,f,m);if(g&&(d=g.placedGlyphBoxes,d&&d.box&&d.box.length)){E=!0,k=g.shift;break}}return d};i((()=>l(U,d.iconBox,mu.horizontal)),(()=>{const e=d.verticalTextBox;return e&&j(e),n.allowVerticalPlacement&&!(P&&P.box&&P.box.length)&&t.numVerticalGlyphVertices>0&&e?l(e,d.verticalIconBox,mu.vertical):{box:null,offscreen:null,occluded:null}})),P&&(E=P.box,z=P.offscreen,C=P.occluded);const c=e(P&&P.box);if(!E&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[t.crossTileID];e&&(this.variableOffsets[t.crossTileID]=e,this.markUsedJustification(n,e.anchor,t,c))}}else{const s=(e,i)=>{const s=n.getSymbolInstanceTextSize(f,t,this.transform.zoom,r),l=this.collisionIndex.placeCollisionBox(s,e,new o(0,0),x,u,a,_.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(n,i,t),this.placedOrientations[t.crossTileID]=i),l};i((()=>s(U,mu.horizontal)),(()=>{const e=d.verticalTextBox;return n.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&e?(j(e),s(e,mu.vertical)):{box:null,offscreen:null,occluded:null}})),e(P&&P.box&&P.box.length)}}if(B=P,E=B&&B.box&&B.box.length>0,z=B&&B.offscreen,C=B&&B.occluded,t.useRuntimeCollisionCircles){const e=n.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex),r=Fh(n.textSizeData,f,e),o=s.get("text-padding");L=this.collisionIndex.placeCollisionCircles(x,e,n.lineVertexArray,n.glyphOffsetArray,r,a,l,c,i,w,_.predicate,t.collisionCircleDiameter*r/24,o,this.retainedQueryData[n.bucketInstanceId].tileID),E=x||L.circles.length>0&&!L.collisionDetected,z=z&&L.offscreen,C=L.occluded}if(d.iconFeatureIndex&&(V=d.iconFeatureIndex),d.iconBox){const t=t=>{j(t);const e=T&&k?Cm(k.x,k.y,b,w,this.transform.angle):new o(0,0),i=n.getSymbolInstanceIconSize(m,this.transform.zoom,r);return this.collisionIndex.placeCollisionBox(i,t,e,v,u,a,_.predicate)};D&&D.box&&D.box.length&&d.verticalIconBox?(R=t(d.verticalIconBox),A=R.box.length>0):(R=t(d.iconBox),A=R.box.length>0),z=z&&R.offscreen,M=R.occluded}const N=g||0===t.numHorizontalGlyphVertices&&0===t.numVerticalGlyphVertices,Z=y||0===t.numIconVertices;if(N||Z?Z?N||(A=A&&E):E=A&&E:A=E=A&&E,E&&B&&B.box&&this.collisionIndex.insertCollisionBox(B.box,s.get("text-ignore-placement"),n.bucketInstanceId,D&&D.box&&O?O:F,_.ID),A&&R&&this.collisionIndex.insertCollisionBox(R.box,s.get("icon-ignore-placement"),n.bucketInstanceId,V,_.ID),L&&(E&&this.collisionIndex.insertCollisionCircles(L.circles,s.get("text-ignore-placement"),n.bucketInstanceId,F,_.ID),i)){const t=n.bucketInstanceId;let e=this.collisionCircleArrays[t];void 0===e&&(e=this.collisionCircleArrays[t]=new Im);for(let t=0;t<L.circles.length;t+=4)e.circles.push(L.circles[t+0]),e.circles.push(L.circles[t+1]),e.circles.push(L.circles[t+2]),e.circles.push(L.collisionDetected?1:0)}const q="globe"!==this.transform.projection.name;I=I&&(q||!C),S=S&&(q||!M),this.placements[t.crossTileID]=new Em(E||I,A||S,z||n.justReloaded),e[t.crossTileID]=!0};if(E){const t=n.getSortedSymbolIndexes(this.transform.angle);for(let e=t.length-1;e>=0;--e){const i=t[e];A(n.symbolInstances.get(i),i,n.collisionArrays[i])}}else for(let e=t.symbolInstanceStart;e<t.symbolInstanceEnd;e++)A(n.symbolInstances.get(e),e,n.collisionArrays[e]);if(i&&n.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[n.bucketInstanceId];nl(t.invProjMatrix,a),t.viewportMatrix=this.collisionIndex.getViewportMatrix()}n.justReloaded=!1}markUsedJustification(t,e,i,r){let n;n=r===mu.vertical?i.verticalPlacedTextSymbolIndex:{left:i.leftJustifiedTextSymbolIndex,center:i.centerJustifiedTextSymbolIndex,right:i.rightJustifiedTextSymbolIndex}[function(t){switch(t){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}(e)];const s=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex,i.verticalPlacedTextSymbolIndex];for(const e of s)e>=0&&(t.text.placedSymbolArray.get(e).crossTileID=n>=0&&e!==n?0:i.crossTileID)}markUsedOrientation(t,e,i){const r=e===mu.horizontal||e===mu.horizontalOnly?e:0,n=e===mu.vertical?e:0,s=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex];for(const e of s)t.text.placedSymbolArray.get(e).placedOrientation=r;i.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(i.verticalPlacedTextSymbolIndex).placedOrientation=n)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const e=this.prevPlacement;let i=!1;this.prevZoomAdjustment=e?e.zoomAdjustment(this.transform.zoom):0;const r=e?e.symbolFadeChange(t):1,n=e?e.opacities:{},s=e?e.variableOffsets:{},o=e?e.placedOrientations:{};for(const t in this.placements){const e=this.placements[t],s=n[t];s?(this.opacities[t]=new Tm(s,r,e.text,e.icon,null,e.clipped),i=i||e.text!==s.text.placed||e.icon!==s.icon.placed):(this.opacities[t]=new Tm(null,r,e.text,e.icon,e.skipFade,e.clipped),i=i||e.text||e.icon)}for(const t in n){const e=n[t];if(!this.opacities[t]){const n=new Tm(e,r,!1,!1);n.isHidden()||(this.opacities[t]=n,i=i||e.text.placed||e.icon.placed)}}for(const t in s)this.variableOffsets[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.variableOffsets[t]=s[t]);for(const t in o)this.placedOrientations[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.placedOrientations[t]=o[t]);i?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=e?e.lastPlacementChangeTime:t)}updateLayerOpacities(t,e){const i={};for(const r of e){const e=r.getBucket(t);e&&r.latestFeatureIndex&&t.id===e.layerIds[0]&&this.updateBucketOpacities(e,i,r.collisionBoxArray)}}updateBucketOpacities(t,e,i){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const r=t.layers[0].layout,n=!!t.layers[0].dynamicFilter(),s=new Tm(null,0,!1,!1,!0),a=r.get("text-allow-overlap"),l=r.get("icon-allow-overlap"),c=r.get("text-variable-anchor"),h="map"===r.get("text-rotation-alignment"),u="map"===r.get("text-pitch-alignment"),p="none"!==r.get("icon-text-fit"),d=new Tm(null,0,a&&(l||!t.hasIconData()||r.get("icon-optional")),l&&(a||!t.hasTextData()||r.get("text-optional")),!0);!t.collisionArrays&&i&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(i);const f=(t,e,i)=>{for(let r=0;r<e/4;r++)t.opacityVertexArray.emplaceBack(i)};let m=0;for(let i=0;i<t.symbolInstances.length;i++){const r=t.symbolInstances.get(i),{numHorizontalGlyphVertices:a,numVerticalGlyphVertices:l,crossTileID:_}=r;let g=this.opacities[_];e[_]?g=s:g||(g=d,this.opacities[_]=g),e[_]=!0;const y=a>0||l>0,x=r.numIconVertices>0,v=this.placedOrientations[r.crossTileID],b=v===mu.vertical,w=v===mu.horizontal||v===mu.horizontalOnly;if(!y&&!x||g.isHidden()||m++,y){const e=Vm(g.text);f(t.text,a,b?jm:e),f(t.text,l,w?jm:e);const i=g.text.isHidden();[r.rightJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.leftJustifiedTextSymbolIndex].forEach((e=>{e>=0&&(t.text.placedSymbolArray.get(e).hidden=i||b?1:0)})),r.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).hidden=i||w?1:0);const n=this.variableOffsets[r.crossTileID];n&&this.markUsedJustification(t,n.anchor,r,v);const s=this.placedOrientations[r.crossTileID];s&&(this.markUsedJustification(t,"left",r,s),this.markUsedOrientation(t,s,r))}if(x){const e=Vm(g.icon);r.placedIconSymbolIndex>=0&&(f(t.icon,r.numIconVertices,b?jm:e),t.icon.placedSymbolArray.get(r.placedIconSymbolIndex).hidden=g.icon.isHidden()),r.verticalPlacedIconSymbolIndex>=0&&(f(t.icon,r.numVerticalIconVertices,w?jm:e),t.icon.placedSymbolArray.get(r.verticalPlacedIconSymbolIndex).hidden=g.icon.isHidden())}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const e=t.collisionArrays[i];if(e){let i=new o(0,0),r=!0;if(e.textBox||e.verticalTextBox){if(c){const t=this.variableOffsets[_];t?(i=zm(t.anchor,t.width,t.height,t.textOffset,t.textScale),h&&i._rotate(u?this.transform.angle:-this.transform.angle)):r=!1}n&&(r=!g.clipped),e.textBox&&km(t.textCollisionBox.collisionVertexArray,g.text.placed,!r||b,i.x,i.y),e.verticalTextBox&&km(t.textCollisionBox.collisionVertexArray,g.text.placed,!r||w,i.x,i.y)}const s=r&&Boolean(!w&&e.verticalIconBox);e.iconBox&&km(t.iconCollisionBox.collisionVertexArray,g.icon.placed,s,p?i.x:0,p?i.y:0),e.verticalIconBox&&km(t.iconCollisionBox.collisionVertexArray,g.icon.placed,!s,p?i.x:0,p?i.y:0)}}}if(t.fullyClipped=0===m,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(t){return 0===this.fadeDuration?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(t,e){const i=this.zoomAtLastRecencyCheck===e?1-this.zoomAdjustment(e):1;return this.zoomAtLastRecencyCheck=e,this.commitTime+this.fadeDuration*i>t}setStale(){this.stale=!0}}function km(t,e,i,r,n){t.emplaceBack(e?1:0,i?1:0,r||0,n||0),t.emplaceBack(e?1:0,i?1:0,r||0,n||0),t.emplaceBack(e?1:0,i?1:0,r||0,n||0),t.emplaceBack(e?1:0,i?1:0,r||0,n||0)}const Pm=Math.pow(2,25),Dm=Math.pow(2,24),Bm=Math.pow(2,17),Lm=Math.pow(2,16),Rm=Math.pow(2,9),Fm=Math.pow(2,8),Om=Math.pow(2,1);function Vm(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;const e=t.placed?1:0,i=Math.floor(127*t.opacity);return i*Pm+e*Dm+i*Bm+e*Lm+i*Rm+e*Fm+i*Om+e}const jm=0;class Um{constructor(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&void 0!==t.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,e,i,r,n){const s=this._bucketParts;for(;this._currentTileIndex<t.length;)if(e.getBucketParts(s,r,t[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,n())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,s.sort(((t,e)=>t.sortKey-e.sortKey)));this._currentPartIndex<s.length;){const t=s[this._currentPartIndex];if(e.placeLayerBucketPart(t,this._seenCrossTileIDs,i,0===t.symbolInstanceStart),this._currentPartIndex++,n())return!0}return!1}}class Nm{constructor(t,e,i,r,n,s,o,a){this.placement=new Mm(t,n,s,o,a),this._currentPlacementIndex=e.length-1,this._forceFullPlacement=i,this._showCollisionBoxes=r,this._done=!1}isDone(){return this._done}continuePlacement(t,e,i){const r=J.now(),n=()=>{const t=J.now()-r;return!this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const r=e[t[this._currentPlacementIndex]],s=this.placement.collisionIndex.transform.zoom;if("symbol"===r.type&&(!r.minzoom||r.minzoom<=s)&&(!r.maxzoom||r.maxzoom>s)){if(this._inProgressLayer||(this._inProgressLayer=new Um(r)),this._inProgressLayer.continuePlacement(i[r.source],this.placement,this._showCollisionBoxes,r,n))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}class Zm{constructor(t,e,i){this.tileID=t,this.indexedSymbolInstances={},this.bucketInstanceId=i;for(let i=0;i<e.length;i++){const r=e.get(i),n=r.key;this.indexedSymbolInstances[n]||(this.indexedSymbolInstances[n]=[]),this.indexedSymbolInstances[n].push({crossTileID:r.crossTileID,coord:this.getScaledCoordinates(r,t)})}}getScaledCoordinates(t,e){const i=.03125/Math.pow(2,e.canonical.z-this.tileID.canonical.z);return{x:Math.floor((e.canonical.x*la+t.tileAnchorX)*i),y:Math.floor((e.canonical.y*la+t.tileAnchorY)*i)}}findMatches(t,e,i){const r=this.tileID.canonical.z<e.canonical.z?1:Math.pow(2,this.tileID.canonical.z-e.canonical.z);for(let n=0;n<t.length;n++){const s=t.get(n);if(s.crossTileID)continue;const o=this.indexedSymbolInstances[s.key];if(!o)continue;const a=this.getScaledCoordinates(s,e);for(const t of o)if(Math.abs(t.coord.x-a.x)<=r&&Math.abs(t.coord.y-a.y)<=r&&!i[t.crossTileID]){i[t.crossTileID]=!0,s.crossTileID=t.crossTileID;break}}}}class qm{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Gm{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const e=Math.round((t-this.lng)/360);if(0!==e)for(const t in this.indexes){const i=this.indexes[t],r={};for(const t in i){const n=i[t];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),r[n.tileID.key]=n}this.indexes[t]=r}this.lng=t}addBucket(t,e,i){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===e.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let t=0;t<e.symbolInstances.length;t++)e.symbolInstances.get(t).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||(this.usedCrossTileIDs[t.overscaledZ]={});const r=this.usedCrossTileIDs[t.overscaledZ];for(const i in this.indexes){const n=this.indexes[i];if(Number(i)>t.overscaledZ)for(const i in n){const s=n[i];s.tileID.isChildOf(t)&&s.findMatches(e.symbolInstances,t,r)}else{const s=n[t.scaledTo(Number(i)).key];s&&s.findMatches(e.symbolInstances,t,r)}}for(let t=0;t<e.symbolInstances.length;t++){const n=e.symbolInstances.get(t);n.crossTileID||(n.crossTileID=i.generate(),r[n.crossTileID]=!0)}return void 0===this.indexes[t.overscaledZ]&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new Zm(t,e.symbolInstances,e.bucketInstanceId),!0}removeBucketCrossTileIDs(t,e){for(const i in e.indexedSymbolInstances)for(const r of e.indexedSymbolInstances[i])delete this.usedCrossTileIDs[t][r.crossTileID]}removeStaleBuckets(t){let e=!1;for(const i in this.indexes){const r=this.indexes[i];for(const n in r)t[r[n].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,r[n]),delete r[n],e=!0)}return e}}class $m{constructor(){this.layerIndexes={},this.crossTileIDs=new qm,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,e,i,r){let n=this.layerIndexes[t.id];void 0===n&&(n=this.layerIndexes[t.id]=new Gm);let s=!1;const o={};"globe"!==r.name&&n.handleWrapJump(i);for(const i of e){const e=i.getBucket(t);e&&t.id===e.layerIds[0]&&(e.bucketInstanceId||(e.bucketInstanceId=++this.maxBucketInstanceId),n.addBucket(i.tileID,e,this.crossTileIDs)&&(s=!0),o[e.bucketInstanceId]=!0)}return n.removeStaleBuckets(o)&&(s=!0),s}pruneUnusedLayers(t){const e={};t.forEach((t=>{e[t]=!0}));for(const t in this.layerIndexes)e[t]||delete this.layerIndexes[t]}}const Wm=(t,e)=>Dn(t,e&&e.filter((t=>"source.canvas"!==t.identifier))),Xm=S(Wf,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Hm=S(Wf,["setCenter","setZoom","setBearing","setPitch"]),Km={version:8,layers:[],sources:{}},Ym={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class Jm extends he{constructor(t,e={}){super(),this.map=t,this.dispatcher=new ap(Zf(),this),this.imageManager=new $u,this.imageManager.setEventedParent(this),this.glyphManager=new bu(t._requestManager,e.localFontFamily?2:e.localIdeographFontFamily?1:0,e.localFontFamily||e.localIdeographFontFamily),this.lineAtlas=new np(256,512),this.crossTileSymbolIndex=new $m,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new Nn,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",Ht());const i=this;this._rtlTextPluginCallback=Jm.registerForPluginStateChange((t=>{i.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},((t,e)=>{if(ss(t),e&&e.every((t=>t)))for(const t in i._sourceCaches){const e=i._sourceCaches[t],r=e.getSource().type;"vector"!==r&&"geojson"!==r||e.reload()}}))})),this.on("data",(t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;const e=this.getSource(t.sourceId);if(e&&e.vectorLayerIds)for(const t in this._layers){const i=this._layers[t];i.source===e.id&&this._validateLayer(i)}}))}loadURL(t,e={}){this.fire(new le("dataloading",{dataType:"style"}));const i="boolean"==typeof e.validate?e.validate:!Tt(t);t=this.map._requestManager.normalizeStyleURL(t,e.accessToken);const r=this.map._requestManager.transformRequest(t,Wt.Style);this._request=Yt(r,((t,e)=>{this._request=null,t?this.fire(new ce(t)):e&&this._load(e,i)}))}loadJSON(t,e={}){this.fire(new le("dataloading",{dataType:"style"})),this._request=J.frame((()=>{this._request=null,this._load(t,!1!==e.validate)}))}loadEmpty(){this.fire(new le("dataloading",{dataType:"style"})),this._load(Km,!1)}_updateLayerCount(t,e){const i=e?1:-1;t.is3D()&&(this._num3DLayers+=i),"circle"===t.type&&(this._numCircleLayers+=i),"symbol"===t.type&&(this._numSymbolLayers+=i)}_load(t,e){if(e&&Wm(this,Tn(t)))return;this._loaded=!0,this.stylesheet=t,this._updateProjection();for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1});this._changed=!1,t.sprite?this._loadSprite(t.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(t.glyphs);const i=$f(this.stylesheet.layers);this._order=i.map((t=>t.id)),this._layers={},this._serializedLayers={};for(let t of i)t=Zu(t),t.setEventedParent(this,{layer:{id:t.id}}),this._layers[t.id]=t,this._serializedLayers[t.id]=t.serialize(),this._updateLayerCount(t,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new Hu(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 le("data",{dataType:"style"})),this.fire(new le("style.load"))}terrainSetForDrapingOnly(){return this.terrain&&0===this.terrain.drapeRenderMode}setProjection(t){t?this.stylesheet.projection=t:delete this.stylesheet.projection,this.map._explicitProjection||this.map._updateProjection()}_updateProjection(){this.map._explicitProjection?this.enableDraping():this.map._updateProjection()}enableDraping(){this._loaded&&(this.map.transform.projection.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null))}_loadSprite(t){this._spriteRequest=function(t,e,i){let r,n,s;const o=J.devicePixelRatio>1?"@2x":"";let a=Yt(e.transformRequest(e.normalizeSpriteURL(t,o,".json"),Wt.SpriteJSON),((t,e)=>{a=null,s||(s=t,r=e,c())})),l=se(e.transformRequest(e.normalizeSpriteURL(t,o,".png"),Wt.SpriteImage),((t,e)=>{l=null,s||(s=t,n=e,c())}));function c(){if(s)i(s);else if(r&&n){const t=J.getImageData(n),e={};for(const i in r){const{width:n,height:s,x:o,y:a,sdf:l,pixelRatio:c,stretchX:h,stretchY:u,content:p}=r[i],d=new ec({width:n,height:s});ec.copy(t,d,{x:o,y:a},{x:0,y:0},{width:n,height:s}),e[i]={data:d,pixelRatio:c,sdf:l,stretchX:h,stretchY:u,content:p}}i(null,e)}}return{cancel(){a&&(a.cancel(),a=null),l&&(l.cancel(),l=null)}}}(t,this.map._requestManager,((t,e)=>{if(this._spriteRequest=null,t)this.fire(new ce(t));else if(e)for(const t in e)this.imageManager.addImage(t,e[t]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new le("data",{dataType:"style"}))}))}_validateLayer(t){const e=this.getSource(t.source);if(!e)return;const i=t.sourceLayer;i&&("geojson"===e.type||e.vectorLayerIds&&-1===e.vectorLayerIds.indexOf(i))&&this.fire(new ce(new Error(`Source layer "${i}" does not exist on source "${e.id}" as specified by style layer "${t.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const t in this._sourceCaches)if(!this._sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(t){const e=[];for(const i of t){const t=this._layers[i];"custom"!==t.type&&e.push(t.serialize())}return e}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;if(this.fog&&this.fog.hasTransition())return!0;for(const t in this._sourceCaches)if(this._sourceCaches[t].hasTransition())return!0;for(const t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(t){return!!this.terrain&&Ym[t.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(t){if(!this._loaded)return;const e=this._changed;if(this._changed){const e=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(e.length||i.length)&&this._updateWorkerLayers(e,i);for(const t in this._updatedSources){const e=this._updatedSources[t];"reload"===e?this._reloadSource(t):"clear"===e&&this._clearSource(t)}this._updateTilesForChangedImages();for(const e in this._updatedPaintProps)this._layers[e].updateTransitions(t);this.light.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this._resetUpdates()}const i={};for(const t in this._sourceCaches){const e=this._sourceCaches[t];i[t]=e.used,e.used=!1}for(const e of this._order){const i=this._layers[e];if(i.recalculate(t,this._availableImages),!i.isHidden(t.zoom)){const t=this._getLayerSourceCache(i);t&&(t.used=!0)}const r=this.map.painter;if(r){const e=i.getProgramIds();if(!e)continue;const n=i.getProgramConfiguration(t.zoom);for(const t of e)r.useProgram(t,n)}}for(const t in i){const e=this._sourceCaches[t];i[t]!==e.used&&e.getSource().fire(new le("data",{sourceDataType:"visibility",dataType:"source",sourceId:e.getSource().id}))}this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),e&&this.fire(new le("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const e in this._sourceCaches)this._sourceCaches[e].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateWorkerLayers(t,e){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(t),removedIds:e})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(t){if(this._checkLoaded(),Wm(this,Tn(t)))return!1;(t=R(t)).layers=$f(t.layers);const e=function(t,e){if(!t)return[{command:Wf.setStyle,args:[e]}];let i=[];try{if(!c(t.version,e.version))return[{command:Wf.setStyle,args:[e]}];c(t.center,e.center)||i.push({command:Wf.setCenter,args:[e.center]}),c(t.zoom,e.zoom)||i.push({command:Wf.setZoom,args:[e.zoom]}),c(t.bearing,e.bearing)||i.push({command:Wf.setBearing,args:[e.bearing]}),c(t.pitch,e.pitch)||i.push({command:Wf.setPitch,args:[e.pitch]}),c(t.sprite,e.sprite)||i.push({command:Wf.setSprite,args:[e.sprite]}),c(t.glyphs,e.glyphs)||i.push({command:Wf.setGlyphs,args:[e.glyphs]}),c(t.transition,e.transition)||i.push({command:Wf.setTransition,args:[e.transition]}),c(t.light,e.light)||i.push({command:Wf.setLight,args:[e.light]}),c(t.fog,e.fog)||i.push({command:Wf.setFog,args:[e.fog]}),c(t.projection,e.projection)||i.push({command:Wf.setProjection,args:[e.projection]});const r={},n=[];!function(t,e,i,r){let n;for(n in e=e||{},t=t||{})t.hasOwnProperty(n)&&(e.hasOwnProperty(n)||Hf(n,i,r));for(n in e)e.hasOwnProperty(n)&&(t.hasOwnProperty(n)?c(t[n],e[n])||("geojson"===t[n].type&&"geojson"===e[n].type&&Yf(t,e,n)?i.push({command:Wf.setGeoJSONSourceData,args:[n,e[n].data]}):Kf(n,e,i,r)):Xf(n,e,i))}(t.sources,e.sources,n,r);const s=[];t.layers&&t.layers.forEach((t=>{t.source&&r[t.source]?i.push({command:Wf.removeLayer,args:[t.id]}):s.push(t)}));let o=t.terrain;o&&r[o.source]&&(i.push({command:Wf.setTerrain,args:[void 0]}),o=void 0),i=i.concat(n),c(o,e.terrain)||i.push({command:Wf.setTerrain,args:[e.terrain]}),function(t,e,i){e=e||[];const r=(t=t||[]).map(Qf),n=e.map(Qf),s=t.reduce(tm,{}),o=e.reduce(tm,{}),a=r.slice(),l=Object.create(null);let h,u,p,d,f,m,_;for(h=0,u=0;h<r.length;h++)p=r[h],o.hasOwnProperty(p)?u++:(i.push({command:Wf.removeLayer,args:[p]}),a.splice(a.indexOf(p,u),1));for(h=0,u=0;h<n.length;h++)p=n[n.length-1-h],a[a.length-1-h]!==p&&(s.hasOwnProperty(p)?(i.push({command:Wf.removeLayer,args:[p]}),a.splice(a.lastIndexOf(p,a.length-u),1)):u++,m=a[a.length-h],i.push({command:Wf.addLayer,args:[o[p],m]}),a.splice(a.length-h,0,p),l[p]=!0);for(h=0;h<n.length;h++)if(p=n[h],d=s[p],f=o[p],!l[p]&&!c(d,f))if(c(d.source,f.source)&&c(d["source-layer"],f["source-layer"])&&c(d.type,f.type)){for(_ in Jf(d.layout,f.layout,i,p,null,Wf.setLayoutProperty),Jf(d.paint,f.paint,i,p,null,Wf.setPaintProperty),c(d.filter,f.filter)||i.push({command:Wf.setFilter,args:[p,f.filter]}),c(d.minzoom,f.minzoom)&&c(d.maxzoom,f.maxzoom)||i.push({command:Wf.setLayerZoomRange,args:[p,f.minzoom,f.maxzoom]}),d)d.hasOwnProperty(_)&&"layout"!==_&&"paint"!==_&&"filter"!==_&&"metadata"!==_&&"minzoom"!==_&&"maxzoom"!==_&&(0===_.indexOf("paint.")?Jf(d[_],f[_],i,p,_.slice(6),Wf.setPaintProperty):c(d[_],f[_])||i.push({command:Wf.setLayerProperty,args:[p,_,f[_]]}));for(_ in f)f.hasOwnProperty(_)&&!d.hasOwnProperty(_)&&"layout"!==_&&"paint"!==_&&"filter"!==_&&"metadata"!==_&&"minzoom"!==_&&"maxzoom"!==_&&(0===_.indexOf("paint.")?Jf(d[_],f[_],i,p,_.slice(6),Wf.setPaintProperty):c(d[_],f[_])||i.push({command:Wf.setLayerProperty,args:[p,_,f[_]]}))}else i.push({command:Wf.removeLayer,args:[p]}),m=a[a.lastIndexOf(p)+1],i.push({command:Wf.addLayer,args:[f,m]})}(s,e.layers,i)}catch(t){console.warn("Unable to compute style diff:",t),i=[{command:Wf.setStyle,args:[e]}]}return i}(this.serialize(),t).filter((t=>!(t.command in Hm)));if(0===e.length)return!1;const i=e.filter((t=>!(t.command in Xm)));if(i.length>0)throw new Error(`Unimplemented: ${i.map((t=>t.command)).join(", ")}.`);return e.forEach((t=>{"setTransition"!==t.command&&this[t.command].apply(this,t.args)})),this.stylesheet=t,this._updateProjection(),!0}addImage(t,e){if(this.getImage(t))return this.fire(new ce(new Error("An image with this name already exists.")));this.imageManager.addImage(t,e),this._afterImageUpdated(t)}updateImage(t,e){this.imageManager.updateImage(t,e)}getImage(t){return this.imageManager.getImage(t)}removeImage(t){if(!this.getImage(t))return this.fire(new ce(new Error("No image with this name exists.")));this.imageManager.removeImage(t),this._afterImageUpdated(t)}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new le("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(t,e,i={}){if(this._checkLoaded(),void 0!==this.getSource(t))throw new Error("There is already a source with this ID");if(!e.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(e).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(e.type)>=0&&this._validate(En,`sources.${t}`,e,null,i))return;this.map&&this.map._collectResourceTiming&&(e.collectResourceTiming=!0);const r=Bf(t,e,this.dispatcher,this);r.setEventedParent(this,(()=>({isSourceLoaded:this._isSourceCacheLoaded(t),source:r.serialize(),sourceId:t})));const n=e=>{const i=(e?"symbol:":"other:")+t,n=this._sourceCaches[i]=new bf(i,r,e);(e?this._symbolSourceCaches:this._otherSourceCaches)[t]=n,n.style=this,n.onAdd(this.map)};n(!1),"vector"!==e.type&&"geojson"!==e.type||n(!0),r.onAdd&&r.onAdd(this.map),this._changed=!0}removeSource(t){this._checkLoaded();const e=this.getSource(t);if(void 0===e)throw new Error("There is no source with this ID");for(const e in this._layers)if(this._layers[e].source===t)return this.fire(new ce(new Error(`Source "${t}" cannot be removed while layer "${e}" is using it.`)));if(this.terrain&&this.terrain.get().source===t)return this.fire(new ce(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));const i=this._getSourceCaches(t);for(const t of i)delete this._sourceCaches[t.id],delete this._updatedSources[t.id],t.fire(new le("data",{sourceDataType:"metadata",dataType:"source",sourceId:t.getSource().id})),t.setEventedParent(null),t.clearTiles();delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],e.setEventedParent(null),e.onRemove&&e.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,e){this._checkLoaded(),this.getSource(t).setData(e),this._changed=!0}getSource(t){const e=this._getSourceCache(t);return e&&e.getSource()}addLayer(t,e,i={}){this._checkLoaded();const r=t.id;if(this.getLayer(r))return void this.fire(new ce(new Error(`Layer with id "${r}" already exists on this map`)));let n;if("custom"===t.type){if(Wm(this,function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e}(t)))return;n=Zu(t)}else{if("object"==typeof t.source&&(this.addSource(r,t.source),t=I(t=R(t),{source:r})),this._validate(zn,`layers.${r}`,t,{arrayIndex:-1},i))return;n=Zu(t),this._validateLayer(n),n.setEventedParent(this,{layer:{id:r}}),this._serializedLayers[n.id]=n.serialize(),this._updateLayerCount(n,!0)}const s=e?this._order.indexOf(e):this._order.length;if(e&&-1===s)return void this.fire(new ce(new Error(`Layer with id "${e}" does not exist on this map.`)));this._order.splice(s,0,r),this._layerOrderChanged=!0,this._layers[r]=n;const o=this._getLayerSourceCache(n);if(this._removedLayers[r]&&n.source&&o&&"custom"!==n.type){const t=this._removedLayers[r];delete this._removedLayers[r],t.type!==n.type?this._updatedSources[n.source]="clear":(this._updatedSources[n.source]="reload",o.pause())}this._updateLayer(n),n.onAdd&&n.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(t,e){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new ce(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===e)return;const i=this._order.indexOf(t);this._order.splice(i,1);const r=e?this._order.indexOf(e):this._order.length;e&&-1===r?this.fire(new ce(new Error(`Layer with id "${e}" does not exist on this map.`))):(this._order.splice(r,0,t),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(t){this._checkLoaded();const e=this._layers[t];if(!e)return void this.fire(new ce(new Error(`The layer '${t}' does not exist in the map's style and cannot be removed.`)));e.setEventedParent(null),this._updateLayerCount(e,!1);const i=this._order.indexOf(t);this._order.splice(i,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=e,delete this._layers[t],delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],e.onRemove&&e.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(t){return this._layers[t]}hasLayer(t){return t in this._layers}hasLayerType(t){for(const e in this._layers)if(this._layers[e].type===t)return!0;return!1}setLayerZoomRange(t,e,i){this._checkLoaded();const r=this.getLayer(t);r?r.minzoom===e&&r.maxzoom===i||(null!=e&&(r.minzoom=e),null!=i&&(r.maxzoom=i),this._updateLayer(r)):this.fire(new ce(new Error(`The layer '${t}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(t,e,i={}){this._checkLoaded();const r=this.getLayer(t);if(r){if(!c(r.filter,e))return null==e?(r.filter=void 0,void this._updateLayer(r)):void(this._validate(Cn,`layers.${r.id}.filter`,e,{layerType:r.type},i)||(r.filter=R(e),this._updateLayer(r)))}else this.fire(new ce(new Error(`The layer '${t}' does not exist in the map's style and cannot be filtered.`)))}getFilter(t){return R(this.getLayer(t).filter)}setLayoutProperty(t,e,i,r={}){this._checkLoaded();const n=this.getLayer(t);n?c(n.getLayoutProperty(e),i)||(n.setLayoutProperty(e,i,r),this._updateLayer(n)):this.fire(new ce(new Error(`The layer '${t}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(t,e){const i=this.getLayer(t);if(i)return i.getLayoutProperty(e);this.fire(new ce(new Error(`The layer '${t}' does not exist in the map's style.`)))}setPaintProperty(t,e,i,r={}){this._checkLoaded();const n=this.getLayer(t);n?c(n.getPaintProperty(e),i)||(n.setPaintProperty(e,i,r)&&this._updateLayer(n),this._changed=!0,this._updatedPaintProps[t]=!0):this.fire(new ce(new Error(`The layer '${t}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(t,e){return this.getLayer(t).getPaintProperty(e)}setFeatureState(t,e){this._checkLoaded();const i=t.source,r=t.sourceLayer,n=this.getSource(i);if(void 0===n)return void this.fire(new ce(new Error(`The source '${i}' does not exist in the map's style.`)));const s=n.type;if("geojson"===s&&r)return void this.fire(new ce(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!r)return void this.fire(new ce(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new ce(new Error("The feature id parameter must be provided.")));const o=this._getSourceCaches(i);for(const i of o)i.setFeatureState(r,t.id,e)}removeFeatureState(t,e){this._checkLoaded();const i=t.source,r=this.getSource(i);if(void 0===r)return void this.fire(new ce(new Error(`The source '${i}' does not exist in the map's style.`)));const n=r.type,s="vector"===n?t.sourceLayer:void 0;if("vector"===n&&!s)return void this.fire(new ce(new Error("The sourceLayer parameter must be provided for vector source types.")));if(e&&"string"!=typeof t.id&&"number"!=typeof t.id)return void this.fire(new ce(new Error("A feature id is required to remove its specific state property.")));const o=this._getSourceCaches(i);for(const i of o)i.removeFeatureState(s,t.id,e)}getFeatureState(t){this._checkLoaded();const e=t.source,i=t.sourceLayer,r=this.getSource(e);if(void 0!==r){if("vector"!==r.type||i)return void 0===t.id&&this.fire(new ce(new Error("The feature id parameter must be provided."))),this._getSourceCaches(e)[0].getFeatureState(i,t.id);this.fire(new ce(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new ce(new Error(`The source '${e}' does not exist in the map's style.`)))}getTransition(){return I({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const t={};for(const e in this._sourceCaches){const i=this._sourceCaches[e].getSource();t[i.id]||(t[i.id]=i.serialize())}return L({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:t,layers:this._serializeLayers(this._order)},(t=>void 0!==t))}_updateLayer(t){this._updatedLayers[t.id]=!0;const e=this._getLayerSourceCache(t);t.source&&!this._updatedSources[t.source]&&e&&"raster"!==e.getSource().type&&(this._updatedSources[t.source]="reload",e.pause()),this._changed=!0,t.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(t){const e=t=>"fill-extrusion"===this._layers[t].type,i={},r=[];for(let n=this._order.length-1;n>=0;n--){const s=this._order[n];if(e(s)){i[s]=n;for(const e of t){const t=e[s];if(t)for(const e of t)r.push(e)}}}r.sort(((t,e)=>e.intersectionZ-t.intersectionZ));const n=[];for(let s=this._order.length-1;s>=0;s--){const o=this._order[s];if(e(o))for(let t=r.length-1;t>=0;t--){const e=r[t].feature;if(i[e.layer.id]<s)break;n.push(e),r.pop()}else for(const e of t){const t=e[o];if(t)for(const e of t)n.push(e.feature)}}return n}queryRenderedFeatures(t,e,i){e&&e.filter&&this._validate(Cn,"queryRenderedFeatures.filter",e.filter,null,e);const r={};if(e&&e.layers){if(!Array.isArray(e.layers))return this.fire(new ce(new Error("parameters.layers must be an Array."))),[];for(const t of e.layers){const e=this._layers[t];if(!e)return this.fire(new ce(new Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];r[e.source]=!0}}const n=[];e.availableImages=this._availableImages;const s=e&&e.layers?e.layers.some((t=>{const e=this.getLayer(t);return e&&e.is3D()})):this.has3DLayers(),o=Hp.createFromScreenPoints(t,i);for(const t in this._sourceCaches){const a=this._sourceCaches[t].getSource().id;e.layers&&!r[a]||n.push(Rf(this._sourceCaches[t],this._layers,this._serializedLayers,o,e,i,s,!!this.map._showQueryGeometry))}return this.placement&&n.push(function(t,e,i,r,n,s,o){const a={},l=s.queryRenderedSymbols(r),c=[];for(const t of Object.keys(l).map(Number))c.push(o[t]);c.sort(Of);for(const i of c){const r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],e,i.bucketIndex,i.sourceLayerIndex,n.filter,n.layers,n.availableImages,t);for(const t in r){const e=a[t]=a[t]||[],n=r[t];n.sort(((t,e)=>{const r=i.featureSortOrder;if(r){const i=r.indexOf(t.featureIndex);return r.indexOf(e.featureIndex)-i}return e.featureIndex-t.featureIndex}));for(const t of n)e.push(t)}}for(const e in a)a[e].forEach((r=>{const n=r.feature,s=i(t[e]).getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=s}));return a}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),o.screenGeometry,e,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(n)}querySourceFeatures(t,e){e&&e.filter&&this._validate(Cn,"querySourceFeatures.filter",e.filter,null,e);const i=this._getSourceCaches(t);let r=[];for(const t of i)r=r.concat(Ff(t,e));return r}addSourceType(t,e,i){return Jm.getSourceType(t)?i(new Error(`A source type called "${t}" already exists.`)):(Jm.setSourceType(t,e),e.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:t,url:e.workerSourceURL},i):i(null,null))}getLight(){return this.light.getLight()}setLight(t,e={}){this._checkLoaded();const i=this.light.getLight();let r=!1;for(const e in t)if(!c(t[e],i[e])){r=!0;break}if(!r)return;const n={now:J.now(),transition:I({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,e),this.light.updateTransitions(n)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(t,e=1){if(this._checkLoaded(),!t)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(1===e){if("object"==typeof t.source){const e="terrain-dem-src";this.addSource(e,t.source),t=I(t=R(t),{source:e})}if(this._validate(Sn,"terrain",t))return}if(!this.terrain||this.terrain&&e!==this.terrain.drapeRenderMode)this._createTerrain(t,e);else{const e=this.terrain,i=e.get();for(const r in t)if(!c(t[r],i[r])){e.set(t),this.stylesheet.terrain=t;const i={now:J.now(),transition:I({duration:0},this.stylesheet.transition)};e.updateTransitions(i);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(t){const e=this.fog=new rp(t,this.map.transform);this.stylesheet.fog=t;const i={now:J.now(),transition:I({duration:0},this.stylesheet.transition)};e.updateTransitions(i)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask((()=>{for(const t of this.map._markers)t._evaluateOpacity()}))}getFog(){return this.fog?this.fog.get():null}setFog(t){if(this._checkLoaded(),!t)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const e=this.fog,i=e.get();for(const r in t)if(!c(t[r],i[r])){e.set(t),this.stylesheet.fog=t;const i={now:J.now(),transition:I({duration:0},this.stylesheet.transition)};e.updateTransitions(i);break}}else this._createFog(t);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const t=this._order.filter((t=>this.isLayerDraped(this._layers[t]))),e=this._order.filter((t=>!this.isLayerDraped(this._layers[t])));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...t),this._drapedFirstOrder.push(...e)}_createTerrain(t,e){const i=this.terrain=new Ju(t,e);this.stylesheet.terrain=t,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const r={now:J.now(),transition:I({duration:0},this.stylesheet.transition)};i.updateTransitions(r)}_force3DLayerUpdate(){for(const t in this._layers){const e=this._layers[t];"fill-extrusion"===e.type&&this._updateLayer(e)}}_forceSymbolLayerUpdate(){for(const t in this._layers){const e=this._layers[t];"symbol"===e.type&&this._updateLayer(e)}}_validate(t,e,i,r,n={}){return(!n||!1!==n.validate)&&Wm(this,t.call(Tn,I({key:e,style:this.serialize(),value:i,styleSpec:ue},r)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),as.off("pluginStateChange",this._rtlTextPluginCallback);for(const t in this._layers)this._layers[t].setEventedParent(null);for(const t in this._sourceCaches)this._sourceCaches[t].clearTiles(),this._sourceCaches[t].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(t){const e=this._getSourceCaches(t);for(const t of e)t.clearTiles()}_reloadSource(t){const e=this._getSourceCaches(t);for(const t of e)t.resume(),t.reload()}_updateSources(t){for(const e in this._sourceCaches)this._sourceCaches[e].update(t)}_generateCollisionBoxes(){for(const t in this._sourceCaches){const e=this._sourceCaches[t];e.resume(),e.reload()}}_updatePlacement(t,e,i,r,n=!1){let s=!1,o=!1;const a={};for(const e of this._order){const i=this._layers[e];if("symbol"!==i.type)continue;if(!a[i.source]){const t=this._getLayerSourceCache(i);if(!t)continue;a[i.source]=t.getRenderableIds(!0).map((e=>t.getTileByID(e))).sort(((t,e)=>e.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(e.tileID)?-1:1)))}const r=this.crossTileSymbolIndex.addLayer(i,a[i.source],t.center.lng,t.projection);s=s||r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),n=n||this._layerOrderChanged||0===i,this._layerOrderChanged&&this.fire(new le("neworder")),(n||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(J.now(),t.zoom))&&(this.pauseablePlacement=new Nm(t,this._order,n,e,i,r,this.placement,this.fog&&t.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,a),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(J.now()),o=!0),s&&this.pauseablePlacement.placement.setStale()),o||s)for(const t of this._order){const e=this._layers[t];"symbol"===e.type&&this.placement.updateLayerOpacities(e,a[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(J.now())}_releaseSymbolFadeTiles(){for(const t in this._sourceCaches)this._sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,e,i){this.imageManager.getImages(e.icons,i),this._updateTilesForChangedImages();const r=t=>{t&&t.setDependencies(e.tileID.key,e.type,e.icons)};r(this._otherSourceCaches[e.source]),r(this._symbolSourceCaches[e.source])}getGlyphs(t,e,i){this.glyphManager.getGlyphs(e.stacks,i)}getResource(t,e,i){return Kt(e,i)}_getSourceCache(t){return this._otherSourceCaches[t]}_getLayerSourceCache(t){return"symbol"===t.type?this._symbolSourceCaches[t.source]:this._otherSourceCaches[t.source]}_getSourceCaches(t){const e=[];return this._otherSourceCaches[t]&&e.push(this._otherSourceCaches[t]),this._symbolSourceCaches[t]&&e.push(this._symbolSourceCaches[t]),e}_isSourceCacheLoaded(t){const e=this._getSourceCaches(t);if(0!==e.length)return e.every((t=>t.loaded()));this.fire(new ce(new Error(`There is no source with ID '${t}'`)))}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)}}Jm.getSourceType=function(t){return Df[t]},Jm.setSourceType=function(t,e){Df[t]=e},Jm.registerForPluginStateChange=function(t){return t({pluginStatus:rs,pluginURL:ns}),as.on("pluginStateChange",t),t};var Qm="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#define EXTENT 8192.0\n#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}\n#endif",t_="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}";let e_={},i_={};e_=o_("","\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;\n#else\nuniform sampler2D u_dem;uniform sampler2D u_dem_prev;\n#endif\nuniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos));\n#ifdef TERRAIN_DEM_NEAREST_FILTER\nreturn u_exaggeration*tl;\n#endif\nfloat tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {return currentElevation(apos);}\n#endif\nfloat unpack_depth(vec4 rgba_depth)\n{const vec4 bit_shift=vec4(1.0/(256.0*256.0*256.0),1.0/(256.0*256.0),1.0/256.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(\nunpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy))\n);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nfloat tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a;\n#else\nvec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack);\n#endif\nreturn vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;vec4 bounds=vec4(d,vec2(1.0)-d);h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",!0),i_=o_("#ifdef FOG\nuniform float u_fog_temporal_offset;float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif","#ifdef FOG\nuniform mat4 u_fog_matrix;vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif",!0);const r_=o_("\nhighp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}\n#ifdef TERRAIN\nhighp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(256.0*256.0*256.0,256.0*256.0,256.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/256.0,1.0/256.0,1.0/256.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\n#endif","\nfloat wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}\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."),n_=Qm;var s_={background:o_("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:o_("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:o_("varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\ngl_FragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);\n#ifdef PROJECTION_GLOBE_VIEW\nvec2 scaled_extrude=extrude*a_scale;vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=scaled_extrude.x*surface_vectors[0]+scaled_extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);vec4 world_center=vec4(pos,1);\n#else \nmat3 surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);vec4 world_center=vec4(circle_center,height,1);\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\n#if defined(SCALE_WITH_MAP) && defined(PROJECTION_GLOBE_VIEW)\nview_scale*=a_scale;\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);vec4 occlusion_world_center=vec4(circle_center,cantilevered_height,1);vec4 occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nvec4 occlusion_world_center=world_center;vec4 occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}"),clippingMask:o_("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:o_("uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\ngl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);\n#ifdef PROJECTION_GLOBE_VIEW\nextrude*=a_scale;vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\nvec3 pos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),heatmapTexture:o_("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:o_("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:o_("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:o_("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:o_("#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:o_("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:o_("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:o_("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:o_("varying vec4 v_color;void main() {vec4 color=v_color;\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 pos=vec3(pos_nx.xy,h);\n#else\nvec3 pos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(pos.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.rgb+=clamp(color.rgb*directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),fillExtrusionPattern:o_("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);out_color=out_color*v_lighting;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 p=vec3(pos_nx.xy,h);\n#else\nvec3 p=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}"),hillshadePrepare:o_("#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:o_("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:o_("uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;uniform float u_mix;uniform vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;varying highp vec2 v_uv;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist_a=texture2D(u_dash_image,v_tex_a).a;float sdfdist_b=texture2D(u_dash_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfwidth=min(dash_from.z*u_scale.y,dash_to.z*u_scale.z);float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/sdfwidth;alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\n#ifdef RENDER_LINE_GRADIENT\nvec4 out_color=texture2D(u_gradient_image,v_uv);\n#else\nvec4 out_color=color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef RENDER_LINE_ALPHA_DISCARD\nif (alpha < u_alpha_discard_threshold) {discard;}\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define EXTRUDE_SCALE 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;\n#ifdef RENDER_LINE_GRADIENT\nattribute vec3 a_packed;\n#else\nattribute float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform mediump vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;varying highp vec2 v_uv;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];float a_linesofar=a_packed[2];highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);\n#endif\n#ifdef RENDER_LINE_DASH\nfloat tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;float scaleA=dash_from.z==0.0 ? 0.0 : tileZoomRatio/(dash_from.z*fromScale);float scaleB=dash_to.z==0.0 ? 0.0 : tileZoomRatio/(dash_to.z*toScale);float heightA=dash_from.y;float heightB=dash_to.y;v_tex_a=vec2(a_linesofar*scaleA/floorwidth,(-normal.y*heightA+dash_from.x+0.5)/u_texsize.y);v_tex_b=vec2(a_linesofar*scaleB/floorwidth,(-normal.y*heightB+dash_to.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),linePattern:o_("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:o_("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:o_("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform 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;\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[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchor_z=a_z_tile_anchor.x;vec2 tile_anchor=a_z_tile_anchor.yz;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(vec3(a_pos,anchor_z)+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(a_pos,anchor_z)+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) {vec4 offsetProjected_point=u_matrix*vec4(a_pos+vec2(1,0),anchor_z,1);vec2 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(vec3(a_projected_pos.xy,anchor_z),mercator_pos,u_zoom_transition);\n#else\nvec3 proj_pos=vec3(a_projected_pos.xy,anchor_z);\n#endif\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_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;gl_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));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}"),symbolSDF:o_("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_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;\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[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchor_z=a_z_tile_anchor.x;vec2 tile_anchor=a_z_tile_anchor.yz;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(vec3(a_pos,anchor_z)+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(a_pos,anchor_z)+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) {vec4 offsetprojected_point=u_matrix*vec4(a_pos+vec2(1,0),anchor_z,1);vec2 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(vec3(a_projected_pos.xy,anchor_z),mercator_pos,u_zoom_transition);\n#else\nvec3 proj_pos=vec3(a_projected_pos.xy,anchor_z);\n#endif\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;gl_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));float gamma_scale=gl_Position.w;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}"),symbolTextAndIcon:o_("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;\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[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchor_z=a_z_tile_anchor.x;vec2 tile_anchor=a_z_tile_anchor.yz;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(vec3(a_pos,anchor_z)+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(a_pos,anchor_z)+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),anchor_z,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(vec3(a_projected_pos.xy,anchor_z),mercator_pos,u_zoom_transition);\n#else\nvec3 proj_pos=vec3(a_projected_pos.xy,anchor_z);\n#endif\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*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;gl_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));float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}"),terrainRaster:o_("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef FOG\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nconst float skirtOffset=24575.0;const float wireframeOffset=0.00015;void main() {v_pos0=a_texture_pos/8192.0;float skirt=float(a_pos.x >=skirtOffset);float elevation=elevation(a_texture_pos)-skirt*u_skirt_height;\n#ifdef TERRAIN_WIREFRAME\nelevation+=u_skirt_height*u_skirt_height*wireframeOffset;\n#endif\nvec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n}"),terrainDepth:o_("#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:o_("\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}",t_),skyboxGradient:o_("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}",t_),skyboxCapture:o_("\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:o_("uniform sampler2D u_image0;varying vec2 v_pos0;void main() {gl_FragColor=texture2D(u_image0,v_pos0);\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_proj_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;attribute vec3 a_globe_pos;attribute vec2 a_merc_pos;attribute vec2 a_uv;varying vec2 v_pos0;const float wireframeOffset=1e3;void main() {v_pos0=a_uv;vec2 uv=a_uv*EXTENT;vec4 up_vector=vec4(elevationVector(uv),1.0);float height=elevation(uv);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nvec4 globe=u_globe_matrix*vec4(a_globe_pos+up_vector.xyz*height,1.0);vec4 mercator=vec4(0.0);if (u_zoom_transition > 0.0) {mercator=vec4(a_merc_pos,height,1.0);mercator.xy-=u_merc_center;mercator.x=wrap(mercator.x,-0.5,0.5);mercator=u_merc_matrix*mercator;}vec3 position=mix(globe.xyz,mercator.xyz,u_zoom_transition);gl_Position=u_proj_matrix*vec4(position,1.0);}"),globeAtmosphere:o_("uniform float u_opacity;uniform highp float u_fadeout_range;uniform vec3 u_start_color;uniform vec3 u_end_color;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;varying vec3 v_ray_dir;void main() {vec3 dir=normalize(v_ray_dir);vec3 closest_point=abs(dot(u_globe_pos,dir))*dir;float norm_dist_from_center=length(closest_point-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 1.0)\ndiscard;float t=clamp(1.0-sqrt(norm_dist_from_center-1.0)/u_fadeout_range,0.0,1.0);vec3 color=mix(u_start_color,u_end_color,1.0-t);gl_FragColor=vec4(color*t*u_opacity,u_opacity);}","attribute vec3 a_pos;attribute vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;varying vec3 v_ray_dir;void main() {v_ray_dir=mix(mix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);gl_Position=vec4(a_pos,1.0);}")};function o_(t,e,i){const r=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,n=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,s=e.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),o=t.match(n),a=e.match(n),l=Qm.match(n);let c=a?a.concat(o):o;i||(e_.staticUniforms&&(c=e_.staticUniforms.concat(c)),i_.staticUniforms&&(c=i_.staticUniforms.concat(c))),c&&(c=c.concat(l));const h={};return{fragmentSource:t=t.replace(r,((t,e,i,r,n)=>(h[n]=!0,"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nvarying ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = u_${n};\n#endif\n`))),vertexSource:e=e.replace(r,((t,e,i,r,n)=>{const s="float"===r?"vec2":"vec4",o=n.match(/color/)?"color":s;return h[n]?"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nattribute ${i} ${s} a_${n};\nvarying ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===o?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = unpack_mix_${o}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nattribute ${i} ${s} a_${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===o?`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = unpack_mix_${o}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`})),staticAttributes:s,staticUniforms:c}}class a_{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,e,i,r,n,s,o,a){this.context=t;let l=this.boundPaintVertexBuffers.length!==r.length;for(let t=0;!l&&t<r.length;t++)this.boundPaintVertexBuffers[t]!==r[t]&&(l=!0);t.extVertexArrayObject&&this.vao&&this.boundProgram===e&&this.boundLayoutVertexBuffer===i&&!l&&this.boundIndexBuffer===n&&this.boundVertexOffset===s&&this.boundDynamicVertexBuffer===o&&this.boundDynamicVertexBuffer2===a?(t.bindVertexArrayOES.set(this.vao),o&&o.bind(),n&&n.dynamicDraw&&n.bind(),a&&a.bind()):this.freshBind(e,i,r,n,s,o,a)}freshBind(t,e,i,r,n,s,o){let a;const l=t.numAttributes,c=this.context,h=c.gl;if(c.extVertexArrayObject)this.vao&&this.destroy(),this.vao=c.extVertexArrayObject.createVertexArrayOES(),c.bindVertexArrayOES.set(this.vao),a=0,this.boundProgram=t,this.boundLayoutVertexBuffer=e,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=r,this.boundVertexOffset=n,this.boundDynamicVertexBuffer=s,this.boundDynamicVertexBuffer2=o;else{a=c.currentNumAttributes||0;for(let t=l;t<a;t++)h.disableVertexAttribArray(t)}e.enableAttributes(h,t);for(const e of i)e.enableAttributes(h,t);s&&s.enableAttributes(h,t),o&&o.enableAttributes(h,t),e.bind(),e.setVertexAttribPointers(h,t,n);for(const e of i)e.bind(),e.setVertexAttribPointers(h,t,n);s&&(s.bind(),s.setVertexAttribPointers(h,t,n)),r&&r.bind(),o&&(o.bind(),o.setVertexAttribPointers(h,t,n)),c.currentNumAttributes=l}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}function l_(t,e){const i=Math.pow(2,e.canonical.z),r=e.canonical.y;return[new ba(0,r/i).toLngLat().lat,new ba(0,(r+1)/i).toLngLat().lat]}function c_(t,e,i,r,n,s,o){const a=t.context,l=a.gl,c=i.fbo;if(!c)return;t.prepareDrawTile();const h=t.useProgram("hillshade");a.activeTexture.set(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,c.colorAttachment.get());const u=((t,e,i,r)=>{const n=i.paint.get("hillshade-shadow-color"),s=i.paint.get("hillshade-highlight-color"),o=i.paint.get("hillshade-accent-color");let a=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===i.paint.get("hillshade-illumination-anchor")&&(a-=t.transform.angle);const l=!t.options.moving;return{u_matrix:r||t.transform.calculateProjMatrix(e.tileID.toUnwrapped(),l),u_image:0,u_latrange:l_(0,e.tileID),u_light:[i.paint.get("hillshade-exaggeration"),a],u_shadow:n,u_highlight:s,u_accent:o}})(t,i,r,t.terrain?e.projMatrix:null);t.prepareDrawProgram(a,h,e.toUnwrapped());const{tileBoundsBuffer:p,tileBoundsIndexBuffer:d,tileBoundsSegments:f}=t.getTileBoundsBuffers(i);h.draw(a,l.TRIANGLES,n,s,o,xf.disabled,u,r.id,p,d,f)}function h_(t,e,i){if(!e.needsDEMTextureUpload)return;const r=t.context,n=r.gl;r.pixelStoreUnpackPremultiplyAlpha.set(!1),e.demTexture=e.demTexture||t.getTileTexture(i.stride);const s=i.getPixels();e.demTexture?e.demTexture.update(s,{premultiply:!1}):e.demTexture=new qu(r,s,n.RGBA,{premultiply:!1}),e.needsDEMTextureUpload=!1}function u_(t,e,i,r,n,s){const o=t.context,a=o.gl;if(!e.dem)return;const l=e.dem;if(o.activeTexture.set(a.TEXTURE1),h_(t,e,l),!e.demTexture)return;e.demTexture.bind(a.NEAREST,a.CLAMP_TO_EDGE);const c=l.dim;o.activeTexture.set(a.TEXTURE0);let h=e.fbo;if(!h){const t=new qu(o,{width:c,height:c,data:null},a.RGBA);t.bind(a.LINEAR,a.CLAMP_TO_EDGE),h=e.fbo=o.createFramebuffer(c,c,!0),h.colorAttachment.set(t.texture)}o.bindFramebuffer.set(h.framebuffer),o.viewport.set([0,0,c,c]);const{tileBoundsBuffer:u,tileBoundsIndexBuffer:p,tileBoundsSegments:d}=t.getMercatorTileBoundsBuffers();t.useProgram("hillshadePrepare").draw(o,a.TRIANGLES,r,n,s,xf.disabled,((t,e)=>{const i=e.stride,r=il();return dl(r,0,la,-8192,0,0,1),ol(r,r,[0,-8192,0]),{u_matrix:r,u_image:1,u_dimension:[i,i],u_zoom:t.overscaledZ,u_unpack:e.unpackVector}})(e.tileID,l),i.id,u,p,d),e.needsHillshadePrepare=!1}const p_=(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_image0:new Po(t,e.u_image0),u_skirt_height:new Do(t,e.u_skirt_height)}),d_=(t,e)=>({u_matrix:t,u_image0:0,u_skirt_height:e}),f_=(t,e,i,r,n)=>({u_proj_matrix:Float32Array.from(t),u_globe_matrix:e,u_merc_matrix:i,u_zoom_transition:r,u_merc_center:n,u_image0:0});function m_(t,e){return null!=t&&null!=e&&!(!t.hasData()||!e.hasData())&&null!=t.demTexture&&null!=e.demTexture&&t.tileID.key!==e.tileID.key}const __=new class{constructor(){this.operations={}}newMorphing(t,e,i,r,n){if(t in this.operations){const e=this.operations[t];e.to.tileID.key!==i.tileID.key&&(e.queued=i)}else this.operations[t]={startTime:r,phase:0,duration:n,from:e,to:i,queued:null}}getMorphValuesForProxy(t){if(!(t in this.operations))return null;const e=this.operations[t];return{from:e.from,to:e.to,phase:e.phase}}update(t){for(const e in this.operations){const i=this.operations[e];for(i.phase=(t-i.startTime)/i.duration;i.phase>=1||!this._validOp(i);)if(!this._nextOp(i,t)){delete this.operations[e];break}}}_nextOp(t,e){return!!t.queued&&(t.from=t.to,t.to=t.queued,t.queued=null,t.phase=0,t.startTime=e,!0)}_validOp(t){return t.from.hasData()&&t.to.hasData()}},g_={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function y_(t,e){const i=1<<t.z;return!e&&(0===t.x||t.x===i-1)||0===t.y||t.y===i-1}const x_=t=>({u_matrix:t});function v_(t,e,i,r,n){if(n>0){const s=J.now(),o=(s-t.timeAdded)/n,a=e?(s-e.timeAdded)/n:-1,l=i.getSource(),c=r.coveringZoomLevel({tileSize:l.tileSize,roundZoom:l.roundZoom}),h=!e||Math.abs(e.tileID.overscaledZ-c)>Math.abs(t.tileID.overscaledZ-c),u=h&&t.refreshedUponExpiration?1:v(h?o:1-a,0,1);return t.refreshedUponExpiration&&o>=1&&(t.refreshedUponExpiration=!1),e?{opacity:1,mix:1-u}:{opacity:u,mix:0}}return{opacity:1,mix:0}}class b_ extends bf{constructor(t){const e={type:"raster-dem",maxzoom:t.transform.maxZoom},i=new ap(Zf(),null),r=Bf("mock-dem",e,i,t.style);super("mock-dem",r,!1),r.setEventedParent(this),this._sourceLoaded=!0}_loadTile(t,e){t.state="loaded",e(null)}}class w_ extends bf{constructor(t){const e=Bf("proxy",{type:"geojson",maxzoom:t.transform.maxZoom},new ap(Zf(),null),t.style);super("proxy",e,!1),e.setEventedParent(this),this.map=this.getSource().map=t,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(t,e,i){if(t.freezeTileCoverage)return;this.transform=t;const r=t.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce(((e,i)=>{if(e[i.key]="",!this._tiles[i.key]){const e=new dd(i,this._source.tileSize*i.overscaleFactor(),t.tileZoom);e.state="loaded",this._tiles[i.key]=e}return e}),{});for(const t in this._tiles)t in r||(this.freeFBO(t),this._tiles[t].unloadVectorData(),delete this._tiles[t])}freeFBO(t){const e=this.proxyCachedFBO[t];if(void 0!==e){const i=Object.values(e);this.renderCachePool.push(...i),delete this.proxyCachedFBO[t]}}deallocRenderCache(){this.renderCache.forEach((t=>t.fb.destroy())),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class T_ extends Zp{constructor(t,e,i){super(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y),this.proxyTileKey=e,this.projMatrix=i}}class E_ extends class{isDataAvailableAtPoint(t){const e=this._source();if(!e||t.y<0||t.y>1)return!1;const i=e.getSource().maxzoom,r=1<<i,n=Math.floor(t.x),s=Math.floor((t.x-n)*r),o=Math.floor(t.y*r),a=this.findDEMTileFor(new Zp(i,n,i,s,o));return a&&a.dem}getAtPointOrZero(t,e=0){return this.getAtPoint(t,e)||0}getAtPoint(t,e,i=!0){null==e&&(e=null);const r=this._source();if(!r)return e;if(t.y<0||t.y>1)return e;const n=r.getSource().maxzoom,s=1<<n,o=Math.floor(t.x),a=t.x-o,l=new Zp(n,o,n,Math.floor(a*s),Math.floor(t.y*s)),c=this.findDEMTileFor(l);if(!c||!c.dem)return e;const h=c.dem,u=1<<c.tileID.canonical.z,p=(a*u-c.tileID.canonical.x)*h.dim,d=(t.y*u-c.tileID.canonical.y)*h.dim,f=Math.floor(p),m=Math.floor(d);return(i?this.exaggeration():1)*Ai(Ai(h.get(f,m),h.get(f,m+1),d-m),Ai(h.get(f+1,m),h.get(f+1,m+1),d-m),p-f)}getAtTileOffset(t,e,i){const r=1<<t.canonical.z;return this.getAtPointOrZero(new ba(t.wrap+(t.canonical.x+e/la)/r,(t.canonical.y+i/la)/r))}getAtTileOffsetFunc(t,e,i,r){return n=>{const s=this.getAtTileOffset(t,n.x,n.y),o=r.upVector(t.canonical,n.x,n.y);return El(o,o,s*r.upVectorScale(t.canonical,e,i).metersToTile),o}}getForTilePoints(t,e,i,r){const n=Ef.create(this,t,r);return!!n&&(e.forEach((t=>{t[2]=this.exaggeration()*n.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,r=e.tileID,n=1<<t.canonical.z-r.canonical.z;let s=t.canonical.x/n-r.canonical.x,o=t.canonical.y/n-r.canonical.y,a=0;for(let e=0;e<t.canonical.z-r.canonical.z&&!i.leaves[a];e++){s*=2,o*=2;const t=2*Math.floor(o)+Math.floor(s);a=i.childOffsets[a]+t,s%=1,o%=1}return{min:this.exaggeration()*i.minimums[a],max:this.exaggeration()*i.maximums[a]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(t,e,i){throw new Error("Pure virtual method called.")}pointCoordinate(t){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(t){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}}{constructor(t,e){super(),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[i,r,n]=function(t){const e=new Bs,i=new $s,r=131;e.reserve(17161),i.reserve(33800);for(let t=-64;t<8288;t+=64)for(let i=-64;i<8288;i+=64){const r=i<0||i>8224||t<0||t>8224?24575:0,n=v(Math.round(i),0,la),s=v(Math.round(t),0,la);e.emplaceBack(n+r,s,n,s)}const n=(t,e)=>{const n=e*r+t;i.emplaceBack(n+1,n,n+r),i.emplaceBack(n+r,n+r+1,n+1)};for(let t=1;t<129;t++)for(let e=1;e<129;e++)n(e,t);return[0,129].forEach((t=>{for(let e=0;e<130;e++)n(e,t),n(t,e)})),[e,i,32768]}(),s=t.context;this.gridBuffer=s.createVertexBuffer(i,ud.members),this.gridIndexBuffer=s.createIndexBuffer(r),this.gridSegments=aa.simpleSegment(0,0,i.length,r.length),this.gridNoSkirtSegments=aa.simpleSegment(0,0,i.length,n),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new w_(e.map),this.orthoMatrix=il(),dl(this.orthoMatrix,0,la,0,la,0,1);const o=s.gl;this._overlapStencilMode=new mf({func:o.GEQUAL,mask:255},0,255,o.KEEP,o.KEEP,o.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=e,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new b_(e.map)}set style(t){t.on("data",this._onStyleDataEvent.bind(this)),t.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=t,this._checkRenderCacheEfficiency()}update(t,e,i){if(t&&t.terrain){this._style!==t&&(this.style=t),this.enabled=!0;const r=t.terrain.properties;this.sourceCache=0===t.terrain.drapeRenderMode?this._mockSourceCache:t._getSourceCache(r.get("source")),this._exaggeration=r.get("exaggeration");const n=()=>{this.sourceCache.used&&O(`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 t=this.getScaledDemTileSize();this.sourceCache.update(e,t,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,n(),this._initializing=!0),n(),e.updateElevation(!i),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(e),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(t){this._findCoveringTileCache[t]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const t=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||100!==t.efficiency&&O(`Terrain render cache efficiency is not optimal (${t.efficiency}%) and performance\n may be affected negatively, consider placing all background, fill and line layers before layer\n with id '${t.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(t){t.coord&&"source"===t.dataType?this._clearRenderCacheForTile(t.sourceCacheId,t.coord):"style"===t.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const t in this._style._sourceCaches)this._style._sourceCaches[t].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach((t=>t.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 t=2*this.proxySourceCache.getSource().tileSize;return[t,t]}set useVertexMorphing(t){this._useVertexMorphing=t}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const e=this.proxySourceCache,i=this.painter.transform;this._initializing&&(this._initializing=0===i._centerAltitude&&-1===this.getAtPointOrZero(ba.fromLngLat(i.center),-1),this._emptyDEMTextureDirty=!this._initializing);const r=this.proxyCoords=e.getIds().map((t=>{const r=e.getTileByID(t).tileID;return r.projMatrix=i.calculateProjMatrix(r.toUnwrapped()),r}));!function(t,e){const i=e.transform.pointCoordinate(e.transform.getCameraPoint()),r=new o(i.x,i.y);t.sort(((t,e)=>{if(e.overscaledZ-t.overscaledZ)return e.overscaledZ-t.overscaledZ;const i=new o(t.canonical.x+(1<<t.canonical.z)*t.wrap,t.canonical.y),n=new o(e.canonical.x+(1<<e.canonical.z)*e.wrap,e.canonical.y),s=r.mult(1<<t.canonical.z);return s.x-=.5,s.y-=.5,s.distSqr(i)-s.distSqr(n)}))}(r,this.painter),this._previousZoom=i.zoom;const n=this.proxyToSource||{};this.proxyToSource={},r.forEach((t=>{this.proxyToSource[t.key]={}})),this.terrainTileForTile={};const s=this._style._sourceCaches;for(const e in s){const i=s[e];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,t[e],n),i.usedForTerrain)continue;const r=t[e];i.getSource().reparseOverscaled&&this._assignTerrainTiles(r)}this.proxiedCoords[e.id]=r.map((t=>new T_(t,t.key,this.orthoMatrix))),this._assignTerrainTiles(r),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(n),this.renderingToTexture=!1,this._updateTimestamp=J.now();const a={};this._visibleDemTiles=[];for(const t of this.proxyCoords){const e=this.terrainTileForTile[t.key];if(!e)continue;const i=e.tileID.key;i in a||(this._visibleDemTiles.push(e),a[i]=i)}}_assignTerrainTiles(t){this._initializing||t.forEach((t=>{if(this.terrainTileForTile[t.key])return;const e=this._findTileCoveringTileID(t,this.sourceCache);e&&(this.terrainTileForTile[t.key]=e)}))}_prepareDEMTextures(){const t=this.painter.context,e=t.gl;for(const i in this.terrainTileForTile){const r=this.terrainTileForTile[i],n=r.dem;!n||r.demTexture&&!r.needsDEMTextureUpload||(t.activeTexture.set(e.TEXTURE1),h_(this.painter,r,n))}}_prepareDemTileUniforms(t,e,i,r){if(!e||null==e.demTexture)return!1;const n=t.tileID.canonical,s=Math.pow(2,e.tileID.canonical.z-n.z),o=r||"";return i[`u_dem_tl${o}`]=[n.x*s%1,n.y*s%1],i[`u_dem_scale${o}`]=s,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const t=this.painter.context,e=t.gl;if(!this._emptyDepthBufferTexture){const i=new ec({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new qu(t,i,e.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let t=0;const e=this._visibleDemTiles.reduce(((e,i)=>{if(!i.dem)return e;const r=i.dem.tree.minimums[0];return r>0&&t++,e+r}),0);return t?e/t:0}_updateEmptyDEMTexture(){const t=this.painter.context,e=t.gl;t.activeTexture.set(e.TEXTURE2);const i=this._getLoadedAreaMinimum(),r=new ec({width:1,height:1},new Uint8Array(Ed.pack(i,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let n=this._emptyDEMTexture;return n?n.update(r,{premultiply:!1}):n=this._emptyDEMTexture=new qu(t,r,e.RGBA,{premultiply:!1}),n}setupElevationDraw(t,e,i){const r=this.painter.context,n=r.gl,s=(o=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:Ed.getUnpackVector(o),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 o;s.u_dem_size=this.sourceCache.getSource().tileSize,s.u_exaggeration=this.exaggeration();const a=this.painter.transform,l=a.projection,c=t.tileID.canonical;s.u_tile_tl_up=l.upVector(c,0,0),s.u_tile_tr_up=l.upVector(c,la,0),s.u_tile_br_up=l.upVector(c,la,la),s.u_tile_bl_up=l.upVector(c,0,la),s.u_tile_up_scale=l.upVectorScale(c,a.center.lat,a.worldSize).metersToTile;let h=null,u=null,p=1;if(i&&i.morphing&&this._useVertexMorphing){const e=i.morphing.srcDemTile,r=i.morphing.dstDemTile;p=i.morphing.phase,e&&r&&(this._prepareDemTileUniforms(t,e,s,"_prev")&&(u=e),this._prepareDemTileUniforms(t,r,s)&&(h=r))}if(u&&h?(r.activeTexture.set(n.TEXTURE2),h.demTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE,n.NEAREST),r.activeTexture.set(n.TEXTURE4),u.demTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE,n.NEAREST),s.u_dem_lerp=p):(h=this.terrainTileForTile[t.tileID.key],r.activeTexture.set(n.TEXTURE2),(this._prepareDemTileUniforms(t,h,s)?h.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&&(s.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE),s.u_depth_size_inv=[1,1]),i&&i.useMeterToDem&&h){const t=(1<<h.tileID.canonical.z)*_a(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;s.u_meter_to_dem=t}i&&i.labelPlaneMatrixInv&&(s.u_label_plane_matrix_inv=i.labelPlaneMatrixInv),e.setTerrainUniformValues(r,s)}renderToBackBuffer(t){const e=this.painter,i=this.painter.context;0!==t.length&&(i.bindFramebuffer.set(null),i.viewport.set([0,0,e.width,e.height]),this.renderingToTexture=!1,function(t,e,i,r,n){if("globe"===t.transform.projection.name)!function(t,e,i,r,n){const s=t.context,o=s.gl;let a,l;const c=t.options.showTerrainWireframe?2:0,h=(e,i)=>{if(l===e)return;const r=[g_[e],"PROJECTION_GLOBE_VIEW"];i&&r.push(g_[c]),a=t.useProgram("globeRaster",null,r),l=e},u=t.colorModeForRenderPass(),p=new df(o.LEQUAL,df.ReadWrite,t.depthRangeFor3D);__.update(n);const d=t.transform,f=function(t){const e=t.worldSize,i=t.point,r=_a(1,t.center.lat)*e,n=t.pixelsPerMeter,s=e/(r/t.pixelsPerMeter),o=rl(new Float64Array(16));return ol(o,o,[i.x,i.y,0]),al(o,o,[s,s,n]),Float32Array.from(o)}(d),_=[fa(d.center.lng),ma(d.center.lat)],g=t.globeSharedBuffers;(c?[!1,!0]:[!1]).forEach((c=>{l=-1;const y=c?o.LINES:o.TRIANGLES;for(const l of r){const r=i.getTile(l),x=Dp(t,r,l),v=mf.disabled,b=e.prevTerrainTileForTile[l.key],w=e.terrainTileForTile[l.key];m_(b,w)&&__.newMorphing(l.key,b,w,n,250),s.activeTexture.set(o.TEXTURE0),r.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE);const T=__.getMorphValuesForProxy(l.key),E=T?1:0,I={};T&&pe(I,{morphing:{srcDemTile:T.from,dstDemTile:T.to,phase:m(T.phase)}});const S=Bp(l.canonical,d.globeMatrix),A=f_(d.projMatrix,S,f,Pp(d.zoom),_);if(h(E,c),e.setupElevationDraw(r,a,I),t.prepareDrawProgram(s,a,l.toUnwrapped()),g){const[e,i]=c?g.getWirefameBuffer(t.context):[g.gridIndexBuffer,g.gridSegments];a.draw(s,y,p,v,u,xf.backCCW,A,"globe_raster",x,e,i)}if(!c&&g){const{x:t,y:e,z:i}=l.canonical,r=0===e,n=e===(1<<i)-1,o=g.poleSegments[i];if(o&&(r||n)){let e=Lp(i,t,d);const l=(t,i)=>t.draw(s,y,p,v,u,xf.disabled,f_(d.projMatrix,e,e,0,_),"globe_pole_raster",i,g.poleIndexBuffer,o);r&&l(a,g.poleNorthVertexBuffer),n&&(e=al(il(),e,[1,-1,1]),l(a,g.poleSouthVertexBuffer))}}}}))}(t,e,i,r,n);else{const s=t.context,o=s.gl;let a,l;const c=t.options.showTerrainWireframe?2:0,h=(e,i)=>{if(l===e)return;const r=[g_[e]];i&&r.push(g_[c]),a=t.useProgram("terrainRaster",null,r),l=e},u=t.colorModeForRenderPass(),p=new df(o.LEQUAL,df.ReadWrite,t.depthRangeFor3D);__.update(n);const d=t.transform,f=6*Math.pow(1.5,22-d.zoom)*e.exaggeration();(c?[!1,!0]:[!1]).forEach((c=>{l=-1;const _=c?o.LINES:o.TRIANGLES,[g,y]=c?e.getWirefameBuffer():[e.gridIndexBuffer,e.gridSegments];for(const l of r){const r=i.getTile(l),x=mf.disabled,v=e.prevTerrainTileForTile[l.key],b=e.terrainTileForTile[l.key];m_(v,b)&&__.newMorphing(l.key,v,b,n,250),s.activeTexture.set(o.TEXTURE0),r.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE,o.LINEAR_MIPMAP_NEAREST);const w=__.getMorphValuesForProxy(l.key),T=w?1:0;let E;w&&(E={morphing:{srcDemTile:w.from,dstDemTile:w.to,phase:m(w.phase)}});const I=d_(l.projMatrix,y_(l.canonical,d.renderWorldCopies)?f/10:f);h(T,c),e.setupElevationDraw(r,a,E),t.prepareDrawProgram(s,a,l.toUnwrapped()),a.draw(s,_,p,x,u,xf.backCCW,I,"terrain_raster",e.gridBuffer,g,y)}}))}}(e,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,t.splice(0,t.length))}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;const e=this.painter,i=this.painter.context,r=this.proxySourceCache,n=this.proxiedCoords[r.id],s=this._drapedRenderBatches.shift(),o=[],a=e.style.order;let l=0;for(const c of n){const n=r.getTileByID(c.proxyTileKey),h=r.proxyCachedFBO[c.key]?r.proxyCachedFBO[c.key][t]:void 0,u=void 0!==h?r.renderCache[h]:this.pool[l++],p=void 0!==h;if(n.texture=u.tex,p&&!u.dirty){o.push(n.tileID);continue}let d;i.bindFramebuffer.set(u.fb.framebuffer),this.renderedToTile=!1,u.dirty&&(i.clear({color:Le.transparent,stencil:0}),u.dirty=!1);for(let t=s.start;t<=s.end;++t){const r=e.style._layers[a[t]];if(r.isHidden(e.transform.zoom))continue;const n=e.style._getLayerSourceCache(r),s=n?this.proxyToSource[c.key][n.id]:[c];if(!s)continue;const o=s;i.viewport.set([0,0,u.fb.width,u.fb.height]),d!==(n?n.id:null)&&(this._setupStencil(u,s,r,n),d=n?n.id:null),e.renderLayer(e,n,r,o)}this.renderedToTile?(u.dirty=!0,o.push(n.tileID)):p||--l,5===l&&(l=0,this.renderToBackBuffer(o))}return this.renderToBackBuffer(o),this.renderingToTexture=!1,i.bindFramebuffer.set(null),i.viewport.set([0,0,e.width,e.height]),s.end+1}postRender(){}renderCacheEfficiency(t){const e=t.order.length;if(0===e)return{efficiency:100};let i,r=0,n=0,s=!1;for(let o=0;o<e;++o){const e=t._layers[t.order[o]];this._style.isLayerDraped(e)?(s&&++r,++n):s||(s=!0,i=e.id)}return 0===n?{efficiency:100}:{efficiency:100*(1-r/n),firstUndrapedLayer:i}}getMinElevationBelowMSL(){let t=0;return this._visibleDemTiles.filter((t=>t.dem)).forEach((e=>{t=Math.min(t,e.dem.tree.minimums[0])})),0===t?t:(t-30)*this._exaggeration}raycast(t,e,i){if(!this._visibleDemTiles)return null;const r=this._visibleDemTiles.filter((t=>t.dem)).map((r=>{const n=r.tileID,s=Math.pow(2,n.overscaledZ),{x:o,y:a}=n.canonical,l=o/s,c=(o+1)/s,h=a/s,u=(a+1)/s;return{minx:l,miny:h,maxx:c,maxy:u,t:r.dem.tree.raycastRoot(l,h,c,u,t,e,i),tile:r}}));r.sort(((t,e)=>(null!==t.t?t.t:Number.MAX_VALUE)-(null!==e.t?e.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,t,e,i);if(null!=r)return r}return null}_createFBO(){const t=this.painter.context,e=t.gl,i=this.drapeBufferSize;t.activeTexture.set(e.TEXTURE0);const r=new qu(t,{width:i[0],height:i[1],data:null},e.RGBA);r.bind(e.LINEAR,e.CLAMP_TO_EDGE);const n=t.createFramebuffer(i[0],i[1],!1);return n.colorAttachment.set(r.texture),n.depthAttachment=new uf(t,n.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,i[0],i[1]),this._stencilRef=0,n.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):n.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&!t.extTextureFilterAnisotropicForceOff&&e.texParameterf(e.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.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 t in this._style._sourceCaches)if(this._style._sourceCaches[t].hasTransition())return!0;return this._style.order.some((t=>{const e=this._style._layers[t],i=e.isHidden(this.painter.transform.zoom),r=e.getCrossfadeParameters(),n=!!r&&1!==r.t,s=e.hasTransition();return"custom"!==e.type&&!i&&(n||s)}))}_clearRasterFadeFromRenderCache(){let t=!1;for(const e in this._style._sourceCaches)if(this._style._sourceCaches[e]._source instanceof Cf){t=!0;break}if(t)for(let t=0;t<this._style.order.length;++t){const e=this._style._layers[this._style.order[t]],i=e.isHidden(this.painter.transform.zoom),r=this._style._getLayerSourceCache(e);if("raster"!==e.type||i||!r)continue;const n=e.paint.get("raster-fade-duration");for(const t of this.proxyCoords){const e=this.proxyToSource[t.key][r.id];if(e)for(const t of e){const e=v_(r.getTile(t),r.findLoadedParent(t,0),r,this.painter.transform,n);(1!==e.opacity||0!==e.mix)&&this._clearRenderCacheForTile(r.id,t)}}}}_setupDrapedRenderBatches(){const t=this._style.order,e=t.length;if(0===e)return;const i=[];let r,n=0,s=this._style._layers[t[n]];for(;!this._style.isLayerDraped(s)&&s.isHidden(this.painter.transform.zoom)&&++n<e;)s=this._style._layers[t[n]];for(;n<e;++n){const e=this._style._layers[t[n]];e.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(e)?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(t){const e=this.proxySourceCache;if(this._shouldDisableRenderCache()||this._invalidateRenderCache){if(this._invalidateRenderCache=!1,e.renderCache.length>e.renderCachePool.length){const t=Object.values(e.proxyCachedFBO);e.proxyCachedFBO={};for(let i=0;i<t.length;++i){const r=Object.values(t[i]);e.renderCachePool.push(...r)}}return}this._clearRasterFadeFromRenderCache();const i=this.proxyCoords,r=this._tilesDirty;for(let n=i.length-1;n>=0;n--){const s=i[n];if(e.getTileByID(s.key),void 0!==e.proxyCachedFBO[s.key]){const i=t[s.key],n=this.proxyToSource[s.key];let o=0;for(const t in n){const e=n[t],s=i[t];if(!s||s.length!==e.length||e.some(((e,i)=>e!==s[i]||r[t]&&r[t].hasOwnProperty(e.key)))){o=-1;break}++o}for(const t in e.proxyCachedFBO[s.key])e.renderCache[e.proxyCachedFBO[s.key][t]].dirty=o<0||o!==Object.values(i).length}}const n=[...this._drapedRenderBatches];n.sort(((t,e)=>e.end-e.start-(t.end-t.start)));for(const t of n)for(const r of i){if(e.proxyCachedFBO[r.key])continue;let i=e.renderCachePool.pop();void 0===i&&e.renderCache.length<50&&(i=e.renderCache.length,e.renderCache.push(this._createFBO())),void 0!==i&&(e.proxyCachedFBO[r.key]={},e.proxyCachedFBO[r.key][t.start]=i,e.renderCache[i].dirty=!0)}this._tilesDirty={}}_setupStencil(t,e,i,r){if(!r||!this._sourceTilesOverlap[r.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const n=this.painter.context,s=n.gl;if(e.length<=1)return void(this._overlapStencilType=!1);let o;if(i.isTileClipped())o=e.length,this._overlapStencilMode.test={func:s.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(e[0].overscaledZ>e[e.length-1].overscaledZ))return void(this._overlapStencilType=!1);o=1,this._overlapStencilMode.test={func:s.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+o>255&&(n.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=o,this._overlapStencilMode.ref=this._stencilRef,i.isTileClipped()&&this._renderTileClippingMasks(e,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(t){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs.get(t.key)||0),this._overlapStencilMode):mf.disabled}_renderTileClippingMasks(t,e){const i=this.painter,r=this.painter.context,n=r.gl;i._tileClippingMaskIDs.clear(),r.setColorMode(_f.disabled),r.setDepthMode(df.disabled);const s=i.useProgram("clippingMask");for(const o of t){const t=--e;i._tileClippingMaskIDs.set(o.key,t),s.draw(r,n.TRIANGLES,df.disabled,new mf({func:n.ALWAYS,mask:0},t,255,n.KEEP,n.KEEP,n.REPLACE),_f.disabled,xf.disabled,x_(o.projMatrix),"$clipping",i.tileExtentBuffer,i.quadTriangleIndexBuffer,i.tileExtentSegments)}}pointCoordinate(t){const e=this.painter.transform;if(t.x<0||t.x>e.width||t.y<0||t.y>e.height)return null;const i=[t.x,t.y,1,1];Ol(i,i,e.pixelMatrixInverse),Fl(i,i,1/i[3]),i[0]/=e.worldSize,i[1]/=e.worldSize;const r=e._camera.position,n=_a(1,e.center.lat),s=[r[0],r[1],r[2]/n,0],o=vl([],i.slice(0,3),s);Sl(o,o);const a=this.raycast(s,o,this._exaggeration);return null!==a&&a?(Il(s,s,o,a),s[3]=s[2],s[2]*=n,s):null}drawDepth(){const t=this.painter,e=t.context,i=this.proxySourceCache,r=Math.ceil(t.width),n=Math.ceil(t.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 t=e.gl,i=e.createFramebuffer(r,n,!0);e.activeTexture.set(t.TEXTURE0);const s=new qu(e,{width:r,height:n,data:null},t.RGBA);s.bind(t.NEAREST,t.CLAMP_TO_EDGE),i.colorAttachment.set(s.texture);const o=e.createRenderbuffer(e.gl.DEPTH_COMPONENT16,r,n);i.depthAttachment.set(o),this._depthFBO=i,this._depthTexture=s}e.bindFramebuffer.set(this._depthFBO.framebuffer),e.viewport.set([0,0,r,n]),function(t,e,i,r){if("globe"===t.transform.projection.name)return;const n=t.context,s=n.gl;n.clear({depth:1});const o=t.useProgram("terrainDepth"),a=new df(s.LESS,df.ReadWrite,t.depthRangeFor3D);for(const t of r){const r=i.getTile(t),l=d_(t.projMatrix,0);e.setupElevationDraw(r,o),o.draw(n,s.TRIANGLES,a,mf.disabled,_f.unblended,xf.backCCW,l,"terrain_depth",e.gridBuffer,e.gridIndexBuffer,e.gridNoSkirtSegments)}}(t,this,i,this.proxyCoords)}_setupProxiedCoordsForOrtho(t,e,i){if(t.getSource()instanceof Pf)return this._setupProxiedCoordsForImageSource(t,e,i);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const r=this.proxiedCoords[t.id]=[],n=this.proxyCoords;for(let e=0;e<n.length;e++){const s=n[e],o=this._findTileCoveringTileID(s,t);if(o){const e=this._createProxiedId(s,o,i[s.key]&&i[s.key][t.id]);r.push(e),this.proxyToSource[s.key][t.id]=[e]}}let s=!1;for(let n=0;n<e.length;n++){const o=t.getTile(e[n]);if(!o||!o.hasData())continue;const a=this._findTileCoveringTileID(o.tileID,this.proxySourceCache);if(a&&a.tileID.canonical.z!==o.tileID.canonical.z){const e=this.proxyToSource[a.tileID.key][t.id],n=this._createProxiedId(a.tileID,o,i[a.tileID.key]&&i[a.tileID.key][t.id]);e?e.splice(e.length-1,0,n):this.proxyToSource[a.tileID.key][t.id]=[n],r.push(n),s=!0}}this._sourceTilesOverlap[t.id]=s}_setupProxiedCoordsForImageSource(t,e,i){if(!t.getSource().loaded())return;const r=this.proxiedCoords[t.id]=[],n=this.proxyCoords,s=t.getSource(),a=new o(s.tileID.x,s.tileID.y)._div(1<<s.tileID.z),l=s.coordinates.map(ba.fromLngLat).reduce(((t,e)=>(t.min.x=Math.min(t.min.x,e.x-a.x),t.min.y=Math.min(t.min.y,e.y-a.y),t.max.x=Math.max(t.max.x,e.x-a.x),t.max.y=Math.max(t.max.y,e.y-a.y),t)),{min:new o(Number.MAX_VALUE,Number.MAX_VALUE),max:new o(-Number.MAX_VALUE,-Number.MAX_VALUE)}),c=(t,e)=>{const i=t.wrap+t.canonical.x/(1<<t.canonical.z),r=t.canonical.y/(1<<t.canonical.z),n=la/(1<<t.canonical.z),s=e.wrap+e.canonical.x/(1<<e.canonical.z),o=e.canonical.y/(1<<e.canonical.z);return i+n<s+l.min.x||i>s+l.max.x||r+n<o+l.min.y||r>o+l.max.y};for(let s=0;s<n.length;s++){const o=n[s];for(let n=0;n<e.length;n++){const s=t.getTile(e[n]);if(!s||!s.hasData())continue;if(c(o,s.tileID))continue;const a=this._createProxiedId(o,s,i[o.key]&&i[o.key][t.id]),l=this.proxyToSource[o.key][t.id];l?l.push(a):this.proxyToSource[o.key][t.id]=[a],r.push(a)}}}_createProxiedId(t,e,i){let r=this.orthoMatrix;if(i){const t=i.find((t=>t.key===e.tileID.key));if(t)return t}if(e.tileID.key!==t.key){const i=t.canonical.z-e.tileID.canonical.z;let n,s,o;r=il();const a=e.tileID.wrap-t.wrap<<t.overscaledZ;i>0?(n=la>>i,s=n*((e.tileID.canonical.x<<i)-t.canonical.x+a),o=n*((e.tileID.canonical.y<<i)-t.canonical.y)):(n=la<<-i,s=la*(e.tileID.canonical.x-(t.canonical.x+a<<-i)),o=la*(e.tileID.canonical.y-(t.canonical.y<<-i))),dl(r,0,n,0,n,0,1),ol(r,r,[s,o,0])}return new T_(e.tileID,t.key,r)}_findTileCoveringTileID(t,e){let i=e.getTile(t);if(i&&i.hasData())return i;const r=this._findCoveringTileCache[e.id],n=r[t.key];if(i=n?e.getTileByID(n):null,i&&i.hasData()||null===n)return i;let s=i?i.tileID:t,o=s.overscaledZ;const a=e.getSource().minzoom,l=[];if(!n){const r=e.getSource().maxzoom;if(t.canonical.z>=r){const i=t.canonical.z-r;e.getSource().reparseOverscaled?(o=Math.max(t.canonical.z+2,e.transform.tileZoom),s=new Zp(o,t.wrap,r,t.canonical.x>>i,t.canonical.y>>i)):0!==i&&(o=r,s=new Zp(o,t.wrap,r,t.canonical.x>>i,t.canonical.y>>i))}s.key!==t.key&&(l.push(s.key),i=e.getTile(s))}const c=t=>{l.forEach((e=>{r[e]=t})),l.length=0};for(o-=1;o>=a&&(!i||!i.hasData());o--){i&&c(i.tileID.key);const t=s.calculateScaledKey(o);if(i=e.getTileByID(t),i&&i.hasData())break;const n=r[t];if(null===n)break;void 0===n?l.push(t):i=e.getTileByID(n)}return c(i?i.tileID.key:null),i&&i.hasData()?i:null}findDEMTileFor(t){return this.enabled?this._findTileCoveringTileID(t,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(t,e){let i=this._tilesDirty[t];i||(i=this._tilesDirty[t]={}),i[e.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const t=function(t){let e=0;const i=new Qs,r=131;for(let t=1;t<129;t++){for(let n=1;n<129;n++)e=t*r+n,i.emplaceBack(e,e+1),i.emplaceBack(e,e+r),i.emplaceBack(e+1,e+r),128===t&&i.emplaceBack(e+r,e+r+1);i.emplaceBack(e+1,e+1+r)}return i}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(t),this.wireframeSegments=aa.simpleSegment(0,0,this.gridBuffer.length,t.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}function I_(t){const e=[];for(let i=0;i<t.length;i++){if(null===t[i])continue;const r=t[i].split(" ");e.push(r.pop())}return e}class S_{static cacheKey(t,e,i){let r=`${t}${i?i.cacheKey:""}`;for(const t of e)r+=`/${t}`;return r}constructor(t,e,i,r,n,s){const o=t.gl;this.program=o.createProgram();const a=I_(i.staticAttributes),l=r?r.getBinderAttributes():[],c=a.concat(l),h=i.staticUniforms?I_(i.staticUniforms):[],u=r?r.getBinderUniforms():[],p=h.concat(u),d=[];for(const t of p)d.indexOf(t)<0&&d.push(t);let f=r?r.defines():[];f=f.concat(s.map((t=>`#define ${t}`)));const m=f.concat("\n#ifdef GL_ES\nprecision mediump float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif",n_,r_.fragmentSource,i_.fragmentSource,i.fragmentSource).join("\n"),_=f.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",n_,r_.vertexSource,i_.vertexSource,e_.vertexSource,i.vertexSource).join("\n"),g=o.createShader(o.FRAGMENT_SHADER);if(o.isContextLost())return void(this.failedToCreate=!0);o.shaderSource(g,m),o.compileShader(g),o.attachShader(this.program,g);const y=o.createShader(o.VERTEX_SHADER);if(o.isContextLost())return void(this.failedToCreate=!0);o.shaderSource(y,_),o.compileShader(y),o.attachShader(this.program,y),this.attributes={};const x={};this.numAttributes=c.length;for(let t=0;t<this.numAttributes;t++)c[t]&&(o.bindAttribLocation(this.program,t,c[t]),this.attributes[c[t]]=t);o.linkProgram(this.program),o.deleteShader(y),o.deleteShader(g);for(let t=0;t<d.length;t++){const e=d[t];if(e&&!x[e]){const t=o.getUniformLocation(this.program,e);t&&(x[e]=t)}}this.fixedUniforms=n(t,x),this.binderUniforms=r?r.getUniforms(t,x):[],-1!==s.indexOf("TERRAIN")&&(this.terrainUniforms=((t,e)=>({u_dem:new Po(t,e.u_dem),u_dem_prev:new Po(t,e.u_dem_prev),u_dem_unpack:new Ro(t,e.u_dem_unpack),u_dem_tl:new Bo(t,e.u_dem_tl),u_dem_scale:new Do(t,e.u_dem_scale),u_dem_tl_prev:new Bo(t,e.u_dem_tl_prev),u_dem_scale_prev:new Do(t,e.u_dem_scale_prev),u_dem_size:new Do(t,e.u_dem_size),u_dem_lerp:new Do(t,e.u_dem_lerp),u_exaggeration:new Do(t,e.u_exaggeration),u_depth:new Po(t,e.u_depth),u_depth_size_inv:new Bo(t,e.u_depth_size_inv),u_meter_to_dem:new Do(t,e.u_meter_to_dem),u_label_plane_matrix_inv:new Vo(t,e.u_label_plane_matrix_inv),u_tile_tl_up:new Lo(t,e.u_tile_tl_up),u_tile_tr_up:new Lo(t,e.u_tile_tr_up),u_tile_br_up:new Lo(t,e.u_tile_br_up),u_tile_bl_up:new Lo(t,e.u_tile_bl_up),u_tile_up_scale:new Do(t,e.u_tile_up_scale)}))(t,x)),-1!==s.indexOf("FOG")&&(this.fogUniforms=((t,e)=>({u_fog_matrix:new Vo(t,e.u_fog_matrix),u_fog_range:new Bo(t,e.u_fog_range),u_fog_color:new Ro(t,e.u_fog_color),u_fog_horizon_blend:new Do(t,e.u_fog_horizon_blend),u_fog_temporal_offset:new Do(t,e.u_fog_temporal_offset)}))(t,x))}setTerrainUniformValues(t,e){if(!this.terrainUniforms)return;const i=this.terrainUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const t in e)i[t].set(e[t])}}setFogUniformValues(t,e){if(!this.fogUniforms)return;const i=this.fogUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const t in e)i[t].location&&i[t].set(e[t])}}draw(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m){const _=t.gl;if(this.failedToCreate)return;t.program.set(this.program),t.setDepthMode(i),t.setStencilMode(r),t.setColorMode(n),t.setCullFace(s);for(const t of Object.keys(this.fixedUniforms))this.fixedUniforms[t].set(o[t]);d&&d.setUniforms(t,this.binderUniforms,u,{zoom:p});const g={[_.LINES]:2,[_.TRIANGLES]:3,[_.LINE_STRIP]:1}[e];for(const i of h.get()){const r=i.vaos||(i.vaos={});(r[a]||(r[a]=new a_)).bind(t,this,l,d?d.getPaintVertexBuffers():[],c,i.vertexOffset,f,m),_.drawElements(e,i.primitiveLength*g,_.UNSIGNED_SHORT,i.primitiveOffset*g*2)}}}function A_(t,e,i){const r=1/lp(i,1,e.transform.tileZoom),n=Math.pow(2,i.tileID.overscaledZ),s=i.tileSize*Math.pow(2,e.transform.tileZoom)/n,o=s*(i.tileID.canonical.x+i.tileID.wrap*n),a=s*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[r,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[o>>16,a>>16],u_pixel_coord_lower:[65535&o,65535&a]}}const z_=il(),C_=(t,e,i,r,n,s,o,a,l)=>{const c=e.style.light,h=c.properties.get("position"),u=[h.x,h.y,h.z],p=Qa();var d,f,m,_;"viewport"===c.properties.get("anchor")&&(d=p,f=-e.transform.angle,m=Math.sin(f),_=Math.cos(f),d[0]=_,d[1]=m,d[2]=0,d[3]=-m,d[4]=_,d[5]=0,d[6]=0,d[7]=0,d[8]=1,Ml(u,u,p));const g=c.properties.get("color"),y=e.transform,x={u_matrix:t,u_lightpos:u,u_lightintensity:c.properties.get("intensity"),u_lightcolor:[g.r,g.g,g.b],u_vertical_gradient:+i,u_opacity:r,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:z_,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0};return"globe"===y.projection.name&&(x.u_tile_id=[n.canonical.x,n.canonical.y,1<<n.canonical.z],x.u_zoom_transition=o,x.u_inv_rot_matrix=l,x.u_merc_center=a,x.u_up_dir=y.projection.upVector(new Up(0,0,0),a[0]*la,a[1]*la),x.u_height_lift=s),x},M_=(t,e,i,r,n,s,o,a,l,c,h)=>{const u=C_(t,e,i,r,n,a,l,c,h),p={u_height_factor:-Math.pow(2,n.overscaledZ)/o.tileSize/8};return I(u,A_(s,e,o),p)},k_=t=>({u_matrix:t}),P_=(t,e,i,r)=>I(k_(t),A_(i,e,r)),D_=(t,e)=>({u_matrix:t,u_world:e}),B_=(t,e,i,r,n)=>I(P_(t,e,i,r),{u_world:n}),L_=il(),R_=(t,e,i,r,n,s)=>{const o=t.transform,a="globe"===o.projection.name;let l;if("map"===s.paint.get("circle-pitch-alignment"))if(a){const t=Cp(o.zoom,e.canonical);l=Float32Array.from([t,0,0,t])}else l=o.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([o.pixelsToGLUnits[0],0,0,o.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:o.cameraToCenterDistance,u_matrix:t.translatePosMatrix(e.projMatrix,i,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_device_pixel_ratio:J.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:L_,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};return a&&(c.u_inv_rot_matrix=r,c.u_merc_center=n,c.u_tile_id=[e.canonical.x,e.canonical.y,1<<e.canonical.z],c.u_zoom_transition=Pp(o.zoom),c.u_up_dir=o.projection.upVector(e.canonical,n[0],n[1])),c},F_=t=>{const e=[];return"map"===t.paint.get("circle-pitch-alignment")&&e.push("PITCH_WITH_MAP"),"map"===t.paint.get("circle-pitch-scale")&&e.push("SCALE_WITH_MAP"),e},O_=(t,e,i)=>{const r=la/i.tileSize;return{u_matrix:t,u_camera_to_center_distance:e.cameraToCenterDistance,u_extrude_scale:[e.pixelsToGLUnits[0]/r,e.pixelsToGLUnits[1]/r]}},V_=(t,e,i=1)=>({u_matrix:t,u_color:e,u_overlay:0,u_overlay_scale:i}),j_=il(),U_=(t,e,i,r,n,s,o)=>{const a=t.transform,l="globe"===a.projection.name,c=l?Cp(a.zoom,e.canonical):lp(i,1,s),h={u_matrix:e.projMatrix,u_extrude_scale:c,u_intensity:o,u_inv_rot_matrix:j_,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};return l&&(h.u_inv_rot_matrix=r,h.u_merc_center=n,h.u_tile_id=[e.canonical.x,e.canonical.y,1<<e.canonical.z],h.u_zoom_transition=Pp(a.zoom),h.u_up_dir=a.projection.upVector(e.canonical,n[0],n[1])),h},N_=(t,e,i,r,n,s,o)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e),c={u_matrix:G_(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:s,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0};if($_(i)){const i=q_(e,t.transform);c.u_texsize=e.lineAtlasTexture.size,c.u_scale=[i,r.fromScale,r.toScale],c.u_mix=r.t}return c},Z_=(t,e,i,r,n,s)=>{const o=t.transform,a=q_(e,o);return{u_matrix:G_(t,e,i,n),u_texsize:e.imageAtlasTexture.size,u_pixels_to_tile_units:o.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:s,u_image:0,u_scale:[a,r.fromScale,r.toScale],u_fade:r.t,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function q_(t,e){return 1/lp(t,1,e.tileZoom)}function G_(t,e,i,r){return t.translatePosMatrix(r||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}function $_(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}const W_=(t,e,i,r,n,s)=>{return{u_matrix:t,u_tl_parent:e,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:(a=n.paint.get("raster-saturation"),a>0?1-1/(1.001-a):-a),u_contrast_factor:(o=n.paint.get("raster-contrast"),o>0?1/(1-o):1+o),u_spin_weights:X_(n.paint.get("raster-hue-rotate")),u_perspective_transform:s};var o,a};function X_(t){t*=Math.PI/180;const e=Math.sin(t),i=Math.cos(t);return[(2*i+1)/3,(-Math.sqrt(3)*e-i+1)/3,(Math.sqrt(3)*e-i+1)/3]}const H_=il(),K_=(t,e,i,r,n,s,o,a,l,c,h,u,p,d)=>{const f=n.transform,m={u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:f.cameraToCenterDistance,u_rotate_symbol:+i,u_aspect_ratio:f.width/f.height,u_fade_change:n.options.fadeDuration?n.symbolFadeChange:1,u_matrix:s,u_label_plane_matrix:o,u_coord_matrix:a,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:H_,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:H_};return"globe"===f.projection.name&&(m.u_tile_id=[h.canonical.x,h.canonical.y,1<<h.canonical.z],m.u_zoom_transition=u,m.u_inv_rot_matrix=d,m.u_merc_center=p,m.u_camera_forward=f._camera.forward(),m.u_ecef_origin=function(t,e){const i=[0,0,0];return Cl(i,i,Sp(xp(e.canonical))),Cl(i,i,t),i}(f.globeMatrix,h.toUnwrapped()),m.u_tile_matrix=Float32Array.from(f.globeMatrix)),m},Y_=(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f)=>{const{cameraToCenterDistance:m,_pitch:_}=n.transform;return I(K_(t,e,i,r,n,s,o,a,l,c,u,p,d,f),{u_gamma_scale:r?m*Math.cos(n.terrain?0:_):1,u_device_pixel_ratio:J.devicePixelRatio,u_is_halo:+h})},J_=(t,e,i,r,n,s,o,a,l,c,h,u,p,d)=>I(Y_(t,e,i,r,n,s,o,a,!0,l,!0,h,u,p,d),{u_texsize_icon:c,u_texture_icon:1}),Q_=(t,e,i)=>({u_matrix:t,u_opacity:e,u_color:i}),tg=(t,e,i,r,n,s)=>I(function(t,e,i,r){const n=i.imageManager.getPattern(t.from.toString()),s=i.imageManager.getPattern(t.to.toString()),{width:o,height:a}=i.imageManager.getPixelSize(),l=Math.pow(2,r.tileID.overscaledZ),c=r.tileSize*Math.pow(2,i.transform.tileZoom)/l,h=c*(r.tileID.canonical.x+r.tileID.wrap*l),u=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:s.tl,u_pattern_br_b:s.br,u_texsize:[o,a],u_mix:e.t,u_pattern_size_a:n.displaySize,u_pattern_size_b:s.displaySize,u_scale_a:e.fromScale,u_scale_b:e.toScale,u_tile_units_to_pixels:1/lp(r,1,i.transform.tileZoom),u_pixel_coord_upper:[h>>16,u>>16],u_pixel_coord_lower:[65535&h,65535&u]}}(r,s,i,n),{u_matrix:t,u_opacity:e}),eg={fillExtrusion:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_lightpos:new Lo(t,e.u_lightpos),u_lightintensity:new Do(t,e.u_lightintensity),u_lightcolor:new Lo(t,e.u_lightcolor),u_vertical_gradient:new Do(t,e.u_vertical_gradient),u_opacity:new Do(t,e.u_opacity),u_tile_id:new Lo(t,e.u_tile_id),u_zoom_transition:new Do(t,e.u_zoom_transition),u_inv_rot_matrix:new Vo(t,e.u_inv_rot_matrix),u_merc_center:new Bo(t,e.u_merc_center),u_up_dir:new Lo(t,e.u_up_dir),u_height_lift:new Do(t,e.u_height_lift)}),fillExtrusionPattern:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_lightpos:new Lo(t,e.u_lightpos),u_lightintensity:new Do(t,e.u_lightintensity),u_lightcolor:new Lo(t,e.u_lightcolor),u_vertical_gradient:new Do(t,e.u_vertical_gradient),u_height_factor:new Do(t,e.u_height_factor),u_tile_id:new Lo(t,e.u_tile_id),u_zoom_transition:new Do(t,e.u_zoom_transition),u_inv_rot_matrix:new Vo(t,e.u_inv_rot_matrix),u_merc_center:new Bo(t,e.u_merc_center),u_up_dir:new Lo(t,e.u_up_dir),u_height_lift:new Do(t,e.u_height_lift),u_image:new Po(t,e.u_image),u_texsize:new Bo(t,e.u_texsize),u_pixel_coord_upper:new Bo(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new Bo(t,e.u_pixel_coord_lower),u_scale:new Lo(t,e.u_scale),u_fade:new Do(t,e.u_fade),u_opacity:new Do(t,e.u_opacity)}),fill:(t,e)=>({u_matrix:new Vo(t,e.u_matrix)}),fillPattern:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_image:new Po(t,e.u_image),u_texsize:new Bo(t,e.u_texsize),u_pixel_coord_upper:new Bo(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new Bo(t,e.u_pixel_coord_lower),u_scale:new Lo(t,e.u_scale),u_fade:new Do(t,e.u_fade)}),fillOutline:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_world:new Bo(t,e.u_world)}),fillOutlinePattern:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_world:new Bo(t,e.u_world),u_image:new Po(t,e.u_image),u_texsize:new Bo(t,e.u_texsize),u_pixel_coord_upper:new Bo(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new Bo(t,e.u_pixel_coord_lower),u_scale:new Lo(t,e.u_scale),u_fade:new Do(t,e.u_fade)}),circle:(t,e)=>({u_camera_to_center_distance:new Do(t,e.u_camera_to_center_distance),u_extrude_scale:new Zo(t,e.u_extrude_scale),u_device_pixel_ratio:new Do(t,e.u_device_pixel_ratio),u_matrix:new Vo(t,e.u_matrix),u_inv_rot_matrix:new Vo(t,e.u_inv_rot_matrix),u_merc_center:new Bo(t,e.u_merc_center),u_tile_id:new Lo(t,e.u_tile_id),u_zoom_transition:new Do(t,e.u_zoom_transition),u_up_dir:new Lo(t,e.u_up_dir)}),collisionBox:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_camera_to_center_distance:new Do(t,e.u_camera_to_center_distance),u_extrude_scale:new Bo(t,e.u_extrude_scale)}),collisionCircle:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_inv_matrix:new Vo(t,e.u_inv_matrix),u_camera_to_center_distance:new Do(t,e.u_camera_to_center_distance),u_viewport_size:new Bo(t,e.u_viewport_size)}),debug:(t,e)=>({u_color:new Fo(t,e.u_color),u_matrix:new Vo(t,e.u_matrix),u_overlay:new Po(t,e.u_overlay),u_overlay_scale:new Do(t,e.u_overlay_scale)}),clippingMask:(t,e)=>({u_matrix:new Vo(t,e.u_matrix)}),heatmap:(t,e)=>({u_extrude_scale:new Do(t,e.u_extrude_scale),u_intensity:new Do(t,e.u_intensity),u_matrix:new Vo(t,e.u_matrix),u_inv_rot_matrix:new Vo(t,e.u_inv_rot_matrix),u_merc_center:new Bo(t,e.u_merc_center),u_tile_id:new Lo(t,e.u_tile_id),u_zoom_transition:new Do(t,e.u_zoom_transition),u_up_dir:new Lo(t,e.u_up_dir)}),heatmapTexture:(t,e)=>({u_image:new Po(t,e.u_image),u_color_ramp:new Po(t,e.u_color_ramp),u_opacity:new Do(t,e.u_opacity)}),hillshade:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_image:new Po(t,e.u_image),u_latrange:new Bo(t,e.u_latrange),u_light:new Bo(t,e.u_light),u_shadow:new Fo(t,e.u_shadow),u_highlight:new Fo(t,e.u_highlight),u_accent:new Fo(t,e.u_accent)}),hillshadePrepare:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_image:new Po(t,e.u_image),u_dimension:new Bo(t,e.u_dimension),u_zoom:new Do(t,e.u_zoom),u_unpack:new Ro(t,e.u_unpack)}),line:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_pixels_to_tile_units:new Zo(t,e.u_pixels_to_tile_units),u_device_pixel_ratio:new Do(t,e.u_device_pixel_ratio),u_units_to_pixels:new Bo(t,e.u_units_to_pixels),u_dash_image:new Po(t,e.u_dash_image),u_gradient_image:new Po(t,e.u_gradient_image),u_image_height:new Do(t,e.u_image_height),u_texsize:new Bo(t,e.u_texsize),u_scale:new Lo(t,e.u_scale),u_mix:new Do(t,e.u_mix),u_alpha_discard_threshold:new Do(t,e.u_alpha_discard_threshold)}),linePattern:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_texsize:new Bo(t,e.u_texsize),u_pixels_to_tile_units:new Zo(t,e.u_pixels_to_tile_units),u_device_pixel_ratio:new Do(t,e.u_device_pixel_ratio),u_image:new Po(t,e.u_image),u_units_to_pixels:new Bo(t,e.u_units_to_pixels),u_scale:new Lo(t,e.u_scale),u_fade:new Do(t,e.u_fade),u_alpha_discard_threshold:new Do(t,e.u_alpha_discard_threshold)}),raster:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_tl_parent:new Bo(t,e.u_tl_parent),u_scale_parent:new Do(t,e.u_scale_parent),u_fade_t:new Do(t,e.u_fade_t),u_opacity:new Do(t,e.u_opacity),u_image0:new Po(t,e.u_image0),u_image1:new Po(t,e.u_image1),u_brightness_low:new Do(t,e.u_brightness_low),u_brightness_high:new Do(t,e.u_brightness_high),u_saturation_factor:new Do(t,e.u_saturation_factor),u_contrast_factor:new Do(t,e.u_contrast_factor),u_spin_weights:new Lo(t,e.u_spin_weights),u_perspective_transform:new Bo(t,e.u_perspective_transform)}),symbolIcon:(t,e)=>({u_is_size_zoom_constant:new Po(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new Po(t,e.u_is_size_feature_constant),u_size_t:new Do(t,e.u_size_t),u_size:new Do(t,e.u_size),u_camera_to_center_distance:new Do(t,e.u_camera_to_center_distance),u_rotate_symbol:new Po(t,e.u_rotate_symbol),u_aspect_ratio:new Do(t,e.u_aspect_ratio),u_fade_change:new Do(t,e.u_fade_change),u_matrix:new Vo(t,e.u_matrix),u_label_plane_matrix:new Vo(t,e.u_label_plane_matrix),u_coord_matrix:new Vo(t,e.u_coord_matrix),u_is_text:new Po(t,e.u_is_text),u_pitch_with_map:new Po(t,e.u_pitch_with_map),u_texsize:new Bo(t,e.u_texsize),u_tile_id:new Lo(t,e.u_tile_id),u_zoom_transition:new Do(t,e.u_zoom_transition),u_inv_rot_matrix:new Vo(t,e.u_inv_rot_matrix),u_merc_center:new Bo(t,e.u_merc_center),u_camera_forward:new Lo(t,e.u_camera_forward),u_tile_matrix:new Vo(t,e.u_tile_matrix),u_ecef_origin:new Lo(t,e.u_ecef_origin),u_texture:new Po(t,e.u_texture)}),symbolSDF:(t,e)=>({u_is_size_zoom_constant:new Po(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new Po(t,e.u_is_size_feature_constant),u_size_t:new Do(t,e.u_size_t),u_size:new Do(t,e.u_size),u_camera_to_center_distance:new Do(t,e.u_camera_to_center_distance),u_rotate_symbol:new Po(t,e.u_rotate_symbol),u_aspect_ratio:new Do(t,e.u_aspect_ratio),u_fade_change:new Do(t,e.u_fade_change),u_matrix:new Vo(t,e.u_matrix),u_label_plane_matrix:new Vo(t,e.u_label_plane_matrix),u_coord_matrix:new Vo(t,e.u_coord_matrix),u_is_text:new Po(t,e.u_is_text),u_pitch_with_map:new Po(t,e.u_pitch_with_map),u_texsize:new Bo(t,e.u_texsize),u_texture:new Po(t,e.u_texture),u_gamma_scale:new Do(t,e.u_gamma_scale),u_device_pixel_ratio:new Do(t,e.u_device_pixel_ratio),u_tile_id:new Lo(t,e.u_tile_id),u_zoom_transition:new Do(t,e.u_zoom_transition),u_inv_rot_matrix:new Vo(t,e.u_inv_rot_matrix),u_merc_center:new Bo(t,e.u_merc_center),u_camera_forward:new Lo(t,e.u_camera_forward),u_tile_matrix:new Vo(t,e.u_tile_matrix),u_ecef_origin:new Lo(t,e.u_ecef_origin),u_is_halo:new Po(t,e.u_is_halo)}),symbolTextAndIcon:(t,e)=>({u_is_size_zoom_constant:new Po(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new Po(t,e.u_is_size_feature_constant),u_size_t:new Do(t,e.u_size_t),u_size:new Do(t,e.u_size),u_camera_to_center_distance:new Do(t,e.u_camera_to_center_distance),u_rotate_symbol:new Po(t,e.u_rotate_symbol),u_aspect_ratio:new Do(t,e.u_aspect_ratio),u_fade_change:new Do(t,e.u_fade_change),u_matrix:new Vo(t,e.u_matrix),u_label_plane_matrix:new Vo(t,e.u_label_plane_matrix),u_coord_matrix:new Vo(t,e.u_coord_matrix),u_is_text:new Po(t,e.u_is_text),u_pitch_with_map:new Po(t,e.u_pitch_with_map),u_texsize:new Bo(t,e.u_texsize),u_texsize_icon:new Bo(t,e.u_texsize_icon),u_texture:new Po(t,e.u_texture),u_texture_icon:new Po(t,e.u_texture_icon),u_gamma_scale:new Do(t,e.u_gamma_scale),u_device_pixel_ratio:new Do(t,e.u_device_pixel_ratio),u_is_halo:new Po(t,e.u_is_halo)}),background:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_opacity:new Do(t,e.u_opacity),u_color:new Fo(t,e.u_color)}),backgroundPattern:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_opacity:new Do(t,e.u_opacity),u_image:new Po(t,e.u_image),u_pattern_tl_a:new Bo(t,e.u_pattern_tl_a),u_pattern_br_a:new Bo(t,e.u_pattern_br_a),u_pattern_tl_b:new Bo(t,e.u_pattern_tl_b),u_pattern_br_b:new Bo(t,e.u_pattern_br_b),u_texsize:new Bo(t,e.u_texsize),u_mix:new Do(t,e.u_mix),u_pattern_size_a:new Bo(t,e.u_pattern_size_a),u_pattern_size_b:new Bo(t,e.u_pattern_size_b),u_scale_a:new Do(t,e.u_scale_a),u_scale_b:new Do(t,e.u_scale_b),u_pixel_coord_upper:new Bo(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new Bo(t,e.u_pixel_coord_lower),u_tile_units_to_pixels:new Do(t,e.u_tile_units_to_pixels)}),terrainRaster:p_,terrainDepth:p_,skybox:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_sun_direction:new Lo(t,e.u_sun_direction),u_cubemap:new Po(t,e.u_cubemap),u_opacity:new Do(t,e.u_opacity),u_temporal_offset:new Do(t,e.u_temporal_offset)}),skyboxGradient:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_color_ramp:new Po(t,e.u_color_ramp),u_center_direction:new Lo(t,e.u_center_direction),u_radius:new Do(t,e.u_radius),u_opacity:new Do(t,e.u_opacity),u_temporal_offset:new Do(t,e.u_temporal_offset)}),skyboxCapture:(t,e)=>({u_matrix_3f:new Uo(t,e.u_matrix_3f),u_sun_direction:new Lo(t,e.u_sun_direction),u_sun_intensity:new Do(t,e.u_sun_intensity),u_color_tint_r:new Ro(t,e.u_color_tint_r),u_color_tint_m:new Ro(t,e.u_color_tint_m),u_luminance:new Do(t,e.u_luminance)}),globeRaster:(t,e)=>({u_proj_matrix:new Vo(t,e.u_proj_matrix),u_globe_matrix:new Vo(t,e.u_globe_matrix),u_merc_matrix:new Vo(t,e.u_merc_matrix),u_zoom_transition:new Do(t,e.u_zoom_transition),u_merc_center:new Bo(t,e.u_merc_center),u_image0:new Po(t,e.u_image0)}),globeAtmosphere:(t,e)=>({u_frustum_tl:new Lo(t,e.u_frustum_tl),u_frustum_tr:new Lo(t,e.u_frustum_tr),u_frustum_br:new Lo(t,e.u_frustum_br),u_frustum_bl:new Lo(t,e.u_frustum_bl),u_globe_pos:new Lo(t,e.u_globe_pos),u_globe_radius:new Do(t,e.u_globe_radius),u_opacity:new Do(t,e.u_opacity),u_fadeout_range:new Do(t,e.u_fadeout_range),u_start_color:new Lo(t,e.u_start_color),u_end_color:new Lo(t,e.u_end_color)})};let ig;function rg(t,e,i,r,n,s,o){const a=t.context,l=a.gl,c=t.useProgram("collisionBox"),h=[];let u=0,p=0;for(let d=0;d<r.length;d++){const f=r[d],m=e.getTile(f),_=m.getBucket(i);if(!_)continue;let g=f.projMatrix;0===n[0]&&0===n[1]||(g=t.translatePosMatrix(f.projMatrix,m,n,s));const y=o?_.textCollisionBox:_.iconCollisionBox,x=_.collisionCircleArray;if(x.length>0){const e=il(),i=g;fl(e,_.placementInvProjMatrix,t.transform.glCoordMatrix),fl(e,e,_.placementViewportMatrix),h.push({circleArray:x,circleOffset:p,transform:i,invTransform:e}),u+=x.length/4,p=u}y&&(t.terrain&&t.terrain.setupElevationDraw(m,c),c.draw(a,l.LINES,df.disabled,mf.disabled,t.colorModeForRenderPass(),xf.disabled,O_(g,t.transform,m),i.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,null,t.transform.zoom,null,y.collisionVertexBuffer,y.collisionVertexBufferExt))}if(!o||!h.length)return;const d=t.useProgram("collisionCircle"),f=new qs;f.resize(4*u),f._trim();let m=0;for(const t of h)for(let e=0;e<t.circleArray.length/4;e++){const i=4*e,r=t.circleArray[i+0],n=t.circleArray[i+1],s=t.circleArray[i+2],o=t.circleArray[i+3];f.emplace(m++,r,n,s,o,0),f.emplace(m++,r,n,s,o,1),f.emplace(m++,r,n,s,o,2),f.emplace(m++,r,n,s,o,3)}(!ig||ig.length<2*u)&&(ig=function(t){const e=2*t,i=new $s;i.resize(e),i._trim();for(let t=0;t<e;t++){const e=6*t;i.uint16[e+0]=4*t+0,i.uint16[e+1]=4*t+1,i.uint16[e+2]=4*t+2,i.uint16[e+3]=4*t+2,i.uint16[e+4]=4*t+3,i.uint16[e+5]=4*t+0}return i}(u));const _=a.createIndexBuffer(ig,!0),g=a.createVertexBuffer(f,Bh.members,!0);for(const e of h){const r={u_matrix:e.transform,u_inv_matrix:e.invTransform,u_camera_to_center_distance:(y=t.transform).cameraToCenterDistance,u_viewport_size:[y.width,y.height]};d.draw(a,l.TRIANGLES,df.disabled,mf.disabled,t.colorModeForRenderPass(),xf.disabled,r,i.id,g,_,aa.simpleSegment(0,2*e.circleOffset,e.circleArray.length,e.circleArray.length/2),null,t.transform.zoom,null,null,null)}var y;g.destroy(),_.destroy()}const ng=il();function sg(t,e,i,r,n,s){const{horizontalAlign:a,verticalAlign:l}=_u(t),c=-(a-.5)*e,h=-(l-.5)*i,u=Eu(t,r);return new o((c/n+u[0])*s,(h/n+u[1])*s)}function og(t,e,i,r,n,s,a,l,c,h,u,p){const d=t.text.placedSymbolArray,f=t.text.dynamicLayoutVertexArray,m=t.icon.dynamicLayoutVertexArray,_={},g=l.projMatrix,y=s.elevation,x=p.upVectorScale(l.canonical,s.center.lat,s.worldSize);f.clear();for(let m=0;m<d.length;m++){const v=d.get(m),b=t.allowVerticalPlacement&&!v.placedOrientation,w=v.hidden||!v.crossTileID||b?null:r[v.crossTileID];if(w){const r=new o(v.tileAnchorX,v.tileAnchorY),d=p.upVector(l.canonical,r.x,r.y),m=y?y.getAtTileOffset(l,r.x,r.y):0,b=am([v.projectedAnchorX+m*d[0]*x.metersToTile,v.projectedAnchorY+m*d[1]*x.metersToTile,v.projectedAnchorZ+m*d[2]*x.metersToTile],i?g:a),T=lm(s.cameraToCenterDistance,b.signedDistanceFromCamera);let E=n.evaluateSizeForFeature(t.textSizeData,h,v)*T/24;i&&(E*=t.tilePixelRatio/c);const{width:I,height:S,anchor:A,textOffset:z,textScale:C}=w,M=sg(A,I,S,z,C,E),k=i?om(r.add(M),a,m*x.metersToLabelSpace).point:b.point.add(e?M.rotate(-s.angle):M),P=t.allowVerticalPlacement&&v.placedOrientation===mu.vertical?Math.PI/2:0;for(let t=0;t<v.numGlyphs;t++)zu(f,k,P);u&&v.associatedIconIndex>=0&&(_[v.associatedIconIndex]={shiftedAnchor:k,angle:P})}else ym(v.numGlyphs,f)}if(u){m.clear();const e=t.icon.placedSymbolArray;for(let t=0;t<e.length;t++){const i=e.get(t);if(i.hidden)ym(i.numGlyphs,m);else{const e=_[t];if(e)for(let t=0;t<i.numGlyphs;t++)zu(m,e.shiftedAnchor,e.angle);else ym(i.numGlyphs,m)}}t.icon.dynamicLayoutVertexBuffer.updateData(m)}t.text.dynamicLayoutVertexBuffer.updateData(f)}function ag(t,e,i){return i.iconsInText&&e?"symbolTextAndIcon":t?"symbolSDF":"symbolIcon"}function lg(t,e,i,r,n,s,o,a,l,c,h,u){const p=t.context,d=p.gl,f=t.transform,m="map"===a,_="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=t.depthModeForSublayer(0,df.ReadOnly),w=[fa(f.center.lng),ma(f.center.lat)],T=i.layout.get("text-variable-anchor"),E="globe"===f.projection.name,I=E?Pp(f.zoom):0,S=[],A=[];t.terrain&&_&&A.push("PITCH_WITH_MAP_TERRAIN"),E&&A.push("PROJECTION_GLOBE_VIEW");for(const a of r){const r=e.getTile(a),l=r.getBucket(i);if(!l||l.projection!==f.projection.name)continue;const h=n?l.text:l.icon;if(!h||l.fullyClipped||!h.segments.get().length)continue;const u=h.programConfigurations.get(i.id),p=n||l.sdfIcons,b=n?l.textSizeData:l.iconSizeData,E=_||0!==f.pitch,z=Oh(b,f.zoom);let C,M,k,P,D=[0,0],B=null;if(n){if(M=r.glyphAtlasTexture,k=d.LINEAR,C=r.glyphAtlasTexture.size,l.iconsInText){D=r.imageAtlasTexture.size,B=r.imageAtlasTexture;const e="composite"===b.kind||"camera"===b.kind;P=E||t.options.rotating||t.options.zooming||e?d.LINEAR:d.NEAREST}}else{const e=1!==i.layout.get("icon-size").constantOr(0)||l.iconsNeedLinear;M=r.imageAtlasTexture,k=p||t.options.rotating||t.options.zooming||e||E?d.LINEAR:d.NEAREST,C=r.imageAtlasTexture.size}const L=t.transform.calculatePixelsToTileUnitsMatrix(r),R=nm(a.projMatrix,r.tileID.canonical,_,m,t.transform,L),F=t.terrain&&_&&g?nl(il(),R):ng,O=sm(a.projMatrix,r.tileID.canonical,_,m,t.transform,L),V=T&&l.hasTextData(),j="none"!==i.layout.get("icon-text-fit")&&V&&l.hasIconData();if(g){const e=f.elevation,i=e?e.getAtTileOffsetFunc(a,f.center.lat,f.worldSize,f.projection):t=>[0,0,0];hm(l,a.projMatrix,t,n,R,O,_,c,i,a)}const U=g||n&&T||j,N=t.translatePosMatrix(a.projMatrix,r,s,o),Z=U?ng:R,q=t.translatePosMatrix(O,r,s,o,!0),G=f.projection.createInversionMatrix(f,a.canonical),$=U?A.concat(["PROJECTED_POS_ON_VIEWPORT"]):A,W=p&&0!==i.paint.get(n?"text-halo-width":"icon-halo-width").constantOr(1);let X;X=p?l.iconsInText?J_(b.kind,z,y,_,t,N,Z,q,C,D,a,I,w,G):Y_(b.kind,z,y,_,t,N,Z,q,n,C,!0,a,I,w,G):K_(b.kind,z,y,_,t,N,Z,q,n,C,a,I,w,G);const H={program:t.useProgram(ag(p,n,l),u,$),buffers:h,uniformValues:X,atlasTexture:M,atlasTextureIcon:B,atlasInterpolation:k,atlasInterpolationIcon:P,isSDF:p,hasHalo:W,tile:r,labelPlaneMatrixInv:F};if(x&&l.canOverlap){v=!0;const t=h.segments.get();for(const e of t)S.push({segments:new aa([e]),sortKey:e.sortKey,state:H})}else S.push({segments:h.segments,sortKey:0,state:H})}v&&S.sort(((t,e)=>t.sortKey-e.sortKey));for(const e of S){const r=e.state;if(t.terrain&&t.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,cg(r.buffers,e.segments,i,t,r.program,b,h,u,n)),n.u_is_halo=0}cg(r.buffers,e.segments,i,t,r.program,b,h,u,r.uniformValues)}}function cg(t,e,i,r,n,s,o,a,l){const c=r.context;n.draw(c,c.gl.TRIANGLES,s,o,a,xf.disabled,l,i.id,t.layoutVertexBuffer,t.indexBuffer,e,i.paint,r.transform.zoom,t.programConfigurations.get(i.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer)}function hg(t,e,i,r,n,s,o){const a=t.context.gl,l=i.paint.get("fill-pattern"),c=l&&l.constantOr(1),h=i.getCrossfadeParameters();let u,p,d,f,m;o?(p=c&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",u=a.LINES):(p=c?"fillPattern":"fill",u=a.TRIANGLES);for(const _ of r){const r=e.getTile(_);if(c&&!r.patternsLoaded())continue;const g=r.getBucket(i);if(!g)continue;t.prepareDrawTile();const y=g.programConfigurations.get(i.id),x=t.useProgram(p,y);c&&(t.context.activeTexture.set(a.TEXTURE0),r.imageAtlasTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE),y.updatePaintBuffers(h));const v=l.constantOr(null);if(v&&r.imageAtlas){const t=r.imageAtlas,e=t.patternPositions[v.to.toString()],i=t.patternPositions[v.from.toString()];e&&i&&y.setConstantPatternPositions(e,i)}const b=t.translatePosMatrix(_.projMatrix,r,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor"));if(o){f=g.indexBuffer2,m=g.segments2;const e=t.terrain&&t.terrain.renderingToTexture?t.terrain.drapeBufferSize:[a.drawingBufferWidth,a.drawingBufferHeight];d="fillOutlinePattern"===p&&c?B_(b,t,h,r,e):D_(b,e)}else f=g.indexBuffer,m=g.segments,d=c?P_(b,t,h,r):k_(b);t.prepareDrawProgram(t.context,x,_.toUnwrapped()),x.draw(t.context,u,n,t.stencilModeForClipping(_),s,xf.disabled,d,i.id,g.layoutVertexBuffer,f,m,i.paint,t.transform.zoom,y)}}function ug(t,e,i,r,n,s,o){const a=t.context,l=a.gl,c=t.transform,h=i.paint.get("fill-extrusion-pattern"),u=h.constantOr(1),p=i.getCrossfadeParameters(),d=i.paint.get("fill-extrusion-opacity"),f=function(t){if("globe"!==t.projection.name)return 0;const e=Math.PI/32,i=Math.tan(e),r=ha;return r*Math.sqrt(1+2*i*i)-r}(c),m="globe"===c.projection.name,_=m?Pp(c.zoom):0,g=[fa(c.center.lng),ma(c.center.lat)],y=[];m&&y.push("PROJECTION_GLOBE_VIEW");for(const x of r){const r=e.getTile(x),v=r.getBucket(i);if(!v||v.projection!==c.projection.name)continue;const b=v.programConfigurations.get(i.id),w=t.useProgram(u?"fillExtrusionPattern":"fillExtrusion",b,y);if(t.terrain){const n=t.terrain;if(t.style.terrainSetForDrapingOnly())n.setupElevationDraw(r,w,{useMeterToDem:!0});else{if(!v.enableTerrain)continue;if(n.setupElevationDraw(r,w,{useMeterToDem:!0}),pg(a,e,x,v,i,n),!v.centroidVertexBuffer){const t=w.attributes.a_centroid_pos;void 0!==t&&l.vertexAttrib2f(t,0,0)}}}u&&(t.context.activeTexture.set(l.TEXTURE0),r.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),b.updatePaintBuffers(p));const T=h.constantOr(null);if(T&&r.imageAtlas){const t=r.imageAtlas,e=t.patternPositions[T.to.toString()],i=t.patternPositions[T.from.toString()];e&&i&&b.setConstantPatternPositions(e,i)}const E=t.translatePosMatrix(x.projMatrix,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),I=c.projection.createInversionMatrix(c,x.canonical),S=i.paint.get("fill-extrusion-vertical-gradient"),A=u?M_(E,t,S,d,x,p,r,f,_,g,I):C_(E,t,S,d,x,f,_,g,I);t.prepareDrawProgram(a,w,x.toUnwrapped()),w.draw(a,a.gl.TRIANGLES,n,s,o,xf.backCCW,A,i.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,i.paint,t.transform.zoom,b,t.terrain?v.centroidVertexBuffer:null,m?v.layoutVertexExtBuffer:null)}}function pg(t,e,i,r,n,s){const a=[t=>{let e=t.canonical.x-1,i=t.wrap;return e<0&&(e=(1<<t.canonical.z)-1,i--),new Zp(t.overscaledZ,i,t.canonical.z,e,t.canonical.y)},t=>{let e=t.canonical.x+1,i=t.wrap;return e===1<<t.canonical.z&&(e=0,i++),new Zp(t.overscaledZ,i,t.canonical.z,e,t.canonical.y)},t=>new Zp(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(0===t.canonical.y?1<<t.canonical.z:t.canonical.y)-1),t=>new Zp(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1<<t.canonical.z)-1?0:t.canonical.y+1)],l=t=>{const i=e.getSource().minzoom,r=t=>{const i=e.getTileByID(t);if(i&&i.hasData())return i.getBucket(n)},s=[0,-1,1];for(const e of s){if(t.overscaledZ+e<i)continue;const n=r(t.calculateScaledKey(t.overscaledZ+e));if(n)return n}},c=[0,0,0],h=(t,e)=>(c[0]=Math.min(t.min.y,e.min.y),c[1]=Math.max(t.max.y,e.max.y),c[2]=la-e.min.x>t.max.x?e.min.x-la:t.max.x,c),u=(t,e)=>(c[0]=Math.min(t.min.x,e.min.x),c[1]=Math.max(t.max.x,e.max.x),c[2]=la-e.min.y>t.max.y?e.min.y-la:t.max.y,c),p=[(t,e)=>h(t,e),(t,e)=>h(e,t),(t,e)=>u(t,e),(t,e)=>u(e,t)],d=new o(0,0);let f,m,_;const g=(t,e,r,n,o)=>{const a=[[n?r:t,n?t:r,0],[n?r:e,n?e:r,0]],l=o<0?la+o:o,c=[n?l:(t+e)/2,n?(t+e)/2:l,0];return 0===r&&o<0||0!==r&&o>0?s.getForTilePoints(_,[c],!0,m):a.push(c),s.getForTilePoints(i,a,!0,f),Math.max(a[0][2],a[1][2],c[2])/s.exaggeration()};for(let t=0;t<4;t++){const e=(t<2?1:5)-t,n=r.borders[t];if(0===n.length)continue;const o=_=a[t](i),c=l(o);if(!(c&&c instanceof uh&&c.enableTerrain))continue;if(r.borderDoneWithNeighborZ[t]===c.canonical.z&&c.borderDoneWithNeighborZ[e]===r.canonical.z)continue;if(m=s.findDEMTileFor(o),!m||!m.dem)continue;if(!f){const t=s.findDEMTileFor(i);if(!t||!t.dem)return;f=t}const h=c.borders[e];let u=0;const y=c.borderDoneWithNeighborZ[e]!==r.canonical.z;if(r.canonical.z===c.canonical.z){for(let i=0;i<n.length;i++){const s=r.featuresOnBorder[n[i]],o=s.borders[t];let a;for(;u<h.length&&(a=c.featuresOnBorder[h[u]],!(a.borders[e][1]>o[0]+3));)y&&c.encodeCentroid(void 0,a,!1),u++;if(a&&u<h.length){const i=u;let n=0;for(;!(a.borders[e][0]>o[1]-3)&&(n++,++u!==h.length);)a=c.featuresOnBorder[h[u]];if(a=c.featuresOnBorder[h[i]],s.intersectsCount()>1||a.intersectsCount()>1||1!==n){1!==n&&(u=i),r.encodeCentroid(void 0,s,!1),y&&c.encodeCentroid(void 0,a,!1);continue}const l=p[t](s,a),f=t%2?8191:0;d.x=g(l[0],Math.min(8191,l[1]),f,t<2,l[2]),d.y=0,r.encodeCentroid(d,s,!1),y&&c.encodeCentroid(d,a,!1)}else r.encodeCentroid(void 0,s,!1)}r.borderDoneWithNeighborZ[t]=c.canonical.z,r.needsCentroidUpdate=!0,y&&(c.borderDoneWithNeighborZ[e]=r.canonical.z,c.needsCentroidUpdate=!0)}else{for(const t of n)r.encodeCentroid(void 0,r.featuresOnBorder[t],!1);if(y){for(const t of h)c.encodeCentroid(void 0,c.featuresOnBorder[t],!1);c.borderDoneWithNeighborZ[e]=r.canonical.z,c.needsCentroidUpdate=!0}r.borderDoneWithNeighborZ[t]=c.canonical.z,r.needsCentroidUpdate=!0}}(r.needsCentroidUpdate||!r.centroidVertexBuffer&&0!==r.centroidVertexArray.length)&&r.uploadCentroid(t)}const dg=new Le(1,0,0,1),fg=new Le(0,1,0,1),mg=new Le(0,0,1,1),_g=new Le(1,0,1,1),gg=new Le(0,1,1,1);function yg(t,e,i,r){vg(t,0,e+i/2,t.transform.width,i,r)}function xg(t,e,i,r){vg(t,e-i/2,0,i,t.transform.height,r)}function vg(t,e,i,r,n,s){const o=t.context,a=o.gl;a.enable(a.SCISSOR_TEST),a.scissor(e*J.devicePixelRatio,i*J.devicePixelRatio,r*J.devicePixelRatio,n*J.devicePixelRatio),o.clear({color:s}),a.disable(a.SCISSOR_TEST)}function bg(t,e,i){const r=t.context,n=r.gl,s="globe"===t.transform.projection.name,o=i.projMatrix,a=t.useProgram("debug",null,s?["PROJECTION_GLOBE_VIEW"]:null),l=e.getTileByID(i.key);t.terrain&&t.terrain.setupElevationDraw(l,a);const c=df.disabled,h=mf.disabled,u=t.colorModeForRenderPass(),p="$debug";r.activeTexture.set(n.TEXTURE0),t.emptyTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE),s?l._makeGlobeTileDebugBuffers(t.context,t.transform.projection):l._makeDebugTileBoundsBuffers(t.context,t.transform.projection);const d=l._tileDebugBuffer||t.debugBuffer,f=l._tileDebugIndexBuffer||t.debugIndexBuffer,m=l._tileDebugSegments||t.debugSegments;a.draw(r,n.LINE_STRIP,c,h,u,xf.disabled,V_(o,Le.red),p,d,f,m,null,null,null,l._globeTileDebugBorderBuffer);const _=l.latestRawTileData,g=Math.floor((_&&_.byteLength||0)/1024),y=e.getTile(i).tileSize,x=512/Math.min(y,512)*(i.overscaledZ/t.transform.zoom)*.5;let v=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(v+=` => ${i.overscaledZ}`),function(t,e){t.initDebugOverlayCanvas();const i=t.debugOverlayCanvas,r=t.context.gl,n=t.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(e,5,5),n.strokeText(e,5,5),t.debugOverlayTexture.update(i),t.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(t,`${v} ${g}kb`);const b=l._tileDebugTextBuffer||t.debugBuffer,w=l._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,T=l._tileDebugTextSegments||t.debugSegments;a.draw(r,n.TRIANGLES,c,h,_f.alphaBlended,xf.disabled,V_(o,Le.transparent,x),p,b,w,T,null,null,null,l._globeTileDebugTextBuffer)}const wg=Ms([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Tg}=wg;function Eg(t,e,i,r){t.emplaceBack(e,i,r)}class Ig{constructor(t){this.vertexArray=new Rs,this.indices=new $s,Eg(this.vertexArray,-1,-1,1),Eg(this.vertexArray,1,-1,1),Eg(this.vertexArray,-1,1,1),Eg(this.vertexArray,1,1,1),Eg(this.vertexArray,-1,-1,-1),Eg(this.vertexArray,1,-1,-1),Eg(this.vertexArray,-1,1,-1),Eg(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=t.createVertexBuffer(this.vertexArray,Tg),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=aa.simpleSegment(0,0,36,12)}}function Sg(t,e,i,r,n,s){const o=t.gl,a=e.paint.get("sky-atmosphere-color"),l=e.paint.get("sky-atmosphere-halo-color"),c=e.paint.get("sky-atmosphere-sun-intensity"),h=((t,e,i,r,n)=>({u_matrix_3f:t,u_sun_direction:e,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}))(((u=Qa())[0]=(p=r)[0],u[1]=p[1],u[2]=p[2],u[3]=p[4],u[4]=p[5],u[5]=p[6],u[6]=p[8],u[7]=p[9],u[8]=p[10],u),n,c,a,l);var u,p;o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_CUBE_MAP_POSITIVE_X+s,e.skyboxTexture,0),i.draw(t,o.TRIANGLES,df.disabled,mf.disabled,_f.unblended,xf.frontCW,h,"skyboxCapture",e.skyboxGeometry.vertexBuffer,e.skyboxGeometry.indexBuffer,e.skyboxGeometry.segment)}function Ag(t,e){return Cl(t,t,e)}const zg={symbol:function(t,e,i,r,n){if("translucent"!==t.renderPass)return;const s=mf.disabled,o=t.colorModeForRenderPass();i.layout.get("text-variable-anchor")&&function(t,e,i,r,n,s,o){const a=e.transform,l="map"===n,c="map"===s;for(const n of t){const t=r.getTile(n),s=t.getBucket(i);if(!s||s.projection!==a.projection.name||!s.text||!s.text.segments.get().length)continue;const h=Oh(s.textSizeData,a.zoom),u=e.transform.calculatePixelsToTileUnitsMatrix(t),p=nm(n.projMatrix,t.tileID.canonical,c,l,e.transform,u),d="none"!==i.layout.get("icon-text-fit")&&s.hasIconData();if(h){const e=Math.pow(2,a.zoom-t.tileID.overscaledZ);og(s,l,c,o,Vh,a,p,n,e,h,d,a.projection)}}}(r,t,i,e,i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),n),0!==i.paint.get("icon-opacity").constantOr(1)&&lg(t,e,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"),s,o),0!==i.paint.get("text-opacity").constantOr(1)&&lg(t,e,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"),s,o),e.map.showCollisionBoxes&&(rg(t,e,i,r,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),!0),rg(t,e,i,r,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),!1))},circle:function(t,e,i,r){if("translucent"!==t.renderPass)return;const n=i.paint.get("circle-opacity"),s=i.paint.get("circle-stroke-width"),o=i.paint.get("circle-stroke-opacity"),a=void 0!==i.layout.get("circle-sort-key").constantOr(1);if(0===n.constantOr(1)&&(0===s.constantOr(1)||0===o.constantOr(1)))return;const l=t.context,c=l.gl,h=t.transform,u=t.depthModeForSublayer(0,df.ReadOnly),p=mf.disabled,d=t.colorModeForRenderPass(),f="globe"===h.projection.name,m=[fa(h.center.lng),ma(h.center.lat)],_=[];for(let n=0;n<r.length;n++){const s=r[n],o=e.getTile(s),l=o.getBucket(i);if(!l)continue;const c=l.programConfigurations.get(i.id),u=F_(i);f&&u.push("PROJECTION_GLOBE_VIEW");const p=t.useProgram("circle",c,u),d=l.layoutVertexBuffer,g=l.globeExtVertexBuffer,y=l.indexBuffer,x=h.projection.createInversionMatrix(h,s.canonical),v={programConfiguration:c,program:p,layoutVertexBuffer:d,globeExtVertexBuffer:g,indexBuffer:y,uniformValues:R_(t,s,o,x,m,i),tile:o};if(a){const t=l.segments.get();for(const e of t)_.push({segments:new aa([e]),sortKey:e.sortKey,state:v})}else _.push({segments:l.segments,sortKey:0,state:v})}a&&_.sort(((t,e)=>t.sortKey-e.sortKey));const g={useDepthForOcclusion:!f};for(const e of _){const{programConfiguration:r,program:n,layoutVertexBuffer:s,globeExtVertexBuffer:o,indexBuffer:a,uniformValues:m,tile:_}=e.state,y=e.segments;t.terrain&&t.terrain.setupElevationDraw(_,n,g),t.prepareDrawProgram(l,n,_.tileID.toUnwrapped()),n.draw(l,c.TRIANGLES,u,p,d,xf.disabled,m,i.id,s,a,y,i.paint,h.zoom,r,f?o:null)}},heatmap:function(t,e,i,r){if(0!==i.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const n=t.context,s=n.gl,o=mf.disabled,a=new _f([s.ONE,s.ONE],Le.transparent,[!0,!0,!0,!0]);!function(t,e,i){const r=t.gl;t.activeTexture.set(r.TEXTURE1),t.viewport.set([0,0,e.width/4,e.height/4]);let n=i.heatmapFbo;if(n)r.bindTexture(r.TEXTURE_2D,n.colorAttachment.get()),t.bindFramebuffer.set(n.framebuffer);else{const s=r.createTexture();r.bindTexture(r.TEXTURE_2D,s),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),n=i.heatmapFbo=t.createFramebuffer(e.width/4,e.height/4,!1),function(t,e,i,r){const n=t.gl;n.texImage2D(n.TEXTURE_2D,0,n.RGBA,e.width/4,e.height/4,0,n.RGBA,t.extRenderToTextureHalfFloat?t.extTextureHalfFloat.HALF_FLOAT_OES:n.UNSIGNED_BYTE,null),r.colorAttachment.set(i)}(t,e,s,n)}}(n,t,i),n.clear({color:Le.transparent});const l=t.transform,c="globe"===l.projection.name,h=c?["PROJECTION_GLOBE_VIEW"]:null,u=[fa(l.center.lng),ma(l.center.lat)];for(let p=0;p<r.length;p++){const d=r[p];if(e.hasRenderableParent(d))continue;const f=e.getTile(d),m=f.getBucket(i);if(!m)continue;const _=m.programConfigurations.get(i.id),g=t.useProgram("heatmap",_,h),{zoom:y}=t.transform;t.terrain&&t.terrain.setupElevationDraw(f,g),t.prepareDrawProgram(n,g,d.toUnwrapped());const x=l.projection.createInversionMatrix(l,d.canonical);g.draw(n,s.TRIANGLES,df.disabled,o,a,xf.disabled,U_(t,d,f,x,u,y,i.paint.get("heatmap-intensity")),i.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,i.paint,t.transform.zoom,_,c?m.globeExtVertexBuffer:null)}n.viewport.set([0,0,t.width,t.height])}else"translucent"===t.renderPass&&(t.context.setColorMode(t.colorModeForRenderPass()),function(t,e){const i=t.context,r=i.gl,n=e.heatmapFbo;if(!n)return;i.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,n.colorAttachment.get()),i.activeTexture.set(r.TEXTURE1);let s=e.colorRampTexture;s||(s=e.colorRampTexture=new qu(i,e.colorRamp,r.RGBA)),s.bind(r.LINEAR,r.CLAMP_TO_EDGE),t.useProgram("heatmapTexture").draw(i,r.TRIANGLES,df.disabled,mf.disabled,t.colorModeForRenderPass(),xf.disabled,((t,e,i,r)=>({u_image:0,u_color_ramp:1,u_opacity:e.paint.get("heatmap-opacity")}))(0,e),e.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,e.paint,t.transform.zoom)}(t,i))},line:function(t,e,i,r){if("translucent"!==t.renderPass)return;const n=i.paint.get("line-opacity"),s=i.paint.get("line-width");if(0===n.constantOr(1)||0===s.constantOr(1))return;const o=t.depthModeForSublayer(0,df.ReadOnly),a=t.colorModeForRenderPass(),l=t.terrain&&t.terrain.renderingToTexture?1:J.devicePixelRatio,c=i.paint.get("line-dasharray"),h=c.constantOr(1),u=i.layout.get("line-cap"),p=i.paint.get("line-pattern"),d=p.constantOr(1),f=i.paint.get("line-gradient"),m=i.getCrossfadeParameters(),_=d?"linePattern":"line",g=t.context,y=g.gl,x=(t=>{const e=[];$_(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-pattern").constantOr(1),r=1!==t.paint.get("line-opacity").constantOr(1);return!i&&r&&e.push("RENDER_LINE_ALPHA_DISCARD"),e})(i);let b=x.includes("RENDER_LINE_ALPHA_DISCARD");t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(b=!1);for(const n of r){const r=e.getTile(n);if(d&&!r.patternsLoaded())continue;const s=r.getBucket(i);if(!s)continue;t.prepareDrawTile();const w=s.programConfigurations.get(i.id),T=t.useProgram(_,w,x),E=p.constantOr(null);if(E&&r.imageAtlas){const t=r.imageAtlas,e=t.patternPositions[E.to.toString()],i=t.patternPositions[E.from.toString()];e&&i&&w.setConstantPatternPositions(e,i)}const I=c.constantOr(null),S=u.constantOr(null);if(!d&&I&&S&&r.lineAtlas){const t=r.lineAtlas,e=t.getDash(I.to,S),i=t.getDash(I.from,S);e&&i&&w.setConstantPatternPositions(e,i)}const A=t.terrain?n.projMatrix:null,z=d?Z_(t,r,i,m,A,l):N_(t,r,i,m,A,s.lineClipsArray.length,l);if(f){const r=s.gradients[i.id];let o=r.texture;if(i.gradientVersion!==r.version){let a=256;if(i.stepInterpolant){const i=e.getSource().maxzoom,r=n.canonical.z===i?Math.ceil(1<<t.transform.maxZoom-n.canonical.z):1;a=v(M(s.maxLineLength/la*1024*r),256,g.maxTextureSize)}r.gradient=rc({expression:i.gradientExpression(),evaluationKey:"lineProgress",resolution:a,image:r.gradient||void 0,clips:s.lineClipsArray}),r.texture?r.texture.update(r.gradient):r.texture=new qu(g,r.gradient,y.RGBA),r.version=i.gradientVersion,o=r.texture}g.activeTexture.set(y.TEXTURE1),o.bind(i.stepInterpolant?y.NEAREST:y.LINEAR,y.CLAMP_TO_EDGE)}h&&(g.activeTexture.set(y.TEXTURE0),r.lineAtlasTexture.bind(y.LINEAR,y.REPEAT),w.updatePaintBuffers(m)),d&&(g.activeTexture.set(y.TEXTURE0),r.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),w.updatePaintBuffers(m)),t.prepareDrawProgram(g,T,n.toUnwrapped());const C=e=>{T.draw(g,y.TRIANGLES,o,e,a,xf.disabled,z,i.id,s.layoutVertexBuffer,s.indexBuffer,s.segments,i.paint,t.transform.zoom,w,s.layoutVertexBuffer2)};if(b){const e=t.stencilModeForClipping(n).ref;0===e&&t.terrain&&g.clear({stencil:0});const i={func:y.EQUAL,mask:255};z.u_alpha_discard_threshold=.8,C(new mf(i,e,255,y.KEEP,y.KEEP,y.INVERT)),z.u_alpha_discard_threshold=0,C(new mf(i,e,255,y.KEEP,y.KEEP,y.KEEP))}else C(t.stencilModeForClipping(n))}b&&(t.resetStencilClippingMasks(),t.terrain&&g.clear({stencil:0}))},fill:function(t,e,i,r){const n=i.paint.get("fill-color"),s=i.paint.get("fill-opacity");if(0===s.constantOr(1))return;const o=t.colorModeForRenderPass(),a=i.paint.get("fill-pattern"),l=t.opaquePassEnabledForLayer()&&!a.constantOr(1)&&1===n.constantOr(Le.transparent).a&&1===s.constantOr(0)?"opaque":"translucent";if(t.renderPass===l){const n=t.depthModeForSublayer(1,"opaque"===t.renderPass?df.ReadWrite:df.ReadOnly);hg(t,e,i,r,n,o,!1)}if("translucent"===t.renderPass&&i.paint.get("fill-antialias")){const n=t.depthModeForSublayer(i.getPaintProperty("fill-outline-color")?2:0,df.ReadOnly);hg(t,e,i,r,n,o,!0)}},"fill-extrusion":function(t,e,i,r){const n=i.paint.get("fill-extrusion-opacity");if(0!==n&&"translucent"===t.renderPass){const s=new df(t.context.gl.LEQUAL,df.ReadWrite,t.depthRangeFor3D);if(1!==n||i.paint.get("fill-extrusion-pattern").constantOr(1))ug(t,e,i,r,s,mf.disabled,_f.disabled),ug(t,e,i,r,s,t.stencilModeFor3D(),t.colorModeForRenderPass()),t.resetStencilClippingMasks();else{const n=t.colorModeForRenderPass();ug(t,e,i,r,s,mf.disabled,n)}}},hillshade:function(t,e,i,r){if("offscreen"!==t.renderPass&&"translucent"!==t.renderPass)return;const n=t.context,s=t.depthModeForSublayer(0,df.ReadOnly),o=t.colorModeForRenderPass(),a=t.terrain&&t.terrain.renderingToTexture,[l,c]="translucent"!==t.renderPass||a?[{},r]:t.stencilConfigForOverlap(r);for(const r of c){const n=e.getTile(r);if(n.needsHillshadePrepare&&"offscreen"===t.renderPass)u_(t,n,i,s,mf.disabled,o);else if("translucent"===t.renderPass){const e=a&&t.terrain?t.terrain.stencilModeForRTTOverlap(r):l[r.overscaledZ];c_(t,r,n,i,s,e,o)}}n.viewport.set([0,0,t.width,t.height]),t.resetStencilClippingMasks()},raster:function(t,e,i,r,n,s){if("translucent"!==t.renderPass)return;if(0===i.paint.get("raster-opacity"))return;if(!r.length)return;const o=t.context,a=o.gl,l=e.getSource(),c=t.useProgram("raster"),h=t.colorModeForRenderPass(),u=t.terrain&&t.terrain.renderingToTexture,[p,d]=l instanceof Pf||u?[{},r]:t.stencilConfigForOverlap(r),f=d[d.length-1].overscaledZ,m=!t.options.moving;for(const r of d){const n=u?df.disabled:t.depthModeForSublayer(r.overscaledZ-f,1===i.paint.get("raster-opacity")?df.ReadWrite:df.ReadOnly,a.LESS),d=r.toUnwrapped(),_=e.getTile(r);if(u&&(!_||!_.hasData()))continue;const g=u?r.projMatrix:t.transform.calculateProjMatrix(d,m),y=t.terrain&&u?t.terrain.stencilModeForRTTOverlap(r):p[r.overscaledZ],x=s?0:i.paint.get("raster-fade-duration");_.registerFadeDuration(x);const v=e.findLoadedParent(r,0),b=v_(_,v,e,t.transform,x);let w,T;t.terrain&&t.terrain.prepareDrawTile();const E="nearest"===i.paint.get("raster-resampling")?a.NEAREST:a.LINEAR;o.activeTexture.set(a.TEXTURE0),_.texture.bind(E,a.CLAMP_TO_EDGE),o.activeTexture.set(a.TEXTURE1),v?(v.texture.bind(E,a.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,a.CLAMP_TO_EDGE);const I=W_(g,T||[0,0],w||1,b,i,l instanceof Pf?l.perspectiveTransform:[0,0]);if(t.prepareDrawProgram(o,c,d),l instanceof Pf)l.boundsBuffer&&l.boundsSegments&&c.draw(o,a.TRIANGLES,n,mf.disabled,h,xf.disabled,I,i.id,l.boundsBuffer,t.quadTriangleIndexBuffer,l.boundsSegments);else{const{tileBoundsBuffer:e,tileBoundsIndexBuffer:r,tileBoundsSegments:s}=t.getTileBoundsBuffers(_);c.draw(o,a.TRIANGLES,n,y,h,xf.disabled,I,i.id,e,r,s)}}t.resetStencilClippingMasks()},background:function(t,e,i,r){const n=i.paint.get("background-color"),s=i.paint.get("background-opacity");if(0===s)return;const o=t.context,a=o.gl,l=t.transform,c=l.tileSize,h=i.paint.get("background-pattern");if(t.isPatternMissing(h))return;const u=!h&&1===n.a&&1===s&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==u)return;const p=mf.disabled,d=t.depthModeForSublayer(0,"opaque"===u?df.ReadWrite:df.ReadOnly),f=t.colorModeForRenderPass(),m=t.useProgram(h?"backgroundPattern":"background");let _,g=r;g||(_=t.getBackgroundTiles(),g=Object.values(_).map((t=>t.tileID))),h&&(o.activeTexture.set(a.TEXTURE0),t.imageManager.bind(t.context));const y=i.getCrossfadeParameters();for(const u of g){const g=u.toUnwrapped(),x=r?u.projMatrix:t.transform.calculateProjMatrix(g);t.prepareDrawTile();const v=e?e.getTile(u):_?_[u.key]:new dd(u,c,l.zoom,t),b=h?tg(x,s,t,h,{tileID:u,tileSize:c},y):Q_(x,s,n);t.prepareDrawProgram(o,m,g);const{tileBoundsBuffer:w,tileBoundsIndexBuffer:T,tileBoundsSegments:E}=t.getTileBoundsBuffers(v);m.draw(o,a.TRIANGLES,d,p,f,xf.disabled,b,i.id,w,T,E)}},sky:function(t,e,i){const r=t.transform,n="mercator"===r.projection.name||"globe"===r.projection.name?1:b(7,8,r.zoom),s=i.paint.get("sky-opacity")*n;if(0===s)return;const o=t.context,a=i.paint.get("sky-type"),l=new df(o.gl.LEQUAL,df.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===a?"offscreen"===t.renderPass?i.needsSkyboxCapture(t)&&(function(t,e,i,r){const n=t.context,s=n.gl;let o=e.skyboxFbo;if(!o){o=e.skyboxFbo=n.createFramebuffer(32,32,!1),e.skyboxGeometry=new Ig(n),e.skyboxTexture=n.gl.createTexture(),s.bindTexture(s.TEXTURE_CUBE_MAP,e.skyboxTexture),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MAG_FILTER,s.LINEAR);for(let t=0;t<6;++t)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,s.RGBA,32,32,0,s.RGBA,s.UNSIGNED_BYTE,null)}n.bindFramebuffer.set(o.framebuffer),n.viewport.set([0,0,32,32]);const a=e.getCenter(t,!0),l=t.useProgram("skyboxCapture"),c=new Float64Array(16);rl(c),cl(c,c,.5*-Math.PI),Sg(n,e,l,c,a,0),rl(c),cl(c,c,.5*Math.PI),Sg(n,e,l,c,a,1),rl(c),ll(c,c,.5*-Math.PI),Sg(n,e,l,c,a,2),rl(c),ll(c,c,.5*Math.PI),Sg(n,e,l,c,a,3),rl(c),Sg(n,e,l,c,a,4),rl(c),cl(c,c,Math.PI),Sg(n,e,l,c,a,5),n.viewport.set([0,0,t.width,t.height])}(t,i),i.markSkyboxValid(t)):"sky"===t.renderPass&&function(t,e,i,r,n){const s=t.context,o=s.gl,a=t.transform,l=t.useProgram("skybox");s.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_CUBE_MAP,e.skyboxTexture);const c=((t,e,i,r,n)=>({u_matrix:t,u_sun_direction:e,u_cubemap:0,u_opacity:r,u_temporal_offset:n}))(a.skyboxMatrix,e.getCenter(t,!1),0,r,n);t.prepareDrawProgram(s,l),l.draw(s,o.TRIANGLES,i,mf.disabled,t.colorModeForRenderPass(),xf.backCW,c,"skybox",e.skyboxGeometry.vertexBuffer,e.skyboxGeometry.indexBuffer,e.skyboxGeometry.segment)}(t,i,l,s,c):"gradient"===a&&"sky"===t.renderPass&&function(t,e,i,r,n){const s=t.context,o=s.gl,a=t.transform,l=t.useProgram("skyboxGradient");e.skyboxGeometry||(e.skyboxGeometry=new Ig(s)),s.activeTexture.set(o.TEXTURE0);let c=e.colorRampTexture;c||(c=e.colorRampTexture=new qu(s,e.colorRamp,o.RGBA)),c.bind(o.LINEAR,o.CLAMP_TO_EDGE);const h=((t,e,i,r,n)=>({u_matrix:t,u_color_ramp:0,u_center_direction:e,u_radius:p(i),u_opacity:r,u_temporal_offset:n}))(a.skyboxMatrix,e.getCenter(t,!1),e.paint.get("sky-gradient-radius"),r,n);t.prepareDrawProgram(s,l),l.draw(s,o.TRIANGLES,i,mf.disabled,t.colorModeForRenderPass(),xf.backCW,h,"skyboxGradient",e.skyboxGeometry.vertexBuffer,e.skyboxGeometry.indexBuffer,e.skyboxGeometry.segment)}(t,i,l,s,c)},debug:function(t,e,i){for(let r=0;r<i.length;r++)bg(t,e,i[r])},custom:function(t,e,i){const r=t.context,n=i.implementation;if(t.transform.projection.unsupportedLayers&&t.transform.projection.unsupportedLayers.includes("custom"))O("Custom layers are not yet supported with non-mercator projections. Use mercator to enable custom layers.");else if("offscreen"===t.renderPass){const e=n.prerender;e&&(t.setCustomLayerDefaults(),r.setColorMode(t.colorModeForRenderPass()),e.call(n,r.gl,t.transform.customLayerMatrix()),r.setDirty(),t.setBaseState())}else if("translucent"===t.renderPass){t.setCustomLayerDefaults(),r.setColorMode(t.colorModeForRenderPass()),r.setStencilMode(mf.disabled);const e="3d"===n.renderingMode?new df(t.context.gl.LEQUAL,df.ReadWrite,t.depthRangeFor3D):t.depthModeForSublayer(0,df.ReadOnly);r.setDepthMode(e),n.render(r.gl,t.transform.customLayerMatrix()),r.setDirty(),t.setBaseState(),r.bindFramebuffer.set(null)}}};class Cg{constructor(t,e){this.context=new vf(t),this.transform=e,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.setup(),this.numSublayers=bf.maxUnderzooming+bf.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new $m,this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this._tileClippingMaskIDs=new Map,this._skippedStencilTileIDs=new Set}updateTerrain(t,e){const i=!!t&&!!t.terrain&&this.transform.projection.supportsTerrain;if(!(i||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new E_(this,t));const r=this._terrain;this.transform.elevation=i?r:null,r.update(t,this.transform,e)}_updateFog(t){const e=t.fog;if(!e||e.getOpacity(this.transform.pitch)<1||e.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[i,r]=e.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(t,e){if(this.width=t*J.devicePixelRatio,this.height=e*J.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const t of this.style.order)this.style._layers[t].resize()}setup(){const t=this.context,e=new Ps;e.emplaceBack(0,0),e.emplaceBack(la,0),e.emplaceBack(0,la),e.emplaceBack(la,la),this.tileExtentBuffer=t.createVertexBuffer(e,rd.members),this.tileExtentSegments=aa.simpleSegment(0,0,4,2);const i=new Ps;i.emplaceBack(0,0),i.emplaceBack(la,0),i.emplaceBack(0,la),i.emplaceBack(la,la),this.debugBuffer=t.createVertexBuffer(i,rd.members),this.debugSegments=aa.simpleSegment(0,0,4,5);const r=new Ps;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(-1,1),r.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(r,rd.members),this.viewportSegments=aa.simpleSegment(0,0,4,2);const n=new Bs;n.emplaceBack(0,0,0,0),n.emplaceBack(la,0,la,0),n.emplaceBack(0,la,0,la),n.emplaceBack(la,la,la,la),this.mercatorBoundsBuffer=t.createVertexBuffer(n,ud.members),this.mercatorBoundsSegments=aa.simpleSegment(0,0,4,2);const s=new $s;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(s);const o=new to;for(const t of[0,1,3,2,0])o.emplaceBack(t);this.debugIndexBuffer=t.createIndexBuffer(o),this.emptyTexture=new qu(t,new ec({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA),this.identityMat=il();const a=this.context.gl;this.stencilClearMode=new mf({func:a.ALWAYS,mask:0},0,255,a.ZERO,a.ZERO,a.ZERO),this.loadTimeStamps.push(l.performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(t){return t._makeTileBoundsBuffers(this.context,this.transform.projection),t._tileBoundsBuffer?{tileBoundsBuffer:t._tileBoundsBuffer,tileBoundsIndexBuffer:t._tileBoundsIndexBuffer,tileBoundsSegments:t._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const t=this.context,e=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs.clear(),this._skippedStencilTileIDs.clear(),this.useProgram("clippingMask").draw(t,e.TRIANGLES,df.disabled,this.stencilClearMode,_f.disabled,xf.disabled,x_(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs.clear(),this._skippedStencilTileIDs.clear())}_renderTileClippingMasks(t,e,i){if(!e||this.currentStencilSource===e.id||!t.isTileClipped()||!i||0===i.length)return;const r=[];let n=!1;if(this._tileClippingMaskIDs&&!this.terrain){for(const s of i)if(this._tileClippingMaskIDs.has(s.key)||(n=!0),this._skippedStencilTileIDs.has(s.key)){if(!e.getTile(s).getBucket(t))continue;this._skippedStencilTileIDs.delete(s.key),r.push(s)}if(!n&&0===r.length)return}const s=this.context,o=s.gl;s.setColorMode(_f.disabled),s.setDepthMode(df.disabled);const a=this.useProgram("clippingMask"),l=t=>{const i=e.getTile(t),{tileBoundsBuffer:r,tileBoundsIndexBuffer:n,tileBoundsSegments:l}=this.getTileBoundsBuffers(i);a.draw(s,o.TRIANGLES,df.disabled,new mf({func:o.GREATER,mask:255},this._tileClippingMaskIDs.get(t.key)||0,255,o.KEEP,o.KEEP,o.REPLACE),_f.disabled,xf.disabled,x_(t.projMatrix),"$clipping",r,n,l)};if(!n&&r.length>0)for(const t of r)l(t);else{(0===this._tileClippingMaskIDs.size||this.nextStencilID+i.length>256)&&this.clearStencil(),this._tileClippingMaskIDs.clear(),this._skippedStencilTileIDs.clear();for(const r of i)this._tileClippingMaskIDs.set(r.key,this.nextStencilID++),e.getTile(r).getBucket(t)?l(r):this._skippedStencilTileIDs.add(r.key)}0===this._skippedStencilTileIDs.size&&(this.currentStencilSource=e.id)}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,e=this.context.gl;return new mf({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)}stencilModeForClipping(t){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(t);const e=this.context.gl;return new mf({func:e.EQUAL,mask:255},this._tileClippingMaskIDs.get(t.key)||0,0,e.KEEP,e.KEEP,e.REPLACE)}stencilConfigForOverlap(t){const e=this.context.gl,i=t.sort(((t,e)=>e.overscaledZ-t.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 t={};for(let i=0;i<n;i++)t[i+r]=new mf({func:e.GEQUAL,mask:255},i+this.nextStencilID,255,e.KEEP,e.KEEP,e.REPLACE);return this.nextStencilID+=n,[t,i]}return[{[r]:mf.disabled},i]}colorModeForRenderPass(){const t=this.context.gl;if(this._showOverdrawInspector){const e=1/8;return new _f([t.CONSTANT_COLOR,t.ONE],new Le(e,e,e,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?_f.unblended:_f.alphaBlended}depthModeForSublayer(t,e,i){if(!this.opaquePassEnabledForLayer())return df.disabled;const r=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new df(i||this.context.gl.LEQUAL,e,[r,r])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,e){this.style=t,this.options=e,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(J.now()),this.imageManager.beginFrame();const i=this.style.order,r=this.style._sourceCaches;for(const t in r){const e=r[t];e.used&&e.prepare(this.context)}const n={},s={},o={};for(const t in r){const e=r[t];n[t]=e.getVisibleCoordinates(),s[t]=n[t].slice().reverse(),o[t]=e.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let t=0;t<i.length;t++)if(this.style._layers[i[t]].is3D()){this.opaquePassCutoff=t;break}if(this.terrain&&(this.terrain.updateTileBinding(o),this.opaquePassCutoff=0),"globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new Vp(this.context)),!Rt.has(this.context.gl))return;this.renderPass="offscreen";for(const e of i){const i=this.style._layers[e],r=t._getLayerSourceCache(i);if(!i.hasOffscreenPass()||i.isHidden(this.transform.zoom))continue;const n=r?s[r.id]:void 0;("custom"===i.type||i.isSky()||n&&n.length)&&this.renderLayer(this,r,i,n)}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]);let a=Le.transparent;if(this.style.fog&&this.style.fog.getOpacity(this.transform.pitch)&&(a=this.style.fog.properties.get("color")),this.context.clear({color:e.showOverdrawInspector?Le.black:a,depth:1}),this.clearStencil(),this._showOverdrawInspector=e.showOverdrawInspector,this.renderPass="opaque",!this.terrain)for(this.currentLayer=i.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[i[this.currentLayer]],r=t._getLayerSourceCache(e);if(e.isSky())continue;const n=r?s[r.id]:void 0;this._renderTileClippingMasks(e,r,n),this.renderLayer(this,r,e,n)}if(this.renderPass="sky",(Pp(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer<i.length;this.currentLayer++){const e=this.style._layers[i[this.currentLayer]],r=t._getLayerSourceCache(e);e.isSky()&&this.renderLayer(this,r,e,r?s[r.id]:void 0)}for("globe"===this.transform.projection.name&&function(t){const e=t.context,i=e.gl,r=t.transform,n=new df(i.LEQUAL,df.ReadOnly,[0,1]),s=t.useProgram("globeAtmosphere"),o=r.centerOffset,a=r._camera.getCameraToClipPerspective(r._fov,r.width/r.height,r._nearZ,r._farZ);a[8]=2*-o.x/r.width,a[9]=2*o.y/r.height;const l=nl([],a),c=fl([],l,r.projMatrix),h={u_frustum_tl:Ag([-1,1,1],l),u_frustum_tr:Ag([1,1,1],l),u_frustum_br:Ag([1,-1,1],l),u_frustum_bl:Ag([-1,-1,1],l),u_globe_pos:Ag([r.globeMatrix[12],r.globeMatrix[13],r.globeMatrix[14]],c),u_globe_radius:r.worldSize/2/Math.PI-1,u_opacity:1-Pp(r.zoom),u_fadeout_range:2,u_start_color:[1,1,1],u_end_color:[.0118,.7451,.9882]};t.prepareDrawProgram(e,s);const u=t.globeSharedBuffers;u&&s.draw(e,i.TRIANGLES,n,mf.disabled,_f.alphaBlended,xf.backCW,h,"skybox",u.atmosphereVertexBuffer,u.atmosphereIndexBuffer,u.atmosphereSegments)}(this),this.renderPass="translucent",this.currentLayer=0;this.currentLayer<i.length;){const e=this.style._layers[i[this.currentLayer]],r=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 a=r?("symbol"===e.type?o:s)[r.id]:void 0;this._renderTileClippingMasks(e,r,r?n[r.id]:void 0),this.renderLayer(this,r,e,a),++this.currentLayer}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry){let e=null;E(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&&zg.debug(this,e,e.getVisibleCoordinates())}this.options.showPadding&&function(t){const e=t.transform.padding;yg(t,t.transform.height-(e.top||0),3,dg),yg(t,e.bottom||0,3,fg),xg(t,e.left||0,3,mg),xg(t,t.transform.width-(e.right||0),3,_g);const i=t.transform.centerPoint;!function(t,e,i,r){vg(t,e-1,i-10,2,20,r),vg(t,e-10,i-1,20,2,r)}(t,i.x,t.transform.height-i.y,gg)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(l.performance.now()),this.saveCanvasCopy())}renderLayer(t,e,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),t.transform.projection.unsupportedLayers&&t.transform.projection.unsupportedLayers.includes(i.type)||zg[i.type](t,e,i,r,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(t){if(!this.options.gpuTiming)return;const e=this.context.extTimerQuery;let i=this.gpuTimers[t.id];i||(i=this.gpuTimers[t.id]={calls:0,cpuTime:0,query:e.createQueryEXT()}),i.calls++,e.beginQueryEXT(e.TIME_ELAPSED_EXT,i.query)}gpuTimingEnd(){if(!this.options.gpuTiming)return;const t=this.context.extTimerQuery;t.endQueryEXT(t.TIME_ELAPSED_EXT)}collectGpuTimers(){const t=this.gpuTimers;return this.gpuTimers={},t}queryGpuTimers(t){const e={};for(const i in t){const r=t[i],n=this.context.extTimerQuery,s=n.getQueryObjectEXT(r.query,n.QUERY_RESULT_EXT)/1e6;n.deleteQueryEXT(r.query),e[i]=s}return e}translatePosMatrix(t,e,i,r,n){if(!i[0]&&!i[1])return t;const s=n?"map"===r?this.transform.angle:0:"viewport"===r?-this.transform.angle:0;if(s){const t=Math.sin(s),e=Math.cos(s);i=[i[0]*e-i[1]*t,i[0]*t+i[1]*e]}const o=[n?i[0]:lp(e,i[0],this.transform.zoom),n?i[1]:lp(e,i[1],this.transform.zoom),0],a=new Float32Array(16);return ol(a,t,o),a}saveTileTexture(t){const e=this._tileTextures[t.size[0]];e?e.push(t):this._tileTextures[t.size[0]]=[t]}getTileTexture(t){const e=this._tileTextures[t];return e&&e.length>0?e.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const e=this.imageManager.getPattern(t.from.toString()),i=this.imageManager.getPattern(t.to.toString());return!e||!i}currentGlobalDefines(){const t=this.terrain&&this.terrain.renderingToTexture,e=this.style&&this.style.fog,i=[];return this.terrain&&!this.terrain.renderingToTexture&&i.push("TERRAIN"),e&&!t&&0!==e.getOpacity(this.transform.pitch)&&i.push("FOG"),t&&i.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&i.push("OVERDRAW_INSPECTOR"),i}useProgram(t,e,i){this.cache=this.cache||{};const r=i||[],n=this.currentGlobalDefines().concat(r),s=S_.cacheKey(t,n,e);return this.cache[s]||(this.cache[s]=new S_(this.context,t,s_[t],e,eg[t],n)),this.cache[s]}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 t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=l.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new qu(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}prepareDrawProgram(t,e,i){if(this.terrain&&this.terrain.renderingToTexture)return;const r=this.style.fog;if(r){const n=r.getOpacity(this.transform.pitch);0!==n&&e.setFogUniformValues(t,((t,e,i,r)=>{const n=e.properties.get("color"),s=t.frameCounter/1e3%1,o=[n.r/n.a,n.g/n.a,n.b/n.a,r];return{u_fog_matrix:i?t.transform.calculateFogTileMatrix(i):t.identityMat,u_fog_range:e.getFovAdjustedRange(t.transform._fov),u_fog_color:o,u_fog_horizon_blend:e.properties.get("horizon-blend"),u_fog_temporal_offset:s}})(this,r,i,n))}}setTileLoadedFlag(t){this.tileLoaded=t}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const t=this.context.gl,e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.copyTexImage2D(t.TEXTURE_2D,0,t.RGBA,0,0,t.drawingBufferWidth,t.drawingBufferHeight,0),e}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const t=this.style&&this.style.fog;return!!t&&0!==t.getOpacity(this.transform.pitch)}getBackgroundTiles(){const t=this._backgroundTiles,e=this._backgroundTiles={},i=this.transform.coveringTiles({tileSize:512});for(const r of i)e[r.key]=t[r.key]||new dd(r,512,this.transform.tileZoom,this);return e}clearBackgroundTiles(){this._backgroundTiles={}}}function Mg(t,e){const i=t.fovAboveCenter,r=t.elevation?t.elevation.getMinElevationBelowMSL()*e:0,n=(t._camera.position[2]*t.worldSize-r)/Math.cos(t._pitch),s=Math.sin(i)*n/Math.sin(Math.max(Math.PI/2-t._pitch-i,.01)),o=Math.sin(t._pitch)*s+n;return Math.min(1.01*o,n*(1/t._horizonShift))}const kg=rl(new Float32Array(16));class Pg{constructor(t){this.name=t.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(t,e){return{x:0,y:0,z:0}}unproject(t,e){return new ua(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e){return t._coordinatePoint(t.locationCoordinate(e),!1)}pixelsPerMeter(t,e){return _a(1,t)*e}farthestPixelDistance(t){return Mg(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,r){const n=t.horizonLineFromTop(!1),s=new o(e,Math.max(n,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(s,r))}createInversionMatrix(t,e){return kg}createTileMatrix(t,e,i){let r,n,s;const o=i.canonical,a=rl(new Float64Array(16));if(this.isReprojectedInTileSpace){const l=Gp(o,this);r=1,n=l.x+i.wrap*l.scale,s=l.y,al(a,a,[r/l.scale,r/l.scale,t.pixelsPerMeter/e])}else r=e/t.zoomScale(o.z),n=(o.x+Math.pow(2,o.z)*i.wrap)*r,s=o.y*r;return ol(a,a,[n,s,0]),al(a,a,[r/la,r/la,1]),a}upVector(t,e,i){return[0,0,1]}upVectorScale(t,e,i){return{metersToTile:1,metersToLabelSpace:1}}}class Dg extends Pg{constructor(t){super(t),this.range=[4,7],this.center=t.center||[-96,37.5];const[e,i]=this.parallels=t.parallels||[29.5,45.5],r=Math.sin(p(e));this.n=(r+Math.sin(p(i)))/2,this.c=1+r*(2*this.n-r),this.r0=Math.sqrt(this.c)/this.n}project(t,e){const{n:i,c:r,r0:n}=this,s=p(t-this.center[0]),o=p(e),a=Math.sqrt(r-2*i*Math.sin(o))/i;return{x:a*Math.sin(s*i),y:a*Math.cos(s*i)-n,z:0}}unproject(t,e){const{n:i,c:r,r0:n}=this,s=n+e;let o=Math.atan2(t,Math.abs(s))*Math.sign(s);s*i<0&&(o-=Math.PI*Math.sign(t)*Math.sign(s));const a=p(this.center[0])*i;o=w(o,-Math.PI-a,Math.PI-a);const l=d(o/i)+this.center[0],c=Math.asin(v((r-(t*t+s*s)*i*i)/(2*i),-1,1)),h=v(d(c),-85.051129,va);return new ua(l,h)}}const Bg=1.340264,Lg=-.081106,Rg=893e-6,Fg=.003796,Og=Math.sqrt(3)/2;class Vg extends Pg{project(t,e){e=e/180*Math.PI,t=t/180*Math.PI;const i=Math.asin(Og*Math.sin(e)),r=i*i,n=r*r*r;return{x:.5*(t*Math.cos(i)/(Og*(Bg+3*Lg*r+n*(7*Rg+9*Fg*r)))/Math.PI+.5),y:1-.5*(i*(Bg+Lg*r+n*(Rg+Fg*r))/Math.PI+1),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI;let i=e=(2*(1-e)-1)*Math.PI,r=i*i,n=r*r*r;for(let t,s,o,a=0;a<12&&(s=i*(Bg+Lg*r+n*(Rg+Fg*r))-e,o=Bg+3*Lg*r+n*(7*Rg+9*Fg*r),t=s/o,i=v(i-t,-Math.PI/3,Math.PI/3),r=i*i,n=r*r*r,!(Math.abs(t)<1e-12));++a);const s=Og*t*(Bg+3*Lg*r+n*(7*Rg+9*Fg*r))/Math.cos(i),o=Math.asin(Math.sin(i)/Og),a=v(180*s/Math.PI,-180,180),l=v(180*o/Math.PI,-85.051129,va);return new ua(a,l)}}class jg extends Pg{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){return{x:.5+t/360,y:.5-e/360,z:0}}unproject(t,e){const i=360*(t-.5),r=v(360*(.5-e),-85.051129,va);return new ua(i,r)}}const Ug=Math.PI/2;function Ng(t){return Math.tan((Ug+t)/2)}class Zg extends Pg{constructor(t){super(t),this.center=t.center||[0,30];const[e,i]=this.parallels=t.parallels||[30,30],r=p(e),n=p(i),s=Math.cos(r);this.n=r===n?Math.sin(r):Math.log(s/Math.cos(n))/Math.log(Ng(n)/Ng(r)),this.f=s*Math.pow(Ng(r),this.n)/this.n}project(t,e){e=p(e),t=p(t-this.center[0]);const i=1e-6,{n:r,f:n}=this;n>0?e<-Ug+i&&(e=-Ug+i):e>Ug-i&&(e=Ug-i);const s=n/Math.pow(Ng(e),r),o=s*Math.sin(r*t),a=n-s*Math.cos(r*t);return{x:.5*(o/Math.PI+.5),y:1-.5*(a/Math.PI+.5),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,e=(2*(1-e)-.5)*Math.PI;const{n:i,f:r}=this,n=r-e,s=Math.sign(n),o=Math.sign(i)*Math.sqrt(t*t+n*n);let a=Math.atan2(t,Math.abs(n))*s;n*i<0&&(a-=Math.PI*Math.sign(t)*s);const l=v(d(a/i)+this.center[0],-180,180),c=v(d(2*Math.atan(Math.pow(r/o,1/i))-Ug),-85.051129,va);return new ua(l,c)}}class qg extends Pg{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(t,e){return{x:fa(t),y:ma(e),z:0}}unproject(t,e){const i=ga(t),r=ya(e);return new ua(i,r)}}const Gg=p(va);class $g extends Pg{project(t,e){const i=(e=p(e))*e,r=i*i;return{x:.5*((t=p(t))*(.8707-.131979*i+r*(r*(.003971*i-.001529*r)-.013791))/Math.PI+.5),y:1-.5*(e*(1.007226+i*(.015085+r*(.028874*i-.044475-.005916*r)))/Math.PI+1),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI;let i=e=(2*(1-e)-1)*Math.PI,r=25,n=0,s=i*i;do{s=i*i;const t=s*s;n=(i*(1.007226+s*(.015085+t*(.028874*s-.044475-.005916*t)))-e)/(1.007226+s*(.045255+t*(.259866*s-.311325-.005916*11*t))),i=v(i-n,-Gg,Gg)}while(Math.abs(n)>1e-6&&--r>0);s=i*i;const o=v(d(t/(.8707+s*(s*(s*s*s*(.003971-.001529*s)-.013791)-.131979))),-180,180),a=d(i);return new ua(o,a)}}const Wg=p(va);class Xg extends Pg{project(t,e){e=p(e),t=p(t);const i=Math.cos(e),r=2/Math.PI,n=Math.acos(i*Math.cos(t/2)),s=Math.sin(n)/n,o=.5*(t*r+2*i*Math.sin(t/2)/s)||0,a=.5*(e+Math.sin(e)/s)||0;return{x:.5*(o/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,r=e=(2*(1-e)-1)*Math.PI,n=25;const s=1e-6;let o=0,a=0;do{const n=Math.cos(r),s=Math.sin(r),l=2*s*n,c=s*s,h=n*n,u=Math.cos(i/2),p=Math.sin(i/2),d=2*u*p,f=p*p,m=1-h*u*u,_=m?1/m:0,g=m?Math.acos(n*u)*Math.sqrt(1/m):0,y=.5*(2*g*n*p+2*i/Math.PI)-t,x=.5*(g*s+r)-e,b=.5*_*(h*f+g*n*u*c)+1/Math.PI,w=_*(d*l/4-g*s*p),T=.125*_*(l*p-g*s*h*d),E=.5*_*(c*u+g*f*n)+.5,I=w*T-E*b;o=(x*w-y*E)/I,a=(y*T-x*b)/I,i=v(i-o,-Math.PI,Math.PI),r=v(r-a,-Wg,Wg)}while((Math.abs(o)>s||Math.abs(a)>s)&&--n>0);return new ua(d(i),d(r))}}class Hg extends Pg{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(p(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){const{scale:i,cosPhi:r}=this;return{x:p(t)*r*i+.5,y:-Math.sin(p(e))/r*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:r}=this,n=-(e-.5)/i,s=v(d((t-.5)/i)/r,-180,180),o=Math.asin(v(n*r,-1,1)),a=v(d(o),-85.051129,va);return new ua(s,a)}}const Kg=2*_a(1,0)*pp*Math.PI;class Yg extends qg{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!1,this.zAxisUnit="pixels",this.unsupportedLayers=["debug","custom"]}projectTilePoint(t,e,i){const r=Math.pow(2,i.z),n=(t/la+i.x)/r,s=Tp(ya((e/la+i.y)/r),ga(n));return Cl(s,s,Sp(xp(i))),{x:s[0],y:s[1],z:s[2]}}locationPoint(t,e){const i=Tp(e.lat,e.lng),r=Sl([],i),n=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude;Il(i,i,r,_a(1,0)*la*n);const s=rl(new Float64Array(16));return sl(s,t.pixelMatrix,t.globeMatrix),Cl(i,i,s),new o(i[0],i[1])}pixelsPerMeter(t,e){return _a(1,0)*e}createTileMatrix(t,e,i){const r=Ap(xp(i.canonical));return sl(new Float64Array(16),t.globeMatrix,r)}createInversionMatrix(t,e){const{center:i,worldSize:r}=t,n=zp(r),s=rl(new Float64Array(16));sl(s,s,Sp(xp(e))),cl(s,s,p(i.lng)),ll(s,s,p(i.lat)),al(s,s,[1/n,1/n,1]);const o=t.pixelsPerMeter/_a(1,i.lat)/la;return al(s,s,[o,o,1]),Float32Array.from(s)}pointCoordinate(t,e,i,r){const n=El([],t._camera.position,t.worldSize),s=[e,i,1,1];Ol(s,s,t.pixelMatrixInverse),Fl(s,s,1/s[3]);const o=Sl([],Dl([],s,n)),a=t.globeMatrix,l=[a[12],a[13],a[14]],c=Dl([],l,n),h=gl(c),u=Sl([],c),p=t.worldSize/(2*Math.PI),f=Al(u,o),m=Math.asin(p/h);if(m<Math.acos(f)){const t=[],e=[];El(t,o,h/f),Sl(e,Dl(e,t,c)),Sl(o,xl(o,c,El(o,e,Math.tan(m)*h)))}const _=[];new Nl(n,o).closestPointOnSphere(l,p,_);const g=Sl([],K(a,0)),y=Sl([],K(a,1)),x=Sl([],K(a,2)),b=Al(g,_),w=Al(y,_),T=Al(x,_),E=d(Math.asin(-w/p));let I=d(Math.atan2(b,T));I=t.center.lng+function(t,e){const i=(e-t+180)%360-180;return i<-180?i+360:i}(t.center.lng,I);const S=fa(I),A=v(ma(E),0,1);return new ba(S,A)}farthestPixelDistance(t){const e=function(t,e){const i=t.cameraToCenterDistance,r=t._centerAltitude*e,n=t._camera,s=t._camera.forward(),o=xl([],El([],s,-i),[0,0,r]),a=t.worldSize/(2*Math.PI),l=[0,0,-a],c=t.width/t.height,h=Math.tan(t.fovAboveCenter),u=El([],n.up(),h),p=El([],n.right(),h*c),d=Sl([],xl([],xl([],s,u),p)),f=[];let m;if(new Nl(o,d).closestPointOnSphere(l,a,f)){const e=xl([],f,l),i=Dl([],e,o);m=Math.cos(t.fovAboveCenter)*gl(i)}else{const t=Dl([],o,l),e=Dl([],l,o);Sl(e,e);const i=gl(t)-a;m=Math.sqrt(i*i+2*a*i);const r=Math.acos(m/(a+i))-Math.acos(Al(s,e));m*=Math.cos(r)}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),i=Pp(t.zoom);return i>0?Ai(e,Mg(t,_a(1,t.center.lat)*t.worldSize),i):e}upVector(t,e,i){const r=1<<t.z,n=(e/la+t.x)/r;return Tp(ya((i/la+t.y)/r),ga(n),1)}upVectorScale(t,e,i){const r=_a(1,e)*i;return{metersToTile:Kg*Ip(xp(t)),metersToLabelSpace:r}}}class Jg{constructor(t=0,e=0,i=0,r=0){if(isNaN(t)||t<0||isNaN(e)||e<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=t,this.bottom=e,this.left=i,this.right=r}interpolate(t,e,i){return null!=e.top&&null!=t.top&&(this.top=Ai(t.top,e.top,i)),null!=e.bottom&&null!=t.bottom&&(this.bottom=Ai(t.bottom,e.bottom,i)),null!=e.left&&null!=t.left&&(this.left=Ai(t.left,e.left,i)),null!=e.right&&null!=t.right&&(this.right=Ai(t.right,e.right,i)),this}getCenter(t,e){const i=v((this.left+t-this.right)/2,0,t),r=v((this.top+e-this.bottom)/2,0,e);return new o(i,r)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Jg(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Qg(t,e){const i=K(t,3);ul(t,e),Y(t,3,i)}function ty(t,e){const i=jl([]);return function(t,e,i){i*=.5;var r=e[0],n=e[1],s=e[2],o=e[3],a=Math.sin(i),l=Math.cos(i);t[0]=r*l+n*a,t[1]=n*l-r*a,t[2]=s*l+o*a,t[3]=o*l-s*a}(i,i,-e),Ul(i,i,-t),i}function ey(t,e){const i=[t[0],t[1],0],r=[e[0],e[1],0];if(gl(i)>=1e-15){const t=Sl([],i);El(r,t,Al(r,t)),e[0]=r[0],e[1]=r[1]}const n=zl([],e,t);if(Rl(n)<1e-15)return null;const s=Math.atan2(-n[1],n[0]);return ty(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),s)}class iy{constructor(t,e){this.position=t,this.orientation=e}get position(){return this._position}set position(t){if(t){const e=t instanceof ba?t:new ba(t[0],t[1],t[2]);this._renderWorldCopies&&(e.x=w(e.x,0,1)),this._position=e}else this._position=null}lookAtPoint(t,e){if(this.orientation=null,!this.position)return;const i=this._elevation?this._elevation.getAtPointOrZero(ba.fromLngLat(t)):0,r=this.position,n=ba.fromLngLat(t,i),s=[n.x-r.x,n.y-r.y,n.z-r.z];e||(e=[0,0,1]),e[2]=Math.abs(e[2]),this.orientation=ey(s,e)}setPitchBearing(t,e){this.orientation=ty(p(t),p(-e))}}class ry{constructor(t,e){this._transform=rl([]),this.orientation=e,this.position=t}get mercatorPosition(){const t=this.position;return new ba(t[0],t[1],t[2])}get position(){const t=K(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var e;t&&Y(this._transform,3,[(e=t)[0],e[1],e[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||jl([]),t&&Qg(this._transform,this._orientation)}getPitchBearing(){const t=this.forward(),e=this.right();return{bearing:Math.atan2(-e[1],e[0]),pitch:Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2])}}setPitchBearing(t,e){this._orientation=ty(t,e),Qg(this._transform,this._orientation)}forward(){const t=K(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){const t=K(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){const t=K(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,e){const i=new Float64Array(16);return nl(i,this.getWorldToCamera(t,e)),i}getWorldToCameraPosition(t,e,i){const r=this.position;El(r,r,-t);const n=new Float64Array(16);var s,o;return(s=n)[0]=(o=[i,i,i])[0],s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=o[1],s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=o[2],s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,ol(n,n,r),n[10]*=e,n}getWorldToCamera(t,e){const i=new Float64Array(16),r=new Float64Array(4),n=this.position;var s,o;return(s=r)[0]=-(o=this._orientation)[0],s[1]=-o[1],s[2]=-o[2],s[3]=o[3],El(n,n,-t),ul(i,r),ol(i,i,n),i[1]*=-1,i[5]*=-1,i[9]*=-1,i[13]*=-1,i[8]*=e,i[9]*=e,i[10]*=e,i[11]*=e,i}getCameraToClipPerspective(t,e,i,r){const n=new Float64Array(16);return pl(n,t,e,i,r),n}getDistanceToElevation(t){const e=0===t?0:_a(t,this.position[1]),i=this.forward();return(e-this.position[2])/i[2]}clone(){return new ry([...this.position],[...this.orientation])}}function ny(t,e){const i=oy(t),r=function(t,e,i,r,n){const s=new ua(i.lng-180*ay,i.lat),o=new ua(i.lng+180*ay,i.lat),a=t.project(s.lng,s.lat),l=t.project(o.lng,o.lat),c=-Math.atan2(l.y-a.y,l.x-a.x),h=ba.fromLngLat(i);h.y=v(h.y,-.999975,.999975);const u=h.toLngLat(),p=t.project(u.lng,u.lat),d=ba.fromLngLat(u);d.x+=ay;const f=d.toLngLat(),m=t.project(f.lng,f.lat),_=cy(m.x-p.x,m.y-p.y,c),g=ba.fromLngLat(u);g.y+=ay;const y=g.toLngLat(),x=t.project(y.lng,y.lat),b=cy(x.x-p.x,x.y-p.y,c),w=Math.abs(_.x)/Math.abs(b.y),T=rl([]);hl(T,T,-c*(1-(n?0:r)));const E=rl([]);return al(E,E,[1,1-(1-w)*r,1]),E[4]=-b.x/b.y*r,hl(E,E,c),sl(E,T,E),E}(t.projection,0,t.center,i,e),n=sy(t);return al(r,r,[n,n,1]),r}function sy(t){const e=t.projection,i=oy(t),r=ly(e,t.center),n=ly(e,ua.convert(e.center));return Math.pow(2,r*i+(1-i)*n)}function oy(t){const e=t.projection.range;if(!e)return 0;const i=Math.max(t.width,t.height),r=Math.log(i/1024)/Math.LN2;return b(e[0]+r,e[1]+r,t.zoom)}const ay=1/4e4;function ly(t,e){const i=v(e.lat,-85.051129,va),r=new ua(e.lng-180*ay,i),n=new ua(e.lng+180*ay,i),s=t.project(r.lng,i),o=t.project(n.lng,i),a=ba.fromLngLat(r),l=ba.fromLngLat(n),c=o.x-s.x,h=o.y-s.y,u=l.x-a.x,p=l.y-a.y,d=Math.sqrt((u*u+p*p)/(c*c+h*h));return Math.log(d)/Math.LN2}function cy(t,e,i){const r=Math.cos(i),n=Math.sin(i);return{x:t*r-e*n,y:t*n+e*r}}class hy{constructor(t,e,i,r,n,s,o){this.tileSize=512,this._renderWorldCopies=void 0===n||n,this._minZoom=t||0,this._maxZoom=e||22,this._minPitch=null==i?0:i,this._maxPitch=null==r?60:r,this.setProjection(s),this.setMaxBounds(o),this.width=0,this.height=0,this._center=new ua(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 Jg,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new ry,this._centerAltitude=0,this._centerAltitudeValid=!1,this._averageElevation=0,this.cameraElevationReference="ground",this._projectionScaler=1,this._horizonShift=.1}clone(){const t=new hy(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return t._elevation=this._elevation,t._centerAltitude=this._centerAltitude,t._centerAltitudeValid=this._centerAltitudeValid,t.tileSize=this.tileSize,t.width=this.width,t.height=this.height,t.cameraElevationReference=this.cameraElevationReference,t._center=this._center,t._setZoom(this.zoom),t._seaLevelZoom=this._seaLevelZoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._nearZ=this._nearZ,t._farZ=this._farZ,t._averageElevation=this._averageElevation,t._unmodified=this._unmodified,t._edgeInsets=this._edgeInsets.clone(),t._camera=this._camera.clone(),t._calcMatrices(),t.freezeTileCoverage=this.freezeTileCoverage,t}get elevation(){return this._elevation}set elevation(t){this._elevation!==t&&(this._elevation=t,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(t){null==this._seaLevelZoom&&this._updateCameraOnTerrain(),t&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return S(this.projection,["name","center","parallels"])}setProjection(t){null==t&&(t={name:"mercator"}),this.projectionOptions=t;const e=this.projection?this.getProjection():void 0;this.projection=function(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])<.01;switch(t.name){case"mercator":return new qg(t);case"equirectangular":return new jg(t);case"naturalEarth":return new $g(t);case"equalEarth":return new Vg(t);case"winkelTripel":return new Xg(t);case"albers":return i?new Hg(t):new Dg(t);case"lambertConformalConic":return i?new Hg(t):new Zg(t);case"globe":return new Yg(t)}throw new Error(`Invalid projection name: ${t.name}`)}(t);const i=this.getProjection();return c(e,i)?null:(this._calcMatrices(),i)}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){const t=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(t))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.cameraWorldSize)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new o(this.width,this.height)}get bearing(){return w(this.rotation,-180,180)}set bearing(t){this.rotation=t}get rotation(){return-this.angle/Math.PI*180}set rotation(t){const e=-t*Math.PI/180;var i;this.angle!==e&&(this._unmodified=!1,this.angle=e,this._calcMatrices(),this.rotationMatrix=(i=new Ya(4),Ya!=Float32Array&&(i[1]=0,i[2]=0),i[0]=1,i[3]=1,i),function(t,e,i){var r=e[0],n=e[1],s=e[2],o=e[3],a=Math.sin(i),l=Math.cos(i);t[0]=r*l+s*a,t[1]=n*l+o*a,t[2]=r*-a+s*l,t[3]=n*-a+o*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const e=v(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==e&&(this._unmodified=!1,this._pitch=e,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(t){this._averageElevation=t,this._calcFogMatrices()}get zoom(){return this._zoom}set zoom(t){const e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._setZoom(e),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(t){this._zoom=t,this.scale=this.zoomScale(t),this.tileZoom=Math.floor(t),this.zoomFraction=t-this.tileZoom}_updateCameraOnTerrain(){if(!this._elevation||!this._elevation.isDataAvailableAtPoint(this.locationCoordinate(this.center)))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValid=!1);this._centerAltitude=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValid=!0,this._updateSeaLevelZoom()}_updateSeaLevelZoom(){this._centerAltitudeValid&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const t=this._elevation,e=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],i=this.horizonLineFromTop();let r=0,n=0;for(let s=0;s<e.length;s++){const a=new o(e[s][0]*this.width,i+e[s][1]*(this.height-i)),l=t.pointCoordinate(a);if(!l)continue;const c=1/Math.hypot(l[0]-this._camera.position[0],l[1]-this._camera.position[1]);r+=l[3]*c,n+=c}return 0===n?NaN:r/n}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._terrainEnabled()&&("ground"===this.cameraElevationReference?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(null==this._seaLevelZoom||!this._elevation)return;const t=this._seaLevelZoom,e=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),i=this.pixelsPerMeter/this.worldSize*e,r=this._mercatorZfromZoom(t),n=this._mercatorZfromZoom(this._maxZoom),s=Math.max(r-i,n);this._setZoom(this._zoomFromMercatorZ(s))}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}computeZoomRelativeTo(t){const e=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,t.toAltitude()));let i;i=t.z<this._camera.position[2]?[e.x,e.y,e.z]:[t.x,t.y,t.z];const r=gl(Dl([],this._camera.position,i));return v(this._zoomFromMercatorZ(r),this._minZoom,this._maxZoom)}setFreeCameraOptions(t){if(!this.height)return;if(!t.position&&!t.orientation)return;this._updateCameraState();let e=!1;if(t.orientation&&!function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}(t.orientation,this._camera.orientation)&&(e=this._setCameraOrientation(t.orientation)),t.position){const n=[t.position.x,t.position.y,t.position.z];((i=n)[0]!==(r=this._camera.position)[0]||i[1]!==r[1]||i[2]!==r[2])&&(this._setCameraPosition(n),e=!0)}var i,r;e&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const t=this._camera.position,e=new iy;return e.position=new ba(t[0],t[1],t[2]),e.orientation=this._camera.orientation,e._elevation=this.elevation,e._renderWorldCopies=this.renderWorldCopies,e}_setCameraOrientation(t){if(e=t,!Math.hypot(e[0],e[1],e[2],e[3]))return!1;var e;!function(t,e){var i=e[0],r=e[1],n=e[2],s=e[3],o=i*i+r*r+n*n+s*s;o>0&&(o=1/Math.sqrt(o)),t[0]=i*o,t[1]=r*o,t[2]=n*o,t[3]=s*o}(t,t);const i=kl([],[0,0,-1],t),r=kl([],[0,-1,0],t);if(r[2]<0)return!1;const n=ey(i,r);return!!n&&(this._camera.orientation=n,!0)}_setCameraPosition(t){const e=this.zoomScale(this.minZoom)*this.tileSize,i=this.zoomScale(this.maxZoom)*this.tileSize,r=this.cameraToCenterDistance;t[2]=v(t[2],r/i,r/e),this._camera.position=t}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,e,i){this._unmodified=!1,this._edgeInsets.interpolate(t,e,i),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){const e=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,e)}getVisibleUnwrappedCoordinates(t){const e=[new Np(0,t)];if(this.renderWorldCopies){const i=this.pointCoordinate(new o(0,0)),r=this.pointCoordinate(new o(this.width,0)),n=this.pointCoordinate(new o(this.width,this.height)),s=this.pointCoordinate(new o(0,this.height)),a=Math.floor(Math.min(i.x,r.x,n.x,s.x)),l=Math.floor(Math.max(i.x,r.x,n.x,s.x)),c=1;for(let i=a-c;i<=l+c;i++)0!==i&&e.push(new Np(i,t))}return e}coveringTiles(t){let e=this.coveringZoomLevel(t);const i=e,r=this.elevation&&!t.isTerrainDEM,n="mercator"===this.projection.name;if(void 0!==t.minzoom&&e<t.minzoom)return[];void 0!==t.maxzoom&&e>t.maxzoom&&(e=t.maxzoom);const s=this.locationCoordinate(this.center),o=this.center.lat,a=1<<e,l=[a*s.x,a*s.y,0],c="globe"===this.projection.name,h=!c,u=Zl.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,e,h),p=c?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),d=a*_a(1,this.center.lat),m=this._camera.position[2]/_a(1,this.center.lat),_=[a*p.x,a*p.y,m*(h?1:d)],g=this.cameraToCenterDistance/t.tileSize*(t.roundZoom?1:.502),y=this.pitch<=60&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace?e:0,x=t.isTerrainDEM&&this._elevation?1e4*this._elevation.exaggeration():this._centerAltitude,v=t.isTerrainDEM?-x:this._elevation?this._elevation.getMinElevationBelowMSL():0,b=this.projection.isReprojectedInTileSpace?sy(this):1,w=t=>{const e=1/4e4,i=new ba(t.x+e,t.y,t.z),r=new ba(t.x,t.y+e,t.z),n=t.toLngLat(),s=i.toLngLat(),o=r.toLngLat(),a=this.locationCoordinate(n),l=this.locationCoordinate(s),c=this.locationCoordinate(o),h=Math.hypot(l.x-a.x,l.y-a.y),u=Math.hypot(c.x-a.x,c.y-a.y);return Math.sqrt(h*u)*b/e},T=t=>{const e=x,i=v;return{aabb:$p(this,a,0,0,0,t,i,e,this.projection),zoom:0,x:0,y:0,minZ:i,maxZ:e,wrap:t,fullyVisible:!1}},E=[];let I=[];const S=e,A=t.reparseOverscaled?i:e,z=t=>t*t,C=z((m-this._centerAltitude)*d),M=t=>{if(!this._elevation||!t.tileID||!n)return;const e=this._elevation.getMinMaxForTile(t.tileID),i=t.aabb;e?(i.min[2]=e.min,i.max[2]=e.max,i.center[2]=(i.min[2]+i.max[2])/2):(t.shouldSplit=k(t),t.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude))},k=t=>{if(t.zoom<y)return!0;if(t.zoom===S)return!1;if(null!=t.shouldSplit)return t.shouldSplit;const e=t.aabb.distanceX(_),n=t.aabb.distanceY(_);let s=C,a=1;if(c){s=z(t.aabb.distanceZ(_));const e=Math.pow(2,t.zoom),i=ya((t.y+1)/e),r=ya(t.y/e),n=da(Math.min(Math.max(o,i),r))/da(o);a=Math.min(n,1)}else if(r&&(s=z(t.aabb.distanceZ(_)*d)),this.projection.isReprojectedInTileSpace&&i<=5){const e=Math.pow(2,t.zoom),i=w(new ba((t.x+.5)/e,(t.y+.5)/e));a=i>.85?1:i}const l=e*e+n*n+s;return l<z((1<<S-t.zoom)*g*a*((t,e)=>{if(e*z(.707)<t)return 1;const i=Math.sqrt(e/t);return i/(1.4144271570014144+(Math.pow(1.1,i-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(s,C),l))};if(this.renderWorldCopies)for(let t=1;t<=3;t++)E.push(T(-t)),E.push(T(t));for(E.push(T(0));E.length>0;){const i=E.pop(),s=i.x,o=i.y;let h=i.fullyVisible;if(!h){const t=i.aabb.intersects(u);if(0===t)continue;h=2===t}if(i.zoom!==S&&k(i))for(let t=0;t<4;t++){const e=(s<<1)+t%2,l=(o<<1)+(t>>1),u={aabb:n?i.aabb.quadrant(t):$p(this,a,i.zoom+1,e,l,i.wrap,i.minZ,i.maxZ,this.projection),zoom:i.zoom+1,x:e,y:l,wrap:i.wrap,fullyVisible:h,tileID:void 0,shouldSplit:void 0,minZ:i.minZ,maxZ:i.maxZ};r&&!c&&(u.tileID=new Zp(i.zoom+1===S?A:i.zoom+1,i.wrap,i.zoom+1,e,l),M(u)),E.push(u)}else{const r=i.zoom===S?A:i.zoom;if(t.minzoom&&t.minzoom>r)continue;const n=l[0]-(.5+s+(i.wrap<<i.zoom))*(1<<e-i.zoom),a=l[1]-.5-o,c=i.tileID?i.tileID:new Zp(r,i.wrap,i.zoom,s,o);I.push({tileID:c,distanceSq:n*n+a*a})}}if(this.fogCullDistSq){const e=this.fogCullDistSq,i=this.horizonLineFromTop();I=I.filter((r=>{const n=[0,0,0,1],s=[la,la,0,1],o=this.calculateFogTileMatrix(r.tileID.toUnwrapped());Ol(n,n,o),Ol(s,s,o);const a=function(t,e,i){let r=0;for(let i=0;i<2;++i){const n=0;t[i]>n&&(r+=(t[i]-n)*(t[i]-n)),e[i]<n&&(r+=(n-e[i])*(n-e[i]))}return r}(n,s);if(0===a)return!0;let l=!1;const c=this._elevation;if(c&&a>e&&0!==i){const e=this.calculateProjMatrix(r.tileID.toUnwrapped());let n;t.isTerrainDEM||(n=c.getMinMaxForTile(r.tileID)),n||(n={min:v,max:x});const s=function(t){const e=Math.round((t+45+360)%360/90)%4;return f[e]}(this.rotation),o=[s[0]*la,s[1]*la,n.max];Cl(o,o,e),l=(1-o[1])*this.height*.5<i}return a<e||l}))}return I.sort(((t,e)=>t.distanceSq-e.distanceSq)).map((t=>t.tileID))}resize(t,e){this.width=t,this.height=e,this.pixelsToGLUnits=[2/t,-2/e],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(t){const e=v(t.lat,-85.051129,va),i=this.projection.project(t.lng,e);return new o(i.x*this.worldSize,i.y*this.worldSize)}unproject(t){return this.projection.unproject(t.x/this.worldSize,t.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(t,e){let i,r;const n=this.centerPoint;if("globe"===this.projection.name){const t=this.worldSize;i=(e.x-n.x)/t,r=(e.y-n.y)/t}else{const t=this.pointCoordinate(e),s=this.pointCoordinate(n);i=t.x-s.x,r=t.y-s.y}const s=this.locationCoordinate(t);this.setLocation(new ba(s.x-i,s.y-r))}setLocation(t){this.center=this.coordinateLocation(t),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(t){return this.projection.locationPoint(this,t)}locationPoint3D(t){return this._coordinatePoint(this.locationCoordinate(t),!0)}pointLocation(t){return this.coordinateLocation(this.pointCoordinate(t))}pointLocation3D(t){return this.coordinateLocation(this.pointCoordinate3D(t))}locationCoordinate(t,e){const i=e?_a(e,t.lat):void 0,r=this.projection.project(t.lng,t.lat);return new ba(r.x,r.y,i)}coordinateLocation(t){return this.projection.unproject(t.x,t.y)}pointRayIntersection(t,e){const i=null!=e?e:this._centerAltitude,r=[t.x,t.y,0,1],n=[t.x,t.y,1,1];Ol(r,r,this.pixelMatrixInverse),Ol(n,n,this.pixelMatrixInverse);const s=n[3];Fl(r,r,1/r[3]),Fl(n,n,1/s);const o=r[2],a=n[2];return{p0:r,p1:n,t:o===a?0:(i-o)/(a-o)}}screenPointToMercatorRay(t){const e=[t.x,t.y,0,1],i=[t.x,t.y,1,1];return Ol(e,e,this.pixelMatrixInverse),Ol(i,i,this.pixelMatrixInverse),Fl(e,e,1/e[3]),Fl(i,i,1/i[3]),e[2]=_a(e[2],this._center.lat)*this.worldSize,i[2]=_a(i[2],this._center.lat)*this.worldSize,Fl(e,e,1/this.worldSize),Fl(i,i,1/this.worldSize),new Nl([e[0],e[1],e[2]],Sl([],Dl([],i,e)))}rayIntersectionCoordinate(t){const{p0:e,p1:i,t:r}=t,n=_a(e[2],this._center.lat),s=_a(i[2],this._center.lat);return new ba(Ai(e[0],i[0],r)/this.worldSize,Ai(e[1],i[1],r)/this.worldSize,Ai(n,s,r))}pointCoordinate(t,e=this._centerAltitude){return this.projection.pointCoordinate(this,t.x,t.y,e)}pointCoordinate3D(t){if(!this.elevation)return this.pointCoordinate(t);const e=this.elevation;let i=this.elevation.pointCoordinate(t);if(i)return new ba(i[0],i[1],i[2]);let r=0,n=this.horizonLineFromTop();if(t.y>n)return this.pointCoordinate(t);const s=.02*n,o=t.clone();for(let t=0;t<10&&n-r>s;t++){o.y=Ai(r,n,.66);const t=e.pointCoordinate(o);t?(n=o.y,i=t):r=o.y}return i?new ba(i[0],i[1],i[2]):this.pointCoordinate(t)}isPointAboveHorizon(t){if(this.elevation)return!this.elevation.pointCoordinate(t);{const e=this.horizonLineFromTop();return t.y<e}}_coordinatePoint(t,e){const i=e&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,r=[t.x*this.worldSize,t.y*this.worldSize,i+t.toAltitude(),1];return Ol(r,r,this.pixelMatrix),r[3]>0?new o(r[0]/r[3],r[1]/r[3]):new o(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(t,e){const i=new o(this._edgeInsets.left,this._edgeInsets.top),r=new o(this.width-this._edgeInsets.right,this._edgeInsets.top),n=new o(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),s=new o(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let a=this.pointCoordinate(i,t),l=this.pointCoordinate(r,t);const c=this.pointCoordinate(n,e),h=this.pointCoordinate(s,e),u=(t,e)=>(e.y-t.y)/(e.x-t.x);return a.y>1&&l.y>=0?a=new ba((1-h.y)/u(h,a)+h.x,1):a.y<0&&l.y<=1&&(a=new ba(-h.y/u(h,a)+h.x,0)),l.y>1&&a.y>=0?l=new ba((1-c.y)/u(c,l)+c.x,1):l.y<0&&a.y<=1&&(l=new ba(-c.y/u(c,l)+c.x,0)),(new ca).extend(this.coordinateLocation(a)).extend(this.coordinateLocation(l)).extend(this.coordinateLocation(h)).extend(this.coordinateLocation(c))}_getBounds3D(){const t=this.elevation;if(!t.visibleDemTiles.length)return this._getBounds(0,0);const e=t.visibleDemTiles.reduce(((t,e)=>{if(e.dem){const i=e.dem.tree;t.min=Math.min(t.min,i.minimums[0]),t.max=Math.max(t.max,i.maximums[0])}return t}),{min:Number.MAX_VALUE,max:0});return this._getBounds(e.min*t.exaggeration(),e.max*t.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(t=!0){const e=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,i=this.height/2-e*(1-this._horizonShift);return t?Math.max(0,i):i}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-85.051129,this.maxLat=va,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=fa(this.minLng)*this.tileSize,this.worldMaxX=fa(this.maxLng)*this.tileSize,this.worldMinY=ma(this.maxLat)*this.tileSize,this.worldMaxY=ma(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(t,e){return this.projection.createTileMatrix(this,e,t)}calculateDistanceTileData(t){const e=t.key,i=this._distanceTileDataCache;if(i[e])return i[e];const r=t.canonical,n=1/this.height,s=this.cameraWorldSize/this.zoomScale(r.z),o=(r.x+Math.pow(2,r.z)*t.wrap)*s,a=r.y*s,l=this.point,c=this.angle,h=Math.sin(-c),u=-Math.cos(-c);return i[e]={bearing:[h,u],center:[(l.x-o)*n,(l.y-a)*n],scale:s/la*n},i[e]}calculateFogTileMatrix(t){const e=t.key,i=this._fogTileMatrixCache;if(i[e])return i[e];const r=this.calculatePosMatrix(t,this.cameraWorldSize);return sl(r,this.worldToFogMatrix,r),i[e]=new Float32Array(r),i[e]}calculateProjMatrix(t,e=!1){const i=t.key,r=e?this._alignedProjMatrixCache:this._projMatrixCache;if(r[i])return r[i];const n=this.calculatePosMatrix(t,this.worldSize);return sl(n,this.projection.isReprojectedInTileSpace?this.mercatorMatrix:e?this.alignedProjMatrix:this.projMatrix,n),r[i]=new Float32Array(n),r[i]}calculatePixelsToTileUnitsMatrix(t){const e=t.tileID.key,i=this._pixelsToTileUnitsCache;if(i[e])return i[e];const r=function(t,e){const{scale:i}=t.tileTransform,r=i*la/(t.tileSize*Math.pow(2,e.zoom-t.tileID.overscaledZ+t.tileID.canonical.z));return function(t,e,i){var r=e[1],n=e[2],s=e[3],o=i[0],a=i[1];return t[0]=e[0]*o,t[1]=r*o,t[2]=n*a,t[3]=s*a,t}(new Float32Array(4),e.inverseAdjustmentMatrix,[r,r])}(t,this);return i[e]=r,i[e]}customLayerMatrix(){return this.mercatorMatrix.slice()}recenterOnTerrain(){if(!this._elevation)return;const t=this._elevation;this._updateCameraState();const e=_a(1,this._center.lat)*this.worldSize,i=this._computeCameraPosition(e),r=this._camera.forward(),n=_a(1,this._center.lat);i[2]/=n,r[2]/=n,Sl(r,r);const s=t.raycast(i,r,t.exaggeration());if(s){const t=Il([],i,r,s),e=new ba(t[0],t[1],_a(t[2],ya(t[1]))),o=(e.z+gl([e.x-i[0],e.y-i[1],e.z-i[2]*n]))*this._projectionScaler;this._seaLevelZoom=this._zoomFromMercatorZ(o),this._centerAltitude=e.toAltitude(),this._center=this.coordinateLocation(e),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCameraAltitude(){if(!this._elevation)return;const t=this._elevation;this._updateCameraState();const e=_a(1,this._center.lat)*this.worldSize,i=this._computeCameraPosition(e),r=t.getAtPointOrZero(new ba(...i)),n=this._minimumHeightOverTerrain()*Math.cos(p(this._maxPitch)),s=this._camera.position[2]-this.pixelsPerMeter/this.worldSize*r;if(s<n){const t=this.locationCoordinate(this._center,this._centerAltitude),e=[t.x-i[0],t.y-i[1],t.z-i[2]],r=gl(e);e[2]-=(n-s)/this._projectionScaler;const o=gl(e);if(0===o)return;El(e,e,r/o*this._projectionScaler),this._camera.position=[t.x-e[0],t.y-e[1],t.z*this._projectionScaler-e[2]],this._camera.orientation=ey(e,this._camera.up()),this._updateStateFromCamera()}}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;if(this._constraining=!0,this.projection.isReprojectedInTileSpace){const t=this.center;return t.lat=v(t.lat,this.minLat,this.maxLat),!this.maxBounds&&this.renderWorldCopies||(t.lng=v(t.lng,this.minLng,this.maxLng)),this.center=t,void(this._constraining=!1)}const t=this._unmodified,{x:e,y:i}=this.point;let r=0,n=e,s=i;const a=this.width/2,l=this.height/2,c=this.worldMinY*this.scale,h=this.worldMaxY*this.scale;if(i-l<c&&(s=c+l),i+l>h&&(s=h-l),h-c<this.height&&(r=Math.max(r,this.height/(h-c)),s=(h+c)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const t=this.worldMinX*this.scale,i=this.worldMaxX*this.scale,s=this.worldSize/2-(t+i)/2;n=(e+s+this.worldSize)%this.worldSize-s,n-a<t&&(n=t+a),n+a>i&&(n=i-a),i-t<this.width&&(r=Math.max(r,this.width/(i-t)),n=(i+t)/2)}n===e&&s===i||(this.center=this.unproject(new o(n,s))),r&&(this.zoom+=this.scaleZoom(r)),this._constrainCameraAltitude(),this._unmodified=t,this._constraining=!1}_minZoomForBounds(){let t=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(t=Math.max(t,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),t}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const t=this._fov/2,e=this.centerOffset,i=this.pixelsPerMeter;this._projectionScaler=i/(_a(1,this.center.lat)*this.worldSize),this.cameraToCenterDistance=.5/Math.tan(t)*this.height*this._projectionScaler,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const r=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?i: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 s=fl([],n,r);if(this.projection.isReprojectedInTileSpace){const t=this.locationCoordinate(this.center),e=rl([]);ol(e,e,[t.x*this.worldSize,t.y*this.worldSize,0]),sl(e,e,ny(this)),ol(e,e,[-t.x*this.worldSize,-t.y*this.worldSize,0]),sl(s,s,e),this.inverseAdjustmentMatrix=function(t){const e=ny(t,!0);return Ja([],[e[0],e[1],e[4],e[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];this.mercatorMatrix=al([],s,[this.worldSize,this.worldSize,this.worldSize/i,1]),this.projMatrix=s,this.invProjMatrix=nl(new Float64Array(16),this.projMatrix);const o=new Float32Array(16);rl(o),al(o,o,[1,-1,1]),ll(o,o,this._pitch),hl(o,o,this.angle);const a=pl(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ),l=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;a[8]=2*-e.x/this.width,a[9]=2*(e.y+l)/this.height,this.skyboxMatrix=sl(o,a,o);const c=this.point,h=c.x,u=c.y,p=this.width%2/2,d=this.height%2/2,f=Math.cos(this.angle),m=Math.sin(this.angle),_=h-Math.round(h)+f*p+m*d,g=u-Math.round(u)+f*d+m*p,y=new Float64Array(s);if(ol(y,y,[_>.5?_-1:_,g>.5?g-1:g,0]),this.alignedProjMatrix=y,s=il(),al(s,s,[this.width/2,-this.height/2,1]),ol(s,s,[1,-1,0]),this.labelPlaneMatrix=s,s=il(),al(s,s,[1,-1,1]),ol(s,s,[-1,-1,0]),al(s,s,[2/this.width,2/this.height,1]),this.glCoordMatrix=s,this.pixelMatrix=sl(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},s=nl(new Float64Array(16),this.pixelMatrix),!s)throw new Error("failed to invert matrix");this.pixelMatrixInverse=s,this.globeMatrix="globe"===this.projection.name?kp(this):s,this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSize,e=this.cameraPixelsPerMeter,i=this._camera.position,r=1/this.height,n=[t,t,e];El(n,n,r),El(i,i,-1),bl(i,i,n);const s=il();ol(s,s,i),al(s,s,n),this.mercatorFogMatrix=s,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,e,r)}_computeCameraPosition(t){const e=(t=t||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),r=this.point,n=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*e-t/this.worldSize*this._centerAltitude;return[r.x/this.worldSize-i[0]*n,r.y/this.worldSize-i[1]*n,t/this.worldSize*this._centerAltitude-i[2]*n]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(t){const e=this._maxCameraBoundsDistance()*Math.cos(this._pitch),i=t[2];let r=1;i>0&&(r=Math.min((e-this._camera.position[2])/i,1)),this._camera.position=Il([],this._camera.position,t,r),this._updateStateFromCamera(),this.projection.wrap&&(this.center=this.center.wrap())}_updateStateFromCamera(){const t=this._camera.position,e=this._camera.forward(),{pitch:i,bearing:r}=this._camera.getPitchBearing(),n=_a(this._centerAltitude,this.center.lat)*this._projectionScaler,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(p(this._maxPitch)),o=Math.max((t[2]-n)/Math.cos(i),s),a=this._zoomFromMercatorZ(o);Il(t,t,e,o),this._pitch=v(i,p(this.minPitch),p(this.maxPitch)),this.angle=w(r,-Math.PI,Math.PI),this._setZoom(v(a,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new ba(t[0],t[1],t[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(t){return Math.pow(2,t)*this.tileSize}_mercatorZfromZoom(t){return this.cameraToCenterDistance/this._worldSizeFromZoom(t)}_minimumHeightOverTerrain(){const t=Math.min((null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(t)}_zoomFromMercatorZ(t){return this.scaleZoom(this.cameraToCenterDistance/(t*this.tileSize))}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(O("Terrain is not yet supported with alternate projections. Use mercator to enable terrain."),1))}anyCornerOffEdge(t,e){const i=Math.min(t.x,e.x),r=Math.max(t.x,e.x),n=Math.min(t.y,e.y),s=Math.max(t.y,e.y);if(n<this.horizonLineFromTop(!1))return!0;if("mercator"!==this.projection.name)return!1;const a=[new o(i,n),new o(r,s),new o(i,s),new o(r,n)],l=this.renderWorldCopies?-3:0,c=this.renderWorldCopies?4:1;for(const t of a){const e=this.pointRayIntersection(t);if(e.t<0)return!0;const i=this.rayIntersectionCoordinate(e);if(i.x<l||i.y<0||i.x>c||i.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+d(this.fovAboveCenter)>88||this.anyCornerOffEdge(new o(0,0),new o(this.width,this.height))}zoomDeltaToMovement(t,e){const i=gl(Dl([],this._camera.position,t)),r=this._zoomFromMercatorZ(i)+e;return i-this._mercatorZfromZoom(r)}getCameraPoint(){const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new o(0,t))}}function uy(t,e){let i=!1,r=null;const n=()=>{r=null,i&&(t(),r=setTimeout(n,e),i=!1)};return()=>(i=!0,r||n(),r)}class py{constructor(t){this._hashName=t&&encodeURIComponent(t),P(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=uy(this._updateHashUnthrottled.bind(this),300)}addTo(t){return this._map=t,l.addEventListener("hashchange",this._onHashChange,!1),t.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),l.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(t){const e=this._map;if(!e)return"";const i=e.getCenter(),r=Math.round(100*e.getZoom())/100,n=Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),s=Math.pow(10,n),o=Math.round(i.lng*s)/s,a=Math.round(i.lat*s)/s,c=e.getBearing(),h=e.getPitch();let u="";if(u+=t?`/${o}/${a}/${r}`:`${r}/${a}/${o}`,(c||h)&&(u+="/"+Math.round(10*c)/10),h&&(u+=`/${Math.round(h)}`),this._hashName){const t=this._hashName;let e=!1;const i=l.location.hash.slice(1).split("&").map((i=>{const r=i.split("=")[0];return r===t?(e=!0,`${r}=${u}`):i})).filter((t=>t));return e||i.push(`${t}=${u}`),`#${i.join("&")}`}return`#${u}`}_getCurrentHash(){const t=l.location.hash.replace("#","");if(this._hashName){let e;return t.split("&").map((t=>t.split("="))).forEach((t=>{t[0]===this._hashName&&(e=t)})),(e&&e[1]||"").split("/")}return t.split("/")}_onHashChange(){const t=this._map;if(!t)return!1;const e=this._getCurrentHash();if(e.length>=3&&!e.some((t=>isNaN(t)))){const i=t.dragRotate.isEnabled()&&t.touchZoomRotate.isEnabled()?+(e[3]||0):t.getBearing();return t.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:i,pitch:+(e[4]||0)}),!0}return!1}_updateHashUnthrottled(){const t=l.location.href.replace(/(#.+)?$/,this.getHashString());l.history.replaceState(l.history.state,null,t)}}const dy={linearity:.3,easing:y(0,0,.3,1)},fy=I({deceleration:2500,maxSpeed:1400},dy),my=I({deceleration:20,maxSpeed:1400},dy),_y=I({deceleration:1e3,maxSpeed:360},dy),gy=I({deceleration:1e3,maxSpeed:90},dy);class yy{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:J.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,e=J.now();for(;t.length>0&&e-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const e={zoom:0,bearing:0,pitch:0,pan:new o(0,0),pinchAround:void 0,around:void 0};for(const{settings:t}of this._inertiaBuffer)e.zoom+=t.zoomDelta||0,e.bearing+=t.bearingDelta||0,e.pitch+=t.pitchDelta||0,t.panDelta&&e.pan._add(t.panDelta),t.around&&(e.around=t.around),t.pinchAround&&(e.pinchAround=t.pinchAround);const i=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(e.pan.mag()){const n=vy(e.pan.mag(),i,I({},fy,t||{}));r.offset=e.pan.mult(n.amount/e.pan.mag()),r.center=this._map.transform.center,xy(r,n)}if(e.zoom){const t=vy(e.zoom,i,my);r.zoom=this._map.transform.zoom+t.amount,xy(r,t)}if(e.bearing){const t=vy(e.bearing,i,_y);r.bearing=this._map.transform.bearing+v(t.amount,-179,179),xy(r,t)}if(e.pitch){const t=vy(e.pitch,i,gy);r.pitch=this._map.transform.pitch+t.amount,xy(r,t)}if(r.zoom||r.bearing){const t=void 0===e.pinchAround?e.around:e.pinchAround;r.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),I(r,{noMoveStart:!0})}}function xy(t,e){(!t.duration||t.duration<e.duration)&&(t.duration=e.duration,t.easing=e.easing)}function vy(t,e,i){const{maxSpeed:r,linearity:n,deceleration:s}=i,o=v(t*n/(e/1e3),-r,r),a=Math.abs(o)/(s*n);return{easing:i.easing,duration:1e3*a,amount:o*(a/2)}}class by extends le{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i,r={}){const n=ct(e.getCanvasContainer(),i);super(t,I({point:n,lngLat:e.unproject(n),originalEvent:i},r)),this._defaultPrevented=!1,this.target=e}}class wy extends le{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i){const r="touchend"===t?i.changedTouches:i.touches,n=ht(e.getCanvasContainer(),r),s=n.map((t=>e.unproject(t))),a=n.reduce(((t,e,i,r)=>t.add(e.div(r.length))),new o(0,0));super(t,{points:n,point:a,lngLats:s,lngLat:e.unproject(a),originalEvent:i}),this._defaultPrevented=!1}}class Ty extends le{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i){super(t,{originalEvent:i}),this._defaultPrevented=!1}}class Ey{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){this._mousedownPos=void 0}wheel(t){return this._firePreventable(new Ty(t.type,this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new by(t.type,this._map,t))}mouseup(t){this._map.fire(new by(t.type,this._map,t))}preclick(t){const e=I({},t);e.type="preclick",this._map.fire(new by(e.type,this._map,e))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||(this.preclick(t),this._map.fire(new by(t.type,this._map,t)))}dblclick(t){return this._firePreventable(new by(t.type,this._map,t))}mouseover(t){this._map.fire(new by(t.type,this._map,t))}mouseout(t){this._map.fire(new by(t.type,this._map,t))}touchstart(t){return this._firePreventable(new wy(t.type,this._map,t))}touchmove(t){this._map.fire(new wy(t.type,this._map,t))}touchend(t){this._map.fire(new wy(t.type,this._map,t))}touchcancel(t){this._map.fire(new wy(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Iy{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(t){this._map.fire(new by(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new by("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._map.fire(new by(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Sy{constructor(t,e){this._map=t,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=e.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,e){this.isEnabled()&&t.shiftKey&&0===t.button&&(st(),this._startPos=this._lastPos=e,this._active=!0)}mousemoveWindow(t,e){if(!this._active)return;const i=e;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=Q("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",t));const n=Math.min(r.x,i.x),s=Math.max(r.x,i.x),o=Math.min(r.y,i.y),a=Math.max(r.y,i.y);this._map._requestDomTask((()=>{this._box&&(this._box.style.transform=`translate(${n}px,${o}px)`,this._box.style.width=s-n+"px",this._box.style.height=a-o+"px")}))}mouseupWindow(t,e){if(!this._active)return;if(0!==t.button)return;const i=this._startPos,r=e;if(this.reset(),lt(),i.x!==r.x||i.y!==r.y)return this._map.fire(new le("boxzoomend",{originalEvent:t})),{cameraAnimation:t=>t.fitScreenCoordinates(i,r,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),ot(),delete this._startPos,delete this._lastPos}_fireEvent(t,e){return this._map.fire(new le(t,{originalEvent:e}))}}function Ay(t,e){const i={};for(let r=0;r<t.length;r++)i[t[r].identifier]=e[r];return i}class zy{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(t,e,i){(this.centroid||i.length>this.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),i.length===this.numTouches&&(this.centroid=function(t){const e=new o(0,0);for(const i of t)e._add(i);return e.div(t.length)}(e),this.touches=Ay(i,e)))}touchmove(t,e,i){if(this.aborted||!this.centroid)return;const r=Ay(i,e);for(const t in this.touches){const e=this.touches[t],i=r[t];(!i||i.dist(e)>30)&&(this.aborted=!0)}}touchend(t,e,i){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}}class Cy{constructor(t){this.singleTap=new zy(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(t,e,i){this.singleTap.touchstart(t,e,i)}touchmove(t,e,i){this.singleTap.touchmove(t,e,i)}touchend(t,e,i){const r=this.singleTap.touchend(t,e,i);if(r){const e=t.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(e&&i||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class My{constructor(){this._zoomIn=new Cy({numTouches:1,numTaps:2}),this._zoomOut=new Cy({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,e,i){this._zoomIn.touchstart(t,e,i),this._zoomOut.touchstart(t,e,i)}touchmove(t,e,i){this._zoomIn.touchmove(t,e,i),this._zoomOut.touchmove(t,e,i)}touchend(t,e,i){const r=this._zoomIn.touchend(t,e,i),n=this._zoomOut.touchend(t,e,i);return r?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()+1,around:e.unproject(r)},{originalEvent:t})}):n?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()-1,around:e.unproject(n)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const ky={0:1,2:2};class Py{constructor(t){this.reset(),this._clickTolerance=t.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(t,e){return!1}_move(t,e){return{}}mousedown(t,e){if(this._lastPoint)return;const i=ut(t);this._correctButton(t,i)&&(this._lastPoint=e,this._eventButton=i)}mousemoveWindow(t,e){const i=this._lastPoint;if(i)if(t.preventDefault(),null!=this._eventButton&&function(t,e){const i=ky[e];return void 0===t.buttons||(t.buttons&i)!==i}(t,this._eventButton))this.reset();else if(this._moved||!(e.dist(i)<this._clickTolerance))return this._moved=!0,this._lastPoint=e,this._move(i,e)}mouseupWindow(t){this._lastPoint&&ut(t)===this._eventButton&&(this._moved&&lt(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Dy extends Py{mousedown(t,e){super.mousedown(t,e),this._lastPoint&&(this._active=!0)}_correctButton(t,e){return 0===e&&!t.ctrlKey}_move(t,e){return{around:e,panDelta:e.sub(t)}}}class By extends Py{_correctButton(t,e){return 0===e&&t.ctrlKey||2===e}_move(t,e){const i=.8*(e.x-t.x);if(i)return this._active=!0,{bearingDelta:i}}contextmenu(t){t.preventDefault()}}class Ly extends Py{_correctButton(t,e){return 0===e&&t.ctrlKey||2===e}_move(t,e){const i=-.5*(e.y-t.y);if(i)return this._active=!0,{pitchDelta:i}}contextmenu(t){t.preventDefault()}}class Ry{constructor(t,e){this._map=t,this._el=t.getCanvasContainer(),this._minTouches=1,this._clickTolerance=e.clickTolerance||1,this.reset(),P(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new o(0,0)}touchstart(t,e,i){return this._calculateTransform(t,e,i)}touchmove(t,e,i){if(this._active&&!(i.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(1===i.length)return void this._showTouchPanBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return t.preventDefault(),this._calculateTransform(t,e,i)}}touchend(t,e,i){this._calculateTransform(t,e,i),this._active&&i.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,e,i){i.length>0&&(this._active=!0);const r=Ay(i,e),n=new o(0,0),s=new o(0,0);let a=0;for(const t in r){const e=r[t],i=this._touches[t];i&&(n._add(e),s._add(e.sub(i)),a++,r[t]=e)}if(this._touches=r,a<this._minTouches||!s.mag())return;const l=s.div(a);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:n.div(a),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=Q("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(){"hidden"===this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show")}),500)}}class Fy{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(t){}_move(t,e,i){return{}}touchstart(t,e,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([e[0],e[1]]))}touchmove(t,e,i){const r=this._firstTwoTouches;if(!r)return;t.preventDefault();const[n,s]=r,o=Oy(i,e,n),a=Oy(i,e,s);if(!o||!a)return;const l=this._aroundCenter?null:o.add(a).div(2);return this._move([o,a],l,t)}touchend(t,e,i){if(!this._firstTwoTouches)return;const[r,n]=this._firstTwoTouches,s=Oy(i,e,r),o=Oy(i,e,n);s&&o||(this._active&&lt(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Oy(t,e,i){for(let r=0;r<t.length;r++)if(t[r].identifier===i)return e[r]}function Vy(t,e){return Math.log(t/e)/Math.LN2}class jy extends Fy{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,e){const i=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(Vy(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Vy(this._distance,i),pinchAround:e}}}function Uy(t,e){return 180*t.angleWith(e)/Math.PI}class Ny extends Fy{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,e){const i=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Uy(this._vector,i),pinchAround:e}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());const e=25/(Math.PI*this._minDiameter)*360,i=Uy(t,this._startVector);return Math.abs(i)<e}}function Zy(t){return Math.abs(t.y)>Math.abs(t.x)}class qy extends Fy{constructor(t){super(),this._map=t}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(t){this._lastPoints=t,Zy(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,e,i){const r=this._lastPoints;if(!r)return;const n=t[0].sub(r[0]),s=t[1].sub(r[1]);return this._map._cooperativeGestures&&i.touches.length<3||(this._valid=this.gestureBeginsVertically(n,s,i.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(n.y+s.y)/2*-.5})}gestureBeginsVertically(t,e,i){if(void 0!==this._valid)return this._valid;const r=t.mag()>=2,n=e.mag()>=2;if(!r&&!n)return;if(!r||!n)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const s=t.y>0==e.y>0;return Zy(t)&&Zy(e)&&s}}const Gy={panStep:100,bearingStep:15,pitchStep:10};class $y{constructor(){const t=Gy;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let e=0,i=0,r=0,n=0,s=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?i=-1:(t.preventDefault(),n=-1);break;case 39:t.shiftKey?i=1:(t.preventDefault(),n=1);break;case 38:t.shiftKey?r=1:(t.preventDefault(),s=-1);break;case 40:t.shiftKey?r=-1:(t.preventDefault(),s=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:o=>{const a=o.getZoom();o.easeTo({duration:300,easeId:"keyboardHandler",easing:Wy,zoom:e?Math.round(a)+e*(t.shiftKey?2:1):a,bearing:o.getBearing()+i*this._bearingStep,pitch:o.getPitch()+r*this._pitchStep,offset:[-n*this._panStep,-s*this._panStep],center:o.getCenter()},{originalEvent:t})}}}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 Wy(t){return t*(2-t)}const Xy=4.000244140625;class Hy{constructor(t,e){this._map=t,this._el=t.getCanvasContainer(),this._handler=e,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,P(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert","_isFullscreen"],this)}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&"center"===t.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()||this._isFullscreen()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let e=t.deltaMode===l.WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const i=J.now(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==e&&e%Xy==0?this._type="wheel":0!==e&&Math.abs(e)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=e,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(r*e)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,e+=this._lastValue)),t.shiftKey&&e&&(e/=4),this._type&&(this._lastWheelEvent=t,this._delta-=e,this._active||this._start(t)),t.preventDefault()}_onTimeout(t){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)}_start(t){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 e=ct(this._el,t);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:e,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 t=this._map.transform,e=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>Xy?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=e(),s=Math.pow(2,n),o="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):s;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(o*r))),"wheel"===this._type&&(this._startZoom=e(),this._easing=this._smoothOutEasing(200)),this._delta=0}const i="number"==typeof this._targetZoom?this._targetZoom:e(),r=this._startZoom,n=this._easing;let s,o=!1;if("wheel"===this._type&&r&&n){const t=Math.min((J.now()-this._lastWheelEventTime)/200,1);s=Ai(r,i,n(t)),t<1?this._frameId||(this._frameId=!0):o=!0}else s=i,o=!0;return this._active=!0,o&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!o,zoomDelta:s-e(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let e=x;if(this._prevEase){const t=this._prevEase,i=(J.now()-t.start)/t.duration,r=t.easing(i+.01)-t.easing(i),n=.27/Math.sqrt(r*r+1e-4)*.01;e=y(n,Math.sqrt(.0729-n*n),.25,1)}return this._prevEase={start:J.now(),duration:t,easing:e},e}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=Q("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(l.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_isFullscreen(){return!!l.document.fullscreenElement}_showBlockerAlert(){"hidden"===this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show")}),200)}}class Ky{constructor(t,e){this._clickZoom=t,this._tapZoom=e}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 Yy{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(t,e){return t.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(t.shiftKey?-1:1),around:i.unproject(e)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Jy{constructor(){this._tap=new Cy({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(t,e,i){this._swipePoint||(this._tapTime&&t.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=e[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(t,e,i))}touchmove(t,e,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=e[0],n=r.y-this._swipePoint.y;return this._swipePoint=r,t.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(t,e,i)}touchend(t,e,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(t,e,i)&&(this._tapTime=t.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Qy{constructor(t,e,i){this._el=t,this._mousePan=e,this._touchPan=i}enable(t){this._inertiaOptions=t||{},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 tx{constructor(t,e,i){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=e,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 ex{constructor(t,e,i,r){this._el=t,this._touchZoom=e,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),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 ix=t=>t.zoom||t.drag||t.pitch||t.rotate;class rx extends le{}class nx{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,e){const i=Dl([],e,t);this.radius=gl(i[2]<0?Ll([],i,this.constants):[i[0],i[1],0])}projectRay(t){Ll(t,t,this.constants),Sl(t,t),Bl(t,t,this.constants);const e=El([],t,this.radius);if(e[2]>0){const t=El([],[0,0,1],Al(e,[0,0,1])),i=El([],Sl([],[e[0],e[1],0]),this.radius),r=xl([],e,El([],Dl([],xl([],i,t),e),2));e[0]=r[0],e[1]=r[1]}return e}}function sx(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta}class ox{constructor(t,e){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new yy(t),this._bearingSnap=e.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new nx,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(e),P(["handleEvent","handleWindowEvent"],this);const i=this._el;this._listeners=[[i,"touchstart",{passive:!0}],[i,"touchmove",{passive:!1}],[i,"touchend",void 0],[i,"touchcancel",void 0],[i,"mousedown",void 0],[i,"mousemove",void 0],[i,"mouseup",void 0],[l.document,"mousemove",{capture:!0}],[l.document,"mouseup",void 0],[i,"mouseover",void 0],[i,"mouseout",void 0],[i,"dblclick",void 0],[i,"click",void 0],[i,"keydown",{capture:!1}],[i,"keyup",void 0],[i,"wheel",{passive:!1}],[i,"contextmenu",void 0],[l,"blur",void 0]];for(const[t,e,i]of this._listeners)t.addEventListener(e,t===l.document?this.handleWindowEvent:this.handleEvent,i)}destroy(){for(const[t,e,i]of this._listeners)t.removeEventListener(e,t===l.document?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(t){const e=this._map,i=e.getCanvasContainer();this._add("mapEvent",new Ey(e,t));const r=e.boxZoom=new Sy(e,t);this._add("boxZoom",r);const n=new My,s=new Yy;e.doubleClickZoom=new Ky(s,n),this._add("tapZoom",n),this._add("clickZoom",s);const o=new Jy;this._add("tapDragZoom",o);const a=e.touchPitch=new qy(e);this._add("touchPitch",a);const l=new By(t),c=new Ly(t);e.dragRotate=new tx(t,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const h=new Dy(t),u=new Ry(e,t);e.dragPan=new Qy(i,h,u),this._add("mousePan",h),this._add("touchPan",u,["touchZoom","touchRotate"]);const p=new Ny,d=new jy;e.touchZoomRotate=new ex(i,d,p,o),this._add("touchRotate",p,["touchPan","touchZoom"]),this._add("touchZoom",d,["touchPan","touchRotate"]),this._add("blockableMapEvent",new Iy(e));const f=e.scrollZoom=new Hy(e,this);this._add("scrollZoom",f,["mousePan"]);const m=e.keyboard=new $y;this._add("keyboard",m);for(const i of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])t.interactive&&t[i]&&e[i].enable(t[i])}_add(t,e,i){this._handlers.push({handlerName:t,handler:e,allowed:i}),this._handlersById[t]=e}stop(t){if(!this._updatingCamera){for(const{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(ix(this._eventsInProgress))||this.isZooming()}_blockedByActive(t,e,i){for(const r in t)if(r!==i&&(!e||e.indexOf(r)<0))return!0;return!1}handleWindowEvent(t){this.handleEvent(t,`${t.type}Window`)}_getMapTouches(t){const e=[];for(const i of t)this._el.contains(i.target)&&e.push(i);return e}handleEvent(t,e){this._updatingCamera=!0;const i="renderFrame"===t.type,r=i?void 0:t,n={needsRenderFrame:!1},s={},o={},a=t.touches?this._getMapTouches(t.touches):void 0,l=a?ht(this._el,a):i?void 0:ct(this._el,t);for(const{handlerName:i,handler:c,allowed:h}of this._handlers){if(!c.isEnabled())continue;let u;this._blockedByActive(o,h,i)?c.reset():c[e||t.type]&&(u=c[e||t.type](t,l,a),this.mergeHandlerResult(n,s,u,i,r),u&&u.needsRenderFrame&&this._triggerRenderFrame()),(u||c.isActive())&&(o[i]=c)}const c={};for(const t in this._previousActiveHandlers)o[t]||(c[t]=r);this._previousActiveHandlers=o,(Object.keys(c).length||sx(n))&&(this._changes.push([n,s,c]),this._triggerRenderFrame()),(Object.keys(o).length||sx(n))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:h}=n;h&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],h(this._map))}mergeHandlerResult(t,e,i,r,n){if(!i)return;I(t,i);const s={handlerName:r,originalEvent:i.originalEvent||n};void 0!==i.zoomDelta&&(e.zoom=s),void 0!==i.panDelta&&(e.drag=s),void 0!==i.pitchDelta&&(e.pitch=s),void 0!==i.bearingDelta&&(e.rotate=s)}_applyChanges(){const t={},e={},i={};for(const[r,n,s]of this._changes)r.panDelta&&(t.panDelta=(t.panDelta||new o(0,0))._add(r.panDelta)),r.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+r.pitchDelta),void 0!==r.around&&(t.around=r.around),void 0!==r.aroundCoord&&(t.aroundCoord=r.aroundCoord),void 0!==r.pinchAround&&(t.pinchAround=r.pinchAround),r.noInertia&&(t.noInertia=r.noInertia),I(e,n),I(i,s);this._updateMapTransform(t,e,i),this._changes=[]}_updateMapTransform(t,e,i){const r=this._map,n=r.transform,s=t=>[t.x,t.y,t.z];if((t=>{const e=this._eventsInProgress.drag;return e&&!this._handlersById[e.handlerName].isActive()})()&&!sx(t)){const t=n.zoom;n.cameraElevationReference="sea",n.recenterOnTerrain(),n.cameraElevationReference="ground",t!==n.zoom&&this._map._update(!0)}if(!sx(t))return this._fireEvents(e,i,!0);let{panDelta:o,zoomDelta:a,bearingDelta:l,pitchDelta:c,around:h,aroundCoord:u,pinchAround:p}=t;void 0!==p&&(h=p),(t=>e.drag&&!this._eventsInProgress.drag)()&&h&&(this._dragOrigin=s(n.pointCoordinate3D(h)),this._trackingEllipsoid.setup(n._camera.position,this._dragOrigin)),n.cameraElevationReference="sea",r._stop(!0),h=h||r.transform.centerPoint,l&&(n.bearing+=l),c&&(n.pitch+=c),n._updateCameraState();const d=[0,0,0];if(o){const t=n.pointCoordinate(h);if("globe"===n.projection.name){const e=ya(t.y),i=n.center.lat,r=Math.min(_a(1,e)/_a(1,i),2);o=o.rotate(-n.angle),d[0]=-o.x/n.worldSize*r,d[1]=-o.y/n.worldSize*r}else{const e=n.pointCoordinate(h.sub(o));t&&e&&(d[0]=e.x-t.x,d[1]=e.y-t.y)}}const f=n.zoom,m=[0,0,0];if(a){const t=s(u||n.pointCoordinate3D(h)),e={dir:Sl([],Dl([],t,n._camera.position))};if(e.dir[2]<0){const i=n.zoomDeltaToMovement(t,a);El(m,e.dir,i)}}const _=xl(d,d,m);n._translateCameraConstrained(_),a&&Math.abs(n.zoom-f)>1e-4&&n.recenterOnTerrain(),n.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(e,i,!0)}_fireEvents(t,e,i){const r=ix(this._eventsInProgress),n=ix(t),s={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(s[`${e}start`]=i),this._eventsInProgress[e]=t[e]}!r&&n&&this._fireEvent("movestart",n.originalEvent);for(const t in s)this._fireEvent(t,s[t]);n&&this._fireEvent("move",n.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i)}const o={};let a;for(const t in this._eventsInProgress){const{handlerName:i,originalEvent:r}=this._eventsInProgress[t];this._handlersById[i].isActive()||(delete this._eventsInProgress[t],a=e[i]||r,o[`${t}end`]=a)}for(const t in o)this._fireEvent(t,o[t]);const l=ix(this._eventsInProgress);if(i&&(r||n)&&!l){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),e=t=>0!==t&&-this._bearingSnap<t&&t<this._bearingSnap;t?(e(t.bearing||this._map.getBearing())&&(t.bearing=0),this._map.easeTo(t,{originalEvent:a})):(this._map.fire(new le("moveend",{originalEvent:a})),e(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(t,e){this._map.fire(new le(t,e?{originalEvent:e}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((t=>{this._frameId=void 0,this.handleEvent(new rx("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const ax="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class lx extends he{constructor(t,e){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=e.bearingSnap,P(["_renderFrameCallback"],this)}getCenter(){return new ua(this.transform.center.lng,this.transform.center.lat)}setCenter(t,e){return this.jumpTo({center:t},e)}panBy(t,e,i){return t=o.convert(t).mult(-1),this.panTo(this.transform.center,I({offset:t},e),i)}panTo(t,e,i){return this.easeTo(I({center:t},e),i)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(t,e,i){return this.easeTo(I({zoom:t},e),i)}zoomIn(t,e){return this.zoomTo(this.getZoom()+1,t,e),this}zoomOut(t,e){return this.zoomTo(this.getZoom()-1,t,e),this}getBearing(){return this.transform.bearing}setBearing(t,e){return this.jumpTo({bearing:t},e),this}getPadding(){return this.transform.padding}setPadding(t,e){return this.jumpTo({padding:t},e),this}rotateTo(t,e,i){return this.easeTo(I({bearing:t},e),i)}resetNorth(t,e){return this.rotateTo(0,I({duration:1e3},t),e),this}resetNorthPitch(t,e){return this.easeTo(I({bearing:0,pitch:0,duration:1e3},t),e),this}snapToNorth(t,e){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,e):this}getPitch(){return this.transform.pitch}setPitch(t,e){return this.jumpTo({pitch:t},e),this}cameraForBounds(t,e){t=ca.convert(t);const i=e&&e.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),i,e)}_extendCameraOptions(t){const e={top:0,bottom:0,right:0,left:0};if("number"==typeof(t=I({padding:e,offset:[0,0],maxZoom:this.transform.maxZoom},t)).padding){const e=t.padding;t.padding={top:e,bottom:e,right:e,left:e}}return t.padding=I(e,t.padding),t}_cameraForBoxAndBearing(t,e,i,r){const n=this._extendCameraOptions(r),s=this.transform,a=s.padding,l=s.project(ua.convert(t)),c=s.project(ua.convert(e)),h=new o(l.x,c.y),u=new o(c.x,l.y),d=-p(i),f=l.rotate(d),m=c.rotate(d),_=h.rotate(d),g=u.rotate(d),y=new o(Math.max(f.x,m.x,_.x,g.x),Math.max(f.y,m.y,_.y,g.y)),x=new o(Math.min(f.x,m.x,_.x,g.x),Math.min(f.y,m.y,_.y,g.y)),v=y.sub(x),b=(s.width-((a.left||0)+(a.right||0)+n.padding.left+n.padding.right))/v.x,w=(s.height-((a.top||0)+(a.bottom||0)+n.padding.top+n.padding.bottom))/v.y;if(w<0||b<0)return void O("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const T=Math.min(s.scaleZoom(s.scale*Math.min(b,w)),n.maxZoom),E="number"==typeof n.offset.x&&"number"==typeof n.offset.y?new o(n.offset.x,n.offset.y):o.convert(n.offset),I=new o((n.padding.left-n.padding.right)/2,(n.padding.top-n.padding.bottom)/2).rotate(i*Math.PI/180),S=E.add(I).mult(s.scale/s.zoomScale(T));return{center:s.unproject(l.add(c).div(2).sub(S)),zoom:T,bearing:i}}_cameraForBox(t,e,i,r,n){const s=this._extendCameraOptions(n);i=i||0,r=r||0,t=ua.convert(t),e=ua.convert(e);const o=this.transform.clone();o.padding=s.padding;const a=this.getFreeCameraOptions(),l=new ua(.5*(t.lng+e.lng),.5*(t.lat+e.lat)),c=.5*(i+r);if(o._camera.position[2]<_a(c,l.lat))return void O("Map cannot fit within canvas with the given bounds, padding, and/or offset.");a.lookAtPoint(l),o.setFreeCameraOptions(a);const h=ba.fromLngLat(t),u=ba.fromLngLat(e),p=o.pointRayIntersection(o.centerPoint,c),d=[(f=o.rayIntersectionCoordinate(p)).x,f.y,f.z];var f;const m=o.screenPointToMercatorRay(o.centerPoint),_="globe"!==o.projection.name;let g,y=0;do{const t=Math.floor(o.zoom),e=1<<t,n=Math.min(e*h.x,e*u.x),s=Math.min(e*h.y,e*u.y),a=Math.max(e*h.x,e*u.x),l=Math.max(e*h.y,e*u.y),c=new ql([n,s,i],[a,l,r]),p=Zl.fromInvProjectionMatrix(o.invProjMatrix,o.worldSize,t,_);if(2!==c.intersects(p)){g&&(o._camera.position=Il([],o._camera.position,m.dir,-g),o._updateStateFromCamera());break}g=.5*gl(Dl([],o._camera.position,d)),o._camera.position=Il([],o._camera.position,m.dir,g);try{o._updateStateFromCamera()}catch(t){return void O("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}}while(++y<10);return{center:o.center,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch}}fitBounds(t,e,i){return this._fitInternal(this.cameraForBounds(t,e),e,i)}_raycastElevationBox(t,e){const i=this.transform.elevation;if(!i)return;const r=new o(t.x,e.y),n=new o(e.x,t.y),s=i.pointCoordinate(t);if(!s)return;const a=i.pointCoordinate(e);if(!a)return;const l=i.pointCoordinate(r);if(!l)return;const c=i.pointCoordinate(n);if(!c)return;const h=new ba(s[0],s[1]).toLngLat(),u=new ba(a[0],a[1]).toLngLat(),p=new ba(l[0],l[1]).toLngLat(),d=new ba(c[0],c[1]).toLngLat(),f=Math.min(h.lng,Math.min(u.lng,Math.min(p.lng,d.lng))),m=Math.min(h.lat,Math.min(u.lat,Math.min(p.lat,d.lat))),_=Math.max(h.lng,Math.max(u.lng,Math.max(p.lng,d.lng))),g=Math.max(h.lat,Math.max(u.lat,Math.max(p.lat,d.lat))),y=Math.min(s[3],Math.min(a[3],Math.min(l[3],c[3]))),x=Math.max(s[3],Math.max(a[3],Math.max(l[3],c[3])));return{minLngLat:new ua(f,m),maxLngLat:new ua(_,g),minAltitude:y,maxAltitude:x}}fitScreenCoordinates(t,e,i,r,n){let s,a,l,c;const h=o.convert(t),u=o.convert(e),p=this._raycastElevationBox(h,u);if(p)s=p.minLngLat,a=p.maxLngLat,l=p.minAltitude,c=p.maxAltitude;else{if(this.transform.anyCornerOffEdge(h,u))return this;s=this.transform.pointLocation(h),a=this.transform.pointLocation(u)}return this._fitInternal(0===this.transform.pitch?this._cameraForBoxAndBearing(this.transform.pointLocation(o.convert(t)),this.transform.pointLocation(o.convert(e)),i,r):this._cameraForBox(s,a,l,c,r),r,n)}_fitInternal(t,e,i){return t?(delete(e=I(t,e)).padding,e.linear?this.easeTo(e,i):this.flyTo(e,i)):this}jumpTo(t,e){this.stop();const i=t.preloadOnly?this.transform.clone():this.transform;let r=!1,n=!1,s=!1;return"zoom"in t&&i.zoom!==+t.zoom&&(r=!0,i.zoom=+t.zoom),void 0!==t.center&&(i.center=ua.convert(t.center)),"bearing"in t&&i.bearing!==+t.bearing&&(n=!0,i.bearing=+t.bearing),"pitch"in t&&i.pitch!==+t.pitch&&(s=!0,i.pitch=+t.pitch),null==t.padding||i.isPaddingEqual(t.padding)||(i.padding=t.padding),t.preloadOnly?(this._preloadTiles(i),this):(this.fire(new le("movestart",e)).fire(new le("move",e)),r&&this.fire(new le("zoomstart",e)).fire(new le("zoom",e)).fire(new le("zoomend",e)),n&&this.fire(new le("rotatestart",e)).fire(new le("rotate",e)).fire(new le("rotateend",e)),s&&this.fire(new le("pitchstart",e)).fire(new le("pitch",e)).fire(new le("pitchend",e)),this.fire(new le("moveend",e)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||O(ax),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,e){const i=this.transform;if(!i.projection.supportsFreeCamera)return O(ax),this;this.stop();const r=i.zoom,n=i.pitch,s=i.bearing;i.setFreeCameraOptions(t);const o=r!==i.zoom,a=n!==i.pitch,l=s!==i.bearing;return this.fire(new le("movestart",e)).fire(new le("move",e)),o&&this.fire(new le("zoomstart",e)).fire(new le("zoom",e)).fire(new le("zoomend",e)),l&&this.fire(new le("rotatestart",e)).fire(new le("rotate",e)).fire(new le("rotateend",e)),a&&this.fire(new le("pitchstart",e)).fire(new le("pitch",e)).fire(new le("pitchend",e)),this.fire(new le("moveend",e)),this}easeTo(t,e){this._stop(!1,t.easeId),(!1===(t=I({offset:[0,0],duration:500,easing:x},t)).animate||!t.essential&&J.prefersReducedMotion)&&(t.duration=0);const i=this.transform,r=this.getZoom(),n=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?+t.zoom:r,c="bearing"in t?this._normalizeBearing(t.bearing,n):n,h="pitch"in t?+t.pitch:s,u="padding"in t?t.padding:i.padding,p=o.convert(t.offset);let d,f,m;if("globe"===i.projection.name){const e=ba.fromLngLat(i.center),r=p.rotate(-i.angle);e.x+=r.x/i.worldSize,e.y+=r.y/i.worldSize;const n=e.toLngLat(),s=ua.convert(t.center||n);this._normalizeCenter(s),d=i.centerPoint.add(r),f=new o(e.x,e.y).mult(i.worldSize),m=new o(fa(s.lng),ma(s.lat)).mult(i.worldSize).sub(f)}else{d=i.centerPoint.add(p);const e=i.pointLocation(d),r=ua.convert(t.center||e);this._normalizeCenter(r),f=i.project(e),m=i.project(r).sub(f)}const _=i.zoomScale(l-r);let g,y;t.around&&(g=ua.convert(t.around),y=i.locationPoint(g));const v=this._zooming||l!==r,b=this._rotating||n!==c,w=this._pitching||h!==s,T=!i.isPaddingEqual(u),E=i=>o=>{if(v&&(i.zoom=Ai(r,l,o)),b&&(i.bearing=Ai(n,c,o)),w&&(i.pitch=Ai(s,h,o)),T&&(i.interpolatePadding(a,u,o),d=i.centerPoint.add(p)),g)i.setLocationAtPoint(g,y);else{const t=i.zoomScale(i.zoom-r),e=l>r?Math.min(2,_):Math.max(.5,_),n=Math.pow(e,1-o),s=i.unproject(f.add(m.mult(o*n)).mult(t));i.setLocationAtPoint(i.renderWorldCopies?s.wrap():s,d)}return t.preloadOnly||this._fireMoveEvents(e),i};if(t.preloadOnly){const e=this._emulate(E,t.duration,i);return this._preloadTiles(e),this}const S={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=v,this._rotating=b,this._pitching=w,this._padding=T,this._easeId=t.easeId,this._prepareEase(e,t.noMoveStart,S),this._ease(E(i),(t=>{i.recenterOnTerrain(),this._afterEase(e,t)}),t),this}_prepareEase(t,e,i={}){this._moving=!0,this.transform.cameraElevationReference="sea",e||i.moving||this.fire(new le("movestart",t)),this._zooming&&!i.zooming&&this.fire(new le("zoomstart",t)),this._rotating&&!i.rotating&&this.fire(new le("rotatestart",t)),this._pitching&&!i.pitching&&this.fire(new le("pitchstart",t))}_fireMoveEvents(t){this.fire(new le("move",t)),this._zooming&&this.fire(new le("zoom",t)),this._rotating&&this.fire(new le("rotate",t)),this._pitching&&this.fire(new le("pitch",t))}_afterEase(t,e){if(this._easeId&&e&&this._easeId===e)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 le("zoomend",t)),r&&this.fire(new le("rotateend",t)),n&&this.fire(new le("pitchend",t)),this.fire(new le("moveend",t))}flyTo(t,e){if(!t.essential&&J.prefersReducedMotion){const i=S(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(i,e)}this.stop(),t=I({offset:[0,0],speed:1.2,curve:1.42,easing:x},t);const i=this.transform,r=this.getZoom(),n=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?v(+t.zoom,i.minZoom,i.maxZoom):r,c="bearing"in t?this._normalizeBearing(t.bearing,n):n,h="pitch"in t?+t.pitch:s,u="padding"in t?t.padding:i.padding,p=i.zoomScale(l-r),d=o.convert(t.offset);let f=i.centerPoint.add(d);const m=i.pointLocation(f),_=ua.convert(t.center||m);this._normalizeCenter(_);const g=i.project(m),y=i.project(_).sub(g);let b=t.curve;const w=Math.max(i.width,i.height),T=w/p,E=y.mag();if("minZoom"in t){const e=v(Math.min(t.minZoom,r,l),i.minZoom,i.maxZoom),n=w/i.zoomScale(e-r);b=Math.sqrt(n/E*2)}const A=b*b;function z(t){const e=(T*T-w*w+(t?-1:1)*A*A*E*E)/(2*(t?T:w)*A*E);return Math.log(Math.sqrt(e*e+1)-e)}function C(t){return(Math.exp(t)-Math.exp(-t))/2}function M(t){return(Math.exp(t)+Math.exp(-t))/2}const k=z(0);let P=function(t){return M(k)/M(k+b*t)},D=function(t){return w*((M(k)*(C(e=k+b*t)/M(e))-C(k))/A)/E;var e},B=(z(1)-k)/b;if(Math.abs(E)<1e-6||!isFinite(B)){if(Math.abs(w-T)<1e-6)return this.easeTo(t,e);const i=T<w?-1:1;B=Math.abs(Math.log(T/w))/b,D=function(){return 0},P=function(t){return Math.exp(i*b*t)}}t.duration="duration"in t?+t.duration:1e3*B/("screenSpeed"in t?+t.screenSpeed/b:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0);const L=n!==c,R=h!==s,F=!i.isPaddingEqual(u),O=i=>o=>{const p=o*B,m=1/P(p);i.zoom=1===o?l:r+i.scaleZoom(m),L&&(i.bearing=Ai(n,c,o)),R&&(i.pitch=Ai(s,h,o)),F&&(i.interpolatePadding(a,u,o),f=i.centerPoint.add(d));const x=1===o?_:i.unproject(g.add(y.mult(D(p))).mult(m));return i.setLocationAtPoint(i.renderWorldCopies?x.wrap():x,f),i._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(e),i};if(t.preloadOnly){const e=this._emulate(O,t.duration,i);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=L,this._pitching=R,this._padding=F,this._prepareEase(e,!1),this._ease(O(i),(()=>this._afterEase(e)),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,e){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const t=this._onEaseEnd;this._onEaseEnd=void 0,t.call(this,e)}if(!t){const t=this.handlers;t&&t.stop(!1)}return this}_ease(t,e,i){!1===i.animate||0===i.duration?(t(1),e()):(this._easeStart=J.now(),this._easeOptions=i,this._onEaseFrame=t,this._onEaseEnd=e,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((J.now()-this._easeStart)/this._easeOptions.duration,1),e=this._onEaseFrame;e&&e(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,e){t=w(t,-180,180);const i=Math.abs(t-e);return Math.abs(t-360-e)<i&&(t-=360),Math.abs(t+360-e)<i&&(t+=360),t}_normalizeCenter(t){const e=this.transform;if(!e.renderWorldCopies||e.maxBounds)return;const i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0}_emulate(t,e,i){const r=Math.ceil(15*e/1e3),n=[],s=t(i.clone());for(let t=0;t<=r;t++){const e=s(t/r);n.push(e.clone())}return n}}class cx{constructor(t={}){this.options=t,P(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(t){const e=this.options&&this.options.compact;return this._map=t,this._container=Q("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=Q("button","mapboxgl-ctrl-attrib-button",this._container),Q("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=Q("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),e&&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===e&&(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(t,e){const i=this._map._getUIString(`AttributionControl.${e}`);t.setAttribute("aria-label",i),t.removeAttribute("title"),t.firstElementChild&&t.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 t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));const e=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||dt.ACCESS_TOKEN}];if(t){const i=e.reduce(((t,i,r)=>(i.value&&(t+=`${i.key}=${i.value}${r<e.length-1?"&":""}`),t)),"?");t.href=`${dt.FEEDBACK_URL}/${i}${this._map._hash?this._map._hash.getHashString(!0):""}`,t.rel="noopener nofollow",this._setElementTitle(t,"MapFeedback")}}_updateData(t){!t||"metadata"!==t.sourceDataType&&"visibility"!==t.sourceDataType&&"style"!==t.dataType||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let t=[];if(this._map.style.stylesheet){const t=this._map.style.stylesheet;this.styleOwner=t.owner,this.styleId=t.id}const e=this._map.style._sourceCaches;for(const i in e){const r=e[i];if(r.used){const e=r.getSource();e.attribution&&t.indexOf(e.attribution)<0&&t.push(e.attribution)}}t.sort(((t,e)=>t.length-e.length)),t=t.filter(((e,i)=>{for(let r=i+1;r<t.length;r++)if(t[r].indexOf(e)>=0)return!1;return!0})),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=[...this.options.customAttribution,...t]:t.unshift(this.options.customAttribution));const i=t.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,t.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 hx{constructor(){P(["_updateLogo","_updateCompact"],this)}onAdd(t){this._map=t,this._container=Q("div","mapboxgl-ctrl");const e=Q("a","mapboxgl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://www.mapbox.com/",e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),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(t){t&&"metadata"!==t.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const t=this._map.style._sourceCaches;if(0===Object.entries(t).length)return!0;for(const e in t){const i=t[e].getSource();if(i.hasOwnProperty("mapbox_logo")&&!i.mapbox_logo)return!1}return!0}_updateCompact(){const t=this._container.children;if(t.length){const e=t[0];this._map.getCanvasContainer().offsetWidth<250?e.classList.add("mapboxgl-compact"):e.classList.remove("mapboxgl-compact")}}}class ux{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e}remove(t){const e=this._currentlyRunning,i=e?this._queue.concat(e):this._queue;for(const e of i)if(e.id===t)return void(e.cancelled=!0)}run(t=0){const e=this._currentlyRunning=this._queue;this._queue=[];for(const i of e)if(!i.cancelled&&(i.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function px(t,e,i){if(t=new ua(t.lng,t.lat),e){const r=new ua(t.lng-360,t.lat),n=new ua(t.lng+360,t.lat),s=360*Math.ceil(Math.abs(t.lng-i.center.lng)/360),o=i.locationPoint(t).distSqr(e),a=e.x<0||e.y<0||e.x>i.width||e.y>i.height;i.locationPoint(r).distSqr(e)<o&&(a||Math.abs(r.lng-i.center.lng)<s)?t=r:i.locationPoint(n).distSqr(e)<o&&(a||Math.abs(n.lng-i.center.lng)<s)&&(t=n)}for(;Math.abs(t.lng-i.center.lng)>180;){const e=i.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=i.width&&e.y<=i.height)break;t.lng>i.center.lng?t.lng-=360:t.lng+=360}return t}const dx={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 fx extends he{constructor(t,e){if(super(),(t instanceof l.HTMLElement||e)&&(t=I({element:t},e)),P(["_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&&"auto"!==t.pitchAlignment?t.pitchAlignment:this._rotationAlignment,this._updateMoving=()=>this._update(!0),t&&t.element)this._element=t.element,this._offset=o.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=Q("div");const e=41,i=27,r=tt("svg",{display:"block",height:e*this._scale+"px",width:i*this._scale+"px",viewBox:`0 0 ${i} ${e}`},this._element),n=tt("radialGradient",{id:"shadowGradient"},tt("defs",{},r));tt("stop",{offset:"10%","stop-opacity":.4},n),tt("stop",{offset:"100%","stop-opacity":.05},n),tt("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},r),tt("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"},r),tt("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"},r),tt("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},r),this._offset=o.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",(t=>{t.preventDefault()})),this._element.addEventListener("mousedown",(t=>{t.preventDefault()}));const i=this._element.classList;for(const t in dx)i.remove(`mapboxgl-marker-anchor-${t}`);i.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(t){return t===this._map||(this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._updateMoving),t.on("moveend",this._update),t.on("remove",this._clearFadeTimer),t._addMarker(this),this.setDraggable(this._draggable),this._update(),t.on("click",this._onMapClick)),this}remove(){const t=this._map;return t&&(t.off("click",this._onMapClick),t.off("move",this._updateMoving),t.off("moveend",this._update),t.off("mousedown",this._addDragHandler),t.off("touchstart",this._addDragHandler),t.off("mouseup",this._onUp),t.off("touchend",this._onUp),t.off("mousemove",this._onMove),t.off("touchmove",this._onMove),t.off("remove",this._clearFadeTimer),t._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=ua.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(t){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")),t){if(!("offset"in t.options)){const e=38.1,i=13.5,r=Math.sqrt(Math.pow(i,2)/2);t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-e],"bottom-left":[r,-1*(e-i+r)],"bottom-right":[-r,-1*(e-i+r)],left:[i,-1*(e-i)],right:[-i,-1*(e-i)]}:this._offset}this._popup=t,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(t){const e=t.code,i=t.charCode||t.keyCode;"Space"!==e&&"Enter"!==e&&32!==i&&13!==i||this.togglePopup()}_onMapClick(t){const e=t.originalEvent.target,i=this._element;this._popup&&(e===i||i.contains(e))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const t=this._popup;return t?(t.isOpen()?(t.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(t.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_evaluateOpacity(){const t=this._map;if(!t)return;const e=this._pos;if(!e||e.x<0||e.x>t.transform.width||e.y<0||e.y>t.transform.height)return void this._clearFadeTimer();const i=t.unproject(e);let r=!1;if(t.transform._terrainEnabled()&&t.getTerrain()){const e=t.getFreeCameraOptions();if(e.position){const t=e.position.toLngLat();r=t.distanceTo(i)<.9*t.distanceTo(this._lngLat)}}const n=(1-t._queryFogOpacity(i))*(r?.2:1);this._element.style.opacity=`${n}`,this._popup&&this._popup._setOpacity(`${n}`),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const t=this._pos;if(!t)return;const e=this._offset.mult(this._scale),i=this._calculatePitch(),r=this._calculateRotation();this._element.style.transform=`\n translate(${t.x}px, ${t.y}px) ${dx[this._anchor]}\n rotateX(${i}deg) rotateZ(${r}deg)\n translate(${e.x}px, ${e.y}px)\n `}_calculatePitch(){return"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?0:this._map&&"map"===this._pitchAlignment?this._map.getPitch():0}_calculateRotation(){return"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?this._rotation:this._map&&"map"===this._rotationAlignment?this._rotation-this._map.getBearing():0}_update(t){l.cancelAnimationFrame(this._updateFrameId);const e=this._map;e&&(e.transform.renderWorldCopies&&(this._lngLat=px(this._lngLat,this._pos,e.transform)),this._pos=e.project(this._lngLat),!0===t?this._updateFrameId=l.requestAnimationFrame((()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())})):this._pos=this._pos.round(),e._requestDomTask((()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),!e.getTerrain()&&!e.getFog()||this._fadeTimer||(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))})))}getOffset(){return this._offset}setOffset(t){return this._offset=o.convert(t),this._update(),this}_onMove(t){const e=this._map;if(e){if(!this._isDragging){const i=this._clickTolerance||e._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=i}this._isDragging&&(this._pos=t.point.sub(this._positionDelta),this._lngLat=e.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new le("dragstart"))),this.fire(new le("drag")))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const t=this._map;t&&(t.off("mousemove",this._onMove),t.off("touchmove",this._onMove)),"active"===this._state&&this.fire(new le("dragend")),this._state="inactive"}_addDragHandler(t){const e=this._map;e&&this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos),this._pointerdownPos=t.point,this._state="pending",e.on("mousemove",this._onMove),e.on("touchmove",this._onMove),e.once("mouseup",this._onUp),e.once("touchend",this._onUp))}setDraggable(t){this._draggable=!!t;const e=this._map;return e&&(t?(e.on("mousedown",this._addDragHandler),e.on("touchstart",this._addDragHandler)):(e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&"auto"!==t?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}class mx{constructor(t){this.jumpTo(t)}getValue(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;const e=m((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-e)+this._end*e}isEasing(t){return t>=this._startTime&&t<=this._endTime}jumpTo(t){this._startTime=-1/0,this._endTime=-1/0,this._start=t,this._end=t}easeTo(t,e,i){this._start=this.getValue(e),this._end=t,this._startTime=e,this._endTime=e+i}}const _x={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},gx={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 yx(t){t.parentNode&&t.parentNode.removeChild(t)}const xx={showCompass:!0,showZoom:!0,visualizePitch:!1};class vx{constructor(t,e,i=!1){this._clickTolerance=10,this.element=e,this.mouseRotate=new By({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,i&&(this.mousePitch=new Ly({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),P(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),e.addEventListener("mousedown",this.mousedown),e.addEventListener("touchstart",this.touchstart,{passive:!1}),e.addEventListener("touchmove",this.touchmove),e.addEventListener("touchend",this.touchend),e.addEventListener("touchcancel",this.reset)}down(t,e){this.mouseRotate.mousedown(t,e),this.mousePitch&&this.mousePitch.mousedown(t,e),st()}move(t,e){const i=this.map,r=this.mouseRotate.mousemoveWindow(t,e);if(r&&r.bearingDelta&&i.setBearing(i.getBearing()+r.bearingDelta),this.mousePitch){const r=this.mousePitch.mousemoveWindow(t,e);r&&r.pitchDelta&&i.setPitch(i.getPitch()+r.pitchDelta)}}off(){const t=this.element;t.removeEventListener("mousedown",this.mousedown),t.removeEventListener("touchstart",this.touchstart,{passive:!1}),t.removeEventListener("touchmove",this.touchmove),t.removeEventListener("touchend",this.touchend),t.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){ot(),l.removeEventListener("mousemove",this.mousemove),l.removeEventListener("mouseup",this.mouseup)}mousedown(t){this.down(I({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),ct(this.element,t)),l.addEventListener("mousemove",this.mousemove),l.addEventListener("mouseup",this.mouseup)}mousemove(t){this.move(t,ct(this.element,t))}mouseup(t){this.mouseRotate.mouseupWindow(t),this.mousePitch&&this.mousePitch.mouseupWindow(t),this.offTemp()}touchstart(t){1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=ht(this.element,t.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>t.preventDefault()},this._startPos))}touchmove(t){1!==t.targetTouches.length?this.reset():(this._lastPos=ht(this.element,t.targetTouches)[0],this.move({preventDefault:()=>t.preventDefault()},this._lastPos))}touchend(t){0===t.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 bx={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1};let wx,Tx=0,Ex=!1;const Ix={maxWidth:100,unit:"metric"};function Sx(t,e,i){const r=i&&i.maxWidth||100,n=t._containerHeight/2,s=t.unproject([0,n]),o=t.unproject([r,n]),a=s.distanceTo(o);if(i&&"imperial"===i.unit){const i=3.2808*a;i>5280?Ax(e,r,i/5280,t._getUIString("ScaleControl.Miles"),t):Ax(e,r,i,t._getUIString("ScaleControl.Feet"),t)}else i&&"nautical"===i.unit?Ax(e,r,a/1852,t._getUIString("ScaleControl.NauticalMiles"),t):a>=1e3?Ax(e,r,a/1e3,t._getUIString("ScaleControl.Kilometers"),t):Ax(e,r,a,t._getUIString("ScaleControl.Meters"),t)}function Ax(t,e,i,r,n){const s=function(t){const e=Math.pow(10,`${Math.floor(t)}`.length-1);let i=t/e;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(t){const e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}(i),e*i}(i),o=s/i;n._requestDomTask((()=>{t.style.width=e*o+"px",t.innerHTML=`${s}&nbsp;${r}`}))}const zx={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},Cx=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Mx(t=new o(0,0),e="bottom"){if("number"==typeof t){const i=Math.round(Math.sqrt(.5*Math.pow(t,2)));switch(e){case"top":return new o(0,t);case"top-left":return new o(i,i);case"top-right":return new o(-i,i);case"bottom":return new o(0,-t);case"bottom-left":return new o(i,-i);case"bottom-right":return new o(-i,-i);case"left":return new o(t,0);case"right":return new o(-t,0)}return new o(0,0)}return t instanceof o||Array.isArray(t)?o.convert(t):o.convert(t[e]||[0,0])}const kx={version:r,supported:t,setRTLTextPlugin:function(t,e,i=!1){if(rs===Qn||rs===ts||rs===es)throw new Error("setRTLTextPlugin cannot be called multiple times.");ns=J.resolveURL(t),rs=Qn,is=e,os(),i||cs()},getRTLTextPluginStatus:ls,Map:class extends lx{constructor(t){if(null!=(t=I({},gx,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(super(new hy(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._renderTaskQueue=new ux,this._domRenderTaskQueue=new ux,this._controls=[],this._markers=[],this._mapId=z(),this._locale=I({},_x,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevation=new mx(0),this._explicitProjection=null,this._requestManager=new wt(t.transformRequest,t.accessToken,t.testMode),this._silenceAuthErrors=!!t.testMode,"string"==typeof t.container){if(this._container=l.document.getElementById(t.container),!this._container)throw new Error(`Container '${t.container}' not found.`)}else{if(!(t.container instanceof l.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(this._container.childNodes.length>0&&O("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),P(["_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!==l&&(l.addEventListener("online",this._onWindowOnline,!1),l.addEventListener("resize",this._onWindowResize,!1),l.addEventListener("orientationchange",this._onWindowResize,!1),l.addEventListener("webkitfullscreenchange",this._onWindowResize,!1)),this.handlers=new ox(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 py("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,I({},t.fitBoundsOptions,{duration:0})))),this.resize(),t.attributionControl&&this.addControl(new cx({customAttribution:t.customAttribution})),this._logoControl=new hx,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)})),this.on("data",(t=>{this._update("style"===t.dataType),this.fire(new le(`${t.dataType}data`,t))})),this.on("dataloading",(t=>{this.fire(new le(`${t.dataType}dataloading`,t))}))}_getMapId(){return this._mapId}addControl(t,e){if(void 0===e&&(e=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new ce(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const i=t.onAdd(this);this._controls.push(t);const r=this._controlPositions[e];return-1!==e.indexOf("bottom")?r.insertBefore(i,r.firstChild):r.appendChild(i),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new ce(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const e=this._controls.indexOf(t);return e>-1&&this._controls.splice(e,1),t.onRemove(this),this}hasControl(t){return this._controls.indexOf(t)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(t){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 e=!this._moving;return e&&this.fire(new le("movestart",t)).fire(new le("move",t)),this.fire(new le("resize",t)),e&&this.fire(new le("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(ca.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()<t?this.setZoom(t):this.fire(new le("zoomstart")).fire(new le("zoom")).fire(new le("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(t){if((t=null==t?22:t)>=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new le("zoomstart")).fire(new le("zoom")).fire(new le("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?0:t)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()<t?this.setPitch(t):this.fire(new le("pitchstart")).fire(new le("pitch")).fire(new le("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(t){if((t=null==t?85:t)>85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new le("pitchstart")).fire(new le("pitch")).fire(new le("pitchend")),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(t){return this.transform.renderWorldCopies=t,this._update()}getProjection(){return this._explicitProjection?this._explicitProjection:this.style&&this.style.stylesheet&&this.style.stylesheet.projection?this.style.stylesheet.projection:{name:"mercator",center:[0,0]}}setProjection(t){return this._lazyInitEmptyStyle(),t?"string"==typeof t&&(t={name:t}):t=null,this._updateProjection(t)}_updateProjection(t){const e=this.getProjection();void 0===t&&(t=e);const i=this.transform.setProjection(t&&"globe"===t.name?{name:this.transform.zoom>=6?"mercator":"globe"}:t);if(t!==e&&(this._explicitProjection=t?"globe"===t.name?{name:"globe",center:[0,0]}:this.transform.getProjection():null),i){if(c(e,this.getProjection()))this.style._forceSymbolLayerUpdate();else{this.painter.clearBackgroundTiles();for(const t in this.style._sourceCaches)this.style._sourceCaches[t].clearTiles()}this.style.dispatcher.broadcast("setProjection",this.transform.projectionOptions),this.style.enableDraping(),this._update(!0)}return this}project(t){return this.transform.locationPoint3D(ua.convert(t))}unproject(t){return this.transform.pointLocation3D(o.convert(t))}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(t,e,i){if("mouseenter"===t||"mouseover"===t){let r=!1;const n=n=>{const s=e.filter((t=>this.getLayer(t))),o=s.length?this.queryRenderedFeatures(n.point,{layers:s}):[];o.length?r||(r=!0,i.call(this,new by(t,this,n.originalEvent,{features:o}))):r=!1},s=()=>{r=!1};return{layers:new Set(e),listener:i,delegates:{mousemove:n,mouseout:s}}}if("mouseleave"===t||"mouseout"===t){let r=!1;const n=n=>{const s=e.filter((t=>this.getLayer(t)));(s.length?this.queryRenderedFeatures(n.point,{layers:s}):[]).length?r=!0:r&&(r=!1,i.call(this,new by(t,this,n.originalEvent)))},s=e=>{r&&(r=!1,i.call(this,new by(t,this,e.originalEvent)))};return{layers:new Set(e),listener:i,delegates:{mousemove:n,mouseout:s}}}{const r=t=>{const r=e.filter((t=>this.getLayer(t))),n=r.length?this.queryRenderedFeatures(t.point,{layers:r}):[];n.length&&(t.features=n,i.call(this,t),delete t.features)};return{layers:new Set(e),listener:i,delegates:{[t]:r}}}}on(t,e,i){if(void 0===i)return super.on(t,e);Array.isArray(e)||(e=[e]);const r=this._createDelegatedListener(t,e,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(r);for(const t in r.delegates)this.on(t,r.delegates[t]);return this}once(t,e,i){if(void 0===i)return super.once(t,e);Array.isArray(e)||(e=[e]);const r=this._createDelegatedListener(t,e,i);for(const t in r.delegates)this.once(t,r.delegates[t]);return this}off(t,e,i){if(void 0===i)return super.off(t,e);e=new Set(Array.isArray(e)?e:[e]);const r=(t,e)=>{if(t.size!==e.size)return!1;for(const i of t)if(!e.has(i))return!1;return!0},n=this._delegatedListeners?this._delegatedListeners[t]:void 0;return n&&(t=>{for(let n=0;n<t.length;n++){const s=t[n];if(s.listener===i&&r(s.layers,e)){for(const t in s.delegates)this.off(t,s.delegates[t]);return t.splice(n,1),this}}})(n),this}queryRenderedFeatures(t,e){return this.style?(void 0!==e||void 0===t||t instanceof o||Array.isArray(t)||(e=t,t=void 0),this.style.queryRenderedFeatures(t=t||[[0,0],[this.transform.width,this.transform.height]],e=e||{},this.transform)):[]}querySourceFeatures(t,e){return this.style.querySourceFeatures(t,e)}queryTerrainElevation(t,e){const i=this.transform.elevation;return i?(e=I({},{exaggerated:!0},e),i.getAtPoint(ba.fromLngLat(t),null,e.exaggerated)):null}setStyle(t,e){return!1!==(e=I({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},e)).diff&&e.localIdeographFontFamily===this._localIdeographFontFamily&&e.localFontFamily===this._localFontFamily&&this.style&&t?(this._diffStyle(t,e),this):(this._localIdeographFontFamily=e.localIdeographFontFamily,this._localFontFamily=e.localFontFamily,this._updateStyle(t,e))}_getUIString(t){const e=this._locale[t];if(null==e)throw new Error(`Missing UI string '${t}'`);return e}_updateStyle(t,e){return this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),t&&(this.style=new Jm(this,e||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof t?this.style.loadURL(t):this.style.loadJSON(t)),this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Jm(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(t,e){if("string"==typeof t){const i=this._requestManager.normalizeStyleURL(t),r=this._requestManager.transformRequest(i,Wt.Style);Yt(r,((t,i)=>{t?this.fire(new ce(t)):i&&this._updateDiff(i,e)}))}else"object"==typeof t&&this._updateDiff(t,e)}_updateDiff(t,e){try{this.style.setState(t)&&this._update(!0)}catch(i){O(`Unable to perform style diff: ${i.message||i.error||i}. Rebuilding the style from scratch.`),this._updateStyle(t,e)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():O("There is no style added to the map.")}addSource(t,e){return this._lazyInitEmptyStyle(),this.style.addSource(t,e),this._update(!0)}isSourceLoaded(t){return this.style&&this.style._isSourceCacheLoaded(t)}areTilesLoaded(){const t=this.style&&this.style._sourceCaches;for(const e in t){const i=t[e]._tiles;for(const t in i){const e=i[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}}return!0}addSourceType(t,e,i){return this._lazyInitEmptyStyle(),this.style.addSourceType(t,e,i)}removeSource(t){return this.style.removeSource(t),this._updateTerrain(),this._update(!0)}getSource(t){return this.style.getSource(t)}addImage(t,e,{pixelRatio:i=1,sdf:r=!1,stretchX:n,stretchY:s,content:o}={}){if(this._lazyInitEmptyStyle(),e instanceof l.HTMLImageElement||l.ImageBitmap&&e instanceof l.ImageBitmap){const{width:a,height:l,data:c}=J.getImageData(e);this.style.addImage(t,{data:new ec({width:a,height:l},c),pixelRatio:i,stretchX:n,stretchY:s,content:o,sdf:r,version:0})}else{if(void 0===e.width||void 0===e.height)return this.fire(new ce(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:a,height:l}=e,c=e;this.style.addImage(t,{data:new ec({width:a,height:l},new Uint8Array(c.data)),pixelRatio:i,stretchX:n,stretchY:s,content:o,sdf:r,version:0,userImage:c}),c.onAdd&&c.onAdd(this,t)}}}updateImage(t,e){const i=this.style.getImage(t);if(!i)return this.fire(new ce(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const r=e instanceof l.HTMLImageElement||l.ImageBitmap&&e instanceof l.ImageBitmap?J.getImageData(e):e,{width:n,height:s}=r,o=r.data;return void 0===n||void 0===s?this.fire(new ce(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`"))):n!==i.data.width||s!==i.data.height?this.fire(new ce(new Error("The width and height of the updated image must be that same as the previous version of the image"))):(i.data.replace(o,!(e instanceof l.HTMLImageElement||l.ImageBitmap&&e instanceof l.ImageBitmap)),void this.style.updateImage(t,i))}hasImage(t){return t?!!this.style.getImage(t):(this.fire(new ce(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}loadImage(t,e){se(this._requestManager.transformRequest(t,Wt.Image),((t,i)=>{e(t,i instanceof l.HTMLImageElement?J.getImageData(i):i)}))}listImages(){return this.style.listImages()}addLayer(t,e){return this._lazyInitEmptyStyle(),this.style.addLayer(t,e),this._update(!0)}moveLayer(t,e){return this.style.moveLayer(t,e),this._update(!0)}removeLayer(t){return this.style.removeLayer(t),this._update(!0)}getLayer(t){return this.style.getLayer(t)}setLayerZoomRange(t,e,i){return this.style.setLayerZoomRange(t,e,i),this._update(!0)}setFilter(t,e,i={}){return this.style.setFilter(t,e,i),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,e,i,r={}){return this.style.setPaintProperty(t,e,i,r),this._update(!0)}getPaintProperty(t,e){return this.style.getPaintProperty(t,e)}setLayoutProperty(t,e,i,r={}){return this.style.setLayoutProperty(t,e,i,r),this._update(!0)}getLayoutProperty(t,e){return this.style.getLayoutProperty(t,e)}setLight(t,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,e),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(t){return this._lazyInitEmptyStyle(),!t&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(t),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(t){return this._lazyInitEmptyStyle(),this.style.setFog(t),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(ua.convert(t),this.transform):0}setFeatureState(t,e){return this.style.setFeatureState(t,e),this._update()}removeFeatureState(t,e){return this.style.removeFeatureState(t,e),this._update()}getFeatureState(t){return this.style.getFeatureState(t)}_updateContainerDimensions(){if(!this._container)return;const t=this._container.getBoundingClientRect().width||400,e=this._container.getBoundingClientRect().height||300;let i,r=this._container;for(;r&&!i;){const t=l.getComputedStyle(r).transform;t&&"none"!==t&&(i=t.match(/matrix.*\((.+)\)/)[1].split(", ")),r=r.parentElement}i?(this._containerWidth=i[0]&&"0"!==i[0]?Math.abs(t/i[0]):t,this._containerHeight=i[3]&&"0"!==i[3]?Math.abs(e/i[3]):e):(this._containerWidth=t,this._containerHeight=e)}_detectMissingCSS(){"rgb(250, 128, 114)"!==l.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&O("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 t=this._container;t.classList.add("mapboxgl-map"),(this._missingCSSCanary=Q("div","mapboxgl-canary",t)).style.visibility="hidden",this._detectMissingCSS();const e=this._canvasContainer=Q("div","mapboxgl-canvas-container",t);this._interactive&&e.classList.add("mapboxgl-interactive"),this._canvas=Q("canvas","mapboxgl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const i=this._controlContainer=Q("div","mapboxgl-control-container",t),r=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((t=>{r[t]=Q("div",`mapboxgl-ctrl-${t}`,i)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,e){const i=J.devicePixelRatio||1;this._canvas.width=i*Math.ceil(t),this._canvas.height=i*Math.ceil(e),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${e}px`}_addMarker(t){this._markers.push(t)}_removeMarker(t){const e=this._markers.indexOf(t);-1!==e&&this._markers.splice(e,1)}_setupPainter(){const e=I({},t.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),i=this._canvas.getContext("webgl",e)||this._canvas.getContext("experimental-webgl",e);i?(Ft(i,!0),this.painter=new Cg(i,this.transform),this.on("data",(t=>{"source"===t.dataType&&this.painter.setTileLoadedFlag(!0)})),ft.testSupport(i)):this.fire(new ce(new Error("Failed to initialize WebGL")))}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new le("webglcontextlost",{originalEvent:t}))}_contextRestored(t){this._setupPainter(),this.resize(),this._update(),this.fire(new le("webglcontextrestored",{originalEvent:t}))}_onMapScroll(t){if(t.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(t){return this.style?(this._styleDirty=this._styleDirty||t,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(t){return this._update(),this._renderTaskQueue.add(t)}_cancelRenderFrame(t){this._renderTaskQueue.remove(t)}_requestDomTask(t){!this.loaded()||this.loaded()&&!this.isMoving()?t():this._domRenderTaskQueue.add(t)}_render(t){let e;const i=this.painter.context.extTimerQuery,r=J.now();this.listens("gpu-timing-frame")&&(e=i.createQueryEXT(),i.beginQueryEXT(i.TIME_ELAPSED_EXT,e));let n=this._updateAverageElevation(r);if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;"globe"===this.getProjection().name&&(this.transform.zoom>=6?"globe"===this.transform.projection.name&&this._updateProjection():"mercator"===this.transform.projection.name&&this._updateProjection());let s=!1;const o=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,e=this.transform.pitch,i=J.now();this.style.zoomHistory.update(t,i);const r=new us(t,{now:i,fadeDuration:o,pitch:e,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),n=r.crossFadingFactor();1===n&&n===this._crossFadingFactor||(s=!0,this._crossFadingFactor=n),this.style.update(r)}if(this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0),this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),this.style._updateSources(this.transform),this._forceMarkerUpdate()),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,o,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:o,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),speedIndexTiming:this.speedIndexTiming}),this.fire(new le("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new le("load"))),this.style&&(this.style.hasTransitions()||s)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){const t=J.now()-r;i.endQueryEXT(i.TIME_ELAPSED_EXT,e),setTimeout((()=>{const r=i.getQueryObjectEXT(e,i.QUERY_RESULT_EXT)/1e6;i.deleteQueryEXT(e),this.fire(new le("gpu-timing-frame",{cpuTime:t,gpuTime:r}))}),50)}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout((()=>{const e=this.painter.queryGpuTimers(t);this.fire(new le("gpu-timing-layer",{layerTimes:e}))}),50)}const a=this._sourcesDirty||this._styleDirty||this._placementDirty||n;if(a||this._repaint)this.triggerRepaint();else{const t=!this.isMoving()&&this.loaded();if(t&&(n=this._updateAverageElevation(r,!0)),n)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new le("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new le("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1}}return!this._loaded||this._fullyLoaded||a||(this._fullyLoaded=!0,this._authenticate()),this}_forceMarkerUpdate(){for(const t of this._markers)t._update()}_updateAverageElevation(t,e=!1){const i=t=>(this.transform.averageElevation=t,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);if((e||t-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(t)){const e=this.transform.averageElevation;let r=this.transform.sampleAverageElevation();isNaN(r)?r=0:this._averageElevationLastSampledAt=t;const n=Math.abs(e-r);if(n>1){if(this._isInitialLoad)return this._averageElevation.jumpTo(r),i(r);this._averageElevation.easeTo(r,t,300)}else if(n>1e-4)return this._averageElevation.jumpTo(r),i(r)}return!!this._averageElevation.isEasing(t)&&i(this._averageElevation.getValue(t))}_authenticate(){Lt(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(t=>{if(t&&(t.message===bt||401===t.status)){const t=this.painter.context.gl;Ft(t,!1),this._logoControl instanceof hx&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new ce(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/")))}})),Dt(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(()=>{}))}_updateTerrain(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){const t=this.painter.canvasCopy(),e=this.painter.getCanvasCopiesAndTimestamps();e.timeStamps.push(performance.now());const i=this.painter.context.gl,r=i.createFramebuffer();function n(t){i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,t,0);const e=new Uint8Array(i.drawingBufferWidth*i.drawingBufferHeight*4);return i.readPixels(0,0,i.drawingBufferWidth,i.drawingBufferHeight,i.RGBA,i.UNSIGNED_BYTE,e),e}return i.bindFramebuffer(i.FRAMEBUFFER,r),this._canvasPixelComparison(n(t),e.canvasCopies.map(n),e.timeStamps)}_canvasPixelComparison(t,e,i){let r=i[1]-i[0];const n=t.length/4;for(let s=0;s<e.length;s++){const o=e[s];let a=0;for(let e=0;e<o.length;e+=4)o[e]===t[e]&&o[e+1]===t[e+1]&&o[e+2]===t[e+2]&&o[e+3]===t[e+3]&&(a+=1);r+=(i[s+2]-i[s+1])*(1-a/n)}return r}remove(){this._hash&&this._hash.remove();for(const t of this._controls)t.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!==l&&(l.removeEventListener("resize",this._onWindowResize,!1),l.removeEventListener("orientationchange",this._onWindowResize,!1),l.removeEventListener("webkitfullscreenchange",this._onWindowResize,!1),l.removeEventListener("online",this._onWindowOnline,!1));const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t&&t.loseContext(),yx(this._canvasContainer),yx(this._controlContainer),yx(this._missingCSSCanary),this._container.classList.remove("mapboxgl-map"),Rt.delete(this.painter.context.gl),this._removed=!0,this.fire(new le("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(t){this._renderNextFrame=this._renderNextFrame||t,this.style&&!this._frame&&(this._frame=J.frame((t=>{const e=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,e&&this._render(t)})))}_preloadTiles(t){return T(this.style?Object.values(this.style._sourceCaches):[],((e,i)=>e._preloadTiles(t,i)),(()=>{this.triggerRepaint()})),this}_onWindowOnline(){this._update()}_onWindowResize(t){this._trackResize&&this.resize({originalEvent:t})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(t){this._showTerrainWireframe!==t&&(this._showTerrainWireframe=t,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(t){this._speedIndexTiming!==t&&(this._speedIndexTiming=t,this._update())}get showPadding(){return!!this._showPadding}set showPadding(t){this._showPadding!==t&&(this._showPadding=t,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,t?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update())}get repaint(){return!!this._repaint}set repaint(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(t){this._vertices=t,this._update()}_setCacheLimits(t,e){!function(t,e){Ut=t,Nt=e}(t,e)}get version(){return r}},NavigationControl:class{constructor(t){this.options=I({},xx,t),this._container=Q("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this.options.showZoom&&(P(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",(t=>{this._map&&this._map.zoomIn({},{originalEvent:t})})),Q("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",(t=>{this._map&&this._map.zoomOut({},{originalEvent:t})})),Q("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(P(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",(t=>{const e=this._map;e&&(this.options.visualizePitch?e.resetNorthPitch({},{originalEvent:t}):e.resetNorth({},{originalEvent:t}))})),this._compassIcon=Q("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const t=this._map;if(!t)return;const e=t.getZoom(),i=e===t.getMaxZoom(),r=e===t.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 t=this._map;if(!t)return;const e=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(t.transform.pitch*(Math.PI/180)),.5)}) rotateX(${t.transform.pitch}deg) rotateZ(${t.transform.angle*(180/Math.PI)}deg)`:`rotate(${t.transform.angle*(180/Math.PI)}deg)`;t._requestDomTask((()=>{this._compassIcon&&(this._compassIcon.style.transform=e)}))}onAdd(t){return this._map=t,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),t.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&t.on("pitch",this._rotateCompassArrow),t.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new vx(t,this._compass,this.options.visualizePitch)),this._container}onRemove(){const t=this._map;t&&(this._container.remove(),this.options.showZoom&&t.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&t.off("pitch",this._rotateCompassArrow),t.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(t,e){const i=Q("button",t,this._container);return i.type="button",i.addEventListener("click",e),i}_setButtonTitle(t,e){if(!this._map)return;const i=this._map._getUIString(`NavigationControl.${e}`);t.setAttribute("aria-label",i),t.firstElementChild&&t.firstElementChild.setAttribute("title",i)}},GeolocateControl:class extends he{constructor(t){super(),this.options=I({},bx,t),P(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=uy(this._updateMarkerRotation,20)}onAdd(t){var e;return this._map=t,this._container=Q("div","mapboxgl-ctrl mapboxgl-ctrl-group"),e=this._setupUI,void 0!==wx?e(wx):void 0!==l.navigator.permissions?l.navigator.permissions.query({name:"geolocation"}).then((t=>{wx="denied"!==t.state,e(wx)})):(wx=!!l.navigator.geolocation,e(wx)),this._container}onRemove(){void 0!==this._geolocationWatchID&&(l.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,Tx=0,Ex=!1}_isOutOfMapMaxBounds(t){const e=this._map.getMaxBounds(),i=t.coords;return!!e&&(i.longitude<e.getWest()||i.longitude>e.getEast()||i.latitude<e.getSouth()||i.latitude>e.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(t){if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new le("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,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(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new le("geolocate",t)),this._finish()}}_updateCamera(t){const e=new ua(t.coords.longitude,t.coords.latitude),i=t.coords.accuracy,r=I({bearing:this._map.getBearing()},this.options.fitBoundsOptions);this._map.fitBounds(e.toBounds(i),r,{geolocateSource:!0})}_updateMarker(t){if(t){const e=new ua(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(e).addTo(this._map),this._userLocationDotMarker.setLngLat(e).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const t=this._map._containerHeight/2,e=this._map.unproject([0,t]),i=this._map.unproject([100,t]),r=e.distanceTo(i)/100,n=Math.ceil(2*this._accuracy/r);this._circleElement.style.width=`${n}px`,this._circleElement.style.height=`${n}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(t){if(this._map){if(this.options.trackUserLocation)if(1===t.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 t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&Ex)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new le("error",t)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(t){if(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=Q("button","mapboxgl-ctrl-geolocate",this._container),Q("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t){O("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}else{const t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=Q("div","mapboxgl-user-location"),this._dotElement.appendChild(Q("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(Q("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new fx({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=Q("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new fx({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",(t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new le("trackuserlocationend")))}))}_onDeviceOrientation(t){this._userLocationDotMarker&&(t.webkitCompassHeading?this._heading=t.webkitCompassHeading:!0===t.absolute&&(this._heading=-1*t.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return O("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 le("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Tx--,Ex=!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 le("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 le("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 t;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Tx++,Tx>1?(t={maximumAge:6e5,timeout:0},Ex=!0):(t=this.options.positionOptions,Ex=!1),this._geolocationWatchID=l.navigator.geolocation.watchPosition(this._onSuccess,this._onError,t),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else l.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const t=()=>{l.addEventListener("ondeviceorientationabsolute"in l?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};void 0!==l.DeviceMotionEvent&&"function"==typeof l.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((e=>{"granted"===e&&t()})).catch(console.error):t()}_clearWatch(){l.navigator.geolocation.clearWatch(this._geolocationWatchID),l.removeEventListener("deviceorientation",this._onDeviceOrientation),l.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:cx,ScaleControl:class{constructor(t){this.options=I({},Ix,t),P(["_onMove","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_onMove(){Sx(this._map,this._container,this.options)}onAdd(t){return this._map=t,this._container=Q("div","mapboxgl-ctrl mapboxgl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._onMove),this._map=void 0}setUnit(t){this.options.unit=t,Sx(this._map,this._container,this.options)}},FullscreenControl:class{constructor(t){this._fullscreen=!1,t&&t.container&&(t.container instanceof l.HTMLElement?this._container=t.container:O("Full screen control 'container' must be a DOM element.")),P(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in l.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in l.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=Q("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",O("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,l.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!l.document.fullscreenEnabled&&!l.document.webkitFullscreenEnabled)}_setupUI(){const t=this._fullscreenButton=Q("button","mapboxgl-ctrl-fullscreen",this._controlContainer);Q("span","mapboxgl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),l.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const t=this._getTitle();this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",t)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(l.document.fullscreenElement||l.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()?l.document.exitFullscreen?l.document.exitFullscreen():l.document.webkitCancelFullScreen&&l.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends he{constructor(t){super(),this.options=I(Object.create(zx),t),P(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(/\s+/):[])}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&t.on("preclick",this._onClose),this.options.closeOnMove&&t.on("move",this._onClose),t.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(t.on("mousemove",this._onMouseEvent),t.on("mouseup",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")):t.on("move",this._update),this.fire(new le("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const t=this._map;return t&&(t.off("move",this._update),t.off("move",this._onClose),t.off("preclick",this._onClose),t.off("click",this._onClose),t.off("remove",this.remove),t.off("mousemove",this._onMouseEvent),t.off("mouseup",this._onMouseEvent),t.off("drag",this._onMouseEvent),this._map=void 0),this.fire(new le("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=ua.convert(t),this._pos=null,this._trackPointer=!1,this._update();const e=this._map;return e&&(e.on("move",this._update),e.off("mousemove",this._onMouseEvent),e._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const t=this._map;return t&&(t.off("move",this._update),t.on("mousemove",this._onMouseEvent),t.on("drag",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(l.document.createTextNode(t))}setHTML(t){const e=l.document.createDocumentFragment(),i=l.document.createElement("body");let r;for(i.innerHTML=t;r=i.firstChild,r;)e.appendChild(r);return this.setDOMContent(e)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(t){return this.options.maxWidth=t,this._update(),this}setDOMContent(t){let e=this._content;if(e)for(;e.hasChildNodes();)e.firstChild&&e.removeChild(e.firstChild);else e=this._content=Q("div","mapboxgl-popup-content",this._container||void 0);if(e.appendChild(t),this.options.closeButton){const t=this._closeButton=Q("button","mapboxgl-popup-close-button",e);t.type="button",t.setAttribute("aria-label","Close popup"),t.setAttribute("aria-hidden","true"),t.innerHTML="&#215;",t.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(t){return this._classList.add(t),this._updateClassList(),this}removeClassName(t){return this._classList.delete(t),this._updateClassList(),this}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){let e;return this._classList.delete(t)?e=!1:(this._classList.add(t),e=!0),this._updateClassList(),e}_onMouseEvent(t){this._update(t.point)}_getAnchor(t){if(this.options.anchor)return this.options.anchor;const e=this._map,i=this._container,r=this._pos;if(!e||!i||!r)return"bottom";const n=i.offsetWidth,s=i.offsetHeight,o=r.x<n/2,a=r.x>e.transform.width-n/2;if(r.y+t<s)return o?"top-left":a?"top-right":"top";if(r.y>e.transform.height-s){if(o)return"bottom-left";if(a)return"bottom-right"}return o?"left":a?"right":"bottom"}_updateClassList(){const t=this._container;if(!t)return;const e=[...this._classList];e.push("mapboxgl-popup"),this._anchor&&e.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&e.push("mapboxgl-popup-track-pointer"),t.className=e.join(" ")}_update(t){const e=this._map,i=this._content;if(!e||!this._lngLat&&!this._trackPointer||!i)return;let r=this._container;if(r||(r=this._container=Q("div","mapboxgl-popup",e.getContainer()),this._tip=Q("div","mapboxgl-popup-tip",r),r.appendChild(i)),this.options.maxWidth&&r.style.maxWidth!==this.options.maxWidth&&(r.style.maxWidth=this.options.maxWidth),e.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=px(this._lngLat,this._pos,e.transform)),!this._trackPointer||t){const i=this._pos=this._trackPointer&&t?t:e.project(this._lngLat),r=Mx(this.options.offset),n=this._anchor=this._getAnchor(r.y),s=Mx(this.options.offset,n),o=i.add(s).round();e._requestDomTask((()=>{this._container&&n&&(this._container.style.transform=`${dx[n]} translate(${o.x}px,${o.y}px)`)}))}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const t=this._container.querySelector(Cx);t&&t.focus()}_onClose(){this.remove()}_setOpacity(t){this._content&&(this._content.style.opacity=t),this._tip&&(this._tip.style.opacity=t)}},Marker:fx,Style:Jm,LngLat:ua,LngLatBounds:ca,Point:o,MercatorCoordinate:ba,FreeCameraOptions:iy,Evented:he,config:dt,prewarm:function(){Zf().acquire(jf)},clearPrewarmedResources:function(){const t=Nf;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(jf),Nf=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 dt.ACCESS_TOKEN},set accessToken(t){dt.ACCESS_TOKEN=t},get baseApiUrl(){return dt.API_URL},set baseApiUrl(t){dt.API_URL=t},get workerCount(){return Uf.workerCount},set workerCount(t){Uf.workerCount=t},get maxParallelImageRequests(){return dt.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){dt.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(t){!function(t){const e=l.caches.delete(Ot);t&&e.catch(t).then((()=>t()))}(t)},workerUrl:"",workerClass:null,setNow:J.setNow,restoreNow:J.restoreNow};return kx}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).mapboxgl=e()}(this,(function(){"use strict";var t=e;function e(t){return!function(t){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 t,e,i=new Blob([""],{type:"text/javascript"}),r=URL.createObjectURL(i);try{e=new Worker(r),t=!0}catch(e){t=!1}return e&&e.terminate(),URL.revokeObjectURL(r),t}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var t=document.createElement("canvas");t.width=t.height=1;var e=t.getContext("2d");if(!e)return!1;var i=e.getImageData(0,0,1,1);return i&&i.width===t.width}()?(void 0===i[r=t&&t.failIfMajorPerformanceCaveat]&&(i[r]=function(t){var i,r=function(t){var i=document.createElement("canvas"),r=Object.create(e.webGLContextAttributes);return r.failIfMajorPerformanceCaveat=t,i.getContext("webgl",r)||i.getContext("experimental-webgl",r)}(t);if(!r)return!1;try{i=r.createShader(r.VERTEX_SHADER)}catch(t){return!1}return!(!i||r.isContextLost())&&(r.shaderSource(i,"void main() {}"),r.compileShader(i),!0===r.getShaderParameter(i,r.COMPILE_STATUS))}(r)),i[r]?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 r}(t)}var i={};e.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};var r="2.8.0-alpha.4",n=s;function s(t,e,i,r){this.cx=3*t,this.bx=3*(i-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(r-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=r,this.p2x=i,this.p2y=r}s.prototype.sampleCurveX=function(t){return((this.ax*t+this.bx)*t+this.cx)*t},s.prototype.sampleCurveY=function(t){return((this.ay*t+this.by)*t+this.cy)*t},s.prototype.sampleCurveDerivativeX=function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},s.prototype.solveCurveX=function(t,e){var i,r,n,s,o;for(void 0===e&&(e=1e-6),n=t,o=0;o<8;o++){if(s=this.sampleCurveX(n)-t,Math.abs(s)<e)return n;var a=this.sampleCurveDerivativeX(n);if(Math.abs(a)<1e-6)break;n-=s/a}if((n=t)<(i=0))return i;if(n>(r=1))return r;for(;i<r;){if(s=this.sampleCurveX(n),Math.abs(s-t)<e)return n;t>s?i=n:r=n,n=.5*(r-i)+i}return n},s.prototype.solve=function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))};var o=a;function a(t,e){this.x=t,this.y=e}a.prototype={clone:function(){return new a(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},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(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,i=t.y-this.y;return e*e+i*i},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),i=Math.sin(t),r=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=r,this},_rotateAround:function(t,e){var i=Math.cos(t),r=Math.sin(t),n=e.y+r*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-r*(this.y-e.y),this.y=n,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},a.convert=function(t){return t instanceof a?t:Array.isArray(t)?new a(t[0],t[1]):t};var l="undefined"!=typeof self?self:{};function c(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!c(t[i],e[i]))return!1;return!0}if("object"==typeof t&&null!==t&&null!==e){if("object"!=typeof e)return!1;if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const i in t)if(!c(t[i],e[i]))return!1;return!0}return t===e}const h=Math.PI/180,u=180/Math.PI;function p(t){return t*h}function d(t){return t*u}const f=[[0,0],[1,0],[1,1],[0,1]];function m(t){if(t<=0)return 0;if(t>=1)return 1;const e=t*t,i=e*t;return 4*(t<.5?i:3*(t-e)+i-.75)}function _(t){let e=1/0,i=1/0,r=-1/0,n=-1/0;for(const s of t)e=Math.min(e,s.x),i=Math.min(i,s.y),r=Math.max(r,s.x),n=Math.max(n,s.y);return{min:new o(e,i),max:new o(r,n)}}function g(t,e,i=0,r=!0){const n=new o(i,i),s=t.sub(n),a=e.add(n),l=[s,new o(a.x,s.y),a,new o(s.x,a.y)];return r&&l.push(s),l}function y(t,e,i,r){const s=new n(t,e,i,r);return function(t){return s.solve(t)}}const x=y(.25,.1,.25,1);function v(t,e,i){return Math.min(i,Math.max(e,t))}function b(t,e,i){return(i=v((i-t)/(e-t),0,1))*i*(3-2*i)}function w(t,e,i){const r=i-e,n=((t-e)%r+r)%r+e;return n===e?i:n}function T(t,e,i){if(!t.length)return i(null,[]);let r=t.length;const n=new Array(t.length);let s=null;t.forEach(((t,o)=>{e(t,((t,e)=>{t&&(s=t),n[o]=e,0==--r&&i(s,n)}))}))}function E(t){const e=[];for(const i in t)e.push(t[i]);return e}function I(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}function S(t,e){const i={};for(let r=0;r<e.length;r++){const n=e[r];n in t&&(i[n]=t[n])}return i}let A=1;function z(){return A++}function C(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}function M(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function k(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)}function P(t,e){t.forEach((t=>{e[t]&&(e[t]=e[t].bind(e))}))}function D(t,e){return-1!==t.indexOf(e,t.length-e.length)}function B(t,e,i){const r={};for(const n in t)r[n]=e.call(i||this,t[n],n,t);return r}function L(t,e,i){const r={};for(const n in t)e.call(i||this,t[n],n,t)&&(r[n]=t[n]);return r}function R(t){return Array.isArray(t)?t.map(R):"object"==typeof t&&t?B(t,R):t}const F={};function O(t){F[t]||("undefined"!=typeof console&&console.warn(t),F[t]=!0)}function V(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}function j(t){let e=0;for(let i,r,n=0,s=t.length,o=s-1;n<s;o=n++)i=t[n],r=t[o],e+=(r.x-i.x)*(i.y+r.y);return e}function U(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}function N(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,i,r,n)=>{const s=r||n;return e[i]=!s||s.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t}return e}let Z,q,G,$,W=null;function X(t){if(null==W){const e=t.navigator?t.navigator.userAgent:null;W=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return W}function H(t){try{const e=l[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}}function K(t,e){return[t[4*e],t[4*e+1],t[4*e+2],t[4*e+3]]}function Y(t,e,i){t[4*e+0]=i[0],t[4*e+1]=i[1],t[4*e+2]=i[2],t[4*e+3]=i[3]}const J={now:()=>void 0!==G?G:l.performance.now(),setNow(t){G=t},restoreNow(){G=void 0},frame(t){const e=l.requestAnimationFrame(t);return{cancel:()=>l.cancelAnimationFrame(e)}},getImageData(t,e=0){const{width:i,height:r}=t;$||($=l.document.createElement("canvas"));const n=$.getContext("2d");if(!n)throw new Error("failed to create canvas 2d context");return(i>$.width||r>$.height)&&($.width=i,$.height=r),n.clearRect(-e,-e,i+2*e,r+2*e),n.drawImage(t,0,0,i,r),n.getImageData(-e,-e,i+2*e,r+2*e)},resolveURL:t=>(Z||(Z=l.document.createElement("a")),Z.href=t,Z.href),get devicePixelRatio(){return l.devicePixelRatio},get prefersReducedMotion(){return!!l.matchMedia&&(null==q&&(q=l.matchMedia("(prefers-reduced-motion: reduce)")),q.matches)}};function Q(t,e,i){const r=l.document.createElement(t);return void 0!==e&&(r.className=e),i&&i.appendChild(r),r}function tt(t,e,i){const r=l.document.createElementNS("http://www.w3.org/2000/svg",t);for(const t of Object.keys(e))r.setAttributeNS(null,t,e[t]);return i&&i.appendChild(r),r}const et=l.document&&l.document.documentElement.style,it=et&&void 0!==et.userSelect?"userSelect":"WebkitUserSelect";let rt,nt;function st(){et&&it&&(rt=et[it],et[it]="none")}function ot(){et&&it&&(et[it]=rt)}function at(t){t.preventDefault(),t.stopPropagation(),l.removeEventListener("click",at,!0)}function lt(){l.addEventListener("click",at,!0),l.setTimeout((()=>{l.removeEventListener("click",at,!0)}),0)}function ct(t,e){const i=t.getBoundingClientRect();return pt(t,i,e)}function ht(t,e){const i=t.getBoundingClientRect(),r=[];for(let n=0;n<e.length;n++)r.push(pt(t,i,e[n]));return r}function ut(t){return void 0!==l.InstallTrigger&&2===t.button&&t.ctrlKey&&l.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:t.button}function pt(t,e,i){const r=t.offsetWidth===e.width?1:t.offsetWidth/e.width;return new o((i.clientX-e.left)*r,(i.clientY-e.top)*r)}const dt={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==nt){const t=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{nt=null!=process.env.API_URL_REGEX?new RegExp(process.env.API_URL_REGEX):t}catch(e){nt=t}}return nt},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},ft={supported:!1,testSupport:function(t){!gt&&_t&&(yt?xt(t):mt=t)}};let mt,_t,gt=!1,yt=!1;function xt(t){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,_t),t.isContextLost())return;ft.supported=!0}catch(t){}t.deleteTexture(e),gt=!0}l.document&&(_t=l.document.createElement("img"),_t.onload=function(){mt&&xt(mt),mt=null,yt=!0},_t.onerror=function(){gt=!0,mt=null},_t.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const vt="01",bt="NO_ACCESS_TOKEN";class wt{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let t="";for(let e=0;e<10;e++)t+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",vt,t].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=t.token,this._skuTokenExpiresAt=t.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,e){if(!Tt(t))return t;const i=St(t);return i.path=`/styles/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeGlyphsURL(t,e){if(!Tt(t))return t;const i=St(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e){if(!Tt(t))return t;const i=St(t);return i.path=`/v4/${i.authority}.json`,i.params.push("secure"),this._makeAPIURL(i,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,r){const n=St(t);return Tt(t)?(n.path=`/styles/v1${n.path}/sprite${e}${i}`,this._makeAPIURL(n,this._customAccessToken||r)):(n.path+=`${e}${i}`,At(n))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!Tt(t))return t;const r=St(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${ft.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${dt.RASTER_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${dt.TILE_URL_VERSION}${r.path}`);const n=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||dt.ACCESS_TOKEN;return dt.REQUIRE_ACCESS_TOKEN&&n&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,n)}canonicalizeTileURL(t,e){const i=St(t);if(!i.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${dt.RASTER_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${dt.TILE_URL_VERSION}/`,"")}`;let n=i.params;return e&&(n=n.filter((t=>!t.match(/^access_token=/)))),n.length&&(r+=`?${n.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&Tt(e),r=[];for(const e of t.tiles||[])Et(e)?r.push(this.canonicalizeTileURL(e,i)):r.push(e);return r}_makeAPIURL(t,e){const i="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",r=St(dt.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!dt.REQUIRE_ACCESS_TOKEN)return At(t);if(e=e||dt.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),At(t)}}function Tt(t){return 0===t.indexOf("mapbox:")}function Et(t){return dt.API_URL_REGEX.test(t)}const It=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function St(t){const e=t.match(It);if(!e)throw new Error("Unable to parse URL object");return{protocol:e[1],authority:e[2],path:e[3]||"/",params:e[4]?e[4].split("&"):[]}}function At(t){const e=t.params.length?`?${t.params.join("&")}`:"";return`${t.protocol}://${t.authority}${t.path}${e}`}function zt(t){if(!t)return null;const e=t.split(".");if(!e||3!==e.length)return null;try{return JSON.parse(decodeURIComponent(l.atob(e[1]).split("").map((t=>"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join("")))}catch(t){return null}}class Ct{constructor(t){this.type=t,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(t){const e=zt(dt.ACCESS_TOKEN);let i="";return i=e&&e.u?l.btoa(encodeURIComponent(e.u).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e))))):dt.ACCESS_TOKEN||"",t?`mapbox.eventData.${t}:${i}`:`mapbox.eventData:${i}`}fetchEventData(){const t=H("localStorage"),e=this.getStorageKey(),i=this.getStorageKey("uuid");if(t)try{const t=l.localStorage.getItem(e);t&&(this.eventData=JSON.parse(t));const r=l.localStorage.getItem(i);r&&(this.anonId=r)}catch(t){O("Unable to read from LocalStorage")}}saveEventData(){const t=H("localStorage"),e=this.getStorageKey(),i=this.getStorageKey("uuid");if(t)try{l.localStorage.setItem(i,this.anonId),Object.keys(this.eventData).length>=1&&l.localStorage.setItem(e,JSON.stringify(this.eventData))}catch(t){O("Unable to write to LocalStorage")}}processRequests(t){}postEvent(t,e,i,n){if(!dt.EVENTS_URL)return;const s=St(dt.EVENTS_URL);s.params.push(`access_token=${n||dt.ACCESS_TOKEN||""}`);const o={event:this.type,created:new Date(t).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:r,skuId:vt,userId:this.anonId},a=e?I(o,e):o,l={url:At(s),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=Qt(l,(t=>{this.pendingRequest=null,i(t),this.saveEventData(),this.processRequests(n)}))}queueRequest(t,e){this.queue.push(t),this.processRequests(e)}}const Mt=new class extends Ct{constructor(t){super("appUserTurnstile"),this._customAccessToken=t}postTurnstileEvent(t,e){dt.EVENTS_URL&&dt.ACCESS_TOKEN&&Array.isArray(t)&&t.some((t=>Tt(t)||Et(t)))&&this.queueRequest(Date.now(),e)}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const e=zt(dt.ACCESS_TOKEN),i=e?e.u:dt.ACCESS_TOKEN;let r=i!==this.eventData.tokenU;k(this.anonId)||(this.anonId=C(),r=!0);const n=this.queue.shift();if(this.eventData.lastSuccess){const t=new Date(this.eventData.lastSuccess),e=new Date(n),i=(n-this.eventData.lastSuccess)/864e5;r=r||i>=1||i<-1||t.getDate()!==e.getDate()}else r=!0;if(!r)return this.processRequests();this.postEvent(n,{"enabled.telemetry":!1},(t=>{t||(this.eventData.lastSuccess=n,this.eventData.tokenU=i)}),t)}},kt=Mt.postTurnstileEvent.bind(Mt),Pt=new class extends Ct{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(t,e,i,r){this.skuToken=e,this.errorCb=r,dt.EVENTS_URL&&(i||dt.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(bt)))}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:e,timestamp:i}=this.queue.shift();e&&this.success[e]||(this.anonId||this.fetchEventData(),k(this.anonId)||(this.anonId=C()),this.postEvent(i,{skuToken:this.skuToken},(t=>{t?this.errorCb(t):e&&(this.success[e]=!0)}),t))}},Dt=Pt.postMapLoadEvent.bind(Pt),Bt=new class extends Ct{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(t,e,i,r){if(!dt.API_URL||!dt.SESSION_PATH)return;const n=St(dt.API_URL+dt.SESSION_PATH);n.params.push(`sku=${e||""}`),n.params.push(`access_token=${r||dt.ACCESS_TOKEN||""}`);const s={url:At(n),headers:{"Content-Type":"text/plain"}};this.pendingRequest=te(s,(t=>{this.pendingRequest=null,i(t),this.saveEventData(),this.processRequests(r)}))}getSessionAPI(t,e,i,r){this.skuToken=e,this.errorCb=r,dt.SESSION_PATH&&dt.API_URL&&(i||dt.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(bt)))}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:e,timestamp:i}=this.queue.shift();e&&this.success[e]||this.getSession(i,this.skuToken,(t=>{t?this.errorCb(t):e&&(this.success[e]=!0)}),t)}},Lt=Bt.getSessionAPI.bind(Bt),Rt=new Set;function Ft(t,e){e?Rt.add(t):Rt.delete(t)}const Ot="mapbox-tiles";let Vt,jt,Ut=500,Nt=50;function Zt(){l.caches&&!Vt&&(Vt=l.caches.open(Ot))}function qt(t){const e=t.indexOf("?");return e<0?t:t.slice(0,e)}let Gt=1/0;function $t(t){Gt++,Gt>Nt&&(t.getActor().send("enforceCacheSizeLimit",Ut),Gt=0)}const Wt={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(Wt);class Xt extends Error{constructor(t,e,i){401===e&&Et(i)&&(t+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(t),this.status=e,this.url=i}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const Ht=U()?()=>self.worker&&self.worker.referrer:()=>("blob:"===l.location.protocol?l.parent:l).location.href;const Kt=function(t,e){if(!(/^file:/.test(i=t.url)||/^file:/.test(Ht())&&!/^\w+:/.test(i))){if(l.fetch&&l.Request&&l.AbortController&&l.Request.prototype.hasOwnProperty("signal"))return function(t,e){const i=new l.AbortController,r=new l.Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:Ht(),signal:i.signal});let n=!1,s=!1;const o=(a=r.url).indexOf("sku=")>0&&Et(a);var a;"json"===t.type&&r.headers.set("Accept","application/json");const c=(i,n,a)=>{if(s)return;if(i&&"SecurityError"!==i.message&&O(i),n&&a)return h(n);const c=Date.now();l.fetch(r).then((i=>{if(i.ok){const t=o?i.clone():null;return h(i,t,c)}return e(new Xt(i.statusText,i.status,t.url))})).catch((t=>{20!==t.code&&e(new Error(t.message))}))},h=(i,o,a)=>{("arrayBuffer"===t.type?i.arrayBuffer():"json"===t.type?i.json():i.text()).then((t=>{s||(o&&a&&function(t,e,i){if(Zt(),!Vt)return;const r={status:e.status,statusText:e.statusText,headers:new l.Headers};e.headers.forEach(((t,e)=>r.headers.set(e,t)));const n=N(e.headers.get("Cache-Control")||"");if(n["no-store"])return;n["max-age"]&&r.headers.set("Expires",new Date(i+1e3*n["max-age"]).toUTCString());const s=r.headers.get("Expires");s&&(new Date(s).getTime()-i<42e4||function(t,e){if(void 0===jt)try{new Response(new ReadableStream),jt=!0}catch(t){jt=!1}jt?e(t.body):t.blob().then(e)}(e,(e=>{const i=new l.Response(e,r);Zt(),Vt&&Vt.then((e=>e.put(qt(t.url),i))).catch((t=>O(t.message)))})))}(r,o,a),n=!0,e(null,t,i.headers.get("Cache-Control"),i.headers.get("Expires")))})).catch((t=>{s||e(new Error(t.message))}))};return o?function(t,e){if(Zt(),!Vt)return e(null);const i=qt(t.url);Vt.then((t=>{t.match(i).then((r=>{const n=function(t){if(!t)return!1;const e=new Date(t.headers.get("Expires")||0),i=N(t.headers.get("Cache-Control")||"");return e>Date.now()&&!i["no-cache"]}(r);t.delete(i),n&&t.put(i,r.clone()),e(null,r,n)})).catch(e)})).catch(e)}(r,c):c(null,null),{cancel:()=>{s=!0,n||i.abort()}}}(t,e);if(U()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var i;return function(t,e){const i=new l.XMLHttpRequest;i.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(i.responseType="arraybuffer");for(const e in t.headers)i.setRequestHeader(e,t.headers[e]);return"json"===t.type&&(i.responseType="text",i.setRequestHeader("Accept","application/json")),i.withCredentials="include"===t.credentials,i.onerror=()=>{e(new Error(i.statusText))},i.onload=()=>{if((i.status>=200&&i.status<300||0===i.status)&&null!==i.response){let r=i.response;if("json"===t.type)try{r=JSON.parse(i.response)}catch(t){return e(t)}e(null,r,i.getResponseHeader("Cache-Control"),i.getResponseHeader("Expires"))}else e(new Xt(i.statusText,i.status,t.url))},i.send(t.body),{cancel:()=>i.abort()}}(t,e)},Yt=function(t,e){return Kt(I(t,{type:"json"}),e)},Jt=function(t,e){return Kt(I(t,{type:"arrayBuffer"}),e)},Qt=function(t,e){return Kt(I(t,{method:"POST"}),e)},te=function(t,e){return Kt(I(t,{method:"GET"}),e)};function ee(t){const e=l.document.createElement("a");return e.href=t,e.protocol===l.document.location.protocol&&e.host===l.document.location.host}const ie="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let re,ne;re=[],ne=0;const se=function(t,e){if(ft.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),ne>=dt.MAX_PARALLEL_IMAGE_REQUESTS){const i={requestParameters:t,callback:e,cancelled:!1,cancel(){this.cancelled=!0}};return re.push(i),i}ne++;let i=!1;const r=()=>{if(!i)for(i=!0,ne--;re.length&&ne<dt.MAX_PARALLEL_IMAGE_REQUESTS;){const t=re.shift(),{requestParameters:e,callback:i,cancelled:r}=t;r||(t.cancel=se(e,i).cancel)}},n=Jt(t,((t,i,n,s)=>{r(),t?e(t):i&&(l.createImageBitmap?function(t,e){const i=new l.Blob([new Uint8Array(t)],{type:"image/png"});l.createImageBitmap(i).then((t=>{e(null,t)})).catch((t=>{e(new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))}))}(i,((t,i)=>e(t,i,n,s))):function(t,e){const i=new l.Image,r=l.URL;i.onload=()=>{e(null,i),r.revokeObjectURL(i.src),i.onload=null,l.requestAnimationFrame((()=>{i.src=ie}))},i.onerror=()=>e(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const n=new l.Blob([new Uint8Array(t)],{type:"image/png"});i.src=t.byteLength?r.createObjectURL(n):ie}(i,((t,i)=>e(t,i,n,s))))}));return{cancel:()=>{n.cancel(),r()}}};function oe(t,e,i){i[t]&&-1!==i[t].indexOf(e)||(i[t]=i[t]||[],i[t].push(e))}function ae(t,e,i){if(i&&i[t]){const r=i[t].indexOf(e);-1!==r&&i[t].splice(r,1)}}class le{constructor(t,e={}){I(this,e),this.type=t}}class ce extends le{constructor(t,e={}){super("error",I({error:t},e))}}class he{on(t,e){return this._listeners=this._listeners||{},oe(t,e,this._listeners),this}off(t,e){return ae(t,e,this._listeners),ae(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},oe(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new le(t,e||{}));const i=t.type;if(this.listens(i)){t.target=this;const e=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of e)i.call(this,t);const r=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const e of r)ae(i,e,this._oneTimeListeners),e.call(this,t);const n=this._eventedParent;n&&(I(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),n.fire(t))}else t instanceof ce&&console.error(t.error);return this}listens(t){return!!(this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t))}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var ue=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":{},"mapbox":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":{},"line":{},"line-center":{}},"default":"point","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"units":"factor of the original icon size","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":{},"width":{},"height":{},"both":{}},"default":"none","requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"units":"pixels","requires":["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","units":"ems","default":0,"requires":["text-field"],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["text-field",{"!":"text-variable-anchor"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"units":"degrees","requires":["text-field",{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","units":"ems","length":2,"default":[0,0],"requires":["text-field",{"!":"text-radial-offset"}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"geometry_type":{"type":"enum","values":{"Point":{},"LineString":{},"Polygon":{}}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":{},"exponential":{},"interval":{},"categorical":{}},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":{},"lab":{},"hcl":{}},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":0.1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{},"globe":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":true,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"cross-faded"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0,"units":"milliseconds"},"delay":{"type":"number","default":0,"minimum":0,"units":"milliseconds"}},"property-type":{"data-driven":{"type":"property-type"},"cross-faded":{"type":"property-type"},"cross-faded-data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function pe(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}function de(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function fe(t){if(Array.isArray(t))return t.map(fe);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const i in t)e[i]=fe(t[i]);return e}return de(t)}class me extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}class _e{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,i]of e)this.bindings[t]=i}concat(t){return new _e(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}const ge={kind:"null"},ye={kind:"number"},xe={kind:"string"},ve={kind:"boolean"},be={kind:"color"},we={kind:"object"},Te={kind:"value"},Ee={kind:"collator"},Ie={kind:"formatted"},Se={kind:"resolvedImage"};function Ae(t,e){return{kind:"array",itemType:t,N:e}}function ze(t){if("array"===t.kind){const e=ze(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Ce=[ge,ye,xe,ve,be,Ie,we,Ae(Te),Se];function Me(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Me(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of Ce)if(!Me(t,e))return null}return`Expected ${ze(t)} but found ${ze(e)} instead.`}function ke(t,e){return e.some((e=>e.kind===t.kind))}function Pe(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}function De(t){var e={exports:{}};return t(e,e.exports),e.exports}var Be=De((function(t,e){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(t){return(t=Math.round(t))<0?0:t>255?255:t}function n(t){return r("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function s(t){return(e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e}function o(t,e,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?t+(e-t)*i*6:2*i<1?e:3*i<2?t+(e-t)*(2/3-i)*6:t}try{e.parseCSSColor=function(t){var e,a=t.replace(/ /g,"").toLowerCase();if(a in i)return i[a].slice();if("#"===a[0])return 4===a.length?(e=parseInt(a.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:7===a.length&&(e=parseInt(a.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var l=a.indexOf("("),c=a.indexOf(")");if(-1!==l&&c+1===a.length){var h=a.substr(0,l),u=a.substr(l+1,c-(l+1)).split(","),p=1;switch(h){case"rgba":if(4!==u.length)return null;p=s(u.pop());case"rgb":return 3!==u.length?null:[n(u[0]),n(u[1]),n(u[2]),p];case"hsla":if(4!==u.length)return null;p=s(u.pop());case"hsl":if(3!==u.length)return null;var d=(parseFloat(u[0])%360+360)%360/360,f=s(u[1]),m=s(u[2]),_=m<=.5?m*(f+1):m+f-m*f,g=2*m-_;return[r(255*o(g,_,d+1/3)),r(255*o(g,_,d)),r(255*o(g,_,d-1/3)),p];default:return null}}return null}}catch(t){}}));class Le{constructor(t,e,i,r=1){this.r=t,this.g=e,this.b=i,this.a=r}static parse(t){if(!t)return;if(t instanceof Le)return t;if("string"!=typeof t)return;const e=Be.parseCSSColor(t);return e?new Le(e[0]/255*e[3],e[1]/255*e[3],e[2]/255*e[3],e[3]):void 0}toString(){const[t,e,i,r]=this.toArray();return`rgba(${Math.round(t)},${Math.round(e)},${Math.round(i)},${r})`}toArray(){const{r:t,g:e,b:i,a:r}=this;return 0===r?[0,0,0,0]:[255*t/r,255*e/r,255*i/r,r]}}Le.black=new Le(0,0,0,1),Le.white=new Le(1,1,1,1),Le.transparent=new Le(0,0,0,0),Le.red=new Le(1,0,0,1),Le.blue=new Le(0,0,1,1);class Re{constructor(t,e,i){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Fe{constructor(t,e,i,r,n){this.text=t.normalize?t.normalize():t,this.image=e,this.scale=i,this.fontStack=r,this.textColor=n}}class Oe{constructor(t){this.sections=t}static fromString(t){return new Oe([new Fe(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof Oe?t:Oe.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}serialize(){const t=["format"];for(const e of this.sections){if(e.image){t.push(["image",e.image.name]);continue}t.push(e.text);const i={};e.fontStack&&(i["text-font"]=["literal",e.fontStack.split(",")]),e.scale&&(i["font-scale"]=e.scale),e.textColor&&(i["text-color"]=["rgba"].concat(e.textColor.toArray())),t.push(i)}return t}}class Ve{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new Ve({name:t,available:!1}):null}serialize(){return["image",this.name]}}function je(t,e,i,r){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[t,e,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[t,e,i,r]:[t,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Ue(t){if(null===t)return!0;if("string"==typeof t)return!0;if("boolean"==typeof t)return!0;if("number"==typeof t)return!0;if(t instanceof Le)return!0;if(t instanceof Re)return!0;if(t instanceof Oe)return!0;if(t instanceof Ve)return!0;if(Array.isArray(t)){for(const e of t)if(!Ue(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!Ue(t[e]))return!1;return!0}return!1}function Ne(t){if(null===t)return ge;if("string"==typeof t)return xe;if("boolean"==typeof t)return ve;if("number"==typeof t)return ye;if(t instanceof Le)return be;if(t instanceof Re)return Ee;if(t instanceof Oe)return Ie;if(t instanceof Ve)return Se;if(Array.isArray(t)){const e=t.length;let i;for(const e of t){const t=Ne(e);if(i){if(i===t)continue;i=Te;break}i=t}return Ae(i||Te,e)}return we}function Ze(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof Le||t instanceof Oe||t instanceof Ve?t.toString():JSON.stringify(t)}class qe{constructor(t,e){this.type=t,this.value=e}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Ue(t[1]))return e.error("invalid value");const i=t[1];let r=Ne(i);const n=e.expectedType;return"array"!==r.kind||0!==r.N||!n||"array"!==n.kind||"number"==typeof n.N&&0!==n.N||(r=n),new qe(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 Le?["rgba"].concat(this.value.toArray()):this.value instanceof Oe?this.value.serialize():this.value}}class Ge{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}}const $e={string:xe,number:ye,boolean:ve,object:we};class We{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let i,r=1;const n=t[0];if("array"===n){let n,s;if(t.length>2){const i=t[1];if("string"!=typeof i||!(i in $e)||"object"===i)return e.error('The item type argument of "array" must be one of string, number, boolean',1);n=$e[i],r++}else n=Te;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);s=t[2],r++}i=Ae(n,s)}else i=$e[n];const s=[];for(;r<t.length;r++){const i=e.parse(t[r],r,Te);if(!i)return null;s.push(i)}return new We(i,s)}evaluate(t){for(let e=0;e<this.args.length;e++){const i=this.args[e].evaluate(t);if(!Me(this.type,Ne(i)))return i;if(e===this.args.length-1)throw new Ge(`Expected value to be of type ${ze(this.type)}, but found ${ze(Ne(i))} instead.`)}return null}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=this.type,e=[t.kind];if("array"===t.kind){const i=t.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){e.push(i.kind);const r=t.N;("number"==typeof r||this.args.length>1)&&e.push(r)}}return e.concat(this.args.map((t=>t.serialize())))}}class Xe{constructor(t){this.type=Ie,this.sections=t}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[1];if(!Array.isArray(i)&&"object"==typeof i)return e.error("First argument must be an image or text section.");const r=[];let n=!1;for(let i=1;i<=t.length-1;++i){const s=t[i];if(n&&"object"==typeof s&&!Array.isArray(s)){n=!1;let t=null;if(s["font-scale"]&&(t=e.parse(s["font-scale"],1,ye),!t))return null;let i=null;if(s["text-font"]&&(i=e.parse(s["text-font"],1,Ae(xe)),!i))return null;let o=null;if(s["text-color"]&&(o=e.parse(s["text-color"],1,be),!o))return null;const a=r[r.length-1];a.scale=t,a.font=i,a.textColor=o}else{const s=e.parse(t[i],1,Te);if(!s)return null;const o=s.type.kind;if("string"!==o&&"value"!==o&&"null"!==o&&"resolvedImage"!==o)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,r.push({content:s,scale:null,font:null,textColor:null})}}return new Xe(r)}evaluate(t){return new Oe(this.sections.map((e=>{const i=e.content.evaluate(t);return Ne(i)===Se?new Fe("",i,null,null,null):new Fe(Ze(i),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor)}outputDefined(){return!1}serialize(){const t=["format"];for(const e of this.sections){t.push(e.content.serialize());const i={};e.scale&&(i["font-scale"]=e.scale.serialize()),e.font&&(i["text-font"]=e.font.serialize()),e.textColor&&(i["text-color"]=e.textColor.serialize()),t.push(i)}return t}}class He{constructor(t){this.type=Se,this.input=t}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,xe);return i?new He(i):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),i=Ve.fromString(e);return i&&t.availableImages&&(i.available=t.availableImages.indexOf(e)>-1),i}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const Ke={"to-boolean":ve,"to-color":be,"to-number":ye,"to-string":xe};class Ye{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[0];if(("to-boolean"===i||"to-string"===i)&&2!==t.length)return e.error("Expected one argument.");const r=Ke[i],n=[];for(let i=1;i<t.length;i++){const r=e.parse(t[i],i,Te);if(!r)return null;n.push(r)}return new Ye(r,n)}evaluate(t){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(t));if("color"===this.type.kind){let e,i;for(const r of this.args){if(e=r.evaluate(t),i=null,e instanceof Le)return e;if("string"==typeof e){const i=t.parseColor(e);if(i)return i}else if(Array.isArray(e)&&(i=e.length<3||e.length>4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:je(e[0],e[1],e[2],e[3]),!i))return new Le(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new Ge(i||`Could not parse color from value '${"string"==typeof e?e:String(JSON.stringify(e))}'`)}if("number"===this.type.kind){let e=null;for(const i of this.args){if(e=i.evaluate(t),null===e)return 0;const r=Number(e);if(!isNaN(r))return r}throw new Ge(`Could not convert ${JSON.stringify(e)} to number.`)}return"formatted"===this.type.kind?Oe.fromString(Ze(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?Ve.fromString(Ze(this.args[0].evaluate(t))):Ze(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new Xe([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new He(this.args[0]).serialize();const t=[`to-${this.type.kind}`];return this.eachChild((e=>{t.push(e.serialize())})),t}}const Je=["Unknown","Point","LineString","Polygon"];class Qe{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Je[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 t=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:i,y:r}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*e-t[0])+this.featureDistanceData.bearing[1]*(r*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=Le.parse(t)),e}}class ti{constructor(t,e,i,r){this.name=t,this.type=e,this._evaluate=i,this.args=r}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((t=>t.serialize())))}static parse(t,e){const i=t[0],r=ti.definitions[i];if(!r)return e.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const n=Array.isArray(r)?r[0]:r.type,s=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,o=s.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let a=null;for(const[r,s]of o){a=new Ti(e.registry,e.path,null,e.scope);const o=[];let l=!1;for(let e=1;e<t.length;e++){const i=t[e],n=Array.isArray(r)?r[e-1]:r.type,s=a.parse(i,1+o.length,n);if(!s){l=!0;break}o.push(s)}if(!l)if(Array.isArray(r)&&r.length!==o.length)a.error(`Expected ${r.length} arguments, but found ${o.length} instead.`);else{for(let t=0;t<o.length;t++){const e=Array.isArray(r)?r[t]:r.type,i=o[t];a.concat(t+1).checkSubtype(e,i.type)}if(0===a.errors.length)return new ti(i,n,s,o)}}if(1===o.length)e.errors.push(...a.errors);else{const i=(o.length?o:s).map((([t])=>{return e=t,Array.isArray(e)?`(${e.map(ze).join(", ")})`:`(${ze(e.type)}...)`;var e})).join(" | "),r=[];for(let i=1;i<t.length;i++){const n=e.parse(t[i],1+r.length);if(!n)return null;r.push(ze(n.type))}e.error(`Expected arguments of type ${i}, but found (${r.join(", ")}) instead.`)}return null}static register(t,e){ti.definitions=e;for(const i in e)t[i]=ti}}class ei{constructor(t,e,i){this.type=Ee,this.locale=i,this.caseSensitive=t,this.diacriticSensitive=e}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const i=t[1];if("object"!=typeof i||Array.isArray(i))return e.error("Collator options argument must be an object.");const r=e.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,ve);if(!r)return null;const n=e.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,ve);if(!n)return null;let s=null;return i.locale&&(s=e.parse(i.locale,1,xe),!s)?null:new ei(r,n,s)}evaluate(t){return new Re(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}serialize(){const t={};return t["case-sensitive"]=this.caseSensitive.serialize(),t["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(t.locale=this.locale.serialize()),["collator",t]}}const ii=8192;function ri(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1])}function ni(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function si(t,e){const i=(180+t[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,n=Math.pow(2,e.z);return[Math.round(i*n*ii),Math.round(r*n*ii)]}function oi(t,e,i){const r=t[0]-e[0],n=t[1]-e[1],s=t[0]-i[0],o=t[1]-i[1];return r*o-s*n==0&&r*s<=0&&n*o<=0}function ai(t,e){let i=!1;for(let o=0,a=e.length;o<a;o++){const a=e[o];for(let e=0,o=a.length;e<o-1;e++){if(oi(t,a[e],a[e+1]))return!1;(n=a[e])[1]>(r=t)[1]!=(s=a[e+1])[1]>r[1]&&r[0]<(s[0]-n[0])*(r[1]-n[1])/(s[1]-n[1])+n[0]&&(i=!i)}}var r,n,s;return i}function li(t,e){for(let i=0;i<e.length;i++)if(ai(t,e[i]))return!0;return!1}function ci(t,e,i,r){const n=r[0]-i[0],s=r[1]-i[1],o=(t[0]-i[0])*s-n*(t[1]-i[1]),a=(e[0]-i[0])*s-n*(e[1]-i[1]);return o>0&&a<0||o<0&&a>0}function hi(t,e,i){for(const c of i)for(let i=0;i<c.length-1;++i)if(0!=(a=[(o=c[i+1])[0]-(s=c[i])[0],o[1]-s[1]])[0]*(l=[(n=e)[0]-(r=t)[0],n[1]-r[1]])[1]-a[1]*l[0]&&ci(r,n,s,o)&&ci(s,o,r,n))return!0;var r,n,s,o,a,l;return!1}function ui(t,e){for(let i=0;i<t.length;++i)if(!ai(t[i],e))return!1;for(let i=0;i<t.length-1;++i)if(hi(t[i],t[i+1],e))return!1;return!0}function pi(t,e){for(let i=0;i<e.length;i++)if(ui(t,e[i]))return!0;return!1}function di(t,e,i){const r=[];for(let n=0;n<t.length;n++){const s=[];for(let r=0;r<t[n].length;r++){const o=si(t[n][r],i);ri(e,o),s.push(o)}r.push(s)}return r}function fi(t,e,i){const r=[];for(let n=0;n<t.length;n++){const s=di(t[n],e,i);r.push(s)}return r}function mi(t,e,i,r){if(t[0]<i[0]||t[0]>i[2]){const e=.5*r;let n=t[0]-i[0]>e?-r:i[0]-t[0]>e?r:0;0===n&&(n=t[0]-i[2]>e?-r:i[2]-t[0]>e?r:0),t[0]+=n}ri(e,t)}function _i(t,e,i,r){const n=Math.pow(2,r.z)*ii,s=[r.x*ii,r.y*ii],o=[];for(const r of t)for(const t of r){const r=[t.x+s[0],t.y+s[1]];mi(r,e,i,n),o.push(r)}return o}function gi(t,e,i,r){const n=Math.pow(2,r.z)*ii,s=[r.x*ii,r.y*ii],o=[];for(const i of t){const t=[];for(const r of i){const i=[r.x+s[0],r.y+s[1]];ri(e,i),t.push(i)}o.push(t)}if(e[2]-e[0]<=n/2){(a=e)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const t of o)for(const r of t)mi(r,e,i,n)}var a;return o}class yi{constructor(t,e){this.type=ve,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Ue(t[1])){const e=t[1];if("FeatureCollection"===e.type)for(let t=0;t<e.features.length;++t){const i=e.features[t].geometry.type;if("Polygon"===i||"MultiPolygon"===i)return new yi(e,e.features[t].geometry)}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new yi(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new yi(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=t.canonicalID();if("Polygon"===e.type){const s=di(e.coordinates,r,n),o=_i(t.geometry(),i,r,n);if(!ni(i,r))return!1;for(const t of o)if(!ai(t,s))return!1}if("MultiPolygon"===e.type){const s=fi(e.coordinates,r,n),o=_i(t.geometry(),i,r,n);if(!ni(i,r))return!1;for(const t of o)if(!li(t,s))return!1}return!0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=t.canonicalID();if("Polygon"===e.type){const s=di(e.coordinates,r,n),o=gi(t.geometry(),i,r,n);if(!ni(i,r))return!1;for(const t of o)if(!ui(t,s))return!1}if("MultiPolygon"===e.type){const s=fi(e.coordinates,r,n),o=gi(t.geometry(),i,r,n);if(!ni(i,r))return!1;for(const t of o)if(!pi(t,s))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}function xi(t){if(t instanceof ti){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof yi)return!1;let e=!0;return t.eachChild((t=>{e&&!xi(t)&&(e=!1)})),e}function vi(t){if(t instanceof ti&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!vi(t)&&(e=!1)})),e}function bi(t,e){if(t instanceof ti&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!bi(t,e)&&(i=!1)})),i}class wi{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const i=t[1];return e.scope.has(i)?new wi(i,e.scope.get(i)):e.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class Ti{constructor(t,e=[],i,r=new _e,n=[]){this.registry=t,this.path=e,this.key=e.map((t=>`[${t}]`)).join(""),this.scope=r,this.errors=n,this.expectedType=i}parse(t,e,i,r,n={}){return e?this.concat(e,i,r)._parse(t,n):this._parse(t,n)}_parse(t,e){function i(t,e,i){return"assert"===i?new We(e,[t]):"coerce"===i?new Ye(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r=t[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(t,this);if(!r)return null;if(this.expectedType){const t=this.expectedType,n=r.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==n.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==n.kind&&"string"!==n.kind){if(this.checkSubtype(t,n))return null}else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"assert")}if(!(r instanceof qe)&&"resolvedImage"!==r.type.kind&&Ei(r)){const t=new Qe;try{r=new qe(r.type,r.evaluate(t))}catch(t){return this.error(t.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,i){const r="number"==typeof t?this.path.concat(t):this.path,n=i?this.scope.concat(i):this.scope;return new Ti(this.registry,r,e||null,n,this.errors)}error(t,...e){const i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new me(i,t))}checkSubtype(t,e){const i=Me(t,e);return i&&this.error(i),i}}function Ei(t){if(t instanceof wi)return Ei(t.boundExpression);if(t instanceof ti&&"error"===t.name)return!1;if(t instanceof ei)return!1;if(t instanceof yi)return!1;const e=t instanceof Ye||t instanceof We;let i=!0;return t.eachChild((t=>{i=e?i&&Ei(t):i&&t instanceof qe})),!!i&&xi(t)&&bi(t,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function Ii(t,e){const i=t.length-1;let r,n,s=0,o=i,a=0;for(;s<=o;)if(a=Math.floor((s+o)/2),r=t[a],n=t[a+1],r<=e){if(a===i||e<n)return a;s=a+1}else{if(!(r>e))throw new Ge("Input is not a number.");o=a-1}return 0}class Si{constructor(t,e,i){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e)}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const i=e.parse(t[1],1,ye);if(!i)return null;const r=[];let n=null;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);for(let i=1;i<t.length;i+=2){const s=1===i?-1/0:t[i],o=t[i+1],a=i,l=i+1;if("number"!=typeof s)return e.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',a);if(r.length&&r[r.length-1][0]>=s)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=e.parse(o,l,n);if(!c)return null;n=n||c.type,r.push([s,c])}return new Si(n,i,r)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const n=e.length;return r>=e[n-1]?i[n-1].evaluate(t):i[Ii(e,r)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){const t=["step",this.input.serialize()];for(let e=0;e<this.labels.length;e++)e>0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t}}function Ai(t,e,i){return t*(1-i)+e*i}var zi=Object.freeze({__proto__:null,number:Ai,color:function(t,e,i){return new Le(Ai(t.r,e.r,i),Ai(t.g,e.g,i),Ai(t.b,e.b,i),Ai(t.a,e.a,i))},array:function(t,e,i){return t.map(((t,r)=>Ai(t,e[r],i)))}});const Ci=.95047,Mi=1.08883,ki=4/29,Pi=6/29,Di=3*Pi*Pi,Bi=Math.PI/180,Li=180/Math.PI;function Ri(t){return t>.008856451679035631?Math.pow(t,1/3):t/Di+ki}function Fi(t){return t>Pi?t*t*t:Di*(t-ki)}function Oi(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Vi(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function ji(t){const e=Vi(t.r),i=Vi(t.g),r=Vi(t.b),n=Ri((.4124564*e+.3575761*i+.1804375*r)/Ci),s=Ri((.2126729*e+.7151522*i+.072175*r)/1);return{l:116*s-16,a:500*(n-s),b:200*(s-Ri((.0193339*e+.119192*i+.9503041*r)/Mi)),alpha:t.a}}function Ui(t){let e=(t.l+16)/116,i=isNaN(t.a)?e:e+t.a/500,r=isNaN(t.b)?e:e-t.b/200;return e=1*Fi(e),i=Ci*Fi(i),r=Mi*Fi(r),new Le(Oi(3.2404542*i-1.5371385*e-.4985314*r),Oi(-.969266*i+1.8760108*e+.041556*r),Oi(.0556434*i-.2040259*e+1.0572252*r),t.alpha)}function Ni(t,e,i){const r=e-t;return t+i*(r>180||r<-180?r-360*Math.round(r/360):r)}const Zi={forward:ji,reverse:Ui,interpolate:function(t,e,i){return{l:Ai(t.l,e.l,i),a:Ai(t.a,e.a,i),b:Ai(t.b,e.b,i),alpha:Ai(t.alpha,e.alpha,i)}}},qi={forward:function(t){const{l:e,a:i,b:r}=ji(t),n=Math.atan2(r,i)*Li;return{h:n<0?n+360:n,c:Math.sqrt(i*i+r*r),l:e,alpha:t.a}},reverse:function(t){const e=t.h*Bi,i=t.c;return Ui({l:t.l,a:Math.cos(e)*i,b:Math.sin(e)*i,alpha:t.alpha})},interpolate:function(t,e,i){return{h:Ni(t.h,e.h,i),c:Ai(t.c,e.c,i),l:Ai(t.l,e.l,i),alpha:Ai(t.alpha,e.alpha,i)}}};var Gi=Object.freeze({__proto__:null,lab:Zi,hcl:qi});class $i{constructor(t,e,i,r,n){this.type=t,this.operator=e,this.interpolation=i,this.input=r,this.labels=[],this.outputs=[];for(const[t,e]of n)this.labels.push(t),this.outputs.push(e)}static interpolationFactor(t,e,i,r){let s=0;if("exponential"===t.name)s=Wi(e,t.base,i,r);else if("linear"===t.name)s=Wi(e,1,i,r);else if("cubic-bezier"===t.name){const o=t.controlPoints;s=new n(o[0],o[1],o[2],o[3]).solve(Wi(e,1,i,r))}return s}static parse(t,e){let[i,r,n,...s]=t;if(!Array.isArray(r)||0===r.length)return e.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const t=r[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:t}}else{if("cubic-bezier"!==r[0])return e.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const t=r.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:t}}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(n=e.parse(n,2,ye),!n)return null;const o=[];let a=null;"interpolate-hcl"===i||"interpolate-lab"===i?a=be:e.expectedType&&"value"!==e.expectedType.kind&&(a=e.expectedType);for(let t=0;t<s.length;t+=2){const i=s[t],r=s[t+1],n=t+3,l=t+4;if("number"!=typeof i)return e.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',n);if(o.length&&o[o.length-1][0]>=i)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',n);const c=e.parse(r,l,a);if(!c)return null;a=a||c.type,o.push([i,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new $i(a,i,r,n,o):e.error(`Type ${ze(a)} is not interpolatable.`)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const n=e.length;if(r>=e[n-1])return i[n-1].evaluate(t);const s=Ii(e,r),o=$i.interpolationFactor(this.interpolation,r,e[s],e[s+1]),a=i[s].evaluate(t),l=i[s+1].evaluate(t);return"interpolate"===this.operator?zi[this.type.kind.toLowerCase()](a,l,o):"interpolate-hcl"===this.operator?qi.reverse(qi.interpolate(qi.forward(a),qi.forward(l),o)):Zi.reverse(Zi.interpolate(Zi.forward(a),Zi.forward(l),o))}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){let t;t="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 e=[this.operator,t,this.input.serialize()];for(let t=0;t<this.labels.length;t++)e.push(this.labels[t],this.outputs[t].serialize());return e}}function Wi(t,e,i,r){const n=r-i,s=t-i;return 0===n?0:1===e?s/n:(Math.pow(e,s)-1)/(Math.pow(e,n)-1)}class Xi{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expectected at least one argument.");let i=null;const r=e.expectedType;r&&"value"!==r.kind&&(i=r);const n=[];for(const r of t.slice(1)){const t=e.parse(r,1+n.length,i,void 0,{typeAnnotation:"omit"});if(!t)return null;i=i||t.type,n.push(t)}const s=r&&n.some((t=>Me(r,t.type)));return new Xi(s?Te:i,n)}evaluate(t){let e,i=null,r=0;for(const n of this.args){if(r++,i=n.evaluate(t),i&&i instanceof Ve&&!i.available&&(e||(e=i),i=null,r===this.args.length))return e;if(null!==i)break}return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=["coalesce"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class Hi{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const i=[];for(let r=1;r<t.length-1;r+=2){const n=t[r];if("string"!=typeof n)return e.error(`Expected string, but found ${typeof n} instead.`,r);if(/[^a-zA-Z0-9_]/.test(n))return e.error("Variable names must contain only alphanumeric characters or '_'.",r);const s=e.parse(t[r+1],r+1);if(!s)return null;i.push([n,s])}const r=e.parse(t[t.length-1],t.length-1,e.expectedType,i);return r?new Hi(i,r):null}outputDefined(){return this.result.outputDefined()}serialize(){const t=["let"];for(const[e,i]of this.bindings)t.push(e,i.serialize());return t.push(this.result.serialize()),t}}class Ki{constructor(t,e,i){this.type=t,this.index=e,this.input=i}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,ye),r=e.parse(t[2],2,Ae(e.expectedType||Te));return i&&r?new Ki(r.type.itemType,i,r):null}evaluate(t){const e=this.index.evaluate(t),i=this.input.evaluate(t);if(e<0)throw new Ge(`Array index out of bounds: ${e} < 0.`);if(e>=i.length)throw new Ge(`Array index out of bounds: ${e} > ${i.length-1}.`);if(e!==Math.floor(e))throw new Ge(`Array index must be an integer, but found ${e} instead.`);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class Yi{constructor(t,e){this.type=ve,this.needle=t,this.haystack=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Te),r=e.parse(t[2],2,Te);return i&&r?ke(i.type,[ve,xe,ye,ge,Te])?new Yi(i,r):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${ze(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(null==i)return!1;if(!Pe(e,["boolean","string","number","null"]))throw new Ge(`Expected first argument to be of type boolean, string, number or null, but found ${ze(Ne(e))} instead.`);if(!Pe(i,["string","array"]))throw new Ge(`Expected second argument to be of type array or string, but found ${ze(Ne(i))} instead.`);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class Ji{constructor(t,e,i){this.type=ye,this.needle=t,this.haystack=e,this.fromIndex=i}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Te),r=e.parse(t[2],2,Te);if(!i||!r)return null;if(!ke(i.type,[ve,xe,ye,ge,Te]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${ze(i.type)} instead`);if(4===t.length){const n=e.parse(t[3],3,ye);return n?new Ji(i,r,n):null}return new Ji(i,r)}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!Pe(e,["boolean","string","number","null"]))throw new Ge(`Expected first argument to be of type boolean, string, number or null, but found ${ze(Ne(e))} instead.`);if(!Pe(i,["string","array"]))throw new Ge(`Expected second argument to be of type array or string, but found ${ze(Ne(i))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(t);return i.indexOf(e,r)}return i.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class Qi{constructor(t,e,i,r,n,s){this.inputType=t,this.type=e,this.input=i,this.cases=r,this.outputs=n,this.otherwise=s}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let i,r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const n={},s=[];for(let o=2;o<t.length-1;o+=2){let a=t[o];const l=t[o+1];Array.isArray(a)||(a=[a]);const c=e.concat(o);if(0===a.length)return c.error("Expected at least one branch label.");for(const t of a){if("number"!=typeof t&&"string"!=typeof t)return c.error("Branch labels must be numbers or strings.");if("number"==typeof t&&Math.abs(t)>Number.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,Ne(t)))return null}else i=Ne(t);if(void 0!==n[String(t)])return c.error("Branch labels must be unique.");n[String(t)]=s.length}const h=e.parse(l,o,r);if(!h)return null;r=r||h.type,s.push(h)}const o=e.parse(t[1],1,Te);if(!o)return null;const a=e.parse(t[t.length-1],t.length-1,r);return a?"value"!==o.type.kind&&e.concat(1).checkSubtype(i,o.type)?null:new Qi(i,r,o,n,s,a):null}evaluate(t){const e=this.input.evaluate(t);return(Ne(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],e=Object.keys(this.cases).sort(),i=[],r={};for(const t of e){const e=r[this.cases[t]];void 0===e?(r[this.cases[t]]=i.length,i.push([this.cases[t],[t]])):i[e][1].push(t)}const n=t=>"number"===this.inputType.kind?Number(t):t;for(const[e,r]of i)t.push(1===r.length?n(r[0]):r.map(n)),t.push(this.outputs[e].serialize());return t.push(this.otherwise.serialize()),t}}class tr{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let i;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);const r=[];for(let n=1;n<t.length-1;n+=2){const s=e.parse(t[n],n,ve);if(!s)return null;const o=e.parse(t[n+1],n+1,i);if(!o)return null;r.push([s,o]),i=i||o.type}const n=e.parse(t[t.length-1],t.length-1,i);return n?new tr(i,r,n):null}evaluate(t){for(const[e,i]of this.branches)if(e.evaluate(t))return i.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(const[e,i]of this.branches)t(e),t(i);t(this.otherwise)}outputDefined(){return this.branches.every((([t,e])=>e.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class er{constructor(t,e,i,r){this.type=t,this.input=e,this.beginIndex=i,this.endIndex=r}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Te),r=e.parse(t[2],2,ye);if(!i||!r)return null;if(!ke(i.type,[Ae(Te),xe,Te]))return e.error(`Expected first argument to be of type array or string, but found ${ze(i.type)} instead`);if(4===t.length){const n=e.parse(t[3],3,ye);return n?new er(i.type,i,r,n):null}return new er(i.type,i,r)}evaluate(t){const e=this.input.evaluate(t),i=this.beginIndex.evaluate(t);if(!Pe(e,["string","array"]))throw new Ge(`Expected first argument to be of type array or string, but found ${ze(Ne(e))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(t);return e.slice(i,r)}return e.slice(i)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function ir(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function rr(t,e,i,r){return 0===r.compare(e,i)}function nr(t,e,i){const r="=="!==t&&"!="!==t;return class n{constructor(t,e,i){this.type=ve,this.lhs=t,this.rhs=e,this.collator=i,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const i=t[0];let s=e.parse(t[1],1,Te);if(!s)return null;if(!ir(i,s.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${ze(s.type)}'.`);let o=e.parse(t[2],2,Te);if(!o)return null;if(!ir(i,o.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${ze(o.type)}'.`);if(s.type.kind!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return e.error(`Cannot compare types '${ze(s.type)}' and '${ze(o.type)}'.`);r&&("value"===s.type.kind&&"value"!==o.type.kind?s=new We(o.type,[s]):"value"!==s.type.kind&&"value"===o.type.kind&&(o=new We(s.type,[o])));let a=null;if(4===t.length){if("string"!==s.type.kind&&"string"!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,Ee),!a)return null}return new n(s,o,a)}evaluate(n){const s=this.lhs.evaluate(n),o=this.rhs.evaluate(n);if(r&&this.hasUntypedArgument){const e=Ne(s),i=Ne(o);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new Ge(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const t=Ne(s),i=Ne(o);if("string"!==t.kind||"string"!==i.kind)return e(n,s,o)}return this.collator?i(n,s,o,this.collator.evaluate(n)):e(n,s,o)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}serialize(){const e=[t];return this.eachChild((t=>{e.push(t.serialize())})),e}}}const sr=nr("==",(function(t,e,i){return e===i}),rr),or=nr("!=",(function(t,e,i){return e!==i}),(function(t,e,i,r){return!rr(0,e,i,r)})),ar=nr("<",(function(t,e,i){return e<i}),(function(t,e,i,r){return r.compare(e,i)<0})),lr=nr(">",(function(t,e,i){return e>i}),(function(t,e,i,r){return r.compare(e,i)>0})),cr=nr("<=",(function(t,e,i){return e<=i}),(function(t,e,i,r){return r.compare(e,i)<=0})),hr=nr(">=",(function(t,e,i){return e>=i}),(function(t,e,i,r){return r.compare(e,i)>=0}));class ur{constructor(t,e,i,r,n){this.type=xe,this.number=t,this.locale=e,this.currency=i,this.minFractionDigits=r,this.maxFractionDigits=n}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,ye);if(!i)return null;const r=t[2];if("object"!=typeof r||Array.isArray(r))return e.error("NumberFormat options argument must be an object.");let n=null;if(r.locale&&(n=e.parse(r.locale,1,xe),!n))return null;let s=null;if(r.currency&&(s=e.parse(r.currency,1,xe),!s))return null;let o=null;if(r["min-fraction-digits"]&&(o=e.parse(r["min-fraction-digits"],1,ye),!o))return null;let a=null;return r["max-fraction-digits"]&&(a=e.parse(r["max-fraction-digits"],1,ye),!a)?null:new ur(i,n,s,o,a)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class pr{constructor(t){this.type=ye,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=e.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?e.error(`Expected argument of type string or array, but found ${ze(i.type)} instead.`):new pr(i):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new Ge(`Expected value to be of type string or array, but found ${ze(Ne(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){const t=["length"];return this.eachChild((e=>{t.push(e.serialize())})),t}}const dr={"==":sr,"!=":or,">":lr,"<":ar,">=":hr,"<=":cr,array:We,at:Ki,boolean:We,case:tr,coalesce:Xi,collator:ei,format:Xe,image:He,in:Yi,"index-of":Ji,interpolate:$i,"interpolate-hcl":$i,"interpolate-lab":$i,length:pr,let:Hi,literal:qe,match:Qi,number:We,"number-format":ur,object:We,slice:er,step:Si,string:We,"to-boolean":Ye,"to-color":Ye,"to-number":Ye,"to-string":Ye,var:wi,within:yi};function fr(t,[e,i,r,n]){e=e.evaluate(t),i=i.evaluate(t),r=r.evaluate(t);const s=n?n.evaluate(t):1,o=je(e,i,r,s);if(o)throw new Ge(o);return new Le(e/255*s,i/255*s,r/255*s,s)}function mr(t,e){return t in e}function _r(t,e){const i=e[t];return void 0===i?null:i}function gr(t){return{type:t}}function yr(t){return{result:"success",value:t}}function xr(t){return{result:"error",value:t}}function vr(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function br(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function wr(t){return!!t.expression&&t.expression.interpolated}function Tr(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Er(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Ir(t){return t}function Sr(t,e){const i="color"===e.type,r=t.stops&&"object"==typeof t.stops[0][0],n=r||!(r||void 0!==t.property),s=t.type||(wr(e)?"exponential":"interval");if(i&&((t=pe({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],Le.parse(t[1])]))),t.default=Le.parse(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!Gi[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let o,a,l;if("exponential"===s)o=Mr;else if("interval"===s)o=Cr;else if("categorical"===s){o=zr,a=Object.create(null);for(const e of t.stops)a[e[0]]=e[1];l=typeof t.stops[0][0]}else{if("identity"!==s)throw new Error(`Unknown function type "${s}"`);o=kr}if(r){const i={},r=[];for(let e=0;e<t.stops.length;e++){const n=t.stops[e],s=n[0].zoom;void 0===i[s]&&(i[s]={zoom:s,type:t.type,property:t.property,default:t.default,stops:[]},r.push(s)),i[s].stops.push([n[0].value,n[1]])}const n=[];for(const t of r)n.push([i[t].zoom,Sr(i[t],e)]);const s={name:"linear"};return{kind:"composite",interpolationType:s,interpolationFactor:$i.interpolationFactor.bind(void 0,s),zoomStops:n.map((t=>t[0])),evaluate:({zoom:i},r)=>Mr({stops:n,base:t.base},e,i).evaluate(i,r)}}if(n){const i="exponential"===s?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:$i.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:i})=>o(t,e,i,a,l)}}return{kind:"source",evaluate(i,r){const n=r&&r.properties?r.properties[t.property]:void 0;return void 0===n?Ar(t.default,e.default):o(t,e,n,a,l)}}}function Ar(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function zr(t,e,i,r,n){return Ar(typeof i===n?r[i]:void 0,t.default,e.default)}function Cr(t,e,i){if("number"!==Tr(i))return Ar(t.default,e.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[r-1][0])return t.stops[r-1][1];const n=Ii(t.stops.map((t=>t[0])),i);return t.stops[n][1]}function Mr(t,e,i){const r=void 0!==t.base?t.base:1;if("number"!==Tr(i))return Ar(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[n-1][0])return t.stops[n-1][1];const s=Ii(t.stops.map((t=>t[0])),i),o=function(t,e,i,r){const n=r-i,s=t-i;return 0===n?0:1===e?s/n:(Math.pow(e,s)-1)/(Math.pow(e,n)-1)}(i,r,t.stops[s][0],t.stops[s+1][0]),a=t.stops[s][1],l=t.stops[s+1][1];let c=zi[e.type]||Ir;if(t.colorSpace&&"rgb"!==t.colorSpace){const e=Gi[t.colorSpace];c=(t,i)=>e.reverse(e.interpolate(e.forward(t),e.forward(i),o))}return"function"==typeof a.evaluate?{evaluate(...t){const e=a.evaluate.apply(void 0,t),i=l.evaluate.apply(void 0,t);if(void 0!==e&&void 0!==i)return c(e,i,o)}}:c(a,l,o)}function kr(t,e,i){return"color"===e.type?i=Le.parse(i):"formatted"===e.type?i=Oe.fromString(i.toString()):"resolvedImage"===e.type?i=Ve.fromString(i.toString()):Tr(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0),Ar(i,t.default,e.default)}ti.register(dr,{error:[{kind:"error"},[xe],(t,[e])=>{throw new Ge(e.evaluate(t))}],typeof:[xe,[Te],(t,[e])=>ze(Ne(e.evaluate(t)))],"to-rgba":[Ae(ye,4),[be],(t,[e])=>e.evaluate(t).toArray()],rgb:[be,[ye,ye,ye],fr],rgba:[be,[ye,ye,ye,ye],fr],has:{type:ve,overloads:[[[xe],(t,[e])=>mr(e.evaluate(t),t.properties())],[[xe,we],(t,[e,i])=>mr(e.evaluate(t),i.evaluate(t))]]},get:{type:Te,overloads:[[[xe],(t,[e])=>_r(e.evaluate(t),t.properties())],[[xe,we],(t,[e,i])=>_r(e.evaluate(t),i.evaluate(t))]]},"feature-state":[Te,[xe],(t,[e])=>_r(e.evaluate(t),t.featureState||{})],properties:[we,[],t=>t.properties()],"geometry-type":[xe,[],t=>t.geometryType()],id:[Te,[],t=>t.id()],zoom:[ye,[],t=>t.globals.zoom],pitch:[ye,[],t=>t.globals.pitch||0],"distance-from-center":[ye,[],t=>t.distanceFromCenter()],"heatmap-density":[ye,[],t=>t.globals.heatmapDensity||0],"line-progress":[ye,[],t=>t.globals.lineProgress||0],"sky-radial-progress":[ye,[],t=>t.globals.skyRadialProgress||0],accumulated:[Te,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[ye,gr(ye),(t,e)=>{let i=0;for(const r of e)i+=r.evaluate(t);return i}],"*":[ye,gr(ye),(t,e)=>{let i=1;for(const r of e)i*=r.evaluate(t);return i}],"-":{type:ye,overloads:[[[ye,ye],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[ye],(t,[e])=>-e.evaluate(t)]]},"/":[ye,[ye,ye],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[ye,[ye,ye],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[ye,[],()=>Math.LN2],pi:[ye,[],()=>Math.PI],e:[ye,[],()=>Math.E],"^":[ye,[ye,ye],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[ye,[ye],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[ye,[ye],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[ye,[ye],(t,[e])=>Math.log(e.evaluate(t))],log2:[ye,[ye],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[ye,[ye],(t,[e])=>Math.sin(e.evaluate(t))],cos:[ye,[ye],(t,[e])=>Math.cos(e.evaluate(t))],tan:[ye,[ye],(t,[e])=>Math.tan(e.evaluate(t))],asin:[ye,[ye],(t,[e])=>Math.asin(e.evaluate(t))],acos:[ye,[ye],(t,[e])=>Math.acos(e.evaluate(t))],atan:[ye,[ye],(t,[e])=>Math.atan(e.evaluate(t))],min:[ye,gr(ye),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[ye,gr(ye),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[ye,[ye],(t,[e])=>Math.abs(e.evaluate(t))],round:[ye,[ye],(t,[e])=>{const i=e.evaluate(t);return i<0?-Math.round(-i):Math.round(i)}],floor:[ye,[ye],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[ye,[ye],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[ve,[xe,Te],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[ve,[Te],(t,[e])=>t.id()===e.value],"filter-type-==":[ve,[xe],(t,[e])=>t.geometryType()===e.value],"filter-<":[ve,[xe,Te],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r<n}],"filter-id-<":[ve,[Te],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i<r}],"filter->":[ve,[xe,Te],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r>n}],"filter-id->":[ve,[Te],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>r}],"filter-<=":[ve,[xe,Te],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r<=n}],"filter-id-<=":[ve,[Te],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i<=r}],"filter->=":[ve,[xe,Te],(t,[e,i])=>{const r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r>=n}],"filter-id->=":[ve,[Te],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>=r}],"filter-has":[ve,[Te],(t,[e])=>e.value in t.properties()],"filter-has-id":[ve,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[ve,[Ae(xe)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[ve,[Ae(Te)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[ve,[xe,Ae(Te)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[ve,[xe,Ae(Te)],(t,[e,i])=>function(t,e,i,r){for(;i<=r;){const n=i+r>>1;if(e[n]===t)return!0;e[n]>t?r=n-1:i=n+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:ve,overloads:[[[ve,ve],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[gr(ve),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:ve,overloads:[[[ve,ve],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[gr(ve),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[ve,[ve],(t,[e])=>!e.evaluate(t)],"is-supported-script":[ve,[xe],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[xe,[xe],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[xe,[xe],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[xe,gr(Te),(t,e)=>e.map((e=>Ze(e.evaluate(t)))).join("")],"resolved-locale":[xe,[Ee],(t,[e])=>e.evaluate(t).resolvedLocale()]});class Pr{constructor(t,e){this.expression=t,this._warningHistory={},this._evaluator=new Qe,this._defaultValue=e?function(t){return"color"===t.type&&Er(t.default)?new Le(0,0,0,0):"color"===t.type?Le.parse(t.default)||null:void 0===t.default?null:t.default}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null}evaluateWithoutErrorHandling(t,e,i,r,n,s,o,a){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=i,this._evaluator.canonical=r,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=s,this._evaluator.featureTileCoord=o||null,this._evaluator.featureDistanceData=a||null,this.expression.evaluate(this._evaluator)}evaluate(t,e,i,r,n,s,o,a){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=s||null,this._evaluator.featureTileCoord=o||null,this._evaluator.featureDistanceData=a||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new Ge(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function Dr(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in dr}function Br(t,e){const i=new Ti(dr,[],e?function(t){const e={color:be,string:xe,number:ye,enum:xe,boolean:ve,formatted:Ie,resolvedImage:Se};return"array"===t.type?Ae(e[t.value]||Te,t.length):e[t.type]}(e):void 0),r=i.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return r?yr(new Pr(r,e)):xr(i.errors)}class Lr{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!vi(e.expression)}evaluateWithoutErrorHandling(t,e,i,r,n,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,n,s)}evaluate(t,e,i,r,n,s){return this._styleExpression.evaluate(t,e,i,r,n,s)}}class Rr{constructor(t,e,i,r){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!vi(e.expression),this.interpolationType=r}evaluateWithoutErrorHandling(t,e,i,r,n,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,n,s)}evaluate(t,e,i,r,n,s){return this._styleExpression.evaluate(t,e,i,r,n,s)}interpolationFactor(t,e,i){return this.interpolationType?$i.interpolationFactor(this.interpolationType,t,e,i):0}}function Fr(t,e){if("error"===(t=Br(t,e)).result)return t;const i=t.value.expression,r=xi(i);if(!r&&!vr(e))return xr([new me("","data expressions not supported")]);const n=bi(i,["zoom","pitch","distance-from-center"]);if(!n&&!br(e))return xr([new me("","zoom expressions not supported")]);const s=Vr(i);return s||n?s instanceof me?xr([s]):s instanceof $i&&!wr(e)?xr([new me("",'"interpolate" expressions cannot be used with this property')]):yr(s?new Rr(r?"camera":"composite",t.value,s.labels,s instanceof $i?s.interpolation:void 0):new Lr(r?"constant":"source",t.value)):xr([new me("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Or{constructor(t,e){this._parameters=t,this._specification=e,pe(this,Sr(this._parameters,this._specification))}static deserialize(t){return new Or(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function Vr(t){let e=null;if(t instanceof Hi)e=Vr(t.result);else if(t instanceof Xi){for(const i of t.args)if(e=Vr(i),e)break}else(t instanceof Si||t instanceof $i)&&t.input instanceof ti&&"zoom"===t.input.name&&(e=t);return e instanceof me||t.eachChild((t=>{const i=Vr(t);i instanceof me?e=i:!e&&i?e=new me("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&i&&e!==i&&(e=new me("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}class jr{constructor(t,e,i,r){this.message=(t?`${t}: `:"")+i,r&&(this.identifier=r),null!=e&&e.__line__&&(this.line=e.__line__)}}function Ur(t){const e=t.key,i=t.value,r=t.valueSpec||{},n=t.objectElementValidators||{},s=t.style,o=t.styleSpec;let a=[];const l=Tr(i);if("object"!==l)return[new jr(e,i,`object expected, ${l} found`)];for(const t in i){const l=t.split(".")[0],c=r[l]||r["*"];let h;if(n[l])h=n[l];else if(r[l])h=bn;else if(n["*"])h=n["*"];else{if(!r["*"]){a.push(new jr(e,i[t],`unknown property "${t}"`));continue}h=bn}a=a.concat(h({key:(e?`${e}.`:e)+t,value:i[t],valueSpec:c,style:s,styleSpec:o,object:i,objectKey:t},i))}for(const t in r)n[t]||r[t].required&&void 0===r[t].default&&void 0===i[t]&&a.push(new jr(e,i,`missing required property "${t}"`));return a}function Nr(t){const e=t.value,i=t.valueSpec,r=t.style,n=t.styleSpec,s=t.key,o=t.arrayElementValidator||bn;if("array"!==Tr(e))return[new jr(s,e,`array expected, ${Tr(e)} found`)];if(i.length&&e.length!==i.length)return[new jr(s,e,`array length ${i.length} expected, length ${e.length} found`)];if(i["min-length"]&&e.length<i["min-length"])return[new jr(s,e,`array length at least ${i["min-length"]} expected, length ${e.length} found`)];let a={type:i.value,values:i.values,minimum:i.minimum,maximum:i.maximum};n.$version<7&&(a.function=i.function),"object"===Tr(i.value)&&(a=i.value);let l=[];for(let t=0;t<e.length;t++)l=l.concat(o({array:e,arrayIndex:t,value:e[t],valueSpec:a,style:r,styleSpec:n,key:`${s}[${t}]`}));return l}function Zr(t){const e=t.key,i=t.value,r=t.valueSpec;let n=Tr(i);if("number"===n&&i!=i&&(n="NaN"),"number"!==n)return[new jr(e,i,`number expected, ${n} found`)];if("minimum"in r){let n=r.minimum;if("array"===Tr(r.minimum)&&(n=r.minimum[t.arrayIndex]),i<n)return[new jr(e,i,`${i} is less than the minimum value ${n}`)]}if("maximum"in r){let n=r.maximum;if("array"===Tr(r.maximum)&&(n=r.maximum[t.arrayIndex]),i>n)return[new jr(e,i,`${i} is greater than the maximum value ${n}`)]}return[]}function qr(t){const e=t.valueSpec,i=de(t.value.type);let r,n,s,o={};const a="categorical"!==i&&void 0===t.value.property,l=!a,c="array"===Tr(t.value.stops)&&"array"===Tr(t.value.stops[0])&&"object"===Tr(t.value.stops[0][0]),h=Ur({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===i)return[new jr(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const r=t.value;return e=e.concat(Nr({key:t.key,value:r,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:u})),"array"===Tr(r)&&0===r.length&&e.push(new jr(t.key,r,"array must have at least one stop")),e},default:function(t){return bn({key:t.key,value:t.value,valueSpec:e,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===i&&a&&h.push(new jr(t.key,t.value,'missing required property "property"')),"identity"===i||t.value.stops||h.push(new jr(t.key,t.value,'missing required property "stops"')),"exponential"===i&&t.valueSpec.expression&&!wr(t.valueSpec)&&h.push(new jr(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!vr(t.valueSpec)?h.push(new jr(t.key,t.value,"property functions not supported")):a&&!br(t.valueSpec)&&h.push(new jr(t.key,t.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==t.value.property||h.push(new jr(t.key,t.value,'"property" property is required')),h;function u(t){let i=[];const r=t.value,a=t.key;if("array"!==Tr(r))return[new jr(a,r,`array expected, ${Tr(r)} found`)];if(2!==r.length)return[new jr(a,r,`array length 2 expected, length ${r.length} found`)];if(c){if("object"!==Tr(r[0]))return[new jr(a,r,`object expected, ${Tr(r[0])} found`)];if(void 0===r[0].zoom)return[new jr(a,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new jr(a,r,"object stop key must have value")];if(s&&s>de(r[0].zoom))return[new jr(a,r[0].zoom,"stop zoom values must appear in ascending order")];de(r[0].zoom)!==s&&(s=de(r[0].zoom),n=void 0,o={}),i=i.concat(Ur({key:`${a}[0]`,value:r[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:Zr,value:p}}))}else i=i.concat(p({key:`${a}[0]`,value:r[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},r));return Dr(fe(r[1]))?i.concat([new jr(`${a}[1]`,r[1],"expressions are not allowed in function stops.")]):i.concat(bn({key:`${a}[1]`,value:r[1],valueSpec:e,style:t.style,styleSpec:t.styleSpec}))}function p(t,s){const a=Tr(t.value),l=de(t.value),c=null!==t.value?t.value:s;if(r){if(a!==r)return[new jr(t.key,c,`${a} stop domain type must match previous stop domain type ${r}`)]}else r=a;if("number"!==a&&"string"!==a&&"boolean"!==a)return[new jr(t.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let r=`number expected, ${a} found`;return vr(e)&&void 0===i&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new jr(t.key,c,r)]}return"categorical"!==i||"number"!==a||isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===a&&void 0!==n&&l<n?[new jr(t.key,c,"stop domain values must appear in ascending order")]:(n=l,"categorical"===i&&l in o?[new jr(t.key,c,"stop domain values must be unique")]:(o[l]=!0,[])):[new jr(t.key,c,`integer expected, found ${l}`)]}}function Gr(t){const e=("property"===t.expressionContext?Fr:Br)(fe(t.value),t.valueSpec);if("error"===e.result)return e.value.map((e=>new jr(`${t.key}${e.key}`,t.value,e.message)));const i=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!i.outputDefined())return[new jr(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!vi(i))return[new jr(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return $r(i,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!bi(i,["zoom","feature-state"]))return[new jr(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!xi(i))return[new jr(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function $r(t,e){const i=new Set(["zoom","feature-state","pitch","distance-from-center"]);for(const t of e.valueSpec.expression.parameters)i.delete(t);if(0===i.size)return[];const r=[];return t instanceof ti&&i.has(t.name)?[new jr(e.key,e.value,`["${t.name}"] expression is not supported in a filter for a ${e.object.type} layer with id: ${e.object.id}`)]:(t.eachChild((t=>{r.push(...$r(t,e))})),r)}function Wr(t){const e=t.key,i=t.value,r=t.valueSpec,n=[];return Array.isArray(r.values)?-1===r.values.indexOf(de(i))&&n.push(new jr(e,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(de(i))&&n.push(new jr(e,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),n}function Xr(t){if(!0===t||!1===t)return!0;if(!Array.isArray(t)||0===t.length)return!1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!Xr(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}function Hr(t,e="fill"){if(null==t)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Xr(t)||(t=rn(t));const i=t;let r=!0;try{r=function(t){if(!Jr(t))return t;let e=fe(t);return Yr(e),e=Kr(e),e}(i)}catch(t){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=ue[`filter_${e}`],s=Br(r,n);let o=null;if("error"===s.result)throw new Error(s.value.map((t=>`${t.key}: ${t.message}`)).join(", "));o=(t,e,i)=>s.value.evaluate(t,e,{},i);let a=null,l=null;if(r!==i){const t=Br(i,n);if("error"===t.result)throw new Error(t.value.map((t=>`${t.key}: ${t.message}`)).join(", "));a=(e,i,r,n,s)=>t.value.evaluate(e,i,{},r,void 0,void 0,n,s),l=!xi(t.value.expression)}return o=o,{filter:o,dynamicFilter:a||void 0,needGeometry:en(r),needFeature:!!l}}function Kr(t){if(!Array.isArray(t))return t;const e=function(t){if(Qr.has(t[0]))for(let e=1;e<t.length;e++)if(Jr(t[e]))return!0;return t}(t);return!0===e?e:e.map((t=>Kr(t)))}function Yr(t){let e=!1;const i=[];if("case"===t[0]){for(let r=1;r<t.length-1;r+=2)e=e||Jr(t[r]),i.push(t[r+1]);i.push(t[t.length-1])}else if("match"===t[0]){e=e||Jr(t[1]);for(let e=2;e<t.length-1;e+=2)i.push(t[e+1]);i.push(t[t.length-1])}else if("step"===t[0]){e=e||Jr(t[1]);for(let e=1;e<t.length-1;e+=2)i.push(t[e+1])}e&&(t.length=0,t.push("any",...i));for(let e=1;e<t.length;e++)Yr(t[e])}function Jr(t){if(!Array.isArray(t))return!1;if("pitch"===(e=t[0])||"distance-from-center"===e)return!0;var e;for(let e=1;e<t.length;e++)if(Jr(t[e]))return!0;return!1}const Qr=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function tn(t,e){return t<e?-1:t>e?1:0}function en(t){if(!Array.isArray(t))return!1;if("within"===t[0])return!0;for(let e=1;e<t.length;e++)if(en(t[e]))return!0;return!1}function rn(t){if(!t)return!0;const e=t[0];return t.length<=1?"any"!==e:"=="===e?nn(t[1],t[2],"=="):"!="===e?an(nn(t[1],t[2],"==")):"<"===e||">"===e||"<="===e||">="===e?nn(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(rn))):"all"===e?["all"].concat(t.slice(1).map(rn)):"none"===e?["all"].concat(t.slice(1).map(rn).map(an)):"in"===e?sn(t[1],t.slice(2)):"!in"===e?an(sn(t[1],t.slice(2))):"has"===e?on(t[1]):"!has"===e?an(on(t[1])):"within"!==e||t;var i}function nn(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function sn(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(tn)]]:["filter-in-small",t,["literal",e]]}}function on(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function an(t){return["!",t]}function ln(t){if(Xr(fe(t.value))){const e=fe(t.layerType);return Gr(pe({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${e||"fill"}`]}))}return cn(t)}function cn(t){const e=t.value,i=t.key;if("array"!==Tr(e))return[new jr(i,e,`array expected, ${Tr(e)} found`)];const r=t.styleSpec;let n,s=[];if(e.length<1)return[new jr(i,e,"filter array must have at least 1 element")];switch(s=s.concat(Wr({key:`${i}[0]`,value:e[0],valueSpec:r.filter_operator,style:t.style,styleSpec:t.styleSpec})),de(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===de(e[1])&&s.push(new jr(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&s.push(new jr(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(n=Tr(e[1]),"string"!==n&&s.push(new jr(`${i}[1]`,e[1],`string expected, ${n} found`)));for(let o=2;o<e.length;o++)n=Tr(e[o]),"$type"===de(e[1])?s=s.concat(Wr({key:`${i}[${o}]`,value:e[o],valueSpec:r.geometry_type,style:t.style,styleSpec:t.styleSpec})):"string"!==n&&"number"!==n&&"boolean"!==n&&s.push(new jr(`${i}[${o}]`,e[o],`string, number, or boolean expected, ${n} found`));break;case"any":case"all":case"none":for(let r=1;r<e.length;r++)s=s.concat(cn({key:`${i}[${r}]`,value:e[r],style:t.style,styleSpec:t.styleSpec}));break;case"has":case"!has":n=Tr(e[1]),2!==e.length?s.push(new jr(i,e,`filter array for "${e[0]}" operator must have 2 elements`)):"string"!==n&&s.push(new jr(`${i}[1]`,e[1],`string expected, ${n} found`));break;case"within":n=Tr(e[1]),2!==e.length?s.push(new jr(i,e,`filter array for "${e[0]}" operator must have 2 elements`)):"object"!==n&&s.push(new jr(`${i}[1]`,e[1],`object expected, ${n} found`))}return s}function hn(t,e){const i=t.key,r=t.style,n=t.styleSpec,s=t.value,o=t.objectKey,a=n[`${e}_${t.layerType}`];if(!a)return[];const l=o.match(/^(.*)-transition$/);if("paint"===e&&l&&a[l[1]]&&a[l[1]].transition)return bn({key:i,value:s,valueSpec:n.transition,style:r,styleSpec:n});const c=t.valueSpec||a[o];if(!c)return[new jr(i,s,`unknown property "${o}"`)];let h;if("string"===Tr(s)&&vr(c)&&!c.tokens&&(h=/^{([^}]+)}$/.exec(s)))return[new jr(i,s,`"${o}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(h[1])} }\`.`)];const u=[];return"symbol"===t.layerType&&("text-field"===o&&r&&!r.glyphs&&u.push(new jr(i,s,'use of "text-field" requires a style "glyphs" property')),"text-font"===o&&Er(fe(s))&&"identity"===de(s.type)&&u.push(new jr(i,s,'"text-font" does not support identity functions'))),u.concat(bn({key:t.key,value:s,valueSpec:c,style:r,styleSpec:n,expressionContext:"property",propertyType:e,propertyKey:o}))}function un(t){return hn(t,"paint")}function pn(t){return hn(t,"layout")}function dn(t){let e=[];const i=t.value,r=t.key,n=t.style,s=t.styleSpec;i.type||i.ref||e.push(new jr(r,i,'either "type" or "ref" is required'));let o=de(i.type);const a=de(i.ref);if(i.id){const s=de(i.id);for(let o=0;o<t.arrayIndex;o++){const t=n.layers[o];de(t.id)===s&&e.push(new jr(r,i.id,`duplicate layer id "${i.id}", previously used at line ${t.id.__line__}`))}}if("ref"in i){let t;["type","source","source-layer","filter","layout"].forEach((t=>{t in i&&e.push(new jr(r,i[t],`"${t}" is prohibited for ref layers`))})),n.layers.forEach((e=>{de(e.id)===a&&(t=e)})),t?t.ref?e.push(new jr(r,i.ref,"ref cannot reference another ref layer")):o=de(t.type):e.push(new jr(r,i.ref,`ref layer "${a}" not found`))}else if("background"!==o&&"sky"!==o)if(i.source){const t=n.sources&&n.sources[i.source],s=t&&de(t.type);t?"vector"===s&&"raster"===o?e.push(new jr(r,i.source,`layer "${i.id}" requires a raster source`)):"raster"===s&&"raster"!==o?e.push(new jr(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==s||i["source-layer"]?"raster-dem"===s&&"hillshade"!==o?e.push(new jr(r,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==o||!i.paint||!i.paint["line-gradient"]||"geojson"===s&&t.lineMetrics||e.push(new jr(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new jr(r,i,`layer "${i.id}" must specify a "source-layer"`)):e.push(new jr(r,i.source,`source "${i.source}" not found`))}else e.push(new jr(r,i,'missing required property "source"'));return e=e.concat(Ur({key:r,value:i,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>bn({key:`${r}.type`,value:i.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,object:i,objectKey:"type"}),filter:t=>ln(pe({layerType:o},t)),layout:t=>Ur({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>pn(pe({layerType:o},t))}}),paint:t=>Ur({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>un(pe({layerType:o},t))}})}})),e}function fn(t){const e=t.value,i=t.key,r=Tr(e);return"string"!==r?[new jr(i,e,`string expected, ${r} found`)]:[]}const mn={promoteId:function({key:t,value:e}){if("string"===Tr(e))return fn({key:t,value:e});{const i=[];for(const r in e)i.push(...fn({key:`${t}.${r}`,value:e[r]}));return i}}};function _n(t){const e=t.value,i=t.key,r=t.styleSpec,n=t.style;if(!e.type)return[new jr(i,e,'"type" is required')];const s=de(e.type);let o;switch(s){case"vector":case"raster":case"raster-dem":return o=Ur({key:i,value:e,valueSpec:r[`source_${s.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:mn}),o;case"geojson":if(o=Ur({key:i,value:e,valueSpec:r.source_geojson,style:n,styleSpec:r,objectElementValidators:mn}),e.cluster)for(const t in e.clusterProperties){const[r,n]=e.clusterProperties[t],s="string"==typeof r?[r,["accumulated"],["get",t]]:r;o.push(...Gr({key:`${i}.${t}.map`,value:n,expressionContext:"cluster-map"})),o.push(...Gr({key:`${i}.${t}.reduce`,value:s,expressionContext:"cluster-reduce"}))}return o;case"video":return Ur({key:i,value:e,valueSpec:r.source_video,style:n,styleSpec:r});case"image":return Ur({key:i,value:e,valueSpec:r.source_image,style:n,styleSpec:r});case"canvas":return[new jr(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Wr({key:`${i}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:n,styleSpec:r})}}function gn(t){const e=t.value,i=t.styleSpec,r=i.light,n=t.style;let s=[];const o=Tr(e);if(void 0===e)return s;if("object"!==o)return s=s.concat([new jr("light",e,`object expected, ${o} found`)]),s;for(const t in e){const o=t.match(/^(.*)-transition$/);s=s.concat(o&&r[o[1]]&&r[o[1]].transition?bn({key:t,value:e[t],valueSpec:i.transition,style:n,styleSpec:i}):r[t]?bn({key:t,value:e[t],valueSpec:r[t],style:n,styleSpec:i}):[new jr(t,e[t],`unknown property "${t}"`)])}return s}function yn(t){const e=t.value,i=t.key,r=t.style,n=t.styleSpec,s=n.terrain;let o=[];const a=Tr(e);if(void 0===e)return o;if("object"!==a)return o=o.concat([new jr("terrain",e,`object expected, ${a} found`)]),o;for(const t in e){const i=t.match(/^(.*)-transition$/);o=o.concat(i&&s[i[1]]&&s[i[1]].transition?bn({key:t,value:e[t],valueSpec:n.transition,style:r,styleSpec:n}):s[t]?bn({key:t,value:e[t],valueSpec:s[t],style:r,styleSpec:n}):[new jr(t,e[t],`unknown property "${t}"`)])}if(e.source){const t=r.sources&&r.sources[e.source],n=t&&de(t.type);t?"raster-dem"!==n&&o.push(new jr(i,e.source,`terrain cannot be used with a source of type ${n}, it only be used with a "raster-dem" source type`)):o.push(new jr(i,e.source,`source "${e.source}" not found`))}else o.push(new jr(i,e,'terrain is missing required property "source"'));return o}function xn(t){const e=t.value,i=t.style,r=t.styleSpec,n=r.fog;let s=[];const o=Tr(e);if(void 0===e)return s;if("object"!==o)return s=s.concat([new jr("fog",e,`object expected, ${o} found`)]),s;for(const t in e){const o=t.match(/^(.*)-transition$/);s=s.concat(o&&n[o[1]]&&n[o[1]].transition?bn({key:t,value:e[t],valueSpec:r.transition,style:i,styleSpec:r}):n[t]?bn({key:t,value:e[t],valueSpec:n[t],style:i,styleSpec:r}):[new jr(t,e[t],`unknown property "${t}"`)])}return s}const vn={"*":()=>[],array:Nr,boolean:function(t){const e=t.value,i=t.key,r=Tr(e);return"boolean"!==r?[new jr(i,e,`boolean expected, ${r} found`)]:[]},number:Zr,color:function(t){const e=t.key,i=t.value,r=Tr(i);return"string"!==r?[new jr(e,i,`color expected, ${r} found`)]:null===Be.parseCSSColor(i)?[new jr(e,i,`color expected, "${i}" found`)]:[]},enum:Wr,filter:ln,function:qr,layer:dn,object:Ur,source:_n,light:gn,terrain:yn,fog:xn,string:fn,formatted:function(t){return 0===fn(t).length?[]:Gr(t)},resolvedImage:function(t){return 0===fn(t).length?[]:Gr(t)},projection:function(t){const e=t.value,i=t.styleSpec,r=i.projection,n=t.style;let s=[];const o=Tr(e);if("object"===o)for(const t in e)s=s.concat(bn({key:t,value:e[t],valueSpec:r[t],style:n,styleSpec:i}));else"string"!==o&&(s=s.concat([new jr("projection",e,`object or string expected, ${o} found`)]));return s}};function bn(t){const e=t.value,i=t.valueSpec,r=t.styleSpec;return i.expression&&Er(de(e))?qr(t):i.expression&&Dr(fe(e))?Gr(t):i.type&&vn[i.type]?vn[i.type](t):Ur(pe({},t,{valueSpec:i.type?r[i.type]:i}))}function wn(t){const e=t.value,i=t.key,r=fn(t);return r.length||(-1===e.indexOf("{fontstack}")&&r.push(new jr(i,e,'"glyphs" url must include a "{fontstack}" token')),-1===e.indexOf("{range}")&&r.push(new jr(i,e,'"glyphs" url must include a "{range}" token'))),r}function Tn(t,e=ue){return Pn(bn({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,objectElementValidators:{glyphs:wn,"*":()=>[]}}))}const En=t=>Pn(_n(t)),In=t=>Pn(gn(t)),Sn=t=>Pn(yn(t)),An=t=>Pn(xn(t)),zn=t=>Pn(dn(t)),Cn=t=>Pn(ln(t)),Mn=t=>Pn(un(t)),kn=t=>Pn(pn(t));function Pn(t){return t.slice().sort(((t,e)=>t.line-e.line))}function Dn(t,e){let i=!1;if(e&&e.length)for(const r of e)t.fire(new ce(new Error(r.message))),i=!0;return i}var Bn=Ln;function Ln(t,e,i){var r=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var n=new Int32Array(this.arrayBuffer);t=n[0],this.d=(e=n[1])+2*(i=n[2]);for(var s=0;s<this.d*this.d;s++){var o=n[3+s],a=n[3+s+1];r.push(o===a?null:n.subarray(o,a))}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=e+2*i;for(var c=0;c<this.d*this.d;c++)r.push([]);this.keys=[],this.bboxes=[]}this.n=e,this.extent=t,this.padding=i,this.scale=e/t,this.uid=0;var h=i/e*t;this.min=-h,this.max=t+h}Ln.prototype.insert=function(t,e,i,r,n){this._forEachCell(e,i,r,n,this._insertCell,this.uid++),this.keys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)},Ln.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},Ln.prototype._insertCell=function(t,e,i,r,n,s){this.cells[n].push(s)},Ln.prototype.query=function(t,e,i,r,n){var s=this.min,o=this.max;if(t<=s&&e<=s&&o<=i&&o<=r&&!n)return Array.prototype.slice.call(this.keys);var a=[];return this._forEachCell(t,e,i,r,this._queryCell,a,{},n),a},Ln.prototype._queryCell=function(t,e,i,r,n,s,o,a){var l=this.cells[n];if(null!==l)for(var c=this.keys,h=this.bboxes,u=0;u<l.length;u++){var p=l[u];if(void 0===o[p]){var d=4*p;(a?a(h[d+0],h[d+1],h[d+2],h[d+3]):t<=h[d+2]&&e<=h[d+3]&&i>=h[d+0]&&r>=h[d+1])?(o[p]=!0,s.push(c[p])):o[p]=!1}}},Ln.prototype._forEachCell=function(t,e,i,r,n,s,o,a){for(var l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),h=this._convertToCellCoord(i),u=this._convertToCellCoord(r),p=l;p<=h;p++)for(var d=c;d<=u;d++){var f=this.d*d+p;if((!a||a(this._convertFromCellCoord(p),this._convertFromCellCoord(d),this._convertFromCellCoord(p+1),this._convertFromCellCoord(d+1)))&&n.call(this,t,e,i,r,f,s,o,a))return}},Ln.prototype._convertFromCellCoord=function(t){return(t-this.padding)/this.scale},Ln.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},Ln.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=3+this.cells.length+1+1,i=0,r=0;r<this.cells.length;r++)i+=this.cells[r].length;var n=new Int32Array(e+i+this.keys.length+this.bboxes.length);n[0]=this.extent,n[1]=this.n,n[2]=this.padding;for(var s=e,o=0;o<t.length;o++){var a=t[o];n[3+o]=s,n.set(a,s),s+=a.length}return n[3+t.length]=s,n.set(this.keys,s),n[3+t.length+1]=s+=this.keys.length,n.set(this.bboxes,s),s+=this.bboxes.length,n.buffer};const Rn={};function Fn(t,e={}){Rn[t.name]={klass:t,omit:e.omit||[]}}Fn(Object),Bn.serialize=function(t,e){const i=t.toArrayBuffer();return e&&e.push(i),{buffer:i}},Bn.deserialize=function(t){return new Bn(t.buffer)},Fn(Bn),Fn(Le),Fn(Error),Fn(Xt),Fn(Ve),Fn(Or),Fn(Pr,{omit:["_evaluator"]}),Fn(Rr),Fn(Lr),Fn(ti,{omit:["_evaluate"]});for(const t in dr)Rn[dr[t].name]||Fn(dr[t]);function On(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}function Vn(t){return l.ImageBitmap&&t instanceof l.ImageBitmap}function jn(t,e){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(On(t)||Vn(t))return e&&e.push(t),t;if(ArrayBuffer.isView(t)){const i=t;return e&&e.push(i.buffer),i}if(t instanceof l.ImageData)return e&&e.push(t.data.buffer),t;if(Array.isArray(t)){const i=[];for(const r of t)i.push(jn(r,e));return i}if("object"==typeof t){const i=t.constructor,r=i.name;if(!Rn[r])throw new Error(`can't serialize object of unregistered class ${r}`);const n=i.serialize?i.serialize(t,e):{};if(!i.serialize){for(const i in t)t.hasOwnProperty(i)&&(Rn[r].omit.indexOf(i)>=0||(n[i]=jn(t[i],e)));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 Un(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||On(t)||Vn(t)||ArrayBuffer.isView(t)||t instanceof l.ImageData)return t;if(Array.isArray(t))return t.map(Un);if("object"==typeof t){const e=t.$name||"Object",{klass:i}=Rn[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]=Un(t[e]));return r}throw new Error("can't deserialize object of type "+typeof t)}class Nn{constructor(){this.first=!0}update(t,e){const i=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=e):this.lastFloorZoom<i&&(this.lastIntegerZoom=i,this.lastIntegerZoomTime=e),t!==this.lastZoom&&(this.lastZoom=t,this.lastFloorZoom=i,!0))}}const Zn=t=>t>=12288&&t<=12351,qn=t=>t>=12352&&t<=12447,Gn=t=>t>=12448&&t<=12543,$n=t=>t>=19968&&t<=40959,Wn=t=>t>=44032&&t<=55215;function Xn(t){for(const e of t)if(Hn(e.charCodeAt(0)))return!0;return!1}function Hn(t){return!(746!==t&&747!==t&&(t<4352||!((t=>t>=12704&&t<=12735)(t)||(t=>t>=12544&&t<=12591)(t)||(t=>t>=65072&&t<=65103)(t)&&!(t>=65097&&t<=65103)||(t=>t>=63744&&t<=64255)(t)||(t=>t>=13056&&t<=13311)(t)||(t=>t>=11904&&t<=12031)(t)||(t=>t>=12736&&t<=12783)(t)||!(!Zn(t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||(t=>t>=13312&&t<=19903)(t)||$n(t)||(t=>t>=12800&&t<=13055)(t)||(t=>t>=12592&&t<=12687)(t)||(t=>t>=43360&&t<=43391)(t)||(t=>t>=55216&&t<=55295)(t)||(t=>t>=4352&&t<=4607)(t)||Wn(t)||qn(t)||(t=>t>=12272&&t<=12287)(t)||(t=>t>=12688&&t<=12703)(t)||(t=>t>=12032&&t<=12255)(t)||(t=>t>=12784&&t<=12799)(t)||Gn(t)&&12540!==t||!(!(t=>t>=65280&&t<=65519)(t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!(t=>t>=65104&&t<=65135)(t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||(t=>t>=5120&&t<=5759)(t)||(t=>t>=6320&&t<=6399)(t)||(t=>t>=65040&&t<=65055)(t)||(t=>t>=19904&&t<=19967)(t)||(t=>t>=40960&&t<=42127)(t)||(t=>t>=42128&&t<=42191)(t))))}function Kn(t){return t>=1424&&t<=2303||(t=>t>=64336&&t<=65023)(t)||(t=>t>=65136&&t<=65279)(t)}function Yn(t,e){return!(!e&&Kn(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||(t=>t>=6016&&t<=6143)(t))}function Jn(t){for(const e of t)if(Kn(e.charCodeAt(0)))return!0;return!1}const Qn="deferred",ts="loading",es="loaded";let is=null,rs="unavailable",ns=null;const ss=function(t){t&&"string"==typeof t&&t.indexOf("NetworkError")>-1&&(rs="error"),is&&is(t)};function os(){as.fire(new le("pluginStateChange",{pluginStatus:rs,pluginURL:ns}))}const as=new he,ls=function(){return rs},cs=function(){if(rs!==Qn||!ns)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");rs=ts,os(),ns&&Jt({url:ns},(t=>{t?ss(t):(rs=es,os())}))},hs={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>rs===es||null!=hs.applyArabicShaping,isLoading:()=>rs===ts,setState(t){rs=t.pluginStatus,ns=t.pluginURL},isParsed:()=>null!=hs.applyArabicShaping&&null!=hs.processBidirectionalText&&null!=hs.processStyledBidirectionalText,getPluginURL:()=>ns};class us{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition,this.pitch=e.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Nn,this.transition={},this.pitch=0)}isSupportedScript(t){return function(t,e){for(const i of t)if(!Yn(i.charCodeAt(0),e))return!1;return!0}(t,hs.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,e=t-Math.floor(t),i=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*e}}}class ps{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Er(t))return new Or(t,e);if(Dr(t)){const i=Fr(t,e);if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return i.value}{let i=t;return"string"==typeof t&&"color"===e.type&&(i=Le.parse(t)),{kind:"constant",evaluate:()=>i}}}(void 0===e?t.specification.default:e,t.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}}class ds{constructor(t){this.property=t,this.value=new ps(t,void 0)}transitioned(t,e){return new ms(this.property,this.value,e,I({},t.transition,this.transition),t.now)}untransitioned(){return new ms(this.property,this.value,null,{},0)}}class fs{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return R(this._values[t].value.value)}setValue(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new ds(this._values[t].property)),this._values[t].value=new ps(this._values[t].property,null===e?void 0:R(e))}getTransition(t){return R(this._values[t].transition)}setTransition(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new ds(this._values[t].property)),this._values[t].transition=R(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i);const r=this.getTransition(e);void 0!==r&&(t[`${e}-transition`]=r)}return t}transitioned(t,e){const i=new _s(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(t,e._values[r]);return i}untransitioned(){const t=new _s(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class ms{constructor(t,e,i,r,n){const s=r.delay||0,o=r.duration||0;n=n||0,this.property=t,this.value=e,this.begin=n+s,this.end=this.begin+o,t.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(t,e,i){const r=t.now||0,n=this.value.possiblyEvaluate(t,e,i),s=this.prior;if(s){if(r>this.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(r<this.begin)return s.possiblyEvaluate(t,e,i);{const o=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(s.possiblyEvaluate(t,e,i),n,m(o))}}return n}}class _s{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,e,i){const r=new xs(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(t,e,i);return r}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class gs{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues)}getValue(t){return R(this._values[t].value)}setValue(t,e){this._values[t]=new ps(this._values[t].property,null===e?void 0:R(e))}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i)}return t}possiblyEvaluate(t,e,i){const r=new xs(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(t,e,i);return r}}class ys{constructor(t,e,i){this.property=t,this.value=e,this.parameters=i}isConstant(){return"constant"===this.value.kind}constantOr(t){return"constant"===this.value.kind?this.value.value:t}evaluate(t,e,i,r){return this.property.evaluate(this.value,this.parameters,t,e,i,r)}}class xs{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class vs{constructor(t){this.specification=t}possiblyEvaluate(t,e){return t.expression.evaluate(e)}interpolate(t,e,i){const r=zi[this.specification.type];return r?r(t,e,i):t}}class bs{constructor(t,e){this.specification=t,this.overrides=e}possiblyEvaluate(t,e,i,r){return new ys(this,"constant"===t.expression.kind||"camera"===t.expression.kind?{kind:"constant",value:t.expression.evaluate(e,null,{},i,r)}:t.expression,e)}interpolate(t,e,i){if("constant"!==t.value.kind||"constant"!==e.value.kind)return t;if(void 0===t.value.value||void 0===e.value.value)return new ys(this,{kind:"constant",value:void 0},t.parameters);const r=zi[this.specification.type];return r?new ys(this,{kind:"constant",value:r(t.value.value,e.value.value,i)},t.parameters):t}evaluate(t,e,i,r,n,s){return"constant"===t.kind?t.value:t.evaluate(e,i,r,n,s)}}class ws extends bs{possiblyEvaluate(t,e,i,r){if(void 0===t.value)return new ys(this,{kind:"constant",value:void 0},e);if("constant"===t.expression.kind){const n=t.expression.evaluate(e,null,{},i,r),s="resolvedImage"===t.property.specification.type&&"string"!=typeof n?n.name:n,o=this._calculate(s,s,s,e);return new ys(this,{kind:"constant",value:o},e)}if("camera"===t.expression.kind){const i=this._calculate(t.expression.evaluate({zoom:e.zoom-1}),t.expression.evaluate({zoom:e.zoom}),t.expression.evaluate({zoom:e.zoom+1}),e);return new ys(this,{kind:"constant",value:i},e)}return new ys(this,t.expression,e)}evaluate(t,e,i,r,n,s){if("source"===t.kind){const o=t.evaluate(e,i,r,n,s);return this._calculate(o,o,o,e)}return"composite"===t.kind?this._calculate(t.evaluate({zoom:Math.floor(e.zoom)-1},i,r),t.evaluate({zoom:Math.floor(e.zoom)},i,r),t.evaluate({zoom:Math.floor(e.zoom)+1},i,r),e):t.value}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e,other:i}:{from:i,to:e,other:t}}interpolate(t){return t}}class Ts{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){if(void 0!==t.value){if("constant"===t.expression.kind){const n=t.expression.evaluate(e,null,{},i,r);return this._calculate(n,n,n,e)}return this._calculate(t.expression.evaluate(new us(Math.floor(e.zoom-1),e)),t.expression.evaluate(new us(Math.floor(e.zoom),e)),t.expression.evaluate(new us(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}}class Es{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){return!!t.expression.evaluate(e,null,{},i,r)}interpolate(){return!1}}class Is{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const e in t){const i=t[e];i.specification.overridable&&this.overridableProperties.push(e);const r=this.defaultPropertyValues[e]=new ps(i,void 0),n=this.defaultTransitionablePropertyValues[e]=new ds(i);this.defaultTransitioningPropertyValues[e]=n.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=r.possiblyEvaluate({})}}}function Ss(t,e){return 256*(t=v(Math.floor(t),0,255))+v(Math.floor(e),0,255)}Fn(bs),Fn(vs),Fn(ws),Fn(Ts),Fn(Es);const As={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class zs{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Cs{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_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(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_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 Ms(t,e=1){let i=0,r=0;return{members:t.map((t=>{const n=As[t.type].BYTES_PER_ELEMENT,s=i=ks(i,Math.max(e,n)),o=t.components||1;return r=Math.max(r,n),i+=n*o,{name:t.name,type:t.type,components:o,offset:s}})),size:ks(i,Math.max(r,e)),alignment:e}}function ks(t,e){return Math.ceil(t/e)*e}class Ps extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.int16[r+0]=e,this.int16[r+1]=i,t}}Ps.prototype.bytesPerElement=4,Fn(Ps);class Ds extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=3*t;return this.int16[n+0]=e,this.int16[n+1]=i,this.int16[n+2]=r,t}}Ds.prototype.bytesPerElement=6,Fn(Ds);class Bs extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r)}emplace(t,e,i,r,n){const s=4*t;return this.int16[s+0]=e,this.int16[s+1]=i,this.int16[s+2]=r,this.int16[s+3]=n,t}}Bs.prototype.bytesPerElement=8,Fn(Bs);class Ls extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s,o){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,n,s,o)}emplace(t,e,i,r,n,s,o,a){const l=6*t,c=12*t,h=3*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.uint8[c+4]=r,this.uint8[c+5]=n,this.uint8[c+6]=s,this.uint8[c+7]=o,this.float32[h+2]=a,t}}Ls.prototype.bytesPerElement=12,Fn(Ls);class Rs extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=3*t;return this.float32[n+0]=e,this.float32[n+1]=i,this.float32[n+2]=r,t}}Rs.prototype.bytesPerElement=12,Fn(Rs);class Fs extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s,o,a,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,t,e,i,r,n,s,o,a,l,c)}emplace(t,e,i,r,n,s,o,a,l,c,h){const u=10*t;return this.uint16[u+0]=e,this.uint16[u+1]=i,this.uint16[u+2]=r,this.uint16[u+3]=n,this.uint16[u+4]=s,this.uint16[u+5]=o,this.uint16[u+6]=a,this.uint16[u+7]=l,this.uint16[u+8]=c,this.uint16[u+9]=h,t}}Fs.prototype.bytesPerElement=20,Fn(Fs);class Os extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s,o,a){const l=this.length;return this.resize(l+1),this.emplace(l,t,e,i,r,n,s,o,a)}emplace(t,e,i,r,n,s,o,a,l){const c=8*t;return this.uint16[c+0]=e,this.uint16[c+1]=i,this.uint16[c+2]=r,this.uint16[c+3]=n,this.uint16[c+4]=s,this.uint16[c+5]=o,this.uint16[c+6]=a,this.uint16[c+7]=l,t}}Os.prototype.bytesPerElement=16,Fn(Os);class Vs extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r,n,s)}emplace(t,e,i,r,n,s,o){const a=6*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=n,this.int16[a+4]=s,this.int16[a+5]=o,t}}Vs.prototype.bytesPerElement=12,Fn(Vs);class js extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m){const _=this.length;return this.resize(_+1),this.emplace(_,t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m)}emplace(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m,_){const g=16*t;return this.int16[g+0]=e,this.int16[g+1]=i,this.int16[g+2]=r,this.int16[g+3]=n,this.uint16[g+4]=s,this.uint16[g+5]=o,this.uint16[g+6]=a,this.uint16[g+7]=l,this.int16[g+8]=c,this.int16[g+9]=h,this.int16[g+10]=u,this.int16[g+11]=p,this.int16[g+12]=d,this.int16[g+13]=f,this.int16[g+14]=m,this.int16[g+15]=_,t}}js.prototype.bytesPerElement=32,Fn(js);class Us extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}Us.prototype.bytesPerElement=4,Fn(Us);class Ns extends Cs{_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(t,e,i,r,n,s,o,a,l,c,h,u,p){const d=this.length;return this.resize(d+1),this.emplace(d,t,e,i,r,n,s,o,a,l,c,h,u,p)}emplace(t,e,i,r,n,s,o,a,l,c,h,u,p,d){const f=20*t,m=10*t;return this.int16[f+0]=e,this.int16[f+1]=i,this.int16[f+2]=r,this.int16[f+3]=n,this.int16[f+4]=s,this.float32[m+3]=o,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=h,this.uint32[m+8]=u,this.uint16[f+18]=p,this.uint16[f+19]=d,t}}Ns.prototype.bytesPerElement=40,Fn(Ns);class Zs extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s,o){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,n,s,o)}emplace(t,e,i,r,n,s,o,a){const l=8*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.int16[l+2]=r,this.int16[l+4]=n,this.int16[l+5]=s,this.int16[l+6]=o,this.int16[l+7]=a,t}}Zs.prototype.bytesPerElement=16,Fn(Zs);class qs extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r,n)}emplace(t,e,i,r,n,s){const o=4*t,a=8*t;return this.float32[o+0]=e,this.float32[o+1]=i,this.float32[o+2]=r,this.int16[a+6]=n,this.int16[a+7]=s,t}}qs.prototype.bytesPerElement=16,Fn(qs);class Gs extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r)}emplace(t,e,i,r,n){const s=12*t,o=3*t;return this.uint8[s+0]=e,this.uint8[s+1]=i,this.float32[o+1]=r,this.float32[o+2]=n,t}}Gs.prototype.bytesPerElement=12,Fn(Gs);class $s extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const n=3*t;return this.uint16[n+0]=e,this.uint16[n+1]=i,this.uint16[n+2]=r,t}}$s.prototype.bytesPerElement=6,Fn($s);class Ws extends Cs{_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(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m,_,g,y,x,v){const b=this.length;return this.resize(b+1),this.emplace(b,t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m,_,g,y,x,v)}emplace(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m,_,g,y,x,v,b){const w=30*t,T=15*t,E=60*t;return this.int16[w+0]=e,this.int16[w+1]=i,this.int16[w+2]=r,this.float32[T+2]=n,this.float32[T+3]=s,this.uint16[w+8]=o,this.uint16[w+9]=a,this.uint32[T+5]=l,this.uint32[T+6]=c,this.uint32[T+7]=h,this.uint16[w+16]=u,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,t}}Ws.prototype.bytesPerElement=60,Fn(Ws);class Xs extends Cs{_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(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m,_,g,y,x,v,b,w,T,E,I,S,A,z,C){const M=this.length;return this.resize(M+1),this.emplace(M,t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m,_,g,y,x,v,b,w,T,E,I,S,A,z,C)}emplace(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m,_,g,y,x,v,b,w,T,E,I,S,A,z,C,M){const k=38*t,P=19*t;return this.int16[k+0]=e,this.int16[k+1]=i,this.int16[k+2]=r,this.float32[P+2]=n,this.float32[P+3]=s,this.int16[k+8]=o,this.int16[k+9]=a,this.int16[k+10]=l,this.int16[k+11]=c,this.int16[k+12]=h,this.int16[k+13]=u,this.uint16[k+14]=p,this.uint16[k+15]=d,this.uint16[k+16]=f,this.uint16[k+17]=m,this.uint16[k+18]=_,this.uint16[k+19]=g,this.uint16[k+20]=y,this.uint16[k+21]=x,this.uint16[k+22]=v,this.uint16[k+23]=b,this.uint16[k+24]=w,this.uint16[k+25]=T,this.uint16[k+26]=E,this.uint16[k+27]=I,this.uint16[k+28]=S,this.uint32[P+15]=A,this.float32[P+16]=z,this.float32[P+17]=C,this.float32[P+18]=M,t}}Xs.prototype.bytesPerElement=76,Fn(Xs);class Hs extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}Hs.prototype.bytesPerElement=4,Fn(Hs);class Ks extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s,o){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,n,s,o)}emplace(t,e,i,r,n,s,o,a){const l=7*t;return this.float32[l+0]=e,this.float32[l+1]=i,this.float32[l+2]=r,this.float32[l+3]=n,this.float32[l+4]=s,this.float32[l+5]=o,this.float32[l+6]=a,t}}Ks.prototype.bytesPerElement=28,Fn(Ks);class Ys extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r,n)}emplace(t,e,i,r,n,s){const o=5*t;return this.float32[o+0]=e,this.float32[o+1]=i,this.float32[o+2]=r,this.float32[o+3]=n,this.float32[o+4]=s,t}}Ys.prototype.bytesPerElement=20,Fn(Ys);class Js extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r)}emplace(t,e,i,r,n){const s=6*t;return this.uint32[3*t+0]=e,this.uint16[s+2]=i,this.uint16[s+3]=r,this.uint16[s+4]=n,t}}Js.prototype.bytesPerElement=12,Fn(Js);class Qs extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.uint16[r+0]=e,this.uint16[r+1]=i,t}}Qs.prototype.bytesPerElement=4,Fn(Qs);class to extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}to.prototype.bytesPerElement=2,Fn(to);class eo extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.float32[r+0]=e,this.float32[r+1]=i,t}}eo.prototype.bytesPerElement=8,Fn(eo);class io extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r)}emplace(t,e,i,r,n){const s=4*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=r,this.float32[s+3]=n,t}}io.prototype.bytesPerElement=16,Fn(io);class ro extends Cs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s,o){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,n,s,o)}emplace(t,e,i,r,n,s,o,a){const l=8*t,c=4*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.int16[l+2]=r,this.int16[l+3]=n,this.int16[l+4]=s,this.int16[l+5]=o,this.float32[c+3]=a,t}}ro.prototype.bytesPerElement=16,Fn(ro);class no extends zs{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]}}no.prototype.size=12;class so extends Vs{get(t){return new no(this,t)}}Fn(so);class oo extends zs{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]}}oo.prototype.size=40;class ao extends Ns{get(t){return new oo(this,t)}}Fn(ao);class lo extends zs{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(t){this._structArray.uint8[this._pos1+49]=t}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(t){this._structArray.uint8[this._pos1+50]=t}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(t){this._structArray.uint32[this._pos4+13]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(t){this._structArray.uint8[this._pos1+58]=t}}lo.prototype.size=60;class co extends Ws{get(t){return new lo(this,t)}}Fn(co);class ho extends zs{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(t){this._structArray.uint32[this._pos4+15]=t}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]}}ho.prototype.size=76;class uo extends Xs{get(t){return new ho(this,t)}}Fn(uo);class po extends Hs{getoffsetX(t){return this.float32[1*t+0]}}Fn(po);class fo extends Ds{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}Fn(fo);class mo extends zs{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]}}mo.prototype.size=12;class _o extends Js{get(t){return new mo(this,t)}}Fn(_o);class go extends zs{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}go.prototype.size=4;class yo extends Qs{get(t){return new go(this,t)}}Fn(yo);class xo extends zs{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]}get a_scale(){return this._structArray.float32[this._pos4+3]}}xo.prototype.size=16;class vo extends ro{get(t){return new xo(this,t)}}Fn(vo);const bo=Ms([{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"}]),wo=Ms([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var To=De((function(t){t.exports=function(t,e){var i,r,n,s,o,a,l,c;for(r=t.length-(i=3&t.length),n=e,o=3432918353,a=461845907,c=0;c<r;)l=255&t.charCodeAt(c)|(255&t.charCodeAt(++c))<<8|(255&t.charCodeAt(++c))<<16|(255&t.charCodeAt(++c))<<24,++c,n=27492+(65535&(s=5*(65535&(n=(n^=l=(65535&(l=(l=(65535&l)*o+(((l>>>16)*o&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(s>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&t.charCodeAt(c+2))<<16;case 2:l^=(255&t.charCodeAt(c+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(c)))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return n^=t.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}})),Eo=De((function(t){t.exports=function(t,e){for(var i,r=t.length,n=e^r,s=0;r>=4;)i=1540483477*(65535&(i=255&t.charCodeAt(s)|(255&t.charCodeAt(++s))<<8|(255&t.charCodeAt(++s))<<16|(255&t.charCodeAt(++s))<<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,++s;switch(r){case 3:n^=(255&t.charCodeAt(s+2))<<16;case 2:n^=(255&t.charCodeAt(s+1))<<8;case 1:n=1540483477*(65535&(n^=255&t.charCodeAt(s)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}})),Io=To,So=Eo;Io.murmur3=To,Io.murmur2=So;class Ao{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,e,i,r){this.ids.push(zo(t)),this.positions.push(e,i,r)}getPositions(t){const e=zo(t);let i=0,r=this.ids.length-1;for(;i<r;){const t=i+r>>1;this.ids[t]>=e?r=t:i=t+1}const n=[];for(;this.ids[i]===e;)n.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return n}static serialize(t,e){const i=new Float64Array(t.ids),r=new Uint32Array(t.positions);return Co(i,r,0,i.length-1),e&&e.push(i.buffer,r.buffer),{ids:i,positions:r}}static deserialize(t){const e=new Ao;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function zo(t){const e=+t;return!isNaN(e)&&Number.MIN_SAFE_INTEGER<=e&&e<=Number.MAX_SAFE_INTEGER?e:Io(String(t))}function Co(t,e,i,r){for(;i<r;){const n=t[i+r>>1];let s=i-1,o=r+1;for(;;){do{s++}while(t[s]<n);do{o--}while(t[o]>n);if(s>=o)break;Mo(t,s,o),Mo(e,3*s,3*o),Mo(e,3*s+1,3*o+1),Mo(e,3*s+2,3*o+2)}o-i<r-o?(Co(t,e,i,o),i=o+1):(Co(t,e,o+1,r),r=o)}}function Mo(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}Fn(Ao);class ko{constructor(t,e){this.gl=t.gl,this.location=e}}class Po extends ko{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t))}}class Do extends ko{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}}class Bo extends ko{constructor(t,e){super(t,e),this.current=[0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]||(this.current=t,this.gl.uniform2f(this.location,t[0],t[1]))}}class Lo extends ko{constructor(t,e){super(t,e),this.current=[0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]||(this.current=t,this.gl.uniform3f(this.location,t[0],t[1],t[2]))}}class Ro extends ko{constructor(t,e){super(t,e),this.current=[0,0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]&&t[3]===this.current[3]||(this.current=t,this.gl.uniform4f(this.location,t[0],t[1],t[2],t[3]))}}class Fo extends ko{constructor(t,e){super(t,e),this.current=Le.transparent}set(t){t.r===this.current.r&&t.g===this.current.g&&t.b===this.current.b&&t.a===this.current.a||(this.current=t,this.gl.uniform4f(this.location,t.r,t.g,t.b,t.a))}}const Oo=new Float32Array(16);class Vo extends ko{constructor(t,e){super(t,e),this.current=Oo}set(t){if(t[12]!==this.current[12]||t[0]!==this.current[0])return this.current=t,void this.gl.uniformMatrix4fv(this.location,!1,t);for(let e=1;e<16;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);break}}}const jo=new Float32Array(9);class Uo extends ko{constructor(t,e){super(t,e),this.current=jo}set(t){for(let e=0;e<9;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix3fv(this.location,!1,t);break}}}const No=new Float32Array(4);class Zo extends ko{constructor(t,e){super(t,e),this.current=No}set(t){for(let e=0;e<4;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix2fv(this.location,!1,t);break}}}function qo(t){return[Ss(255*t.r,255*t.g),Ss(255*t.b,255*t.a)]}class Go{constructor(t,e,i){this.value=t,this.uniformNames=e.map((t=>`u_${t}`)),this.type=i}setUniform(t,e,i){t.set(i.constantOr(this.value))}getBinding(t,e,i){return"color"===this.type?new Fo(t,e):new Do(t,e)}}class $o{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio||1,this.pixelRatioTo=t.pixelRatio||1,this.patternFrom=e.tl.concat(e.br),this.patternTo=t.tl.concat(t.br)}setUniform(t,e,i,r){const n="u_pattern_to"===r||"u_dash_to"===r?this.patternTo:"u_pattern_from"===r||"u_dash_from"===r?this.patternFrom:"u_pixel_ratio_to"===r?this.pixelRatioTo:"u_pixel_ratio_from"===r?this.pixelRatioFrom:null;n&&t.set(n)}getBinding(t,e,i){return"u_pattern_from"===i||"u_pattern_to"===i||"u_dash_from"===i||"u_dash_to"===i?new Ro(t,e):new Do(t,e)}}class Wo{constructor(t,e,i,r){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new r}populatePaintArray(t,e,i,r,n,s){const o=this.paintVertexArray.length,a=this.expression.evaluate(new us(0),e,{},n,r,s);this.paintVertexArray.resize(t),this._setPaintValue(o,t,a)}updatePaintArray(t,e,i,r,n){const s=this.expression.evaluate({zoom:0},i,r,void 0,n);this._setPaintValue(t,e,s)}_setPaintValue(t,e,i){if("color"===this.type){const r=qo(i);for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,r[0],r[1])}else{for(let r=t;r<e;r++)this.paintVertexArray.emplace(r,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Xo{constructor(t,e,i,r,n,s){this.expression=t,this.uniformNames=e.map((t=>`u_${t}_t`)),this.type=i,this.useIntegerZoom=r,this.zoom=n,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new s}populatePaintArray(t,e,i,r,n,s){const o=this.expression.evaluate(new us(this.zoom),e,{},n,r,s),a=this.expression.evaluate(new us(this.zoom+1),e,{},n,r,s),l=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(l,t,o,a)}updatePaintArray(t,e,i,r,n){const s=this.expression.evaluate({zoom:this.zoom},i,r,void 0,n),o=this.expression.evaluate({zoom:this.zoom+1},i,r,void 0,n);this._setPaintValue(t,e,s,o)}_setPaintValue(t,e,i,r){if("color"===this.type){const n=qo(i),s=qo(r);for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,n[0],n[1],s[0],s[1])}else{for(let n=t;n<e;n++)this.paintVertexArray.emplace(n,i,r);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(r))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(t,e){const i=this.useIntegerZoom?Math.floor(e.zoom):e.zoom,r=v(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);t.set(r)}getBinding(t,e,i){return new Do(t,e)}}class Ho{constructor(t,e,i,r,n,s,o){this.expression=t,this.type=i,this.useIntegerZoom=r,this.zoom=n,this.layerId=o,this.paintVertexAttributes=("array"===i?wo:bo).members;for(let t=0;t<e.length;++t);this.zoomInPaintVertexArray=new s,this.zoomOutPaintVertexArray=new s}populatePaintArray(t,e,i){const r=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(r,t,e.patterns&&e.patterns[this.layerId],i)}updatePaintArray(t,e,i,r,n,s){this._setPaintValues(t,e,i.patterns&&i.patterns[this.layerId],s)}_setPaintValues(t,e,i,r){if(!r||!i)return;const{min:n,mid:s,max:o}=i,a=r[n],l=r[s],c=r[o];if(a&&l&&c)for(let i=t;i<e;i++)this._setPaintValue(this.zoomInPaintVertexArray,i,l,a),this._setPaintValue(this.zoomOutPaintVertexArray,i,l,c)}_setPaintValue(t,e,i,r){t.emplace(e,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(t){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=t.createVertexBuffer(this.zoomInPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=t.createVertexBuffer(this.zoomOutPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class Ko{constructor(t,e,i=(()=>!0)){this.binders={},this._buffers=[];const r=[];for(const n in t.paint._values){if(!i(n))continue;const s=t.paint.get(n);if(!(s instanceof ys&&vr(s.property.specification)))continue;const o=Qo(n,t.type),a=s.value,l=s.property.specification.type,c=s.property.useIntegerZoom,h=s.property.specification["property-type"],u="cross-faded"===h||"cross-faded-data-driven"===h,p="line-dasharray"===String(n)&&"constant"!==t.layout.get("line-cap").value.kind;if("constant"!==a.kind||p)if("source"===a.kind||p||u){const i=ia(n,l,"source");this.binders[n]=u?new Ho(a,o,l,c,e,i,t.id):new Wo(a,o,l,i),r.push(`/a_${n}`)}else{const t=ia(n,l,"composite");this.binders[n]=new Xo(a,o,l,c,e,t),r.push(`/z_${n}`)}else this.binders[n]=u?new $o(a.value,o):new Go(a.value,o,l),r.push(`/u_${n}`)}this.cacheKey=r.sort().join("")}getMaxValue(t){const e=this.binders[t];return e instanceof Wo||e instanceof Xo?e.maxValue:0}populatePaintArrays(t,e,i,r,n,s){for(const o in this.binders){const a=this.binders[o];(a instanceof Wo||a instanceof Xo||a instanceof Ho)&&a.populatePaintArray(t,e,i,r,n,s)}}setConstantPatternPositions(t,e){for(const i in this.binders){const r=this.binders[i];r instanceof $o&&r.setConstantPatternPositions(t,e)}}updatePaintArrays(t,e,i,r,n,s){let o=!1;for(const a in t){const l=e.getPositions(a);for(const e of l){const l=i.feature(e.index);for(const i in this.binders){const c=this.binders[i];if((c instanceof Wo||c instanceof Xo||c instanceof Ho)&&!0===c.expression.isStateDependent){const h=r.paint.get(i);c.expression=h.value,c.updatePaintArray(e.start,e.end,l,t[a],n,s),o=!0}}}}return o}defines(){const t=[];for(const e in this.binders){const i=this.binders[e];(i instanceof Go||i instanceof $o)&&t.push(...i.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof Wo||i instanceof Xo||i instanceof Ho)for(let e=0;e<i.paintVertexAttributes.length;e++)t.push(i.paintVertexAttributes[e].name)}return t}getBinderUniforms(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof Go||i instanceof $o||i instanceof Xo)for(const e of i.uniformNames)t.push(e)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,e){const i=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof Go||n instanceof $o||n instanceof Xo)for(const s of n.uniformNames)if(e[s]){const o=n.getBinding(t,e[s],s);i.push({name:s,property:r,binding:o})}}return i}setUniforms(t,e,i,r){for(const{name:t,property:n,binding:s}of e)this.binders[n].setUniform(s,r,i.get(n),t)}updatePaintBuffers(t){this._buffers=[];for(const e in this.binders){const i=this.binders[e];if(t&&i instanceof Ho){const e=2===t.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;e&&this._buffers.push(e)}else(i instanceof Wo||i instanceof Xo)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(t){for(const e in this.binders){const i=this.binders[e];(i instanceof Wo||i instanceof Xo||i instanceof Ho)&&i.upload(t)}this.updatePaintBuffers()}destroy(){for(const t in this.binders){const e=this.binders[t];(e instanceof Wo||e instanceof Xo||e instanceof Ho)&&e.destroy()}}}class Yo{constructor(t,e,i=(()=>!0)){this.programConfigurations={};for(const r of t)this.programConfigurations[r.id]=new Ko(r,e,i);this.needsUpload=!1,this._featureMap=new Ao,this._bufferOffset=0}populatePaintArrays(t,e,i,r,n,s,o){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(t,e,r,n,s,o);void 0!==e.id&&this._featureMap.add(e.id,i,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,i,r,n){for(const s of i)this.needsUpload=this.programConfigurations[s.id].updatePaintArrays(t,this._featureMap,e,s,r,n)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}const Jo={"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 Qo(t,e){return Jo[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}const ta={"line-pattern":{source:Fs,composite:Fs},"fill-pattern":{source:Fs,composite:Fs},"fill-extrusion-pattern":{source:Fs,composite:Fs},"line-dasharray":{source:Os,composite:Os}},ea={color:{source:eo,composite:io},number:{source:Hs,composite:eo}};function ia(t,e,i){const r=ta[t];return r&&r[i]||ea[e][i]}Fn(Go),Fn($o),Fn(Wo),Fn(Ho),Fn(Xo),Fn(Ko,{omit:["_buffers"]}),Fn(Yo);const ra="-transition";class na extends he{constructor(t,e){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==t.type&&(this.metadata=(t=t).metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&"sky"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),e.layout&&(this._unevaluatedLayout=new gs(e.layout)),e.paint)){this._transitionablePaint=new fs(e.paint);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new xs(e.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,i={}){null!=e&&this._validate(kn,`layers.${this.id}.layout.${t}`,t,e,i)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e)}getPaintProperty(t){return D(t,ra)?this._transitionablePaint.getTransition(t.slice(0,-ra.length)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,i={}){if(null!=e&&this._validate(Mn,`layers.${this.id}.paint.${t}`,t,e,i))return!1;if(D(t,ra))return this._transitionablePaint.setTransition(t.slice(0,-ra.length),e||void 0),!1;{const i=this._transitionablePaint._values[t],r="cross-faded-data-driven"===i.property.specification["property-type"],n=i.value.isDataDriven(),s=i.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const o=this._transitionablePaint._values[t].value;return o.isDataDriven()||n||r||this._handleOverridablePaintPropertyUpdate(t,s,o)}}_handleSpecialPaintPropertyUpdate(t){}getProgramIds(){return null}getProgramConfiguration(t){return null}_handleOverridablePaintPropertyUpdate(t,e,i){return!1}isHidden(t){return!!(this.minzoom&&t<this.minzoom)||!!(this.maxzoom&&t>=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){const t={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&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),L(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,i,r,n={}){return(!n||!1!==n.validate)&&Dn(this,t.call(Tn,{key:e,layerType:this.type,objectKey:i,value:r,styleSpec:ue,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof ys&&vr(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=Hr(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const sa=Ms([{name:"a_pos",components:2,type:"Int16"}],4),oa=Ms([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"},{name:"a_scale",components:1,type:"Float32"}]);class aa{constructor(t=[]){this.segments=t}prepareSegment(t,e,i,r){let n=this.segments[this.segments.length-1];return t>aa.MAX_VERTEX_ARRAY_LENGTH&&O(`Max vertices per segment is ${aa.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!n||n.vertexLength+t>aa.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==r)&&(n={vertexOffset:e.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 t of this.segments)for(const e in t.vaos)t.vaos[e].destroy()}static simpleSegment(t,e,i,r){return new aa([{vertexOffset:t,primitiveOffset:e,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}aa.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Fn(aa);var la=8192;class ca{constructor(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1]))}setNorthEast(t){return this._ne=t instanceof ua?new ua(t.lng,t.lat):ua.convert(t),this}setSouthWest(t){return this._sw=t instanceof ua?new ua(t.lng,t.lat):ua.convert(t),this}extend(t){const e=this._sw,i=this._ne;let r,n;if(t instanceof ua)r=t,n=t;else{if(!(t instanceof ca))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(ca.convert(t)):this.extend(ua.convert(t)):this;if(r=t._sw,n=t._ne,!r||!n)return this}return e||i?(e.lng=Math.min(r.lng,e.lng),e.lat=Math.min(r.lat,e.lat),i.lng=Math.max(n.lng,i.lng),i.lat=Math.max(n.lat,i.lat)):(this._sw=new ua(r.lng,r.lat),this._ne=new ua(n.lng,n.lat)),this}getCenter(){return new ua((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 ua(this.getWest(),this.getNorth())}getSouthEast(){return new ua(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(t){const{lng:e,lat:i}=ua.convert(t);let r=this._sw.lng<=e&&e<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&r}static convert(t){return!t||t instanceof ca?t:new ca(t)}}const ha=6371008.8;class ua{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new ua(w(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,i=this.lat*e,r=t.lat*e,n=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((t.lng-this.lng)*e);return ha*Math.acos(Math.min(n,1))}toBounds(t=0){const e=360*t/40075017,i=e/Math.cos(Math.PI/180*this.lat);return new ca(new ua(this.lng-i,this.lat-e),new ua(this.lng+i,this.lat+e))}static convert(t){if(t instanceof ua)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new ua(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new ua(Number("lng"in t?t.lng:t.lon),Number(t.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 pa=2*Math.PI*ha;function da(t){return pa*Math.cos(t*Math.PI/180)}function fa(t){return(180+t)/360}function ma(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function _a(t,e){return t/da(e)}function ga(t){return 360*t-180}function ya(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function xa(t,e){return t*da(ya(e))}const va=85.051129;class ba{constructor(t,e,i=0){this.x=+t,this.y=+e,this.z=+i}static fromLngLat(t,e=0){const i=ua.convert(t);return new ba(fa(i.lng),ma(i.lat),_a(e,i.lat))}toLngLat(){return new ua(ga(this.x),ya(this.y))}toAltitude(){return xa(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/pa*(t=ya(this.y),1/Math.cos(t*Math.PI/180));var t}}function wa(t,e,i,r,n,s,a,l,c){const h=(e+r)/2,u=(i+n)/2,p=new o(h,u);l(p),function(t,e,i,r,n,s){const o=i-n,a=r-s;return Math.abs((r-e)*o-(i-t)*a)/Math.hypot(o,a)}(p.x,p.y,s.x,s.y,a.x,a.y)>=c?(wa(t,e,i,h,u,s,p,l,c),wa(t,h,u,r,n,p,a,l,c)):t.push(a)}function Ta(t,e,i){let r=t[0],n=r.x,s=r.y;e(r);const o=[r];for(let a=1;a<t.length;a++){const l=t[a],{x:c,y:h}=l;e(l),wa(o,n,s,c,h,r,l,e,i),n=c,s=h,r=l}return o}const Ea=Math.pow(2,14)-1,Ia=-Ea-1;function Sa(t,e){const i=Math.round(t.x*e),r=Math.round(t.y*e);return t.x=v(i,Ia,Ea),t.y=v(r,Ia,Ea),(i<t.x||i>t.x+1||r<t.y||r>t.y+1)&&O("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function Aa(t,e,i){const r=t.loadGeometry(),n=t.extent,s=la/n;if(e&&i&&i.projection.isReprojectedInTileSpace){const s=1<<e.z,{scale:o,x:a,y:l,projection:c}=i,h=t=>{const i=ga((e.x+t.x/n)/s),r=ya((e.y+t.y/n)/s),h=c.project(i,r);t.x=(h.x*o-a)*n,t.y=(h.y*o-l)*n};for(let e=0;e<r.length;e++)if(1!==t.type)r[e]=Ta(r[e],h,1);else{const t=[];for(const i of r[e])i.x<0||i.x>=n||i.y<0||i.y>=n||(h(i),t.push(i));r[e]=t}}for(const t of r)for(const e of t)Sa(e,s);return r}function za(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?Aa(t):[]}}function Ca(t,e,i,r,n){t.emplaceBack(2*e+(r+1)/2,2*i+(n+1)/2)}function Ma(t,e,i,r){const n=16384;t.emplaceBack(e.x,e.y,e.z,i[0]*n,i[1]*n,i[2]*n,r)}class ka{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new Ps,this.indexArray=new $s,this.segments=new aa,this.programConfigurations=new Yo(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i,r){const n=this.layers[0],s=[];let o=null;"circle"===n.type&&(o=n.layout.get("circle-sort-key"));for(const{feature:e,id:n,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=za(e,t);if(!this.layers[0]._featureFilter.filter(new us(this.zoom),c,i))continue;const h=o?o.evaluate(c,{},i):void 0,u={id:n,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Aa(e,i,r),patterns:{},sortKey:h};s.push(u)}o&&s.sort(((t,e)=>t.sortKey-e.sortKey));let a=null;"globe"===r.projection.name&&(this.globeExtVertexArray=new vo,a=r.projection);for(const r of s){const{geometry:n,index:s,sourceLayerIndex:o}=r,l=t[s].feature;this.addFeature(r,n,s,e.availableImages,i,a),e.featureIndex.insert(l,n,s,o,this.index)}}update(t,e,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,sa.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,oa.members))),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(t,e,i,r,n,s){for(const i of e)for(const e of i){const i=e.x,r=e.y;if(i<0||i>=la||r<0||r>=la)continue;if(s){const t=s.projectTilePoint(i,r,n),e=s.upVector(n,i,r),o=ya((r/la+n.y)/(1<<n.z)),a=s.pixelsPerMeter(o,1)/_a(1,o),l=this.globeExtVertexArray;Ma(l,t,e,a),Ma(l,t,e,a),Ma(l,t,e,a),Ma(l,t,e,a)}const o=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),a=o.vertexLength;Ca(this.layoutVertexArray,i,r,-1,-1),Ca(this.layoutVertexArray,i,r,1,-1),Ca(this.layoutVertexArray,i,r,1,1),Ca(this.layoutVertexArray,i,r,-1,1),this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+3,a+2),o.vertexLength+=4,o.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{},r,n)}}function Pa(t,e){for(let i=0;i<t.length;i++)if(Ua(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(Ua(t,e[i]))return!0;return!!Ra(t,e)}function Da(t,e,i){return!!Ua(t,e)||!!Oa(e,t,i)}function Ba(t,e){if(1===t.length)return ja(e,t[0]);for(let i=0;i<e.length;i++){const r=e[i];for(let e=0;e<r.length;e++)if(Ua(t,r[e]))return!0}for(let i=0;i<t.length;i++)if(ja(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(Ra(t,e[i]))return!0;return!1}function La(t,e,i){if(t.length>1){if(Ra(t,e))return!0;for(let r=0;r<e.length;r++)if(Oa(e[r],t,i))return!0}for(let r=0;r<t.length;r++)if(Oa(t[r],e,i))return!0;return!1}function Ra(t,e){if(0===t.length||0===e.length)return!1;for(let i=0;i<t.length-1;i++){const r=t[i],n=t[i+1];for(let t=0;t<e.length-1;t++)if(Fa(r,n,e[t],e[t+1]))return!0}return!1}function Fa(t,e,i,r){return V(t,i,r)!==V(e,i,r)&&V(t,e,i)!==V(t,e,r)}function Oa(t,e,i){const r=i*i;if(1===e.length)return t.distSqr(e[0])<r;for(let i=1;i<e.length;i++)if(Va(t,e[i-1],e[i])<r)return!0;return!1}function Va(t,e,i){const r=e.distSqr(i);if(0===r)return t.distSqr(e);const n=((t.x-e.x)*(i.x-e.x)+(t.y-e.y)*(i.y-e.y))/r;return t.distSqr(n<0?e:n>1?i:i.sub(e)._mult(n)._add(e))}function ja(t,e){let i,r,n,s=!1;for(let o=0;o<t.length;o++){i=t[o];for(let t=0,o=i.length-1;t<i.length;o=t++)r=i[t],n=i[o],r.y>e.y!=n.y>e.y&&e.x<(n.x-r.x)*(e.y-r.y)/(n.y-r.y)+r.x&&(s=!s)}return s}function Ua(t,e){let i=!1;for(let r=0,n=t.length-1;r<t.length;n=r++){const s=t[r],o=t[n];s.y>e.y!=o.y>e.y&&e.x<(o.x-s.x)*(e.y-s.y)/(o.y-s.y)+s.x&&(i=!i)}return i}function Na(t,e,i,r,n){for(const s of t)if(e<=s.x&&i<=s.y&&r>=s.x&&n>=s.y)return!0;const s=[new o(e,i),new o(e,n),new o(r,n),new o(r,i)];if(t.length>2)for(const e of s)if(Ua(t,e))return!0;for(let e=0;e<t.length-1;e++)if(Za(t[e],t[e+1],s))return!0;return!1}function Za(t,e,i){const r=i[0],n=i[2];if(t.x<r.x&&e.x<r.x||t.x>n.x&&e.x>n.x||t.y<r.y&&e.y<r.y||t.y>n.y&&e.y>n.y)return!1;const s=V(t,e,i[0]);return s!==V(t,e,i[1])||s!==V(t,e,i[2])||s!==V(t,e,i[3])}function qa(t,e,i){const r=e.paint.get(t).value;return"constant"===r.kind?r.value:i.programConfigurations.get(e.id).getMaxValue(t)}function Ga(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function $a(t,e,i,r,n){if(!e[0]&&!e[1])return t;const s=o.convert(e)._mult(n);"viewport"===i&&s._rotate(-r);const a=[];for(let e=0;e<t.length;e++)a.push(t[e].sub(s));return a}function Wa(t,e,i,r){const n=o.convert(t)._mult(r);return"viewport"===e&&n._rotate(-i),n}Fn(ka,{omit:["layers"]});const Xa=new Is({"circle-sort-key":new bs(ue.layout_circle["circle-sort-key"])});var Ha={paint:new Is({"circle-radius":new bs(ue.paint_circle["circle-radius"]),"circle-color":new bs(ue.paint_circle["circle-color"]),"circle-blur":new bs(ue.paint_circle["circle-blur"]),"circle-opacity":new bs(ue.paint_circle["circle-opacity"]),"circle-translate":new vs(ue.paint_circle["circle-translate"]),"circle-translate-anchor":new vs(ue.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new vs(ue.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new vs(ue.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new bs(ue.paint_circle["circle-stroke-width"]),"circle-stroke-color":new bs(ue.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new bs(ue.paint_circle["circle-stroke-opacity"])}),layout:Xa},Ka=1e-6,Ya="undefined"!=typeof Float32Array?Float32Array:Array;function Ja(t,e){var i=e[0],r=e[1],n=e[2],s=e[3],o=i*s-n*r;return o?(t[0]=s*(o=1/o),t[1]=-r*o,t[2]=-n*o,t[3]=i*o,t):null}function Qa(){var t=new Ya(9);return Ya!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function tl(t,e){var i=e[0],r=e[1],n=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8];return t[0]=o*h-a*c,t[1]=n*c-r*h,t[2]=r*a-n*o,t[3]=a*l-s*h,t[4]=i*h-n*l,t[5]=n*s-i*a,t[6]=s*c-o*l,t[7]=r*l-i*c,t[8]=i*o-r*s,t}function el(t,e,i){var r=e[0],n=e[1],s=e[2],o=e[3],a=e[4],l=e[5],c=e[6],h=e[7],u=e[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 t[0]=p*r+d*o+f*c,t[1]=p*n+d*a+f*h,t[2]=p*s+d*l+f*u,t[3]=m*r+_*o+g*c,t[4]=m*n+_*a+g*h,t[5]=m*s+_*l+g*u,t[6]=y*r+x*o+v*c,t[7]=y*n+x*a+v*h,t[8]=y*s+x*l+v*u,t}function il(){var t=new Ya(16);return Ya!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function rl(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function nl(t,e){var i=e[0],r=e[1],n=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=e[9],p=e[10],d=e[11],f=e[12],m=e[13],_=e[14],g=e[15],y=i*a-r*o,x=i*l-n*o,v=i*c-s*o,b=r*l-n*a,w=r*c-s*a,T=n*c-s*l,E=h*m-u*f,I=h*_-p*f,S=h*g-d*f,A=u*_-p*m,z=u*g-d*m,C=p*g-d*_,M=y*C-x*z+v*A+b*S-w*I+T*E;return M?(t[0]=(a*C-l*z+c*A)*(M=1/M),t[1]=(n*z-r*C-s*A)*M,t[2]=(m*T-_*w+g*b)*M,t[3]=(p*w-u*T-d*b)*M,t[4]=(l*S-o*C-c*I)*M,t[5]=(i*C-n*S+s*I)*M,t[6]=(_*v-f*T-g*x)*M,t[7]=(h*T-p*v+d*x)*M,t[8]=(o*z-a*S+c*E)*M,t[9]=(r*S-i*z-s*E)*M,t[10]=(f*w-m*v+g*y)*M,t[11]=(u*v-h*w-d*y)*M,t[12]=(a*I-o*A-l*E)*M,t[13]=(i*A-r*I+n*E)*M,t[14]=(m*x-f*b-_*y)*M,t[15]=(h*b-u*x+p*y)*M,t):null}function sl(t,e,i){var r=e[0],n=e[1],s=e[2],o=e[3],a=e[4],l=e[5],c=e[6],h=e[7],u=e[8],p=e[9],d=e[10],f=e[11],m=e[12],_=e[13],g=e[14],y=e[15],x=i[0],v=i[1],b=i[2],w=i[3];return t[0]=x*r+v*a+b*u+w*m,t[1]=x*n+v*l+b*p+w*_,t[2]=x*s+v*c+b*d+w*g,t[3]=x*o+v*h+b*f+w*y,t[4]=(x=i[4])*r+(v=i[5])*a+(b=i[6])*u+(w=i[7])*m,t[5]=x*n+v*l+b*p+w*_,t[6]=x*s+v*c+b*d+w*g,t[7]=x*o+v*h+b*f+w*y,t[8]=(x=i[8])*r+(v=i[9])*a+(b=i[10])*u+(w=i[11])*m,t[9]=x*n+v*l+b*p+w*_,t[10]=x*s+v*c+b*d+w*g,t[11]=x*o+v*h+b*f+w*y,t[12]=(x=i[12])*r+(v=i[13])*a+(b=i[14])*u+(w=i[15])*m,t[13]=x*n+v*l+b*p+w*_,t[14]=x*s+v*c+b*d+w*g,t[15]=x*o+v*h+b*f+w*y,t}function ol(t,e,i){var r,n,s,o,a,l,c,h,u,p,d,f,m=i[0],_=i[1],g=i[2];return e===t?(t[12]=e[0]*m+e[4]*_+e[8]*g+e[12],t[13]=e[1]*m+e[5]*_+e[9]*g+e[13],t[14]=e[2]*m+e[6]*_+e[10]*g+e[14],t[15]=e[3]*m+e[7]*_+e[11]*g+e[15]):(n=e[1],s=e[2],o=e[3],a=e[4],l=e[5],c=e[6],h=e[7],u=e[8],p=e[9],d=e[10],f=e[11],t[0]=r=e[0],t[1]=n,t[2]=s,t[3]=o,t[4]=a,t[5]=l,t[6]=c,t[7]=h,t[8]=u,t[9]=p,t[10]=d,t[11]=f,t[12]=r*m+a*_+u*g+e[12],t[13]=n*m+l*_+p*g+e[13],t[14]=s*m+c*_+d*g+e[14],t[15]=o*m+h*_+f*g+e[15]),t}function al(t,e,i){var r=i[0],n=i[1],s=i[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*s,t[9]=e[9]*s,t[10]=e[10]*s,t[11]=e[11]*s,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function ll(t,e,i){var r=Math.sin(i),n=Math.cos(i),s=e[4],o=e[5],a=e[6],l=e[7],c=e[8],h=e[9],u=e[10],p=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=s*n+c*r,t[5]=o*n+h*r,t[6]=a*n+u*r,t[7]=l*n+p*r,t[8]=c*n-s*r,t[9]=h*n-o*r,t[10]=u*n-a*r,t[11]=p*n-l*r,t}function cl(t,e,i){var r=Math.sin(i),n=Math.cos(i),s=e[0],o=e[1],a=e[2],l=e[3],c=e[8],h=e[9],u=e[10],p=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*n-c*r,t[1]=o*n-h*r,t[2]=a*n-u*r,t[3]=l*n-p*r,t[8]=s*r+c*n,t[9]=o*r+h*n,t[10]=a*r+u*n,t[11]=l*r+p*n,t}function hl(t,e,i){var r=Math.sin(i),n=Math.cos(i),s=e[0],o=e[1],a=e[2],l=e[3],c=e[4],h=e[5],u=e[6],p=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*n+c*r,t[1]=o*n+h*r,t[2]=a*n+u*r,t[3]=l*n+p*r,t[4]=c*n-s*r,t[5]=h*n-o*r,t[6]=u*n-a*r,t[7]=p*n-l*r,t}function ul(t,e){var i=e[0],r=e[1],n=e[2],s=e[3],o=i+i,a=r+r,l=n+n,c=i*o,h=r*o,u=r*a,p=n*o,d=n*a,f=n*l,m=s*o,_=s*a,g=s*l;return t[0]=1-u-f,t[1]=h+g,t[2]=p-_,t[3]=0,t[4]=h-g,t[5]=1-c-f,t[6]=d+m,t[7]=0,t[8]=p+_,t[9]=d-m,t[10]=1-c-u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function pl(t,e,i,r,n){var s,o=1/Math.tan(e/2);return t[0]=o/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=n&&n!==1/0?(t[10]=(n+r)*(s=1/(r-n)),t[14]=2*n*r*s):(t[10]=-1,t[14]=-2*r),t}function dl(t,e,i,r,n,s,o){var a=1/(e-i),l=1/(r-n),c=1/(s-o);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+i)*a,t[13]=(n+r)*l,t[14]=(o+s)*c,t[15]=1,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var fl=sl;function ml(){var t=new Ya(3);return Ya!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function _l(t){var e=new Ya(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function gl(t){return Math.hypot(t[0],t[1],t[2])}function yl(t,e,i){var r=new Ya(3);return r[0]=t,r[1]=e,r[2]=i,r}function xl(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t}function vl(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t}function bl(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t[2]=e[2]*i[2],t}function wl(t,e,i){return t[0]=Math.min(e[0],i[0]),t[1]=Math.min(e[1],i[1]),t[2]=Math.min(e[2],i[2]),t}function Tl(t,e,i){return t[0]=Math.max(e[0],i[0]),t[1]=Math.max(e[1],i[1]),t[2]=Math.max(e[2],i[2]),t}function El(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t}function Il(t,e,i,r){return t[0]=e[0]+i[0]*r,t[1]=e[1]+i[1]*r,t[2]=e[2]+i[2]*r,t}function Sl(t,e){var i=e[0],r=e[1],n=e[2],s=i*i+r*r+n*n;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t}function Al(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function zl(t,e,i){var r=e[0],n=e[1],s=e[2],o=i[0],a=i[1],l=i[2];return t[0]=n*l-s*a,t[1]=s*o-r*l,t[2]=r*a-n*o,t}function Cl(t,e,i){var r=e[0],n=e[1],s=e[2],o=i[3]*r+i[7]*n+i[11]*s+i[15];return t[0]=(i[0]*r+i[4]*n+i[8]*s+i[12])/(o=o||1),t[1]=(i[1]*r+i[5]*n+i[9]*s+i[13])/o,t[2]=(i[2]*r+i[6]*n+i[10]*s+i[14])/o,t}function Ml(t,e,i){var r=e[0],n=e[1],s=e[2];return t[0]=r*i[0]+n*i[3]+s*i[6],t[1]=r*i[1]+n*i[4]+s*i[7],t[2]=r*i[2]+n*i[5]+s*i[8],t}function kl(t,e,i){var r=i[0],n=i[1],s=i[2],o=e[0],a=e[1],l=e[2],c=n*l-s*a,h=s*o-r*l,u=r*a-n*o,p=n*u-s*h,d=s*c-r*u,f=r*h-n*c,m=2*i[3];return h*=m,u*=m,d*=2,f*=2,t[0]=o+(c*=m)+(p*=2),t[1]=a+h+d,t[2]=l+u+f,t}var Pl,Dl=vl,Bl=bl,Ll=function(t,e,i){return t[0]=e[0]/i[0],t[1]=e[1]/i[1],t[2]=e[2]/i[2],t},Rl=gl;function Fl(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t}function Ol(t,e,i){var r=e[0],n=e[1],s=e[2],o=e[3];return t[0]=i[0]*r+i[4]*n+i[8]*s+i[12]*o,t[1]=i[1]*r+i[5]*n+i[9]*s+i[13]*o,t[2]=i[2]*r+i[6]*n+i[10]*s+i[14]*o,t[3]=i[3]*r+i[7]*n+i[11]*s+i[15]*o,t}function Vl(){var t=new Ya(4);return Ya!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function jl(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function Ul(t,e,i){i*=.5;var r=e[0],n=e[1],s=e[2],o=e[3],a=Math.sin(i),l=Math.cos(i);return t[0]=r*l+o*a,t[1]=n*l+s*a,t[2]=s*l-n*a,t[3]=o*l-r*a,t}ml(),Pl=new Ya(4),Ya!=Float32Array&&(Pl[0]=0,Pl[1]=0,Pl[2]=0,Pl[3]=0),ml(),yl(1,0,0),yl(0,1,0),Vl(),Vl(),Qa();class Nl{constructor(t,e){this.pos=t,this.dir=e}intersectsPlane(t,e,i){const r=Al(e,this.dir);if(Math.abs(r)<1e-6)return!1;const n=((t[0]-this.pos[0])*e[0]+(t[1]-this.pos[1])*e[1]+(t[2]-this.pos[2])*e[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(t,e,i){if(function(t,e){var i=t[0],r=t[1],n=t[2],s=e[0],o=e[1],a=e[2];return Math.abs(i-s)<=Ka*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(r-o)<=Ka*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(n-a)<=Ka*Math.max(1,Math.abs(n),Math.abs(a))}(this.pos,t)||0===e)return i[0]=i[1]=i[2]=0,!1;const[r,n,s]=this.dir,o=this.pos[0]-t[0],a=this.pos[1]-t[1],l=this.pos[2]-t[2],c=r*r+n*n+s*s,h=2*(o*r+a*n+l*s),u=h*h-4*c*(o*o+a*a+l*l-e*e);if(u<0){const t=Math.max(-h/2,0),c=o+r*t,u=a+n*t,p=l+s*t,d=Math.hypot(c,u,p);return i[0]=c*e/d,i[1]=u*e/d,i[2]=p*e/d,!1}{const t=(-h-Math.sqrt(u))/(2*c);if(t<0){const t=Math.hypot(o,a,l);return i[0]=o*e/t,i[1]=a*e/t,i[2]=l*e/t,!1}return i[0]=o+r*t,i[1]=a+n*t,i[2]=l+s*t,!0}}}class Zl{constructor(t,e){this.points=t,this.planes=e}static fromInvProjectionMatrix(t,e,i,r){const n=Math.pow(2,i),s=[[-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 s=Ol([],i,t),o=1/s[3]/e*n;return function(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t[2]=e[2]*i[2],t[3]=e[3]*i[3],t}(s,s,[o,o,r?1/s[3]:o,o])})),o=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const e=Sl([],zl([],Dl([],s[t[0]],s[t[1]]),Dl([],s[t[2]],s[t[1]]))),i=-Al(e,s[t[1]]);return e.concat(i)}));return new Zl(s,o)}}class ql{constructor(t,e){this.min=t,this.max=e,this.center=El([],xl([],this.min,this.max),.5)}quadrant(t){const e=[t%2==0,t<2],i=_l(this.min),r=_l(this.max);for(let t=0;t<e.length;t++)i[t]=e[t]?this.min[t]:this.center[t],r[t]=e[t]?this.center[t]:this.max[t];return r[2]=this.max[2],new ql(i,r)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}distanceZ(t){return Math.max(Math.min(this.max[2],t[2]),this.min[2])-t[2]}getCorners(){const t=this.min,e=this.max;return[[t[0],t[1],t[2]],[e[0],t[1],t[2]],[e[0],e[1],t[2]],[t[0],e[1],t[2]],[t[0],t[1],e[2]],[e[0],t[1],e[2]],[e[0],e[1],e[2]],[t[0],e[1],e[2]]]}intersects(t){const e=this.getCorners();let i=!0;for(let r=0;r<t.planes.length;r++){const n=t.planes[r];let s=0;for(let t=0;t<e.length;t++)s+=Al(n,e[t])+n[3]>=0;if(0===s)return 0;s!==e.length&&(i=!1)}if(i)return 2;for(let e=0;e<3;e++){let i=Number.MAX_VALUE,r=-Number.MAX_VALUE;for(let n=0;n<t.points.length;n++){const s=t.points[n][e]-this.min[e];i=Math.min(i,s),r=Math.max(r,s)}if(r<0||i>this.max[e]-this.min[e])return 0}return 1}}function Gl(t,e,i,r,n,s,o,a,l){if(s&&t.queryGeometry.isAboveHorizon)return!1;s&&(l*=t.pixelToTileUnitsFactor);for(const c of e)for(const e of c){const c=e.add(a),h=n&&i.elevation?i.elevation.exaggeration()*n.getElevationAt(c.x,c.y,!0):0,u=s?c:$l(c,h,r),p=s?t.tilespaceRays.map((t=>Hl(t,h))):t.queryGeometry.screenGeometry,d=Ol([],[e.x,e.y,h,1],r);if(!o&&s?l*=d[3]/i.cameraToCenterDistance:o&&!s&&(l*=i.cameraToCenterDistance/d[3]),Da(p,u,l))return!0}return!1}function $l(t,e,i){const r=Ol([],[t.x,t.y,e,1],i);return new o(r[0]/r[3],r[1]/r[3])}const Wl=yl(0,0,0),Xl=yl(0,0,1);function Hl(t,e){const i=ml();return Wl[2]=e,t.intersectsPlane(Wl,Xl,i),new o(i[0],i[1])}class Kl extends ka{}function Yl(t,{width:e,height:i},r,n){if(n){if(n instanceof Uint8ClampedArray)n=new Uint8Array(n.buffer);else if(n.length!==e*i*r)throw new RangeError("mismatched image size")}else n=new Uint8Array(e*i*r);return t.width=e,t.height=i,t.data=n,t}function Jl(t,e,i){const{width:r,height:n}=e;r===t.width&&n===t.height||(Ql(t,e,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,r),height:Math.min(t.height,n)},i),t.width=r,t.height=n,t.data=e.data)}function Ql(t,e,i,r,n,s){if(0===n.width||0===n.height)return e;if(n.width>t.width||n.height>t.height||i.x>t.width-n.width||i.y>t.height-n.height)throw new RangeError("out of range source coordinates for image copy");if(n.width>e.width||n.height>e.height||r.x>e.width-n.width||r.y>e.height-n.height)throw new RangeError("out of range destination coordinates for image copy");const o=t.data,a=e.data;for(let l=0;l<n.height;l++){const c=((i.y+l)*t.width+i.x)*s,h=((r.y+l)*e.width+r.x)*s;for(let t=0;t<n.width*s;t++)a[h+t]=o[c+t]}return e}Fn(Kl,{omit:["layers"]});class tc{constructor(t,e){Yl(this,t,1,e)}resize(t){Jl(this,new tc(t),1)}clone(){return new tc({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,n){Ql(t,e,i,r,n,1)}}class ec{constructor(t,e){Yl(this,t,4,e)}resize(t){Jl(this,new ec(t),4)}replace(t,e){e?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new ec({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,n){Ql(t,e,i,r,n,4)}}Fn(tc),Fn(ec);var ic={paint:new Is({"heatmap-radius":new bs(ue.paint_heatmap["heatmap-radius"]),"heatmap-weight":new bs(ue.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new vs(ue.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Es(ue.paint_heatmap["heatmap-color"]),"heatmap-opacity":new vs(ue.paint_heatmap["heatmap-opacity"])})};function rc(t){const e={},i=t.resolution||256,r=t.clips?t.clips.length:1,n=t.image||new ec({width:i,height:r}),s=(i,r,s)=>{e[t.evaluationKey]=s;const o=t.expression.evaluate(e);n.data[i+r+0]=Math.floor(255*o.r/o.a),n.data[i+r+1]=Math.floor(255*o.g/o.a),n.data[i+r+2]=Math.floor(255*o.b/o.a),n.data[i+r+3]=Math.floor(255*o.a)};if(t.clips)for(let e=0,n=0;e<r;++e,n+=4*i)for(let r=0,o=0;r<i;r++,o+=4){const a=r/(i-1),{start:l,end:c}=t.clips[e];s(n,o,l*(1-a)+c*a)}else for(let t=0,e=0;t<i;t++,e+=4)s(0,e,t/(i-1));return n}var nc={paint:new Is({"hillshade-illumination-direction":new vs(ue.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new vs(ue.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new vs(ue.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new vs(ue.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new vs(ue.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new vs(ue.paint_hillshade["hillshade-accent-color"])})};const sc=Ms([{name:"a_pos",components:2,type:"Int16"}],4),{members:oc}=sc;var ac=cc,lc=cc;function cc(t,e,i){i=i||2;var r,n,s,o,a,l,c,h=e&&e.length,u=h?e[0]*i:t.length,p=hc(t,0,u,i,!0),d=[];if(!p||p.next===p.prev)return d;if(h&&(p=function(t,e,i,r){var n,s,o,a=[];for(n=0,s=e.length;n<s;n++)(o=hc(t,e[n]*r,n<s-1?e[n+1]*r:t.length,r,!1))===o.next&&(o.steiner=!0),a.push(bc(o));for(a.sort(gc),n=0;n<a.length;n++)i=uc(i=yc(a[n],i),i.next);return i}(t,e,p,i)),t.length>80*i){r=s=t[0],n=o=t[1];for(var f=i;f<u;f+=i)(a=t[f])<r&&(r=a),(l=t[f+1])<n&&(n=l),a>s&&(s=a),l>o&&(o=l);c=0!==(c=Math.max(s-r,o-n))?1/c:0}return pc(p,d,i,r,n,c),d}function hc(t,e,i,r,n){var s,o;if(n===Bc(t,e,i,r)>0)for(s=e;s<i;s+=r)o=kc(s,t[s],t[s+1],o);else for(s=i-r;s>=e;s-=r)o=kc(s,t[s],t[s+1],o);return o&&Ic(o,o.next)&&(Pc(o),o=o.next),o}function uc(t,e){if(!t)return t;e||(e=t);var i,r=t;do{if(i=!1,r.steiner||!Ic(r,r.next)&&0!==Ec(r.prev,r,r.next))r=r.next;else{if(Pc(r),(r=e=r.prev)===r.next)break;i=!0}}while(i||r!==e);return e}function pc(t,e,i,r,n,s,o){if(t){!o&&s&&function(t,e,i,r){var n=t;do{null===n.z&&(n.z=vc(n.x,n.y,e,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,function(t){var e,i,r,n,s,o,a,l,c=1;do{for(i=t,t=null,s=null,o=0;i;){for(o++,r=i,a=0,e=0;e<c&&(a++,r=r.nextZ);e++);for(l=c;a>0||l>0&&r;)0!==a&&(0===l||!r||i.z<=r.z)?(n=i,i=i.nextZ,a--):(n=r,r=r.nextZ,l--),s?s.nextZ=n:t=n,n.prevZ=s,s=n;i=r}s.nextZ=null,c*=2}while(o>1)}(n)}(t,r,n,s);for(var a,l,c=t;t.prev!==t.next;)if(a=t.prev,l=t.next,s?fc(t,r,n,s):dc(t))e.push(a.i/i),e.push(t.i/i),e.push(l.i/i),Pc(t),t=l.next,c=l.next;else if((t=l)===c){o?1===o?pc(t=mc(uc(t),e,i),e,i,r,n,s,2):2===o&&_c(t,e,i,r,n,s):pc(uc(t),e,i,r,n,s,1);break}}}function dc(t){var e=t.prev,i=t,r=t.next;if(Ec(e,i,r)>=0)return!1;for(var n=t.next.next;n!==t.prev;){if(wc(e.x,e.y,i.x,i.y,r.x,r.y,n.x,n.y)&&Ec(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function fc(t,e,i,r){var n=t.prev,s=t,o=t.next;if(Ec(n,s,o)>=0)return!1;for(var a=n.x>s.x?n.x>o.x?n.x:o.x:s.x>o.x?s.x:o.x,l=n.y>s.y?n.y>o.y?n.y:o.y:s.y>o.y?s.y:o.y,c=vc(n.x<s.x?n.x<o.x?n.x:o.x:s.x<o.x?s.x:o.x,n.y<s.y?n.y<o.y?n.y:o.y:s.y<o.y?s.y:o.y,e,i,r),h=vc(a,l,e,i,r),u=t.prevZ,p=t.nextZ;u&&u.z>=c&&p&&p.z<=h;){if(u!==t.prev&&u!==t.next&&wc(n.x,n.y,s.x,s.y,o.x,o.y,u.x,u.y)&&Ec(u.prev,u,u.next)>=0)return!1;if(u=u.prevZ,p!==t.prev&&p!==t.next&&wc(n.x,n.y,s.x,s.y,o.x,o.y,p.x,p.y)&&Ec(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;u&&u.z>=c;){if(u!==t.prev&&u!==t.next&&wc(n.x,n.y,s.x,s.y,o.x,o.y,u.x,u.y)&&Ec(u.prev,u,u.next)>=0)return!1;u=u.prevZ}for(;p&&p.z<=h;){if(p!==t.prev&&p!==t.next&&wc(n.x,n.y,s.x,s.y,o.x,o.y,p.x,p.y)&&Ec(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function mc(t,e,i){var r=t;do{var n=r.prev,s=r.next.next;!Ic(n,s)&&Sc(n,r,r.next,s)&&Cc(n,s)&&Cc(s,n)&&(e.push(n.i/i),e.push(r.i/i),e.push(s.i/i),Pc(r),Pc(r.next),r=t=s),r=r.next}while(r!==t);return uc(r)}function _c(t,e,i,r,n,s){var o=t;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&Tc(o,a)){var l=Mc(o,a);return o=uc(o,o.next),l=uc(l,l.next),pc(o,e,i,r,n,s),void pc(l,e,i,r,n,s)}a=a.next}o=o.next}while(o!==t)}function gc(t,e){return t.x-e.x}function yc(t,e){var i=function(t,e){var i,r=e,n=t.x,s=t.y,o=-1/0;do{if(s<=r.y&&s>=r.next.y&&r.next.y!==r.y){var a=r.x+(s-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=n&&a>o){if(o=a,a===n){if(s===r.y)return r;if(s===r.next.y)return r.next}i=r.x<r.next.x?r:r.next}}r=r.next}while(r!==e);if(!i)return null;if(n===o)return i;var l,c=i,h=i.x,u=i.y,p=1/0;r=i;do{n>=r.x&&r.x>=h&&n!==r.x&&wc(s<u?n:o,s,h,u,s<u?o:n,s,r.x,r.y)&&(l=Math.abs(s-r.y)/(n-r.x),Cc(r,t)&&(l<p||l===p&&(r.x>i.x||r.x===i.x&&xc(i,r)))&&(i=r,p=l)),r=r.next}while(r!==c);return i}(t,e);if(!i)return e;var r=Mc(i,t),n=uc(i,i.next);return uc(r,r.next),e===i?n:e}function xc(t,e){return Ec(t.prev,t,e.prev)<0&&Ec(e.next,t,t.next)<0}function vc(t,e,i,r,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*n)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*n)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function bc(t){var e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function wc(t,e,i,r,n,s,o,a){return(n-o)*(e-a)-(t-o)*(s-a)>=0&&(t-o)*(r-a)-(i-o)*(e-a)>=0&&(i-o)*(s-a)-(n-o)*(r-a)>=0}function Tc(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Sc(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Cc(t,e)&&Cc(e,t)&&function(t,e){var i=t,r=!1,n=(t.x+e.x)/2,s=(t.y+e.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&n<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==t);return r}(t,e)&&(Ec(t.prev,t,e.prev)||Ec(t,e.prev,e))||Ic(t,e)&&Ec(t.prev,t,t.next)>0&&Ec(e.prev,e,e.next)>0)}function Ec(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Ic(t,e){return t.x===e.x&&t.y===e.y}function Sc(t,e,i,r){var n=zc(Ec(t,e,i)),s=zc(Ec(t,e,r)),o=zc(Ec(i,r,t)),a=zc(Ec(i,r,e));return n!==s&&o!==a||!(0!==n||!Ac(t,i,e))||!(0!==s||!Ac(t,r,e))||!(0!==o||!Ac(i,t,r))||!(0!==a||!Ac(i,e,r))}function Ac(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function zc(t){return t>0?1:t<0?-1:0}function Cc(t,e){return Ec(t.prev,t,t.next)<0?Ec(t,e,t.next)>=0&&Ec(t,t.prev,e)>=0:Ec(t,e,t.prev)<0||Ec(t,t.next,e)<0}function Mc(t,e){var i=new Dc(t.i,t.x,t.y),r=new Dc(e.i,e.x,e.y),n=t.next,s=e.prev;return t.next=e,e.prev=t,i.next=n,n.prev=i,r.next=i,i.prev=r,s.next=r,r.prev=s,r}function kc(t,e,i,r){var n=new Dc(t,e,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 Pc(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Dc(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Bc(t,e,i,r){for(var n=0,s=e,o=i-r;s<i;s+=r)n+=(t[o]-t[s])*(t[s+1]+t[o+1]),o=s;return n}function Lc(t,e,i,r,n){Rc(t,e,i||0,r||t.length-1,n||Oc)}function Rc(t,e,i,r,n){for(;r>i;){if(r-i>600){var s=r-i+1,o=e-i+1,a=Math.log(s),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(s-l)/s)*(o-s/2<0?-1:1);Rc(t,e,Math.max(i,Math.floor(e-o*l/s+c)),Math.min(r,Math.floor(e+(s-o)*l/s+c)),n)}var h=t[e],u=i,p=r;for(Fc(t,i,e),n(t[r],h)>0&&Fc(t,i,r);u<p;){for(Fc(t,u,p),u++,p--;n(t[u],h)<0;)u++;for(;n(t[p],h)>0;)p--}0===n(t[i],h)?Fc(t,i,p):Fc(t,++p,r),p<=e&&(i=p+1),e<=p&&(r=p-1)}}function Fc(t,e,i){var r=t[e];t[e]=t[i],t[i]=r}function Oc(t,e){return t<e?-1:t>e?1:0}function Vc(t,e){const i=t.length;if(i<=1)return[t];const r=[];let n,s;for(let e=0;e<i;e++){const i=j(t[e]);0!==i&&(t[e].area=Math.abs(i),void 0===s&&(s=i<0),s===i<0?(n&&r.push(n),n=[t[e]]):n.push(t[e]))}if(n&&r.push(n),e>1)for(let t=0;t<r.length;t++)r[t].length<=e||(Lc(r[t],e,1,r[t].length-1,jc),r[t]=r[t].slice(0,e));return r}function jc(t,e){return e.area-t.area}function Uc(t,e,i){const r=i.patternDependencies;let n=!1;for(const i of e){const e=i.paint.get(`${t}-pattern`);e.isConstant()||(n=!0);const s=e.constantOr(null);s&&(n=!0,r[s.to]=!0,r[s.from]=!0)}return n}function Nc(t,e,i,r,n){const s=n.patternDependencies;for(const o of e){const e=o.paint.get(`${t}-pattern`).value;if("constant"!==e.kind){let t=e.evaluate({zoom:r-1},i,{},n.availableImages),a=e.evaluate({zoom:r},i,{},n.availableImages),l=e.evaluate({zoom:r+1},i,{},n.availableImages);t=t&&t.name?t.name:t,a=a&&a.name?a.name:a,l=l&&l.name?l.name:l,s[t]=!0,s[a]=!0,s[l]=!0,i.patterns[o.id]={min:t,mid:a,max:l}}}return i}cc.deviation=function(t,e,i,r){var n=e&&e.length,s=Math.abs(Bc(t,0,n?e[0]*i:t.length,i));if(n)for(var o=0,a=e.length;o<a;o++)s-=Math.abs(Bc(t,e[o]*i,o<a-1?e[o+1]*i:t.length,i));var l=0;for(o=0;o<r.length;o+=3){var c=r[o]*i,h=r[o+1]*i,u=r[o+2]*i;l+=Math.abs((t[c]-t[u])*(t[h+1]-t[c+1])-(t[c]-t[h])*(t[u+1]-t[c+1]))}return 0===s&&0===l?0:Math.abs((l-s)/s)},cc.flatten=function(t){for(var e=t[0][0].length,i={vertices:[],holes:[],dimensions:e},r=0,n=0;n<t.length;n++){for(var s=0;s<t[n].length;s++)for(var o=0;o<e;o++)i.vertices.push(t[n][s][o]);n>0&&i.holes.push(r+=t[n-1].length)}return i},ac.default=lc;class Zc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Ps,this.indexArray=new $s,this.indexArray2=new Qs,this.programConfigurations=new Yo(t.layers,t.zoom),this.segments=new aa,this.segments2=new aa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection}populate(t,e,i,r){this.hasPattern=Uc("fill",this.layers,e);const n=this.layers[0].layout.get("fill-sort-key"),s=[];for(const{feature:o,id:a,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,h=za(o,t);if(!this.layers[0]._featureFilter.filter(new us(this.zoom),h,i))continue;const u=n?n.evaluate(h,{},i,e.availableImages):void 0,p={id:a,properties:o.properties,type:o.type,sourceLayerIndex:c,index:l,geometry:t?h.geometry:Aa(o,i,r),patterns:{},sortKey:u};s.push(p)}n&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of s){const{geometry:n,index:s,sourceLayerIndex:o}=r;if(this.hasPattern){const t=Nc("fill",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,n,s,i,{},e.availableImages);e.featureIndex.insert(t[s].feature,n,s,o,this.index)}}update(t,e,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i,r)}addFeatures(t,e,i,r,n){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,oc),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),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(t,e,i,r,n,s=[]){for(const t of Vc(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),r=i.vertexLength,n=[],s=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&s.push(n.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),r=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(r+e.length-1,r),n.push(e[0].x),n.push(e[0].y);for(let t=1;t<e.length;t++)this.layoutVertexArray.emplaceBack(e[t].x,e[t].y),this.indexArray2.emplaceBack(r+t-1,r+t),n.push(e[t].x),n.push(e[t].y);i.vertexLength+=e.length,i.primitiveLength+=e.length}const o=ac(n,s);for(let t=0;t<o.length;t+=3)this.indexArray.emplaceBack(r+o[t],r+o[t+1],r+o[t+2]);i.vertexLength+=e,i.primitiveLength+=o.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,n,s,r)}}Fn(Zc,{omit:["layers","patternFeatures"]});const qc=new Is({"fill-sort-key":new bs(ue.layout_fill["fill-sort-key"])});var Gc={paint:new Is({"fill-antialias":new vs(ue.paint_fill["fill-antialias"]),"fill-opacity":new bs(ue.paint_fill["fill-opacity"]),"fill-color":new bs(ue.paint_fill["fill-color"]),"fill-outline-color":new bs(ue.paint_fill["fill-outline-color"]),"fill-translate":new vs(ue.paint_fill["fill-translate"]),"fill-translate-anchor":new vs(ue.paint_fill["fill-translate-anchor"]),"fill-pattern":new ws(ue.paint_fill["fill-pattern"])}),layout:qc};const $c=Ms([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),Wc=Ms([{name:"a_centroid_pos",components:2,type:"Uint16"}]),Xc=Ms([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:Hc}=$c;var Kc=Yc;function Yc(t,e,i,r,n){this.properties={},this.extent=i,this.type=0,this._pbf=t,this._geometry=-1,this._keys=r,this._values=n,t.readFields(Jc,this,e)}function Jc(t,e,i){1==t?e.id=i.readVarint():2==t?function(t,e){for(var i=t.readVarint()+t.pos;t.pos<i;){var r=e._keys[t.readVarint()],n=e._values[t.readVarint()];e.properties[r]=n}}(i,e):3==t?e.type=i.readVarint():4==t&&(e._geometry=i.pos)}function Qc(t){for(var e,i,r=0,n=0,s=t.length,o=s-1;n<s;o=n++)r+=((i=t[o]).x-(e=t[n]).x)*(e.y+i.y);return r}Yc.types=["Unknown","Point","LineString","Polygon"],Yc.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var e,i=t.readVarint()+t.pos,r=1,n=0,s=0,a=0,l=[];t.pos<i;){if(n<=0){var c=t.readVarint();r=7&c,n=c>>3}if(n--,1===r||2===r)s+=t.readSVarint(),a+=t.readSVarint(),1===r&&(e&&l.push(e),e=[]),e.push(new o(s,a));else{if(7!==r)throw new Error("unknown command "+r);e&&e.push(e[0].clone())}}return e&&l.push(e),l},Yc.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,r=0,n=0,s=0,o=1/0,a=-1/0,l=1/0,c=-1/0;t.pos<e;){if(r<=0){var h=t.readVarint();i=7&h,r=h>>3}if(r--,1===i||2===i)(n+=t.readSVarint())<o&&(o=n),n>a&&(a=n),(s+=t.readSVarint())<l&&(l=s),s>c&&(c=s);else if(7!==i)throw new Error("unknown command "+i)}return[o,l,a,c]},Yc.prototype.toGeoJSON=function(t,e,i){var r,n,s=this.extent*Math.pow(2,i),o=this.extent*t,a=this.extent*e,l=this.loadGeometry(),c=Yc.types[this.type];function h(t){for(var e=0;e<t.length;e++){var i=t[e];t[e]=[360*(i.x+o)/s-180,360/Math.PI*Math.atan(Math.exp((180-360*(i.y+a)/s)*Math.PI/180))-90]}}switch(this.type){case 1:var u=[];for(r=0;r<l.length;r++)u[r]=l[r][0];h(l=u);break;case 2:for(r=0;r<l.length;r++)h(l[r]);break;case 3:for(l=function(t){var e=t.length;if(e<=1)return[t];for(var i,r,n=[],s=0;s<e;s++){var o=Qc(t[s]);0!==o&&(void 0===r&&(r=o<0),r===o<0?(i&&n.push(i),i=[t[s]]):i.push(t[s]))}return i&&n.push(i),n}(l),r=0;r<l.length;r++)for(n=0;n<l[r].length;n++)h(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 th=eh;function eh(t,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(ih,this,e),this.length=this._features.length}function ih(t,e,i){15===t?e.version=i.readVarint():1===t?e.name=i.readString():5===t?e.extent=i.readVarint():2===t?e._features.push(i.pos):3===t?e._keys.push(i.readString()):4===t&&e._values.push(function(t){for(var e=null,i=t.readVarint()+t.pos;t.pos<i;){var r=t.readVarint()>>3;e=1===r?t.readString():2===r?t.readFloat():3===r?t.readDouble():4===r?t.readVarint64():5===r?t.readVarint():6===r?t.readSVarint():7===r?t.readBoolean():null}return e}(i))}function rh(t,e,i){if(3===t){var r=new th(i,i.readVarint()+i.pos);r.length&&(e[r.name]=r)}}eh.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new Kc(this._pbf,e,this.extent,this._keys,this._values)};var nh={VectorTile:function(t,e){this.layers=t.readFields(rh,{},e)},VectorTileFeature:Kc,VectorTileLayer:th};function sh(t,e,i,r){const n=[],s=0===r?(t,e,i,r,n,s)=>{t.push(new o(s,i+(s-e)/(r-e)*(n-i)))}:(t,e,i,r,n,s)=>{t.push(new o(e+(s-i)/(n-i)*(r-e),s))};for(const o of t){const t=[];for(const n of o){if(n.length<=2)continue;const o=[];for(let t=0;t<n.length-1;t++){const a=n[t].x,l=n[t].y,c=n[t+1].x,h=n[t+1].y,u=0===r?a:l,p=0===r?c:h;u<e?p>e&&s(o,a,l,c,h,e):u>i?p<i&&s(o,a,l,c,h,i):o.push(n[t]),p<e&&u>=e&&s(o,a,l,c,h,e),p>i&&u<=i&&s(o,a,l,c,h,i)}let a=n[n.length-1];const l=0===r?a.x:a.y;l>=e&&l<=i&&o.push(a),o.length&&(a=o[o.length-1],o[0].x===a.x&&o[0].y===a.y||o.push(o[0]),t.push(o))}t.length&&n.push(t)}return n}const oh=nh.VectorTileFeature.types,ah=Math.pow(2,13);function lh(t,e,i,r,n,s,o,a){t.emplaceBack((e<<1)+o,(i<<1)+s,(Math.floor(r*ah)<<1)+n,Math.round(a))}function ch(t,e,i){const r=16384;t.emplaceBack(e.x,e.y,e.z,i[0]*r,i[1]*r,i[2]*r)}class hh{constructor(){this.acc=new o(0,0),this.polyCount=[]}startRing(t){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new o(t.x,t.y),this.max=new o(t.x,t.y))}append(t,e){this.currentPolyCount.edges++,this.acc._add(t);const i=this.min,r=this.max;t.x<i.x?i.x=t.x:t.x>r.x&&(r.x=t.x),t.y<i.y?i.y=t.y:t.y>r.y&&(r.y=t.y),((0===t.x||t.x===la)&&t.x===e.x)!=((0===t.y||t.y===la)&&t.y===e.y)&&this.processBorderOverlap(t,e),e.x<0!=t.x<0&&this.addBorderIntersection(0,Ai(e.y,t.y,(0-e.x)/(t.x-e.x))),e.x>la!=t.x>la&&this.addBorderIntersection(1,Ai(e.y,t.y,(la-e.x)/(t.x-e.x))),e.y<0!=t.y<0&&this.addBorderIntersection(2,Ai(e.x,t.x,(0-e.y)/(t.y-e.y))),e.y>la!=t.y>la&&this.addBorderIntersection(3,Ai(e.x,t.x,(la-e.y)/(t.y-e.y)))}addBorderIntersection(t,e){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[t];e<i[0]&&(i[0]=e),e>i[1]&&(i[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const i=0===t.x?0:1;this.addBorderIntersection(i,e.y),this.addBorderIntersection(i,t.y)}else{const i=0===t.y?2:3;this.addBorderIntersection(i,e.x),this.addBorderIntersection(i,t.x)}}centroid(){const t=this.polyCount.reduce(((t,e)=>t+e.edges),0);return 0!==t?this.acc.div(t)._round():new o(0,0)}span(){return new o(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0)}}class uh{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new Bs,this.centroidVertexArray=new yo,this.indexArray=new $s,this.programConfigurations=new Yo(t.layers,t.zoom),this.segments=new aa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.enableTerrain=t.enableTerrain}populate(t,e,i,r){this.features=[],this.hasPattern=Uc("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(t){const e=Math.exp(Math.PI*(1-t.y/(1<<t.z)*2));return 80150034*e/(e*e+1)/la/(1<<t.z)}(i);for(const{feature:n,id:s,index:o,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=za(n,t);if(!this.layers[0]._featureFilter.filter(new us(this.zoom),l,i))continue;const c={id:s,sourceLayerIndex:a,index:o,geometry:t?l.geometry:Aa(n,i,r),properties:n.properties,type:n.type,patterns:{}},h=this.layoutVertexArray.length;this.hasPattern?this.features.push(Nc("fill-extrusion",this.layers,c,this.zoom,e)):this.addFeature(c,c.geometry,o,i,{},e.availableImages,r),e.featureIndex.insert(n,c.geometry,o,a,this.index,h)}this.sortBorders()}addFeatures(t,e,i,r,n){for(const t of this.features){const{geometry:s}=t;this.addFeature(t,s,t.index,e,i,r,n)}this.sortBorders()}update(t,e,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Hc),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,Xc.members,!0))),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){0!==this.centroidVertexArray.length&&(this.centroidVertexBuffer?this.needsCentroidUpdate&&this.centroidVertexBuffer.updateData(this.centroidVertexArray):this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Wc.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(t,e,i,r,n,s,a){const l=[new o(0,0),new o(la,la)],c=a.projection,h="globe"===c.name,u=this.enableTerrain&&!h?new hh:null;h&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new so);const p=Vc(e,500);for(let t=p.length-1;t>=0;t--){const e=p[t];(0===e.length||(d=e[0]).every((t=>t.x<=0))||d.every((t=>t.x>=la))||d.every((t=>t.y<=0))||d.every((t=>t.y>=la)))&&p.splice(t,1)}var d;let f;if(h){const t=11.25,e=1<<r.z,i=ga(r.x/e),n=ga((r.x+1)/e),s=ya(r.y/e),a=ya((r.y+1)/e);f=function(t,e,i,r,n=0,s){const a=[];if(!t.length||!i||!r)return a;const l=(t,e)=>{for(const i of t)a.push({polygon:i,bounds:e})},c=Math.ceil(Math.log2(i)),h=Math.ceil(Math.log2(r)),u=c-h,p=[];for(let t=0;t<Math.abs(u);t++)p.push(u>0?0:1);for(let t=0;t<Math.min(c,h);t++)p.push(0),p.push(1);let d=t;if(d=sh(d,e[0].y-n,e[1].y+n,1),d=sh(d,e[0].x-n,e[1].x+n,0),!d.length)return a;const f=[];for(p.length?f.push({polygons:d,bounds:e,depth:0}):l(d,e);f.length;){const t=f.pop(),e=t.depth,i=p[e],r=t.bounds[0],a=t.bounds[1],c=0===i?r.x:r.y,h=0===i?a.x:a.y,u=s?s(i,c,h):.5*(c+h),d=sh(t.polygons,c-n,u+n,i),m=sh(t.polygons,u-n,h+n,i);if(d.length){const t=[r,new o(0===i?u:a.x,1===i?u:a.y)];p.length>e+1?f.push({polygons:d,bounds:t,depth:e+1}):l(d,t)}if(m.length){const t=[new o(0===i?u:r.x,1===i?u:r.y),a];p.length>e+1?f.push({polygons:m,bounds:t,depth:e+1}):l(m,t)}}return a}(p,l,Math.ceil((n-i)/t),Math.ceil((s-a)/t),1,((t,i,n)=>{if(0===t)return.5*(i+n);{const t=ya((r.y+i/la)/e);return(ma(.5*(ya((r.y+n/la)/e)+t))*e-r.y)*la}}))}else{f=[];for(const t of p)f.push({polygon:t,bounds:l})}for(const e of f){const i=e.polygon;let n=0,s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(let t=0;t<i.length;t++){const o=i[t];if(0===o.length)continue;n+=o.length;let a=0;u&&u.startRing(o[0]);for(let t=0;t<o.length;t++){const i=o[t];if(t>=1){const n=o[t-1];if(!ph(i,n,e.bounds)){u&&u.append(i,n),s.vertexLength+4>aa.MAX_VERTEX_ARRAY_LENGTH&&(s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const t=i.sub(n)._perp(),e=t.x/(Math.abs(t.x)+Math.abs(t.y)),o=t.y>0?1:0,l=n.dist(i);a+l>32768&&(a=0),lh(this.layoutVertexArray,i.x,i.y,e,o,0,0,a),lh(this.layoutVertexArray,i.x,i.y,e,o,0,1,a),a+=l,lh(this.layoutVertexArray,n.x,n.y,e,o,0,0,a),lh(this.layoutVertexArray,n.x,n.y,e,o,0,1,a);const p=s.vertexLength;if(this.indexArray.emplaceBack(p,p+2,p+1),this.indexArray.emplaceBack(p+1,p+2,p+3),s.vertexLength+=4,s.primitiveLength+=2,h){const t=this.layoutVertexExtArray,e=c.projectTilePoint(i.x,i.y,r),s=c.projectTilePoint(n.x,n.y,r),o=c.upVector(r,i.x,i.y),a=c.upVector(r,n.x,n.y);ch(t,e,o),ch(t,e,o),ch(t,s,a),ch(t,s,a)}}}}}if(s.vertexLength+n>aa.MAX_VERTEX_ARRAY_LENGTH&&(s=this.segments.prepareSegment(n,this.layoutVertexArray,this.indexArray)),"Polygon"!==oh[t.type])continue;const o=[],a=[],l=s.vertexLength;for(let t=0;t<i.length;t++){const e=i[t];if(0!==e.length){e!==i[0]&&a.push(o.length/2);for(let t=0;t<e.length;t++){const i=e[t];lh(this.layoutVertexArray,i.x,i.y,0,0,1,1,0),o.push(i.x),o.push(i.y),u&&u.currentPolyCount.top++,h&&ch(this.layoutVertexExtArray,c.projectTilePoint(i.x,i.y,r),c.upVector(r,i.x,i.y))}}}const p=ac(o,a);for(let t=0;t<p.length;t+=3)this.indexArray.emplaceBack(l+p[t],l+p[t+2],l+p[t+1]);s.primitiveLength+=p.length/3,s.vertexLength+=n}if(u&&u.polyCount.length>0){if(u.borders){u.vertexArrayOffset=this.centroidVertexArray.length;const t=u.borders,e=this.featuresOnBorder.push(u)-1;for(let i=0;i<4;i++)t[i][0]!==Number.MAX_VALUE&&this.borders[i].push(e)}this.encodeCentroid(u.borders?void 0:u.centroid(),u)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,n,s,r)}sortBorders(){for(let t=0;t<4;t++)this.borders[t].sort(((e,i)=>this.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[i].borders[t][0]))}encodeCentroid(t,e,i=!0){let r,n;if(t)if(0!==t.y){const i=e.span()._mult(this.tileToMeter);r=(Math.max(t.x,1)<<3)+Math.min(7,Math.round(i.x/10)),n=(Math.max(t.y,1)<<3)+Math.min(7,Math.round(i.y/10))}else r=Math.ceil(7*(t.x+450)),n=0;else r=0,n=+i;let s=i?this.centroidVertexArray.length:e.vertexArrayOffset;for(const t of e.polyCount){i&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*t.edges+t.top);for(let e=0;e<2*t.edges;e++)this.centroidVertexArray.emplace(s++,0,n),this.centroidVertexArray.emplace(s++,r,n);for(let e=0;e<t.top;e++)this.centroidVertexArray.emplace(s++,r,n)}}}function ph(t,e,i){return t.x===e.x&&(t.x<i[0].x||t.x>i[1].x)||t.y===e.y&&(t.y<i[0].y||t.y>i[1].y)}Fn(uh,{omit:["layers","features"]}),Fn(hh);var dh={paint:new Is({"fill-extrusion-opacity":new vs(ue["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new bs(ue["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new vs(ue["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new vs(ue["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new ws(ue["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new bs(ue["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new bs(ue["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new vs(ue["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function fh(t,e){return t.x*e.x+t.y*e.y}function mh(t,e){if(1===t.length){let i=0;const r=e[i++];let n;for(;!n||r.equals(n);)if(n=e[i++],!n)return 1/0;for(;i<e.length;i++){const s=e[i],o=t[0],a=n.sub(r),l=s.sub(r),c=o.sub(r),h=fh(a,a),u=fh(a,l),p=fh(l,l),d=fh(c,a),f=fh(c,l),m=h*p-u*u,_=(p*d-u*f)/m,g=(h*f-u*d)/m,y=r.z*(1-_-g)+n.z*_+s.z*g;if(isFinite(y))return y}return 1/0}{let t=1/0;for(const i of e)t=Math.min(t,i.z);return t}}function _h(t){const e=new o(t[0],t[1]);return e.z=t[2],e}function gh(t,e,i,r,n,s,o,a){const l=o*n.getElevationAt(t,e,!0,!0),c=0!==s[0],h=c?0===s[1]?o*(s[0]/7-450):o*function(t,e,i){const r=Math.floor(e[0]/8),n=Math.floor(e[1]/8),s=10*(e[0]-8*r),o=10*(e[1]-8*n),a=t.getElevationAt(r,n,!0,!0),l=t.getMeterToDEM(i),c=Math.floor(.5*(s*l-1)),h=Math.floor(.5*(o*l-1)),u=t.tileCoordToPixel(r,n),p=2*c+1,d=2*h+1,f=function(t,e,i,r,n){return[t.getElevationAtPixel(e,i,!0),t.getElevationAtPixel(e+n,i,!0),t.getElevationAtPixel(e,i+n,!0),t.getElevationAtPixel(e+r,i+n,!0)]}(t,u.x-c,u.y-h,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 a+Math.max(y*s,x*o)}(n,s,a):l;return{base:l+(0===i)?-1:i,top:c?Math.max(h+r,l+i+2):l+r}}const yh=Ms([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:xh}=yh,vh=Ms([{name:"a_packed",components:3,type:"Float32"}]),{members:bh}=vh,wh=nh.VectorTileFeature.types,Th=Math.cos(Math.PI/180*37.5);class Eh{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new Ls,this.layoutVertexArray2=new Rs,this.indexArray=new $s,this.programConfigurations=new Yo(t.layers,t.zoom),this.segments=new aa,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i,r){this.hasPattern=Uc("line",this.layers,e);const n=this.layers[0].layout.get("line-sort-key"),s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=za(e,t);if(!this.layers[0]._featureFilter.filter(new us(this.zoom),c,i))continue;const h=n?n.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Aa(e,i,r),patterns:{},sortKey:h};s.push(u)}n&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:o,featureIndex:a}=e,l=this.addConstantDashes(o);for(const r of s){const{geometry:n,index:s,sourceLayerIndex:c}=r;if(l&&this.addFeatureDashes(r,o),this.hasPattern){const t=Nc("line",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,n,s,i,o.positions,e.availableImages);a.insert(t[s].feature,n,s,c,this.index)}}addConstantDashes(t){let e=!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)e=!0;else{const e=n.value,i=r.value;if(!i)continue;t.addDash(i.from,e),t.addDash(i.to,e),i.other&&t.addDash(i.other,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const r of this.layers){const n=r.paint.get("line-dasharray").value,s=r.layout.get("line-cap").value;if("constant"===n.kind&&"constant"===s.kind)continue;let o,a,l,c,h,u;if("constant"===n.kind){const t=n.value;if(!t)continue;o=t.other||t.to,a=t.to,l=t.from}else o=n.evaluate({zoom:i-1},t),a=n.evaluate({zoom:i},t),l=n.evaluate({zoom:i+1},t);"constant"===s.kind?c=h=u=s.value:(c=s.evaluate({zoom:i-1},t),h=s.evaluate({zoom:i},t),u=s.evaluate({zoom:i+1},t)),e.addDash(o,c),e.addDash(a,h),e.addDash(l,u);const p=e.getKey(o,c),d=e.getKey(a,h),f=e.getKey(l,u);t.patterns[r.id]={min:p,mid:d,max:f}}}update(t,e,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i,r)}addFeatures(t,e,i,r,n){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,bh)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,xh),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,r,n,s){const o=this.layers[0].layout,a=o.get("line-join").evaluate(t,{}),l=o.get("line-cap").evaluate(t,{}),c=o.get("line-miter-limit"),h=o.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,a,l,c,h);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,n,s,r)}addLine(t,e,i,r,n,s){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e<t.length-1;e++)this.totalDistance+=t[e].dist(t[e+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const o="Polygon"===wh[e.type];let a=t.length;for(;a>=2&&t[a-1].equals(t[a-2]);)a--;let l=0;for(;l<a-1&&t[l].equals(t[l+1]);)l++;if(a<(o?3:2))return;"bevel"===i&&(n=1.05);const c=this.overscaling<=16?122880/(512*this.overscaling):0,h=this.segments.prepareSegment(10*a,this.layoutVertexArray,this.indexArray);let u,p,d,f,m;this.e1=this.e2=-1,o&&(u=t[a-2],m=t[l].sub(u)._unit()._perp());for(let e=l;e<a;e++){if(d=e===a-1?o?t[l+1]:void 0:t[e+1],d&&t[e].equals(d))continue;m&&(f=m),u&&(p=u),u=t[e],m=d?d.sub(u)._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<Th&&p&&d,w=f.x*m.y-f.y*m.x>0;if(b&&e>l){const t=u.dist(p);if(t>2*c){const e=u.sub(u.sub(p)._mult(c/t)._round());this.updateDistance(p,e),this.addCurrentVertex(e,f,0,0,h),p=e}}const T=p&&d;let E=T?i:o?"butt":r;if(T&&"round"===E&&(x<s?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,u),"miter"===E)_._mult(x),this.addCurrentVertex(u,_,0,0,h);else if("flipbevel"===E){if(x>100)_=m.mult(-1);else{const t=x*f.add(m).mag()/f.sub(m).mag();_._perp()._mult(t*(w?-1:1))}this.addCurrentVertex(u,_,0,0,h),this.addCurrentVertex(u,_.mult(-1),0,0,h)}else if("bevel"===E||"fakeround"===E){const t=-Math.sqrt(x*x-1),e=w?t:0,i=w?0:t;if(p&&this.addCurrentVertex(u,f,e,i,h),"fakeround"===E){const t=Math.round(180*v/Math.PI/20);for(let e=1;e<t;e++){let i=e/t;if(.5!==i){const t=i-.5;i+=i*t*(i-1)*((1.0904+g*(g*(3.55645-1.43519*g)-3.2452))*t*t+(.848013+g*(.215638*g-1.06021)))}const r=m.sub(f)._mult(i)._add(f)._unit()._mult(w?-1:1);this.addHalfVertex(u,r.x,r.y,!1,w,0,h)}}d&&this.addCurrentVertex(u,m,-e,-i,h)}else if("butt"===E)this.addCurrentVertex(u,_,0,0,h);else if("square"===E){const t=p?1:-1;p||this.addCurrentVertex(u,_,t,t,h),this.addCurrentVertex(u,_,0,0,h),p&&this.addCurrentVertex(u,_,t,t,h)}else"round"===E&&(p&&(this.addCurrentVertex(u,f,0,0,h),this.addCurrentVertex(u,f,1,1,h,!0)),d&&(this.addCurrentVertex(u,m,-1,-1,h,!0),this.addCurrentVertex(u,m,0,0,h)));if(b&&e<a-1){const t=u.dist(d);if(t>2*c){const e=u.add(d.sub(u)._mult(c/t)._round());this.updateDistance(u,e),this.addCurrentVertex(e,m,0,0,h),u=e}}}}addCurrentVertex(t,e,i,r,n,s=!1){const o=e.y*r-e.x,a=-e.y-e.x*r;this.addHalfVertex(t,e.x+e.y*i,e.y-e.x*i,s,!1,i,n),this.addHalfVertex(t,o,a,s,!0,-r,n)}addHalfVertex({x:t,y:e},i,r,n,s,o,a){this.layoutVertexArray.emplaceBack((t<<1)+(n?1:0),(e<<1)+(s?1:0),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===o?0:o<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const l=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,l),a.primitiveLength++),s?this.e2=l:this.e1=l}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}Fn(Eh,{omit:["layers","patternFeatures"]});const Ih=new Is({"line-cap":new bs(ue.layout_line["line-cap"]),"line-join":new bs(ue.layout_line["line-join"]),"line-miter-limit":new vs(ue.layout_line["line-miter-limit"]),"line-round-limit":new vs(ue.layout_line["line-round-limit"]),"line-sort-key":new bs(ue.layout_line["line-sort-key"])});var Sh={paint:new Is({"line-opacity":new bs(ue.paint_line["line-opacity"]),"line-color":new bs(ue.paint_line["line-color"]),"line-translate":new vs(ue.paint_line["line-translate"]),"line-translate-anchor":new vs(ue.paint_line["line-translate-anchor"]),"line-width":new bs(ue.paint_line["line-width"]),"line-gap-width":new bs(ue.paint_line["line-gap-width"]),"line-offset":new bs(ue.paint_line["line-offset"]),"line-blur":new bs(ue.paint_line["line-blur"]),"line-dasharray":new ws(ue.paint_line["line-dasharray"]),"line-pattern":new ws(ue.paint_line["line-pattern"]),"line-gradient":new Es(ue.paint_line["line-gradient"])}),layout:Ih};const Ah=new class extends bs{possiblyEvaluate(t,e){return e=new us(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,r){return e=I({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,r)}}(Sh.paint.properties["line-width"].specification);function zh(t,e){return e>0?e+2*t:t}Ah.useIntegerZoom=!0;const Ch=Ms([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"},{name:"a_z_tile_anchor",components:4,type:"Int16"}],4),Mh=Ms([{name:"a_projected_pos",components:3,type:"Float32"}],4);Ms([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const kh=Ms([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),Ph=Ms([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);Ms([{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 Dh=Ms([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Bh=Ms([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Ms([{name:"triangle",components:3,type:"Uint16"}]),Ms([{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"}]),Ms([{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"}]),Ms([{type:"Float32",name:"offsetX"}]),Ms([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);const Lh=128;function Rh(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new us(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:r}=i;let n=0;for(;n<e.length&&e[n]<=t;)n++;n=Math.max(0,n-1);let s=n;for(;s<e.length&&e[s]<t+1;)s++;s=Math.min(e.length-1,s);const o=e[n],a=e[s];return"composite"===i.kind?{kind:"composite",minZoom:o,maxZoom:a,interpolationType:r}:{kind:"camera",minZoom:o,maxZoom:a,minSize:i.evaluate(new us(o)),maxSize:i.evaluate(new us(a)),interpolationType:r}}}function Fh(t,{uSize:e,uSizeT:i},{lowerSize:r,upperSize:n}){return"source"===t.kind?r/Lh:"composite"===t.kind?Ai(r/Lh,n/Lh,i):e}function Oh(t,e){let i=0,r=0;if("constant"===t.kind)r=t.layoutSize;else if("source"!==t.kind){const{interpolationType:n,minZoom:s,maxZoom:o}=t,a=n?v($i.interpolationFactor(n,e,s,o),0,1):0;"camera"===t.kind?r=Ai(t.minSize,t.maxSize,a):i=a}return{uSizeT:i,uSize:r}}var Vh=Object.freeze({__proto__:null,getSizeData:Rh,evaluateSizeForFeature:Fh,evaluateSizeForZoom:Oh,SIZE_PACK_FACTOR:Lh});function jh(t,e,i){return t.sections.forEach((t=>{t.text=function(t,e,i){const r=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?t=t.toLocaleUpperCase():"lowercase"===r&&(t=t.toLocaleLowerCase()),hs.applyArabicShaping&&(t=hs.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Uh={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var Nh=function(t,e,i,r,n){var s,o,a=8*n-r-1,l=(1<<a)-1,c=l>>1,h=-7,u=i?n-1:0,p=i?-1:1,d=t[e+u];for(u+=p,s=d&(1<<-h)-1,d>>=-h,h+=a;h>0;s=256*s+t[e+u],u+=p,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=r;h>0;o=256*o+t[e+u],u+=p,h-=8);if(0===s)s=1-c;else{if(s===l)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,r),s-=c}return(d?-1:1)*o*Math.pow(2,s-r)},Zh=function(t,e,i,r,n,s){var o,a,l,c=8*s-n-1,h=(1<<c)-1,u=h>>1,p=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:s-1,f=r?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=h):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+u>=1?p/l:p*Math.pow(2,1-u))*l>=2&&(o++,l/=2),o+u>=h?(a=0,o=h):o+u>=1?(a=(e*l-1)*Math.pow(2,n),o+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,n),o=0));n>=8;t[i+d]=255&a,d+=f,a/=256,n-=8);for(o=o<<n|a,c+=n;c>0;t[i+d]=255&o,d+=f,o/=256,c-=8);t[i+d-f]|=128*m},qh=Gh;function Gh(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}Gh.Varint=0,Gh.Fixed64=1,Gh.Bytes=2,Gh.Fixed32=5;var $h=4294967296,Wh=1/$h,Xh="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function Hh(t){return t.type===Gh.Bytes?t.readVarint()+t.pos:t.pos+1}function Kh(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function Yh(t,e,i){var r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(r);for(var n=i.pos-1;n>=t;n--)i.buf[n+r]=i.buf[n]}function Jh(t,e){for(var i=0;i<t.length;i++)e.writeVarint(t[i])}function Qh(t,e){for(var i=0;i<t.length;i++)e.writeSVarint(t[i])}function tu(t,e){for(var i=0;i<t.length;i++)e.writeFloat(t[i])}function eu(t,e){for(var i=0;i<t.length;i++)e.writeDouble(t[i])}function iu(t,e){for(var i=0;i<t.length;i++)e.writeBoolean(t[i])}function ru(t,e){for(var i=0;i<t.length;i++)e.writeFixed32(t[i])}function nu(t,e){for(var i=0;i<t.length;i++)e.writeSFixed32(t[i])}function su(t,e){for(var i=0;i<t.length;i++)e.writeFixed64(t[i])}function ou(t,e){for(var i=0;i<t.length;i++)e.writeSFixed64(t[i])}function au(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function lu(t,e,i){t[i]=e,t[i+1]=e>>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function cu(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function hu(t,e,i){e.glyphs=[],1===t&&i.readMessage(uu,e)}function uu(t,e,i){if(3===t){const{id:t,bitmap:r,width:n,height:s,left:o,top:a,advance:l}=i.readMessage(pu,{});e.glyphs.push({id:t,bitmap:new tc({width:n+6,height:s+6},r),metrics:{width:n,height:s,left:o,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function pu(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}function du(t){let e=0,i=0;for(const r of t)e+=r.w*r.h,i=Math.max(i,r.w);t.sort(((t,e)=>e.h-t.h));const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let n=0,s=0;for(const e of t)for(let t=r.length-1;t>=0;t--){const i=r[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,s=Math.max(s,e.y+e.h),n=Math.max(n,e.x+e.w),e.w===i.w&&e.h===i.h){const e=r.pop();t<r.length&&(r[t]=e)}else e.h===i.h?(i.x+=e.w,i.w-=e.w):e.w===i.w?(i.y+=e.h,i.h-=e.h):(r.push({x:i.x+e.w,y:i.y,w:i.w-e.w,h:e.h}),i.y+=e.h,i.h-=e.h);break}}return{w:n,h:s,fill:e/(n*s)||0}}Gh.prototype={destroy:function(){this.buf=null},readFields:function(t,e,i){for(i=i||this.length;this.pos<i;){var r=this.readVarint(),n=r>>3,s=this.pos;this.type=7&r,t(n,e,this),this.pos===s&&this.skip(r)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=au(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=cu(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=au(this.buf,this.pos)+au(this.buf,this.pos+4)*$h;return this.pos+=8,t},readSFixed64:function(){var t=au(this.buf,this.pos)+cu(this.buf,this.pos+4)*$h;return this.pos+=8,t},readFloat:function(){var t=Nh(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Nh(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,r=this.buf;return e=127&(i=r[this.pos++]),i<128?e:(e|=(127&(i=r[this.pos++]))<<7,i<128?e:(e|=(127&(i=r[this.pos++]))<<14,i<128?e:(e|=(127&(i=r[this.pos++]))<<21,i<128?e:function(t,e,i){var r,n,s=i.buf;if(r=(112&(n=s[i.pos++]))>>4,n<128)return Kh(t,r,e);if(r|=(127&(n=s[i.pos++]))<<3,n<128)return Kh(t,r,e);if(r|=(127&(n=s[i.pos++]))<<10,n<128)return Kh(t,r,e);if(r|=(127&(n=s[i.pos++]))<<17,n<128)return Kh(t,r,e);if(r|=(127&(n=s[i.pos++]))<<24,n<128)return Kh(t,r,e);if(r|=(1&(n=s[i.pos++]))<<31,n<128)return Kh(t,r,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(i=r[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&Xh?function(t,e,i){return Xh.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var r="",n=e;n<i;){var s,o,a,l=t[n],c=null,h=l>239?4:l>223?3:l>191?2:1;if(n+h>i)break;1===h?l<128&&(c=l):2===h?128==(192&(s=t[n+1]))&&(c=(31&l)<<6|63&s)<=127&&(c=null):3===h?(o=t[n+2],128==(192&(s=t[n+1]))&&128==(192&o)&&((c=(15&l)<<12|(63&s)<<6|63&o)<=2047||c>=55296&&c<=57343)&&(c=null)):4===h&&(o=t[n+2],a=t[n+3],128==(192&(s=t[n+1]))&&128==(192&o)&&128==(192&a)&&((c=(15&l)<<18|(63&s)<<12|(63&o)<<6|63&a)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),n+=h}return r}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==Gh.Bytes)return t.push(this.readVarint(e));var i=Hh(this);for(t=t||[];this.pos<i;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==Gh.Bytes)return t.push(this.readSVarint());var e=Hh(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==Gh.Bytes)return t.push(this.readBoolean());var e=Hh(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==Gh.Bytes)return t.push(this.readFloat());var e=Hh(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==Gh.Bytes)return t.push(this.readDouble());var e=Hh(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==Gh.Bytes)return t.push(this.readFixed32());var e=Hh(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==Gh.Bytes)return t.push(this.readSFixed32());var e=Hh(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==Gh.Bytes)return t.push(this.readFixed64());var e=Hh(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==Gh.Bytes)return t.push(this.readSFixed64());var e=Hh(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=7&t;if(e===Gh.Varint)for(;this.buf[this.pos++]>127;);else if(e===Gh.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Gh.Fixed32)this.pos+=4;else{if(e!==Gh.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var i=new Uint8Array(e);i.set(this.buf),this.buf=i,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),lu(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),lu(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),lu(this.buf,-1&t,this.pos),lu(this.buf,Math.floor(t*Wh),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),lu(this.buf,-1&t,this.pos),lu(this.buf,Math.floor(t*Wh),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(t,e){var i,r;if(t>=0?(i=t%4294967296|0,r=t/4294967296|0):(r=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,r=r+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,i){i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)<<4;e.buf[e.pos++]|=i|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(r,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,i){for(var r,n,s=0;s<e.length;s++){if((r=e.charCodeAt(s))>55295&&r<57344){if(!n){r>56319||s+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):n=r;continue}if(r<56320){t[i++]=239,t[i++]=191,t[i++]=189,n=r;continue}r=n-55296<<10|r-56320|65536,n=null}else n&&(t[i++]=239,t[i++]=191,t[i++]=189,n=null);r<128?t[i++]=r:(r<2048?t[i++]=r>>6|192:(r<65536?t[i++]=r>>12|224:(t[i++]=r>>18|240,t[i++]=r>>12&63|128),t[i++]=r>>6&63|128),t[i++]=63&r|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&Yh(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),Zh(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),Zh(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i<e;i++)this.buf[this.pos++]=t[i]},writeRawMessage:function(t,e){this.pos++;var i=this.pos;t(e,this);var r=this.pos-i;r>=128&&Yh(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r},writeMessage:function(t,e,i){this.writeTag(t,Gh.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,Jh,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,Qh,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,iu,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,tu,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,eu,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,ru,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,nu,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,su,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,ou,e)},writeBytesField:function(t,e){this.writeTag(t,Gh.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,Gh.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,Gh.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,Gh.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,Gh.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,Gh.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,Gh.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,Gh.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,Gh.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,Gh.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};class fu{constructor(t,{pixelRatio:e,version:i,stretchX:r,stretchY:n,content:s}){this.paddedRect=t,this.pixelRatio=e,this.stretchX=r,this.stretchY=n,this.content=s,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]}}Fn(fu),Fn(class{constructor(t,e){const i={},r={};this.haveRenderCallbacks=[];const n=[];this.addImages(t,i,n),this.addImages(e,r,n);const{w:s,h:o}=du(n),a=new ec({width:s||1,height:o||1});for(const e in t){const r=t[e],n=i[e].paddedRect;ec.copy(r.data,a,{x:0,y:0},{x:n.x+1,y:n.y+1},r.data)}for(const t in e){const i=e[t],n=r[t].paddedRect,s=n.x+1,o=n.y+1,l=i.data.width,c=i.data.height;ec.copy(i.data,a,{x:0,y:0},{x:s,y:o},i.data),ec.copy(i.data,a,{x:0,y:c-1},{x:s,y:o-1},{width:l,height:1}),ec.copy(i.data,a,{x:0,y:0},{x:s,y:o+c},{width:l,height:1}),ec.copy(i.data,a,{x:l-1,y:0},{x:s-1,y:o},{width:1,height:c}),ec.copy(i.data,a,{x:0,y:0},{x:s+l,y:o},{width:1,height:c})}this.image=a,this.iconPositions=i,this.patternPositions=r}addImages(t,e,i){for(const r in t){const n=t[r],s={x:0,y:0,w:n.data.width+2,h:n.data.height+2};i.push(s),e[r]=new fu(s,n),n.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e){t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const i in t.updatedImages)this.patchUpdatedImage(this.iconPositions[i],t.getImage(i),e),this.patchUpdatedImage(this.patternPositions[i],t.getImage(i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[r,n]=t.tl;i.update(e.data,void 0,{x:r,y:n})}});const mu={horizontal:1,vertical:2,horizontalOnly:3};function _u(t){let e=.5,i=.5;switch(t){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(t){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:e,verticalAlign:i}}class gu extends o{constructor(t,e,i,r,n){super(t,e),this.angle=r,this.z=i,void 0!==n&&(this.segment=n)}clone(){return new gu(this.x,this.y,this.z,this.angle,this.segment)}}Fn(gu);const yu=1e20;function xu(t,e,i,r,n,s,o,a,l){for(let c=e;c<e+r;c++)vu(t,i*s+c,s,n,o,a,l);for(let c=i;c<i+n;c++)vu(t,c*s+e,1,r,o,a,l)}function vu(t,e,i,r,n,s,o){s[0]=0,o[0]=-yu,o[1]=yu,n[0]=t[e];for(let a=1,l=0,c=0;a<r;a++){n[a]=t[e+a*i];const r=a*a;do{const t=s[l];c=(n[a]-n[t]+r-t*t)/(a-t)/2}while(c<=o[l]&&--l>-1);l++,s[l]=a,o[l]=c,o[l+1]=yu}for(let a=0,l=0;a<r;a++){for(;o[l+1]<a;)l++;const r=s[l],c=a-r;t[e+a*i]=n[r]+c*c}}class bu{constructor(t,e,i){this.requestManager=t,this.localGlyphMode=e,this.localFontFamily=i,this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(t){this.url=t}getGlyphs(t,e){const i=[];for(const e in t)for(const r of t[e])i.push({stack:e,id:r});T(i,(({stack:t,id:e},i)=>{let r=this.entries[t];r||(r=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let n=r.glyphs[e];if(void 0!==n)return void i(null,{stack:t,id:e,glyph:n});if(n=this._tinySDF(r,t,e),n)return r.glyphs[e]=n,void i(null,{stack:t,id:e,glyph:n});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(r.ranges[s])return void i(null,{stack:t,id:e,glyph:n});let o=r.requests[s];o||(o=r.requests[s]=[],bu.loadGlyphRange(t,s,this.url,this.requestManager,((t,e)=>{if(e){r.ascender=e.ascender,r.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(r.glyphs[+t]=e.glyphs[+t]);r.ranges[s]=!0}for(const i of o)i(t,e);delete r.requests[s]}))),o.push(((r,n)=>{r?i(r):n&&i(null,{stack:t,id:e,glyph:n.glyphs[e]||null})}))}),((t,i)=>{if(t)e(t);else if(i){const t={};for(const{stack:e,id:r,glyph:n}of i)void 0===t[e]&&(t[e]={}),void 0===t[e].glyphs&&(t[e].glyphs={}),t[e].glyphs[r]=n&&{id:n.id,bitmap:n.bitmap.clone(),metrics:n.metrics},t[e].ascender=this.entries[e].ascender,t[e].descender=this.entries[e].descender;e(null,t)}}))}_doesCharSupportLocalGlyph(t){return 0!==this.localGlyphMode&&(2===this.localGlyphMode?!!this.localFontFamily:!!this.localFontFamily&&($n(t)||Wn(t)||qn(t)||Gn(t)||Zn(t)))}_tinySDF(t,e,i){const r=this.localFontFamily;if(!r||!this._doesCharSupportLocalGlyph(i))return;let n=t.tinySDF;if(!n){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),n=t.tinySDF=new bu.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 s=String.fromCharCode(i),{data:o,width:a,height:l,glyphWidth:c,glyphHeight:h,glyphLeft:u,glyphTop:p,glyphAdvance:d}=n.draw(s);return this.localGlyphs[n.fontWeight][i]={id:i,bitmap:new tc({width:a,height:l},o),metrics:{width:c/2,height:h/2,left:u/2,top:p/2-27,advance:d/2,localGlyph:!0}}}}bu.loadGlyphRange=function(t,e,i,r,n){const s=256*e,o=s+255,a=r.transformRequest(r.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${s}-${o}`),Wt.Glyphs);Jt(a,((t,e)=>{if(t)n(t);else if(e){const t={},i=function(t){return new qh(t).readFields(hu,{})}(e);for(const e of i.glyphs)t[e.id]=e;n(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},bu.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:r=.25,fontFamily:n="sans-serif",fontWeight:s="normal",fontStyle:o="normal"}){this.buffer=e,this.cutoff=r,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${o} ${s} ${t}px ${n}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:n,actualBoundingBoxRight:s}=this.ctx.measureText(t),o=Math.floor(i),a=Math.min(this.size-this.buffer,Math.ceil(s-n)),l=Math.min(this.size-this.buffer,Math.ceil(i)+Math.ceil(r)),c=a+2*this.buffer,h=l+2*this.buffer,u=c*h,p=new Uint8ClampedArray(u),d={data:p,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:o,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return d;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+o+1);const y=f.getImageData(m,m,a,l);g.fill(yu,0,u),_.fill(0,0,u);for(let t=0;t<l;t++)for(let e=0;e<a;e++){const i=y.data[4*(t*a+e)+3]/255;if(0===i)continue;const r=(t+m)*c+e+m;if(1===i)g[r]=0,_[r]=yu;else{const t=.5-i;g[r]=t>0?t*t:0,_[r]=t<0?t*t:0}}xu(g,0,0,c,h,c,this.f,this.v,this.z),xu(_,m,m,a,l,c,this.f,this.v,this.z);for(let t=0;t<u;t++){const e=Math.sqrt(g[t])-Math.sqrt(_[t]);p[t]=Math.round(255-255*(e/this.radius+this.cutoff))}return d}};const wu=Number.POSITIVE_INFINITY,Tu=Math.sqrt(2);function Eu(t,e){return e[1]!==wu?function(t,e,i){let r=0,n=0;switch(e=Math.abs(e),i=Math.abs(i),t){case"top-right":case"top-left":case"top":n=i-7;break;case"bottom-right":case"bottom-left":case"bottom":n=7-i}switch(t){case"top-right":case"bottom-right":case"right":r=-e;break;case"top-left":case"bottom-left":case"left":r=e}return[r,n]}(t,e[0],e[1]):function(t,e){let i=0,r=0;e<0&&(e=0);const n=e/Tu;switch(t){case"top-right":case"top-left":r=n-7;break;case"bottom-right":case"bottom-left":r=7-n;break;case"bottom":r=7-e;break;case"top":r=e-7}switch(t){case"top-right":case"bottom-right":i=-n;break;case"top-left":case"bottom-left":i=n;break;case"left":i=e;break;case"right":i=-e}return[i,r]}(t,e[0])}const Iu=nh.VectorTileFeature.types,Su=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Au(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m){const _=h?Math.min(32640,Math.round(h[0])):0,g=h?Math.min(32640,Math.round(h[1])):0;t.emplaceBack(e,i,Math.round(32*o),Math.round(32*a),l,c,(_<<1)+(u?1:0),g,16*p,16*d,256*f,256*m,r,n,s,0)}function zu(t,e,i){t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i)}function Cu(t){for(const e of t.sections)if(Jn(e.text))return!0;return!1}class Mu{constructor(t){this.layoutVertexArray=new js,this.indexArray=new $s,this.programConfigurations=t,this.segments=new aa,this.dynamicLayoutVertexArray=new Rs,this.opacityVertexArray=new Us,this.placedSymbolArray=new co}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(t,e,i,r){this.isEmpty()||(i&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ch.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,Mh.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,Su,!0),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}Fn(Mu);class ku{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new aa,this.collisionVertexArray=new Gs,this.collisionVertexArrayExt=new Rs}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,kh.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Ph.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}Fn(ku);class Pu{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=rl([]),this.placementViewportMatrix=rl([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Rh(this.zoom,e["text-size"]),this.iconSizeData=Rh(this.zoom,e["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((t=>mu[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection}createArrays(){this.text=new Mu(new Yo(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new Mu(new Yo(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new po,this.lineVertexArray=new fo,this.symbolInstances=new uo}calculateGlyphDependencies(t,e,i,r,n){for(let i=0;i<t.length;i++)if(e[t.charCodeAt(i)]=!0,r&&n){const r=Uh[t.charAt(i)];r&&(e[r.charCodeAt(0)]=!0)}}populate(t,e,i,r){const n=this.layers[0],s=n.layout,o=s.get("text-font"),a=s.get("text-field"),l=s.get("icon-image"),c=("constant"!==a.value.kind||a.value.value instanceof Oe&&!a.value.value.isEmpty()||a.value.value.toString().length>0)&&("constant"!==o.value.kind||o.value.value.length>0),h="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,u=s.get("symbol-sort-key");if(this.features=[],!c&&!h)return;const p=e.iconDependencies,d=e.glyphDependencies,f=e.availableImages,m=new us(this.zoom);for(const{feature:e,id:a,index:l,sourceLayerIndex:_}of t){const t=n._featureFilter.needGeometry,g=za(e,t);if(!n._featureFilter.filter(m,g,i))continue;let y,x;if(t||(g.geometry=Aa(e,i,r)),c){const t=n.getValueAndResolveTokens("text-field",g,i,f),e=Oe.factory(t);Cu(e)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===ls()||this.hasRTLText&&hs.isParsed())&&(y=jh(e,n,g))}if(h){const t=n.getValueAndResolveTokens("icon-image",g,i,f);x=t instanceof Ve?t:Ve.fromString(t)}if(!y&&!x)continue;const v=this.sortFeaturesByKey?u.evaluate(g,{},i):void 0;if(this.features.push({id:a,text:y,icon:x,index:l,sourceLayerIndex:_,geometry:g.geometry,properties:e.properties,type:Iu[e.type],sortKey:v}),x&&(p[x.name]=!0),y){const t=o.evaluate(g,{},i).join(","),e="map"===s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(mu.vertical)>=0;for(const i of y.sections)if(i.image)p[i.image.name]=!0;else{const r=Xn(y.toString()),n=i.fontStack||t,s=d[n]=d[n]||{};this.calculateGlyphDependencies(i.text,s,e,this.allowVerticalPlacement,r)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},i={},r=[];let n=0;function s(e){r.push(t[e]),n++}function o(t,e,n){const s=i[t];return delete i[t],i[e]=s,r[s].geometry[0].pop(),r[s].geometry[0]=r[s].geometry[0].concat(n[0]),s}function a(t,i,n){const s=e[i];return delete e[i],e[t]=s,r[s].geometry[0].shift(),r[s].geometry[0]=n[0].concat(r[s].geometry[0]),s}function l(t,e,i){const r=i?e[0][e[0].length-1]:e[0][0];return`${t}:${r.x}:${r.y}`}for(let c=0;c<t.length;c++){const h=t[c],u=h.geometry,p=h.text?h.text.toString():null;if(!p){s(c);continue}const d=l(p,u),f=l(p,u,!0);if(d in i&&f in e&&i[d]!==e[f]){const t=a(d,f,u),n=o(d,f,r[t].geometry);delete e[d],delete i[f],i[l(p,r[n].geometry,!0)]=n,r[t].geometry=null}else d in i?o(d,f,u):f in e?a(d,f,u):(s(c),e[d]=n-1,i[f]=n-1)}return r.filter((t=>t.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,i,r),this.icon.programConfigurations.updatePaintArrays(t,e,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(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length,r=t.segment;if(void 0!==r){let i=t.dist(e[r+1]),n=t.dist(e[r]);const s={};for(let t=r+1;t<e.length;t++)s[t]={x:e[t].x,y:e[t].y,tileUnitDistanceFromAnchor:i},t<e.length-1&&(i+=e[t+1].dist(e[t]));for(let t=r||0;t>=0;t--)s[t]={x:e[t].x,y:e[t].y,tileUnitDistanceFromAnchor:n},t>0&&(n+=e[t-1].dist(e[t]));for(let t=0;t<e.length;t++){const e=s[t];this.lineVertexArray.emplaceBack(e.x,e.y,e.tileUnitDistanceFromAnchor)}}return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,r,n,s,o,a,l,c,h,u,p,d){const f=t.indexArray,m=t.layoutVertexArray,_=t.segments.prepareSegment(4*e.length,m,f,this.canOverlap?s.sortKey:void 0),g=this.glyphOffsetArray.length,y=_.vertexLength,x=this.allowVerticalPlacement&&o===mu.vertical?Math.PI/2:0,v=s.text&&s.text.sections;for(let r=0;r<e.length;r++){const{tl:n,tr:o,bl:c,br:h,tex:u,pixelOffsetTL:g,pixelOffsetBR:y,minFontScaleX:b,minFontScaleY:w,glyphOffset:T,isSDF:E,sectionIndex:I}=e[r],S=_.vertexLength,A=T[1];Au(m,a.x,a.y,a.z,l.x,l.y,n.x,A+n.y,u.x,u.y,i,E,g.x,g.y,b,w),Au(m,a.x,a.y,a.z,l.x,l.y,o.x,A+o.y,u.x+u.w,u.y,i,E,y.x,g.y,b,w),Au(m,a.x,a.y,a.z,l.x,l.y,c.x,A+c.y,u.x,u.y+u.h,i,E,g.x,y.y,b,w),Au(m,a.x,a.y,a.z,l.x,l.y,h.x,A+h.y,u.x+u.w,u.y+u.h,i,E,y.x,y.y,b,w),zu(t.dynamicLayoutVertexArray,a,x),f.emplaceBack(S,S+1,S+2),f.emplaceBack(S+1,S+2,S+3),_.vertexLength+=4,_.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(T[0]),r!==e.length-1&&I===e[r+1].sectionIndex||t.programConfigurations.populatePaintArrays(m.length,s,s.index,{},p,d,v&&v[I])}t.placedSymbolArray.emplaceBack(a.x,a.y,a.z,l.x,l.y,g,this.glyphOffsetArray.length-g,y,c,h,l.segment,i?i[0]:0,i?i[1]:0,r[0],r[1],o,0,!1,0,u,0)}_commitLayoutVertex(t,e,i,r,n,s,o){t.emplaceBack(e,i,r,n,s,Math.round(o.x),Math.round(o.y))}_addCollisionDebugVertices(t,e,i,r,n,s,a){const l=i.segments.prepareSegment(4,i.layoutVertexArray,i.indexArray),c=l.vertexLength,h=a.tileAnchorX,u=a.tileAnchorY;for(let t=0;t<4;t++)i.collisionVertexArray.emplaceBack(0,0,0,0);i.collisionVertexArrayExt.emplaceBack(e,-t.padding,-t.padding),i.collisionVertexArrayExt.emplaceBack(e,t.padding,-t.padding),i.collisionVertexArrayExt.emplaceBack(e,t.padding,t.padding),i.collisionVertexArrayExt.emplaceBack(e,-t.padding,t.padding),this._commitLayoutVertex(i.layoutVertexArray,r,n,s,h,u,new o(t.x1,t.y1)),this._commitLayoutVertex(i.layoutVertexArray,r,n,s,h,u,new o(t.x2,t.y1)),this._commitLayoutVertex(i.layoutVertexArray,r,n,s,h,u,new o(t.x2,t.y2)),this._commitLayoutVertex(i.layoutVertexArray,r,n,s,h,u,new o(t.x1,t.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(t,e,i,r,n,s){for(let o=r;o<n;o++){const r=i.get(o),n=this.getSymbolInstanceTextSize(t,s,e,o);this._addCollisionDebugVertices(r,n,this.textCollisionBox,r.projectedAnchorX,r.projectedAnchorY,r.projectedAnchorZ,s)}}_addIconDebugCollisionBoxes(t,e,i,r,n,s){for(let o=r;o<n;o++){const r=i.get(o),n=this.getSymbolInstanceIconSize(t,e,o);this._addCollisionDebugVertices(r,n,this.iconCollisionBox,r.projectedAnchorX,r.projectedAnchorY,r.projectedAnchorZ,s)}}generateCollisionDebugBuffers(t,e){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new ku(Zs,Dh.members,Qs),this.iconCollisionBox=new ku(Zs,Dh.members,Qs);const i=Oh(this.iconSizeData,t),r=Oh(this.textSizeData,t);for(let n=0;n<this.symbolInstances.length;n++){const s=this.symbolInstances.get(n);this._addTextDebugCollisionBoxes(r,t,e,s.textBoxStartIndex,s.textBoxEndIndex,s),this._addTextDebugCollisionBoxes(r,t,e,s.verticalTextBoxStartIndex,s.verticalTextBoxEndIndex,s),this._addIconDebugCollisionBoxes(i,t,e,s.iconBoxStartIndex,s.iconBoxEndIndex,s),this._addIconDebugCollisionBoxes(i,t,e,s.verticalIconBoxStartIndex,s.verticalIconBoxEndIndex,s)}}getSymbolInstanceTextSize(t,e,i,r){const n=this.text.placedSymbolArray.get(e.rightJustifiedTextSymbolIndex>=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:r),s=Fh(this.textSizeData,t,n)/24;return this.tilePixelRatio*s}getSymbolInstanceIconSize(t,e,i){const r=this.icon.placedSymbolArray.get(i),n=Fh(this.iconSizeData,t,r);return this.tilePixelRatio*n}_commitDebugCollisionVertexUpdate(t,e,i){t.emplaceBack(e,-i,-i),t.emplaceBack(e,i,-i),t.emplaceBack(e,i,i),t.emplaceBack(e,-i,i)}_updateTextDebugCollisionBoxes(t,e,i,r,n,s){for(let o=r;o<n;o++){const r=i.get(o),n=this.getSymbolInstanceTextSize(t,s,e,o);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,n,r.padding)}}_updateIconDebugCollisionBoxes(t,e,i,r,n){for(let s=r;s<n;s++){const r=i.get(s),n=this.getSymbolInstanceIconSize(t,e,s);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,n,r.padding)}}updateCollisionDebugBuffers(t,e){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const i=Oh(this.iconSizeData,t),r=Oh(this.textSizeData,t);for(let n=0;n<this.symbolInstances.length;n++){const s=this.symbolInstances.get(n);this._updateTextDebugCollisionBoxes(r,t,e,s.textBoxStartIndex,s.textBoxEndIndex,s),this._updateTextDebugCollisionBoxes(r,t,e,s.verticalTextBoxStartIndex,s.verticalTextBoxEndIndex,s),this._updateIconDebugCollisionBoxes(i,t,e,s.iconBoxStartIndex,s.iconBoxEndIndex),this._updateIconDebugCollisionBoxes(i,t,e,s.verticalIconBoxStartIndex,s.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(t,e,i,r,n,s,o,a,l){const c={};for(let r=e;r<i;r++){const e=t.get(r);c.textBox={x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,padding:e.padding,projectedAnchorX:e.projectedAnchorX,projectedAnchorY:e.projectedAnchorY,projectedAnchorZ:e.projectedAnchorZ,tileAnchorX:e.tileAnchorX,tileAnchorY:e.tileAnchorY},c.textFeatureIndex=e.featureIndex;break}for(let e=r;e<n;e++){const i=t.get(e);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 e=s;e<o;e++){const i=t.get(e);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 e=a;e<l;e++){const i=t.get(e);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(t){this.collisionArrays=[];for(let e=0;e<this.symbolInstances.length;e++){const i=this.symbolInstances.get(e);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,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(t,e){const i=t.placedSymbolArray.get(e),r=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;e<r;e+=4)t.indexArray.emplaceBack(e,e+1,e+2),t.indexArray.emplaceBack(e+1,e+2,e+3)}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const e=Math.sin(t),i=Math.cos(t),r=[],n=[],s=[];for(let t=0;t<this.symbolInstances.length;++t){s.push(t);const o=this.symbolInstances.get(t);r.push(0|Math.round(e*o.tileAnchorX+i*o.tileAnchorY)),n.push(o.featureIndex)}return s.sort(((t,e)=>r[t]-r[e]||n[e]-n[t])),s}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,i)=>{t>=0&&i.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t)})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Fn(Pu,{omit:["layers","collisionBoxArray","features","compareText"]}),Pu.MAX_GLYPHS=65535,Pu.addDynamicAttributes=zu;const Du=new Is({"symbol-placement":new vs(ue.layout_symbol["symbol-placement"]),"symbol-spacing":new vs(ue.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new vs(ue.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new bs(ue.layout_symbol["symbol-sort-key"]),"symbol-z-order":new vs(ue.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new vs(ue.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new vs(ue.layout_symbol["icon-ignore-placement"]),"icon-optional":new vs(ue.layout_symbol["icon-optional"]),"icon-rotation-alignment":new vs(ue.layout_symbol["icon-rotation-alignment"]),"icon-size":new bs(ue.layout_symbol["icon-size"]),"icon-text-fit":new vs(ue.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new vs(ue.layout_symbol["icon-text-fit-padding"]),"icon-image":new bs(ue.layout_symbol["icon-image"]),"icon-rotate":new bs(ue.layout_symbol["icon-rotate"]),"icon-padding":new vs(ue.layout_symbol["icon-padding"]),"icon-keep-upright":new vs(ue.layout_symbol["icon-keep-upright"]),"icon-offset":new bs(ue.layout_symbol["icon-offset"]),"icon-anchor":new bs(ue.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new vs(ue.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new vs(ue.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new vs(ue.layout_symbol["text-rotation-alignment"]),"text-field":new bs(ue.layout_symbol["text-field"]),"text-font":new bs(ue.layout_symbol["text-font"]),"text-size":new bs(ue.layout_symbol["text-size"]),"text-max-width":new bs(ue.layout_symbol["text-max-width"]),"text-line-height":new bs(ue.layout_symbol["text-line-height"]),"text-letter-spacing":new bs(ue.layout_symbol["text-letter-spacing"]),"text-justify":new bs(ue.layout_symbol["text-justify"]),"text-radial-offset":new bs(ue.layout_symbol["text-radial-offset"]),"text-variable-anchor":new vs(ue.layout_symbol["text-variable-anchor"]),"text-anchor":new bs(ue.layout_symbol["text-anchor"]),"text-max-angle":new vs(ue.layout_symbol["text-max-angle"]),"text-writing-mode":new vs(ue.layout_symbol["text-writing-mode"]),"text-rotate":new bs(ue.layout_symbol["text-rotate"]),"text-padding":new vs(ue.layout_symbol["text-padding"]),"text-keep-upright":new vs(ue.layout_symbol["text-keep-upright"]),"text-transform":new bs(ue.layout_symbol["text-transform"]),"text-offset":new bs(ue.layout_symbol["text-offset"]),"text-allow-overlap":new vs(ue.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new vs(ue.layout_symbol["text-ignore-placement"]),"text-optional":new vs(ue.layout_symbol["text-optional"])});var Bu={paint:new Is({"icon-opacity":new bs(ue.paint_symbol["icon-opacity"]),"icon-color":new bs(ue.paint_symbol["icon-color"]),"icon-halo-color":new bs(ue.paint_symbol["icon-halo-color"]),"icon-halo-width":new bs(ue.paint_symbol["icon-halo-width"]),"icon-halo-blur":new bs(ue.paint_symbol["icon-halo-blur"]),"icon-translate":new vs(ue.paint_symbol["icon-translate"]),"icon-translate-anchor":new vs(ue.paint_symbol["icon-translate-anchor"]),"text-opacity":new bs(ue.paint_symbol["text-opacity"]),"text-color":new bs(ue.paint_symbol["text-color"],{runtimeType:be,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new bs(ue.paint_symbol["text-halo-color"]),"text-halo-width":new bs(ue.paint_symbol["text-halo-width"]),"text-halo-blur":new bs(ue.paint_symbol["text-halo-blur"]),"text-translate":new vs(ue.paint_symbol["text-translate"]),"text-translate-anchor":new vs(ue.paint_symbol["text-translate-anchor"])}),layout:Du};class Lu{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:ge,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Fn(Lu,{omit:["defaultValue"]});class Ru extends na{constructor(t){super(t,Bu)}recalculate(t,e){super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)<0&&t.push(e);this.layout._values["text-writing-mode"]=t}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(t,e,i,r){const n=this.layout.get(t).evaluate(e,{},i,r),s=this._unevaluatedLayout._values[t];return s.isDataDriven()||Dr(s.value)||!n?n:function(t,e){return e.replace(/{([^{}]+)}/g,((e,i)=>i in t?String(t[i]):""))}(e.properties,n)}createBucket(t){return new Pu(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of Bu.paint.overridableProperties){if(!Ru.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Lu(e),r=new Pr(i,e.property.specification);let n=null;n="constant"===e.value.kind||"source"===e.value.kind?new Lr("source",r):new Rr("composite",r,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new ys(e.property,n,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Ru.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),r=Bu.paint.properties[e];let n=!1;const s=t=>{for(const e of t)if(r.overrides&&r.overrides.hasOverride(e))return void(n=!0)};if("constant"===i.value.kind&&i.value.value instanceof Oe)s(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{n||(e instanceof qe&&Ne(e.value)===Ie?s(e.value.sections):e instanceof Xe?s(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return n}getProgramConfiguration(t){return new Ko(this,t)}}var Fu={paint:new Is({"background-color":new vs(ue.paint_background["background-color"]),"background-pattern":new Ts(ue.paint_background["background-pattern"]),"background-opacity":new vs(ue.paint_background["background-opacity"])})},Ou={paint:new Is({"raster-opacity":new vs(ue.paint_raster["raster-opacity"]),"raster-hue-rotate":new vs(ue.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new vs(ue.paint_raster["raster-brightness-min"]),"raster-brightness-max":new vs(ue.paint_raster["raster-brightness-max"]),"raster-saturation":new vs(ue.paint_raster["raster-saturation"]),"raster-contrast":new vs(ue.paint_raster["raster-contrast"]),"raster-resampling":new vs(ue.paint_raster["raster-resampling"]),"raster-fade-duration":new vs(ue.paint_raster["raster-fade-duration"])})};class Vu extends na{constructor(t){super(t,{}),this.implementation=t}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(t){this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)}onRemove(t){this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)}}var ju={paint:new Is({"sky-type":new vs(ue.paint_sky["sky-type"]),"sky-atmosphere-sun":new vs(ue.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new vs(ue.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new vs(ue.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new vs(ue.paint_sky["sky-gradient-radius"]),"sky-gradient":new Es(ue.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new vs(ue.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new vs(ue.paint_sky["sky-atmosphere-color"]),"sky-opacity":new vs(ue.paint_sky["sky-opacity"])})};function Uu(t,e,i){const r=[0,0,1],n=jl([]);return function(t,e,i){i*=.5;var r=e[0],n=e[1],s=e[2],o=e[3],a=Math.sin(i),l=Math.cos(i);t[0]=r*l-s*a,t[1]=n*l+o*a,t[2]=s*l+r*a,t[3]=o*l-n*a}(n,n,i?-p(t)+Math.PI:p(t)),Ul(n,n,-p(e)),kl(r,r,n),Sl(r,r)}const Nu={circle:class extends na{constructor(t){super(t,Ha)}createBucket(t){return new ka(t)}queryRadius(t){const e=t;return qa("circle-radius",this,e)+qa("circle-stroke-width",this,e)+Ga(this.paint.get("circle-translate"))}queryIntersectsFeature(t,e,i,r,n,s,o,a){const l=Wa(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),s.angle,t.pixelToTileUnitsFactor),c=this.paint.get("circle-radius").evaluate(e,i)+this.paint.get("circle-stroke-width").evaluate(e,i);return Gl(t,r,s,o,a,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,c)}getProgramIds(){return["circle"]}getProgramConfiguration(t){return new Ko(this,t)}},heatmap:class extends na{createBucket(t){return new Kl(t)}constructor(t){super(t,ic),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=rc({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(t){return qa("heatmap-radius",this,t)}queryIntersectsFeature(t,e,i,r,n,s,a,l){const c=this.paint.get("heatmap-radius").evaluate(e,i);return Gl(t,r,s,a,l,!0,!0,new o(0,0),c)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(t){return new Ko(this,t)}},hillshade:class extends na{constructor(t){super(t,nc)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getProgramConfiguration(t){return new Ko(this,t)}},fill:class extends na{constructor(t){super(t,Gc)}getProgramIds(){const t=this.paint.get("fill-pattern"),e=t&&t.constantOr(1),i=[e?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&i.push(e&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),i}getProgramConfiguration(t){return new Ko(this,t)}recalculate(t,e){super.recalculate(t,e);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(t){return new Zc(t)}queryRadius(){return Ga(this.paint.get("fill-translate"))}queryIntersectsFeature(t,e,i,r,n,s){return!t.queryGeometry.isAboveHorizon&&Ba($a(t.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),s.angle,t.pixelToTileUnitsFactor),r)}isTileClipped(){return!0}},"fill-extrusion":class extends na{constructor(t){super(t,dh)}createBucket(t){return new uh(t)}queryRadius(){return Ga(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(t){return new Ko(this,t)}queryIntersectsFeature(t,e,i,r,n,s,a,l,c){const h=Wa(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),s.angle,t.pixelToTileUnitsFactor),u=this.paint.get("fill-extrusion-height").evaluate(e,i),p=this.paint.get("fill-extrusion-base").evaluate(e,i),d=[0,0],f=l&&s.elevation,m=s.elevation?s.elevation.exaggeration():1,_=t.tile.getBucket(this);if(f&&_ instanceof uh){const t=_.centroidVertexArray,e=c+1;if(e<t.length){const i=t.get(e);d[0]=i.a_centroid_pos0,d[1]=i.a_centroid_pos1}}if(0===d[0]&&1===d[1])return!1;const g=function(t,e,i,r,n,s,a,l,c){return s?function(t,e,i,r,n,s,o,a,l){const c=[],h=[],u=[0,0,0,1];for(const p of t){const t=[],d=[];for(const c of p){const h=c.x+r.x,p=c.y+r.y,f=gh(h,p,e,i,s,o,a,l);u[0]=h,u[1]=p,u[2]=f.base,u[3]=1,Ol(u,u,n),u[3]=Math.max(u[3],1e-5);const m=_h([u[0]/u[3],u[1]/u[3],u[2]/u[3]]);u[0]=h,u[1]=p,u[2]=f.top,u[3]=1,Ol(u,u,n),u[3]=Math.max(u[3],1e-5);const _=_h([u[0]/u[3],u[1]/u[3],u[2]/u[3]]);t.push(m),d.push(_)}c.push(t),h.push(d)}return[c,h]}(t,e,i,r,n,s,a,l,c):function(t,e,i,r,n){const s=[],a=[],l=n[8]*e,c=n[9]*e,h=n[10]*e,u=n[11]*e,p=n[8]*i,d=n[9]*i,f=n[10]*i,m=n[11]*i;for(const e of t){const t=[],i=[];for(const s of e){const e=s.x+r.x,a=s.y+r.y,_=n[0]*e+n[4]*a+n[12],g=n[1]*e+n[5]*a+n[13],y=n[2]*e+n[6]*a+n[14],x=n[3]*e+n[7]*a+n[15],v=_+l,b=g+c,w=y+h,T=Math.max(x+u,1e-5),E=_+p,I=g+d,S=y+f,A=Math.max(x+m,1e-5),z=new o(v/T,b/T);z.z=w/T,t.push(z);const C=new o(E/A,I/A);C.z=S/A,i.push(C)}s.push(t),a.push(i)}return[s,a]}(t,e,i,r,n)}(r,p,u,h,a,f?l:null,d,m,s.center.lat),y=t.queryGeometry;return function(t,e,i){let r=1/0;Ba(i,e)&&(r=mh(i,e[0]));for(let n=0;n<e.length;n++){const s=e[n],o=t[n];for(let t=0;t<s.length-1;t++){const e=s[t],n=[e,s[t+1],o[t+1],o[t],e];Pa(i,n)&&(r=Math.min(r,mh(i,n)))}}return r!==1/0&&r}(g[0],g[1],y.isPointQuery()?y.screenBounds:y.screenGeometry)}},line:class extends na{constructor(t){super(t,Sh),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=t._styleExpression&&t._styleExpression.expression instanceof Si,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=Ah.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new Eh(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getProgramConfiguration(t){return new Ko(this,t)}queryRadius(t){const e=t,i=zh(qa("line-width",this,e),qa("line-gap-width",this,e)),r=qa("line-offset",this,e);return i/2+Math.abs(r)+Ga(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,r,n,s){if(t.queryGeometry.isAboveHorizon)return!1;const a=$a(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),s.angle,t.pixelToTileUnitsFactor),l=t.pixelToTileUnitsFactor/2*zh(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),c=this.paint.get("line-offset").evaluate(e,i);return c&&(r=function(t,e){const i=[],r=new o(0,0);for(let n=0;n<t.length;n++){const s=t[n],o=[];for(let t=0;t<s.length;t++){const i=s[t-1],n=s[t],a=s[t+1],l=0===t?r:n.sub(i)._unit()._perp(),c=t===s.length-1?r:a.sub(n)._unit()._perp(),h=l._add(c)._unit();h._mult(1/(h.x*c.x+h.y*c.y)),o.push(h._mult(e)._add(n))}i.push(o)}return i}(r,c*t.pixelToTileUnitsFactor)),function(t,e,i){for(let r=0;r<e.length;r++){const n=e[r];if(t.length>=3)for(let e=0;e<n.length;e++)if(Ua(t,n[e]))return!0;if(La(t,n,i))return!0}return!1}(a,r,l)}isTileClipped(){return!0}},symbol:Ru,background:class extends na{constructor(t){super(t,Fu)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}},raster:class extends na{constructor(t){super(t,Ou)}getProgramIds(){return["raster"]}},sky:class extends na{constructor(t){super(t,ju),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"sky-gradient"===t?this._updateColorRamp():"sky-atmosphere-sun"!==t&&"sky-atmosphere-halo-color"!==t&&"sky-atmosphere-color"!==t&&"sky-atmosphere-sun-intensity"!==t||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=rc({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(t){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const e=t.style.light.properties.get("position");return this._lightPosition.azimuthal!==e.azimuthal||this._lightPosition.polar!==e.polar}return!1}getCenter(t,e){if("atmosphere"===this.paint.get("sky-type")){const i=this.paint.get("sky-atmosphere-sun"),r=!i,n=t.style.light,s=n.properties.get("position");return r&&"viewport"===n.properties.get("anchor")&&O("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),r?Uu(s.azimuthal,90-s.polar,e):Uu(i[0],90-i[1],e)}const i=this.paint.get("sky-gradient-center");return Uu(i[0],90-i[1],e)}is3D(){return!1}isSky(){return!0}markSkyboxValid(t){this._skyboxInvalidated=!1,this._lightPosition=t.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const t=this.paint.get("sky-type");return"atmosphere"===t?["skyboxCapture","skybox"]:"gradient"===t?["skyboxGradient"]:null}}};function Zu(t){return"custom"===t.type?new Vu(t):new Nu[t.type](t)}class qu{constructor(t,e,i,r){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,r)}update(t,e,i){const{width:r,height:n}=t,{context:s}=this,{gl:o}=s,{HTMLImageElement:a,HTMLCanvasElement:c,HTMLVideoElement:h,ImageData:u,ImageBitmap:p}=l;if(o.bindTexture(o.TEXTURE_2D,this.texture),s.pixelStoreUnpackFlipY.set(!1),s.pixelStoreUnpack.set(1),s.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA&&(!e||!1!==e.premultiply)),i||this.size&&this.size[0]===r&&this.size[1]===n){const{x:e,y:s}=i||{x:0,y:0};t instanceof a||t instanceof c||t instanceof h||t instanceof u||p&&t instanceof p?o.texSubImage2D(o.TEXTURE_2D,0,e,s,o.RGBA,o.UNSIGNED_BYTE,t):o.texSubImage2D(o.TEXTURE_2D,0,e,s,r,n,o.RGBA,o.UNSIGNED_BYTE,t.data)}else this.size=[r,n],t instanceof a||t instanceof c||t instanceof h||t instanceof u||p&&t instanceof p?o.texImage2D(o.TEXTURE_2D,0,this.format,this.format,o.UNSIGNED_BYTE,t):o.texImage2D(o.TEXTURE_2D,0,this.format,r,n,0,this.format,o.UNSIGNED_BYTE,t.data);this.useMipmap=Boolean(e&&e.useMipmap&&this.isSizePowerOfTwo()),this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(t,e){const{context:i}=this,{gl:r}=i;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.filter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_NEAREST:t),this.filter=t),e!==this.wrap&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrap=e)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}function Gu(t){const{userImage:e}=t;return!!(e&&e.render&&e.render())&&(t.data.replace(new Uint8Array(e.data.buffer)),!0)}class $u extends he{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new ec({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:t,callback:e}of this.requestors)this._notify(t,e);this.requestors=[]}}getImage(t){return this.images[t]}addImage(t,e){this._validate(t,e)&&(this.images[t]=e)}_validate(t,e){let i=!0;return this._validateStretch(e.stretchX,e.data&&e.data.width)||(this.fire(new ce(new Error(`Image "${t}" has invalid "stretchX" value`))),i=!1),this._validateStretch(e.stretchY,e.data&&e.data.height)||(this.fire(new ce(new Error(`Image "${t}" has invalid "stretchY" value`))),i=!1),this._validateContent(e.content,e)||(this.fire(new ce(new Error(`Image "${t}" has invalid "content" value`))),i=!1),i}_validateStretch(t,e){if(!t)return!0;let i=0;for(const r of t){if(r[0]<i||r[1]<r[0]||e<r[1])return!1;i=r[1]}return!0}_validateContent(t,e){return!(t&&(4!==t.length||t[0]<0||e.data.width<t[0]||t[1]<0||e.data.height<t[1]||t[2]<0||e.data.width<t[2]||t[3]<0||e.data.height<t[3]||t[2]<t[0]||t[3]<t[1]))}updateImage(t,e){e.version=this.images[t].version+1,this.images[t]=e,this.updatedImages[t]=!0}removeImage(t){const e=this.images[t];delete this.images[t],delete this.patterns[t],e.userImage&&e.userImage.onRemove&&e.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(t,e){let i=!0;if(!this.isLoaded())for(const e of t)this.images[e]||(i=!1);this.isLoaded()||i?this._notify(t,e):this.requestors.push({ids:t,callback:e})}_notify(t,e){const i={};for(const e of t){this.images[e]||this.fire(new le("styleimagemissing",{id:e}));const t=this.images[e];t?i[e]={data:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)}:O(`Image "${e}" 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.`)}e(null,i)}getPixelSize(){const{width:t,height:e}=this.atlasImage;return{width:t,height:e}}getPattern(t){const e=this.patterns[t],i=this.getImage(t);if(!i)return null;if(e&&e.position.version===i.version)return e.position;if(e)e.position.version=i.version;else{const e={w:i.data.width+2,h:i.data.height+2,x:0,y:0},r=new fu(e,i);this.patterns[t]={bin:e,position:r}}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){const e=t.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new qu(t,this.atlasImage,e.RGBA),this.atlasTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE)}_updatePatternAtlas(){const t=[];for(const e in this.patterns)t.push(this.patterns[e].bin);const{w:e,h:i}=du(t),r=this.atlasImage;r.resize({width:e||1,height:i||1});for(const t in this.patterns){const{bin:e}=this.patterns[t],i=e.x+1,n=e.y+1,s=this.images[t].data,o=s.width,a=s.height;ec.copy(s,r,{x:0,y:0},{x:i,y:n},{width:o,height:a}),ec.copy(s,r,{x:0,y:a-1},{x:i,y:n-1},{width:o,height:1}),ec.copy(s,r,{x:0,y:0},{x:i,y:n+a},{width:o,height:1}),ec.copy(s,r,{x:o-1,y:0},{x:i-1,y:n},{width:1,height:a}),ec.copy(s,r,{x:0,y:0},{x:i+o,y:n},{width:1,height:a})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(const e of t){if(this.callbackDispatchedThisFrame[e])continue;this.callbackDispatchedThisFrame[e]=!0;const t=this.images[e];Gu(t)&&this.updateImage(e,t)}}}const Wu=new Is({anchor:new vs(ue.light.anchor),position:new class{constructor(){this.specification=ue.light.position}possiblyEvaluate(t,e){return function([t,e,i]){const r=p(e+90),n=p(i);return{x:t*Math.cos(r)*Math.sin(n),y:t*Math.sin(r)*Math.sin(n),z:t*Math.cos(n),azimuthal:e,polar:i}}(t.expression.evaluate(e))}interpolate(t,e,i){return{x:Ai(t.x,e.x,i),y:Ai(t.y,e.y,i),z:Ai(t.z,e.z,i),azimuthal:Ai(t.azimuthal,e.azimuthal,i),polar:Ai(t.polar,e.polar,i)}}},color:new vs(ue.light.color),intensity:new vs(ue.light.intensity)}),Xu="-transition";class Hu extends he{constructor(t){super(),this._transitionable=new fs(Wu),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,e={}){if(!this._validate(In,t,e))for(const e in t){const i=t[e];D(e,Xu)?this._transitionable.setTransition(e.slice(0,-Xu.length),i):this._transitionable.setValue(e,i)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,e,i){return(!i||!1!==i.validate)&&Dn(this,t.call(Tn,I({value:e,style:{glyphs:!0,sprite:!0},styleSpec:ue})))}}const Ku=new Is({source:new vs(ue.terrain.source),exaggeration:new vs(ue.terrain.exaggeration)}),Yu="-transition";class Ju extends he{constructor(t,e){super(),this._transitionable=new fs(Ku),this.set(t),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=e}get(){return this._transitionable.serialize()}set(t){for(const e in t){const i=t[e];D(e,Yu)?this._transitionable.setTransition(e.slice(0,-Yu.length),i):this._transitionable.setValue(e,i)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}}function Qu(t,e,i,r){const n=b(45,65,i),[s,o]=tp(t,r),a=gl(e);let l=1-Math.min(1,Math.exp((a-s)/(o-s)*-6));return l*=l*l,l=Math.min(1,1.00747*l),l*n*t.alpha}function tp(t,e){const i=.5/Math.tan(.5*e);return[t.range[0]+i,t.range[1]+i]}const ep=new Is({range:new vs(ue.fog.range),color:new vs(ue.fog.color),"horizon-blend":new vs(ue.fog["horizon-blend"])}),ip="-transition";class rp extends he{constructor(t,e){super(),this._transitionable=new fs(ep),this.set(t),this._transitioning=this._transitionable.untransitioned(),this._transform=e}get state(){return{range:this.properties.get("range"),horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(t,e={}){if(!this._validate(An,t,e))for(const e in t){const i=t[e];D(e,ip)?this._transitionable.setTransition(e.slice(0,-ip.length),i):this._transitionable.setValue(e,i)}}getOpacity(t){if(!this._transform.projection.supportsFog)return 0;const e=this.properties&&this.properties.get("color")||1;return b(45,65,t)*e.a}getOpacityAtLatLng(t,e){return this._transform.projection.supportsFog?function(t,e,i){const r=ba.fromLngLat(e),n=i.elevation?i.elevation.getAtPointOrZero(r):0,s=[r.x,r.y,n];return Cl(s,s,i.mercatorFogMatrix),Qu(t,s,i.pitch,i._fov)}(this.state,t,e):0}getFovAdjustedRange(t){return this._transform.projection.supportsFog?tp(this.state,t):[0,1]}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,e,i){return(!i||!1!==i.validate)&&Dn(this,t.call(Tn,I({value:e,style:{glyphs:!0,sprite:!0},styleSpec:ue})))}}class np{constructor(t,e){this.width=t,this.height=e,this.nextRow=0,this.image=new tc({width:t,height:e}),this.positions={},this.uploaded=!1}getDash(t,e){const i=this.getKey(t,e);return this.positions[i]}trim(){const t=this.width,e=this.height=M(this.nextRow);this.image.resize({width:t,height:e})}getKey(t,e){return t.join(",")+e}getDashRanges(t,e,i){const r=[];let n=t.length%2==1?-t[t.length-1]*i:0,s=t[0]*i,o=!0;r.push({left:n,right:s,isDash:o,zeroLength:0===t[0]});let a=t[0];for(let e=1;e<t.length;e++){o=!o;const l=t[e];n=a*i,a+=l,s=a*i,r.push({left:n,right:s,isDash:o,zeroLength:0===l})}return r}addRoundDash(t,e,i){const r=e/2;for(let e=-i;e<=i;e++){const n=this.width*(this.nextRow+i+e);let s=0,o=t[s];for(let a=0;a<this.width;a++){a/o.right>1&&(o=t[++s]);const l=Math.abs(a-o.left),c=Math.abs(a-o.right),h=Math.min(l,c);let u;const p=e/i*(r+1);if(o.isDash){const t=r-Math.abs(p);u=Math.sqrt(h*h+t*t)}else u=r-Math.sqrt(h*h+p*p);this.image.data[n+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],r=t[e+1];i.zeroLength?t.splice(e,1):r&&r.isDash===i.isDash&&(r.left=i.left,t.splice(e,1))}const i=t[0],r=t[t.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 s=0,o=t[s];for(let i=0;i<this.width;i++){i/o.right>1&&(o=t[++s]);const r=Math.abs(i-o.left),a=Math.abs(i-o.right),l=Math.min(r,a);this.image.data[n+i]=Math.max(0,Math.min(255,(o.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const r="round"===e,n=r?7:0,s=2*n+1;if(this.nextRow+s>this.height)return O("LineAtlas out of space"),null;0===t.length&&t.push(1);let o=0;for(let e=0;e<t.length;e++)t[e]<0&&(O("Negative value is found in line dasharray, replacing values with 0"),t[e]=0),o+=t[e];if(0!==o){const i=this.width/o,s=this.getDashRanges(t,this.width,i);r?this.addRoundDash(s,i,n):this.addRegularDash(s,"square"===e?.5*i:0)}const a=this.nextRow+n;this.nextRow+=s;const l={tl:[a,n],br:[o,0]};return this.positions[i]=l,l}}Fn(np);class sp{constructor(t){this._callback=t,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 op{constructor(){this.tasks={},this.taskQueue=[],P(["process"],this),this.invoker=new sp(this.process),this.nextId=0}add(t,e){const i=this.nextId++,r=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===r){U();try{t()}finally{}return{cancel:()=>{}}}return this.tasks[i]={fn:t,metadata:e,priority:r,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){U();try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i<this.taskQueue.length;i++){const r=this.tasks[this.taskQueue[i]];r.priority<e&&(e=r.priority,t=i)}if(null===t)return null;const i=this.taskQueue[t];return this.taskQueue.splice(t,1),i}remove(){this.invoker.remove()}}class ap{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=z();const i=this.workerPool.acquire(this.id);for(let t=0;t<i.length;t++){const r=new ap.Actor(i[t],e,this.id);r.name=`Worker ${t}`,this.actors.push(r)}this.ready=!1,this.broadcast("checkIfReady",null,(()=>{this.ready=!0}))}broadcast(t,e,i){T(this.actors,((i,r)=>{i.send(t,e,r)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}function lp(t,e,i){return e*(la/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}ap.Actor=class{constructor(t,e,i){this.target=t,this.parent=e,this.mapId=i,this.callbacks={},this.cancelCallbacks={},P(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=U()?t:l,this.scheduler=new op}send(t,e,i,r,n=!1,s){const o=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=s,this.callbacks[o]=i);const a=X(this.globalScope)?void 0:[];return this.target.postMessage({id:o,type:t,hasCallback:!!i,targetMapId:r,mustQueue:n,sourceMapId:this.mapId,data:jn(e,a)},a),{cancel:()=>{i&&delete this.callbacks[o],this.target.postMessage({id:o,type:"<cancel>",targetMapId:r,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if("<cancel>"===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||U()){const t=this.callbacks[i];this.cancelCallbacks[i]=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"})}else this.processTask(i,e)}processTask(t,e){if("<response>"===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Un(e.error)):i(null,Un(e.data)))}else{const i=X(this.globalScope)?void 0:[],r=e.hasCallback?(e,r)=>{delete this.cancelCallbacks[t],this.target.postMessage({id:t,type:"<response>",sourceMapId:this.mapId,error:e?jn(e):null,data:jn(r,i)},i)}:t=>{},n=Un(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,n,r);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],n.source)[t[1]](n,r)}else r(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}};const cp=Ms([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_merc_pos",components:2},{type:"Float32",name:"a_uv",components:2}]),hp=Ms([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:up}=cp,pp=la/Math.PI/2,dp=64,fp=-pp,mp=pp,_p=[new ql([fp,fp,fp],[mp,mp,mp]),new ql([fp,fp,fp],[0,0,mp]),new ql([0,fp,fp],[mp,0,mp]),new ql([fp,0,fp],[0,mp,mp]),new ql([0,0,fp],[mp,mp,mp])];class gp{constructor(t,e,i){this.a=Dl([],t,i),this.b=Dl([],e,i),this.center=i;const r=Sl([],this.a),n=Sl([],this.b);this.angle=Math.acos(Al(r,n))}}function yp(t,e){if(0===t.angle)return null;let i;return i=0===t.a[e]?1/t.angle*.5*Math.PI:1/t.angle*Math.atan(t.b[e]/t.a[e]/Math.sin(t.angle)-1/Math.tan(t.angle)),i<0||i>1?null:function(t,e,i,r){const n=Math.sin(i);return t*(Math.sin((1-r)*i)/n)+e*(Math.sin(r*i)/n)}(t.a[e],t.b[e],t.angle,v(i,0,1))+t.center[e]}function xp(t){if(t.z<=1)return _p[t.z+2*t.y+t.x];const[e,i]=bp(t),r=[Tp(e[0],e[1]),Tp(e[0],i[1]),Tp(i[0],e[1]),Tp(i[0],i[1])],n=[mp,mp,mp],s=[fp,fp,fp];for(const t of r)n[0]=Math.min(n[0],t[0]),n[1]=Math.min(n[1],t[1]),n[2]=Math.min(n[2],t[2]),s[0]=Math.max(s[0],t[0]),s[1]=Math.max(s[1],t[1]),s[2]=Math.max(s[2],t[2]);return new ql(n,s)}function vp(t,e,i){const r=e/t.worldSize,n=(t,e)=>{El(t,t,r),El(e,e,r)},s=Number.MAX_VALUE,o=[-s,-s,-s],a=[s,s,s],l=kp(t);if(i.z<=1){const t=xp(i).getCorners();for(let e=0;e<t.length;e++)Cl(t[e],t[e],l),wl(a,a,t[e]),Tl(o,o,t[e]);return n(a,o),new ql(a,o)}const[c,h]=bp(i),u=new ca;u.setSouthWest([c[1],h[0]]),u.setNorthEast([h[1],c[0]]);const d=[Tp(u.getSouth(),u.getWest()),Tp(u.getSouth(),u.getEast()),Tp(u.getNorth(),u.getEast()),Tp(u.getNorth(),u.getWest())];for(let t=0;t<d.length;t++)Cl(d[t],d[t],l),wl(a,a,d[t]),Tl(o,o,d[t]);if(u.contains(t.center))return o[2]=0,n(a,o),new ql(a,o);const f=[l[12],l[13],l[14]],m=t.center.lng,_=v(t.center.lat,-85.051129,va),g=[fa(m),ma(_)],y=u.getCenter().lng,x=v(u.getCenter().lat,-85.051129,va),b=[fa(y),ma(x)];let w=new Array(3),T=0;const E=g[0]-b[0],I=g[1]-b[1];if(Math.abs(E)>Math.abs(I))T=E>=0?1:3,w=f;else{T=I>=0?0:2;const t=[l[4],l[5],l[6]];let e;e=I>=0?-Math.sin(p(u.getSouth()))*pp:-Math.sin(p(u.getNorth()))*pp,w=Il(w,f,t,e)}const S=d[T],A=d[(T+1)%4],z=new gp(S,A,w),C=[yp(z,0)||S[0],yp(z,1)||S[1],yp(z,2)||S[2]];return a[2]=Math.min(S[2],A[2]),wl(a,a,C),Tl(o,o,C),n(a,o),new ql(a,o)}function bp(t){const e=1<<t.z,i=t.x/e,r=(t.x+1)/e,n=(t.y+1)/e;return[[ya(t.y/e),ga(i)],[ya(n),ga(r)]]}function wp(t,e,i,r=pp){return i=p(i),[t*Math.sin(i)*r,-e*r,t*Math.cos(i)*r]}function Tp(t,e,i){return wp(Math.cos(p(t)),Math.sin(p(t)),e,i)}function Ep(t,e,i){const r=Math.pow(2,i.z),n=(t/la+i.x)/r;return Tp(ya((e/la+i.y)/r),ga(n))}function Ip(t){return 16383/Math.max(...Dl([],t.max,t.min))}function Sp(t){const e=rl(new Float64Array(16)),i=Ip(t);var r,n;return al(e,e,[i,i,i]),ol(e,e,((r=[])[0]=-(n=t.min)[0],r[1]=-n[1],r[2]=-n[2],r)),e}function Ap(t){const e=rl(new Float64Array(16)),i=1/Ip(t);return ol(e,e,t.min),al(e,e,[i,i,i]),e}function zp(t){const e=la/(2*Math.PI);return t/(2*Math.PI)/e}function Cp(t,e){return la/(512*Math.pow(2,t))*Ip(xp(e))}function Mp(t,e,i,r,n){const s=zp(i),o=[t,e,-i/(2*Math.PI)],a=rl(new Float64Array(16));return ol(a,a,o),al(a,a,[s,s,s]),ll(a,a,p(-n)),cl(a,a,p(-r)),a}function kp(t){const{x:e,y:i}=t.point,{lng:r,lat:n}=t._center;return Mp(e,i,t.worldSize,r,n)}function Pp(t){return b(5,6,t)}function Dp(t,e,i){const r=t.context;let n=e.globeGridBuffer;if(!n){const t=Vp.createGridVertices(i.canonical);n=e.globeGridBuffer=r.createVertexBuffer(t,up,!1)}return n}function Bp(t,e){const i=Ap(xp(t));return fl(il(),e,i)}function Lp(t,e,i){const r=rl(new Float64Array(16)),n=1<<t,s=360*(e/n-.5),o=i.point,a=i.worldSize/(i.tileSize*n);return ol(r,r,[o.x,o.y,-i.worldSize/Math.PI/2]),al(r,r,[a,a,a]),ll(r,r,p(-i._center.lat)),cl(r,r,p(-i._center.lng+s)),Float32Array.from(r)}const Rp=p(85),Fp=Math.cos(Rp),Op=Math.sin(Rp);class Vp{constructor(t){this._createGrid(t),this._createPoles(t),this._createAtmosphere(t)}destroy(){this.poleIndexBuffer.destroy(),this.gridIndexBuffer.destroy(),this.poleNorthVertexBuffer.destroy(),this.poleSouthVertexBuffer.destroy();for(const t of this.poleSegments)t.destroy();this.gridSegments.destroy(),this.atmosphereVertexBuffer.destroy(),this.atmosphereIndexBuffer.destroy(),this.atmosphereSegments.destroy(),this.wireframeIndexBuffer&&(this.wireframeIndexBuffer.destroy(),this.wireframeSegments.destroy())}_createGrid(t){const e=new $s;for(let t=0;t<64;t++)for(let i=0;i<64;i++){const r=65*t+i;e.emplaceBack(r+1,r,r+65),e.emplaceBack(r+65,r+65+1,r+1)}this.gridIndexBuffer=t.createIndexBuffer(e,!0),this.gridSegments=aa.simpleSegment(0,0,4225,8192)}_createPoles(t){const e=new $s;for(let t=0;t<=dp;t++)e.emplaceBack(0,t+1,t+2);this.poleIndexBuffer=t.createIndexBuffer(e,!0);const i=new Ks,r=new Ks;this.poleSegments=[];for(let t=0,e=0;t<5;t++){const n=1<<t,s=512*n/Math.PI/2,o=360/n;i.emplaceBack(0,-s,0,0,0,.5,0),r.emplaceBack(0,-s,0,0,0,.5,1);for(let t=0;t<=dp;t++){const e=t/dp,n=Ai(0,o,e),[a,l,c]=wp(Fp,Op,n,s);i.emplaceBack(a,l,c,0,0,e,0),r.emplaceBack(a,l,c,0,0,e,1)}this.poleSegments.push(aa.simpleSegment(e,0,66,64)),e+=66}this.poleNorthVertexBuffer=t.createVertexBuffer(i,up,!1),this.poleSouthVertexBuffer=t.createVertexBuffer(r,up,!1)}_createAtmosphere(t){const e=new Ys;e.emplaceBack(-1,1,1,0,0),e.emplaceBack(1,1,1,1,0),e.emplaceBack(1,-1,1,1,1),e.emplaceBack(-1,-1,1,0,1);const i=new $s;i.emplaceBack(0,1,2),i.emplaceBack(2,3,0),this.atmosphereVertexBuffer=t.createVertexBuffer(e,hp.members),this.atmosphereIndexBuffer=t.createIndexBuffer(i),this.atmosphereSegments=aa.simpleSegment(0,0,4,2)}static createGridVertices(t){const e=1<<t.z,[i,r]=bp(t),n=Sp(xp(t)),s=new Ks;s.reserve(4096);for(let o=0;o<65;o++){const a=Ai(i[0],r[0],o/dp),l=ma(a),c=l*e-t.y,h=Math.sin(p(a)),u=Math.cos(p(a));for(let t=0;t<65;t++){const e=t/dp,o=Ai(i[1],r[1],e),a=fa(o),p=wp(u,h,o),[d,f,m]=Cl(p,p,n);s.emplaceBack(d,f,m,a,l,e,c)}}return s}getWirefameBuffer(t){if(!this.wireframeSegments){const e=new Qs,i=dp,r=i+1;for(let t=0;t<i;t++)for(let n=0;n<i;n++){const i=t*r+n;e.emplaceBack(i,i+1),e.emplaceBack(i,i+r),e.emplaceBack(i,i+r+1)}this.wireframeIndexBuffer=t.createIndexBuffer(e),this.wireframeSegments=aa.simpleSegment(0,0,i*i,e.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}function jp(t,e,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return[t*r-2*Math.PI*6378137/2,e*r-2*Math.PI*6378137/2]}class Up{constructor(t,e,i){this.z=t,this.x=e,this.y=i,this.key=qp(0,t,t,e,i)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e){const i=function(t,e,i){var r=jp(256*t,256*(e=Math.pow(2,i)-e-1),i),n=jp(256*(t+1),256*(e+1),i);return r[0]+","+r[1]+","+n[0]+","+n[1]}(this.x,this.y,this.z),r=function(t,e,i){let r,n="";for(let s=t;s>0;s--)r=1<<s-1,n+=(e&r?1:0)+(i&r?2:0);return n}(this.z,this.x,this.y);return t[(this.x+this.y)%t.length].replace("{prefix}",(this.x%16).toString(16)+(this.y%16).toString(16)).replace("{z}",String(this.z)).replace("{x}",String(this.x)).replace("{y}",String("tms"===e?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 Np{constructor(t,e){this.wrap=t,this.canonical=e,this.key=qp(t,e.z,e.z,e.x,e.y)}}class Zp{constructor(t,e,i,r,n){this.overscaledZ=t,this.wrap=e,this.canonical=new Up(i,+r,+n),this.key=0===e&&t===i?this.canonical.key:qp(e,t,i,r,n)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){const e=this.canonical.z-t;return t>this.canonical.z?new Zp(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Zp(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e=!0){if(this.overscaledZ===t&&e)return this.key;if(t>this.canonical.z)return qp(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-t;return qp(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(t){if(t.wrap!==this.wrap)return!1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ<this.overscaledZ&&t.canonical.x===this.canonical.x>>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new Zp(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new Zp(e,this.wrap,e,i,r),new Zp(e,this.wrap,e,i+1,r),new Zp(e,this.wrap,e,i,r+1),new Zp(e,this.wrap,e,i+1,r+1)]}isLessThan(t){return this.wrap<t.wrap||!(this.wrap>t.wrap)&&(this.overscaledZ<t.overscaledZ||!(this.overscaledZ>t.overscaledZ)&&(this.canonical.x<t.canonical.x||!(this.canonical.x>t.canonical.x)&&this.canonical.y<t.canonical.y))}wrapped(){return new Zp(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new Zp(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Np(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function qp(t,e,i,r,n){const s=1<<Math.min(i,22);let o=s*(n%s)+r%s;return t&&i<22&&(o+=s*s*((t<0?-2*t-1:2*t)%(1<<2*(22-i)))),16*(32*o+i)+(e-i)}function Gp(t,e){if(!e.isReprojectedInTileSpace)return{scale:1<<t.z,x:t.x,y:t.y,x2:t.x+1,y2:t.y+1,projection:e};const i=Math.pow(2,-t.z),r=t.x*i,n=(t.x+1)*i,s=t.y*i,o=(t.y+1)*i,a=ga(r),l=ga(n),c=ya(s),h=ya(o),u=e.project(a,c),p=e.project(l,c),d=e.project(l,h),f=e.project(a,h);let m=Math.min(u.x,p.x,d.x,f.x),_=Math.min(u.y,p.y,d.y,f.y),g=Math.max(u.x,p.x,d.x,f.x),y=Math.max(u.y,p.y,d.y,f.y);const x=i/16;function v(t,i,r,n,s,o){const a=(r+s)/2,l=(n+o)/2,c=e.project(ga(a),ya(l)),h=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),h>x&&(v(t,c,r,n,a,l),v(c,i,a,l,s,o))}v(u,p,r,s,n,s),v(p,d,n,s,n,o),v(d,f,n,o,r,o),v(f,u,r,o,r,s),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:e}}function $p(t,e,i,r,n,s,o,a,l){if("globe"===l.name)return vp(t,e,new Up(i,r,n));const c=Gp({z:i,x:r,y:n},l);return new ql([(s+c.x/c.scale)*e,e*(c.y/c.scale),o],[(s+c.x2/c.scale)*e,e*(c.y2/c.scale),a])}function Wp(t,{x:e,y:i},r=0){return new o(((e-r)*t.scale-t.x)*la,(i*t.scale-t.y)*la)}function Xp(t,e,i=0){return yl(((e.x-i)*t.scale-t.x)*la,(e.y*t.scale-t.y)*la,xa(e.z,e.y))}Fn(Up),Fn(Zp,{omit:["projMatrix"]});class Hp{constructor(t,e,i,r){this.screenBounds=t,this.cameraPoint=e,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this.screenGeometry.map((t=>r.pointCoordinate3D(t))),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(t,e){let i,r;if(t instanceof o||"number"==typeof t[0]){const n=o.convert(t);i=[o.convert(t)],r=e.isPointAboveHorizon(n)}else{const n=o.convert(t[0]),s=o.convert(t[1]);i=[n,s],r=g(n,s).every((t=>e.isPointAboveHorizon(t)))}return new Hp(i,e.getCameraPoint(),r,e)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return g(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const e=this.screenBounds[0],i=1===this.screenBounds.length?this.screenBounds[0].add(new o(1,1)):this.screenBounds[1],r=g(e,i,0,!1);return this.cameraPoint.y>i.y&&(this.cameraPoint.x>e.x&&this.cameraPoint.x<i.x?r.splice(3,0,this.cameraPoint):this.cameraPoint.x>=i.x?r[2]=this.cameraPoint:this.cameraPoint.x<=e.x&&(r[3]=this.cameraPoint)),function(t,e){const i=[];for(let r=0;r<t.length;r++){const n=w(r-1,-1,t.length-1),s=w(r+1,-1,t.length-1),o=t[r],a=t[s],l=t[n].sub(o).unit(),c=a.sub(o).unit(),h=c.angleWithSep(l.x,l.y),u=l.add(c).unit().mult(-1*e/Math.sin(h/2));i.push(o.add(u))}return i}(r,t)}containsTile(t,e,i){const r=t.queryPadding+1,n=t.tileID.wrap,s=i?this._bufferedCameraMercator(r,e).map((e=>Wp(t.tileTransform,e,n))):this._bufferedScreenMercator(r,e).map((e=>Wp(t.tileTransform,e,n))),a=this.screenGeometryMercator.map((e=>Xp(t.tileTransform,e,n))),l=a.map((t=>new o(t[0],t[1]))),c=e.getFreeCameraOptions().position||new ba(0,0,0),h=Xp(t.tileTransform,c,n),u=a.map((t=>{const e=Dl(t,t,h);return Sl(e,e),new Nl(h,e)})),p=lp(t,1,e.zoom);if(Na(s,0,0,la,la))return{queryGeometry:this,tilespaceGeometry:l,tilespaceRays:u,bufferedTilespaceGeometry:s,bufferedTilespaceBounds:(d=_(s),d.min.x=v(d.min.x,0,la),d.min.y=v(d.min.y,0,la),d.max.x=v(d.max.x,0,la),d.max.y=v(d.max.y,0,la),d),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:p};var d}_bufferedScreenMercator(t,e){const i=Kp(t);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{const r=this.bufferedScreenGeometry(t).map((t=>e.pointCoordinate3D(t)));return this._screenRaycastCache[i]=r,r}}_bufferedCameraMercator(t,e){const i=Kp(t);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{const r=this.bufferedCameraGeometry(t).map((t=>e.pointCoordinate3D(t)));return this._cameraRaycastCache[i]=r,r}}}function Kp(t){return 100*t|0}function Yp(t,e,i){const r=function(r,n){if(r)return i(r);if(n){const r=S(I(n,t),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);n.vector_layers&&(r.vectorLayers=n.vector_layers,r.vectorLayerIds=r.vectorLayers.map((t=>t.id))),r.tiles=e.canonicalizeTileset(r,t.url),i(null,r)}};return t.url?Yt(e.transformRequest(e.normalizeSourceURL(t.url),Wt.Source),r):J.frame((()=>r(null,t)))}class Jp{constructor(t,e,i){this.bounds=ca.convert(this.validateBounds(t)),this.minzoom=e||0,this.maxzoom=i||24}validateBounds(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(t){const e=Math.pow(2,t.z),i=Math.floor(fa(this.bounds.getWest())*e),r=Math.floor(ma(this.bounds.getNorth())*e),n=Math.ceil(fa(this.bounds.getEast())*e),s=Math.ceil(ma(this.bounds.getSouth())*e);return t.x>=i&&t.x<n&&t.y>=r&&t.y<s}}class Qp{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e<t.length;e++){const i=t[e];this._stringToNumber[i]=e,this._numberToString[e]=i}}encode(t){return this._stringToNumber[t]}decode(t){return this._numberToString[t]}}const td=["tile","layer","source","sourceLayer","state"];class ed{constructor(t,e,i,r,n){this.type="Feature",this._vectorTileFeature=t,this._z=e,this._x=i,this._y=r,this.properties=t.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(t){this._geometry=t}toJSON(){const t={type:"Feature",geometry:this.geometry,properties:this.properties};void 0!==this.id&&(t.id=this.id);for(const e of td)void 0!==this[e]&&(t[e]=this[e]);return t}}const id=Ms([{name:"a_pos_3",components:3,type:"Int16"}]);var rd=Ms([{name:"a_pos",type:"Int16",components:2}]);const nd=32,sd=33,od=new Uint16Array(8184);for(let t=0;t<2046;t++){let e=t+2,i=0,r=0,n=0,s=0,o=0,a=0;for(1&e?n=s=o=nd:i=r=a=nd;(e>>=1)>1;){const t=i+n>>1,l=r+s>>1;1&e?(n=i,s=r,i=o,r=a):(i=n,r=s,n=o,s=a),o=t,a=l}const l=4*t;od[l+0]=i,od[l+1]=r,od[l+2]=n,od[l+3]=s}const ad=new Uint16Array(2178),ld=new Uint8Array(1089),cd=new Uint16Array(1089);function hd(t){return 0===t?-.03125:32===t?.03125:0}var ud=Ms([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const pd={type:2,extent:la,loadGeometry:()=>[[new o(0,0),new o(8193,0),new o(8193,8193),new o(0,8193),new o(0,0)]]};class dd{constructor(t,e,i,r,n){this.tileID=t,this.uid=z(),this.uses=0,this.tileSize=e,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(t){const e=t+this.timeAdded;e<J.now()||this.fadeEndTime&&e<this.fadeEndTime||(this.fadeEndTime=e)}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}get tileTransform(){return this._tileTransform||(this._tileTransform=Gp(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(t,e,i){if(this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestFeatureIndex.rawTileData=t.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=function(t,e){const i={};if(!e)return i;for(const r of t){const t=r.layerIds.map((t=>e.getLayer(t))).filter(Boolean);if(0!==t.length){r.layers=t,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.id]=r}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof Pu){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof Pu&&e.hasRTLText){this.hasRTLText=!0,hs.isLoading()||hs.isLoaded()||"deferred"!==ls()||cs();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,e.style.getLayer(t).queryRadius(i))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas)}else this.collisionBoxArray=new ao}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugIndexBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this.globeGridBuffer&&(this.globeGridBuffer.destroy(),this.globeGridBuffer=null),this._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(t){return this.buckets[t.id]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new qu(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new qu(t,this.glyphAtlasImage,e.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new qu(t,this.lineAtlas.image,e.ALPHA),this.lineAtlas.uploaded=!0)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,e,i,r,n,s,o,a){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:r,pixelPosMatrix:o,transform:s,params:n,tileTransform:this.tileTransform},t,e,i):{}}querySourceFeatures(t,e){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const r=i.loadVTLayers(),n=e?e.sourceLayer:"",s=r._geojsonTileLayer||r[n];if(!s)return;const o=Hr(e&&e.filter),{z:a,x:l,y:c}=this.tileID.canonical,h={z:a,x:l,y:c};for(let e=0;e<s.length;e++){const r=s.feature(e);if(o.needGeometry){const t=za(r,!0);if(!o.filter(new us(this.tileID.overscaledZ),t,this.tileID.canonical))continue}else if(!o.filter(new us(this.tileID.overscaledZ),r))continue;const u=i.getId(r,n),p=new ed(r,a,l,c,u);p.tile=h,t.push(p)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return!!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const e=this.expirationTime;if(t.cacheControl){const e=N(t.cacheControl);e["max-age"]&&(this.expirationTime=Date.now()+1e3*e["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const t=Date.now();let i=!1;if(this.expirationTime>t)i=!1;else if(e)if(this.expirationTime<e)i=!0;else{const r=this.expirationTime-e;r?this.expirationTime=t+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(t,e){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||0===Object.keys(t).length||!e)return;const i=this.latestFeatureIndex.loadVTLayers(),r=e.style.listImages();for(const n in this.buckets){if(!e.style.hasLayer(n))continue;const s=this.buckets[n],o=s.layers[0].sourceLayer||"_geojsonTileLayer",a=i[o],l=t[o];if(!a||!l||0===Object.keys(l).length)continue;if(s.update(l,a,r,this.imageAtlas&&this.imageAtlas.patternPositions||{}),s instanceof Eh||s instanceof Zc){const t=e.style._getSourceCache(s.layers[0].source);e._terrain&&e._terrain.enabled&&t&&s.programConfigurations.needsUpload&&e._terrain._clearRenderCacheForTile(t.id,this.tileID)}const c=e&&e.style&&e.style.getLayer(n);c&&(this.queryPadding=Math.max(this.queryPadding,c.queryRadius(s)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<J.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(t){this.symbolFadeHoldUntil=J.now()+t}setDependencies(t,e){const i={};for(const t of e)i[t]=!0;this.dependencies[t]=i}hasDependency(t,e){for(const i of t){const t=this.dependencies[i];if(t)for(const i of e)if(t[i])return!0}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(t,e){if(!e||"mercator"===e.name||this._tileDebugBuffer)return;const i=Aa(pd,this.tileID.canonical,this.tileTransform)[0],r=new Ps,n=new to;for(let t=0;t<i.length;t++){const{x:e,y:s}=i[t];r.emplaceBack(e,s),n.emplaceBack(t)}n.emplaceBack(0),this._tileDebugIndexBuffer=t.createIndexBuffer(n),this._tileDebugBuffer=t.createVertexBuffer(r,rd.members),this._tileDebugSegments=aa.simpleSegment(0,0,r.length,n.length)}_makeTileBoundsBuffers(t,e){if(this._tileBoundsBuffer||!e||"mercator"===e.name)return;const i=Aa(pd,this.tileID.canonical,this.tileTransform)[0];let r,n;if(this.isRaster){const t=function(t,e){const i=Gp(t,e),r=Math.pow(2,t.z);for(let n=0;n<sd;n++)for(let s=0;s<sd;s++){const o=ga((t.x+(s+hd(s))/nd)/r),a=ya((t.y+(n+hd(n))/nd)/r),l=e.project(o,a),c=n*sd+s;ad[2*c+0]=Math.round((l.x*i.scale-i.x)*la),ad[2*c+1]=Math.round((l.y*i.scale-i.y)*la)}ld.fill(0),cd.fill(0);for(let t=2045;t>=0;t--){const e=4*t,i=od[e+0],r=od[e+1],n=od[e+2],s=od[e+3],o=i+n>>1,a=r+s>>1,l=o+a-r,c=a+i-o,h=r*sd+i,u=s*sd+n,p=a*sd+o,d=Math.hypot((ad[2*h+0]+ad[2*u+0])/2-ad[2*p+0],(ad[2*h+1]+ad[2*u+1])/2-ad[2*p+1])>=16;if(ld[p]=ld[p]||(d?1:0),t<1022){const t=(r+c>>1)*sd+(i+l>>1),e=(s+c>>1)*sd+(n+l>>1);ld[p]=ld[p]||ld[t]||ld[e]}}const n=new Bs,s=new $s;let o=0;function a(t,e){const i=e*sd+t;return 0===cd[i]&&(n.emplaceBack(ad[2*i+0],ad[2*i+1],t*la/nd,e*la/nd),cd[i]=++o),cd[i]-1}function l(t,e,i,r,n,o){const c=t+i>>1,h=e+r>>1;if(Math.abs(t-n)+Math.abs(e-o)>1&&ld[h*sd+c])l(n,o,t,e,c,h),l(i,r,n,o,c,h);else{const l=a(t,e),c=a(i,r),h=a(n,o);s.emplaceBack(l,c,h)}}return l(0,0,nd,nd,nd,0),l(nd,nd,0,0,0,nd),{vertices:n,indices:s}}(this.tileID.canonical,e);r=t.vertices,n=t.indices}else{r=new Bs,n=new $s;for(const{x:t,y:e}of i)r.emplaceBack(t,e,0,0);const t=ac(r.int16,void 0,4);for(let e=0;e<t.length;e+=3)n.emplaceBack(t[e],t[e+1],t[e+2])}this._tileBoundsBuffer=t.createVertexBuffer(r,ud.members),this._tileBoundsIndexBuffer=t.createIndexBuffer(n),this._tileBoundsSegments=aa.simpleSegment(0,0,r.length,n.length)}_makeGlobeTileDebugBuffers(t,e){if(this._globeTileDebugBorderBuffer||this._globeTileDebugTextBuffer||!e||"globe"!==e.name)return;const i=this.tileID.canonical,r=Sp(xp(i));this._makeGlobeTileDebugBorderBuffer(t,i,r),this._makeGlobeTileDebugTextBuffer(t,i,r)}_makeGlobeTileDebugBorderBuffer(t,e,i){const r=new Ps,n=new to,s=new Ds,o=(t,o,a,l,c)=>{const h=(a-t)/(c-1),u=(l-o)/(c-1),p=r.length;for(let a=0;a<c;a++){const l=t+a*h,c=o+a*u;r.emplaceBack(l,c);const d=Ep(l,c,e),f=Cl(d,d,i);s.emplaceBack(f[0],f[1],f[2]),n.emplaceBack(p+a)}},a=la;o(0,0,a,0,16),o(a,0,a,a,16),o(a,a,0,a,16),o(0,a,0,0,16),this._tileDebugIndexBuffer=t.createIndexBuffer(n),this._tileDebugBuffer=t.createVertexBuffer(r,rd.members),this._globeTileDebugBorderBuffer=t.createVertexBuffer(s,id.members),this._tileDebugSegments=aa.simpleSegment(0,0,r.length,n.length)}_makeGlobeTileDebugTextBuffer(t,e,i){const r=new Ps,n=new $s,s=new Ds,o=25;n.reserve(32),r.reserve(o),s.reserve(o);const a=(t,e)=>o*t+e;for(let t=0;t<o;t++){const n=2048*t;for(let t=0;t<o;t++){const o=2048*t;r.emplaceBack(o,n);const a=Ep(o,n,e),l=Cl(a,a,i);s.emplaceBack(l[0],l[1],l[2])}}for(let t=0;t<4;t++)for(let e=0;e<4;e++){const i=a(t,e),r=a(t,e+1),s=a(t+1,e),o=a(t+1,e+1);n.emplaceBack(i,r,s),n.emplaceBack(s,r,o)}this._tileDebugTextIndexBuffer=t.createIndexBuffer(n),this._tileDebugTextBuffer=t.createVertexBuffer(r,rd.members),this._globeTileDebugTextBuffer=t.createVertexBuffer(s,id.members),this._tileDebugTextSegments=aa.simpleSegment(0,0,o,32)}}class fd{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,e,i){const r=String(e);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][r]=this.stateChanges[t][r]||{},I(this.stateChanges[t][r],i),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==r&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][r]){this.deletedStates[t][r]={};for(const e in this.state[t][r])i[e]||(this.deletedStates[t][r][e]=null)}else for(const e in i)this.deletedStates[t]&&this.deletedStates[t][r]&&null===this.deletedStates[t][r][e]&&delete this.deletedStates[t][r][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const r=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][r]&&(this.deletedStates[t][r]=this.deletedStates[t][r]||{},this.deletedStates[t][r][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][r])for(i in this.deletedStates[t][r]={},this.stateChanges[t][r])this.deletedStates[t][r][i]=null;else this.deletedStates[t][r]=null;else this.deletedStates[t]=null}getState(t,e){const i=String(e),r=I({},(this.state[t]||{})[i],(this.stateChanges[t]||{})[i]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const i=this.deletedStates[t][e];if(null===i)return{};for(const t in i)delete r[t]}return r}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,e){const i={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const e={};for(const i in this.stateChanges[t])this.state[t][i]||(this.state[t][i]={}),I(this.state[t][i],this.stateChanges[t][i]),e[i]=this.state[t][i];i[t]=e}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const e={};if(null===this.deletedStates[t])for(const i in this.state[t])e[i]={},this.state[t][i]={};else for(const i in this.deletedStates[t]){if(null===this.deletedStates[t][i])this.state[t][i]={};else for(const e of Object.keys(this.deletedStates[t][i]))delete this.state[t][i][e];e[i]=this.state[t][i]}i[t]=i[t]||{},I(i[t],e)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const r in t)t[r].setFeatureState(i,e)}}class md{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(t,e){const i=this.toIdx(t,e);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(t,e){return this.leaves[this.toIdx(t,e)]}toIdx(t,e){return e*this.size+t}}function _d(t,e,i,r){let n=0,s=Number.MAX_VALUE;for(let o=0;o<3;o++)if(Math.abs(r[o])<1e-15){if(i[o]<t[o]||i[o]>e[o])return null}else{const a=1/r[o];let l=(t[o]-i[o])*a,c=(e[o]-i[o])*a;if(l>c){const t=l;l=c,c=t}if(l>n&&(n=l),c<s&&(s=c),n>s)return null}return n}function gd(t,e,i,r,n,s,o,a,l,c,h){const u=r-t,p=n-e,d=s-i,f=o-t,m=a-e,_=l-i,g=h[1]*_-h[2]*m,y=h[2]*f-h[0]*_,x=h[0]*m-h[1]*f,v=u*g+p*y+d*x;if(Math.abs(v)<1e-15)return null;const b=1/v,w=c[0]-t,T=c[1]-e,E=c[2]-i,I=(w*g+T*y+E*x)*b;if(I<0||I>1)return null;const S=T*d-E*p,A=E*u-w*d,z=w*p-T*u,C=(h[0]*S+h[1]*A+h[2]*z)*b;return C<0||I+C>1?null:(f*S+m*A+_*z)*b}function yd(t,e,i){return(t-e)/(i-e)}function xd(t,e,i,r,n,s,o,a,l){const c=1<<i,h=s-r,u=o-n,p=(t+1)/c*h+r,d=(e+0)/c*u+n,f=(e+1)/c*u+n;a[0]=(t+0)/c*h+r,a[1]=d,l[0]=p,l[1]=f}class vd{constructor(t){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=t,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;const e=function(t){const e=Math.ceil(Math.log2(t.dim/8)),i=[];let r=Math.ceil(Math.pow(2,e));const n=1/r,s=(t,e,i,r,n)=>{const s=r?1:0,o=(t+1)*i-s,a=e*i,l=(e+1)*i-s;n[0]=t*i,n[1]=a,n[2]=o,n[3]=l};let o=new md(r);const a=[];for(let e=0;e<r*r;e++){s(e%r,Math.floor(e/r),n,!1,a);const i=wd(a[0],a[1],t),l=wd(a[2],a[1],t),c=wd(a[2],a[3],t),h=wd(a[0],a[3],t);o.minimums.push(Math.min(i,l,c,h)),o.maximums.push(Math.max(i,l,c,h)),o.leaves.push(1)}for(i.push(o),r/=2;r>=1;r/=2){const t=i[i.length-1];o=new md(r);for(let e=0;e<r*r;e++){s(e%r,Math.floor(e/r),2,!0,a);const i=t.getElevation(a[0],a[1]),n=t.getElevation(a[2],a[1]),l=t.getElevation(a[2],a[3]),c=t.getElevation(a[0],a[3]),h=t.isLeaf(a[0],a[1]),u=t.isLeaf(a[2],a[1]),p=t.isLeaf(a[2],a[3]),d=t.isLeaf(a[0],a[3]),f=Math.min(i.min,n.min,l.min,c.min),m=Math.max(i.max,n.max,l.max,c.max),_=h&&u&&p&&d;o.maximums.push(m),o.minimums.push(f),o.leaves.push(m-f<=5&&_?1:0)}i.push(o)}return i}(this.dem),i=e.length-1,r=e[i];this._addNode(r.minimums[0],r.maximums[0],r.leaves[0]),this._construct(e,0,0,i,0)}raycastRoot(t,e,i,r,n,s,o=1){return _d([t,e,-100],[i,r,this.maximums[0]*o],n,s)}raycast(t,e,i,r,n,s,o=1){if(!this.nodeCount)return null;const a=this.raycastRoot(t,e,i,r,n,s,o);if(null==a)return null;const l=[],c=[],h=[],u=[],p=[{idx:0,t:a,nodex:0,nodey:0,depth:0}];for(;p.length>0;){const{idx:a,t:d,nodex:f,nodey:m,depth:_}=p.pop();if(this.leaves[a]){xd(f,m,_,t,e,i,r,h,u);const a=1<<_,l=(f+0)/a,c=(f+1)/a,p=(m+0)/a,g=(m+1)/a,y=wd(l,p,this.dem)*o,x=wd(c,p,this.dem)*o,v=wd(c,g,this.dem)*o,b=wd(l,g,this.dem)*o,w=gd(h[0],h[1],y,u[0],h[1],x,u[0],u[1],v,n,s),T=gd(u[0],u[1],v,h[0],u[1],b,h[0],h[1],y,n,s),E=Math.min(null!==w?w:Number.MAX_VALUE,null!==T?T:Number.MAX_VALUE);if(E!==Number.MAX_VALUE)return E;{const t=Il([],n,s,d);if(bd(y,x,b,v,yd(t[0],h[0],u[0]),yd(t[1],h[1],u[1]))>=t[2])return d}continue}let g=0;for(let p=0;p<this._siblingOffset.length;p++){xd((f<<1)+this._siblingOffset[p][0],(m<<1)+this._siblingOffset[p][1],_+1,t,e,i,r,h,u),h[2]=-100,u[2]=this.maximums[this.childOffsets[a]+p]*o;const d=_d(h,u,n,s);if(null!=d){const t=d;l[p]=t;let e=!1;for(let i=0;i<g&&!e;i++)t>=l[c[i]]&&(c.splice(i,0,p),e=!0);e||(c[g]=p),g++}}for(let t=0;t<g;t++){const e=c[t];p.push({idx:this.childOffsets[a]+e,t:l[e],nodex:(f<<1)+this._siblingOffset[e][0],nodey:(m<<1)+this._siblingOffset[e][1],depth:_+1})}}return null}_addNode(t,e,i){return this.minimums.push(t),this.maximums.push(e),this.leaves.push(i),this.childOffsets.push(0),this.nodeCount++}_construct(t,e,i,r,n){if(1===t[r].isLeaf(e,i))return;this.childOffsets[n]||(this.childOffsets[n]=this.nodeCount);const s=r-1,o=t[s];let a=0,l=0;for(let t=0;t<this._siblingOffset.length;t++){const r=2*e+this._siblingOffset[t][0],n=2*i+this._siblingOffset[t][1],s=o.getElevation(r,n),c=o.isLeaf(r,n),h=this._addNode(s.min,s.max,c);c&&(a|=1<<t),l||(l=h)}for(let r=0;r<this._siblingOffset.length;r++)a&1<<r||this._construct(t,2*e+this._siblingOffset[r][0],2*i+this._siblingOffset[r][1],s,l+r)}}function bd(t,e,i,r,n,s){return Ai(Ai(t,i,s),Ai(e,r,s),n)}function wd(t,e,i){const r=i.dim,n=v(t*r-.5,0,r-1),s=v(e*r-.5,0,r-1),o=Math.floor(n),a=Math.floor(s),l=Math.min(o+1,r-1),c=Math.min(a+1,r-1);return bd(i.get(o,a),i.get(l,a),i.get(o,c),i.get(l,c),n-o,s-a)}const Td={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};class Ed{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(t,e,i,r=!1,n=!1){if(this.uid=t,e.height!==e.width)throw new RangeError("DEM tiles must be square");if(i&&"mapbox"!==i&&"terrarium"!==i)return O(`"${i}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=e.height;const s=this.dim=e.height-2,o=new Uint32Array(e.data.buffer);if(this.pixels=new Uint8Array(e.data.buffer),this.encoding=i||"mapbox",this.borderReady=r,!r){for(let t=0;t<s;t++)o[this._idx(-1,t)]=o[this._idx(0,t)],o[this._idx(s,t)]=o[this._idx(s-1,t)],o[this._idx(t,-1)]=o[this._idx(t,0)],o[this._idx(t,s)]=o[this._idx(t,s-1)];o[this._idx(-1,-1)]=o[this._idx(0,0)],o[this._idx(s,-1)]=o[this._idx(s-1,0)],o[this._idx(-1,s)]=o[this._idx(0,s-1)],o[this._idx(s,s)]=o[this._idx(s-1,s-1)],n&&this._buildQuadTree()}}_buildQuadTree(){this._tree=new vd(this)}get(t,e,i=!1){i&&(t=v(t,-1,this.dim),e=v(e,-1,this.dim));const r=4*this._idx(t,e);return("terrarium"===this.encoding?this._unpackTerrarium:this._unpackMapbox)(this.pixels[r],this.pixels[r+1],this.pixels[r+2])}static getUnpackVector(t){return Td[t]}get unpackVector(){return Td[this.encoding]}_idx(t,e){if(t<-1||t>=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}_unpackMapbox(t,e,i){return(256*t*256+256*e+i)/10-1e4}_unpackTerrarium(t,e,i){return 256*t+e+i/256-32768}static pack(t,e){const i=[0,0,0,0],r=Ed.getUnpackVector(e);let n=Math.floor((t+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 ec({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let r=e*this.dim,n=e*this.dim+this.dim,s=i*this.dim,o=i*this.dim+this.dim;switch(e){case-1:r=n-1;break;case 1:n=r+1}switch(i){case-1:s=o-1;break;case 1:o=s+1}const a=-e*this.dim,l=-i*this.dim;for(let e=s;e<o;e++)for(let i=r;i<n;i++){const r=4*this._idx(i,e),n=4*this._idx(i+a,e+l);this.pixels[r+0]=t.pixels[n+0],this.pixels[r+1]=t.pixels[n+1],this.pixels[r+2]=t.pixels[n+2],this.pixels[r+3]=t.pixels[n+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}Fn(Ed),Fn(vd,{omit:["dem"]});class Id{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const r=t.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);const n={value:e,timeout:void 0};if(void 0!==i&&(n.timeout=setTimeout((()=>{this.remove(t,n)}),i)),this.data[r].push(n),this.order.push(r),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,r=void 0===e?0:this.data[i].indexOf(e),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(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const r of this.data[i])t(r.value)||e.push(r);for(const t of e)this.remove(t.value.tileID,t)}}class Sd{constructor(t,e,i){this.context=t;const r=t.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||e.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const e=this.context.gl;this.context.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Ad={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class zd{constructor(t,e,i,r){this.length=e.length,this.attributes=i,this.itemSize=e.bytesPerElement,this.dynamicDraw=r,this.context=t;const n=t.gl;this.buffer=n.createBuffer(),t.bindVertexBuffer.set(this.buffer),n.bufferData(n.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||e.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){const e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,e){for(let i=0;i<this.attributes.length;i++){const r=e.attributes[this.attributes[i].name];void 0!==r&&t.enableVertexAttribArray(r)}}setVertexAttribPointers(t,e,i){for(let r=0;r<this.attributes.length;r++){const n=this.attributes[r],s=e.attributes[n.name];void 0!==s&&t.vertexAttribPointer(s,n.components,t[Ad[n.type]],!1,this.itemSize,n.offset+this.itemSize*(i||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Cd{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class Md extends Cd{getDefault(){return Le.transparent}set(t){const e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class kd extends Cd{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class Pd extends Cd{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class Dd extends Cd{getDefault(){return[!0,!0,!0,!0]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Bd extends Cd{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class Ld extends Cd{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class Rd extends Cd{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){const e=this.current;(t.func!==e.func||t.ref!==e.ref||t.mask!==e.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class Fd extends Cd{getDefault(){const t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class Od extends Cd{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this.current=t,this.dirty=!1}}class Vd extends Cd{getDefault(){return[0,1]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class jd extends Cd{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this.current=t,this.dirty=!1}}class Ud extends Cd{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class Nd extends Cd{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.BLEND):e.disable(e.BLEND),this.current=t,this.dirty=!1}}class Zd extends Cd{getDefault(){const t=this.gl;return[t.ONE,t.ZERO]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class qd extends Cd{getDefault(){return Le.transparent}set(t){const e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Gd extends Cd{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class $d extends Cd{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this.current=t,this.dirty=!1}}class Wd extends Cd{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class Xd extends Cd{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class Hd extends Cd{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class Kd extends Cd{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class Yd extends Cd{getDefault(){const t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Jd extends Cd{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class Qd extends Cd{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindRenderbuffer(e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class tf extends Cd{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindTexture(e.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class ef extends Cd{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindBuffer(e.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class rf extends Cd{getDefault(){return null}set(t){const e=this.gl;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class nf extends Cd{constructor(t){super(t),this.vao=t.extVertexArrayObject}getDefault(){return null}set(t){this.vao&&(t!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(t),this.current=t,this.dirty=!1)}}class sf extends Cd{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class of extends Cd{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class af extends Cd{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class lf extends Cd{constructor(t,e){super(t),this.context=t,this.parent=e}getDefault(){return null}}class cf extends lf{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class hf extends lf{attachment(){return this.gl.DEPTH_ATTACHMENT}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,this.attachment(),e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class uf extends hf{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class pf{constructor(t,e,i,r){this.context=t,this.width=e,this.height=i;const n=this.framebuffer=t.gl.createFramebuffer();this.colorAttachment=new cf(t,n),r&&(this.depthAttachment=new hf(t,n))}destroy(){const t=this.context.gl,e=this.colorAttachment.get();if(e&&t.deleteTexture(e),this.depthAttachment){const e=this.depthAttachment.get();e&&t.deleteRenderbuffer(e)}t.deleteFramebuffer(this.framebuffer)}}class df{constructor(t,e,i){this.func=t,this.mask=e,this.range=i}}df.ReadOnly=!1,df.ReadWrite=!0,df.disabled=new df(519,df.ReadOnly,[0,1]);const ff=7680;class mf{constructor(t,e,i,r,n,s){this.test=t,this.ref=e,this.mask=i,this.fail=r,this.depthFail=n,this.pass=s}}mf.disabled=new mf({func:519,mask:0},0,0,ff,ff,ff);class _f{constructor(t,e,i){this.blendFunction=t,this.blendColor=e,this.mask=i}}_f.Replace=[1,0],_f.disabled=new _f(_f.Replace,Le.transparent,[!1,!1,!1,!1]),_f.unblended=new _f(_f.Replace,Le.transparent,[!0,!0,!0,!0]),_f.alphaBlended=new _f([1,771],Le.transparent,[!0,!0,!0,!0]);const gf=1029,yf=2305;class xf{constructor(t,e,i){this.enable=t,this.mode=e,this.frontFace=i}}xf.disabled=new xf(!1,gf,yf),xf.backCCW=new xf(!0,gf,yf),xf.backCW=new xf(!0,gf,2304),xf.frontCW=new xf(!0,1028,2304),xf.frontCCW=new xf(!0,1028,yf);class vf{constructor(t){this.gl=t,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),this.clearColor=new Md(this),this.clearDepth=new kd(this),this.clearStencil=new Pd(this),this.colorMask=new Dd(this),this.depthMask=new Bd(this),this.stencilMask=new Ld(this),this.stencilFunc=new Rd(this),this.stencilOp=new Fd(this),this.stencilTest=new Od(this),this.depthRange=new Vd(this),this.depthTest=new jd(this),this.depthFunc=new Ud(this),this.blend=new Nd(this),this.blendFunc=new Zd(this),this.blendColor=new qd(this),this.blendEquation=new Gd(this),this.cullFace=new $d(this),this.cullFaceSide=new Wd(this),this.frontFace=new Xd(this),this.program=new Hd(this),this.activeTexture=new Kd(this),this.viewport=new Yd(this),this.bindFramebuffer=new Jd(this),this.bindRenderbuffer=new Qd(this),this.bindTexture=new tf(this),this.bindVertexBuffer=new ef(this),this.bindElementBuffer=new rf(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new nf(this),this.pixelStoreUnpack=new sf(this),this.pixelStoreUnpackPremultiplyAlpha=new of(this),this.pixelStoreUnpackFlipY=new af(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureFilterAnisotropicForceOff=!1,this.extTextureHalfFloat=t.getExtension("OES_texture_half_float"),this.extTextureHalfFloat&&(t.getExtension("OES_texture_half_float_linear"),this.extRenderToTextureHalfFloat=t.getExtension("EXT_color_buffer_half_float")),this.extTimerQuery=t.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=t.getParameter(t.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(t,e){return new Sd(this,t,e)}createVertexBuffer(t,e,i){return new zd(this,t,e,i)}createRenderbuffer(t,e,i){const r=this.gl,n=r.createRenderbuffer();return this.bindRenderbuffer.set(n),r.renderbufferStorage(r.RENDERBUFFER,t,e,i),this.bindRenderbuffer.set(null),n}createFramebuffer(t,e,i){return new pf(this,t,e,i)}clear({color:t,depth:e,stencil:i}){const r=this.gl;let n=0;t&&(n|=r.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),void 0!==e&&(n|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(e),this.depthMask.set(!0)),void 0!==i&&(n|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.clear(n)}setCullFace(t){!1===t.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)}setStencilMode(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)}setColorMode(t){c(t.blendFunction,_f.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}class bf extends he{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Id(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=null,this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new fd}onAdd(t){this.map=t,this._minTileCacheSize=t?t._minTileCacheSize:null,this._maxTileCacheSize=t?t._maxTileCacheSize:null}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t,(()=>{}))}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t,(()=>{}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager)}}getIds(){return E(this._tiles).map((t=>t.tileID)).sort(wf).map((t=>t.key))}getRenderableIds(t){const e=[];for(const i in this._tiles)this._isIdRenderable(+i,t)&&e.push(this._tiles[i]);return t?e.sort(((t,e)=>{const i=t.tileID,r=e.tileID,n=new o(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),s=new o(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-r.overscaledZ||s.y-n.y||s.x-n.x})).map((t=>t.tileID.key)):e.map((t=>t.tileID)).sort(wf).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,r){if(r)if(t.state="errored",404!==r.status)this._source.fire(new ce(r,{tile:t}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform);else t.timeAdded=J.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new le("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let r=0;r<e.length;r++){const n=e[r];if(t.neighboringTiles&&t.neighboringTiles[n]){const e=this.getTileByID(n);i(t,e),i(e,t)}}function i(t,e){if(!t.dem||t.dem.borderReady)return;t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0;let i=e.tileID.canonical.x-t.tileID.canonical.x;const r=e.tileID.canonical.y-t.tileID.canonical.y,n=Math.pow(2,t.tileID.canonical.z),s=e.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)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,r),t.neighboringTiles&&t.neighboringTiles[s]&&(t.neighboringTiles[s].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,r){for(const n in this._tiles){let s=this._tiles[n];if(r[n]||!s.hasData()||s.tileID.overscaledZ<=e||s.tileID.overscaledZ>i)continue;let o=s.tileID;for(;s&&s.tileID.overscaledZ>e+1;){const t=s.tileID.scaledTo(s.tileID.overscaledZ-1);s=this._tiles[t.key],s&&s.hasData()&&(o=t)}let a=o;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){r[o.key]=o;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),r=this._getLoadedTile(e);if(r)return r}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,r=Math.ceil(t.height/e)+1,n=Math.floor(i*r*5),s="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,n):n,o="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,s):s;this._cache.setMaxSize(o)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+e),t[r.tileID.key]=r}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new Zp(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(r=t.coveringTiles({tileSize:e||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((t=>this._source.hasTile(t))))):r=[];const n=this._updateRetainedTiles(r);if(Tf(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(n);for(const r of i){const i=n[r],s=this._tiles[r];if(!s||s.fadeEndTime&&s.fadeEndTime<=J.now())continue;const o=this.findLoadedParent(i,Math.max(i.overscaledZ-bf.maxOverzooming,this._source.minzoom));o&&(this._addTile(o.tileID),t[o.tileID.key]=o.tileID),e[r]=i}const s=r[r.length-1].overscaledZ;for(const t in this._tiles){const i=this._tiles[t];if(n[t]||!i.hasData())continue;let r=i.tileID;for(;r.overscaledZ>s;){r=r.scaledTo(r.overscaledZ-1);const s=this._tiles[r.key];if(s&&s.hasData()&&e[r.key]){n[t]=i.tileID;break}}}for(const e in t)n[e]||(this._coveredTiles[e]=!0,n[e]=t[e])}for(const t in n)this._tiles[t].clearFadeHold();const s=function(t,e){const i=[];for(const r in t)r in e||i.push(r);return i}(this._tiles,n);for(const t of s){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},r=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),n=t[0].overscaledZ,s=Math.max(n-bf.maxOverzooming,this._source.minzoom),o=Math.max(n+bf.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||r<this._source.maxzoom&&(a[i.key]=i)}this._retainLoadedChildren(a,r,o,e);for(const r of t){let t=this._tiles[r.key];if(t.hasData())continue;if(r.canonical.z>=this._source.maxzoom){const t=r.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=r.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let n=t.wasRequested();for(let o=r.overscaledZ-1;o>=s;--o){const s=r.scaledTo(o);if(i[s.key])break;if(i[s.key]=!0,t=this.getTile(s),!t&&n&&(t=this._addTile(s)),t&&(e[s.key]=s,n=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,r=this._tiles[t].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}e.push(r.key);const t=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;r=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null,r="raster"===this._source.type||"raster-dem"===this._source.type;e=new dd(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,i,r),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new le("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);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(t,e,i){const r=[],n=this.transform;if(!n)return r;for(const s in this._tiles){const o=this._tiles[s];if(i&&o.clearQueryDebugViz(),o.holdingForFade())continue;const a=t.containsTile(o,n,e);a&&r.push(a)}return r}getVisibleCoordinates(t){const e=this.getRenderableIds(t).map((t=>this._tiles[t].tileID));for(const t of e)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped());return e}hasTransition(){if(this._source.hasTransition())return!0;if(Tf(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=J.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const r=this._tiles[t];r&&r.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){const i=new Map,r=Array.isArray(t)?t:[t],n=this.map.painter.terrain,s=this.usedForTerrain&&n?n.getScaledDemTileSize():this._source.tileSize;for(const t of r){const e=t.coveringTiles({tileSize:s,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}const o=Array.from(i.values()),a="raster"===this._source.type||"raster-dem"===this._source.type;T(o,((t,e)=>{const i=new dd(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,a);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function wf(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap<0),r=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||r-i||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function Tf(t){return"raster"===t||"image"===t||"video"===t}bf.maxOverzooming=10,bf.maxUnderzooming=3;class Ef{constructor(t,e,i){this._demTile=t,this._dem=this._demTile.dem,this._scale=e,this._offset=i}static create(t,e,i){const r=i||t.findDEMTileFor(e);if(!r||!r.dem)return;const n=r.dem,s=r.tileID,o=1<<e.canonical.z-s.canonical.z;return new Ef(r,r.tileSize/la/o,[(e.canonical.x/o-s.canonical.x)*n.dim,(e.canonical.y/o-s.canonical.y)*n.dim])}tileCoordToPixel(t,e){const i=e*this._scale+this._offset[1],r=Math.floor(t*this._scale+this._offset[0]),n=Math.floor(i);return new o(r,n)}getElevationAt(t,e,i,r){const n=t*this._scale+this._offset[0],s=e*this._scale+this._offset[1],o=Math.floor(n),a=Math.floor(s),l=this._dem;return r=!!r,i?Ai(Ai(l.get(o,a,r),l.get(o,a+1,r),s-a),Ai(l.get(o+1,a,r),l.get(o+1,a+1,r),s-a),n-o):l.get(o,a,r)}getElevationAtPixel(t,e,i){return this._dem.get(t,e,!!i)}getMeterToDEM(t){return(1<<this._demTile.tileID.canonical.z)*_a(1,t)*this._dem.stride}}function If(t,e,i,r,n){return B(t,((t,s)=>{const o=e instanceof xs?e.get(s):null;return o&&o.evaluate?o.evaluate(i,r,n):o}))}function Sf(t,e){return e-t}Fn(class{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new Bn(la,16,0),this.featureIndexArray=new _o,this.promoteId=e}insert(t,e,i,r,n,s=0){const o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,n,s);const a=this.grid;for(let t=0;t<e.length;t++){const i=e[t],r=[1/0,1/0,-1/0,-1/0];for(let t=0;t<i.length;t++){const e=i[t];r[0]=Math.min(r[0],e.x),r[1]=Math.min(r[1],e.y),r[2]=Math.max(r[2],e.x),r[3]=Math.max(r[3],e.y)}r[0]<la&&r[1]<la&&r[2]>=0&&r[3]>=0&&a.insert(o,r[0],r[1],r[2],r[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new nh.VectorTile(new qh(this.rawTileData)).layers,this.sourceLayerCoder=new Qp(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[]}return this.vtLayers}query(t,e,i,r){this.loadVTLayers();const n=t.params||{},s=Hr(n.filter),o=t.tileResult,a=t.transform,l=o.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,r)=>Na(o.bufferedTilespaceGeometry,t,e,i,r)));c.sort(Sf);let h=null;a.elevation&&c.length>0&&(h=Ef.create(a.elevation,this.tileID));const u={};let p;for(let a=0;a<c.length;a++){const l=c[a];if(l===p)continue;p=l;const d=this.featureIndexArray.get(l);let f=null;this.loadMatchingFeature(u,d,s,n.layers,n.availableImages,e,i,r,((e,i,r,n=0)=>(f||(f=Aa(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(o,e,r,f,this.z,t.transform,t.pixelPosMatrix,h,n))))}return u}loadMatchingFeature(t,e,i,r,n,s,o,a,l){const{featureIndex:c,bucketIndex:h,sourceLayerIndex:u,layoutVertexArrayOffset:p}=e,d=this.bucketLayerIDs[h];if(r&&!function(t,e){for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>=0)return!0;return!1}(r,d))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=za(m,!0);if(!i.filter(new us(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new us(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e<d.length;e++){const i=d[e];if(r&&r.indexOf(i)<0)continue;const h=s[i];if(!h)continue;let u={};void 0!==_&&a&&(u=a.getState(h.sourceLayer||"_geojsonTileLayer",_));const f=I({},o[i]);f.paint=If(f.paint,h.paint,m,u,n),f.layout=If(f.layout,h.layout,m,u,n);const g=!l||l(m,h,u,p);if(!g)continue;const y=new ed(m,this.z,this.x,this.y,_);y.layer=f;let x=t[i];void 0===x&&(x=t[i]=[]),x.push({featureIndex:c,feature:y,intersectionZ:g})}}lookupSymbolFeatures(t,e,i,r,n,s,o,a){const l={};this.loadVTLayers();const c=Hr(n);for(const n of t)this.loadMatchingFeature(l,{bucketIndex:i,sourceLayerIndex:r,featureIndex:n,layoutVertexArrayOffset:0},c,s,o,a,e);return l}loadFeature(t){const{featureIndex:e,sourceLayerIndex:i}=t;this.loadVTLayers();const r=this.sourceLayerCoder.decode(i),n=this.vtFeatures[r];if(n[e])return n[e];const s=this.vtLayers[r].feature(e);return n[e]=s,s}hasLayer(t){for(const e of this.bucketLayerIDs)for(const i of e)if(t===i)return!0;return!1}getId(t,e){let i=t.id;return this.promoteId&&(i=t.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[e]],"boolean"==typeof i&&(i=Number(i))),i}},{omit:["rawTileData","sourceLayerCoder"]}),Fn(class{constructor(t){const e={},i=[];for(const r in t){const n=t[r],s=e[r]={};for(const t in n.glyphs){const e=n.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const r=e.metrics.localGlyph?2:1,o={x:0,y:0,w:e.bitmap.width+2*r,h:e.bitmap.height+2*r};i.push(o),s[t]=o}}const{w:r,h:n}=du(i),s=new tc({width:r||1,height:n||1});for(const i in t){const r=t[i];for(const t in r.glyphs){const n=r.glyphs[+t];if(!n||0===n.bitmap.width||0===n.bitmap.height)continue;const o=e[i][t],a=n.metrics.localGlyph?2:1;tc.copy(n.bitmap,s,{x:0,y:0},{x:o.x+a,y:o.y+a},n.bitmap)}}this.image=s,this.positions=e}});class Af{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,r){const n=this.entries[t]=this.entries[t]||{callbacks:[]};if(n.result){const[t,i]=n.result;return this.scheduler?this.scheduler.add((()=>{r(t,i)}),e):r(t,i),()=>{}}return n.callbacks.push(r),n.cancel||(n.cancel=i(((i,r)=>{n.result=[i,r];for(const t of n.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,r)}),e):t(i,r);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{n.result||(n.callbacks=n.callbacks.filter((t=>t!==r)),n.callbacks.length||(n.cancel(),delete this.entries[t]))}}}function zf(t,e,i){const r=JSON.stringify(t.request);return t.data&&(this.deduped.entries[r]={result:[null,t.data]}),this.deduped.request(r,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const r=Jt(t.request,((t,r,n,s)=>{t?e(t):r&&e(null,{vectorTile:i?void 0:new nh.VectorTile(new qh(r)),rawData:r,cacheControl:n,expires:s})}));return()=>{r.cancel(),e()}}),e)}class Cf extends he{constructor(t,e,i,r){super(),this.id=t,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=I({type:"raster"},e),I(this,S(e,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new le("dataloading",{dataType:"source"})),this._tileJSONRequest=Yp(this._options,this.map._requestManager,((t,e)=>{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new ce(t)):e&&(I(this,e),e.bounds&&(this.tileBounds=new Jp(e.bounds,this.minzoom,this.maxzoom)),kt(e.tiles),this.fire(new le("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new le("data",{dataType:"source",sourceDataType:"content"})))}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return I({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t,e){const i=J.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),i,this.tileSize);t.request=se(this.map._requestManager.transformRequest(r,Wt.Tile),((i,r,n,s)=>{if(delete t.request,t.aborted)t.state="unloaded",e(null);else if(i)t.state="errored",e(i);else if(r){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:n,expires:s});const i=this.map.painter.context,o=i.gl;t.texture=this.map.painter.getTileTexture(r.width),t.texture?t.texture.update(r,{useMipmap:!0}):(t.texture=new qu(i,r,o.RGBA,{useMipmap:!0}),t.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE),i.extTextureFilterAnisotropic&&o.texParameterf(o.TEXTURE_2D,i.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,i.extTextureFilterAnisotropicMax)),t.state="loaded",$t(this.dispatcher),e(null)}}))}abortTile(t,e){t.request&&(t.request.cancel(),delete t.request),e()}unloadTile(t,e){t.texture&&this.map.painter.saveTileTexture(t.texture),e()}hasTransition(){return!1}}let Mf;function kf(t,e,i,r,n,s,o,a){const l=[t,i,n,e,r,s,1,1,1],c=[o,a,1],h=tl([],l),[u,p,d]=Ml(c,c,function(t,e){if(t===e){var i=e[1],r=e[2],n=e[5];t[1]=e[3],t[2]=e[6],t[3]=i,t[5]=e[7],t[6]=r,t[7]=n}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t}(h,h));return el(l,[u,0,0,0,p,0,0,0,d],l)}class Pf extends he{constructor(t,e,i,r){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=e}load(t){this._loaded=!1,this.fire(new le("dataloading",{dataType:"source"})),this.url=this.options.url,se(this.map._requestManager.transformRequest(this.url,Wt.Image),((e,i)=>{if(this._loaded=!0,e)this.fire(new ce(e));else if(i){const{HTMLImageElement:e}=l;this.image=i instanceof e?J.getImageData(i):i,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading()}}))}loaded(){return this._loaded}updateImage(t){return this.image&&t.url?(this.options.url=t.url,this.load(t.coordinates),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new le("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this.texture&&this.texture.destroy()}setCoordinates(t){this.coordinates=t,this._boundsArray=void 0;const e=t.map(ba.fromLngLat);return this.tileID=function(t){let e=1/0,i=1/0,r=-1/0,n=-1/0;for(const s of t)e=Math.min(e,s.x),i=Math.min(i,s.y),r=Math.max(r,s.x),n=Math.max(n,s.y);const s=Math.max(r-e,n-i),o=Math.max(0,Math.floor(-Math.log(s)/Math.LN2)),a=Math.pow(2,o);return new Up(o,Math.floor((e+r)/2*a),Math.floor((i+n)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new le("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(t){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray)return;const e=Gp(this.tileID,this.map.transform.projection),[i,r,n,s]=this.coordinates.map((t=>{const i=e.projection.project(t[0],t[1]);return Wp(e,i)._round()}));this.perspectiveTransform=function(t,e,i,r,n,s,o,a,l,c){const h=kf(0,0,t,0,0,e,t,e),u=kf(i,r,n,s,o,a,l,c);return el(u,tl(h,h),u),[u[6]/u[8]*t/la,u[7]/u[8]*e/la]}(this.width,this.height,i.x,i.y,r.x,r.y,s.x,s.y,n.x,n.y);const o=this._boundsArray=new Bs;o.emplaceBack(i.x,i.y,0,0),o.emplaceBack(r.x,r.y,la,0),o.emplaceBack(s.x,s.y,0,la),o.emplaceBack(n.x,n.y,la,la),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=t.createVertexBuffer(o,ud.members),this.boundsSegments=aa.simpleSegment(0,0,4,2)}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const t=this.map.painter.context,e=t.gl;this.texture?this.texture.update(this.image):(this.texture=new qu(t,this.image,e.RGBA),this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE)),this._prepareData(t)}loadTile(t,e){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={},e(null)):(t.state="errored",e(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const Df={vector:class extends he{constructor(t,e,i,r){if(super(),this.id=t,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,I(this,S(e,["url","scheme","tileSize","promoteId"])),this._options=I({type:"vector"},e),this._collectResourceTiming=e.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r),this._tileWorkers={},this._deduped=new Af}load(){this._loaded=!1,this.fire(new le("dataloading",{dataType:"source"})),this._tileJSONRequest=Yp(this._options,this.map._requestManager,((t,e)=>{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new ce(t)):e&&(I(this,e),e.bounds&&(this.tileBounds=new Jp(e.bounds,this.minzoom,this.maxzoom)),kt(e.tiles,this.map._requestManager._customAccessToken),this.fire(new le("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new le("data",{dataType:"source",sourceDataType:"content"})))}))}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.cancel(),t();const e=this.map.style._getSourceCaches(this.id);for(const t of e)t.clearTiles();this.load()}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return I({},this._options)}loadTile(t,e){const i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(i,Wt.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:J.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:t.isSymbolTile};if(r.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=e:t.request=t.actor.send("reloadTile",r,n.bind(this));else if(t.actor=this._tileWorkers[i]=this._tileWorkers[i]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send("loadTile",r,n.bind(this),void 0,!0);else{const e=zf.call({deduped:this._deduped},r,((e,i)=>{e||!i?n.call(this,e):(r.data={cacheControl:i.cacheControl,expires:i.expires,rawData:i.rawData.slice(0)},t.actor&&t.actor.send("loadTile",r,n.bind(this),void 0,!0))}),!0);t.request={cancel:e}}function n(i,r){return delete t.request,t.aborted?e(null):i&&404!==i.status?e(i):(r&&r.resourceTiming&&(t.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&t.setExpiryData(r),t.loadVectorData(r,this.map.painter),$t(this.dispatcher),e(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.actor&&t.actor.send("abortTile",{uid:t.uid,type:this.type,source:this.id})}unloadTile(t){t.unloadVectorData(),t.actor&&t.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:Cf,"raster-dem":class extends Cf{constructor(t,e,i,r){super(t,e,i,r),this.type="raster-dem",this.maxzoom=22,this._options=I({type:"raster-dem"},e),this.encoding=e.encoding||"mapbox"}loadTile(t,e){const i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function r(i,r){i&&(t.state="errored",e(i)),r&&(t.dem=r,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state="loaded",e(null))}t.request=se(this.map._requestManager.transformRequest(i,Wt.Tile),function(i,n,s,o){if(delete t.request,t.aborted)t.state="unloaded",e(null);else if(i)t.state="errored",e(i);else if(n){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:s,expires:o});const e=l.ImageBitmap&&n instanceof l.ImageBitmap&&(null==Mf&&(Mf=l.OffscreenCanvas&&new l.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof l.createImageBitmap),Mf),i=1-(n.width-((a=n.width)<=1?1:Math.pow(2,Math.floor(Math.log(a)/Math.LN2))))/2;i<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));const c=e?n:J.getImageData(n,i),h={uid:t.uid,coord:t.tileID,source:this.id,rawImageData:c,encoding:this.encoding,padding:i};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",h,r.bind(this),void 0,!0))}var a}.bind(this))}_getNeighboringTiles(t){const e=t.canonical,i=Math.pow(2,e.z),r=(e.x-1+i)%i,n=0===e.x?t.wrap-1:t.wrap,s=(e.x+1+i)%i,o=e.x+1===i?t.wrap+1:t.wrap,a={};return a[new Zp(t.overscaledZ,n,e.z,r,e.y).key]={backfilled:!1},a[new Zp(t.overscaledZ,o,e.z,s,e.y).key]={backfilled:!1},e.y>0&&(a[new Zp(t.overscaledZ,n,e.z,r,e.y-1).key]={backfilled:!1},a[new Zp(t.overscaledZ,t.wrap,e.z,e.x,e.y-1).key]={backfilled:!1},a[new Zp(t.overscaledZ,o,e.z,s,e.y-1).key]={backfilled:!1}),e.y+1<i&&(a[new Zp(t.overscaledZ,n,e.z,r,e.y+1).key]={backfilled:!1},a[new Zp(t.overscaledZ,t.wrap,e.z,e.x,e.y+1).key]={backfilled:!1},a[new Zp(t.overscaledZ,o,e.z,s,e.y+1).key]={backfilled:!1}),a}unloadTile(t){t.demTexture&&this.map.painter.saveTileTexture(t.demTexture),t.fbo&&(t.fbo.destroy(),delete t.fbo),t.dem&&delete t.dem,delete t.neighboringTiles,t.state="unloaded"}},geojson:class extends he{constructor(t,e,i,r){super(),this.id=t,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=e.data,this._options=I({},e),this._collectResourceTiming=e.collectResourceTiming,void 0!==e.maxzoom&&(this.maxzoom=e.maxzoom),e.type&&(this.type=e.type),e.attribution&&(this.attribution=e.attribution),this.promoteId=e.promoteId;const n=la/this.tileSize;this.workerOptions=I({source:this.id,cluster:e.cluster||!1,geojsonVtOptions:{buffer:(void 0!==e.buffer?e.buffer:128)*n,tolerance:(void 0!==e.tolerance?e.tolerance:.375)*n,extent:la,maxZoom:this.maxzoom,lineMetrics:e.lineMetrics||!1,generateId:e.generateId||!1},superclusterOptions:{maxZoom:void 0!==e.clusterMaxZoom?e.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,e.clusterMinPoints||2),extent:la,radius:(void 0!==e.clusterRadius?e.clusterRadius:50)*n,log:!1,generateId:e.generateId||!1},clusterProperties:e.clusterProperties,filter:e.filter},e.workerOptions)}onAdd(t){this.map=t,this.setData(this._data)}setData(t){return this._data=t,this._updateWorkerData(),this}getClusterExpansionZoom(t,e){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:t,source:this.id},e),this}getClusterChildren(t,e){return this.actor.send("geojson.getClusterChildren",{clusterId:t,source:this.id},e),this}getClusterLeaves(t,e,i,r){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:t,limit:e,offset:i},r),this}_updateWorkerData(){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new le("dataloading",{dataType:"source"})),this._loaded=!1;const t=I({},this.workerOptions),e=this._data;"string"==typeof e?(t.request=this.map._requestManager.transformRequest(J.resolveURL(e),Wt.Source),t.request.collectResourceTiming=this._collectResourceTiming):t.data=JSON.stringify(e),this._pendingLoad=this.actor.send(`${this.type}.loadData`,t,((t,e)=>{if(this._loaded=!0,this._pendingLoad=null,t)this.fire(new ce(t));else{const t={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&e&&e.resourceTiming&&e.resourceTiming[this.id]&&(t.resourceTiming=e.resourceTiming[this.id]),this.fire(new le("data",t)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)}))}loaded(){return this._loaded}loadTile(t,e){const i=t.actor?"reloadTile":"loadTile";t.actor=this.actor,t.request=this.actor.send(i,{type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:J.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},((r,n)=>(delete t.request,t.unloadVectorData(),t.aborted?e(null):r?e(r):(t.loadVectorData(n,this.map.painter,"reloadTile"===i),e(null)))),void 0,"loadTile"===i)}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.aborted=!0}unloadTile(t){t.unloadVectorData(),this.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return I({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends Pf{constructor(t,e,i,r){super(t,e,i,r),this.roundZoom=!0,this.type="video",this.options=e}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const e of t.urls)this.urls.push(this.map._requestManager.transformRequest(e,Wt.Source).url);!function(t,e){const i=l.document.createElement("video");i.muted=!0,i.onloadstart=function(){e(null,i)};for(let e=0;e<t.length;e++){const r=l.document.createElement("source");ee(t[e])||(i.crossOrigin="Anonymous"),r.src=t[e],i.appendChild(r)}}(this.urls,((t,e)=>{this._loaded=!0,t?this.fire(new ce(t)):e&&(this.video=e,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(t){if(this.video){const e=this.video.seekable;t<e.start(0)||t>e.end(0)?this.fire(new ce(new jr(`sources.${this.id}`,null,`Playback for this video can be set only between the ${e.start(0)} and ${e.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,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 t=this.map.painter.context,e=t.gl;this.texture?this.video.paused||(this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE),e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,this.video)):(this.texture=new qu(t,this.video,e.RGBA),this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:Pf,canvas:class extends Pf{constructor(t,e,i,r){super(t,e,i,r),e.coordinates?Array.isArray(e.coordinates)&&4===e.coordinates.length&&!e.coordinates.some((t=>!Array.isArray(t)||2!==t.length||t.some((t=>"number"!=typeof t))))||this.fire(new ce(new jr(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new ce(new jr(`sources.${t}`,null,'missing required property "coordinates"'))),e.animate&&"boolean"!=typeof e.animate&&this.fire(new ce(new jr(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),e.canvas?"string"==typeof e.canvas||e.canvas instanceof l.HTMLCanvasElement||this.fire(new ce(new jr(`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 ce(new jr(`sources.${t}`,null,'missing required property "canvas"'))),this.options=e,this.animate=void 0===e.animate||e.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof l.HTMLCanvasElement?this.options.canvas:l.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new ce(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(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const e=this.map.painter.context;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new qu(e,this.canvas,e.gl.RGBA,{premultiply:!0}),this._prepareData(e)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}}},Bf=function(t,e,i,r){const n=new Df[e.type](t,e,i,r);if(n.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${n.id}`);return P(["load","abort","unload","serialize","prepare"],n),n};function Lf(t,e){const i=rl([]);return al(i,i,[.5*t.width,.5*-t.height,1]),ol(i,i,[1,-1,0]),sl(i,i,t.calculateProjMatrix(e.toUnwrapped())),Float32Array.from(i)}function Rf(t,e,i,r,n,s,o,a=!1){const l=t.tilesIn(r,o,a);l.sort(Of);const c=[];for(const r of l)c.push({wrappedTileID:r.tile.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(e,i,t._state,r,n,s,Lf(t.transform,r.tile.tileID),a)});const h=function(t){const e={},i={};for(const r of t){const t=r.queryResults,n=r.wrappedTileID,s=i[n]=i[n]||{};for(const i in t){const r=t[i],n=s[i]=s[i]||{},o=e[i]=e[i]||[];for(const t of r)n[t.featureIndex]||(n[t.featureIndex]=!0,o.push(t))}}return e}(c);for(const e in h)h[e].forEach((e=>{const i=e.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?t.getFeatureState(r["source-layer"],i.id):{})}));return h}function Ff(t,e){const i=t.getRenderableIds().map((e=>t.getTileByID(e))),r=[],n={};for(let t=0;t<i.length;t++){const s=i[t],o=s.tileID.canonical.key;n[o]||(n[o]=!0,s.querySourceFeatures(r,e))}return r}function Of(t,e){const i=t.tileID,r=e.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function Vf(){return null!=kx.workerClass?new kx.workerClass:new l.Worker(kx.workerUrl)}const jf="mapboxgl_preloaded_worker_pool";class Uf{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<Uf.workerCount;)this.workers.push(new Vf);return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],0===this.numActive()&&(this.workers.forEach((t=>{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[jf]}numActive(){return Object.keys(this.active).length}}let Nf;function Zf(){return Nf||(Nf=new Uf),Nf}Uf.workerCount=2;var qf=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function Gf(t,e){const i={};for(const e in t)"ref"!==e&&(i[e]=t[e]);return qf.forEach((t=>{t in e&&(i[t]=e[t])})),i}function $f(t){t=t.slice();const e=Object.create(null);for(let i=0;i<t.length;i++)e[t[i].id]=t[i];for(let i=0;i<t.length;i++)"ref"in t[i]&&(t[i]=Gf(t[i],e[t[i].ref]));return t}const Wf={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 Xf(t,e,i){i.push({command:Wf.addSource,args:[t,e[t]]})}function Hf(t,e,i){e.push({command:Wf.removeSource,args:[t]}),i[t]=!0}function Kf(t,e,i,r){Hf(t,i,r),Xf(t,e,i)}function Yf(t,e,i){let r;for(r in t[i])if(t[i].hasOwnProperty(r)&&"data"!==r&&!c(t[i][r],e[i][r]))return!1;for(r in e[i])if(e[i].hasOwnProperty(r)&&"data"!==r&&!c(t[i][r],e[i][r]))return!1;return!0}function Jf(t,e,i,r,n,s){let o;for(o in e=e||{},t=t||{})t.hasOwnProperty(o)&&(c(t[o],e[o])||i.push({command:s,args:[r,o,e[o],n]}));for(o in e)e.hasOwnProperty(o)&&!t.hasOwnProperty(o)&&(c(t[o],e[o])||i.push({command:s,args:[r,o,e[o],n]}))}function Qf(t){return t.id}function tm(t,e){return t[e.id]=e,t}class em{constructor(t,e){this.reset(t,e)}reset(t,e){this.points=t||[],this._distances=[0];for(let t=1;t<this.points.length;t++)this._distances[t]=this._distances[t-1]+this.points[t].dist(this.points[t-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(e||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(1===this.points.length)return this.points[0];t=v(t,0,1);let e=1,i=this._distances[e];const r=t*this.paddedLength+this.padding;for(;i<r&&e<this._distances.length;)i=this._distances[++e];const n=e-1,s=this._distances[n],o=i-s,a=o>0?(r-s)/o:0;return this.points[n].mult(1-a).add(this.points[e].mult(a))}}class im{constructor(t,e,i){const r=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(t/i),this.yCellCount=Math.ceil(e/i);for(let t=0;t<this.xCellCount*this.yCellCount;t++)r.push([]),n.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=t,this.height=e,this.xScale=this.xCellCount/t,this.yScale=this.yCellCount/e,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(t,e,i,r,n){this._forEachCell(e,i,r,n,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)}insertCircle(t,e,i,r){this._forEachCell(e-r,i-r,e+r,i+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(e),this.circles.push(i),this.circles.push(r)}_insertBoxCell(t,e,i,r,n,s){this.boxCells[n].push(s)}_insertCircleCell(t,e,i,r,n,s){this.circleCells[n].push(s)}_query(t,e,i,r,n,s){if(i<0||t>this.width||r<0||e>this.height)return!n&&[];const o=[];if(t<=0&&e<=0&&this.width<=i&&this.height<=r){if(n)return!0;for(let t=0;t<this.boxKeys.length;t++)o.push({key:this.boxKeys[t],x1:this.bboxes[4*t],y1:this.bboxes[4*t+1],x2:this.bboxes[4*t+2],y2:this.bboxes[4*t+3]});for(let t=0;t<this.circleKeys.length;t++){const e=this.circles[3*t],i=this.circles[3*t+1],r=this.circles[3*t+2];o.push({key:this.circleKeys[t],x1:e-r,y1:i-r,x2:e+r,y2:i+r})}return s?o.filter(s):o}return this._forEachCell(t,e,i,r,this._queryCell,o,{hitTest:n,seenUids:{box:{},circle:{}}},s),n?o.length>0:o}_queryCircle(t,e,i,r,n){const s=t-i,o=t+i,a=e-i,l=e+i;if(o<0||s>this.width||l<0||a>this.height)return!r&&[];const c=[];return this._forEachCell(s,a,o,l,this._queryCellCircle,c,{hitTest:r,circle:{x:t,y:e,radius:i},seenUids:{box:{},circle:{}}},n),r?c.length>0:c}query(t,e,i,r,n){return this._query(t,e,i,r,!1,n)}hitTest(t,e,i,r,n){return this._query(t,e,i,r,!0,n)}hitTestCircle(t,e,i,r){return this._queryCircle(t,e,i,!0,r)}_queryCell(t,e,i,r,n,s,o,a){const l=o.seenUids,c=this.boxCells[n];if(null!==c){const n=this.bboxes;for(const h of c)if(!l.box[h]){l.box[h]=!0;const c=4*h;if(t<=n[c+2]&&e<=n[c+3]&&i>=n[c+0]&&r>=n[c+1]&&(!a||a(this.boxKeys[h]))){if(o.hitTest)return s.push(!0),!0;s.push({key:this.boxKeys[h],x1:n[c],y1:n[c+1],x2:n[c+2],y2:n[c+3]})}}}const h=this.circleCells[n];if(null!==h){const n=this.circles;for(const c of h)if(!l.circle[c]){l.circle[c]=!0;const h=3*c;if(this._circleAndRectCollide(n[h],n[h+1],n[h+2],t,e,i,r)&&(!a||a(this.circleKeys[c]))){if(o.hitTest)return s.push(!0),!0;{const t=n[h],e=n[h+1],i=n[h+2];s.push({key:this.circleKeys[c],x1:t-i,y1:e-i,x2:t+i,y2:e+i})}}}}}_queryCellCircle(t,e,i,r,n,s,o,a){const l=o.circle,c=o.seenUids,h=this.boxCells[n];if(null!==h){const t=this.bboxes;for(const e of h)if(!c.box[e]){c.box[e]=!0;const i=4*e;if(this._circleAndRectCollide(l.x,l.y,l.radius,t[i+0],t[i+1],t[i+2],t[i+3])&&(!a||a(this.boxKeys[e])))return s.push(!0),!0}}const u=this.circleCells[n];if(null!==u){const t=this.circles;for(const e of u)if(!c.circle[e]){c.circle[e]=!0;const i=3*e;if(this._circlesCollide(t[i],t[i+1],t[i+2],l.x,l.y,l.radius)&&(!a||a(this.circleKeys[e])))return s.push(!0),!0}}}_forEachCell(t,e,i,r,n,s,o,a){const l=this._convertToXCellCoord(t),c=this._convertToYCellCoord(e),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r);for(let p=l;p<=h;p++)for(let l=c;l<=u;l++)if(n.call(this,t,e,i,r,this.xCellCount*l+p,s,o,a))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,e,i,r,n,s){const o=r-t,a=n-e,l=i+s;return l*l>o*o+a*a}_circleAndRectCollide(t,e,i,r,n,s,o){const a=(s-r)/2,l=Math.abs(t-(r+a));if(l>a+i)return!1;const c=(o-n)/2,h=Math.abs(e-(n+c));if(h>c+i)return!1;if(l<=a||h<=c)return!0;const u=l-a,p=h-c;return u*u+p*p<=i*i}}const rm=Math.tan(85*Math.PI/180);function nm(t,e,i,r,n,s){const o=il();if(i){if("globe"===n.projection.name)sl(o,o,function(t,e){const{lng:i,lat:r}=t._center,n=Mp(0,0,t.worldSize/t._projectionScaler,i,r);return sl(n,n,Ap(xp(e)))}(n,e));else{const t=Ja([],s);o[0]=t[0],o[1]=t[1],o[4]=t[2],o[5]=t[3]}r||hl(o,o,n.angle)}else sl(o,n.labelPlaneMatrix,t);return o}function sm(t,e,i,r,n,s){if(i){if("globe"===n.projection.name){const o=nm(t,e,i,r,n,s);return nl(o,o),sl(o,t,o),o}{const e=(o=t,(a=new Ya(16))[0]=o[0],a[1]=o[1],a[2]=o[2],a[3]=o[3],a[4]=o[4],a[5]=o[5],a[6]=o[6],a[7]=o[7],a[8]=o[8],a[9]=o[9],a[10]=o[10],a[11]=o[11],a[12]=o[12],a[13]=o[13],a[14]=o[14],a[15]=o[15],a),i=rl([]);return i[0]=s[0],i[1]=s[1],i[4]=s[2],i[5]=s[3],sl(e,e,i),r||hl(e,e,-n.angle),e}}return n.glCoordMatrix;var o,a}function om(t,e,i=0){const r=[t.x,t.y,i,1];i?Ol(r,r,e):xm(r,r,e);const n=r[3];return{point:new o(r[0]/n,r[1]/n),signedDistanceFromCamera:n}}function am(t,e){const i=[t[0],t[1],t[2],1];Ol(i,i,e);const r=i[3];return{point:new o(i[0]/r,i[1]/r),signedDistanceFromCamera:r}}function lm(t,e){return Math.min(.5+t/e*.5,1.5)}function cm(t,e){const i=t[0]/t[3],r=t[1]/t[3];return i>=-e[0]&&i<=e[0]&&r>=-e[1]&&r<=e[1]}function hm(t,e,i,r,n,s,a,l,c,h){const u=i.transform,p=r?t.textSizeData:t.iconSizeData,d=Oh(p,i.transform.zoom),f=[256/i.width*2+1,256/i.height*2+1],m=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;m.clear();const _=t.lineVertexArray,g=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,y=i.transform.width/i.transform.height;let x=!1;for(let r=0;r<g.length;r++){const v=g.get(r);if(v.writingMode!==mu.vertical||x||0!==r&&g.get(r-1).writingMode===mu.horizontal||(x=!0),(v.hidden||v.writingMode===mu.vertical)&&!x){ym(v.numGlyphs,m);continue}x=!1;const b=new o(v.tileAnchorX,v.tileAnchorY),w=c?c(b):[0,0,0],T=u.projection.projectTilePoint(b.x,b.y,h.canonical),E=[T.x+w[0],T.y+w[1],T.z+w[2]],I=[...E,1];if(Ol(I,I,e),!cm(I,f)){ym(v.numGlyphs,m);continue}const S=lm(i.transform.cameraToCenterDistance,I[3]),A=Fh(p,d,v),z=a?A/S:A*S,C=om(new o(E[0],E[1]),n,E[2]);if(C.signedDistanceFromCamera<=0){ym(v.numGlyphs,m);continue}let M={};const k=a?null:c,P=dm(v,z,!1,l,e,n,s,t.glyphOffsetArray,_,m,C.point,b,M,y,k,u.projection,h);x=P.useVertical,k&&P.needsFlipping&&(M={}),(P.notEnoughRoom||x||P.needsFlipping&&dm(v,z,!0,l,e,n,s,t.glyphOffsetArray,_,m,C.point,b,M,y,k,u.projection,h).notEnoughRoom)&&ym(v.numGlyphs,m)}r?t.text.dynamicLayoutVertexBuffer.updateData(m):t.icon.dynamicLayoutVertexBuffer.updateData(m)}function um(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f){const m=a.glyphStartIndex+a.numGlyphs,_=a.lineStartIndex,g=a.lineStartIndex+a.lineLength,y=e.getoffsetX(a.glyphStartIndex),x=e.getoffsetX(m-1),v=_m(t*y,i,r,n,s,o,a.segment,_,g,l,c,h,u,p,!0,d,f);if(!v)return null;const b=_m(t*x,i,r,n,s,o,a.segment,_,g,l,c,h,u,p,!0,d,f);return b?{first:v,last:b}:null}function pm(t,e,i,r){return t.writingMode===mu.horizontal&&Math.abs(i.y-e.y)>Math.abs(i.x-e.x)*r?{useVertical:!0}:t.writingMode===mu.vertical?e.y<i.y?{needsFlipping:!0}:null:0!==t.flipState&&function(t,e,i){const r=(e.x-t.x)*i;return 0===r||Math.abs((e.y-t.y)/r)>rm}(e,i,r)?1===t.flipState?{needsFlipping:!0}:null:e.x>i.x?{needsFlipping:!0}:null}function dm(t,e,i,r,n,s,a,l,c,h,u,p,d,f,m,_,g){const y=e/24,x=t.lineOffsetX*y,v=t.lineOffsetY*y;let b;if(t.numGlyphs>1){const e=t.glyphStartIndex+t.numGlyphs,n=t.lineStartIndex,o=t.lineStartIndex+t.lineLength,h=um(y,l,x,v,i,u,p,t,c,s,d,m,!1,_,g);if(!h)return{notEnoughRoom:!0};const w=om(h.first.point,a).point,T=om(h.last.point,a).point;if(r&&!i){const e=pm(t,w,T,f);if(t.flipState=e&&e.needsFlipping?1:2,e)return e}b=[h.first];for(let r=t.glyphStartIndex+1;r<e-1;r++)b.push(_m(y*l.getoffsetX(r),x,v,i,u,p,t.segment,n,o,c,s,d,m,!1,!1,_,g));b.push(h.last)}else{if(r&&!i){const e=om(p,n).point,i=t.lineStartIndex+t.segment+1,r=new o(c.getx(i),c.gety(i)),s=om(r,n),a=pm(t,e,s.signedDistanceFromCamera>0?s.point:mm(p,r,e,1,n,void 0,_,g.canonical),f);if(t.flipState=a&&a.needsFlipping?1:2,a)return a}const e=_m(y*l.getoffsetX(t.glyphStartIndex),x,v,i,u,p,t.segment,t.lineStartIndex,t.lineStartIndex+t.lineLength,c,s,d,m,!1,!1,_,g);if(!e)return{notEnoughRoom:!0};b=[e]}for(const t of b)zu(h,t.point,t.angle);return{}}function fm(t,e,i,r,n){const s=r.projectTilePoint(t.x,t.y,e);if(!n)return om(s,i,s.z);const a=n(t);return om(new o(s.x+a[0],s.y+a[1]),i,s.z+a[2])}function mm(t,e,i,r,n,s,o,a){const l=fm(t.add(t.sub(e)._unit()),a,n,o,s).point,c=i.sub(l);return i.add(c._mult(r/c.mag()))}function _m(t,e,i,r,n,s,a,l,c,h,u,p,d,f,m,_,g){const y=r?t-e:t+e;let x=y>0?1:-1,v=0;r&&(x*=-1,v=Math.PI),x<0&&(v+=Math.PI);let b=x>0?l+a:l+a+1,w=n,T=n,E=0,I=0;const S=Math.abs(y),A=[],z=[];let C=s;const M=()=>{const t=b-x;return 0===E?s:new o(h.getx(t),h.gety(t))},k=()=>mm(M(),C,T,S-E+1,u,d,_,g.canonical);for(;E+I<=S;){if(b+=x,b<l||b>=c)return null;if(T=w,A.push(w),f&&z.push(C||M()),w=p[b],void 0===w){C=new o(h.getx(b),h.gety(b));const t=fm(C,g.canonical,u,_,d);w=t.signedDistanceFromCamera>0?p[b]=t.point:k()}else C=null;E+=I,I=T.dist(w)}m&&d&&(C=C||new o(h.getx(b),h.gety(b)),p[b]=w=void 0===p[b]?w:k(),I=T.dist(w));const P=(S-E)/I,D=w.sub(T),B=D.mult(P)._add(T);i&&B._add(D._unit()._perp()._mult(i*x));const L=v+Math.atan2(w.y-T.y,w.x-T.x);return A.push(B),f&&(C=C||new o(h.getx(b),h.gety(b)),z.push(function(t,e,i){const r=1-i;return new o(t.x*r+e.x*i,t.y*r+e.y*i)}(z.length>0?z[z.length-1]:C,C,P))),{point:B,angle:L,path:A,tilePath:z}}const gm=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function ym(t,e){for(let i=0;i<t;i++){const t=e.length;e.resize(t+4),e.float32.set(gm,3*t)}}function xm(t,e,i){const r=e[0],n=e[1];return t[0]=i[0]*r+i[4]*n+i[12],t[1]=i[1]*r+i[5]*n+i[13],t[3]=i[3]*r+i[7]*n+i[15],t}const vm=100;class bm{constructor(t,e,i=new im(t.width+200,t.height+200,25),r=new im(t.width+200,t.height+200,25)){this.transform=t,this.grid=i,this.ignoredGrid=r,this.pitchfactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+vm,this.screenBottomBoundary=t.height+vm,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.fogState=e}placeCollisionBox(t,e,i,r,n,s,o){let a=e.projectedAnchorX,l=e.projectedAnchorY,c=e.projectedAnchorZ;const h=e.elevation,u=e.tileID;if(h&&u){const t=this.transform.projection.upVector(u.canonical,e.tileAnchorX,e.tileAnchorY),i=this.transform.projection.upVectorScale(u.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;a+=t[0]*h*i,l+=t[1]*h*i,c+=t[2]*h*i}const p=this.projectAndGetPerspectiveRatio(s,[a,l,c],e.tileID,"globe"===this.transform.projection.name||!!h||this.transform.pitch>0),d=n*p.perspectiveRatio,f=(e.x1*t+i.x-e.padding)*d+p.point.x,m=(e.y1*t+i.y-e.padding)*d+p.point.y,_=(e.x2*t+i.x+e.padding)*d+p.point.x,g=(e.y2*t+i.y+e.padding)*d+p.point.y,y=p.perspectiveRatio<=.55||p.occluded;return!this.isInsideGrid(f,m,_,g)||!r&&this.grid.hitTest(f,m,_,g,o)||y?{box:[],offscreen:!1,occluded:p.occluded}:{box:[f,m,_,g],offscreen:this.isOffscreen(f,m,_,g),occluded:!1}}placeCollisionCircles(t,e,i,r,n,s,a,l,c,h,u,p,d,f){const m=[],_=this.transform.elevation,g=_?_.getAtTileOffsetFunc(f,this.transform.center.lat,this.transform.worldSize,this.transform.projection):t=>[0,0,0],y=new o(e.tileAnchorX,e.tileAnchorY),x=this.transform.projection.projectTilePoint(e.tileAnchorX,e.tileAnchorY,f.canonical),v=g(y),b=[x.x+v[0],x.y+v[1],x.z+v[2]],w=this.projectAndGetPerspectiveRatio(s,[b[0],b[1],b[2]],f,"globe"===this.transform.projection.name||!!_||this.transform.pitch>0),{perspectiveRatio:T}=w,E=(h?n/T:n*T)/24,I=om(new o(b[0],b[1]),a,b[2]).point,S=w.signedDistanceFromCamera>0?um(E,r,e.lineOffsetX*E,e.lineOffsetY*E,!1,I,y,e,i,a,{},_&&!h?g:null,h&&!!_,this.transform.projection,f):null;let A=!1,z=!1,C=!0;if(S&&!w.occluded){const e=.5*p*T+d,i=new o(-100,-100),r=new o(this.screenRightBoundary,this.screenBottomBoundary),n=new em,s=S.first,a=S.last;let h=[];for(let t=s.path.length-1;t>=1;t--)h.push(s.path[t]);for(let t=1;t<a.path.length;t++)h.push(a.path[t]);const f=2.5*e;if(l){const t=h.map(_?(t,e)=>{const i=g(e<s.path.length-1?s.tilePath[s.path.length-1-e]:a.tilePath[e-s.path.length+2]);return om(t,l,i[2])}:t=>om(t,l));h=t.some((t=>t.signedDistanceFromCamera<=0))?[]:t.map((t=>t.point))}let y=[];if(h.length>0){const t=h[0].clone(),e=h[0].clone();for(let i=1;i<h.length;i++)t.x=Math.min(t.x,h[i].x),t.y=Math.min(t.y,h[i].y),e.x=Math.max(e.x,h[i].x),e.y=Math.max(e.y,h[i].y);y=t.x>=i.x&&e.x<=r.x&&t.y>=i.y&&e.y<=r.y?[h]:e.x<i.x||t.x>r.x||e.y<i.y||t.y>r.y?[]:function(t,e,i,r,n){const s=[];for(let a=0;a<t.length;a++){const l=t[a];let c;for(let t=0;t<l.length-1;t++){let a=l[t],h=l[t+1];a.x<e&&h.x<e||(a.x<e?a=new o(e,a.y+(e-a.x)/(h.x-a.x)*(h.y-a.y))._round():h.x<e&&(h=new o(e,a.y+(e-a.x)/(h.x-a.x)*(h.y-a.y))._round()),a.y<i&&h.y<i||(a.y<i?a=new o(a.x+(i-a.y)/(h.y-a.y)*(h.x-a.x),i)._round():h.y<i&&(h=new o(a.x+(i-a.y)/(h.y-a.y)*(h.x-a.x),i)._round()),a.x>=r&&h.x>=r||(a.x>=r?a=new o(r,a.y+(r-a.x)/(h.x-a.x)*(h.y-a.y))._round():h.x>=r&&(h=new o(r,a.y+(r-a.x)/(h.x-a.x)*(h.y-a.y))._round()),a.y>=n&&h.y>=n||(a.y>=n?a=new o(a.x+(n-a.y)/(h.y-a.y)*(h.x-a.x),n)._round():h.y>=n&&(h=new o(a.x+(n-a.y)/(h.y-a.y)*(h.x-a.x),n)._round()),c&&a.equals(c[c.length-1])||(c=[a],s.push(c)),c.push(h)))))}}return s}([h],i.x,i.y,r.x,r.y)}for(const i of y){n.reset(i,.25*e);let r=0;r=n.length<=.5*e?1:Math.ceil(n.paddedLength/f)+1;for(let i=0;i<r;i++){const s=i/Math.max(r-1,1),o=n.lerp(s),a=o.x+vm,l=o.y+vm;m.push(a,l,e,0);const h=a-e,p=l-e,d=a+e,f=l+e;if(C=C&&this.isOffscreen(h,p,d,f),z=z||this.isInsideGrid(h,p,d,f),!t&&this.grid.hitTestCircle(a,l,e,u)&&(A=!0,!c))return{circles:[],offscreen:!1,collisionDetected:A,occluded:!1}}}}return{circles:!c&&A||!z?[]:m,offscreen:C,collisionDetected:A,occluded:w.occluded}}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const e=[];let i=1/0,r=1/0,n=-1/0,s=-1/0;for(const a of t){const t=new o(a.x+vm,a.y+vm);i=Math.min(i,t.x),r=Math.min(r,t.y),n=Math.max(n,t.x),s=Math.max(s,t.y),e.push(t)}const a=this.grid.query(i,r,n,s).concat(this.ignoredGrid.query(i,r,n,s)),l={},c={};for(const t of a){const i=t.key;void 0===l[i.bucketInstanceId]&&(l[i.bucketInstanceId]={}),l[i.bucketInstanceId][i.featureIndex]||Pa(e,[new o(t.x1,t.y1),new o(t.x2,t.y1),new o(t.x2,t.y2),new o(t.x1,t.y2)])&&(l[i.bucketInstanceId][i.featureIndex]=!0,void 0===c[i.bucketInstanceId]&&(c[i.bucketInstanceId]=[]),c[i.bucketInstanceId].push(i.featureIndex))}return c}insertCollisionBox(t,e,i,r,n){(e?this.ignoredGrid:this.grid).insert({bucketInstanceId:i,featureIndex:r,collisionGroupID:n},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,e,i,r,n){const s=e?this.ignoredGrid:this.grid,o={bucketInstanceId:i,featureIndex:r,collisionGroupID:n};for(let e=0;e<t.length;e+=4)s.insertCircle(o,t[e],t[e+1],t[e+2])}projectAndGetPerspectiveRatio(t,e,i,r){const n=[e[0],e[1],e[2],1];let s=!1;return e[2]||this.transform.pitch>0?(Ol(n,n,t),this.fogState&&i&&(s=function(t,e,i,r,n,s){const o=[e,i,r];return Cl(o,o,s.calculateFogTileMatrix(n)),Qu(t,o,s.pitch,s._fov)}(this.fogState,e[0],e[1],e[2],i.toUnwrapped(),this.transform)>.9)):xm(n,n,t),{point:new o((n[0]/n[3]+1)/2*this.transform.width+vm,(-n[1]/n[3]+1)/2*this.transform.height+vm),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/n[3]*.5,1.5),signedDistanceFromCamera:n[3],occluded:r&&n[2]>n[3]||s}}isOffscreen(t,e,i,r){return i<vm||t>=this.screenRightBoundary||r<vm||e>this.screenBottomBoundary}isInsideGrid(t,e,i,r){return i>=0&&t<this.gridRightBoundary&&r>=0&&e<this.gridBottomBoundary}getViewportMatrix(){const t=rl([]);return ol(t,t,[-100,-100,0]),t}}class wm{constructor(t,e,i,r){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?e:-e))):r&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class Tm{constructor(t,e,i,r,n,s=!1){this.text=new wm(t?t.text:null,e,i,n),this.icon=new wm(t?t.icon:null,e,r,n),this.clipped=s}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Em{constructor(t,e,i,r=!1){this.text=t,this.icon=e,this.skipFade=i,this.clipped=r}}class Im{constructor(){this.invProjMatrix=il(),this.viewportMatrix=il(),this.circles=[]}}class Sm{constructor(t,e,i,r,n){this.bucketInstanceId=t,this.featureIndex=e,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=n}}class Am{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){const e=++this.maxGroupID;this.collisionGroups[t]={ID:e,predicate:t=>t.collisionGroupID===e}}return this.collisionGroups[t]}}function zm(t,e,i,r,n){const{horizontalAlign:s,verticalAlign:a}=_u(t),l=-(s-.5)*e,c=-(a-.5)*i,h=Eu(t,r);return new o(l+h[0]*n,c+h[1]*n)}function Cm(t,e,i,r,n){const s=new o(t,e);return i&&s._rotate(r?n:-n),s}class Mm{constructor(t,e,i,r,n){this.transform=t.clone(),this.collisionIndex=new bm(this.transform,n),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=e,this.retainedQueryData={},this.collisionGroups=new Am(i),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,e,i,r){const n=i.getBucket(e),s=i.latestFeatureIndex;if(!n||!s||e.id!==n.layerIds[0])return;const o=n.layers[0].layout,a=i.collisionBoxArray,l=Math.pow(2,this.transform.zoom-i.tileID.overscaledZ),c=i.tileSize/la,h=i.tileID.toUnwrapped(),u=this.transform.calculateProjMatrix(h),p="map"===o.get("text-pitch-alignment"),d="map"===o.get("text-rotation-alignment");e.compileFilter();const f=e.dynamicFilter(),m=e.dynamicFilterNeedsFeature(),_=this.transform.calculatePixelsToTileUnitsMatrix(i),g=nm(u,i.tileID.canonical,p,d,this.transform,_);let y=null;if(p){const t=sm(u,i.tileID.canonical,p,d,this.transform,_);y=sl([],this.transform.labelPlaneMatrix,t)}let x=null;f&&i.latestFeatureIndex&&(x={unwrappedTileID:h,dynamicFilter:f,dynamicFilterNeedsFeature:m,featureIndex:i.latestFeatureIndex}),this.retainedQueryData[n.bucketInstanceId]=new Sm(n.bucketInstanceId,s,n.sourceLayerIndex,n.index,i.tileID);const v={bucket:n,layout:o,posMatrix:u,textLabelPlaneMatrix:g,labelToScreenMatrix:y,clippingData:x,scale:l,textPixelRatio:c,holdingForFade:i.holdingForFade(),collisionBoxArray:a,partiallyEvaluatedTextSize:Oh(n.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:Oh(n.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(n.sourceID)};if(r)for(const e of n.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n}=e;t.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n,parameters:v})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:n.symbolInstances.length,parameters:v})}attemptAnchorPlacement(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m,_,g){const y=[u.textOffset0,u.textOffset1],x=zm(t,i,r,y,n),v=this.collisionIndex.placeCollisionBox(n,e,Cm(x.x,x.y,s,o,this.transform.angle),h,a,l,c.predicate);if((!m||0!==this.collisionIndex.placeCollisionBox(d.getSymbolInstanceIconSize(g,this.transform.zoom,p),m,Cm(x.x,x.y,s,o,this.transform.angle),h,a,l,c.predicate).box.length)&&v.box.length>0){let e;return this.prevPlacement&&this.prevPlacement.variableOffsets[u.crossTileID]&&this.prevPlacement.placements[u.crossTileID]&&this.prevPlacement.placements[u.crossTileID].text&&(e=this.prevPlacement.variableOffsets[u.crossTileID].anchor),this.variableOffsets[u.crossTileID]={textOffset:y,width:i,height:r,anchor:t,textScale:n,prevAnchor:e},this.markUsedJustification(d,t,u,f),d.allowVerticalPlacement&&(this.markUsedOrientation(d,f,u),this.placedOrientations[u.crossTileID]=f),{shift:x,placedGlyphBoxes:v}}}placeLayerBucketPart(t,e,i,r){const{bucket:n,layout:s,posMatrix:a,textLabelPlaneMatrix:l,labelToScreenMatrix:c,clippingData:h,textPixelRatio:u,holdingForFade:p,collisionBoxArray:d,partiallyEvaluatedTextSize:f,partiallyEvaluatedIconSize:m,collisionGroup:_}=t.parameters,g=s.get("text-optional"),y=s.get("icon-optional"),x=s.get("text-allow-overlap"),v=s.get("icon-allow-overlap"),b="map"===s.get("text-rotation-alignment"),w="map"===s.get("text-pitch-alignment"),T="none"!==s.get("icon-text-fit"),E="viewport-y"===s.get("symbol-z-order");let I=x&&(v||!n.hasIconData()||y),S=v&&(x||!n.hasTextData()||g);!n.collisionArrays&&d&&n.deserializeCollisionBoxes(d),i&&r&&n.updateCollisionDebugBuffers(this.transform.zoom,d);const A=(t,r,d)=>{if(h){const i={zoom:this.transform.zoom,pitch:this.transform.pitch};let r=null;if(h.dynamicFilterNeedsFeature){const e=this.retainedQueryData[n.bucketInstanceId];r=h.featureIndex.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,h.dynamicFilter)(i,r,this.retainedQueryData[n.bucketInstanceId].tileID.canonical,new o(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(h.unwrappedTileID)))return this.placements[t.crossTileID]=new Em(!1,!1,!1,!0),void(e[t.crossTileID]=!0)}if(e[t.crossTileID])return;if(p)return void(this.placements[t.crossTileID]=new Em(!1,!1,!1));let E=!1,A=!1,z=!0,C=!1,M=!1,k=null,P={box:null,offscreen:null,occluded:null},D={box:null,offscreen:null,occluded:null},B=null,L=null,R=null,F=0,O=0,V=0;d.textFeatureIndex?F=d.textFeatureIndex:t.useRuntimeCollisionCircles&&(F=t.featureIndex),d.verticalTextFeatureIndex&&(O=d.verticalTextFeatureIndex);const j=t=>{t.tileID=this.retainedQueryData[n.bucketInstanceId].tileID,(this.transform.elevation||t.elevation)&&(t.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[n.bucketInstanceId].tileID,t.tileAnchorX,t.tileAnchorY):0)},U=d.textBox;if(U){j(U);const e=e=>{let i=mu.horizontal;if(n.allowVerticalPlacement&&!e&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[t.crossTileID];e&&(this.placedOrientations[t.crossTileID]=e,i=e,this.markUsedOrientation(n,i,t))}return i},i=(e,i)=>{if(n.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const t of n.writingModes)if(t===mu.vertical?(P=i(),D=P):P=e(),P&&P.box&&P.box.length)break}else P=e()};if(s.get("text-variable-anchor")){let o=s.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[t.crossTileID]){const e=this.prevPlacement.variableOffsets[t.crossTileID];o.indexOf(e.anchor)>0&&(o=o.filter((t=>t!==e.anchor)),o.unshift(e.anchor))}const l=(e,i,s)=>{const l=n.getSymbolInstanceTextSize(f,t,this.transform.zoom,r),c=(e.x2-e.x1)*l+2*e.padding,h=(e.y2-e.y1)*l+2*e.padding,p=T&&!v?i:null;p&&j(p);let d={box:[],offscreen:!1,occluded:!1};const g=x?2*o.length:o.length;for(let i=0;i<g;++i){const g=this.attemptAnchorPlacement(o[i%o.length],e,c,h,l,b,w,u,a,_,i>=o.length,t,r,n,s,p,f,m);if(g&&(d=g.placedGlyphBoxes,d&&d.box&&d.box.length)){E=!0,k=g.shift;break}}return d};i((()=>l(U,d.iconBox,mu.horizontal)),(()=>{const e=d.verticalTextBox;return e&&j(e),n.allowVerticalPlacement&&!(P&&P.box&&P.box.length)&&t.numVerticalGlyphVertices>0&&e?l(e,d.verticalIconBox,mu.vertical):{box:null,offscreen:null,occluded:null}})),P&&(E=P.box,z=P.offscreen,C=P.occluded);const c=e(P&&P.box);if(!E&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[t.crossTileID];e&&(this.variableOffsets[t.crossTileID]=e,this.markUsedJustification(n,e.anchor,t,c))}}else{const s=(e,i)=>{const s=n.getSymbolInstanceTextSize(f,t,this.transform.zoom,r),l=this.collisionIndex.placeCollisionBox(s,e,new o(0,0),x,u,a,_.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(n,i,t),this.placedOrientations[t.crossTileID]=i),l};i((()=>s(U,mu.horizontal)),(()=>{const e=d.verticalTextBox;return n.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&e?(j(e),s(e,mu.vertical)):{box:null,offscreen:null,occluded:null}})),e(P&&P.box&&P.box.length)}}if(B=P,E=B&&B.box&&B.box.length>0,z=B&&B.offscreen,C=B&&B.occluded,t.useRuntimeCollisionCircles){const e=n.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex),r=Fh(n.textSizeData,f,e),o=s.get("text-padding");L=this.collisionIndex.placeCollisionCircles(x,e,n.lineVertexArray,n.glyphOffsetArray,r,a,l,c,i,w,_.predicate,t.collisionCircleDiameter*r/24,o,this.retainedQueryData[n.bucketInstanceId].tileID),E=x||L.circles.length>0&&!L.collisionDetected,z=z&&L.offscreen,C=L.occluded}if(d.iconFeatureIndex&&(V=d.iconFeatureIndex),d.iconBox){const t=t=>{j(t);const e=T&&k?Cm(k.x,k.y,b,w,this.transform.angle):new o(0,0),i=n.getSymbolInstanceIconSize(m,this.transform.zoom,r);return this.collisionIndex.placeCollisionBox(i,t,e,v,u,a,_.predicate)};D&&D.box&&D.box.length&&d.verticalIconBox?(R=t(d.verticalIconBox),A=R.box.length>0):(R=t(d.iconBox),A=R.box.length>0),z=z&&R.offscreen,M=R.occluded}const N=g||0===t.numHorizontalGlyphVertices&&0===t.numVerticalGlyphVertices,Z=y||0===t.numIconVertices;if(N||Z?Z?N||(A=A&&E):E=A&&E:A=E=A&&E,E&&B&&B.box&&this.collisionIndex.insertCollisionBox(B.box,s.get("text-ignore-placement"),n.bucketInstanceId,D&&D.box&&O?O:F,_.ID),A&&R&&this.collisionIndex.insertCollisionBox(R.box,s.get("icon-ignore-placement"),n.bucketInstanceId,V,_.ID),L&&(E&&this.collisionIndex.insertCollisionCircles(L.circles,s.get("text-ignore-placement"),n.bucketInstanceId,F,_.ID),i)){const t=n.bucketInstanceId;let e=this.collisionCircleArrays[t];void 0===e&&(e=this.collisionCircleArrays[t]=new Im);for(let t=0;t<L.circles.length;t+=4)e.circles.push(L.circles[t+0]),e.circles.push(L.circles[t+1]),e.circles.push(L.circles[t+2]),e.circles.push(L.collisionDetected?1:0)}const q="globe"!==this.transform.projection.name;I=I&&(q||!C),S=S&&(q||!M),this.placements[t.crossTileID]=new Em(E||I,A||S,z||n.justReloaded),e[t.crossTileID]=!0};if(E){const t=n.getSortedSymbolIndexes(this.transform.angle);for(let e=t.length-1;e>=0;--e){const i=t[e];A(n.symbolInstances.get(i),i,n.collisionArrays[i])}}else for(let e=t.symbolInstanceStart;e<t.symbolInstanceEnd;e++)A(n.symbolInstances.get(e),e,n.collisionArrays[e]);if(i&&n.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[n.bucketInstanceId];nl(t.invProjMatrix,a),t.viewportMatrix=this.collisionIndex.getViewportMatrix()}n.justReloaded=!1}markUsedJustification(t,e,i,r){let n;n=r===mu.vertical?i.verticalPlacedTextSymbolIndex:{left:i.leftJustifiedTextSymbolIndex,center:i.centerJustifiedTextSymbolIndex,right:i.rightJustifiedTextSymbolIndex}[function(t){switch(t){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}(e)];const s=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex,i.verticalPlacedTextSymbolIndex];for(const e of s)e>=0&&(t.text.placedSymbolArray.get(e).crossTileID=n>=0&&e!==n?0:i.crossTileID)}markUsedOrientation(t,e,i){const r=e===mu.horizontal||e===mu.horizontalOnly?e:0,n=e===mu.vertical?e:0,s=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex];for(const e of s)t.text.placedSymbolArray.get(e).placedOrientation=r;i.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(i.verticalPlacedTextSymbolIndex).placedOrientation=n)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const e=this.prevPlacement;let i=!1;this.prevZoomAdjustment=e?e.zoomAdjustment(this.transform.zoom):0;const r=e?e.symbolFadeChange(t):1,n=e?e.opacities:{},s=e?e.variableOffsets:{},o=e?e.placedOrientations:{};for(const t in this.placements){const e=this.placements[t],s=n[t];s?(this.opacities[t]=new Tm(s,r,e.text,e.icon,null,e.clipped),i=i||e.text!==s.text.placed||e.icon!==s.icon.placed):(this.opacities[t]=new Tm(null,r,e.text,e.icon,e.skipFade,e.clipped),i=i||e.text||e.icon)}for(const t in n){const e=n[t];if(!this.opacities[t]){const n=new Tm(e,r,!1,!1);n.isHidden()||(this.opacities[t]=n,i=i||e.text.placed||e.icon.placed)}}for(const t in s)this.variableOffsets[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.variableOffsets[t]=s[t]);for(const t in o)this.placedOrientations[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.placedOrientations[t]=o[t]);i?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=e?e.lastPlacementChangeTime:t)}updateLayerOpacities(t,e){const i={};for(const r of e){const e=r.getBucket(t);e&&r.latestFeatureIndex&&t.id===e.layerIds[0]&&this.updateBucketOpacities(e,i,r.collisionBoxArray)}}updateBucketOpacities(t,e,i){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const r=t.layers[0].layout,n=!!t.layers[0].dynamicFilter(),s=new Tm(null,0,!1,!1,!0),a=r.get("text-allow-overlap"),l=r.get("icon-allow-overlap"),c=r.get("text-variable-anchor"),h="map"===r.get("text-rotation-alignment"),u="map"===r.get("text-pitch-alignment"),p="none"!==r.get("icon-text-fit"),d=new Tm(null,0,a&&(l||!t.hasIconData()||r.get("icon-optional")),l&&(a||!t.hasTextData()||r.get("text-optional")),!0);!t.collisionArrays&&i&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(i);const f=(t,e,i)=>{for(let r=0;r<e/4;r++)t.opacityVertexArray.emplaceBack(i)};let m=0;for(let i=0;i<t.symbolInstances.length;i++){const r=t.symbolInstances.get(i),{numHorizontalGlyphVertices:a,numVerticalGlyphVertices:l,crossTileID:_}=r;let g=this.opacities[_];e[_]?g=s:g||(g=d,this.opacities[_]=g),e[_]=!0;const y=a>0||l>0,x=r.numIconVertices>0,v=this.placedOrientations[r.crossTileID],b=v===mu.vertical,w=v===mu.horizontal||v===mu.horizontalOnly;if(!y&&!x||g.isHidden()||m++,y){const e=Vm(g.text);f(t.text,a,b?jm:e),f(t.text,l,w?jm:e);const i=g.text.isHidden();[r.rightJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.leftJustifiedTextSymbolIndex].forEach((e=>{e>=0&&(t.text.placedSymbolArray.get(e).hidden=i||b?1:0)})),r.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).hidden=i||w?1:0);const n=this.variableOffsets[r.crossTileID];n&&this.markUsedJustification(t,n.anchor,r,v);const s=this.placedOrientations[r.crossTileID];s&&(this.markUsedJustification(t,"left",r,s),this.markUsedOrientation(t,s,r))}if(x){const e=Vm(g.icon);r.placedIconSymbolIndex>=0&&(f(t.icon,r.numIconVertices,b?jm:e),t.icon.placedSymbolArray.get(r.placedIconSymbolIndex).hidden=g.icon.isHidden()),r.verticalPlacedIconSymbolIndex>=0&&(f(t.icon,r.numVerticalIconVertices,w?jm:e),t.icon.placedSymbolArray.get(r.verticalPlacedIconSymbolIndex).hidden=g.icon.isHidden())}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const e=t.collisionArrays[i];if(e){let i=new o(0,0),r=!0;if(e.textBox||e.verticalTextBox){if(c){const t=this.variableOffsets[_];t?(i=zm(t.anchor,t.width,t.height,t.textOffset,t.textScale),h&&i._rotate(u?this.transform.angle:-this.transform.angle)):r=!1}n&&(r=!g.clipped),e.textBox&&km(t.textCollisionBox.collisionVertexArray,g.text.placed,!r||b,i.x,i.y),e.verticalTextBox&&km(t.textCollisionBox.collisionVertexArray,g.text.placed,!r||w,i.x,i.y)}const s=r&&Boolean(!w&&e.verticalIconBox);e.iconBox&&km(t.iconCollisionBox.collisionVertexArray,g.icon.placed,s,p?i.x:0,p?i.y:0),e.verticalIconBox&&km(t.iconCollisionBox.collisionVertexArray,g.icon.placed,!s,p?i.x:0,p?i.y:0)}}}if(t.fullyClipped=0===m,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(t){return 0===this.fadeDuration?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(t,e){const i=this.zoomAtLastRecencyCheck===e?1-this.zoomAdjustment(e):1;return this.zoomAtLastRecencyCheck=e,this.commitTime+this.fadeDuration*i>t}setStale(){this.stale=!0}}function km(t,e,i,r,n){t.emplaceBack(e?1:0,i?1:0,r||0,n||0),t.emplaceBack(e?1:0,i?1:0,r||0,n||0),t.emplaceBack(e?1:0,i?1:0,r||0,n||0),t.emplaceBack(e?1:0,i?1:0,r||0,n||0)}const Pm=Math.pow(2,25),Dm=Math.pow(2,24),Bm=Math.pow(2,17),Lm=Math.pow(2,16),Rm=Math.pow(2,9),Fm=Math.pow(2,8),Om=Math.pow(2,1);function Vm(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;const e=t.placed?1:0,i=Math.floor(127*t.opacity);return i*Pm+e*Dm+i*Bm+e*Lm+i*Rm+e*Fm+i*Om+e}const jm=0;class Um{constructor(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&void 0!==t.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,e,i,r,n){const s=this._bucketParts;for(;this._currentTileIndex<t.length;)if(e.getBucketParts(s,r,t[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,n())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,s.sort(((t,e)=>t.sortKey-e.sortKey)));this._currentPartIndex<s.length;){const t=s[this._currentPartIndex];if(e.placeLayerBucketPart(t,this._seenCrossTileIDs,i,0===t.symbolInstanceStart),this._currentPartIndex++,n())return!0}return!1}}class Nm{constructor(t,e,i,r,n,s,o,a){this.placement=new Mm(t,n,s,o,a),this._currentPlacementIndex=e.length-1,this._forceFullPlacement=i,this._showCollisionBoxes=r,this._done=!1}isDone(){return this._done}continuePlacement(t,e,i){const r=J.now(),n=()=>{const t=J.now()-r;return!this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const r=e[t[this._currentPlacementIndex]],s=this.placement.collisionIndex.transform.zoom;if("symbol"===r.type&&(!r.minzoom||r.minzoom<=s)&&(!r.maxzoom||r.maxzoom>s)){if(this._inProgressLayer||(this._inProgressLayer=new Um(r)),this._inProgressLayer.continuePlacement(i[r.source],this.placement,this._showCollisionBoxes,r,n))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}class Zm{constructor(t,e,i){this.tileID=t,this.indexedSymbolInstances={},this.bucketInstanceId=i;for(let i=0;i<e.length;i++){const r=e.get(i),n=r.key;this.indexedSymbolInstances[n]||(this.indexedSymbolInstances[n]=[]),this.indexedSymbolInstances[n].push({crossTileID:r.crossTileID,coord:this.getScaledCoordinates(r,t)})}}getScaledCoordinates(t,e){const i=.03125/Math.pow(2,e.canonical.z-this.tileID.canonical.z);return{x:Math.floor((e.canonical.x*la+t.tileAnchorX)*i),y:Math.floor((e.canonical.y*la+t.tileAnchorY)*i)}}findMatches(t,e,i){const r=this.tileID.canonical.z<e.canonical.z?1:Math.pow(2,this.tileID.canonical.z-e.canonical.z);for(let n=0;n<t.length;n++){const s=t.get(n);if(s.crossTileID)continue;const o=this.indexedSymbolInstances[s.key];if(!o)continue;const a=this.getScaledCoordinates(s,e);for(const t of o)if(Math.abs(t.coord.x-a.x)<=r&&Math.abs(t.coord.y-a.y)<=r&&!i[t.crossTileID]){i[t.crossTileID]=!0,s.crossTileID=t.crossTileID;break}}}}class qm{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Gm{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const e=Math.round((t-this.lng)/360);if(0!==e)for(const t in this.indexes){const i=this.indexes[t],r={};for(const t in i){const n=i[t];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),r[n.tileID.key]=n}this.indexes[t]=r}this.lng=t}addBucket(t,e,i){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===e.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let t=0;t<e.symbolInstances.length;t++)e.symbolInstances.get(t).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||(this.usedCrossTileIDs[t.overscaledZ]={});const r=this.usedCrossTileIDs[t.overscaledZ];for(const i in this.indexes){const n=this.indexes[i];if(Number(i)>t.overscaledZ)for(const i in n){const s=n[i];s.tileID.isChildOf(t)&&s.findMatches(e.symbolInstances,t,r)}else{const s=n[t.scaledTo(Number(i)).key];s&&s.findMatches(e.symbolInstances,t,r)}}for(let t=0;t<e.symbolInstances.length;t++){const n=e.symbolInstances.get(t);n.crossTileID||(n.crossTileID=i.generate(),r[n.crossTileID]=!0)}return void 0===this.indexes[t.overscaledZ]&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new Zm(t,e.symbolInstances,e.bucketInstanceId),!0}removeBucketCrossTileIDs(t,e){for(const i in e.indexedSymbolInstances)for(const r of e.indexedSymbolInstances[i])delete this.usedCrossTileIDs[t][r.crossTileID]}removeStaleBuckets(t){let e=!1;for(const i in this.indexes){const r=this.indexes[i];for(const n in r)t[r[n].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,r[n]),delete r[n],e=!0)}return e}}class $m{constructor(){this.layerIndexes={},this.crossTileIDs=new qm,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,e,i,r){let n=this.layerIndexes[t.id];void 0===n&&(n=this.layerIndexes[t.id]=new Gm);let s=!1;const o={};"globe"!==r.name&&n.handleWrapJump(i);for(const i of e){const e=i.getBucket(t);e&&t.id===e.layerIds[0]&&(e.bucketInstanceId||(e.bucketInstanceId=++this.maxBucketInstanceId),n.addBucket(i.tileID,e,this.crossTileIDs)&&(s=!0),o[e.bucketInstanceId]=!0)}return n.removeStaleBuckets(o)&&(s=!0),s}pruneUnusedLayers(t){const e={};t.forEach((t=>{e[t]=!0}));for(const t in this.layerIndexes)e[t]||delete this.layerIndexes[t]}}const Wm=(t,e)=>Dn(t,e&&e.filter((t=>"source.canvas"!==t.identifier))),Xm=S(Wf,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Hm=S(Wf,["setCenter","setZoom","setBearing","setPitch"]),Km={version:8,layers:[],sources:{}},Ym={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class Jm extends he{constructor(t,e={}){super(),this.map=t,this.dispatcher=new ap(Zf(),this),this.imageManager=new $u,this.imageManager.setEventedParent(this),this.glyphManager=new bu(t._requestManager,e.localFontFamily?2:e.localIdeographFontFamily?1:0,e.localFontFamily||e.localIdeographFontFamily),this.lineAtlas=new np(256,512),this.crossTileSymbolIndex=new $m,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new Nn,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",Ht());const i=this;this._rtlTextPluginCallback=Jm.registerForPluginStateChange((t=>{i.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},((t,e)=>{if(ss(t),e&&e.every((t=>t)))for(const t in i._sourceCaches){const e=i._sourceCaches[t],r=e.getSource().type;"vector"!==r&&"geojson"!==r||e.reload()}}))})),this.on("data",(t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;const e=this.getSource(t.sourceId);if(e&&e.vectorLayerIds)for(const t in this._layers){const i=this._layers[t];i.source===e.id&&this._validateLayer(i)}}))}loadURL(t,e={}){this.fire(new le("dataloading",{dataType:"style"}));const i="boolean"==typeof e.validate?e.validate:!Tt(t);t=this.map._requestManager.normalizeStyleURL(t,e.accessToken);const r=this.map._requestManager.transformRequest(t,Wt.Style);this._request=Yt(r,((t,e)=>{this._request=null,t?this.fire(new ce(t)):e&&this._load(e,i)}))}loadJSON(t,e={}){this.fire(new le("dataloading",{dataType:"style"})),this._request=J.frame((()=>{this._request=null,this._load(t,!1!==e.validate)}))}loadEmpty(){this.fire(new le("dataloading",{dataType:"style"})),this._load(Km,!1)}_updateLayerCount(t,e){const i=e?1:-1;t.is3D()&&(this._num3DLayers+=i),"circle"===t.type&&(this._numCircleLayers+=i),"symbol"===t.type&&(this._numSymbolLayers+=i)}_load(t,e){if(e&&Wm(this,Tn(t)))return;this._loaded=!0,this.stylesheet=t,this._updateProjection();for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1});this._changed=!1,t.sprite?this._loadSprite(t.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(t.glyphs);const i=$f(this.stylesheet.layers);this._order=i.map((t=>t.id)),this._layers={},this._serializedLayers={};for(let t of i)t=Zu(t),t.setEventedParent(this,{layer:{id:t.id}}),this._layers[t.id]=t,this._serializedLayers[t.id]=t.serialize(),this._updateLayerCount(t,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new Hu(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 le("data",{dataType:"style"})),this.fire(new le("style.load"))}terrainSetForDrapingOnly(){return this.terrain&&0===this.terrain.drapeRenderMode}setProjection(t){t?this.stylesheet.projection=t:delete this.stylesheet.projection,this.map._explicitProjection||this.map._updateProjection()}_updateProjection(){this.map._explicitProjection?this.enableDraping():this.map._updateProjection()}enableDraping(){this._loaded&&(this.map.transform.projection.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null))}_loadSprite(t){this._spriteRequest=function(t,e,i){let r,n,s;const o=J.devicePixelRatio>1?"@2x":"";let a=Yt(e.transformRequest(e.normalizeSpriteURL(t,o,".json"),Wt.SpriteJSON),((t,e)=>{a=null,s||(s=t,r=e,c())})),l=se(e.transformRequest(e.normalizeSpriteURL(t,o,".png"),Wt.SpriteImage),((t,e)=>{l=null,s||(s=t,n=e,c())}));function c(){if(s)i(s);else if(r&&n){const t=J.getImageData(n),e={};for(const i in r){const{width:n,height:s,x:o,y:a,sdf:l,pixelRatio:c,stretchX:h,stretchY:u,content:p}=r[i],d=new ec({width:n,height:s});ec.copy(t,d,{x:o,y:a},{x:0,y:0},{width:n,height:s}),e[i]={data:d,pixelRatio:c,sdf:l,stretchX:h,stretchY:u,content:p}}i(null,e)}}return{cancel(){a&&(a.cancel(),a=null),l&&(l.cancel(),l=null)}}}(t,this.map._requestManager,((t,e)=>{if(this._spriteRequest=null,t)this.fire(new ce(t));else if(e)for(const t in e)this.imageManager.addImage(t,e[t]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new le("data",{dataType:"style"}))}))}_validateLayer(t){const e=this.getSource(t.source);if(!e)return;const i=t.sourceLayer;i&&("geojson"===e.type||e.vectorLayerIds&&-1===e.vectorLayerIds.indexOf(i))&&this.fire(new ce(new Error(`Source layer "${i}" does not exist on source "${e.id}" as specified by style layer "${t.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const t in this._sourceCaches)if(!this._sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(t){const e=[];for(const i of t){const t=this._layers[i];"custom"!==t.type&&e.push(t.serialize())}return e}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;if(this.fog&&this.fog.hasTransition())return!0;for(const t in this._sourceCaches)if(this._sourceCaches[t].hasTransition())return!0;for(const t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(t){return!!this.terrain&&Ym[t.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(t){if(!this._loaded)return;const e=this._changed;if(this._changed){const e=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(e.length||i.length)&&this._updateWorkerLayers(e,i);for(const t in this._updatedSources){const e=this._updatedSources[t];"reload"===e?this._reloadSource(t):"clear"===e&&this._clearSource(t)}this._updateTilesForChangedImages();for(const e in this._updatedPaintProps)this._layers[e].updateTransitions(t);this.light.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this._resetUpdates()}const i={};for(const t in this._sourceCaches){const e=this._sourceCaches[t];i[t]=e.used,e.used=!1}for(const e of this._order){const i=this._layers[e];if(i.recalculate(t,this._availableImages),!i.isHidden(t.zoom)){const t=this._getLayerSourceCache(i);t&&(t.used=!0)}const r=this.map.painter;if(r){const e=i.getProgramIds();if(!e)continue;const n=i.getProgramConfiguration(t.zoom);for(const t of e)r.useProgram(t,n)}}for(const t in i){const e=this._sourceCaches[t];i[t]!==e.used&&e.getSource().fire(new le("data",{sourceDataType:"visibility",dataType:"source",sourceId:e.getSource().id}))}this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),e&&this.fire(new le("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const e in this._sourceCaches)this._sourceCaches[e].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateWorkerLayers(t,e){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(t),removedIds:e})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(t){if(this._checkLoaded(),Wm(this,Tn(t)))return!1;(t=R(t)).layers=$f(t.layers);const e=function(t,e){if(!t)return[{command:Wf.setStyle,args:[e]}];let i=[];try{if(!c(t.version,e.version))return[{command:Wf.setStyle,args:[e]}];c(t.center,e.center)||i.push({command:Wf.setCenter,args:[e.center]}),c(t.zoom,e.zoom)||i.push({command:Wf.setZoom,args:[e.zoom]}),c(t.bearing,e.bearing)||i.push({command:Wf.setBearing,args:[e.bearing]}),c(t.pitch,e.pitch)||i.push({command:Wf.setPitch,args:[e.pitch]}),c(t.sprite,e.sprite)||i.push({command:Wf.setSprite,args:[e.sprite]}),c(t.glyphs,e.glyphs)||i.push({command:Wf.setGlyphs,args:[e.glyphs]}),c(t.transition,e.transition)||i.push({command:Wf.setTransition,args:[e.transition]}),c(t.light,e.light)||i.push({command:Wf.setLight,args:[e.light]}),c(t.fog,e.fog)||i.push({command:Wf.setFog,args:[e.fog]}),c(t.projection,e.projection)||i.push({command:Wf.setProjection,args:[e.projection]});const r={},n=[];!function(t,e,i,r){let n;for(n in e=e||{},t=t||{})t.hasOwnProperty(n)&&(e.hasOwnProperty(n)||Hf(n,i,r));for(n in e)e.hasOwnProperty(n)&&(t.hasOwnProperty(n)?c(t[n],e[n])||("geojson"===t[n].type&&"geojson"===e[n].type&&Yf(t,e,n)?i.push({command:Wf.setGeoJSONSourceData,args:[n,e[n].data]}):Kf(n,e,i,r)):Xf(n,e,i))}(t.sources,e.sources,n,r);const s=[];t.layers&&t.layers.forEach((t=>{t.source&&r[t.source]?i.push({command:Wf.removeLayer,args:[t.id]}):s.push(t)}));let o=t.terrain;o&&r[o.source]&&(i.push({command:Wf.setTerrain,args:[void 0]}),o=void 0),i=i.concat(n),c(o,e.terrain)||i.push({command:Wf.setTerrain,args:[e.terrain]}),function(t,e,i){e=e||[];const r=(t=t||[]).map(Qf),n=e.map(Qf),s=t.reduce(tm,{}),o=e.reduce(tm,{}),a=r.slice(),l=Object.create(null);let h,u,p,d,f,m,_;for(h=0,u=0;h<r.length;h++)p=r[h],o.hasOwnProperty(p)?u++:(i.push({command:Wf.removeLayer,args:[p]}),a.splice(a.indexOf(p,u),1));for(h=0,u=0;h<n.length;h++)p=n[n.length-1-h],a[a.length-1-h]!==p&&(s.hasOwnProperty(p)?(i.push({command:Wf.removeLayer,args:[p]}),a.splice(a.lastIndexOf(p,a.length-u),1)):u++,m=a[a.length-h],i.push({command:Wf.addLayer,args:[o[p],m]}),a.splice(a.length-h,0,p),l[p]=!0);for(h=0;h<n.length;h++)if(p=n[h],d=s[p],f=o[p],!l[p]&&!c(d,f))if(c(d.source,f.source)&&c(d["source-layer"],f["source-layer"])&&c(d.type,f.type)){for(_ in Jf(d.layout,f.layout,i,p,null,Wf.setLayoutProperty),Jf(d.paint,f.paint,i,p,null,Wf.setPaintProperty),c(d.filter,f.filter)||i.push({command:Wf.setFilter,args:[p,f.filter]}),c(d.minzoom,f.minzoom)&&c(d.maxzoom,f.maxzoom)||i.push({command:Wf.setLayerZoomRange,args:[p,f.minzoom,f.maxzoom]}),d)d.hasOwnProperty(_)&&"layout"!==_&&"paint"!==_&&"filter"!==_&&"metadata"!==_&&"minzoom"!==_&&"maxzoom"!==_&&(0===_.indexOf("paint.")?Jf(d[_],f[_],i,p,_.slice(6),Wf.setPaintProperty):c(d[_],f[_])||i.push({command:Wf.setLayerProperty,args:[p,_,f[_]]}));for(_ in f)f.hasOwnProperty(_)&&!d.hasOwnProperty(_)&&"layout"!==_&&"paint"!==_&&"filter"!==_&&"metadata"!==_&&"minzoom"!==_&&"maxzoom"!==_&&(0===_.indexOf("paint.")?Jf(d[_],f[_],i,p,_.slice(6),Wf.setPaintProperty):c(d[_],f[_])||i.push({command:Wf.setLayerProperty,args:[p,_,f[_]]}))}else i.push({command:Wf.removeLayer,args:[p]}),m=a[a.lastIndexOf(p)+1],i.push({command:Wf.addLayer,args:[f,m]})}(s,e.layers,i)}catch(t){console.warn("Unable to compute style diff:",t),i=[{command:Wf.setStyle,args:[e]}]}return i}(this.serialize(),t).filter((t=>!(t.command in Hm)));if(0===e.length)return!1;const i=e.filter((t=>!(t.command in Xm)));if(i.length>0)throw new Error(`Unimplemented: ${i.map((t=>t.command)).join(", ")}.`);return e.forEach((t=>{"setTransition"!==t.command&&this[t.command].apply(this,t.args)})),this.stylesheet=t,this._updateProjection(),!0}addImage(t,e){if(this.getImage(t))return this.fire(new ce(new Error("An image with this name already exists.")));this.imageManager.addImage(t,e),this._afterImageUpdated(t)}updateImage(t,e){this.imageManager.updateImage(t,e)}getImage(t){return this.imageManager.getImage(t)}removeImage(t){if(!this.getImage(t))return this.fire(new ce(new Error("No image with this name exists.")));this.imageManager.removeImage(t),this._afterImageUpdated(t)}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new le("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(t,e,i={}){if(this._checkLoaded(),void 0!==this.getSource(t))throw new Error("There is already a source with this ID");if(!e.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(e).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(e.type)>=0&&this._validate(En,`sources.${t}`,e,null,i))return;this.map&&this.map._collectResourceTiming&&(e.collectResourceTiming=!0);const r=Bf(t,e,this.dispatcher,this);r.setEventedParent(this,(()=>({isSourceLoaded:this._isSourceCacheLoaded(t),source:r.serialize(),sourceId:t})));const n=e=>{const i=(e?"symbol:":"other:")+t,n=this._sourceCaches[i]=new bf(i,r,e);(e?this._symbolSourceCaches:this._otherSourceCaches)[t]=n,n.style=this,n.onAdd(this.map)};n(!1),"vector"!==e.type&&"geojson"!==e.type||n(!0),r.onAdd&&r.onAdd(this.map),this._changed=!0}removeSource(t){this._checkLoaded();const e=this.getSource(t);if(void 0===e)throw new Error("There is no source with this ID");for(const e in this._layers)if(this._layers[e].source===t)return this.fire(new ce(new Error(`Source "${t}" cannot be removed while layer "${e}" is using it.`)));if(this.terrain&&this.terrain.get().source===t)return this.fire(new ce(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));const i=this._getSourceCaches(t);for(const t of i)delete this._sourceCaches[t.id],delete this._updatedSources[t.id],t.fire(new le("data",{sourceDataType:"metadata",dataType:"source",sourceId:t.getSource().id})),t.setEventedParent(null),t.clearTiles();delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],e.setEventedParent(null),e.onRemove&&e.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,e){this._checkLoaded(),this.getSource(t).setData(e),this._changed=!0}getSource(t){const e=this._getSourceCache(t);return e&&e.getSource()}addLayer(t,e,i={}){this._checkLoaded();const r=t.id;if(this.getLayer(r))return void this.fire(new ce(new Error(`Layer with id "${r}" already exists on this map`)));let n;if("custom"===t.type){if(Wm(this,function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e}(t)))return;n=Zu(t)}else{if("object"==typeof t.source&&(this.addSource(r,t.source),t=I(t=R(t),{source:r})),this._validate(zn,`layers.${r}`,t,{arrayIndex:-1},i))return;n=Zu(t),this._validateLayer(n),n.setEventedParent(this,{layer:{id:r}}),this._serializedLayers[n.id]=n.serialize(),this._updateLayerCount(n,!0)}const s=e?this._order.indexOf(e):this._order.length;if(e&&-1===s)return void this.fire(new ce(new Error(`Layer with id "${e}" does not exist on this map.`)));this._order.splice(s,0,r),this._layerOrderChanged=!0,this._layers[r]=n;const o=this._getLayerSourceCache(n);if(this._removedLayers[r]&&n.source&&o&&"custom"!==n.type){const t=this._removedLayers[r];delete this._removedLayers[r],t.type!==n.type?this._updatedSources[n.source]="clear":(this._updatedSources[n.source]="reload",o.pause())}this._updateLayer(n),n.onAdd&&n.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(t,e){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new ce(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===e)return;const i=this._order.indexOf(t);this._order.splice(i,1);const r=e?this._order.indexOf(e):this._order.length;e&&-1===r?this.fire(new ce(new Error(`Layer with id "${e}" does not exist on this map.`))):(this._order.splice(r,0,t),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(t){this._checkLoaded();const e=this._layers[t];if(!e)return void this.fire(new ce(new Error(`The layer '${t}' does not exist in the map's style and cannot be removed.`)));e.setEventedParent(null),this._updateLayerCount(e,!1);const i=this._order.indexOf(t);this._order.splice(i,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=e,delete this._layers[t],delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],e.onRemove&&e.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(t){return this._layers[t]}hasLayer(t){return t in this._layers}hasLayerType(t){for(const e in this._layers)if(this._layers[e].type===t)return!0;return!1}setLayerZoomRange(t,e,i){this._checkLoaded();const r=this.getLayer(t);r?r.minzoom===e&&r.maxzoom===i||(null!=e&&(r.minzoom=e),null!=i&&(r.maxzoom=i),this._updateLayer(r)):this.fire(new ce(new Error(`The layer '${t}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(t,e,i={}){this._checkLoaded();const r=this.getLayer(t);if(r){if(!c(r.filter,e))return null==e?(r.filter=void 0,void this._updateLayer(r)):void(this._validate(Cn,`layers.${r.id}.filter`,e,{layerType:r.type},i)||(r.filter=R(e),this._updateLayer(r)))}else this.fire(new ce(new Error(`The layer '${t}' does not exist in the map's style and cannot be filtered.`)))}getFilter(t){return R(this.getLayer(t).filter)}setLayoutProperty(t,e,i,r={}){this._checkLoaded();const n=this.getLayer(t);n?c(n.getLayoutProperty(e),i)||(n.setLayoutProperty(e,i,r),this._updateLayer(n)):this.fire(new ce(new Error(`The layer '${t}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(t,e){const i=this.getLayer(t);if(i)return i.getLayoutProperty(e);this.fire(new ce(new Error(`The layer '${t}' does not exist in the map's style.`)))}setPaintProperty(t,e,i,r={}){this._checkLoaded();const n=this.getLayer(t);n?c(n.getPaintProperty(e),i)||(n.setPaintProperty(e,i,r)&&this._updateLayer(n),this._changed=!0,this._updatedPaintProps[t]=!0):this.fire(new ce(new Error(`The layer '${t}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(t,e){return this.getLayer(t).getPaintProperty(e)}setFeatureState(t,e){this._checkLoaded();const i=t.source,r=t.sourceLayer,n=this.getSource(i);if(void 0===n)return void this.fire(new ce(new Error(`The source '${i}' does not exist in the map's style.`)));const s=n.type;if("geojson"===s&&r)return void this.fire(new ce(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!r)return void this.fire(new ce(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new ce(new Error("The feature id parameter must be provided.")));const o=this._getSourceCaches(i);for(const i of o)i.setFeatureState(r,t.id,e)}removeFeatureState(t,e){this._checkLoaded();const i=t.source,r=this.getSource(i);if(void 0===r)return void this.fire(new ce(new Error(`The source '${i}' does not exist in the map's style.`)));const n=r.type,s="vector"===n?t.sourceLayer:void 0;if("vector"===n&&!s)return void this.fire(new ce(new Error("The sourceLayer parameter must be provided for vector source types.")));if(e&&"string"!=typeof t.id&&"number"!=typeof t.id)return void this.fire(new ce(new Error("A feature id is required to remove its specific state property.")));const o=this._getSourceCaches(i);for(const i of o)i.removeFeatureState(s,t.id,e)}getFeatureState(t){this._checkLoaded();const e=t.source,i=t.sourceLayer,r=this.getSource(e);if(void 0!==r){if("vector"!==r.type||i)return void 0===t.id&&this.fire(new ce(new Error("The feature id parameter must be provided."))),this._getSourceCaches(e)[0].getFeatureState(i,t.id);this.fire(new ce(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new ce(new Error(`The source '${e}' does not exist in the map's style.`)))}getTransition(){return I({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const t={};for(const e in this._sourceCaches){const i=this._sourceCaches[e].getSource();t[i.id]||(t[i.id]=i.serialize())}return L({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:t,layers:this._serializeLayers(this._order)},(t=>void 0!==t))}_updateLayer(t){this._updatedLayers[t.id]=!0;const e=this._getLayerSourceCache(t);t.source&&!this._updatedSources[t.source]&&e&&"raster"!==e.getSource().type&&(this._updatedSources[t.source]="reload",e.pause()),this._changed=!0,t.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(t){const e=t=>"fill-extrusion"===this._layers[t].type,i={},r=[];for(let n=this._order.length-1;n>=0;n--){const s=this._order[n];if(e(s)){i[s]=n;for(const e of t){const t=e[s];if(t)for(const e of t)r.push(e)}}}r.sort(((t,e)=>e.intersectionZ-t.intersectionZ));const n=[];for(let s=this._order.length-1;s>=0;s--){const o=this._order[s];if(e(o))for(let t=r.length-1;t>=0;t--){const e=r[t].feature;if(i[e.layer.id]<s)break;n.push(e),r.pop()}else for(const e of t){const t=e[o];if(t)for(const e of t)n.push(e.feature)}}return n}queryRenderedFeatures(t,e,i){e&&e.filter&&this._validate(Cn,"queryRenderedFeatures.filter",e.filter,null,e);const r={};if(e&&e.layers){if(!Array.isArray(e.layers))return this.fire(new ce(new Error("parameters.layers must be an Array."))),[];for(const t of e.layers){const e=this._layers[t];if(!e)return this.fire(new ce(new Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];r[e.source]=!0}}const n=[];e.availableImages=this._availableImages;const s=e&&e.layers?e.layers.some((t=>{const e=this.getLayer(t);return e&&e.is3D()})):this.has3DLayers(),o=Hp.createFromScreenPoints(t,i);for(const t in this._sourceCaches){const a=this._sourceCaches[t].getSource().id;e.layers&&!r[a]||n.push(Rf(this._sourceCaches[t],this._layers,this._serializedLayers,o,e,i,s,!!this.map._showQueryGeometry))}return this.placement&&n.push(function(t,e,i,r,n,s,o){const a={},l=s.queryRenderedSymbols(r),c=[];for(const t of Object.keys(l).map(Number))c.push(o[t]);c.sort(Of);for(const i of c){const r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],e,i.bucketIndex,i.sourceLayerIndex,n.filter,n.layers,n.availableImages,t);for(const t in r){const e=a[t]=a[t]||[],n=r[t];n.sort(((t,e)=>{const r=i.featureSortOrder;if(r){const i=r.indexOf(t.featureIndex);return r.indexOf(e.featureIndex)-i}return e.featureIndex-t.featureIndex}));for(const t of n)e.push(t)}}for(const e in a)a[e].forEach((r=>{const n=r.feature,s=i(t[e]).getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=s}));return a}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),o.screenGeometry,e,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(n)}querySourceFeatures(t,e){e&&e.filter&&this._validate(Cn,"querySourceFeatures.filter",e.filter,null,e);const i=this._getSourceCaches(t);let r=[];for(const t of i)r=r.concat(Ff(t,e));return r}addSourceType(t,e,i){return Jm.getSourceType(t)?i(new Error(`A source type called "${t}" already exists.`)):(Jm.setSourceType(t,e),e.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:t,url:e.workerSourceURL},i):i(null,null))}getLight(){return this.light.getLight()}setLight(t,e={}){this._checkLoaded();const i=this.light.getLight();let r=!1;for(const e in t)if(!c(t[e],i[e])){r=!0;break}if(!r)return;const n={now:J.now(),transition:I({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,e),this.light.updateTransitions(n)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(t,e=1){if(this._checkLoaded(),!t)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(1===e){if("object"==typeof t.source){const e="terrain-dem-src";this.addSource(e,t.source),t=I(t=R(t),{source:e})}if(this._validate(Sn,"terrain",t))return}if(!this.terrain||this.terrain&&e!==this.terrain.drapeRenderMode)this._createTerrain(t,e);else{const e=this.terrain,i=e.get();for(const r in t)if(!c(t[r],i[r])){e.set(t),this.stylesheet.terrain=t;const i={now:J.now(),transition:I({duration:0},this.stylesheet.transition)};e.updateTransitions(i);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(t){const e=this.fog=new rp(t,this.map.transform);this.stylesheet.fog=t;const i={now:J.now(),transition:I({duration:0},this.stylesheet.transition)};e.updateTransitions(i)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask((()=>{for(const t of this.map._markers)t._evaluateOpacity()}))}getFog(){return this.fog?this.fog.get():null}setFog(t){if(this._checkLoaded(),!t)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const e=this.fog,i=e.get();for(const r in t)if(!c(t[r],i[r])){e.set(t),this.stylesheet.fog=t;const i={now:J.now(),transition:I({duration:0},this.stylesheet.transition)};e.updateTransitions(i);break}}else this._createFog(t);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const t=this._order.filter((t=>this.isLayerDraped(this._layers[t]))),e=this._order.filter((t=>!this.isLayerDraped(this._layers[t])));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...t),this._drapedFirstOrder.push(...e)}_createTerrain(t,e){const i=this.terrain=new Ju(t,e);this.stylesheet.terrain=t,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const r={now:J.now(),transition:I({duration:0},this.stylesheet.transition)};i.updateTransitions(r)}_force3DLayerUpdate(){for(const t in this._layers){const e=this._layers[t];"fill-extrusion"===e.type&&this._updateLayer(e)}}_forceSymbolLayerUpdate(){for(const t in this._layers){const e=this._layers[t];"symbol"===e.type&&this._updateLayer(e)}}_validate(t,e,i,r,n={}){return(!n||!1!==n.validate)&&Wm(this,t.call(Tn,I({key:e,style:this.serialize(),value:i,styleSpec:ue},r)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),as.off("pluginStateChange",this._rtlTextPluginCallback);for(const t in this._layers)this._layers[t].setEventedParent(null);for(const t in this._sourceCaches)this._sourceCaches[t].clearTiles(),this._sourceCaches[t].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(t){const e=this._getSourceCaches(t);for(const t of e)t.clearTiles()}_reloadSource(t){const e=this._getSourceCaches(t);for(const t of e)t.resume(),t.reload()}_updateSources(t){for(const e in this._sourceCaches)this._sourceCaches[e].update(t)}_generateCollisionBoxes(){for(const t in this._sourceCaches){const e=this._sourceCaches[t];e.resume(),e.reload()}}_updatePlacement(t,e,i,r,n=!1){let s=!1,o=!1;const a={};for(const e of this._order){const i=this._layers[e];if("symbol"!==i.type)continue;if(!a[i.source]){const t=this._getLayerSourceCache(i);if(!t)continue;a[i.source]=t.getRenderableIds(!0).map((e=>t.getTileByID(e))).sort(((t,e)=>e.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(e.tileID)?-1:1)))}const r=this.crossTileSymbolIndex.addLayer(i,a[i.source],t.center.lng,t.projection);s=s||r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),n=n||this._layerOrderChanged||0===i,this._layerOrderChanged&&this.fire(new le("neworder")),(n||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(J.now(),t.zoom))&&(this.pauseablePlacement=new Nm(t,this._order,n,e,i,r,this.placement,this.fog&&t.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,a),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(J.now()),o=!0),s&&this.pauseablePlacement.placement.setStale()),o||s)for(const t of this._order){const e=this._layers[t];"symbol"===e.type&&this.placement.updateLayerOpacities(e,a[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(J.now())}_releaseSymbolFadeTiles(){for(const t in this._sourceCaches)this._sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,e,i){this.imageManager.getImages(e.icons,i),this._updateTilesForChangedImages();const r=t=>{t&&t.setDependencies(e.tileID.key,e.type,e.icons)};r(this._otherSourceCaches[e.source]),r(this._symbolSourceCaches[e.source])}getGlyphs(t,e,i){this.glyphManager.getGlyphs(e.stacks,i)}getResource(t,e,i){return Kt(e,i)}_getSourceCache(t){return this._otherSourceCaches[t]}_getLayerSourceCache(t){return"symbol"===t.type?this._symbolSourceCaches[t.source]:this._otherSourceCaches[t.source]}_getSourceCaches(t){const e=[];return this._otherSourceCaches[t]&&e.push(this._otherSourceCaches[t]),this._symbolSourceCaches[t]&&e.push(this._symbolSourceCaches[t]),e}_isSourceCacheLoaded(t){const e=this._getSourceCaches(t);if(0!==e.length)return e.every((t=>t.loaded()));this.fire(new ce(new Error(`There is no source with ID '${t}'`)))}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)}}Jm.getSourceType=function(t){return Df[t]},Jm.setSourceType=function(t,e){Df[t]=e},Jm.registerForPluginStateChange=function(t){return t({pluginStatus:rs,pluginURL:ns}),as.on("pluginStateChange",t),t};var Qm="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#define EXTENT 8192.0\n#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}\n#endif",t_="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}";let e_={},i_={};e_=o_("","\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;\n#else\nuniform sampler2D u_dem;uniform sampler2D u_dem_prev;\n#endif\nuniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos));\n#ifdef TERRAIN_DEM_NEAREST_FILTER\nreturn u_exaggeration*tl;\n#endif\nfloat tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {return currentElevation(apos);}\n#endif\nfloat unpack_depth(vec4 rgba_depth)\n{const vec4 bit_shift=vec4(1.0/(256.0*256.0*256.0),1.0/(256.0*256.0),1.0/256.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(\nunpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy))\n);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nfloat tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a;\n#else\nvec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack);\n#endif\nreturn vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;vec4 bounds=vec4(d,vec2(1.0)-d);h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",!0),i_=o_("#ifdef FOG\nuniform float u_fog_temporal_offset;float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif","#ifdef FOG\nuniform mat4 u_fog_matrix;vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif",!0);const r_=o_("\nhighp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}\n#ifdef TERRAIN\nhighp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(256.0*256.0*256.0,256.0*256.0,256.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/256.0,1.0/256.0,1.0/256.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\n#endif","\nfloat wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}\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."),n_=Qm;var s_={background:o_("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:o_("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:o_("varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\ngl_FragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);\n#ifdef PROJECTION_GLOBE_VIEW\nvec2 scaled_extrude=extrude*a_scale;vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=scaled_extrude.x*surface_vectors[0]+scaled_extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);vec4 world_center=vec4(pos,1);\n#else \nmat3 surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);vec4 world_center=vec4(circle_center,height,1);\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\n#if defined(SCALE_WITH_MAP) && defined(PROJECTION_GLOBE_VIEW)\nview_scale*=a_scale;\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);vec4 occlusion_world_center=vec4(circle_center,cantilevered_height,1);vec4 occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nvec4 occlusion_world_center=world_center;vec4 occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}"),clippingMask:o_("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:o_("uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\ngl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);\n#ifdef PROJECTION_GLOBE_VIEW\nextrude*=a_scale;vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\nvec3 pos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),heatmapTexture:o_("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:o_("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:o_("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:o_("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:o_("#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:o_("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:o_("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:o_("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:o_("varying vec4 v_color;void main() {vec4 color=v_color;\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 pos=vec3(pos_nx.xy,h);\n#else\nvec3 pos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(pos.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.rgb+=clamp(color.rgb*directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),fillExtrusionPattern:o_("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);out_color=out_color*v_lighting;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 p=vec3(pos_nx.xy,h);\n#else\nvec3 p=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}"),hillshadePrepare:o_("#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:o_("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:o_("uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;uniform float u_mix;uniform vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;varying highp vec2 v_uv;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist_a=texture2D(u_dash_image,v_tex_a).a;float sdfdist_b=texture2D(u_dash_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfwidth=min(dash_from.z*u_scale.y,dash_to.z*u_scale.z);float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/sdfwidth;alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\n#ifdef RENDER_LINE_GRADIENT\nvec4 out_color=texture2D(u_gradient_image,v_uv);\n#else\nvec4 out_color=color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef RENDER_LINE_ALPHA_DISCARD\nif (alpha < u_alpha_discard_threshold) {discard;}\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define EXTRUDE_SCALE 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;\n#ifdef RENDER_LINE_GRADIENT\nattribute vec3 a_packed;\n#else\nattribute float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform mediump vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;varying highp vec2 v_uv;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];float a_linesofar=a_packed[2];highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);\n#endif\n#ifdef RENDER_LINE_DASH\nfloat tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;float scaleA=dash_from.z==0.0 ? 0.0 : tileZoomRatio/(dash_from.z*fromScale);float scaleB=dash_to.z==0.0 ? 0.0 : tileZoomRatio/(dash_to.z*toScale);float heightA=dash_from.y;float heightB=dash_to.y;v_tex_a=vec2(a_linesofar*scaleA/floorwidth,(-normal.y*heightA+dash_from.x+0.5)/u_texsize.y);v_tex_b=vec2(a_linesofar*scaleB/floorwidth,(-normal.y*heightB+dash_to.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),linePattern:o_("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:o_("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:o_("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform 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;\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[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchor_z=a_z_tile_anchor.x;vec2 tile_anchor=a_z_tile_anchor.yz;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(vec3(a_pos,anchor_z)+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(a_pos,anchor_z)+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) {vec4 offsetProjected_point=u_matrix*vec4(a_pos+vec2(1,0),anchor_z,1);vec2 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(vec3(a_projected_pos.xy,anchor_z),mercator_pos,u_zoom_transition);\n#else\nvec3 proj_pos=vec3(a_projected_pos.xy,anchor_z);\n#endif\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_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;gl_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));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}"),symbolSDF:o_("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_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;\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[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchor_z=a_z_tile_anchor.x;vec2 tile_anchor=a_z_tile_anchor.yz;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(vec3(a_pos,anchor_z)+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(a_pos,anchor_z)+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) {vec4 offsetprojected_point=u_matrix*vec4(a_pos+vec2(1,0),anchor_z,1);vec2 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(vec3(a_projected_pos.xy,anchor_z),mercator_pos,u_zoom_transition);\n#else\nvec3 proj_pos=vec3(a_projected_pos.xy,anchor_z);\n#endif\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;gl_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));float gamma_scale=gl_Position.w;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}"),symbolTextAndIcon:o_("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;\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[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchor_z=a_z_tile_anchor.x;vec2 tile_anchor=a_z_tile_anchor.yz;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(vec3(a_pos,anchor_z)+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(a_pos,anchor_z)+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),anchor_z,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(vec3(a_projected_pos.xy,anchor_z),mercator_pos,u_zoom_transition);\n#else\nvec3 proj_pos=vec3(a_projected_pos.xy,anchor_z);\n#endif\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*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;gl_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));float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}"),terrainRaster:o_("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef FOG\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nconst float skirtOffset=24575.0;const float wireframeOffset=0.00015;void main() {v_pos0=a_texture_pos/8192.0;float skirt=float(a_pos.x >=skirtOffset);float elevation=elevation(a_texture_pos)-skirt*u_skirt_height;\n#ifdef TERRAIN_WIREFRAME\nelevation+=u_skirt_height*u_skirt_height*wireframeOffset;\n#endif\nvec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n}"),terrainDepth:o_("#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:o_("\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}",t_),skyboxGradient:o_("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}",t_),skyboxCapture:o_("\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:o_("uniform sampler2D u_image0;varying vec2 v_pos0;void main() {gl_FragColor=texture2D(u_image0,v_pos0);\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_proj_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;attribute vec3 a_globe_pos;attribute vec2 a_merc_pos;attribute vec2 a_uv;varying vec2 v_pos0;const float wireframeOffset=1e3;void main() {v_pos0=a_uv;vec2 uv=a_uv*EXTENT;vec4 up_vector=vec4(elevationVector(uv),1.0);float height=elevation(uv);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nvec4 globe=u_globe_matrix*vec4(a_globe_pos+up_vector.xyz*height,1.0);vec4 mercator=vec4(0.0);if (u_zoom_transition > 0.0) {mercator=vec4(a_merc_pos,height,1.0);mercator.xy-=u_merc_center;mercator.x=wrap(mercator.x,-0.5,0.5);mercator=u_merc_matrix*mercator;}vec3 position=mix(globe.xyz,mercator.xyz,u_zoom_transition);gl_Position=u_proj_matrix*vec4(position,1.0);}"),globeAtmosphere:o_("uniform float u_opacity;uniform highp float u_fadeout_range;uniform vec3 u_start_color;uniform vec3 u_end_color;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;varying vec3 v_ray_dir;void main() {vec3 dir=normalize(v_ray_dir);vec3 closest_point=abs(dot(u_globe_pos,dir))*dir;float norm_dist_from_center=length(closest_point-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 1.0)\ndiscard;float t=clamp(1.0-sqrt(norm_dist_from_center-1.0)/u_fadeout_range,0.0,1.0);vec3 color=mix(u_start_color,u_end_color,1.0-t);gl_FragColor=vec4(color*t*u_opacity,u_opacity);}","attribute vec3 a_pos;attribute vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;varying vec3 v_ray_dir;void main() {v_ray_dir=mix(mix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);gl_Position=vec4(a_pos,1.0);}")};function o_(t,e,i){const r=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,n=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,s=e.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),o=t.match(n),a=e.match(n),l=Qm.match(n);let c=a?a.concat(o):o;i||(e_.staticUniforms&&(c=e_.staticUniforms.concat(c)),i_.staticUniforms&&(c=i_.staticUniforms.concat(c))),c&&(c=c.concat(l));const h={};return{fragmentSource:t=t.replace(r,((t,e,i,r,n)=>(h[n]=!0,"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nvarying ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = u_${n};\n#endif\n`))),vertexSource:e=e.replace(r,((t,e,i,r,n)=>{const s="float"===r?"vec2":"vec4",o=n.match(/color/)?"color":s;return h[n]?"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nattribute ${i} ${s} a_${n};\nvarying ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===o?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = unpack_mix_${o}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nattribute ${i} ${s} a_${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===o?`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = unpack_mix_${o}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`})),staticAttributes:s,staticUniforms:c}}class a_{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,e,i,r,n,s,o,a){this.context=t;let l=this.boundPaintVertexBuffers.length!==r.length;for(let t=0;!l&&t<r.length;t++)this.boundPaintVertexBuffers[t]!==r[t]&&(l=!0);t.extVertexArrayObject&&this.vao&&this.boundProgram===e&&this.boundLayoutVertexBuffer===i&&!l&&this.boundIndexBuffer===n&&this.boundVertexOffset===s&&this.boundDynamicVertexBuffer===o&&this.boundDynamicVertexBuffer2===a?(t.bindVertexArrayOES.set(this.vao),o&&o.bind(),n&&n.dynamicDraw&&n.bind(),a&&a.bind()):this.freshBind(e,i,r,n,s,o,a)}freshBind(t,e,i,r,n,s,o){let a;const l=t.numAttributes,c=this.context,h=c.gl;if(c.extVertexArrayObject)this.vao&&this.destroy(),this.vao=c.extVertexArrayObject.createVertexArrayOES(),c.bindVertexArrayOES.set(this.vao),a=0,this.boundProgram=t,this.boundLayoutVertexBuffer=e,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=r,this.boundVertexOffset=n,this.boundDynamicVertexBuffer=s,this.boundDynamicVertexBuffer2=o;else{a=c.currentNumAttributes||0;for(let t=l;t<a;t++)h.disableVertexAttribArray(t)}e.enableAttributes(h,t);for(const e of i)e.enableAttributes(h,t);s&&s.enableAttributes(h,t),o&&o.enableAttributes(h,t),e.bind(),e.setVertexAttribPointers(h,t,n);for(const e of i)e.bind(),e.setVertexAttribPointers(h,t,n);s&&(s.bind(),s.setVertexAttribPointers(h,t,n)),r&&r.bind(),o&&(o.bind(),o.setVertexAttribPointers(h,t,n)),c.currentNumAttributes=l}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}function l_(t,e){const i=Math.pow(2,e.canonical.z),r=e.canonical.y;return[new ba(0,r/i).toLngLat().lat,new ba(0,(r+1)/i).toLngLat().lat]}function c_(t,e,i,r,n,s,o){const a=t.context,l=a.gl,c=i.fbo;if(!c)return;t.prepareDrawTile();const h=t.useProgram("hillshade");a.activeTexture.set(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,c.colorAttachment.get());const u=((t,e,i,r)=>{const n=i.paint.get("hillshade-shadow-color"),s=i.paint.get("hillshade-highlight-color"),o=i.paint.get("hillshade-accent-color");let a=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===i.paint.get("hillshade-illumination-anchor")&&(a-=t.transform.angle);const l=!t.options.moving;return{u_matrix:r||t.transform.calculateProjMatrix(e.tileID.toUnwrapped(),l),u_image:0,u_latrange:l_(0,e.tileID),u_light:[i.paint.get("hillshade-exaggeration"),a],u_shadow:n,u_highlight:s,u_accent:o}})(t,i,r,t.terrain?e.projMatrix:null);t.prepareDrawProgram(a,h,e.toUnwrapped());const{tileBoundsBuffer:p,tileBoundsIndexBuffer:d,tileBoundsSegments:f}=t.getTileBoundsBuffers(i);h.draw(a,l.TRIANGLES,n,s,o,xf.disabled,u,r.id,p,d,f)}function h_(t,e,i){if(!e.needsDEMTextureUpload)return;const r=t.context,n=r.gl;r.pixelStoreUnpackPremultiplyAlpha.set(!1),e.demTexture=e.demTexture||t.getTileTexture(i.stride);const s=i.getPixels();e.demTexture?e.demTexture.update(s,{premultiply:!1}):e.demTexture=new qu(r,s,n.RGBA,{premultiply:!1}),e.needsDEMTextureUpload=!1}function u_(t,e,i,r,n,s){const o=t.context,a=o.gl;if(!e.dem)return;const l=e.dem;if(o.activeTexture.set(a.TEXTURE1),h_(t,e,l),!e.demTexture)return;e.demTexture.bind(a.NEAREST,a.CLAMP_TO_EDGE);const c=l.dim;o.activeTexture.set(a.TEXTURE0);let h=e.fbo;if(!h){const t=new qu(o,{width:c,height:c,data:null},a.RGBA);t.bind(a.LINEAR,a.CLAMP_TO_EDGE),h=e.fbo=o.createFramebuffer(c,c,!0),h.colorAttachment.set(t.texture)}o.bindFramebuffer.set(h.framebuffer),o.viewport.set([0,0,c,c]);const{tileBoundsBuffer:u,tileBoundsIndexBuffer:p,tileBoundsSegments:d}=t.getMercatorTileBoundsBuffers();t.useProgram("hillshadePrepare").draw(o,a.TRIANGLES,r,n,s,xf.disabled,((t,e)=>{const i=e.stride,r=il();return dl(r,0,la,-8192,0,0,1),ol(r,r,[0,-8192,0]),{u_matrix:r,u_image:1,u_dimension:[i,i],u_zoom:t.overscaledZ,u_unpack:e.unpackVector}})(e.tileID,l),i.id,u,p,d),e.needsHillshadePrepare=!1}const p_=(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_image0:new Po(t,e.u_image0),u_skirt_height:new Do(t,e.u_skirt_height)}),d_=(t,e)=>({u_matrix:t,u_image0:0,u_skirt_height:e}),f_=(t,e,i,r,n)=>({u_proj_matrix:Float32Array.from(t),u_globe_matrix:e,u_merc_matrix:i,u_zoom_transition:r,u_merc_center:n,u_image0:0});function m_(t,e){return null!=t&&null!=e&&!(!t.hasData()||!e.hasData())&&null!=t.demTexture&&null!=e.demTexture&&t.tileID.key!==e.tileID.key}const __=new class{constructor(){this.operations={}}newMorphing(t,e,i,r,n){if(t in this.operations){const e=this.operations[t];e.to.tileID.key!==i.tileID.key&&(e.queued=i)}else this.operations[t]={startTime:r,phase:0,duration:n,from:e,to:i,queued:null}}getMorphValuesForProxy(t){if(!(t in this.operations))return null;const e=this.operations[t];return{from:e.from,to:e.to,phase:e.phase}}update(t){for(const e in this.operations){const i=this.operations[e];for(i.phase=(t-i.startTime)/i.duration;i.phase>=1||!this._validOp(i);)if(!this._nextOp(i,t)){delete this.operations[e];break}}}_nextOp(t,e){return!!t.queued&&(t.from=t.to,t.to=t.queued,t.queued=null,t.phase=0,t.startTime=e,!0)}_validOp(t){return t.from.hasData()&&t.to.hasData()}},g_={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function y_(t,e){const i=1<<t.z;return!e&&(0===t.x||t.x===i-1)||0===t.y||t.y===i-1}const x_=t=>({u_matrix:t});function v_(t,e,i,r,n){if(n>0){const s=J.now(),o=(s-t.timeAdded)/n,a=e?(s-e.timeAdded)/n:-1,l=i.getSource(),c=r.coveringZoomLevel({tileSize:l.tileSize,roundZoom:l.roundZoom}),h=!e||Math.abs(e.tileID.overscaledZ-c)>Math.abs(t.tileID.overscaledZ-c),u=h&&t.refreshedUponExpiration?1:v(h?o:1-a,0,1);return t.refreshedUponExpiration&&o>=1&&(t.refreshedUponExpiration=!1),e?{opacity:1,mix:1-u}:{opacity:u,mix:0}}return{opacity:1,mix:0}}class b_ extends bf{constructor(t){const e={type:"raster-dem",maxzoom:t.transform.maxZoom},i=new ap(Zf(),null),r=Bf("mock-dem",e,i,t.style);super("mock-dem",r,!1),r.setEventedParent(this),this._sourceLoaded=!0}_loadTile(t,e){t.state="loaded",e(null)}}class w_ extends bf{constructor(t){const e=Bf("proxy",{type:"geojson",maxzoom:t.transform.maxZoom},new ap(Zf(),null),t.style);super("proxy",e,!1),e.setEventedParent(this),this.map=this.getSource().map=t,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(t,e,i){if(t.freezeTileCoverage)return;this.transform=t;const r=t.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce(((e,i)=>{if(e[i.key]="",!this._tiles[i.key]){const e=new dd(i,this._source.tileSize*i.overscaleFactor(),t.tileZoom);e.state="loaded",this._tiles[i.key]=e}return e}),{});for(const t in this._tiles)t in r||(this.freeFBO(t),this._tiles[t].unloadVectorData(),delete this._tiles[t])}freeFBO(t){const e=this.proxyCachedFBO[t];if(void 0!==e){const i=Object.values(e);this.renderCachePool.push(...i),delete this.proxyCachedFBO[t]}}deallocRenderCache(){this.renderCache.forEach((t=>t.fb.destroy())),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class T_ extends Zp{constructor(t,e,i){super(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y),this.proxyTileKey=e,this.projMatrix=i}}class E_ extends class{isDataAvailableAtPoint(t){const e=this._source();if(!e||t.y<0||t.y>1)return!1;const i=e.getSource().maxzoom,r=1<<i,n=Math.floor(t.x),s=Math.floor((t.x-n)*r),o=Math.floor(t.y*r),a=this.findDEMTileFor(new Zp(i,n,i,s,o));return a&&a.dem}getAtPointOrZero(t,e=0){return this.getAtPoint(t,e)||0}getAtPoint(t,e,i=!0){null==e&&(e=null);const r=this._source();if(!r)return e;if(t.y<0||t.y>1)return e;const n=r.getSource().maxzoom,s=1<<n,o=Math.floor(t.x),a=t.x-o,l=new Zp(n,o,n,Math.floor(a*s),Math.floor(t.y*s)),c=this.findDEMTileFor(l);if(!c||!c.dem)return e;const h=c.dem,u=1<<c.tileID.canonical.z,p=(a*u-c.tileID.canonical.x)*h.dim,d=(t.y*u-c.tileID.canonical.y)*h.dim,f=Math.floor(p),m=Math.floor(d);return(i?this.exaggeration():1)*Ai(Ai(h.get(f,m),h.get(f,m+1),d-m),Ai(h.get(f+1,m),h.get(f+1,m+1),d-m),p-f)}getAtTileOffset(t,e,i){const r=1<<t.canonical.z;return this.getAtPointOrZero(new ba(t.wrap+(t.canonical.x+e/la)/r,(t.canonical.y+i/la)/r))}getAtTileOffsetFunc(t,e,i,r){return n=>{const s=this.getAtTileOffset(t,n.x,n.y),o=r.upVector(t.canonical,n.x,n.y);return El(o,o,s*r.upVectorScale(t.canonical,e,i).metersToTile),o}}getForTilePoints(t,e,i,r){const n=Ef.create(this,t,r);return!!n&&(e.forEach((t=>{t[2]=this.exaggeration()*n.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,r=e.tileID,n=1<<t.canonical.z-r.canonical.z;let s=t.canonical.x/n-r.canonical.x,o=t.canonical.y/n-r.canonical.y,a=0;for(let e=0;e<t.canonical.z-r.canonical.z&&!i.leaves[a];e++){s*=2,o*=2;const t=2*Math.floor(o)+Math.floor(s);a=i.childOffsets[a]+t,s%=1,o%=1}return{min:this.exaggeration()*i.minimums[a],max:this.exaggeration()*i.maximums[a]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(t,e,i){throw new Error("Pure virtual method called.")}pointCoordinate(t){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(t){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}}{constructor(t,e){super(),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[i,r,n]=function(t){const e=new Bs,i=new $s,r=131;e.reserve(17161),i.reserve(33800);for(let t=-64;t<8288;t+=64)for(let i=-64;i<8288;i+=64){const r=i<0||i>8224||t<0||t>8224?24575:0,n=v(Math.round(i),0,la),s=v(Math.round(t),0,la);e.emplaceBack(n+r,s,n,s)}const n=(t,e)=>{const n=e*r+t;i.emplaceBack(n+1,n,n+r),i.emplaceBack(n+r,n+r+1,n+1)};for(let t=1;t<129;t++)for(let e=1;e<129;e++)n(e,t);return[0,129].forEach((t=>{for(let e=0;e<130;e++)n(e,t),n(t,e)})),[e,i,32768]}(),s=t.context;this.gridBuffer=s.createVertexBuffer(i,ud.members),this.gridIndexBuffer=s.createIndexBuffer(r),this.gridSegments=aa.simpleSegment(0,0,i.length,r.length),this.gridNoSkirtSegments=aa.simpleSegment(0,0,i.length,n),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new w_(e.map),this.orthoMatrix=il(),dl(this.orthoMatrix,0,la,0,la,0,1);const o=s.gl;this._overlapStencilMode=new mf({func:o.GEQUAL,mask:255},0,255,o.KEEP,o.KEEP,o.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=e,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new b_(e.map)}set style(t){t.on("data",this._onStyleDataEvent.bind(this)),t.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=t,this._checkRenderCacheEfficiency()}update(t,e,i){if(t&&t.terrain){this._style!==t&&(this.style=t),this.enabled=!0;const r=t.terrain.properties;this.sourceCache=0===t.terrain.drapeRenderMode?this._mockSourceCache:t._getSourceCache(r.get("source")),this._exaggeration=r.get("exaggeration");const n=()=>{this.sourceCache.used&&O(`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 t=this.getScaledDemTileSize();this.sourceCache.update(e,t,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,n(),this._initializing=!0),n(),e.updateElevation(!i),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(e),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(t){this._findCoveringTileCache[t]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const t=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||100!==t.efficiency&&O(`Terrain render cache efficiency is not optimal (${t.efficiency}%) and performance\n may be affected negatively, consider placing all background, fill and line layers before layer\n with id '${t.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(t){t.coord&&"source"===t.dataType?this._clearRenderCacheForTile(t.sourceCacheId,t.coord):"style"===t.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const t in this._style._sourceCaches)this._style._sourceCaches[t].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach((t=>t.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 t=2*this.proxySourceCache.getSource().tileSize;return[t,t]}set useVertexMorphing(t){this._useVertexMorphing=t}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const e=this.proxySourceCache,i=this.painter.transform;this._initializing&&(this._initializing=0===i._centerAltitude&&-1===this.getAtPointOrZero(ba.fromLngLat(i.center),-1),this._emptyDEMTextureDirty=!this._initializing);const r=this.proxyCoords=e.getIds().map((t=>{const r=e.getTileByID(t).tileID;return r.projMatrix=i.calculateProjMatrix(r.toUnwrapped()),r}));!function(t,e){const i=e.transform.pointCoordinate(e.transform.getCameraPoint()),r=new o(i.x,i.y);t.sort(((t,e)=>{if(e.overscaledZ-t.overscaledZ)return e.overscaledZ-t.overscaledZ;const i=new o(t.canonical.x+(1<<t.canonical.z)*t.wrap,t.canonical.y),n=new o(e.canonical.x+(1<<e.canonical.z)*e.wrap,e.canonical.y),s=r.mult(1<<t.canonical.z);return s.x-=.5,s.y-=.5,s.distSqr(i)-s.distSqr(n)}))}(r,this.painter),this._previousZoom=i.zoom;const n=this.proxyToSource||{};this.proxyToSource={},r.forEach((t=>{this.proxyToSource[t.key]={}})),this.terrainTileForTile={};const s=this._style._sourceCaches;for(const e in s){const i=s[e];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,t[e],n),i.usedForTerrain)continue;const r=t[e];i.getSource().reparseOverscaled&&this._assignTerrainTiles(r)}this.proxiedCoords[e.id]=r.map((t=>new T_(t,t.key,this.orthoMatrix))),this._assignTerrainTiles(r),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(n),this.renderingToTexture=!1,this._updateTimestamp=J.now();const a={};this._visibleDemTiles=[];for(const t of this.proxyCoords){const e=this.terrainTileForTile[t.key];if(!e)continue;const i=e.tileID.key;i in a||(this._visibleDemTiles.push(e),a[i]=i)}}_assignTerrainTiles(t){this._initializing||t.forEach((t=>{if(this.terrainTileForTile[t.key])return;const e=this._findTileCoveringTileID(t,this.sourceCache);e&&(this.terrainTileForTile[t.key]=e)}))}_prepareDEMTextures(){const t=this.painter.context,e=t.gl;for(const i in this.terrainTileForTile){const r=this.terrainTileForTile[i],n=r.dem;!n||r.demTexture&&!r.needsDEMTextureUpload||(t.activeTexture.set(e.TEXTURE1),h_(this.painter,r,n))}}_prepareDemTileUniforms(t,e,i,r){if(!e||null==e.demTexture)return!1;const n=t.tileID.canonical,s=Math.pow(2,e.tileID.canonical.z-n.z),o=r||"";return i[`u_dem_tl${o}`]=[n.x*s%1,n.y*s%1],i[`u_dem_scale${o}`]=s,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const t=this.painter.context,e=t.gl;if(!this._emptyDepthBufferTexture){const i=new ec({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new qu(t,i,e.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let t=0;const e=this._visibleDemTiles.reduce(((e,i)=>{if(!i.dem)return e;const r=i.dem.tree.minimums[0];return r>0&&t++,e+r}),0);return t?e/t:0}_updateEmptyDEMTexture(){const t=this.painter.context,e=t.gl;t.activeTexture.set(e.TEXTURE2);const i=this._getLoadedAreaMinimum(),r=new ec({width:1,height:1},new Uint8Array(Ed.pack(i,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let n=this._emptyDEMTexture;return n?n.update(r,{premultiply:!1}):n=this._emptyDEMTexture=new qu(t,r,e.RGBA,{premultiply:!1}),n}setupElevationDraw(t,e,i){const r=this.painter.context,n=r.gl,s=(o=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:Ed.getUnpackVector(o),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 o;s.u_dem_size=this.sourceCache.getSource().tileSize,s.u_exaggeration=this.exaggeration();const a=this.painter.transform,l=a.projection,c=t.tileID.canonical;s.u_tile_tl_up=l.upVector(c,0,0),s.u_tile_tr_up=l.upVector(c,la,0),s.u_tile_br_up=l.upVector(c,la,la),s.u_tile_bl_up=l.upVector(c,0,la),s.u_tile_up_scale=l.upVectorScale(c,a.center.lat,a.worldSize).metersToTile;let h=null,u=null,p=1;if(i&&i.morphing&&this._useVertexMorphing){const e=i.morphing.srcDemTile,r=i.morphing.dstDemTile;p=i.morphing.phase,e&&r&&(this._prepareDemTileUniforms(t,e,s,"_prev")&&(u=e),this._prepareDemTileUniforms(t,r,s)&&(h=r))}if(u&&h?(r.activeTexture.set(n.TEXTURE2),h.demTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE,n.NEAREST),r.activeTexture.set(n.TEXTURE4),u.demTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE,n.NEAREST),s.u_dem_lerp=p):(h=this.terrainTileForTile[t.tileID.key],r.activeTexture.set(n.TEXTURE2),(this._prepareDemTileUniforms(t,h,s)?h.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&&(s.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE),s.u_depth_size_inv=[1,1]),i&&i.useMeterToDem&&h){const t=(1<<h.tileID.canonical.z)*_a(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;s.u_meter_to_dem=t}i&&i.labelPlaneMatrixInv&&(s.u_label_plane_matrix_inv=i.labelPlaneMatrixInv),e.setTerrainUniformValues(r,s)}renderToBackBuffer(t){const e=this.painter,i=this.painter.context;0!==t.length&&(i.bindFramebuffer.set(null),i.viewport.set([0,0,e.width,e.height]),this.renderingToTexture=!1,function(t,e,i,r,n){if("globe"===t.transform.projection.name)!function(t,e,i,r,n){const s=t.context,o=s.gl;let a,l;const c=t.options.showTerrainWireframe?2:0,h=(e,i)=>{if(l===e)return;const r=[g_[e],"PROJECTION_GLOBE_VIEW"];i&&r.push(g_[c]),a=t.useProgram("globeRaster",null,r),l=e},u=t.colorModeForRenderPass(),p=new df(o.LEQUAL,df.ReadWrite,t.depthRangeFor3D);__.update(n);const d=t.transform,f=function(t){const e=t.worldSize,i=t.point,r=_a(1,t.center.lat)*e,n=t.pixelsPerMeter,s=e/(r/t.pixelsPerMeter),o=rl(new Float64Array(16));return ol(o,o,[i.x,i.y,0]),al(o,o,[s,s,n]),Float32Array.from(o)}(d),_=[fa(d.center.lng),ma(d.center.lat)],g=t.globeSharedBuffers;(c?[!1,!0]:[!1]).forEach((c=>{l=-1;const y=c?o.LINES:o.TRIANGLES;for(const l of r){const r=i.getTile(l),x=Dp(t,r,l),v=mf.disabled,b=e.prevTerrainTileForTile[l.key],w=e.terrainTileForTile[l.key];m_(b,w)&&__.newMorphing(l.key,b,w,n,250),s.activeTexture.set(o.TEXTURE0),r.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE);const T=__.getMorphValuesForProxy(l.key),E=T?1:0,I={};T&&pe(I,{morphing:{srcDemTile:T.from,dstDemTile:T.to,phase:m(T.phase)}});const S=Bp(l.canonical,d.globeMatrix),A=f_(d.projMatrix,S,f,Pp(d.zoom),_);if(h(E,c),e.setupElevationDraw(r,a,I),t.prepareDrawProgram(s,a,l.toUnwrapped()),g){const[e,i]=c?g.getWirefameBuffer(t.context):[g.gridIndexBuffer,g.gridSegments];a.draw(s,y,p,v,u,xf.backCCW,A,"globe_raster",x,e,i)}if(!c&&g){const{x:t,y:e,z:i}=l.canonical,r=0===e,n=e===(1<<i)-1,o=g.poleSegments[i];if(o&&(r||n)){let e=Lp(i,t,d);const l=(t,i)=>t.draw(s,y,p,v,u,xf.disabled,f_(d.projMatrix,e,e,0,_),"globe_pole_raster",i,g.poleIndexBuffer,o);r&&l(a,g.poleNorthVertexBuffer),n&&(e=al(il(),e,[1,-1,1]),l(a,g.poleSouthVertexBuffer))}}}}))}(t,e,i,r,n);else{const s=t.context,o=s.gl;let a,l;const c=t.options.showTerrainWireframe?2:0,h=(e,i)=>{if(l===e)return;const r=[g_[e]];i&&r.push(g_[c]),a=t.useProgram("terrainRaster",null,r),l=e},u=t.colorModeForRenderPass(),p=new df(o.LEQUAL,df.ReadWrite,t.depthRangeFor3D);__.update(n);const d=t.transform,f=6*Math.pow(1.5,22-d.zoom)*e.exaggeration();(c?[!1,!0]:[!1]).forEach((c=>{l=-1;const _=c?o.LINES:o.TRIANGLES,[g,y]=c?e.getWirefameBuffer():[e.gridIndexBuffer,e.gridSegments];for(const l of r){const r=i.getTile(l),x=mf.disabled,v=e.prevTerrainTileForTile[l.key],b=e.terrainTileForTile[l.key];m_(v,b)&&__.newMorphing(l.key,v,b,n,250),s.activeTexture.set(o.TEXTURE0),r.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE,o.LINEAR_MIPMAP_NEAREST);const w=__.getMorphValuesForProxy(l.key),T=w?1:0;let E;w&&(E={morphing:{srcDemTile:w.from,dstDemTile:w.to,phase:m(w.phase)}});const I=d_(l.projMatrix,y_(l.canonical,d.renderWorldCopies)?f/10:f);h(T,c),e.setupElevationDraw(r,a,E),t.prepareDrawProgram(s,a,l.toUnwrapped()),a.draw(s,_,p,x,u,xf.backCCW,I,"terrain_raster",e.gridBuffer,g,y)}}))}}(e,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,t.splice(0,t.length))}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;const e=this.painter,i=this.painter.context,r=this.proxySourceCache,n=this.proxiedCoords[r.id],s=this._drapedRenderBatches.shift(),o=[],a=e.style.order;let l=0;for(const c of n){const n=r.getTileByID(c.proxyTileKey),h=r.proxyCachedFBO[c.key]?r.proxyCachedFBO[c.key][t]:void 0,u=void 0!==h?r.renderCache[h]:this.pool[l++],p=void 0!==h;if(n.texture=u.tex,p&&!u.dirty){o.push(n.tileID);continue}let d;i.bindFramebuffer.set(u.fb.framebuffer),this.renderedToTile=!1,u.dirty&&(i.clear({color:Le.transparent,stencil:0}),u.dirty=!1);for(let t=s.start;t<=s.end;++t){const r=e.style._layers[a[t]];if(r.isHidden(e.transform.zoom))continue;const n=e.style._getLayerSourceCache(r),s=n?this.proxyToSource[c.key][n.id]:[c];if(!s)continue;const o=s;i.viewport.set([0,0,u.fb.width,u.fb.height]),d!==(n?n.id:null)&&(this._setupStencil(u,s,r,n),d=n?n.id:null),e.renderLayer(e,n,r,o)}this.renderedToTile?(u.dirty=!0,o.push(n.tileID)):p||--l,5===l&&(l=0,this.renderToBackBuffer(o))}return this.renderToBackBuffer(o),this.renderingToTexture=!1,i.bindFramebuffer.set(null),i.viewport.set([0,0,e.width,e.height]),s.end+1}postRender(){}renderCacheEfficiency(t){const e=t.order.length;if(0===e)return{efficiency:100};let i,r=0,n=0,s=!1;for(let o=0;o<e;++o){const e=t._layers[t.order[o]];this._style.isLayerDraped(e)?(s&&++r,++n):s||(s=!0,i=e.id)}return 0===n?{efficiency:100}:{efficiency:100*(1-r/n),firstUndrapedLayer:i}}getMinElevationBelowMSL(){let t=0;return this._visibleDemTiles.filter((t=>t.dem)).forEach((e=>{t=Math.min(t,e.dem.tree.minimums[0])})),0===t?t:(t-30)*this._exaggeration}raycast(t,e,i){if(!this._visibleDemTiles)return null;const r=this._visibleDemTiles.filter((t=>t.dem)).map((r=>{const n=r.tileID,s=Math.pow(2,n.overscaledZ),{x:o,y:a}=n.canonical,l=o/s,c=(o+1)/s,h=a/s,u=(a+1)/s;return{minx:l,miny:h,maxx:c,maxy:u,t:r.dem.tree.raycastRoot(l,h,c,u,t,e,i),tile:r}}));r.sort(((t,e)=>(null!==t.t?t.t:Number.MAX_VALUE)-(null!==e.t?e.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,t,e,i);if(null!=r)return r}return null}_createFBO(){const t=this.painter.context,e=t.gl,i=this.drapeBufferSize;t.activeTexture.set(e.TEXTURE0);const r=new qu(t,{width:i[0],height:i[1],data:null},e.RGBA);r.bind(e.LINEAR,e.CLAMP_TO_EDGE);const n=t.createFramebuffer(i[0],i[1],!1);return n.colorAttachment.set(r.texture),n.depthAttachment=new uf(t,n.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,i[0],i[1]),this._stencilRef=0,n.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):n.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&!t.extTextureFilterAnisotropicForceOff&&e.texParameterf(e.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.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 t in this._style._sourceCaches)if(this._style._sourceCaches[t].hasTransition())return!0;return this._style.order.some((t=>{const e=this._style._layers[t],i=e.isHidden(this.painter.transform.zoom),r=e.getCrossfadeParameters(),n=!!r&&1!==r.t,s=e.hasTransition();return"custom"!==e.type&&!i&&(n||s)}))}_clearRasterFadeFromRenderCache(){let t=!1;for(const e in this._style._sourceCaches)if(this._style._sourceCaches[e]._source instanceof Cf){t=!0;break}if(t)for(let t=0;t<this._style.order.length;++t){const e=this._style._layers[this._style.order[t]],i=e.isHidden(this.painter.transform.zoom),r=this._style._getLayerSourceCache(e);if("raster"!==e.type||i||!r)continue;const n=e.paint.get("raster-fade-duration");for(const t of this.proxyCoords){const e=this.proxyToSource[t.key][r.id];if(e)for(const t of e){const e=v_(r.getTile(t),r.findLoadedParent(t,0),r,this.painter.transform,n);(1!==e.opacity||0!==e.mix)&&this._clearRenderCacheForTile(r.id,t)}}}}_setupDrapedRenderBatches(){const t=this._style.order,e=t.length;if(0===e)return;const i=[];let r,n=0,s=this._style._layers[t[n]];for(;!this._style.isLayerDraped(s)&&s.isHidden(this.painter.transform.zoom)&&++n<e;)s=this._style._layers[t[n]];for(;n<e;++n){const e=this._style._layers[t[n]];e.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(e)?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(t){const e=this.proxySourceCache;if(this._shouldDisableRenderCache()||this._invalidateRenderCache){if(this._invalidateRenderCache=!1,e.renderCache.length>e.renderCachePool.length){const t=Object.values(e.proxyCachedFBO);e.proxyCachedFBO={};for(let i=0;i<t.length;++i){const r=Object.values(t[i]);e.renderCachePool.push(...r)}}return}this._clearRasterFadeFromRenderCache();const i=this.proxyCoords,r=this._tilesDirty;for(let n=i.length-1;n>=0;n--){const s=i[n];if(e.getTileByID(s.key),void 0!==e.proxyCachedFBO[s.key]){const i=t[s.key],n=this.proxyToSource[s.key];let o=0;for(const t in n){const e=n[t],s=i[t];if(!s||s.length!==e.length||e.some(((e,i)=>e!==s[i]||r[t]&&r[t].hasOwnProperty(e.key)))){o=-1;break}++o}for(const t in e.proxyCachedFBO[s.key])e.renderCache[e.proxyCachedFBO[s.key][t]].dirty=o<0||o!==Object.values(i).length}}const n=[...this._drapedRenderBatches];n.sort(((t,e)=>e.end-e.start-(t.end-t.start)));for(const t of n)for(const r of i){if(e.proxyCachedFBO[r.key])continue;let i=e.renderCachePool.pop();void 0===i&&e.renderCache.length<50&&(i=e.renderCache.length,e.renderCache.push(this._createFBO())),void 0!==i&&(e.proxyCachedFBO[r.key]={},e.proxyCachedFBO[r.key][t.start]=i,e.renderCache[i].dirty=!0)}this._tilesDirty={}}_setupStencil(t,e,i,r){if(!r||!this._sourceTilesOverlap[r.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const n=this.painter.context,s=n.gl;if(e.length<=1)return void(this._overlapStencilType=!1);let o;if(i.isTileClipped())o=e.length,this._overlapStencilMode.test={func:s.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(e[0].overscaledZ>e[e.length-1].overscaledZ))return void(this._overlapStencilType=!1);o=1,this._overlapStencilMode.test={func:s.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+o>255&&(n.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=o,this._overlapStencilMode.ref=this._stencilRef,i.isTileClipped()&&this._renderTileClippingMasks(e,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(t){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs.get(t.key)||0),this._overlapStencilMode):mf.disabled}_renderTileClippingMasks(t,e){const i=this.painter,r=this.painter.context,n=r.gl;i._tileClippingMaskIDs.clear(),r.setColorMode(_f.disabled),r.setDepthMode(df.disabled);const s=i.useProgram("clippingMask");for(const o of t){const t=--e;i._tileClippingMaskIDs.set(o.key,t),s.draw(r,n.TRIANGLES,df.disabled,new mf({func:n.ALWAYS,mask:0},t,255,n.KEEP,n.KEEP,n.REPLACE),_f.disabled,xf.disabled,x_(o.projMatrix),"$clipping",i.tileExtentBuffer,i.quadTriangleIndexBuffer,i.tileExtentSegments)}}pointCoordinate(t){const e=this.painter.transform;if(t.x<0||t.x>e.width||t.y<0||t.y>e.height)return null;const i=[t.x,t.y,1,1];Ol(i,i,e.pixelMatrixInverse),Fl(i,i,1/i[3]),i[0]/=e.worldSize,i[1]/=e.worldSize;const r=e._camera.position,n=_a(1,e.center.lat),s=[r[0],r[1],r[2]/n,0],o=vl([],i.slice(0,3),s);Sl(o,o);const a=this.raycast(s,o,this._exaggeration);return null!==a&&a?(Il(s,s,o,a),s[3]=s[2],s[2]*=n,s):null}drawDepth(){const t=this.painter,e=t.context,i=this.proxySourceCache,r=Math.ceil(t.width),n=Math.ceil(t.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 t=e.gl,i=e.createFramebuffer(r,n,!0);e.activeTexture.set(t.TEXTURE0);const s=new qu(e,{width:r,height:n,data:null},t.RGBA);s.bind(t.NEAREST,t.CLAMP_TO_EDGE),i.colorAttachment.set(s.texture);const o=e.createRenderbuffer(e.gl.DEPTH_COMPONENT16,r,n);i.depthAttachment.set(o),this._depthFBO=i,this._depthTexture=s}e.bindFramebuffer.set(this._depthFBO.framebuffer),e.viewport.set([0,0,r,n]),function(t,e,i,r){if("globe"===t.transform.projection.name)return;const n=t.context,s=n.gl;n.clear({depth:1});const o=t.useProgram("terrainDepth"),a=new df(s.LESS,df.ReadWrite,t.depthRangeFor3D);for(const t of r){const r=i.getTile(t),l=d_(t.projMatrix,0);e.setupElevationDraw(r,o),o.draw(n,s.TRIANGLES,a,mf.disabled,_f.unblended,xf.backCCW,l,"terrain_depth",e.gridBuffer,e.gridIndexBuffer,e.gridNoSkirtSegments)}}(t,this,i,this.proxyCoords)}_setupProxiedCoordsForOrtho(t,e,i){if(t.getSource()instanceof Pf)return this._setupProxiedCoordsForImageSource(t,e,i);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const r=this.proxiedCoords[t.id]=[],n=this.proxyCoords;for(let e=0;e<n.length;e++){const s=n[e],o=this._findTileCoveringTileID(s,t);if(o){const e=this._createProxiedId(s,o,i[s.key]&&i[s.key][t.id]);r.push(e),this.proxyToSource[s.key][t.id]=[e]}}let s=!1;for(let n=0;n<e.length;n++){const o=t.getTile(e[n]);if(!o||!o.hasData())continue;const a=this._findTileCoveringTileID(o.tileID,this.proxySourceCache);if(a&&a.tileID.canonical.z!==o.tileID.canonical.z){const e=this.proxyToSource[a.tileID.key][t.id],n=this._createProxiedId(a.tileID,o,i[a.tileID.key]&&i[a.tileID.key][t.id]);e?e.splice(e.length-1,0,n):this.proxyToSource[a.tileID.key][t.id]=[n],r.push(n),s=!0}}this._sourceTilesOverlap[t.id]=s}_setupProxiedCoordsForImageSource(t,e,i){if(!t.getSource().loaded())return;const r=this.proxiedCoords[t.id]=[],n=this.proxyCoords,s=t.getSource(),a=new o(s.tileID.x,s.tileID.y)._div(1<<s.tileID.z),l=s.coordinates.map(ba.fromLngLat).reduce(((t,e)=>(t.min.x=Math.min(t.min.x,e.x-a.x),t.min.y=Math.min(t.min.y,e.y-a.y),t.max.x=Math.max(t.max.x,e.x-a.x),t.max.y=Math.max(t.max.y,e.y-a.y),t)),{min:new o(Number.MAX_VALUE,Number.MAX_VALUE),max:new o(-Number.MAX_VALUE,-Number.MAX_VALUE)}),c=(t,e)=>{const i=t.wrap+t.canonical.x/(1<<t.canonical.z),r=t.canonical.y/(1<<t.canonical.z),n=la/(1<<t.canonical.z),s=e.wrap+e.canonical.x/(1<<e.canonical.z),o=e.canonical.y/(1<<e.canonical.z);return i+n<s+l.min.x||i>s+l.max.x||r+n<o+l.min.y||r>o+l.max.y};for(let s=0;s<n.length;s++){const o=n[s];for(let n=0;n<e.length;n++){const s=t.getTile(e[n]);if(!s||!s.hasData())continue;if(c(o,s.tileID))continue;const a=this._createProxiedId(o,s,i[o.key]&&i[o.key][t.id]),l=this.proxyToSource[o.key][t.id];l?l.push(a):this.proxyToSource[o.key][t.id]=[a],r.push(a)}}}_createProxiedId(t,e,i){let r=this.orthoMatrix;if(i){const t=i.find((t=>t.key===e.tileID.key));if(t)return t}if(e.tileID.key!==t.key){const i=t.canonical.z-e.tileID.canonical.z;let n,s,o;r=il();const a=e.tileID.wrap-t.wrap<<t.overscaledZ;i>0?(n=la>>i,s=n*((e.tileID.canonical.x<<i)-t.canonical.x+a),o=n*((e.tileID.canonical.y<<i)-t.canonical.y)):(n=la<<-i,s=la*(e.tileID.canonical.x-(t.canonical.x+a<<-i)),o=la*(e.tileID.canonical.y-(t.canonical.y<<-i))),dl(r,0,n,0,n,0,1),ol(r,r,[s,o,0])}return new T_(e.tileID,t.key,r)}_findTileCoveringTileID(t,e){let i=e.getTile(t);if(i&&i.hasData())return i;const r=this._findCoveringTileCache[e.id],n=r[t.key];if(i=n?e.getTileByID(n):null,i&&i.hasData()||null===n)return i;let s=i?i.tileID:t,o=s.overscaledZ;const a=e.getSource().minzoom,l=[];if(!n){const r=e.getSource().maxzoom;if(t.canonical.z>=r){const i=t.canonical.z-r;e.getSource().reparseOverscaled?(o=Math.max(t.canonical.z+2,e.transform.tileZoom),s=new Zp(o,t.wrap,r,t.canonical.x>>i,t.canonical.y>>i)):0!==i&&(o=r,s=new Zp(o,t.wrap,r,t.canonical.x>>i,t.canonical.y>>i))}s.key!==t.key&&(l.push(s.key),i=e.getTile(s))}const c=t=>{l.forEach((e=>{r[e]=t})),l.length=0};for(o-=1;o>=a&&(!i||!i.hasData());o--){i&&c(i.tileID.key);const t=s.calculateScaledKey(o);if(i=e.getTileByID(t),i&&i.hasData())break;const n=r[t];if(null===n)break;void 0===n?l.push(t):i=e.getTileByID(n)}return c(i?i.tileID.key:null),i&&i.hasData()?i:null}findDEMTileFor(t){return this.enabled?this._findTileCoveringTileID(t,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(t,e){let i=this._tilesDirty[t];i||(i=this._tilesDirty[t]={}),i[e.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const t=function(t){let e=0;const i=new Qs,r=131;for(let t=1;t<129;t++){for(let n=1;n<129;n++)e=t*r+n,i.emplaceBack(e,e+1),i.emplaceBack(e,e+r),i.emplaceBack(e+1,e+r),128===t&&i.emplaceBack(e+r,e+r+1);i.emplaceBack(e+1,e+1+r)}return i}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(t),this.wireframeSegments=aa.simpleSegment(0,0,this.gridBuffer.length,t.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}function I_(t){const e=[];for(let i=0;i<t.length;i++){if(null===t[i])continue;const r=t[i].split(" ");e.push(r.pop())}return e}class S_{static cacheKey(t,e,i){let r=`${t}${i?i.cacheKey:""}`;for(const t of e)r+=`/${t}`;return r}constructor(t,e,i,r,n,s){const o=t.gl;this.program=o.createProgram();const a=I_(i.staticAttributes),l=r?r.getBinderAttributes():[],c=a.concat(l),h=i.staticUniforms?I_(i.staticUniforms):[],u=r?r.getBinderUniforms():[],p=h.concat(u),d=[];for(const t of p)d.indexOf(t)<0&&d.push(t);let f=r?r.defines():[];f=f.concat(s.map((t=>`#define ${t}`)));const m=f.concat("\n#ifdef GL_ES\nprecision mediump float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif",n_,r_.fragmentSource,i_.fragmentSource,i.fragmentSource).join("\n"),_=f.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",n_,r_.vertexSource,i_.vertexSource,e_.vertexSource,i.vertexSource).join("\n"),g=o.createShader(o.FRAGMENT_SHADER);if(o.isContextLost())return void(this.failedToCreate=!0);o.shaderSource(g,m),o.compileShader(g),o.attachShader(this.program,g);const y=o.createShader(o.VERTEX_SHADER);if(o.isContextLost())return void(this.failedToCreate=!0);o.shaderSource(y,_),o.compileShader(y),o.attachShader(this.program,y),this.attributes={};const x={};this.numAttributes=c.length;for(let t=0;t<this.numAttributes;t++)c[t]&&(o.bindAttribLocation(this.program,t,c[t]),this.attributes[c[t]]=t);o.linkProgram(this.program),o.deleteShader(y),o.deleteShader(g);for(let t=0;t<d.length;t++){const e=d[t];if(e&&!x[e]){const t=o.getUniformLocation(this.program,e);t&&(x[e]=t)}}this.fixedUniforms=n(t,x),this.binderUniforms=r?r.getUniforms(t,x):[],-1!==s.indexOf("TERRAIN")&&(this.terrainUniforms=((t,e)=>({u_dem:new Po(t,e.u_dem),u_dem_prev:new Po(t,e.u_dem_prev),u_dem_unpack:new Ro(t,e.u_dem_unpack),u_dem_tl:new Bo(t,e.u_dem_tl),u_dem_scale:new Do(t,e.u_dem_scale),u_dem_tl_prev:new Bo(t,e.u_dem_tl_prev),u_dem_scale_prev:new Do(t,e.u_dem_scale_prev),u_dem_size:new Do(t,e.u_dem_size),u_dem_lerp:new Do(t,e.u_dem_lerp),u_exaggeration:new Do(t,e.u_exaggeration),u_depth:new Po(t,e.u_depth),u_depth_size_inv:new Bo(t,e.u_depth_size_inv),u_meter_to_dem:new Do(t,e.u_meter_to_dem),u_label_plane_matrix_inv:new Vo(t,e.u_label_plane_matrix_inv),u_tile_tl_up:new Lo(t,e.u_tile_tl_up),u_tile_tr_up:new Lo(t,e.u_tile_tr_up),u_tile_br_up:new Lo(t,e.u_tile_br_up),u_tile_bl_up:new Lo(t,e.u_tile_bl_up),u_tile_up_scale:new Do(t,e.u_tile_up_scale)}))(t,x)),-1!==s.indexOf("FOG")&&(this.fogUniforms=((t,e)=>({u_fog_matrix:new Vo(t,e.u_fog_matrix),u_fog_range:new Bo(t,e.u_fog_range),u_fog_color:new Ro(t,e.u_fog_color),u_fog_horizon_blend:new Do(t,e.u_fog_horizon_blend),u_fog_temporal_offset:new Do(t,e.u_fog_temporal_offset)}))(t,x))}setTerrainUniformValues(t,e){if(!this.terrainUniforms)return;const i=this.terrainUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const t in e)i[t].set(e[t])}}setFogUniformValues(t,e){if(!this.fogUniforms)return;const i=this.fogUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const t in e)i[t].location&&i[t].set(e[t])}}draw(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f,m){const _=t.gl;if(this.failedToCreate)return;t.program.set(this.program),t.setDepthMode(i),t.setStencilMode(r),t.setColorMode(n),t.setCullFace(s);for(const t of Object.keys(this.fixedUniforms))this.fixedUniforms[t].set(o[t]);d&&d.setUniforms(t,this.binderUniforms,u,{zoom:p});const g={[_.LINES]:2,[_.TRIANGLES]:3,[_.LINE_STRIP]:1}[e];for(const i of h.get()){const r=i.vaos||(i.vaos={});(r[a]||(r[a]=new a_)).bind(t,this,l,d?d.getPaintVertexBuffers():[],c,i.vertexOffset,f,m),_.drawElements(e,i.primitiveLength*g,_.UNSIGNED_SHORT,i.primitiveOffset*g*2)}}}function A_(t,e,i){const r=1/lp(i,1,e.transform.tileZoom),n=Math.pow(2,i.tileID.overscaledZ),s=i.tileSize*Math.pow(2,e.transform.tileZoom)/n,o=s*(i.tileID.canonical.x+i.tileID.wrap*n),a=s*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[r,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[o>>16,a>>16],u_pixel_coord_lower:[65535&o,65535&a]}}const z_=il(),C_=(t,e,i,r,n,s,o,a,l)=>{const c=e.style.light,h=c.properties.get("position"),u=[h.x,h.y,h.z],p=Qa();var d,f,m,_;"viewport"===c.properties.get("anchor")&&(d=p,f=-e.transform.angle,m=Math.sin(f),_=Math.cos(f),d[0]=_,d[1]=m,d[2]=0,d[3]=-m,d[4]=_,d[5]=0,d[6]=0,d[7]=0,d[8]=1,Ml(u,u,p));const g=c.properties.get("color"),y=e.transform,x={u_matrix:t,u_lightpos:u,u_lightintensity:c.properties.get("intensity"),u_lightcolor:[g.r,g.g,g.b],u_vertical_gradient:+i,u_opacity:r,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:z_,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0};return"globe"===y.projection.name&&(x.u_tile_id=[n.canonical.x,n.canonical.y,1<<n.canonical.z],x.u_zoom_transition=o,x.u_inv_rot_matrix=l,x.u_merc_center=a,x.u_up_dir=y.projection.upVector(new Up(0,0,0),a[0]*la,a[1]*la),x.u_height_lift=s),x},M_=(t,e,i,r,n,s,o,a,l,c,h)=>{const u=C_(t,e,i,r,n,a,l,c,h),p={u_height_factor:-Math.pow(2,n.overscaledZ)/o.tileSize/8};return I(u,A_(s,e,o),p)},k_=t=>({u_matrix:t}),P_=(t,e,i,r)=>I(k_(t),A_(i,e,r)),D_=(t,e)=>({u_matrix:t,u_world:e}),B_=(t,e,i,r,n)=>I(P_(t,e,i,r),{u_world:n}),L_=il(),R_=(t,e,i,r,n,s)=>{const o=t.transform,a="globe"===o.projection.name;let l;if("map"===s.paint.get("circle-pitch-alignment"))if(a){const t=Cp(o.zoom,e.canonical);l=Float32Array.from([t,0,0,t])}else l=o.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([o.pixelsToGLUnits[0],0,0,o.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:o.cameraToCenterDistance,u_matrix:t.translatePosMatrix(e.projMatrix,i,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_device_pixel_ratio:J.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:L_,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};return a&&(c.u_inv_rot_matrix=r,c.u_merc_center=n,c.u_tile_id=[e.canonical.x,e.canonical.y,1<<e.canonical.z],c.u_zoom_transition=Pp(o.zoom),c.u_up_dir=o.projection.upVector(e.canonical,n[0],n[1])),c},F_=t=>{const e=[];return"map"===t.paint.get("circle-pitch-alignment")&&e.push("PITCH_WITH_MAP"),"map"===t.paint.get("circle-pitch-scale")&&e.push("SCALE_WITH_MAP"),e},O_=(t,e,i)=>{const r=la/i.tileSize;return{u_matrix:t,u_camera_to_center_distance:e.cameraToCenterDistance,u_extrude_scale:[e.pixelsToGLUnits[0]/r,e.pixelsToGLUnits[1]/r]}},V_=(t,e,i=1)=>({u_matrix:t,u_color:e,u_overlay:0,u_overlay_scale:i}),j_=il(),U_=(t,e,i,r,n,s,o)=>{const a=t.transform,l="globe"===a.projection.name,c=l?Cp(a.zoom,e.canonical):lp(i,1,s),h={u_matrix:e.projMatrix,u_extrude_scale:c,u_intensity:o,u_inv_rot_matrix:j_,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};return l&&(h.u_inv_rot_matrix=r,h.u_merc_center=n,h.u_tile_id=[e.canonical.x,e.canonical.y,1<<e.canonical.z],h.u_zoom_transition=Pp(a.zoom),h.u_up_dir=a.projection.upVector(e.canonical,n[0],n[1])),h},N_=(t,e,i,r,n,s,o)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e),c={u_matrix:G_(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:s,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0};if($_(i)){const i=q_(e,t.transform);c.u_texsize=e.lineAtlasTexture.size,c.u_scale=[i,r.fromScale,r.toScale],c.u_mix=r.t}return c},Z_=(t,e,i,r,n,s)=>{const o=t.transform,a=q_(e,o);return{u_matrix:G_(t,e,i,n),u_texsize:e.imageAtlasTexture.size,u_pixels_to_tile_units:o.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:s,u_image:0,u_scale:[a,r.fromScale,r.toScale],u_fade:r.t,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function q_(t,e){return 1/lp(t,1,e.tileZoom)}function G_(t,e,i,r){return t.translatePosMatrix(r||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}function $_(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}const W_=(t,e,i,r,n,s)=>{return{u_matrix:t,u_tl_parent:e,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:(a=n.paint.get("raster-saturation"),a>0?1-1/(1.001-a):-a),u_contrast_factor:(o=n.paint.get("raster-contrast"),o>0?1/(1-o):1+o),u_spin_weights:X_(n.paint.get("raster-hue-rotate")),u_perspective_transform:s};var o,a};function X_(t){t*=Math.PI/180;const e=Math.sin(t),i=Math.cos(t);return[(2*i+1)/3,(-Math.sqrt(3)*e-i+1)/3,(Math.sqrt(3)*e-i+1)/3]}const H_=il(),K_=(t,e,i,r,n,s,o,a,l,c,h,u,p,d)=>{const f=n.transform,m={u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:f.cameraToCenterDistance,u_rotate_symbol:+i,u_aspect_ratio:f.width/f.height,u_fade_change:n.options.fadeDuration?n.symbolFadeChange:1,u_matrix:s,u_label_plane_matrix:o,u_coord_matrix:a,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:H_,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:H_};return"globe"===f.projection.name&&(m.u_tile_id=[h.canonical.x,h.canonical.y,1<<h.canonical.z],m.u_zoom_transition=u,m.u_inv_rot_matrix=d,m.u_merc_center=p,m.u_camera_forward=f._camera.forward(),m.u_ecef_origin=function(t,e){const i=[0,0,0];return Cl(i,i,Sp(xp(e.canonical))),Cl(i,i,t),i}(f.globeMatrix,h.toUnwrapped()),m.u_tile_matrix=Float32Array.from(f.globeMatrix)),m},Y_=(t,e,i,r,n,s,o,a,l,c,h,u,p,d,f)=>{const{cameraToCenterDistance:m,_pitch:_}=n.transform;return I(K_(t,e,i,r,n,s,o,a,l,c,u,p,d,f),{u_gamma_scale:r?m*Math.cos(n.terrain?0:_):1,u_device_pixel_ratio:J.devicePixelRatio,u_is_halo:+h})},J_=(t,e,i,r,n,s,o,a,l,c,h,u,p,d)=>I(Y_(t,e,i,r,n,s,o,a,!0,l,!0,h,u,p,d),{u_texsize_icon:c,u_texture_icon:1}),Q_=(t,e,i)=>({u_matrix:t,u_opacity:e,u_color:i}),tg=(t,e,i,r,n,s)=>I(function(t,e,i,r){const n=i.imageManager.getPattern(t.from.toString()),s=i.imageManager.getPattern(t.to.toString()),{width:o,height:a}=i.imageManager.getPixelSize(),l=Math.pow(2,r.tileID.overscaledZ),c=r.tileSize*Math.pow(2,i.transform.tileZoom)/l,h=c*(r.tileID.canonical.x+r.tileID.wrap*l),u=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:s.tl,u_pattern_br_b:s.br,u_texsize:[o,a],u_mix:e.t,u_pattern_size_a:n.displaySize,u_pattern_size_b:s.displaySize,u_scale_a:e.fromScale,u_scale_b:e.toScale,u_tile_units_to_pixels:1/lp(r,1,i.transform.tileZoom),u_pixel_coord_upper:[h>>16,u>>16],u_pixel_coord_lower:[65535&h,65535&u]}}(r,s,i,n),{u_matrix:t,u_opacity:e}),eg={fillExtrusion:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_lightpos:new Lo(t,e.u_lightpos),u_lightintensity:new Do(t,e.u_lightintensity),u_lightcolor:new Lo(t,e.u_lightcolor),u_vertical_gradient:new Do(t,e.u_vertical_gradient),u_opacity:new Do(t,e.u_opacity),u_tile_id:new Lo(t,e.u_tile_id),u_zoom_transition:new Do(t,e.u_zoom_transition),u_inv_rot_matrix:new Vo(t,e.u_inv_rot_matrix),u_merc_center:new Bo(t,e.u_merc_center),u_up_dir:new Lo(t,e.u_up_dir),u_height_lift:new Do(t,e.u_height_lift)}),fillExtrusionPattern:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_lightpos:new Lo(t,e.u_lightpos),u_lightintensity:new Do(t,e.u_lightintensity),u_lightcolor:new Lo(t,e.u_lightcolor),u_vertical_gradient:new Do(t,e.u_vertical_gradient),u_height_factor:new Do(t,e.u_height_factor),u_tile_id:new Lo(t,e.u_tile_id),u_zoom_transition:new Do(t,e.u_zoom_transition),u_inv_rot_matrix:new Vo(t,e.u_inv_rot_matrix),u_merc_center:new Bo(t,e.u_merc_center),u_up_dir:new Lo(t,e.u_up_dir),u_height_lift:new Do(t,e.u_height_lift),u_image:new Po(t,e.u_image),u_texsize:new Bo(t,e.u_texsize),u_pixel_coord_upper:new Bo(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new Bo(t,e.u_pixel_coord_lower),u_scale:new Lo(t,e.u_scale),u_fade:new Do(t,e.u_fade),u_opacity:new Do(t,e.u_opacity)}),fill:(t,e)=>({u_matrix:new Vo(t,e.u_matrix)}),fillPattern:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_image:new Po(t,e.u_image),u_texsize:new Bo(t,e.u_texsize),u_pixel_coord_upper:new Bo(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new Bo(t,e.u_pixel_coord_lower),u_scale:new Lo(t,e.u_scale),u_fade:new Do(t,e.u_fade)}),fillOutline:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_world:new Bo(t,e.u_world)}),fillOutlinePattern:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_world:new Bo(t,e.u_world),u_image:new Po(t,e.u_image),u_texsize:new Bo(t,e.u_texsize),u_pixel_coord_upper:new Bo(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new Bo(t,e.u_pixel_coord_lower),u_scale:new Lo(t,e.u_scale),u_fade:new Do(t,e.u_fade)}),circle:(t,e)=>({u_camera_to_center_distance:new Do(t,e.u_camera_to_center_distance),u_extrude_scale:new Zo(t,e.u_extrude_scale),u_device_pixel_ratio:new Do(t,e.u_device_pixel_ratio),u_matrix:new Vo(t,e.u_matrix),u_inv_rot_matrix:new Vo(t,e.u_inv_rot_matrix),u_merc_center:new Bo(t,e.u_merc_center),u_tile_id:new Lo(t,e.u_tile_id),u_zoom_transition:new Do(t,e.u_zoom_transition),u_up_dir:new Lo(t,e.u_up_dir)}),collisionBox:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_camera_to_center_distance:new Do(t,e.u_camera_to_center_distance),u_extrude_scale:new Bo(t,e.u_extrude_scale)}),collisionCircle:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_inv_matrix:new Vo(t,e.u_inv_matrix),u_camera_to_center_distance:new Do(t,e.u_camera_to_center_distance),u_viewport_size:new Bo(t,e.u_viewport_size)}),debug:(t,e)=>({u_color:new Fo(t,e.u_color),u_matrix:new Vo(t,e.u_matrix),u_overlay:new Po(t,e.u_overlay),u_overlay_scale:new Do(t,e.u_overlay_scale)}),clippingMask:(t,e)=>({u_matrix:new Vo(t,e.u_matrix)}),heatmap:(t,e)=>({u_extrude_scale:new Do(t,e.u_extrude_scale),u_intensity:new Do(t,e.u_intensity),u_matrix:new Vo(t,e.u_matrix),u_inv_rot_matrix:new Vo(t,e.u_inv_rot_matrix),u_merc_center:new Bo(t,e.u_merc_center),u_tile_id:new Lo(t,e.u_tile_id),u_zoom_transition:new Do(t,e.u_zoom_transition),u_up_dir:new Lo(t,e.u_up_dir)}),heatmapTexture:(t,e)=>({u_image:new Po(t,e.u_image),u_color_ramp:new Po(t,e.u_color_ramp),u_opacity:new Do(t,e.u_opacity)}),hillshade:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_image:new Po(t,e.u_image),u_latrange:new Bo(t,e.u_latrange),u_light:new Bo(t,e.u_light),u_shadow:new Fo(t,e.u_shadow),u_highlight:new Fo(t,e.u_highlight),u_accent:new Fo(t,e.u_accent)}),hillshadePrepare:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_image:new Po(t,e.u_image),u_dimension:new Bo(t,e.u_dimension),u_zoom:new Do(t,e.u_zoom),u_unpack:new Ro(t,e.u_unpack)}),line:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_pixels_to_tile_units:new Zo(t,e.u_pixels_to_tile_units),u_device_pixel_ratio:new Do(t,e.u_device_pixel_ratio),u_units_to_pixels:new Bo(t,e.u_units_to_pixels),u_dash_image:new Po(t,e.u_dash_image),u_gradient_image:new Po(t,e.u_gradient_image),u_image_height:new Do(t,e.u_image_height),u_texsize:new Bo(t,e.u_texsize),u_scale:new Lo(t,e.u_scale),u_mix:new Do(t,e.u_mix),u_alpha_discard_threshold:new Do(t,e.u_alpha_discard_threshold)}),linePattern:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_texsize:new Bo(t,e.u_texsize),u_pixels_to_tile_units:new Zo(t,e.u_pixels_to_tile_units),u_device_pixel_ratio:new Do(t,e.u_device_pixel_ratio),u_image:new Po(t,e.u_image),u_units_to_pixels:new Bo(t,e.u_units_to_pixels),u_scale:new Lo(t,e.u_scale),u_fade:new Do(t,e.u_fade),u_alpha_discard_threshold:new Do(t,e.u_alpha_discard_threshold)}),raster:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_tl_parent:new Bo(t,e.u_tl_parent),u_scale_parent:new Do(t,e.u_scale_parent),u_fade_t:new Do(t,e.u_fade_t),u_opacity:new Do(t,e.u_opacity),u_image0:new Po(t,e.u_image0),u_image1:new Po(t,e.u_image1),u_brightness_low:new Do(t,e.u_brightness_low),u_brightness_high:new Do(t,e.u_brightness_high),u_saturation_factor:new Do(t,e.u_saturation_factor),u_contrast_factor:new Do(t,e.u_contrast_factor),u_spin_weights:new Lo(t,e.u_spin_weights),u_perspective_transform:new Bo(t,e.u_perspective_transform)}),symbolIcon:(t,e)=>({u_is_size_zoom_constant:new Po(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new Po(t,e.u_is_size_feature_constant),u_size_t:new Do(t,e.u_size_t),u_size:new Do(t,e.u_size),u_camera_to_center_distance:new Do(t,e.u_camera_to_center_distance),u_rotate_symbol:new Po(t,e.u_rotate_symbol),u_aspect_ratio:new Do(t,e.u_aspect_ratio),u_fade_change:new Do(t,e.u_fade_change),u_matrix:new Vo(t,e.u_matrix),u_label_plane_matrix:new Vo(t,e.u_label_plane_matrix),u_coord_matrix:new Vo(t,e.u_coord_matrix),u_is_text:new Po(t,e.u_is_text),u_pitch_with_map:new Po(t,e.u_pitch_with_map),u_texsize:new Bo(t,e.u_texsize),u_tile_id:new Lo(t,e.u_tile_id),u_zoom_transition:new Do(t,e.u_zoom_transition),u_inv_rot_matrix:new Vo(t,e.u_inv_rot_matrix),u_merc_center:new Bo(t,e.u_merc_center),u_camera_forward:new Lo(t,e.u_camera_forward),u_tile_matrix:new Vo(t,e.u_tile_matrix),u_ecef_origin:new Lo(t,e.u_ecef_origin),u_texture:new Po(t,e.u_texture)}),symbolSDF:(t,e)=>({u_is_size_zoom_constant:new Po(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new Po(t,e.u_is_size_feature_constant),u_size_t:new Do(t,e.u_size_t),u_size:new Do(t,e.u_size),u_camera_to_center_distance:new Do(t,e.u_camera_to_center_distance),u_rotate_symbol:new Po(t,e.u_rotate_symbol),u_aspect_ratio:new Do(t,e.u_aspect_ratio),u_fade_change:new Do(t,e.u_fade_change),u_matrix:new Vo(t,e.u_matrix),u_label_plane_matrix:new Vo(t,e.u_label_plane_matrix),u_coord_matrix:new Vo(t,e.u_coord_matrix),u_is_text:new Po(t,e.u_is_text),u_pitch_with_map:new Po(t,e.u_pitch_with_map),u_texsize:new Bo(t,e.u_texsize),u_texture:new Po(t,e.u_texture),u_gamma_scale:new Do(t,e.u_gamma_scale),u_device_pixel_ratio:new Do(t,e.u_device_pixel_ratio),u_tile_id:new Lo(t,e.u_tile_id),u_zoom_transition:new Do(t,e.u_zoom_transition),u_inv_rot_matrix:new Vo(t,e.u_inv_rot_matrix),u_merc_center:new Bo(t,e.u_merc_center),u_camera_forward:new Lo(t,e.u_camera_forward),u_tile_matrix:new Vo(t,e.u_tile_matrix),u_ecef_origin:new Lo(t,e.u_ecef_origin),u_is_halo:new Po(t,e.u_is_halo)}),symbolTextAndIcon:(t,e)=>({u_is_size_zoom_constant:new Po(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new Po(t,e.u_is_size_feature_constant),u_size_t:new Do(t,e.u_size_t),u_size:new Do(t,e.u_size),u_camera_to_center_distance:new Do(t,e.u_camera_to_center_distance),u_rotate_symbol:new Po(t,e.u_rotate_symbol),u_aspect_ratio:new Do(t,e.u_aspect_ratio),u_fade_change:new Do(t,e.u_fade_change),u_matrix:new Vo(t,e.u_matrix),u_label_plane_matrix:new Vo(t,e.u_label_plane_matrix),u_coord_matrix:new Vo(t,e.u_coord_matrix),u_is_text:new Po(t,e.u_is_text),u_pitch_with_map:new Po(t,e.u_pitch_with_map),u_texsize:new Bo(t,e.u_texsize),u_texsize_icon:new Bo(t,e.u_texsize_icon),u_texture:new Po(t,e.u_texture),u_texture_icon:new Po(t,e.u_texture_icon),u_gamma_scale:new Do(t,e.u_gamma_scale),u_device_pixel_ratio:new Do(t,e.u_device_pixel_ratio),u_is_halo:new Po(t,e.u_is_halo)}),background:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_opacity:new Do(t,e.u_opacity),u_color:new Fo(t,e.u_color)}),backgroundPattern:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_opacity:new Do(t,e.u_opacity),u_image:new Po(t,e.u_image),u_pattern_tl_a:new Bo(t,e.u_pattern_tl_a),u_pattern_br_a:new Bo(t,e.u_pattern_br_a),u_pattern_tl_b:new Bo(t,e.u_pattern_tl_b),u_pattern_br_b:new Bo(t,e.u_pattern_br_b),u_texsize:new Bo(t,e.u_texsize),u_mix:new Do(t,e.u_mix),u_pattern_size_a:new Bo(t,e.u_pattern_size_a),u_pattern_size_b:new Bo(t,e.u_pattern_size_b),u_scale_a:new Do(t,e.u_scale_a),u_scale_b:new Do(t,e.u_scale_b),u_pixel_coord_upper:new Bo(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new Bo(t,e.u_pixel_coord_lower),u_tile_units_to_pixels:new Do(t,e.u_tile_units_to_pixels)}),terrainRaster:p_,terrainDepth:p_,skybox:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_sun_direction:new Lo(t,e.u_sun_direction),u_cubemap:new Po(t,e.u_cubemap),u_opacity:new Do(t,e.u_opacity),u_temporal_offset:new Do(t,e.u_temporal_offset)}),skyboxGradient:(t,e)=>({u_matrix:new Vo(t,e.u_matrix),u_color_ramp:new Po(t,e.u_color_ramp),u_center_direction:new Lo(t,e.u_center_direction),u_radius:new Do(t,e.u_radius),u_opacity:new Do(t,e.u_opacity),u_temporal_offset:new Do(t,e.u_temporal_offset)}),skyboxCapture:(t,e)=>({u_matrix_3f:new Uo(t,e.u_matrix_3f),u_sun_direction:new Lo(t,e.u_sun_direction),u_sun_intensity:new Do(t,e.u_sun_intensity),u_color_tint_r:new Ro(t,e.u_color_tint_r),u_color_tint_m:new Ro(t,e.u_color_tint_m),u_luminance:new Do(t,e.u_luminance)}),globeRaster:(t,e)=>({u_proj_matrix:new Vo(t,e.u_proj_matrix),u_globe_matrix:new Vo(t,e.u_globe_matrix),u_merc_matrix:new Vo(t,e.u_merc_matrix),u_zoom_transition:new Do(t,e.u_zoom_transition),u_merc_center:new Bo(t,e.u_merc_center),u_image0:new Po(t,e.u_image0)}),globeAtmosphere:(t,e)=>({u_frustum_tl:new Lo(t,e.u_frustum_tl),u_frustum_tr:new Lo(t,e.u_frustum_tr),u_frustum_br:new Lo(t,e.u_frustum_br),u_frustum_bl:new Lo(t,e.u_frustum_bl),u_globe_pos:new Lo(t,e.u_globe_pos),u_globe_radius:new Do(t,e.u_globe_radius),u_opacity:new Do(t,e.u_opacity),u_fadeout_range:new Do(t,e.u_fadeout_range),u_start_color:new Lo(t,e.u_start_color),u_end_color:new Lo(t,e.u_end_color)})};let ig;function rg(t,e,i,r,n,s,o){const a=t.context,l=a.gl,c=t.useProgram("collisionBox"),h=[];let u=0,p=0;for(let d=0;d<r.length;d++){const f=r[d],m=e.getTile(f),_=m.getBucket(i);if(!_)continue;let g=f.projMatrix;0===n[0]&&0===n[1]||(g=t.translatePosMatrix(f.projMatrix,m,n,s));const y=o?_.textCollisionBox:_.iconCollisionBox,x=_.collisionCircleArray;if(x.length>0){const e=il(),i=g;fl(e,_.placementInvProjMatrix,t.transform.glCoordMatrix),fl(e,e,_.placementViewportMatrix),h.push({circleArray:x,circleOffset:p,transform:i,invTransform:e}),u+=x.length/4,p=u}y&&(t.terrain&&t.terrain.setupElevationDraw(m,c),c.draw(a,l.LINES,df.disabled,mf.disabled,t.colorModeForRenderPass(),xf.disabled,O_(g,t.transform,m),i.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,null,t.transform.zoom,null,y.collisionVertexBuffer,y.collisionVertexBufferExt))}if(!o||!h.length)return;const d=t.useProgram("collisionCircle"),f=new qs;f.resize(4*u),f._trim();let m=0;for(const t of h)for(let e=0;e<t.circleArray.length/4;e++){const i=4*e,r=t.circleArray[i+0],n=t.circleArray[i+1],s=t.circleArray[i+2],o=t.circleArray[i+3];f.emplace(m++,r,n,s,o,0),f.emplace(m++,r,n,s,o,1),f.emplace(m++,r,n,s,o,2),f.emplace(m++,r,n,s,o,3)}(!ig||ig.length<2*u)&&(ig=function(t){const e=2*t,i=new $s;i.resize(e),i._trim();for(let t=0;t<e;t++){const e=6*t;i.uint16[e+0]=4*t+0,i.uint16[e+1]=4*t+1,i.uint16[e+2]=4*t+2,i.uint16[e+3]=4*t+2,i.uint16[e+4]=4*t+3,i.uint16[e+5]=4*t+0}return i}(u));const _=a.createIndexBuffer(ig,!0),g=a.createVertexBuffer(f,Bh.members,!0);for(const e of h){const r={u_matrix:e.transform,u_inv_matrix:e.invTransform,u_camera_to_center_distance:(y=t.transform).cameraToCenterDistance,u_viewport_size:[y.width,y.height]};d.draw(a,l.TRIANGLES,df.disabled,mf.disabled,t.colorModeForRenderPass(),xf.disabled,r,i.id,g,_,aa.simpleSegment(0,2*e.circleOffset,e.circleArray.length,e.circleArray.length/2),null,t.transform.zoom,null,null,null)}var y;g.destroy(),_.destroy()}const ng=il();function sg(t,e,i,r,n,s){const{horizontalAlign:a,verticalAlign:l}=_u(t),c=-(a-.5)*e,h=-(l-.5)*i,u=Eu(t,r);return new o((c/n+u[0])*s,(h/n+u[1])*s)}function og(t,e,i,r,n,s,a,l,c,h,u,p){const d=t.text.placedSymbolArray,f=t.text.dynamicLayoutVertexArray,m=t.icon.dynamicLayoutVertexArray,_={},g=l.projMatrix,y=s.elevation,x=p.upVectorScale(l.canonical,s.center.lat,s.worldSize);f.clear();for(let m=0;m<d.length;m++){const v=d.get(m),b=t.allowVerticalPlacement&&!v.placedOrientation,w=v.hidden||!v.crossTileID||b?null:r[v.crossTileID];if(w){const r=new o(v.tileAnchorX,v.tileAnchorY),d=p.upVector(l.canonical,r.x,r.y),m=y?y.getAtTileOffset(l,r.x,r.y):0,b=am([v.projectedAnchorX+m*d[0]*x.metersToTile,v.projectedAnchorY+m*d[1]*x.metersToTile,v.projectedAnchorZ+m*d[2]*x.metersToTile],i?g:a),T=lm(s.cameraToCenterDistance,b.signedDistanceFromCamera);let E=n.evaluateSizeForFeature(t.textSizeData,h,v)*T/24;i&&(E*=t.tilePixelRatio/c);const{width:I,height:S,anchor:A,textOffset:z,textScale:C}=w,M=sg(A,I,S,z,C,E),k=i?om(r.add(M),a,m*x.metersToLabelSpace).point:b.point.add(e?M.rotate(-s.angle):M),P=t.allowVerticalPlacement&&v.placedOrientation===mu.vertical?Math.PI/2:0;for(let t=0;t<v.numGlyphs;t++)zu(f,k,P);u&&v.associatedIconIndex>=0&&(_[v.associatedIconIndex]={shiftedAnchor:k,angle:P})}else ym(v.numGlyphs,f)}if(u){m.clear();const e=t.icon.placedSymbolArray;for(let t=0;t<e.length;t++){const i=e.get(t);if(i.hidden)ym(i.numGlyphs,m);else{const e=_[t];if(e)for(let t=0;t<i.numGlyphs;t++)zu(m,e.shiftedAnchor,e.angle);else ym(i.numGlyphs,m)}}t.icon.dynamicLayoutVertexBuffer.updateData(m)}t.text.dynamicLayoutVertexBuffer.updateData(f)}function ag(t,e,i){return i.iconsInText&&e?"symbolTextAndIcon":t?"symbolSDF":"symbolIcon"}function lg(t,e,i,r,n,s,o,a,l,c,h,u){const p=t.context,d=p.gl,f=t.transform,m="map"===a,_="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=t.depthModeForSublayer(0,df.ReadOnly),w=[fa(f.center.lng),ma(f.center.lat)],T=i.layout.get("text-variable-anchor"),E="globe"===f.projection.name,I=E?Pp(f.zoom):0,S=[],A=[];t.terrain&&_&&A.push("PITCH_WITH_MAP_TERRAIN"),E&&A.push("PROJECTION_GLOBE_VIEW");for(const a of r){const r=e.getTile(a),l=r.getBucket(i);if(!l||l.projection!==f.projection.name)continue;const h=n?l.text:l.icon;if(!h||l.fullyClipped||!h.segments.get().length)continue;const u=h.programConfigurations.get(i.id),p=n||l.sdfIcons,b=n?l.textSizeData:l.iconSizeData,E=_||0!==f.pitch,z=Oh(b,f.zoom);let C,M,k,P,D=[0,0],B=null;if(n){if(M=r.glyphAtlasTexture,k=d.LINEAR,C=r.glyphAtlasTexture.size,l.iconsInText){D=r.imageAtlasTexture.size,B=r.imageAtlasTexture;const e="composite"===b.kind||"camera"===b.kind;P=E||t.options.rotating||t.options.zooming||e?d.LINEAR:d.NEAREST}}else{const e=1!==i.layout.get("icon-size").constantOr(0)||l.iconsNeedLinear;M=r.imageAtlasTexture,k=p||t.options.rotating||t.options.zooming||e||E?d.LINEAR:d.NEAREST,C=r.imageAtlasTexture.size}const L=t.transform.calculatePixelsToTileUnitsMatrix(r),R=nm(a.projMatrix,r.tileID.canonical,_,m,t.transform,L),F=t.terrain&&_&&g?nl(il(),R):ng,O=sm(a.projMatrix,r.tileID.canonical,_,m,t.transform,L),V=T&&l.hasTextData(),j="none"!==i.layout.get("icon-text-fit")&&V&&l.hasIconData();if(g){const e=f.elevation,i=e?e.getAtTileOffsetFunc(a,f.center.lat,f.worldSize,f.projection):t=>[0,0,0];hm(l,a.projMatrix,t,n,R,O,_,c,i,a)}const U=g||n&&T||j,N=t.translatePosMatrix(a.projMatrix,r,s,o),Z=U?ng:R,q=t.translatePosMatrix(O,r,s,o,!0),G=f.projection.createInversionMatrix(f,a.canonical),$=U?A.concat(["PROJECTED_POS_ON_VIEWPORT"]):A,W=p&&0!==i.paint.get(n?"text-halo-width":"icon-halo-width").constantOr(1);let X;X=p?l.iconsInText?J_(b.kind,z,y,_,t,N,Z,q,C,D,a,I,w,G):Y_(b.kind,z,y,_,t,N,Z,q,n,C,!0,a,I,w,G):K_(b.kind,z,y,_,t,N,Z,q,n,C,a,I,w,G);const H={program:t.useProgram(ag(p,n,l),u,$),buffers:h,uniformValues:X,atlasTexture:M,atlasTextureIcon:B,atlasInterpolation:k,atlasInterpolationIcon:P,isSDF:p,hasHalo:W,tile:r,labelPlaneMatrixInv:F};if(x&&l.canOverlap){v=!0;const t=h.segments.get();for(const e of t)S.push({segments:new aa([e]),sortKey:e.sortKey,state:H})}else S.push({segments:h.segments,sortKey:0,state:H})}v&&S.sort(((t,e)=>t.sortKey-e.sortKey));for(const e of S){const r=e.state;if(t.terrain&&t.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,cg(r.buffers,e.segments,i,t,r.program,b,h,u,n)),n.u_is_halo=0}cg(r.buffers,e.segments,i,t,r.program,b,h,u,r.uniformValues)}}function cg(t,e,i,r,n,s,o,a,l){const c=r.context;n.draw(c,c.gl.TRIANGLES,s,o,a,xf.disabled,l,i.id,t.layoutVertexBuffer,t.indexBuffer,e,i.paint,r.transform.zoom,t.programConfigurations.get(i.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer)}function hg(t,e,i,r,n,s,o){const a=t.context.gl,l=i.paint.get("fill-pattern"),c=l&&l.constantOr(1),h=i.getCrossfadeParameters();let u,p,d,f,m;o?(p=c&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",u=a.LINES):(p=c?"fillPattern":"fill",u=a.TRIANGLES);for(const _ of r){const r=e.getTile(_);if(c&&!r.patternsLoaded())continue;const g=r.getBucket(i);if(!g)continue;t.prepareDrawTile();const y=g.programConfigurations.get(i.id),x=t.useProgram(p,y);c&&(t.context.activeTexture.set(a.TEXTURE0),r.imageAtlasTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE),y.updatePaintBuffers(h));const v=l.constantOr(null);if(v&&r.imageAtlas){const t=r.imageAtlas,e=t.patternPositions[v.to.toString()],i=t.patternPositions[v.from.toString()];e&&i&&y.setConstantPatternPositions(e,i)}const b=t.translatePosMatrix(_.projMatrix,r,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor"));if(o){f=g.indexBuffer2,m=g.segments2;const e=t.terrain&&t.terrain.renderingToTexture?t.terrain.drapeBufferSize:[a.drawingBufferWidth,a.drawingBufferHeight];d="fillOutlinePattern"===p&&c?B_(b,t,h,r,e):D_(b,e)}else f=g.indexBuffer,m=g.segments,d=c?P_(b,t,h,r):k_(b);t.prepareDrawProgram(t.context,x,_.toUnwrapped()),x.draw(t.context,u,n,t.stencilModeForClipping(_),s,xf.disabled,d,i.id,g.layoutVertexBuffer,f,m,i.paint,t.transform.zoom,y)}}function ug(t,e,i,r,n,s,o){const a=t.context,l=a.gl,c=t.transform,h=i.paint.get("fill-extrusion-pattern"),u=h.constantOr(1),p=i.getCrossfadeParameters(),d=i.paint.get("fill-extrusion-opacity"),f=function(t){if("globe"!==t.projection.name)return 0;const e=Math.PI/32,i=Math.tan(e),r=ha;return r*Math.sqrt(1+2*i*i)-r}(c),m="globe"===c.projection.name,_=m?Pp(c.zoom):0,g=[fa(c.center.lng),ma(c.center.lat)],y=[];m&&y.push("PROJECTION_GLOBE_VIEW");for(const x of r){const r=e.getTile(x),v=r.getBucket(i);if(!v||v.projection!==c.projection.name)continue;const b=v.programConfigurations.get(i.id),w=t.useProgram(u?"fillExtrusionPattern":"fillExtrusion",b,y);if(t.terrain){const n=t.terrain;if(t.style.terrainSetForDrapingOnly())n.setupElevationDraw(r,w,{useMeterToDem:!0});else{if(!v.enableTerrain)continue;if(n.setupElevationDraw(r,w,{useMeterToDem:!0}),pg(a,e,x,v,i,n),!v.centroidVertexBuffer){const t=w.attributes.a_centroid_pos;void 0!==t&&l.vertexAttrib2f(t,0,0)}}}u&&(t.context.activeTexture.set(l.TEXTURE0),r.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),b.updatePaintBuffers(p));const T=h.constantOr(null);if(T&&r.imageAtlas){const t=r.imageAtlas,e=t.patternPositions[T.to.toString()],i=t.patternPositions[T.from.toString()];e&&i&&b.setConstantPatternPositions(e,i)}const E=t.translatePosMatrix(x.projMatrix,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),I=c.projection.createInversionMatrix(c,x.canonical),S=i.paint.get("fill-extrusion-vertical-gradient"),A=u?M_(E,t,S,d,x,p,r,f,_,g,I):C_(E,t,S,d,x,f,_,g,I);t.prepareDrawProgram(a,w,x.toUnwrapped()),w.draw(a,a.gl.TRIANGLES,n,s,o,xf.backCCW,A,i.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,i.paint,t.transform.zoom,b,t.terrain?v.centroidVertexBuffer:null,m?v.layoutVertexExtBuffer:null)}}function pg(t,e,i,r,n,s){const a=[t=>{let e=t.canonical.x-1,i=t.wrap;return e<0&&(e=(1<<t.canonical.z)-1,i--),new Zp(t.overscaledZ,i,t.canonical.z,e,t.canonical.y)},t=>{let e=t.canonical.x+1,i=t.wrap;return e===1<<t.canonical.z&&(e=0,i++),new Zp(t.overscaledZ,i,t.canonical.z,e,t.canonical.y)},t=>new Zp(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(0===t.canonical.y?1<<t.canonical.z:t.canonical.y)-1),t=>new Zp(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1<<t.canonical.z)-1?0:t.canonical.y+1)],l=t=>{const i=e.getSource().minzoom,r=t=>{const i=e.getTileByID(t);if(i&&i.hasData())return i.getBucket(n)},s=[0,-1,1];for(const e of s){if(t.overscaledZ+e<i)continue;const n=r(t.calculateScaledKey(t.overscaledZ+e));if(n)return n}},c=[0,0,0],h=(t,e)=>(c[0]=Math.min(t.min.y,e.min.y),c[1]=Math.max(t.max.y,e.max.y),c[2]=la-e.min.x>t.max.x?e.min.x-la:t.max.x,c),u=(t,e)=>(c[0]=Math.min(t.min.x,e.min.x),c[1]=Math.max(t.max.x,e.max.x),c[2]=la-e.min.y>t.max.y?e.min.y-la:t.max.y,c),p=[(t,e)=>h(t,e),(t,e)=>h(e,t),(t,e)=>u(t,e),(t,e)=>u(e,t)],d=new o(0,0);let f,m,_;const g=(t,e,r,n,o)=>{const a=[[n?r:t,n?t:r,0],[n?r:e,n?e:r,0]],l=o<0?la+o:o,c=[n?l:(t+e)/2,n?(t+e)/2:l,0];return 0===r&&o<0||0!==r&&o>0?s.getForTilePoints(_,[c],!0,m):a.push(c),s.getForTilePoints(i,a,!0,f),Math.max(a[0][2],a[1][2],c[2])/s.exaggeration()};for(let t=0;t<4;t++){const e=(t<2?1:5)-t,n=r.borders[t];if(0===n.length)continue;const o=_=a[t](i),c=l(o);if(!(c&&c instanceof uh&&c.enableTerrain))continue;if(r.borderDoneWithNeighborZ[t]===c.canonical.z&&c.borderDoneWithNeighborZ[e]===r.canonical.z)continue;if(m=s.findDEMTileFor(o),!m||!m.dem)continue;if(!f){const t=s.findDEMTileFor(i);if(!t||!t.dem)return;f=t}const h=c.borders[e];let u=0;const y=c.borderDoneWithNeighborZ[e]!==r.canonical.z;if(r.canonical.z===c.canonical.z){for(let i=0;i<n.length;i++){const s=r.featuresOnBorder[n[i]],o=s.borders[t];let a;for(;u<h.length&&(a=c.featuresOnBorder[h[u]],!(a.borders[e][1]>o[0]+3));)y&&c.encodeCentroid(void 0,a,!1),u++;if(a&&u<h.length){const i=u;let n=0;for(;!(a.borders[e][0]>o[1]-3)&&(n++,++u!==h.length);)a=c.featuresOnBorder[h[u]];if(a=c.featuresOnBorder[h[i]],s.intersectsCount()>1||a.intersectsCount()>1||1!==n){1!==n&&(u=i),r.encodeCentroid(void 0,s,!1),y&&c.encodeCentroid(void 0,a,!1);continue}const l=p[t](s,a),f=t%2?8191:0;d.x=g(l[0],Math.min(8191,l[1]),f,t<2,l[2]),d.y=0,r.encodeCentroid(d,s,!1),y&&c.encodeCentroid(d,a,!1)}else r.encodeCentroid(void 0,s,!1)}r.borderDoneWithNeighborZ[t]=c.canonical.z,r.needsCentroidUpdate=!0,y&&(c.borderDoneWithNeighborZ[e]=r.canonical.z,c.needsCentroidUpdate=!0)}else{for(const t of n)r.encodeCentroid(void 0,r.featuresOnBorder[t],!1);if(y){for(const t of h)c.encodeCentroid(void 0,c.featuresOnBorder[t],!1);c.borderDoneWithNeighborZ[e]=r.canonical.z,c.needsCentroidUpdate=!0}r.borderDoneWithNeighborZ[t]=c.canonical.z,r.needsCentroidUpdate=!0}}(r.needsCentroidUpdate||!r.centroidVertexBuffer&&0!==r.centroidVertexArray.length)&&r.uploadCentroid(t)}const dg=new Le(1,0,0,1),fg=new Le(0,1,0,1),mg=new Le(0,0,1,1),_g=new Le(1,0,1,1),gg=new Le(0,1,1,1);function yg(t,e,i,r){vg(t,0,e+i/2,t.transform.width,i,r)}function xg(t,e,i,r){vg(t,e-i/2,0,i,t.transform.height,r)}function vg(t,e,i,r,n,s){const o=t.context,a=o.gl;a.enable(a.SCISSOR_TEST),a.scissor(e*J.devicePixelRatio,i*J.devicePixelRatio,r*J.devicePixelRatio,n*J.devicePixelRatio),o.clear({color:s}),a.disable(a.SCISSOR_TEST)}function bg(t,e,i){const r=t.context,n=r.gl,s="globe"===t.transform.projection.name,o=i.projMatrix,a=t.useProgram("debug",null,s?["PROJECTION_GLOBE_VIEW"]:null),l=e.getTileByID(i.key);t.terrain&&t.terrain.setupElevationDraw(l,a);const c=df.disabled,h=mf.disabled,u=t.colorModeForRenderPass(),p="$debug";r.activeTexture.set(n.TEXTURE0),t.emptyTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE),s?l._makeGlobeTileDebugBuffers(t.context,t.transform.projection):l._makeDebugTileBoundsBuffers(t.context,t.transform.projection);const d=l._tileDebugBuffer||t.debugBuffer,f=l._tileDebugIndexBuffer||t.debugIndexBuffer,m=l._tileDebugSegments||t.debugSegments;a.draw(r,n.LINE_STRIP,c,h,u,xf.disabled,V_(o,Le.red),p,d,f,m,null,null,null,l._globeTileDebugBorderBuffer);const _=l.latestRawTileData,g=Math.floor((_&&_.byteLength||0)/1024),y=e.getTile(i).tileSize,x=512/Math.min(y,512)*(i.overscaledZ/t.transform.zoom)*.5;let v=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(v+=` => ${i.overscaledZ}`),function(t,e){t.initDebugOverlayCanvas();const i=t.debugOverlayCanvas,r=t.context.gl,n=t.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(e,5,5),n.strokeText(e,5,5),t.debugOverlayTexture.update(i),t.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(t,`${v} ${g}kb`);const b=l._tileDebugTextBuffer||t.debugBuffer,w=l._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,T=l._tileDebugTextSegments||t.debugSegments;a.draw(r,n.TRIANGLES,c,h,_f.alphaBlended,xf.disabled,V_(o,Le.transparent,x),p,b,w,T,null,null,null,l._globeTileDebugTextBuffer)}const wg=Ms([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Tg}=wg;function Eg(t,e,i,r){t.emplaceBack(e,i,r)}class Ig{constructor(t){this.vertexArray=new Rs,this.indices=new $s,Eg(this.vertexArray,-1,-1,1),Eg(this.vertexArray,1,-1,1),Eg(this.vertexArray,-1,1,1),Eg(this.vertexArray,1,1,1),Eg(this.vertexArray,-1,-1,-1),Eg(this.vertexArray,1,-1,-1),Eg(this.vertexArray,-1,1,-1),Eg(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=t.createVertexBuffer(this.vertexArray,Tg),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=aa.simpleSegment(0,0,36,12)}}function Sg(t,e,i,r,n,s){const o=t.gl,a=e.paint.get("sky-atmosphere-color"),l=e.paint.get("sky-atmosphere-halo-color"),c=e.paint.get("sky-atmosphere-sun-intensity"),h=((t,e,i,r,n)=>({u_matrix_3f:t,u_sun_direction:e,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}))(((u=Qa())[0]=(p=r)[0],u[1]=p[1],u[2]=p[2],u[3]=p[4],u[4]=p[5],u[5]=p[6],u[6]=p[8],u[7]=p[9],u[8]=p[10],u),n,c,a,l);var u,p;o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_CUBE_MAP_POSITIVE_X+s,e.skyboxTexture,0),i.draw(t,o.TRIANGLES,df.disabled,mf.disabled,_f.unblended,xf.frontCW,h,"skyboxCapture",e.skyboxGeometry.vertexBuffer,e.skyboxGeometry.indexBuffer,e.skyboxGeometry.segment)}function Ag(t,e){return Cl(t,t,e)}const zg={symbol:function(t,e,i,r,n){if("translucent"!==t.renderPass)return;const s=mf.disabled,o=t.colorModeForRenderPass();i.layout.get("text-variable-anchor")&&function(t,e,i,r,n,s,o){const a=e.transform,l="map"===n,c="map"===s;for(const n of t){const t=r.getTile(n),s=t.getBucket(i);if(!s||s.projection!==a.projection.name||!s.text||!s.text.segments.get().length)continue;const h=Oh(s.textSizeData,a.zoom),u=e.transform.calculatePixelsToTileUnitsMatrix(t),p=nm(n.projMatrix,t.tileID.canonical,c,l,e.transform,u),d="none"!==i.layout.get("icon-text-fit")&&s.hasIconData();if(h){const e=Math.pow(2,a.zoom-t.tileID.overscaledZ);og(s,l,c,o,Vh,a,p,n,e,h,d,a.projection)}}}(r,t,i,e,i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),n),0!==i.paint.get("icon-opacity").constantOr(1)&&lg(t,e,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"),s,o),0!==i.paint.get("text-opacity").constantOr(1)&&lg(t,e,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"),s,o),e.map.showCollisionBoxes&&(rg(t,e,i,r,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),!0),rg(t,e,i,r,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),!1))},circle:function(t,e,i,r){if("translucent"!==t.renderPass)return;const n=i.paint.get("circle-opacity"),s=i.paint.get("circle-stroke-width"),o=i.paint.get("circle-stroke-opacity"),a=void 0!==i.layout.get("circle-sort-key").constantOr(1);if(0===n.constantOr(1)&&(0===s.constantOr(1)||0===o.constantOr(1)))return;const l=t.context,c=l.gl,h=t.transform,u=t.depthModeForSublayer(0,df.ReadOnly),p=mf.disabled,d=t.colorModeForRenderPass(),f="globe"===h.projection.name,m=[fa(h.center.lng),ma(h.center.lat)],_=[];for(let n=0;n<r.length;n++){const s=r[n],o=e.getTile(s),l=o.getBucket(i);if(!l)continue;const c=l.programConfigurations.get(i.id),u=F_(i);f&&u.push("PROJECTION_GLOBE_VIEW");const p=t.useProgram("circle",c,u),d=l.layoutVertexBuffer,g=l.globeExtVertexBuffer,y=l.indexBuffer,x=h.projection.createInversionMatrix(h,s.canonical),v={programConfiguration:c,program:p,layoutVertexBuffer:d,globeExtVertexBuffer:g,indexBuffer:y,uniformValues:R_(t,s,o,x,m,i),tile:o};if(a){const t=l.segments.get();for(const e of t)_.push({segments:new aa([e]),sortKey:e.sortKey,state:v})}else _.push({segments:l.segments,sortKey:0,state:v})}a&&_.sort(((t,e)=>t.sortKey-e.sortKey));const g={useDepthForOcclusion:!f};for(const e of _){const{programConfiguration:r,program:n,layoutVertexBuffer:s,globeExtVertexBuffer:o,indexBuffer:a,uniformValues:m,tile:_}=e.state,y=e.segments;t.terrain&&t.terrain.setupElevationDraw(_,n,g),t.prepareDrawProgram(l,n,_.tileID.toUnwrapped()),n.draw(l,c.TRIANGLES,u,p,d,xf.disabled,m,i.id,s,a,y,i.paint,h.zoom,r,f?o:null)}},heatmap:function(t,e,i,r){if(0!==i.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const n=t.context,s=n.gl,o=mf.disabled,a=new _f([s.ONE,s.ONE],Le.transparent,[!0,!0,!0,!0]);!function(t,e,i){const r=t.gl;t.activeTexture.set(r.TEXTURE1),t.viewport.set([0,0,e.width/4,e.height/4]);let n=i.heatmapFbo;if(n)r.bindTexture(r.TEXTURE_2D,n.colorAttachment.get()),t.bindFramebuffer.set(n.framebuffer);else{const s=r.createTexture();r.bindTexture(r.TEXTURE_2D,s),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),n=i.heatmapFbo=t.createFramebuffer(e.width/4,e.height/4,!1),function(t,e,i,r){const n=t.gl;n.texImage2D(n.TEXTURE_2D,0,n.RGBA,e.width/4,e.height/4,0,n.RGBA,t.extRenderToTextureHalfFloat?t.extTextureHalfFloat.HALF_FLOAT_OES:n.UNSIGNED_BYTE,null),r.colorAttachment.set(i)}(t,e,s,n)}}(n,t,i),n.clear({color:Le.transparent});const l=t.transform,c="globe"===l.projection.name,h=c?["PROJECTION_GLOBE_VIEW"]:null,u=[fa(l.center.lng),ma(l.center.lat)];for(let p=0;p<r.length;p++){const d=r[p];if(e.hasRenderableParent(d))continue;const f=e.getTile(d),m=f.getBucket(i);if(!m)continue;const _=m.programConfigurations.get(i.id),g=t.useProgram("heatmap",_,h),{zoom:y}=t.transform;t.terrain&&t.terrain.setupElevationDraw(f,g),t.prepareDrawProgram(n,g,d.toUnwrapped());const x=l.projection.createInversionMatrix(l,d.canonical);g.draw(n,s.TRIANGLES,df.disabled,o,a,xf.disabled,U_(t,d,f,x,u,y,i.paint.get("heatmap-intensity")),i.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,i.paint,t.transform.zoom,_,c?m.globeExtVertexBuffer:null)}n.viewport.set([0,0,t.width,t.height])}else"translucent"===t.renderPass&&(t.context.setColorMode(t.colorModeForRenderPass()),function(t,e){const i=t.context,r=i.gl,n=e.heatmapFbo;if(!n)return;i.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,n.colorAttachment.get()),i.activeTexture.set(r.TEXTURE1);let s=e.colorRampTexture;s||(s=e.colorRampTexture=new qu(i,e.colorRamp,r.RGBA)),s.bind(r.LINEAR,r.CLAMP_TO_EDGE),t.useProgram("heatmapTexture").draw(i,r.TRIANGLES,df.disabled,mf.disabled,t.colorModeForRenderPass(),xf.disabled,((t,e,i,r)=>({u_image:0,u_color_ramp:1,u_opacity:e.paint.get("heatmap-opacity")}))(0,e),e.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,e.paint,t.transform.zoom)}(t,i))},line:function(t,e,i,r){if("translucent"!==t.renderPass)return;const n=i.paint.get("line-opacity"),s=i.paint.get("line-width");if(0===n.constantOr(1)||0===s.constantOr(1))return;const o=t.depthModeForSublayer(0,df.ReadOnly),a=t.colorModeForRenderPass(),l=t.terrain&&t.terrain.renderingToTexture?1:J.devicePixelRatio,c=i.paint.get("line-dasharray"),h=c.constantOr(1),u=i.layout.get("line-cap"),p=i.paint.get("line-pattern"),d=p.constantOr(1),f=i.paint.get("line-gradient"),m=i.getCrossfadeParameters(),_=d?"linePattern":"line",g=t.context,y=g.gl,x=(t=>{const e=[];$_(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-pattern").constantOr(1),r=1!==t.paint.get("line-opacity").constantOr(1);return!i&&r&&e.push("RENDER_LINE_ALPHA_DISCARD"),e})(i);let b=x.includes("RENDER_LINE_ALPHA_DISCARD");t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(b=!1);for(const n of r){const r=e.getTile(n);if(d&&!r.patternsLoaded())continue;const s=r.getBucket(i);if(!s)continue;t.prepareDrawTile();const w=s.programConfigurations.get(i.id),T=t.useProgram(_,w,x),E=p.constantOr(null);if(E&&r.imageAtlas){const t=r.imageAtlas,e=t.patternPositions[E.to.toString()],i=t.patternPositions[E.from.toString()];e&&i&&w.setConstantPatternPositions(e,i)}const I=c.constantOr(null),S=u.constantOr(null);if(!d&&I&&S&&r.lineAtlas){const t=r.lineAtlas,e=t.getDash(I.to,S),i=t.getDash(I.from,S);e&&i&&w.setConstantPatternPositions(e,i)}const A=t.terrain?n.projMatrix:null,z=d?Z_(t,r,i,m,A,l):N_(t,r,i,m,A,s.lineClipsArray.length,l);if(f){const r=s.gradients[i.id];let o=r.texture;if(i.gradientVersion!==r.version){let a=256;if(i.stepInterpolant){const i=e.getSource().maxzoom,r=n.canonical.z===i?Math.ceil(1<<t.transform.maxZoom-n.canonical.z):1;a=v(M(s.maxLineLength/la*1024*r),256,g.maxTextureSize)}r.gradient=rc({expression:i.gradientExpression(),evaluationKey:"lineProgress",resolution:a,image:r.gradient||void 0,clips:s.lineClipsArray}),r.texture?r.texture.update(r.gradient):r.texture=new qu(g,r.gradient,y.RGBA),r.version=i.gradientVersion,o=r.texture}g.activeTexture.set(y.TEXTURE1),o.bind(i.stepInterpolant?y.NEAREST:y.LINEAR,y.CLAMP_TO_EDGE)}h&&(g.activeTexture.set(y.TEXTURE0),r.lineAtlasTexture.bind(y.LINEAR,y.REPEAT),w.updatePaintBuffers(m)),d&&(g.activeTexture.set(y.TEXTURE0),r.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),w.updatePaintBuffers(m)),t.prepareDrawProgram(g,T,n.toUnwrapped());const C=e=>{T.draw(g,y.TRIANGLES,o,e,a,xf.disabled,z,i.id,s.layoutVertexBuffer,s.indexBuffer,s.segments,i.paint,t.transform.zoom,w,s.layoutVertexBuffer2)};if(b){const e=t.stencilModeForClipping(n).ref;0===e&&t.terrain&&g.clear({stencil:0});const i={func:y.EQUAL,mask:255};z.u_alpha_discard_threshold=.8,C(new mf(i,e,255,y.KEEP,y.KEEP,y.INVERT)),z.u_alpha_discard_threshold=0,C(new mf(i,e,255,y.KEEP,y.KEEP,y.KEEP))}else C(t.stencilModeForClipping(n))}b&&(t.resetStencilClippingMasks(),t.terrain&&g.clear({stencil:0}))},fill:function(t,e,i,r){const n=i.paint.get("fill-color"),s=i.paint.get("fill-opacity");if(0===s.constantOr(1))return;const o=t.colorModeForRenderPass(),a=i.paint.get("fill-pattern"),l=t.opaquePassEnabledForLayer()&&!a.constantOr(1)&&1===n.constantOr(Le.transparent).a&&1===s.constantOr(0)?"opaque":"translucent";if(t.renderPass===l){const n=t.depthModeForSublayer(1,"opaque"===t.renderPass?df.ReadWrite:df.ReadOnly);hg(t,e,i,r,n,o,!1)}if("translucent"===t.renderPass&&i.paint.get("fill-antialias")){const n=t.depthModeForSublayer(i.getPaintProperty("fill-outline-color")?2:0,df.ReadOnly);hg(t,e,i,r,n,o,!0)}},"fill-extrusion":function(t,e,i,r){const n=i.paint.get("fill-extrusion-opacity");if(0!==n&&"translucent"===t.renderPass){const s=new df(t.context.gl.LEQUAL,df.ReadWrite,t.depthRangeFor3D);if(1!==n||i.paint.get("fill-extrusion-pattern").constantOr(1))ug(t,e,i,r,s,mf.disabled,_f.disabled),ug(t,e,i,r,s,t.stencilModeFor3D(),t.colorModeForRenderPass()),t.resetStencilClippingMasks();else{const n=t.colorModeForRenderPass();ug(t,e,i,r,s,mf.disabled,n)}}},hillshade:function(t,e,i,r){if("offscreen"!==t.renderPass&&"translucent"!==t.renderPass)return;const n=t.context,s=t.depthModeForSublayer(0,df.ReadOnly),o=t.colorModeForRenderPass(),a=t.terrain&&t.terrain.renderingToTexture,[l,c]="translucent"!==t.renderPass||a?[{},r]:t.stencilConfigForOverlap(r);for(const r of c){const n=e.getTile(r);if(n.needsHillshadePrepare&&"offscreen"===t.renderPass)u_(t,n,i,s,mf.disabled,o);else if("translucent"===t.renderPass){const e=a&&t.terrain?t.terrain.stencilModeForRTTOverlap(r):l[r.overscaledZ];c_(t,r,n,i,s,e,o)}}n.viewport.set([0,0,t.width,t.height]),t.resetStencilClippingMasks()},raster:function(t,e,i,r,n,s){if("translucent"!==t.renderPass)return;if(0===i.paint.get("raster-opacity"))return;if(!r.length)return;const o=t.context,a=o.gl,l=e.getSource(),c=t.useProgram("raster"),h=t.colorModeForRenderPass(),u=t.terrain&&t.terrain.renderingToTexture,[p,d]=l instanceof Pf||u?[{},r]:t.stencilConfigForOverlap(r),f=d[d.length-1].overscaledZ,m=!t.options.moving;for(const r of d){const n=u?df.disabled:t.depthModeForSublayer(r.overscaledZ-f,1===i.paint.get("raster-opacity")?df.ReadWrite:df.ReadOnly,a.LESS),d=r.toUnwrapped(),_=e.getTile(r);if(u&&(!_||!_.hasData()))continue;const g=u?r.projMatrix:t.transform.calculateProjMatrix(d,m),y=t.terrain&&u?t.terrain.stencilModeForRTTOverlap(r):p[r.overscaledZ],x=s?0:i.paint.get("raster-fade-duration");_.registerFadeDuration(x);const v=e.findLoadedParent(r,0),b=v_(_,v,e,t.transform,x);let w,T;t.terrain&&t.terrain.prepareDrawTile();const E="nearest"===i.paint.get("raster-resampling")?a.NEAREST:a.LINEAR;o.activeTexture.set(a.TEXTURE0),_.texture.bind(E,a.CLAMP_TO_EDGE),o.activeTexture.set(a.TEXTURE1),v?(v.texture.bind(E,a.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,a.CLAMP_TO_EDGE);const I=W_(g,T||[0,0],w||1,b,i,l instanceof Pf?l.perspectiveTransform:[0,0]);if(t.prepareDrawProgram(o,c,d),l instanceof Pf)l.boundsBuffer&&l.boundsSegments&&c.draw(o,a.TRIANGLES,n,mf.disabled,h,xf.disabled,I,i.id,l.boundsBuffer,t.quadTriangleIndexBuffer,l.boundsSegments);else{const{tileBoundsBuffer:e,tileBoundsIndexBuffer:r,tileBoundsSegments:s}=t.getTileBoundsBuffers(_);c.draw(o,a.TRIANGLES,n,y,h,xf.disabled,I,i.id,e,r,s)}}t.resetStencilClippingMasks()},background:function(t,e,i,r){const n=i.paint.get("background-color"),s=i.paint.get("background-opacity");if(0===s)return;const o=t.context,a=o.gl,l=t.transform,c=l.tileSize,h=i.paint.get("background-pattern");if(t.isPatternMissing(h))return;const u=!h&&1===n.a&&1===s&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==u)return;const p=mf.disabled,d=t.depthModeForSublayer(0,"opaque"===u?df.ReadWrite:df.ReadOnly),f=t.colorModeForRenderPass(),m=t.useProgram(h?"backgroundPattern":"background");let _,g=r;g||(_=t.getBackgroundTiles(),g=Object.values(_).map((t=>t.tileID))),h&&(o.activeTexture.set(a.TEXTURE0),t.imageManager.bind(t.context));const y=i.getCrossfadeParameters();for(const u of g){const g=u.toUnwrapped(),x=r?u.projMatrix:t.transform.calculateProjMatrix(g);t.prepareDrawTile();const v=e?e.getTile(u):_?_[u.key]:new dd(u,c,l.zoom,t),b=h?tg(x,s,t,h,{tileID:u,tileSize:c},y):Q_(x,s,n);t.prepareDrawProgram(o,m,g);const{tileBoundsBuffer:w,tileBoundsIndexBuffer:T,tileBoundsSegments:E}=t.getTileBoundsBuffers(v);m.draw(o,a.TRIANGLES,d,p,f,xf.disabled,b,i.id,w,T,E)}},sky:function(t,e,i){const r=t.transform,n="mercator"===r.projection.name||"globe"===r.projection.name?1:b(7,8,r.zoom),s=i.paint.get("sky-opacity")*n;if(0===s)return;const o=t.context,a=i.paint.get("sky-type"),l=new df(o.gl.LEQUAL,df.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===a?"offscreen"===t.renderPass?i.needsSkyboxCapture(t)&&(function(t,e,i,r){const n=t.context,s=n.gl;let o=e.skyboxFbo;if(!o){o=e.skyboxFbo=n.createFramebuffer(32,32,!1),e.skyboxGeometry=new Ig(n),e.skyboxTexture=n.gl.createTexture(),s.bindTexture(s.TEXTURE_CUBE_MAP,e.skyboxTexture),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MAG_FILTER,s.LINEAR);for(let t=0;t<6;++t)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,s.RGBA,32,32,0,s.RGBA,s.UNSIGNED_BYTE,null)}n.bindFramebuffer.set(o.framebuffer),n.viewport.set([0,0,32,32]);const a=e.getCenter(t,!0),l=t.useProgram("skyboxCapture"),c=new Float64Array(16);rl(c),cl(c,c,.5*-Math.PI),Sg(n,e,l,c,a,0),rl(c),cl(c,c,.5*Math.PI),Sg(n,e,l,c,a,1),rl(c),ll(c,c,.5*-Math.PI),Sg(n,e,l,c,a,2),rl(c),ll(c,c,.5*Math.PI),Sg(n,e,l,c,a,3),rl(c),Sg(n,e,l,c,a,4),rl(c),cl(c,c,Math.PI),Sg(n,e,l,c,a,5),n.viewport.set([0,0,t.width,t.height])}(t,i),i.markSkyboxValid(t)):"sky"===t.renderPass&&function(t,e,i,r,n){const s=t.context,o=s.gl,a=t.transform,l=t.useProgram("skybox");s.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_CUBE_MAP,e.skyboxTexture);const c=((t,e,i,r,n)=>({u_matrix:t,u_sun_direction:e,u_cubemap:0,u_opacity:r,u_temporal_offset:n}))(a.skyboxMatrix,e.getCenter(t,!1),0,r,n);t.prepareDrawProgram(s,l),l.draw(s,o.TRIANGLES,i,mf.disabled,t.colorModeForRenderPass(),xf.backCW,c,"skybox",e.skyboxGeometry.vertexBuffer,e.skyboxGeometry.indexBuffer,e.skyboxGeometry.segment)}(t,i,l,s,c):"gradient"===a&&"sky"===t.renderPass&&function(t,e,i,r,n){const s=t.context,o=s.gl,a=t.transform,l=t.useProgram("skyboxGradient");e.skyboxGeometry||(e.skyboxGeometry=new Ig(s)),s.activeTexture.set(o.TEXTURE0);let c=e.colorRampTexture;c||(c=e.colorRampTexture=new qu(s,e.colorRamp,o.RGBA)),c.bind(o.LINEAR,o.CLAMP_TO_EDGE);const h=((t,e,i,r,n)=>({u_matrix:t,u_color_ramp:0,u_center_direction:e,u_radius:p(i),u_opacity:r,u_temporal_offset:n}))(a.skyboxMatrix,e.getCenter(t,!1),e.paint.get("sky-gradient-radius"),r,n);t.prepareDrawProgram(s,l),l.draw(s,o.TRIANGLES,i,mf.disabled,t.colorModeForRenderPass(),xf.backCW,h,"skyboxGradient",e.skyboxGeometry.vertexBuffer,e.skyboxGeometry.indexBuffer,e.skyboxGeometry.segment)}(t,i,l,s,c)},debug:function(t,e,i){for(let r=0;r<i.length;r++)bg(t,e,i[r])},custom:function(t,e,i){const r=t.context,n=i.implementation;if(t.transform.projection.unsupportedLayers&&t.transform.projection.unsupportedLayers.includes("custom"))O("Custom layers are not yet supported with non-mercator projections. Use mercator to enable custom layers.");else if("offscreen"===t.renderPass){const e=n.prerender;e&&(t.setCustomLayerDefaults(),r.setColorMode(t.colorModeForRenderPass()),e.call(n,r.gl,t.transform.customLayerMatrix()),r.setDirty(),t.setBaseState())}else if("translucent"===t.renderPass){t.setCustomLayerDefaults(),r.setColorMode(t.colorModeForRenderPass()),r.setStencilMode(mf.disabled);const e="3d"===n.renderingMode?new df(t.context.gl.LEQUAL,df.ReadWrite,t.depthRangeFor3D):t.depthModeForSublayer(0,df.ReadOnly);r.setDepthMode(e),n.render(r.gl,t.transform.customLayerMatrix()),r.setDirty(),t.setBaseState(),r.bindFramebuffer.set(null)}}};class Cg{constructor(t,e){this.context=new vf(t),this.transform=e,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.setup(),this.numSublayers=bf.maxUnderzooming+bf.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new $m,this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this._tileClippingMaskIDs=new Map,this._skippedStencilTileIDs=new Set}updateTerrain(t,e){const i=!!t&&!!t.terrain&&this.transform.projection.supportsTerrain;if(!(i||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new E_(this,t));const r=this._terrain;this.transform.elevation=i?r:null,r.update(t,this.transform,e)}_updateFog(t){const e=t.fog;if(!e||e.getOpacity(this.transform.pitch)<1||e.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[i,r]=e.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(t,e){if(this.width=t*J.devicePixelRatio,this.height=e*J.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const t of this.style.order)this.style._layers[t].resize()}setup(){const t=this.context,e=new Ps;e.emplaceBack(0,0),e.emplaceBack(la,0),e.emplaceBack(0,la),e.emplaceBack(la,la),this.tileExtentBuffer=t.createVertexBuffer(e,rd.members),this.tileExtentSegments=aa.simpleSegment(0,0,4,2);const i=new Ps;i.emplaceBack(0,0),i.emplaceBack(la,0),i.emplaceBack(0,la),i.emplaceBack(la,la),this.debugBuffer=t.createVertexBuffer(i,rd.members),this.debugSegments=aa.simpleSegment(0,0,4,5);const r=new Ps;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(-1,1),r.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(r,rd.members),this.viewportSegments=aa.simpleSegment(0,0,4,2);const n=new Bs;n.emplaceBack(0,0,0,0),n.emplaceBack(la,0,la,0),n.emplaceBack(0,la,0,la),n.emplaceBack(la,la,la,la),this.mercatorBoundsBuffer=t.createVertexBuffer(n,ud.members),this.mercatorBoundsSegments=aa.simpleSegment(0,0,4,2);const s=new $s;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(s);const o=new to;for(const t of[0,1,3,2,0])o.emplaceBack(t);this.debugIndexBuffer=t.createIndexBuffer(o),this.emptyTexture=new qu(t,new ec({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA),this.identityMat=il();const a=this.context.gl;this.stencilClearMode=new mf({func:a.ALWAYS,mask:0},0,255,a.ZERO,a.ZERO,a.ZERO),this.loadTimeStamps.push(l.performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(t){return t._makeTileBoundsBuffers(this.context,this.transform.projection),t._tileBoundsBuffer?{tileBoundsBuffer:t._tileBoundsBuffer,tileBoundsIndexBuffer:t._tileBoundsIndexBuffer,tileBoundsSegments:t._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const t=this.context,e=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs.clear(),this._skippedStencilTileIDs.clear(),this.useProgram("clippingMask").draw(t,e.TRIANGLES,df.disabled,this.stencilClearMode,_f.disabled,xf.disabled,x_(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs.clear(),this._skippedStencilTileIDs.clear())}_renderTileClippingMasks(t,e,i){if(!e||this.currentStencilSource===e.id||!t.isTileClipped()||!i||0===i.length)return;const r=[];let n=!1;if(this._tileClippingMaskIDs&&!this.terrain){for(const s of i)if(this._tileClippingMaskIDs.has(s.key)||(n=!0),this._skippedStencilTileIDs.has(s.key)){if(!e.getTile(s).getBucket(t))continue;this._skippedStencilTileIDs.delete(s.key),r.push(s)}if(!n&&0===r.length)return}const s=this.context,o=s.gl;s.setColorMode(_f.disabled),s.setDepthMode(df.disabled);const a=this.useProgram("clippingMask"),l=t=>{const i=e.getTile(t),{tileBoundsBuffer:r,tileBoundsIndexBuffer:n,tileBoundsSegments:l}=this.getTileBoundsBuffers(i);a.draw(s,o.TRIANGLES,df.disabled,new mf({func:o.GREATER,mask:255},this._tileClippingMaskIDs.get(t.key)||0,255,o.KEEP,o.KEEP,o.REPLACE),_f.disabled,xf.disabled,x_(t.projMatrix),"$clipping",r,n,l)};if(!n&&r.length>0)for(const t of r)l(t);else{(0===this._tileClippingMaskIDs.size||this.nextStencilID+i.length>256)&&this.clearStencil(),this._tileClippingMaskIDs.clear(),this._skippedStencilTileIDs.clear();for(const r of i)this._tileClippingMaskIDs.set(r.key,this.nextStencilID++),e.getTile(r).getBucket(t)?l(r):this._skippedStencilTileIDs.add(r.key)}0===this._skippedStencilTileIDs.size&&(this.currentStencilSource=e.id)}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,e=this.context.gl;return new mf({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)}stencilModeForClipping(t){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(t);const e=this.context.gl;return new mf({func:e.EQUAL,mask:255},this._tileClippingMaskIDs.get(t.key)||0,0,e.KEEP,e.KEEP,e.REPLACE)}stencilConfigForOverlap(t){const e=this.context.gl,i=t.sort(((t,e)=>e.overscaledZ-t.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 t={};for(let i=0;i<n;i++)t[i+r]=new mf({func:e.GEQUAL,mask:255},i+this.nextStencilID,255,e.KEEP,e.KEEP,e.REPLACE);return this.nextStencilID+=n,[t,i]}return[{[r]:mf.disabled},i]}colorModeForRenderPass(){const t=this.context.gl;if(this._showOverdrawInspector){const e=1/8;return new _f([t.CONSTANT_COLOR,t.ONE],new Le(e,e,e,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?_f.unblended:_f.alphaBlended}depthModeForSublayer(t,e,i){if(!this.opaquePassEnabledForLayer())return df.disabled;const r=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new df(i||this.context.gl.LEQUAL,e,[r,r])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,e){this.style=t,this.options=e,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(J.now()),this.imageManager.beginFrame();const i=this.style.order,r=this.style._sourceCaches;for(const t in r){const e=r[t];e.used&&e.prepare(this.context)}const n={},s={},o={};for(const t in r){const e=r[t];n[t]=e.getVisibleCoordinates(),s[t]=n[t].slice().reverse(),o[t]=e.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let t=0;t<i.length;t++)if(this.style._layers[i[t]].is3D()){this.opaquePassCutoff=t;break}if(this.terrain&&(this.terrain.updateTileBinding(o),this.opaquePassCutoff=0),"globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new Vp(this.context)),!Rt.has(this.context.gl))return;this.renderPass="offscreen";for(const e of i){const i=this.style._layers[e],r=t._getLayerSourceCache(i);if(!i.hasOffscreenPass()||i.isHidden(this.transform.zoom))continue;const n=r?s[r.id]:void 0;("custom"===i.type||i.isSky()||n&&n.length)&&this.renderLayer(this,r,i,n)}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]);let a=Le.transparent;if(this.style.fog&&this.style.fog.getOpacity(this.transform.pitch)&&(a=this.style.fog.properties.get("color")),this.context.clear({color:e.showOverdrawInspector?Le.black:a,depth:1}),this.clearStencil(),this._showOverdrawInspector=e.showOverdrawInspector,this.renderPass="opaque",!this.terrain)for(this.currentLayer=i.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[i[this.currentLayer]],r=t._getLayerSourceCache(e);if(e.isSky())continue;const n=r?s[r.id]:void 0;this._renderTileClippingMasks(e,r,n),this.renderLayer(this,r,e,n)}if(this.renderPass="sky",(Pp(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer<i.length;this.currentLayer++){const e=this.style._layers[i[this.currentLayer]],r=t._getLayerSourceCache(e);e.isSky()&&this.renderLayer(this,r,e,r?s[r.id]:void 0)}for("globe"===this.transform.projection.name&&function(t){const e=t.context,i=e.gl,r=t.transform,n=new df(i.LEQUAL,df.ReadOnly,[0,1]),s=t.useProgram("globeAtmosphere"),o=r.centerOffset,a=r._camera.getCameraToClipPerspective(r._fov,r.width/r.height,r._nearZ,r._farZ);a[8]=2*-o.x/r.width,a[9]=2*o.y/r.height;const l=nl([],a),c=fl([],l,r.projMatrix),h={u_frustum_tl:Ag([-1,1,1],l),u_frustum_tr:Ag([1,1,1],l),u_frustum_br:Ag([1,-1,1],l),u_frustum_bl:Ag([-1,-1,1],l),u_globe_pos:Ag([r.globeMatrix[12],r.globeMatrix[13],r.globeMatrix[14]],c),u_globe_radius:r.worldSize/2/Math.PI-1,u_opacity:1-Pp(r.zoom),u_fadeout_range:2,u_start_color:[1,1,1],u_end_color:[.0118,.7451,.9882]};t.prepareDrawProgram(e,s);const u=t.globeSharedBuffers;u&&s.draw(e,i.TRIANGLES,n,mf.disabled,_f.alphaBlended,xf.backCW,h,"skybox",u.atmosphereVertexBuffer,u.atmosphereIndexBuffer,u.atmosphereSegments)}(this),this.renderPass="translucent",this.currentLayer=0;this.currentLayer<i.length;){const e=this.style._layers[i[this.currentLayer]],r=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 a=r?("symbol"===e.type?o:s)[r.id]:void 0;this._renderTileClippingMasks(e,r,r?n[r.id]:void 0),this.renderLayer(this,r,e,a),++this.currentLayer}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry){let e=null;E(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&&zg.debug(this,e,e.getVisibleCoordinates())}this.options.showPadding&&function(t){const e=t.transform.padding;yg(t,t.transform.height-(e.top||0),3,dg),yg(t,e.bottom||0,3,fg),xg(t,e.left||0,3,mg),xg(t,t.transform.width-(e.right||0),3,_g);const i=t.transform.centerPoint;!function(t,e,i,r){vg(t,e-1,i-10,2,20,r),vg(t,e-10,i-1,20,2,r)}(t,i.x,t.transform.height-i.y,gg)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(l.performance.now()),this.saveCanvasCopy())}renderLayer(t,e,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),t.transform.projection.unsupportedLayers&&t.transform.projection.unsupportedLayers.includes(i.type)||zg[i.type](t,e,i,r,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(t){if(!this.options.gpuTiming)return;const e=this.context.extTimerQuery;let i=this.gpuTimers[t.id];i||(i=this.gpuTimers[t.id]={calls:0,cpuTime:0,query:e.createQueryEXT()}),i.calls++,e.beginQueryEXT(e.TIME_ELAPSED_EXT,i.query)}gpuTimingEnd(){if(!this.options.gpuTiming)return;const t=this.context.extTimerQuery;t.endQueryEXT(t.TIME_ELAPSED_EXT)}collectGpuTimers(){const t=this.gpuTimers;return this.gpuTimers={},t}queryGpuTimers(t){const e={};for(const i in t){const r=t[i],n=this.context.extTimerQuery,s=n.getQueryObjectEXT(r.query,n.QUERY_RESULT_EXT)/1e6;n.deleteQueryEXT(r.query),e[i]=s}return e}translatePosMatrix(t,e,i,r,n){if(!i[0]&&!i[1])return t;const s=n?"map"===r?this.transform.angle:0:"viewport"===r?-this.transform.angle:0;if(s){const t=Math.sin(s),e=Math.cos(s);i=[i[0]*e-i[1]*t,i[0]*t+i[1]*e]}const o=[n?i[0]:lp(e,i[0],this.transform.zoom),n?i[1]:lp(e,i[1],this.transform.zoom),0],a=new Float32Array(16);return ol(a,t,o),a}saveTileTexture(t){const e=this._tileTextures[t.size[0]];e?e.push(t):this._tileTextures[t.size[0]]=[t]}getTileTexture(t){const e=this._tileTextures[t];return e&&e.length>0?e.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const e=this.imageManager.getPattern(t.from.toString()),i=this.imageManager.getPattern(t.to.toString());return!e||!i}currentGlobalDefines(){const t=this.terrain&&this.terrain.renderingToTexture,e=this.style&&this.style.fog,i=[];return this.terrain&&!this.terrain.renderingToTexture&&i.push("TERRAIN"),e&&!t&&0!==e.getOpacity(this.transform.pitch)&&i.push("FOG"),t&&i.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&i.push("OVERDRAW_INSPECTOR"),i}useProgram(t,e,i){this.cache=this.cache||{};const r=i||[],n=this.currentGlobalDefines().concat(r),s=S_.cacheKey(t,n,e);return this.cache[s]||(this.cache[s]=new S_(this.context,t,s_[t],e,eg[t],n)),this.cache[s]}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 t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=l.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new qu(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}prepareDrawProgram(t,e,i){if(this.terrain&&this.terrain.renderingToTexture)return;const r=this.style.fog;if(r){const n=r.getOpacity(this.transform.pitch);0!==n&&e.setFogUniformValues(t,((t,e,i,r)=>{const n=e.properties.get("color"),s=t.frameCounter/1e3%1,o=[n.r/n.a,n.g/n.a,n.b/n.a,r];return{u_fog_matrix:i?t.transform.calculateFogTileMatrix(i):t.identityMat,u_fog_range:e.getFovAdjustedRange(t.transform._fov),u_fog_color:o,u_fog_horizon_blend:e.properties.get("horizon-blend"),u_fog_temporal_offset:s}})(this,r,i,n))}}setTileLoadedFlag(t){this.tileLoaded=t}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const t=this.context.gl,e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.copyTexImage2D(t.TEXTURE_2D,0,t.RGBA,0,0,t.drawingBufferWidth,t.drawingBufferHeight,0),e}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const t=this.style&&this.style.fog;return!!t&&0!==t.getOpacity(this.transform.pitch)}getBackgroundTiles(){const t=this._backgroundTiles,e=this._backgroundTiles={},i=this.transform.coveringTiles({tileSize:512});for(const r of i)e[r.key]=t[r.key]||new dd(r,512,this.transform.tileZoom,this);return e}clearBackgroundTiles(){this._backgroundTiles={}}}function Mg(t,e){const i=t.fovAboveCenter,r=t.elevation?t.elevation.getMinElevationBelowMSL()*e:0,n=(t._camera.position[2]*t.worldSize-r)/Math.cos(t._pitch),s=Math.sin(i)*n/Math.sin(Math.max(Math.PI/2-t._pitch-i,.01)),o=Math.sin(t._pitch)*s+n;return Math.min(1.01*o,n*(1/t._horizonShift))}const kg=rl(new Float32Array(16));class Pg{constructor(t){this.name=t.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(t,e){return{x:0,y:0,z:0}}unproject(t,e){return new ua(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e){return t._coordinatePoint(t.locationCoordinate(e),!1)}pixelsPerMeter(t,e){return _a(1,t)*e}farthestPixelDistance(t){return Mg(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,r){const n=t.horizonLineFromTop(!1),s=new o(e,Math.max(n,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(s,r))}createInversionMatrix(t,e){return kg}createTileMatrix(t,e,i){let r,n,s;const o=i.canonical,a=rl(new Float64Array(16));if(this.isReprojectedInTileSpace){const l=Gp(o,this);r=1,n=l.x+i.wrap*l.scale,s=l.y,al(a,a,[r/l.scale,r/l.scale,t.pixelsPerMeter/e])}else r=e/t.zoomScale(o.z),n=(o.x+Math.pow(2,o.z)*i.wrap)*r,s=o.y*r;return ol(a,a,[n,s,0]),al(a,a,[r/la,r/la,1]),a}upVector(t,e,i){return[0,0,1]}upVectorScale(t,e,i){return{metersToTile:1,metersToLabelSpace:1}}}class Dg extends Pg{constructor(t){super(t),this.range=[4,7],this.center=t.center||[-96,37.5];const[e,i]=this.parallels=t.parallels||[29.5,45.5],r=Math.sin(p(e));this.n=(r+Math.sin(p(i)))/2,this.c=1+r*(2*this.n-r),this.r0=Math.sqrt(this.c)/this.n}project(t,e){const{n:i,c:r,r0:n}=this,s=p(t-this.center[0]),o=p(e),a=Math.sqrt(r-2*i*Math.sin(o))/i;return{x:a*Math.sin(s*i),y:a*Math.cos(s*i)-n,z:0}}unproject(t,e){const{n:i,c:r,r0:n}=this,s=n+e;let o=Math.atan2(t,Math.abs(s))*Math.sign(s);s*i<0&&(o-=Math.PI*Math.sign(t)*Math.sign(s));const a=p(this.center[0])*i;o=w(o,-Math.PI-a,Math.PI-a);const l=d(o/i)+this.center[0],c=Math.asin(v((r-(t*t+s*s)*i*i)/(2*i),-1,1)),h=v(d(c),-85.051129,va);return new ua(l,h)}}const Bg=1.340264,Lg=-.081106,Rg=893e-6,Fg=.003796,Og=Math.sqrt(3)/2;class Vg extends Pg{project(t,e){e=e/180*Math.PI,t=t/180*Math.PI;const i=Math.asin(Og*Math.sin(e)),r=i*i,n=r*r*r;return{x:.5*(t*Math.cos(i)/(Og*(Bg+3*Lg*r+n*(7*Rg+9*Fg*r)))/Math.PI+.5),y:1-.5*(i*(Bg+Lg*r+n*(Rg+Fg*r))/Math.PI+1),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI;let i=e=(2*(1-e)-1)*Math.PI,r=i*i,n=r*r*r;for(let t,s,o,a=0;a<12&&(s=i*(Bg+Lg*r+n*(Rg+Fg*r))-e,o=Bg+3*Lg*r+n*(7*Rg+9*Fg*r),t=s/o,i=v(i-t,-Math.PI/3,Math.PI/3),r=i*i,n=r*r*r,!(Math.abs(t)<1e-12));++a);const s=Og*t*(Bg+3*Lg*r+n*(7*Rg+9*Fg*r))/Math.cos(i),o=Math.asin(Math.sin(i)/Og),a=v(180*s/Math.PI,-180,180),l=v(180*o/Math.PI,-85.051129,va);return new ua(a,l)}}class jg extends Pg{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){return{x:.5+t/360,y:.5-e/360,z:0}}unproject(t,e){const i=360*(t-.5),r=v(360*(.5-e),-85.051129,va);return new ua(i,r)}}const Ug=Math.PI/2;function Ng(t){return Math.tan((Ug+t)/2)}class Zg extends Pg{constructor(t){super(t),this.center=t.center||[0,30];const[e,i]=this.parallels=t.parallels||[30,30],r=p(e),n=p(i),s=Math.cos(r);this.n=r===n?Math.sin(r):Math.log(s/Math.cos(n))/Math.log(Ng(n)/Ng(r)),this.f=s*Math.pow(Ng(r),this.n)/this.n}project(t,e){e=p(e),t=p(t-this.center[0]);const i=1e-6,{n:r,f:n}=this;n>0?e<-Ug+i&&(e=-Ug+i):e>Ug-i&&(e=Ug-i);const s=n/Math.pow(Ng(e),r),o=s*Math.sin(r*t),a=n-s*Math.cos(r*t);return{x:.5*(o/Math.PI+.5),y:1-.5*(a/Math.PI+.5),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,e=(2*(1-e)-.5)*Math.PI;const{n:i,f:r}=this,n=r-e,s=Math.sign(n),o=Math.sign(i)*Math.sqrt(t*t+n*n);let a=Math.atan2(t,Math.abs(n))*s;n*i<0&&(a-=Math.PI*Math.sign(t)*s);const l=v(d(a/i)+this.center[0],-180,180),c=v(d(2*Math.atan(Math.pow(r/o,1/i))-Ug),-85.051129,va);return new ua(l,c)}}class qg extends Pg{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(t,e){return{x:fa(t),y:ma(e),z:0}}unproject(t,e){const i=ga(t),r=ya(e);return new ua(i,r)}}const Gg=p(va);class $g extends Pg{project(t,e){const i=(e=p(e))*e,r=i*i;return{x:.5*((t=p(t))*(.8707-.131979*i+r*(r*(.003971*i-.001529*r)-.013791))/Math.PI+.5),y:1-.5*(e*(1.007226+i*(.015085+r*(.028874*i-.044475-.005916*r)))/Math.PI+1),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI;let i=e=(2*(1-e)-1)*Math.PI,r=25,n=0,s=i*i;do{s=i*i;const t=s*s;n=(i*(1.007226+s*(.015085+t*(.028874*s-.044475-.005916*t)))-e)/(1.007226+s*(.045255+t*(.259866*s-.311325-.005916*11*t))),i=v(i-n,-Gg,Gg)}while(Math.abs(n)>1e-6&&--r>0);s=i*i;const o=v(d(t/(.8707+s*(s*(s*s*s*(.003971-.001529*s)-.013791)-.131979))),-180,180),a=d(i);return new ua(o,a)}}const Wg=p(va);class Xg extends Pg{project(t,e){e=p(e),t=p(t);const i=Math.cos(e),r=2/Math.PI,n=Math.acos(i*Math.cos(t/2)),s=Math.sin(n)/n,o=.5*(t*r+2*i*Math.sin(t/2)/s)||0,a=.5*(e+Math.sin(e)/s)||0;return{x:.5*(o/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,r=e=(2*(1-e)-1)*Math.PI,n=25;const s=1e-6;let o=0,a=0;do{const n=Math.cos(r),s=Math.sin(r),l=2*s*n,c=s*s,h=n*n,u=Math.cos(i/2),p=Math.sin(i/2),d=2*u*p,f=p*p,m=1-h*u*u,_=m?1/m:0,g=m?Math.acos(n*u)*Math.sqrt(1/m):0,y=.5*(2*g*n*p+2*i/Math.PI)-t,x=.5*(g*s+r)-e,b=.5*_*(h*f+g*n*u*c)+1/Math.PI,w=_*(d*l/4-g*s*p),T=.125*_*(l*p-g*s*h*d),E=.5*_*(c*u+g*f*n)+.5,I=w*T-E*b;o=(x*w-y*E)/I,a=(y*T-x*b)/I,i=v(i-o,-Math.PI,Math.PI),r=v(r-a,-Wg,Wg)}while((Math.abs(o)>s||Math.abs(a)>s)&&--n>0);return new ua(d(i),d(r))}}class Hg extends Pg{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(p(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){const{scale:i,cosPhi:r}=this;return{x:p(t)*r*i+.5,y:-Math.sin(p(e))/r*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:r}=this,n=-(e-.5)/i,s=v(d((t-.5)/i)/r,-180,180),o=Math.asin(v(n*r,-1,1)),a=v(d(o),-85.051129,va);return new ua(s,a)}}const Kg=2*_a(1,0)*pp*Math.PI;class Yg extends qg{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!1,this.zAxisUnit="pixels",this.unsupportedLayers=["debug","custom"]}projectTilePoint(t,e,i){const r=Math.pow(2,i.z),n=(t/la+i.x)/r,s=Tp(ya((e/la+i.y)/r),ga(n));return Cl(s,s,Sp(xp(i))),{x:s[0],y:s[1],z:s[2]}}locationPoint(t,e){const i=Tp(e.lat,e.lng),r=Sl([],i),n=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude;Il(i,i,r,_a(1,0)*la*n);const s=rl(new Float64Array(16));return sl(s,t.pixelMatrix,t.globeMatrix),Cl(i,i,s),new o(i[0],i[1])}pixelsPerMeter(t,e){return _a(1,0)*e}createTileMatrix(t,e,i){const r=Ap(xp(i.canonical));return sl(new Float64Array(16),t.globeMatrix,r)}createInversionMatrix(t,e){const{center:i,worldSize:r}=t,n=zp(r),s=rl(new Float64Array(16));sl(s,s,Sp(xp(e))),cl(s,s,p(i.lng)),ll(s,s,p(i.lat)),al(s,s,[1/n,1/n,1]);const o=t.pixelsPerMeter/_a(1,i.lat)/la;return al(s,s,[o,o,1]),Float32Array.from(s)}pointCoordinate(t,e,i,r){const n=El([],t._camera.position,t.worldSize),s=[e,i,1,1];Ol(s,s,t.pixelMatrixInverse),Fl(s,s,1/s[3]);const o=Sl([],Dl([],s,n)),a=t.globeMatrix,l=[a[12],a[13],a[14]],c=Dl([],l,n),h=gl(c),u=Sl([],c),p=t.worldSize/(2*Math.PI),f=Al(u,o),m=Math.asin(p/h);if(m<Math.acos(f)){const t=[],e=[];El(t,o,h/f),Sl(e,Dl(e,t,c)),Sl(o,xl(o,c,El(o,e,Math.tan(m)*h)))}const _=[];new Nl(n,o).closestPointOnSphere(l,p,_);const g=Sl([],K(a,0)),y=Sl([],K(a,1)),x=Sl([],K(a,2)),b=Al(g,_),w=Al(y,_),T=Al(x,_),E=d(Math.asin(-w/p));let I=d(Math.atan2(b,T));I=t.center.lng+function(t,e){const i=(e-t+180)%360-180;return i<-180?i+360:i}(t.center.lng,I);const S=fa(I),A=v(ma(E),0,1);return new ba(S,A)}farthestPixelDistance(t){const e=function(t,e){const i=t.cameraToCenterDistance,r=t._centerAltitude*e,n=t._camera,s=t._camera.forward(),o=xl([],El([],s,-i),[0,0,r]),a=t.worldSize/(2*Math.PI),l=[0,0,-a],c=t.width/t.height,h=Math.tan(t.fovAboveCenter),u=El([],n.up(),h),p=El([],n.right(),h*c),d=Sl([],xl([],xl([],s,u),p)),f=[];let m;if(new Nl(o,d).closestPointOnSphere(l,a,f)){const e=xl([],f,l),i=Dl([],e,o);m=Math.cos(t.fovAboveCenter)*gl(i)}else{const t=Dl([],o,l),e=Dl([],l,o);Sl(e,e);const i=gl(t)-a;m=Math.sqrt(i*i+2*a*i);const r=Math.acos(m/(a+i))-Math.acos(Al(s,e));m*=Math.cos(r)}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),i=Pp(t.zoom);return i>0?Ai(e,Mg(t,_a(1,t.center.lat)*t.worldSize),i):e}upVector(t,e,i){const r=1<<t.z,n=(e/la+t.x)/r;return Tp(ya((i/la+t.y)/r),ga(n),1)}upVectorScale(t,e,i){const r=_a(1,e)*i;return{metersToTile:Kg*Ip(xp(t)),metersToLabelSpace:r}}}class Jg{constructor(t=0,e=0,i=0,r=0){if(isNaN(t)||t<0||isNaN(e)||e<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=t,this.bottom=e,this.left=i,this.right=r}interpolate(t,e,i){return null!=e.top&&null!=t.top&&(this.top=Ai(t.top,e.top,i)),null!=e.bottom&&null!=t.bottom&&(this.bottom=Ai(t.bottom,e.bottom,i)),null!=e.left&&null!=t.left&&(this.left=Ai(t.left,e.left,i)),null!=e.right&&null!=t.right&&(this.right=Ai(t.right,e.right,i)),this}getCenter(t,e){const i=v((this.left+t-this.right)/2,0,t),r=v((this.top+e-this.bottom)/2,0,e);return new o(i,r)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Jg(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Qg(t,e){const i=K(t,3);ul(t,e),Y(t,3,i)}function ty(t,e){const i=jl([]);return function(t,e,i){i*=.5;var r=e[0],n=e[1],s=e[2],o=e[3],a=Math.sin(i),l=Math.cos(i);t[0]=r*l+n*a,t[1]=n*l-r*a,t[2]=s*l+o*a,t[3]=o*l-s*a}(i,i,-e),Ul(i,i,-t),i}function ey(t,e){const i=[t[0],t[1],0],r=[e[0],e[1],0];if(gl(i)>=1e-15){const t=Sl([],i);El(r,t,Al(r,t)),e[0]=r[0],e[1]=r[1]}const n=zl([],e,t);if(Rl(n)<1e-15)return null;const s=Math.atan2(-n[1],n[0]);return ty(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),s)}class iy{constructor(t,e){this.position=t,this.orientation=e}get position(){return this._position}set position(t){if(t){const e=t instanceof ba?t:new ba(t[0],t[1],t[2]);this._renderWorldCopies&&(e.x=w(e.x,0,1)),this._position=e}else this._position=null}lookAtPoint(t,e){if(this.orientation=null,!this.position)return;const i=this._elevation?this._elevation.getAtPointOrZero(ba.fromLngLat(t)):0,r=this.position,n=ba.fromLngLat(t,i),s=[n.x-r.x,n.y-r.y,n.z-r.z];e||(e=[0,0,1]),e[2]=Math.abs(e[2]),this.orientation=ey(s,e)}setPitchBearing(t,e){this.orientation=ty(p(t),p(-e))}}class ry{constructor(t,e){this._transform=rl([]),this.orientation=e,this.position=t}get mercatorPosition(){const t=this.position;return new ba(t[0],t[1],t[2])}get position(){const t=K(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var e;t&&Y(this._transform,3,[(e=t)[0],e[1],e[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||jl([]),t&&Qg(this._transform,this._orientation)}getPitchBearing(){const t=this.forward(),e=this.right();return{bearing:Math.atan2(-e[1],e[0]),pitch:Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2])}}setPitchBearing(t,e){this._orientation=ty(t,e),Qg(this._transform,this._orientation)}forward(){const t=K(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){const t=K(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){const t=K(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,e){const i=new Float64Array(16);return nl(i,this.getWorldToCamera(t,e)),i}getWorldToCameraPosition(t,e,i){const r=this.position;El(r,r,-t);const n=new Float64Array(16);var s,o;return(s=n)[0]=(o=[i,i,i])[0],s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=o[1],s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=o[2],s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,ol(n,n,r),n[10]*=e,n}getWorldToCamera(t,e){const i=new Float64Array(16),r=new Float64Array(4),n=this.position;var s,o;return(s=r)[0]=-(o=this._orientation)[0],s[1]=-o[1],s[2]=-o[2],s[3]=o[3],El(n,n,-t),ul(i,r),ol(i,i,n),i[1]*=-1,i[5]*=-1,i[9]*=-1,i[13]*=-1,i[8]*=e,i[9]*=e,i[10]*=e,i[11]*=e,i}getCameraToClipPerspective(t,e,i,r){const n=new Float64Array(16);return pl(n,t,e,i,r),n}getDistanceToElevation(t){const e=0===t?0:_a(t,this.position[1]),i=this.forward();return(e-this.position[2])/i[2]}clone(){return new ry([...this.position],[...this.orientation])}}function ny(t,e){const i=oy(t),r=function(t,e,i,r,n){const s=new ua(i.lng-180*ay,i.lat),o=new ua(i.lng+180*ay,i.lat),a=t.project(s.lng,s.lat),l=t.project(o.lng,o.lat),c=-Math.atan2(l.y-a.y,l.x-a.x),h=ba.fromLngLat(i);h.y=v(h.y,-.999975,.999975);const u=h.toLngLat(),p=t.project(u.lng,u.lat),d=ba.fromLngLat(u);d.x+=ay;const f=d.toLngLat(),m=t.project(f.lng,f.lat),_=cy(m.x-p.x,m.y-p.y,c),g=ba.fromLngLat(u);g.y+=ay;const y=g.toLngLat(),x=t.project(y.lng,y.lat),b=cy(x.x-p.x,x.y-p.y,c),w=Math.abs(_.x)/Math.abs(b.y),T=rl([]);hl(T,T,-c*(1-(n?0:r)));const E=rl([]);return al(E,E,[1,1-(1-w)*r,1]),E[4]=-b.x/b.y*r,hl(E,E,c),sl(E,T,E),E}(t.projection,0,t.center,i,e),n=sy(t);return al(r,r,[n,n,1]),r}function sy(t){const e=t.projection,i=oy(t),r=ly(e,t.center),n=ly(e,ua.convert(e.center));return Math.pow(2,r*i+(1-i)*n)}function oy(t){const e=t.projection.range;if(!e)return 0;const i=Math.max(t.width,t.height),r=Math.log(i/1024)/Math.LN2;return b(e[0]+r,e[1]+r,t.zoom)}const ay=1/4e4;function ly(t,e){const i=v(e.lat,-85.051129,va),r=new ua(e.lng-180*ay,i),n=new ua(e.lng+180*ay,i),s=t.project(r.lng,i),o=t.project(n.lng,i),a=ba.fromLngLat(r),l=ba.fromLngLat(n),c=o.x-s.x,h=o.y-s.y,u=l.x-a.x,p=l.y-a.y,d=Math.sqrt((u*u+p*p)/(c*c+h*h));return Math.log(d)/Math.LN2}function cy(t,e,i){const r=Math.cos(i),n=Math.sin(i);return{x:t*r-e*n,y:t*n+e*r}}class hy{constructor(t,e,i,r,n,s,o){this.tileSize=512,this._renderWorldCopies=void 0===n||n,this._minZoom=t||0,this._maxZoom=e||22,this._minPitch=null==i?0:i,this._maxPitch=null==r?60:r,this.setProjection(s),this.setMaxBounds(o),this.width=0,this.height=0,this._center=new ua(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 Jg,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new ry,this._centerAltitude=0,this._centerAltitudeValid=!1,this._averageElevation=0,this.cameraElevationReference="ground",this._projectionScaler=1,this._horizonShift=.1}clone(){const t=new hy(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return t._elevation=this._elevation,t._centerAltitude=this._centerAltitude,t._centerAltitudeValid=this._centerAltitudeValid,t.tileSize=this.tileSize,t.width=this.width,t.height=this.height,t.cameraElevationReference=this.cameraElevationReference,t._center=this._center,t._setZoom(this.zoom),t._seaLevelZoom=this._seaLevelZoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._nearZ=this._nearZ,t._farZ=this._farZ,t._averageElevation=this._averageElevation,t._unmodified=this._unmodified,t._edgeInsets=this._edgeInsets.clone(),t._camera=this._camera.clone(),t._calcMatrices(),t.freezeTileCoverage=this.freezeTileCoverage,t}get elevation(){return this._elevation}set elevation(t){this._elevation!==t&&(this._elevation=t,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(t){null==this._seaLevelZoom&&this._updateCameraOnTerrain(),t&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return S(this.projection,["name","center","parallels"])}setProjection(t){null==t&&(t={name:"mercator"}),this.projectionOptions=t;const e=this.projection?this.getProjection():void 0;this.projection=function(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])<.01;switch(t.name){case"mercator":return new qg(t);case"equirectangular":return new jg(t);case"naturalEarth":return new $g(t);case"equalEarth":return new Vg(t);case"winkelTripel":return new Xg(t);case"albers":return i?new Hg(t):new Dg(t);case"lambertConformalConic":return i?new Hg(t):new Zg(t);case"globe":return new Yg(t)}throw new Error(`Invalid projection name: ${t.name}`)}(t);const i=this.getProjection();return c(e,i)?null:(this._calcMatrices(),i)}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){const t=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(t))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.cameraWorldSize)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new o(this.width,this.height)}get bearing(){return w(this.rotation,-180,180)}set bearing(t){this.rotation=t}get rotation(){return-this.angle/Math.PI*180}set rotation(t){const e=-t*Math.PI/180;var i;this.angle!==e&&(this._unmodified=!1,this.angle=e,this._calcMatrices(),this.rotationMatrix=(i=new Ya(4),Ya!=Float32Array&&(i[1]=0,i[2]=0),i[0]=1,i[3]=1,i),function(t,e,i){var r=e[0],n=e[1],s=e[2],o=e[3],a=Math.sin(i),l=Math.cos(i);t[0]=r*l+s*a,t[1]=n*l+o*a,t[2]=r*-a+s*l,t[3]=n*-a+o*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const e=v(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==e&&(this._unmodified=!1,this._pitch=e,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(t){this._averageElevation=t,this._calcFogMatrices()}get zoom(){return this._zoom}set zoom(t){const e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._setZoom(e),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(t){this._zoom=t,this.scale=this.zoomScale(t),this.tileZoom=Math.floor(t),this.zoomFraction=t-this.tileZoom}_updateCameraOnTerrain(){if(!this._elevation||!this._elevation.isDataAvailableAtPoint(this.locationCoordinate(this.center)))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValid=!1);this._centerAltitude=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValid=!0,this._updateSeaLevelZoom()}_updateSeaLevelZoom(){this._centerAltitudeValid&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const t=this._elevation,e=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],i=this.horizonLineFromTop();let r=0,n=0;for(let s=0;s<e.length;s++){const a=new o(e[s][0]*this.width,i+e[s][1]*(this.height-i)),l=t.pointCoordinate(a);if(!l)continue;const c=1/Math.hypot(l[0]-this._camera.position[0],l[1]-this._camera.position[1]);r+=l[3]*c,n+=c}return 0===n?NaN:r/n}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._terrainEnabled()&&("ground"===this.cameraElevationReference?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(null==this._seaLevelZoom||!this._elevation)return;const t=this._seaLevelZoom,e=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),i=this.pixelsPerMeter/this.worldSize*e,r=this._mercatorZfromZoom(t),n=this._mercatorZfromZoom(this._maxZoom),s=Math.max(r-i,n);this._setZoom(this._zoomFromMercatorZ(s))}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}computeZoomRelativeTo(t){const e=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,t.toAltitude()));let i;i=t.z<this._camera.position[2]?[e.x,e.y,e.z]:[t.x,t.y,t.z];const r=gl(Dl([],this._camera.position,i));return v(this._zoomFromMercatorZ(r),this._minZoom,this._maxZoom)}setFreeCameraOptions(t){if(!this.height)return;if(!t.position&&!t.orientation)return;this._updateCameraState();let e=!1;if(t.orientation&&!function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}(t.orientation,this._camera.orientation)&&(e=this._setCameraOrientation(t.orientation)),t.position){const n=[t.position.x,t.position.y,t.position.z];((i=n)[0]!==(r=this._camera.position)[0]||i[1]!==r[1]||i[2]!==r[2])&&(this._setCameraPosition(n),e=!0)}var i,r;e&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const t=this._camera.position,e=new iy;return e.position=new ba(t[0],t[1],t[2]),e.orientation=this._camera.orientation,e._elevation=this.elevation,e._renderWorldCopies=this.renderWorldCopies,e}_setCameraOrientation(t){if(e=t,!Math.hypot(e[0],e[1],e[2],e[3]))return!1;var e;!function(t,e){var i=e[0],r=e[1],n=e[2],s=e[3],o=i*i+r*r+n*n+s*s;o>0&&(o=1/Math.sqrt(o)),t[0]=i*o,t[1]=r*o,t[2]=n*o,t[3]=s*o}(t,t);const i=kl([],[0,0,-1],t),r=kl([],[0,-1,0],t);if(r[2]<0)return!1;const n=ey(i,r);return!!n&&(this._camera.orientation=n,!0)}_setCameraPosition(t){const e=this.zoomScale(this.minZoom)*this.tileSize,i=this.zoomScale(this.maxZoom)*this.tileSize,r=this.cameraToCenterDistance;t[2]=v(t[2],r/i,r/e),this._camera.position=t}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,e,i){this._unmodified=!1,this._edgeInsets.interpolate(t,e,i),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){const e=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,e)}getVisibleUnwrappedCoordinates(t){const e=[new Np(0,t)];if(this.renderWorldCopies){const i=this.pointCoordinate(new o(0,0)),r=this.pointCoordinate(new o(this.width,0)),n=this.pointCoordinate(new o(this.width,this.height)),s=this.pointCoordinate(new o(0,this.height)),a=Math.floor(Math.min(i.x,r.x,n.x,s.x)),l=Math.floor(Math.max(i.x,r.x,n.x,s.x)),c=1;for(let i=a-c;i<=l+c;i++)0!==i&&e.push(new Np(i,t))}return e}coveringTiles(t){let e=this.coveringZoomLevel(t);const i=e,r=this.elevation&&!t.isTerrainDEM,n="mercator"===this.projection.name;if(void 0!==t.minzoom&&e<t.minzoom)return[];void 0!==t.maxzoom&&e>t.maxzoom&&(e=t.maxzoom);const s=this.locationCoordinate(this.center),o=this.center.lat,a=1<<e,l=[a*s.x,a*s.y,0],c="globe"===this.projection.name,h=!c,u=Zl.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,e,h),p=c?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),d=a*_a(1,this.center.lat),m=this._camera.position[2]/_a(1,this.center.lat),_=[a*p.x,a*p.y,m*(h?1:d)],g=this.cameraToCenterDistance/t.tileSize*(t.roundZoom?1:.502),y=this.pitch<=60&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace?e:0,x=t.isTerrainDEM&&this._elevation?1e4*this._elevation.exaggeration():this._centerAltitude,v=t.isTerrainDEM?-x:this._elevation?this._elevation.getMinElevationBelowMSL():0,b=this.projection.isReprojectedInTileSpace?sy(this):1,w=t=>{const e=1/4e4,i=new ba(t.x+e,t.y,t.z),r=new ba(t.x,t.y+e,t.z),n=t.toLngLat(),s=i.toLngLat(),o=r.toLngLat(),a=this.locationCoordinate(n),l=this.locationCoordinate(s),c=this.locationCoordinate(o),h=Math.hypot(l.x-a.x,l.y-a.y),u=Math.hypot(c.x-a.x,c.y-a.y);return Math.sqrt(h*u)*b/e},T=t=>{const e=x,i=v;return{aabb:$p(this,a,0,0,0,t,i,e,this.projection),zoom:0,x:0,y:0,minZ:i,maxZ:e,wrap:t,fullyVisible:!1}},E=[];let I=[];const S=e,A=t.reparseOverscaled?i:e,z=t=>t*t,C=z((m-this._centerAltitude)*d),M=t=>{if(!this._elevation||!t.tileID||!n)return;const e=this._elevation.getMinMaxForTile(t.tileID),i=t.aabb;e?(i.min[2]=e.min,i.max[2]=e.max,i.center[2]=(i.min[2]+i.max[2])/2):(t.shouldSplit=k(t),t.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude))},k=t=>{if(t.zoom<y)return!0;if(t.zoom===S)return!1;if(null!=t.shouldSplit)return t.shouldSplit;const e=t.aabb.distanceX(_),n=t.aabb.distanceY(_);let s=C,a=1;if(c){s=z(t.aabb.distanceZ(_));const e=Math.pow(2,t.zoom),i=ya((t.y+1)/e),r=ya(t.y/e),n=da(Math.min(Math.max(o,i),r))/da(o);a=Math.min(n,1)}else if(r&&(s=z(t.aabb.distanceZ(_)*d)),this.projection.isReprojectedInTileSpace&&i<=5){const e=Math.pow(2,t.zoom),i=w(new ba((t.x+.5)/e,(t.y+.5)/e));a=i>.85?1:i}const l=e*e+n*n+s;return l<z((1<<S-t.zoom)*g*a*((t,e)=>{if(e*z(.707)<t)return 1;const i=Math.sqrt(e/t);return i/(1.4144271570014144+(Math.pow(1.1,i-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(s,C),l))};if(this.renderWorldCopies)for(let t=1;t<=3;t++)E.push(T(-t)),E.push(T(t));for(E.push(T(0));E.length>0;){const i=E.pop(),s=i.x,o=i.y;let h=i.fullyVisible;if(!h){const t=i.aabb.intersects(u);if(0===t)continue;h=2===t}if(i.zoom!==S&&k(i))for(let t=0;t<4;t++){const e=(s<<1)+t%2,l=(o<<1)+(t>>1),u={aabb:n?i.aabb.quadrant(t):$p(this,a,i.zoom+1,e,l,i.wrap,i.minZ,i.maxZ,this.projection),zoom:i.zoom+1,x:e,y:l,wrap:i.wrap,fullyVisible:h,tileID:void 0,shouldSplit:void 0,minZ:i.minZ,maxZ:i.maxZ};r&&!c&&(u.tileID=new Zp(i.zoom+1===S?A:i.zoom+1,i.wrap,i.zoom+1,e,l),M(u)),E.push(u)}else{const r=i.zoom===S?A:i.zoom;if(t.minzoom&&t.minzoom>r)continue;const n=l[0]-(.5+s+(i.wrap<<i.zoom))*(1<<e-i.zoom),a=l[1]-.5-o,c=i.tileID?i.tileID:new Zp(r,i.wrap,i.zoom,s,o);I.push({tileID:c,distanceSq:n*n+a*a})}}if(this.fogCullDistSq){const e=this.fogCullDistSq,i=this.horizonLineFromTop();I=I.filter((r=>{const n=[0,0,0,1],s=[la,la,0,1],o=this.calculateFogTileMatrix(r.tileID.toUnwrapped());Ol(n,n,o),Ol(s,s,o);const a=function(t,e,i){let r=0;for(let i=0;i<2;++i){const n=0;t[i]>n&&(r+=(t[i]-n)*(t[i]-n)),e[i]<n&&(r+=(n-e[i])*(n-e[i]))}return r}(n,s);if(0===a)return!0;let l=!1;const c=this._elevation;if(c&&a>e&&0!==i){const e=this.calculateProjMatrix(r.tileID.toUnwrapped());let n;t.isTerrainDEM||(n=c.getMinMaxForTile(r.tileID)),n||(n={min:v,max:x});const s=function(t){const e=Math.round((t+45+360)%360/90)%4;return f[e]}(this.rotation),o=[s[0]*la,s[1]*la,n.max];Cl(o,o,e),l=(1-o[1])*this.height*.5<i}return a<e||l}))}return I.sort(((t,e)=>t.distanceSq-e.distanceSq)).map((t=>t.tileID))}resize(t,e){this.width=t,this.height=e,this.pixelsToGLUnits=[2/t,-2/e],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(t){const e=v(t.lat,-85.051129,va),i=this.projection.project(t.lng,e);return new o(i.x*this.worldSize,i.y*this.worldSize)}unproject(t){return this.projection.unproject(t.x/this.worldSize,t.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(t,e){let i,r;const n=this.centerPoint;if("globe"===this.projection.name){const t=this.worldSize;i=(e.x-n.x)/t,r=(e.y-n.y)/t}else{const t=this.pointCoordinate(e),s=this.pointCoordinate(n);i=t.x-s.x,r=t.y-s.y}const s=this.locationCoordinate(t);this.setLocation(new ba(s.x-i,s.y-r))}setLocation(t){this.center=this.coordinateLocation(t),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(t){return this.projection.locationPoint(this,t)}locationPoint3D(t){return this._coordinatePoint(this.locationCoordinate(t),!0)}pointLocation(t){return this.coordinateLocation(this.pointCoordinate(t))}pointLocation3D(t){return this.coordinateLocation(this.pointCoordinate3D(t))}locationCoordinate(t,e){const i=e?_a(e,t.lat):void 0,r=this.projection.project(t.lng,t.lat);return new ba(r.x,r.y,i)}coordinateLocation(t){return this.projection.unproject(t.x,t.y)}pointRayIntersection(t,e){const i=null!=e?e:this._centerAltitude,r=[t.x,t.y,0,1],n=[t.x,t.y,1,1];Ol(r,r,this.pixelMatrixInverse),Ol(n,n,this.pixelMatrixInverse);const s=n[3];Fl(r,r,1/r[3]),Fl(n,n,1/s);const o=r[2],a=n[2];return{p0:r,p1:n,t:o===a?0:(i-o)/(a-o)}}screenPointToMercatorRay(t){const e=[t.x,t.y,0,1],i=[t.x,t.y,1,1];return Ol(e,e,this.pixelMatrixInverse),Ol(i,i,this.pixelMatrixInverse),Fl(e,e,1/e[3]),Fl(i,i,1/i[3]),e[2]=_a(e[2],this._center.lat)*this.worldSize,i[2]=_a(i[2],this._center.lat)*this.worldSize,Fl(e,e,1/this.worldSize),Fl(i,i,1/this.worldSize),new Nl([e[0],e[1],e[2]],Sl([],Dl([],i,e)))}rayIntersectionCoordinate(t){const{p0:e,p1:i,t:r}=t,n=_a(e[2],this._center.lat),s=_a(i[2],this._center.lat);return new ba(Ai(e[0],i[0],r)/this.worldSize,Ai(e[1],i[1],r)/this.worldSize,Ai(n,s,r))}pointCoordinate(t,e=this._centerAltitude){return this.projection.pointCoordinate(this,t.x,t.y,e)}pointCoordinate3D(t){if(!this.elevation)return this.pointCoordinate(t);const e=this.elevation;let i=this.elevation.pointCoordinate(t);if(i)return new ba(i[0],i[1],i[2]);let r=0,n=this.horizonLineFromTop();if(t.y>n)return this.pointCoordinate(t);const s=.02*n,o=t.clone();for(let t=0;t<10&&n-r>s;t++){o.y=Ai(r,n,.66);const t=e.pointCoordinate(o);t?(n=o.y,i=t):r=o.y}return i?new ba(i[0],i[1],i[2]):this.pointCoordinate(t)}isPointAboveHorizon(t){if(this.elevation)return!this.elevation.pointCoordinate(t);{const e=this.horizonLineFromTop();return t.y<e}}_coordinatePoint(t,e){const i=e&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,r=[t.x*this.worldSize,t.y*this.worldSize,i+t.toAltitude(),1];return Ol(r,r,this.pixelMatrix),r[3]>0?new o(r[0]/r[3],r[1]/r[3]):new o(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(t,e){const i=new o(this._edgeInsets.left,this._edgeInsets.top),r=new o(this.width-this._edgeInsets.right,this._edgeInsets.top),n=new o(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),s=new o(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let a=this.pointCoordinate(i,t),l=this.pointCoordinate(r,t);const c=this.pointCoordinate(n,e),h=this.pointCoordinate(s,e),u=(t,e)=>(e.y-t.y)/(e.x-t.x);return a.y>1&&l.y>=0?a=new ba((1-h.y)/u(h,a)+h.x,1):a.y<0&&l.y<=1&&(a=new ba(-h.y/u(h,a)+h.x,0)),l.y>1&&a.y>=0?l=new ba((1-c.y)/u(c,l)+c.x,1):l.y<0&&a.y<=1&&(l=new ba(-c.y/u(c,l)+c.x,0)),(new ca).extend(this.coordinateLocation(a)).extend(this.coordinateLocation(l)).extend(this.coordinateLocation(h)).extend(this.coordinateLocation(c))}_getBounds3D(){const t=this.elevation;if(!t.visibleDemTiles.length)return this._getBounds(0,0);const e=t.visibleDemTiles.reduce(((t,e)=>{if(e.dem){const i=e.dem.tree;t.min=Math.min(t.min,i.minimums[0]),t.max=Math.max(t.max,i.maximums[0])}return t}),{min:Number.MAX_VALUE,max:0});return this._getBounds(e.min*t.exaggeration(),e.max*t.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(t=!0){const e=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,i=this.height/2-e*(1-this._horizonShift);return t?Math.max(0,i):i}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-85.051129,this.maxLat=va,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=fa(this.minLng)*this.tileSize,this.worldMaxX=fa(this.maxLng)*this.tileSize,this.worldMinY=ma(this.maxLat)*this.tileSize,this.worldMaxY=ma(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(t,e){return this.projection.createTileMatrix(this,e,t)}calculateDistanceTileData(t){const e=t.key,i=this._distanceTileDataCache;if(i[e])return i[e];const r=t.canonical,n=1/this.height,s=this.cameraWorldSize/this.zoomScale(r.z),o=(r.x+Math.pow(2,r.z)*t.wrap)*s,a=r.y*s,l=this.point,c=this.angle,h=Math.sin(-c),u=-Math.cos(-c);return i[e]={bearing:[h,u],center:[(l.x-o)*n,(l.y-a)*n],scale:s/la*n},i[e]}calculateFogTileMatrix(t){const e=t.key,i=this._fogTileMatrixCache;if(i[e])return i[e];const r=this.calculatePosMatrix(t,this.cameraWorldSize);return sl(r,this.worldToFogMatrix,r),i[e]=new Float32Array(r),i[e]}calculateProjMatrix(t,e=!1){const i=t.key,r=e?this._alignedProjMatrixCache:this._projMatrixCache;if(r[i])return r[i];const n=this.calculatePosMatrix(t,this.worldSize);return sl(n,this.projection.isReprojectedInTileSpace?this.mercatorMatrix:e?this.alignedProjMatrix:this.projMatrix,n),r[i]=new Float32Array(n),r[i]}calculatePixelsToTileUnitsMatrix(t){const e=t.tileID.key,i=this._pixelsToTileUnitsCache;if(i[e])return i[e];const r=function(t,e){const{scale:i}=t.tileTransform,r=i*la/(t.tileSize*Math.pow(2,e.zoom-t.tileID.overscaledZ+t.tileID.canonical.z));return function(t,e,i){var r=e[1],n=e[2],s=e[3],o=i[0],a=i[1];return t[0]=e[0]*o,t[1]=r*o,t[2]=n*a,t[3]=s*a,t}(new Float32Array(4),e.inverseAdjustmentMatrix,[r,r])}(t,this);return i[e]=r,i[e]}customLayerMatrix(){return this.mercatorMatrix.slice()}recenterOnTerrain(){if(!this._elevation)return;const t=this._elevation;this._updateCameraState();const e=_a(1,this._center.lat)*this.worldSize,i=this._computeCameraPosition(e),r=this._camera.forward(),n=_a(1,this._center.lat);i[2]/=n,r[2]/=n,Sl(r,r);const s=t.raycast(i,r,t.exaggeration());if(s){const t=Il([],i,r,s),e=new ba(t[0],t[1],_a(t[2],ya(t[1]))),o=(e.z+gl([e.x-i[0],e.y-i[1],e.z-i[2]*n]))*this._projectionScaler;this._seaLevelZoom=this._zoomFromMercatorZ(o),this._centerAltitude=e.toAltitude(),this._center=this.coordinateLocation(e),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCameraAltitude(){if(!this._elevation)return;const t=this._elevation;this._updateCameraState();const e=_a(1,this._center.lat)*this.worldSize,i=this._computeCameraPosition(e),r=t.getAtPointOrZero(new ba(...i)),n=this._minimumHeightOverTerrain()*Math.cos(p(this._maxPitch)),s=this._camera.position[2]-this.pixelsPerMeter/this.worldSize*r;if(s<n){const t=this.locationCoordinate(this._center,this._centerAltitude),e=[t.x-i[0],t.y-i[1],t.z-i[2]],r=gl(e);e[2]-=(n-s)/this._projectionScaler;const o=gl(e);if(0===o)return;El(e,e,r/o*this._projectionScaler),this._camera.position=[t.x-e[0],t.y-e[1],t.z*this._projectionScaler-e[2]],this._camera.orientation=ey(e,this._camera.up()),this._updateStateFromCamera()}}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;if(this._constraining=!0,this.projection.isReprojectedInTileSpace){const t=this.center;return t.lat=v(t.lat,this.minLat,this.maxLat),!this.maxBounds&&this.renderWorldCopies||(t.lng=v(t.lng,this.minLng,this.maxLng)),this.center=t,void(this._constraining=!1)}const t=this._unmodified,{x:e,y:i}=this.point;let r=0,n=e,s=i;const a=this.width/2,l=this.height/2,c=this.worldMinY*this.scale,h=this.worldMaxY*this.scale;if(i-l<c&&(s=c+l),i+l>h&&(s=h-l),h-c<this.height&&(r=Math.max(r,this.height/(h-c)),s=(h+c)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const t=this.worldMinX*this.scale,i=this.worldMaxX*this.scale,s=this.worldSize/2-(t+i)/2;n=(e+s+this.worldSize)%this.worldSize-s,n-a<t&&(n=t+a),n+a>i&&(n=i-a),i-t<this.width&&(r=Math.max(r,this.width/(i-t)),n=(i+t)/2)}n===e&&s===i||(this.center=this.unproject(new o(n,s))),r&&(this.zoom+=this.scaleZoom(r)),this._constrainCameraAltitude(),this._unmodified=t,this._constraining=!1}_minZoomForBounds(){let t=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(t=Math.max(t,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),t}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const t=this._fov/2,e=this.centerOffset,i=this.pixelsPerMeter;this._projectionScaler=i/(_a(1,this.center.lat)*this.worldSize),this.cameraToCenterDistance=.5/Math.tan(t)*this.height*this._projectionScaler,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const r=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?i: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 s=fl([],n,r);if(this.projection.isReprojectedInTileSpace){const t=this.locationCoordinate(this.center),e=rl([]);ol(e,e,[t.x*this.worldSize,t.y*this.worldSize,0]),sl(e,e,ny(this)),ol(e,e,[-t.x*this.worldSize,-t.y*this.worldSize,0]),sl(s,s,e),this.inverseAdjustmentMatrix=function(t){const e=ny(t,!0);return Ja([],[e[0],e[1],e[4],e[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];this.mercatorMatrix=al([],s,[this.worldSize,this.worldSize,this.worldSize/i,1]),this.projMatrix=s,this.invProjMatrix=nl(new Float64Array(16),this.projMatrix);const o=new Float32Array(16);rl(o),al(o,o,[1,-1,1]),ll(o,o,this._pitch),hl(o,o,this.angle);const a=pl(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ),l=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;a[8]=2*-e.x/this.width,a[9]=2*(e.y+l)/this.height,this.skyboxMatrix=sl(o,a,o);const c=this.point,h=c.x,u=c.y,p=this.width%2/2,d=this.height%2/2,f=Math.cos(this.angle),m=Math.sin(this.angle),_=h-Math.round(h)+f*p+m*d,g=u-Math.round(u)+f*d+m*p,y=new Float64Array(s);if(ol(y,y,[_>.5?_-1:_,g>.5?g-1:g,0]),this.alignedProjMatrix=y,s=il(),al(s,s,[this.width/2,-this.height/2,1]),ol(s,s,[1,-1,0]),this.labelPlaneMatrix=s,s=il(),al(s,s,[1,-1,1]),ol(s,s,[-1,-1,0]),al(s,s,[2/this.width,2/this.height,1]),this.glCoordMatrix=s,this.pixelMatrix=sl(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},s=nl(new Float64Array(16),this.pixelMatrix),!s)throw new Error("failed to invert matrix");this.pixelMatrixInverse=s,this.globeMatrix="globe"===this.projection.name?kp(this):s,this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSize,e=this.cameraPixelsPerMeter,i=this._camera.position,r=1/this.height,n=[t,t,e];El(n,n,r),El(i,i,-1),bl(i,i,n);const s=il();ol(s,s,i),al(s,s,n),this.mercatorFogMatrix=s,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,e,r)}_computeCameraPosition(t){const e=(t=t||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),r=this.point,n=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*e-t/this.worldSize*this._centerAltitude;return[r.x/this.worldSize-i[0]*n,r.y/this.worldSize-i[1]*n,t/this.worldSize*this._centerAltitude-i[2]*n]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(t){const e=this._maxCameraBoundsDistance()*Math.cos(this._pitch),i=t[2];let r=1;i>0&&(r=Math.min((e-this._camera.position[2])/i,1)),this._camera.position=Il([],this._camera.position,t,r),this._updateStateFromCamera(),this.projection.wrap&&(this.center=this.center.wrap())}_updateStateFromCamera(){const t=this._camera.position,e=this._camera.forward(),{pitch:i,bearing:r}=this._camera.getPitchBearing(),n=_a(this._centerAltitude,this.center.lat)*this._projectionScaler,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(p(this._maxPitch)),o=Math.max((t[2]-n)/Math.cos(i),s),a=this._zoomFromMercatorZ(o);Il(t,t,e,o),this._pitch=v(i,p(this.minPitch),p(this.maxPitch)),this.angle=w(r,-Math.PI,Math.PI),this._setZoom(v(a,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new ba(t[0],t[1],t[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(t){return Math.pow(2,t)*this.tileSize}_mercatorZfromZoom(t){return this.cameraToCenterDistance/this._worldSizeFromZoom(t)}_minimumHeightOverTerrain(){const t=Math.min((null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(t)}_zoomFromMercatorZ(t){return this.scaleZoom(this.cameraToCenterDistance/(t*this.tileSize))}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(O("Terrain is not yet supported with alternate projections. Use mercator to enable terrain."),1))}anyCornerOffEdge(t,e){const i=Math.min(t.x,e.x),r=Math.max(t.x,e.x),n=Math.min(t.y,e.y),s=Math.max(t.y,e.y);if(n<this.horizonLineFromTop(!1))return!0;if("mercator"!==this.projection.name)return!1;const a=[new o(i,n),new o(r,s),new o(i,s),new o(r,n)],l=this.renderWorldCopies?-3:0,c=this.renderWorldCopies?4:1;for(const t of a){const e=this.pointRayIntersection(t);if(e.t<0)return!0;const i=this.rayIntersectionCoordinate(e);if(i.x<l||i.y<0||i.x>c||i.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+d(this.fovAboveCenter)>88||this.anyCornerOffEdge(new o(0,0),new o(this.width,this.height))}zoomDeltaToMovement(t,e){const i=gl(Dl([],this._camera.position,t)),r=this._zoomFromMercatorZ(i)+e;return i-this._mercatorZfromZoom(r)}getCameraPoint(){const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new o(0,t))}}function uy(t,e){let i=!1,r=null;const n=()=>{r=null,i&&(t(),r=setTimeout(n,e),i=!1)};return()=>(i=!0,r||n(),r)}class py{constructor(t){this._hashName=t&&encodeURIComponent(t),P(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=uy(this._updateHashUnthrottled.bind(this),300)}addTo(t){return this._map=t,l.addEventListener("hashchange",this._onHashChange,!1),t.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),l.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(t){const e=this._map;if(!e)return"";const i=e.getCenter(),r=Math.round(100*e.getZoom())/100,n=Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),s=Math.pow(10,n),o=Math.round(i.lng*s)/s,a=Math.round(i.lat*s)/s,c=e.getBearing(),h=e.getPitch();let u="";if(u+=t?`/${o}/${a}/${r}`:`${r}/${a}/${o}`,(c||h)&&(u+="/"+Math.round(10*c)/10),h&&(u+=`/${Math.round(h)}`),this._hashName){const t=this._hashName;let e=!1;const i=l.location.hash.slice(1).split("&").map((i=>{const r=i.split("=")[0];return r===t?(e=!0,`${r}=${u}`):i})).filter((t=>t));return e||i.push(`${t}=${u}`),`#${i.join("&")}`}return`#${u}`}_getCurrentHash(){const t=l.location.hash.replace("#","");if(this._hashName){let e;return t.split("&").map((t=>t.split("="))).forEach((t=>{t[0]===this._hashName&&(e=t)})),(e&&e[1]||"").split("/")}return t.split("/")}_onHashChange(){const t=this._map;if(!t)return!1;const e=this._getCurrentHash();if(e.length>=3&&!e.some((t=>isNaN(t)))){const i=t.dragRotate.isEnabled()&&t.touchZoomRotate.isEnabled()?+(e[3]||0):t.getBearing();return t.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:i,pitch:+(e[4]||0)}),!0}return!1}_updateHashUnthrottled(){const t=l.location.href.replace(/(#.+)?$/,this.getHashString());l.history.replaceState(l.history.state,null,t)}}const dy={linearity:.3,easing:y(0,0,.3,1)},fy=I({deceleration:2500,maxSpeed:1400},dy),my=I({deceleration:20,maxSpeed:1400},dy),_y=I({deceleration:1e3,maxSpeed:360},dy),gy=I({deceleration:1e3,maxSpeed:90},dy);class yy{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:J.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,e=J.now();for(;t.length>0&&e-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const e={zoom:0,bearing:0,pitch:0,pan:new o(0,0),pinchAround:void 0,around:void 0};for(const{settings:t}of this._inertiaBuffer)e.zoom+=t.zoomDelta||0,e.bearing+=t.bearingDelta||0,e.pitch+=t.pitchDelta||0,t.panDelta&&e.pan._add(t.panDelta),t.around&&(e.around=t.around),t.pinchAround&&(e.pinchAround=t.pinchAround);const i=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(e.pan.mag()){const n=vy(e.pan.mag(),i,I({},fy,t||{}));r.offset=e.pan.mult(n.amount/e.pan.mag()),r.center=this._map.transform.center,xy(r,n)}if(e.zoom){const t=vy(e.zoom,i,my);r.zoom=this._map.transform.zoom+t.amount,xy(r,t)}if(e.bearing){const t=vy(e.bearing,i,_y);r.bearing=this._map.transform.bearing+v(t.amount,-179,179),xy(r,t)}if(e.pitch){const t=vy(e.pitch,i,gy);r.pitch=this._map.transform.pitch+t.amount,xy(r,t)}if(r.zoom||r.bearing){const t=void 0===e.pinchAround?e.around:e.pinchAround;r.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),I(r,{noMoveStart:!0})}}function xy(t,e){(!t.duration||t.duration<e.duration)&&(t.duration=e.duration,t.easing=e.easing)}function vy(t,e,i){const{maxSpeed:r,linearity:n,deceleration:s}=i,o=v(t*n/(e/1e3),-r,r),a=Math.abs(o)/(s*n);return{easing:i.easing,duration:1e3*a,amount:o*(a/2)}}class by extends le{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i,r={}){const n=ct(e.getCanvasContainer(),i);super(t,I({point:n,lngLat:e.unproject(n),originalEvent:i},r)),this._defaultPrevented=!1,this.target=e}}class wy extends le{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i){const r="touchend"===t?i.changedTouches:i.touches,n=ht(e.getCanvasContainer(),r),s=n.map((t=>e.unproject(t))),a=n.reduce(((t,e,i,r)=>t.add(e.div(r.length))),new o(0,0));super(t,{points:n,point:a,lngLats:s,lngLat:e.unproject(a),originalEvent:i}),this._defaultPrevented=!1}}class Ty extends le{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i){super(t,{originalEvent:i}),this._defaultPrevented=!1}}class Ey{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){this._mousedownPos=void 0}wheel(t){return this._firePreventable(new Ty(t.type,this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new by(t.type,this._map,t))}mouseup(t){this._map.fire(new by(t.type,this._map,t))}preclick(t){const e=I({},t);e.type="preclick",this._map.fire(new by(e.type,this._map,e))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||(this.preclick(t),this._map.fire(new by(t.type,this._map,t)))}dblclick(t){return this._firePreventable(new by(t.type,this._map,t))}mouseover(t){this._map.fire(new by(t.type,this._map,t))}mouseout(t){this._map.fire(new by(t.type,this._map,t))}touchstart(t){return this._firePreventable(new wy(t.type,this._map,t))}touchmove(t){this._map.fire(new wy(t.type,this._map,t))}touchend(t){this._map.fire(new wy(t.type,this._map,t))}touchcancel(t){this._map.fire(new wy(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Iy{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(t){this._map.fire(new by(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new by("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._map.fire(new by(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Sy{constructor(t,e){this._map=t,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=e.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,e){this.isEnabled()&&t.shiftKey&&0===t.button&&(st(),this._startPos=this._lastPos=e,this._active=!0)}mousemoveWindow(t,e){if(!this._active)return;const i=e;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=Q("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",t));const n=Math.min(r.x,i.x),s=Math.max(r.x,i.x),o=Math.min(r.y,i.y),a=Math.max(r.y,i.y);this._map._requestDomTask((()=>{this._box&&(this._box.style.transform=`translate(${n}px,${o}px)`,this._box.style.width=s-n+"px",this._box.style.height=a-o+"px")}))}mouseupWindow(t,e){if(!this._active)return;if(0!==t.button)return;const i=this._startPos,r=e;if(this.reset(),lt(),i.x!==r.x||i.y!==r.y)return this._map.fire(new le("boxzoomend",{originalEvent:t})),{cameraAnimation:t=>t.fitScreenCoordinates(i,r,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),ot(),delete this._startPos,delete this._lastPos}_fireEvent(t,e){return this._map.fire(new le(t,{originalEvent:e}))}}function Ay(t,e){const i={};for(let r=0;r<t.length;r++)i[t[r].identifier]=e[r];return i}class zy{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(t,e,i){(this.centroid||i.length>this.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),i.length===this.numTouches&&(this.centroid=function(t){const e=new o(0,0);for(const i of t)e._add(i);return e.div(t.length)}(e),this.touches=Ay(i,e)))}touchmove(t,e,i){if(this.aborted||!this.centroid)return;const r=Ay(i,e);for(const t in this.touches){const e=this.touches[t],i=r[t];(!i||i.dist(e)>30)&&(this.aborted=!0)}}touchend(t,e,i){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}}class Cy{constructor(t){this.singleTap=new zy(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(t,e,i){this.singleTap.touchstart(t,e,i)}touchmove(t,e,i){this.singleTap.touchmove(t,e,i)}touchend(t,e,i){const r=this.singleTap.touchend(t,e,i);if(r){const e=t.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(e&&i||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class My{constructor(){this._zoomIn=new Cy({numTouches:1,numTaps:2}),this._zoomOut=new Cy({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,e,i){this._zoomIn.touchstart(t,e,i),this._zoomOut.touchstart(t,e,i)}touchmove(t,e,i){this._zoomIn.touchmove(t,e,i),this._zoomOut.touchmove(t,e,i)}touchend(t,e,i){const r=this._zoomIn.touchend(t,e,i),n=this._zoomOut.touchend(t,e,i);return r?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()+1,around:e.unproject(r)},{originalEvent:t})}):n?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()-1,around:e.unproject(n)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const ky={0:1,2:2};class Py{constructor(t){this.reset(),this._clickTolerance=t.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(t,e){return!1}_move(t,e){return{}}mousedown(t,e){if(this._lastPoint)return;const i=ut(t);this._correctButton(t,i)&&(this._lastPoint=e,this._eventButton=i)}mousemoveWindow(t,e){const i=this._lastPoint;if(i)if(t.preventDefault(),null!=this._eventButton&&function(t,e){const i=ky[e];return void 0===t.buttons||(t.buttons&i)!==i}(t,this._eventButton))this.reset();else if(this._moved||!(e.dist(i)<this._clickTolerance))return this._moved=!0,this._lastPoint=e,this._move(i,e)}mouseupWindow(t){this._lastPoint&&ut(t)===this._eventButton&&(this._moved&&lt(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Dy extends Py{mousedown(t,e){super.mousedown(t,e),this._lastPoint&&(this._active=!0)}_correctButton(t,e){return 0===e&&!t.ctrlKey}_move(t,e){return{around:e,panDelta:e.sub(t)}}}class By extends Py{_correctButton(t,e){return 0===e&&t.ctrlKey||2===e}_move(t,e){const i=.8*(e.x-t.x);if(i)return this._active=!0,{bearingDelta:i}}contextmenu(t){t.preventDefault()}}class Ly extends Py{_correctButton(t,e){return 0===e&&t.ctrlKey||2===e}_move(t,e){const i=-.5*(e.y-t.y);if(i)return this._active=!0,{pitchDelta:i}}contextmenu(t){t.preventDefault()}}class Ry{constructor(t,e){this._map=t,this._el=t.getCanvasContainer(),this._minTouches=1,this._clickTolerance=e.clickTolerance||1,this.reset(),P(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new o(0,0)}touchstart(t,e,i){return this._calculateTransform(t,e,i)}touchmove(t,e,i){if(this._active&&!(i.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(1===i.length)return void this._showTouchPanBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return t.preventDefault(),this._calculateTransform(t,e,i)}}touchend(t,e,i){this._calculateTransform(t,e,i),this._active&&i.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,e,i){i.length>0&&(this._active=!0);const r=Ay(i,e),n=new o(0,0),s=new o(0,0);let a=0;for(const t in r){const e=r[t],i=this._touches[t];i&&(n._add(e),s._add(e.sub(i)),a++,r[t]=e)}if(this._touches=r,a<this._minTouches||!s.mag())return;const l=s.div(a);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:n.div(a),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=Q("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(){"hidden"===this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show")}),500)}}class Fy{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(t){}_move(t,e,i){return{}}touchstart(t,e,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([e[0],e[1]]))}touchmove(t,e,i){const r=this._firstTwoTouches;if(!r)return;t.preventDefault();const[n,s]=r,o=Oy(i,e,n),a=Oy(i,e,s);if(!o||!a)return;const l=this._aroundCenter?null:o.add(a).div(2);return this._move([o,a],l,t)}touchend(t,e,i){if(!this._firstTwoTouches)return;const[r,n]=this._firstTwoTouches,s=Oy(i,e,r),o=Oy(i,e,n);s&&o||(this._active&&lt(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Oy(t,e,i){for(let r=0;r<t.length;r++)if(t[r].identifier===i)return e[r]}function Vy(t,e){return Math.log(t/e)/Math.LN2}class jy extends Fy{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,e){const i=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(Vy(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Vy(this._distance,i),pinchAround:e}}}function Uy(t,e){return 180*t.angleWith(e)/Math.PI}class Ny extends Fy{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,e){const i=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Uy(this._vector,i),pinchAround:e}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());const e=25/(Math.PI*this._minDiameter)*360,i=Uy(t,this._startVector);return Math.abs(i)<e}}function Zy(t){return Math.abs(t.y)>Math.abs(t.x)}class qy extends Fy{constructor(t){super(),this._map=t}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(t){this._lastPoints=t,Zy(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,e,i){const r=this._lastPoints;if(!r)return;const n=t[0].sub(r[0]),s=t[1].sub(r[1]);return this._map._cooperativeGestures&&i.touches.length<3||(this._valid=this.gestureBeginsVertically(n,s,i.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(n.y+s.y)/2*-.5})}gestureBeginsVertically(t,e,i){if(void 0!==this._valid)return this._valid;const r=t.mag()>=2,n=e.mag()>=2;if(!r&&!n)return;if(!r||!n)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const s=t.y>0==e.y>0;return Zy(t)&&Zy(e)&&s}}const Gy={panStep:100,bearingStep:15,pitchStep:10};class $y{constructor(){const t=Gy;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let e=0,i=0,r=0,n=0,s=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?i=-1:(t.preventDefault(),n=-1);break;case 39:t.shiftKey?i=1:(t.preventDefault(),n=1);break;case 38:t.shiftKey?r=1:(t.preventDefault(),s=-1);break;case 40:t.shiftKey?r=-1:(t.preventDefault(),s=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:o=>{const a=o.getZoom();o.easeTo({duration:300,easeId:"keyboardHandler",easing:Wy,zoom:e?Math.round(a)+e*(t.shiftKey?2:1):a,bearing:o.getBearing()+i*this._bearingStep,pitch:o.getPitch()+r*this._pitchStep,offset:[-n*this._panStep,-s*this._panStep],center:o.getCenter()},{originalEvent:t})}}}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 Wy(t){return t*(2-t)}const Xy=4.000244140625;class Hy{constructor(t,e){this._map=t,this._el=t.getCanvasContainer(),this._handler=e,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,P(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert","_isFullscreen"],this)}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&"center"===t.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()||this._isFullscreen()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let e=t.deltaMode===l.WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const i=J.now(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==e&&e%Xy==0?this._type="wheel":0!==e&&Math.abs(e)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=e,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(r*e)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,e+=this._lastValue)),t.shiftKey&&e&&(e/=4),this._type&&(this._lastWheelEvent=t,this._delta-=e,this._active||this._start(t)),t.preventDefault()}_onTimeout(t){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)}_start(t){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 e=ct(this._el,t);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:e,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 t=this._map.transform,e=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>Xy?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=e(),s=Math.pow(2,n),o="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):s;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(o*r))),"wheel"===this._type&&(this._startZoom=e(),this._easing=this._smoothOutEasing(200)),this._delta=0}const i="number"==typeof this._targetZoom?this._targetZoom:e(),r=this._startZoom,n=this._easing;let s,o=!1;if("wheel"===this._type&&r&&n){const t=Math.min((J.now()-this._lastWheelEventTime)/200,1);s=Ai(r,i,n(t)),t<1?this._frameId||(this._frameId=!0):o=!0}else s=i,o=!0;return this._active=!0,o&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!o,zoomDelta:s-e(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let e=x;if(this._prevEase){const t=this._prevEase,i=(J.now()-t.start)/t.duration,r=t.easing(i+.01)-t.easing(i),n=.27/Math.sqrt(r*r+1e-4)*.01;e=y(n,Math.sqrt(.0729-n*n),.25,1)}return this._prevEase={start:J.now(),duration:t,easing:e},e}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=Q("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(l.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_isFullscreen(){return!!l.document.fullscreenElement}_showBlockerAlert(){"hidden"===this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show")}),200)}}class Ky{constructor(t,e){this._clickZoom=t,this._tapZoom=e}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 Yy{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(t,e){return t.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(t.shiftKey?-1:1),around:i.unproject(e)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Jy{constructor(){this._tap=new Cy({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(t,e,i){this._swipePoint||(this._tapTime&&t.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=e[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(t,e,i))}touchmove(t,e,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=e[0],n=r.y-this._swipePoint.y;return this._swipePoint=r,t.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(t,e,i)}touchend(t,e,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(t,e,i)&&(this._tapTime=t.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Qy{constructor(t,e,i){this._el=t,this._mousePan=e,this._touchPan=i}enable(t){this._inertiaOptions=t||{},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 tx{constructor(t,e,i){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=e,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 ex{constructor(t,e,i,r){this._el=t,this._touchZoom=e,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),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 ix=t=>t.zoom||t.drag||t.pitch||t.rotate;class rx extends le{}class nx{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,e){const i=Dl([],e,t);this.radius=gl(i[2]<0?Ll([],i,this.constants):[i[0],i[1],0])}projectRay(t){Ll(t,t,this.constants),Sl(t,t),Bl(t,t,this.constants);const e=El([],t,this.radius);if(e[2]>0){const t=El([],[0,0,1],Al(e,[0,0,1])),i=El([],Sl([],[e[0],e[1],0]),this.radius),r=xl([],e,El([],Dl([],xl([],i,t),e),2));e[0]=r[0],e[1]=r[1]}return e}}function sx(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta}class ox{constructor(t,e){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new yy(t),this._bearingSnap=e.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new nx,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(e),P(["handleEvent","handleWindowEvent"],this);const i=this._el;this._listeners=[[i,"touchstart",{passive:!0}],[i,"touchmove",{passive:!1}],[i,"touchend",void 0],[i,"touchcancel",void 0],[i,"mousedown",void 0],[i,"mousemove",void 0],[i,"mouseup",void 0],[l.document,"mousemove",{capture:!0}],[l.document,"mouseup",void 0],[i,"mouseover",void 0],[i,"mouseout",void 0],[i,"dblclick",void 0],[i,"click",void 0],[i,"keydown",{capture:!1}],[i,"keyup",void 0],[i,"wheel",{passive:!1}],[i,"contextmenu",void 0],[l,"blur",void 0]];for(const[t,e,i]of this._listeners)t.addEventListener(e,t===l.document?this.handleWindowEvent:this.handleEvent,i)}destroy(){for(const[t,e,i]of this._listeners)t.removeEventListener(e,t===l.document?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(t){const e=this._map,i=e.getCanvasContainer();this._add("mapEvent",new Ey(e,t));const r=e.boxZoom=new Sy(e,t);this._add("boxZoom",r);const n=new My,s=new Yy;e.doubleClickZoom=new Ky(s,n),this._add("tapZoom",n),this._add("clickZoom",s);const o=new Jy;this._add("tapDragZoom",o);const a=e.touchPitch=new qy(e);this._add("touchPitch",a);const l=new By(t),c=new Ly(t);e.dragRotate=new tx(t,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const h=new Dy(t),u=new Ry(e,t);e.dragPan=new Qy(i,h,u),this._add("mousePan",h),this._add("touchPan",u,["touchZoom","touchRotate"]);const p=new Ny,d=new jy;e.touchZoomRotate=new ex(i,d,p,o),this._add("touchRotate",p,["touchPan","touchZoom"]),this._add("touchZoom",d,["touchPan","touchRotate"]),this._add("blockableMapEvent",new Iy(e));const f=e.scrollZoom=new Hy(e,this);this._add("scrollZoom",f,["mousePan"]);const m=e.keyboard=new $y;this._add("keyboard",m);for(const i of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])t.interactive&&t[i]&&e[i].enable(t[i])}_add(t,e,i){this._handlers.push({handlerName:t,handler:e,allowed:i}),this._handlersById[t]=e}stop(t){if(!this._updatingCamera){for(const{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(ix(this._eventsInProgress))||this.isZooming()}_blockedByActive(t,e,i){for(const r in t)if(r!==i&&(!e||e.indexOf(r)<0))return!0;return!1}handleWindowEvent(t){this.handleEvent(t,`${t.type}Window`)}_getMapTouches(t){const e=[];for(const i of t)this._el.contains(i.target)&&e.push(i);return e}handleEvent(t,e){this._updatingCamera=!0;const i="renderFrame"===t.type,r=i?void 0:t,n={needsRenderFrame:!1},s={},o={},a=t.touches?this._getMapTouches(t.touches):void 0,l=a?ht(this._el,a):i?void 0:ct(this._el,t);for(const{handlerName:i,handler:c,allowed:h}of this._handlers){if(!c.isEnabled())continue;let u;this._blockedByActive(o,h,i)?c.reset():c[e||t.type]&&(u=c[e||t.type](t,l,a),this.mergeHandlerResult(n,s,u,i,r),u&&u.needsRenderFrame&&this._triggerRenderFrame()),(u||c.isActive())&&(o[i]=c)}const c={};for(const t in this._previousActiveHandlers)o[t]||(c[t]=r);this._previousActiveHandlers=o,(Object.keys(c).length||sx(n))&&(this._changes.push([n,s,c]),this._triggerRenderFrame()),(Object.keys(o).length||sx(n))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:h}=n;h&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],h(this._map))}mergeHandlerResult(t,e,i,r,n){if(!i)return;I(t,i);const s={handlerName:r,originalEvent:i.originalEvent||n};void 0!==i.zoomDelta&&(e.zoom=s),void 0!==i.panDelta&&(e.drag=s),void 0!==i.pitchDelta&&(e.pitch=s),void 0!==i.bearingDelta&&(e.rotate=s)}_applyChanges(){const t={},e={},i={};for(const[r,n,s]of this._changes)r.panDelta&&(t.panDelta=(t.panDelta||new o(0,0))._add(r.panDelta)),r.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+r.pitchDelta),void 0!==r.around&&(t.around=r.around),void 0!==r.aroundCoord&&(t.aroundCoord=r.aroundCoord),void 0!==r.pinchAround&&(t.pinchAround=r.pinchAround),r.noInertia&&(t.noInertia=r.noInertia),I(e,n),I(i,s);this._updateMapTransform(t,e,i),this._changes=[]}_updateMapTransform(t,e,i){const r=this._map,n=r.transform,s=t=>[t.x,t.y,t.z];if((t=>{const e=this._eventsInProgress.drag;return e&&!this._handlersById[e.handlerName].isActive()})()&&!sx(t)){const t=n.zoom;n.cameraElevationReference="sea",n.recenterOnTerrain(),n.cameraElevationReference="ground",t!==n.zoom&&this._map._update(!0)}if(!sx(t))return this._fireEvents(e,i,!0);let{panDelta:o,zoomDelta:a,bearingDelta:l,pitchDelta:c,around:h,aroundCoord:u,pinchAround:p}=t;void 0!==p&&(h=p),(t=>e.drag&&!this._eventsInProgress.drag)()&&h&&(this._dragOrigin=s(n.pointCoordinate3D(h)),this._trackingEllipsoid.setup(n._camera.position,this._dragOrigin)),n.cameraElevationReference="sea",r._stop(!0),h=h||r.transform.centerPoint,l&&(n.bearing+=l),c&&(n.pitch+=c),n._updateCameraState();const d=[0,0,0];if(o){const t=n.pointCoordinate(h);if("globe"===n.projection.name){const e=ya(t.y),i=n.center.lat,r=Math.min(_a(1,e)/_a(1,i),2);o=o.rotate(-n.angle),d[0]=-o.x/n.worldSize*r,d[1]=-o.y/n.worldSize*r}else{const e=n.pointCoordinate(h.sub(o));t&&e&&(d[0]=e.x-t.x,d[1]=e.y-t.y)}}const f=n.zoom,m=[0,0,0];if(a){const t=s(u||n.pointCoordinate3D(h)),e={dir:Sl([],Dl([],t,n._camera.position))};if(e.dir[2]<0){const i=n.zoomDeltaToMovement(t,a);El(m,e.dir,i)}}const _=xl(d,d,m);n._translateCameraConstrained(_),a&&Math.abs(n.zoom-f)>1e-4&&n.recenterOnTerrain(),n.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(e,i,!0)}_fireEvents(t,e,i){const r=ix(this._eventsInProgress),n=ix(t),s={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(s[`${e}start`]=i),this._eventsInProgress[e]=t[e]}!r&&n&&this._fireEvent("movestart",n.originalEvent);for(const t in s)this._fireEvent(t,s[t]);n&&this._fireEvent("move",n.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i)}const o={};let a;for(const t in this._eventsInProgress){const{handlerName:i,originalEvent:r}=this._eventsInProgress[t];this._handlersById[i].isActive()||(delete this._eventsInProgress[t],a=e[i]||r,o[`${t}end`]=a)}for(const t in o)this._fireEvent(t,o[t]);const l=ix(this._eventsInProgress);if(i&&(r||n)&&!l){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),e=t=>0!==t&&-this._bearingSnap<t&&t<this._bearingSnap;t?(e(t.bearing||this._map.getBearing())&&(t.bearing=0),this._map.easeTo(t,{originalEvent:a})):(this._map.fire(new le("moveend",{originalEvent:a})),e(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(t,e){this._map.fire(new le(t,e?{originalEvent:e}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((t=>{this._frameId=void 0,this.handleEvent(new rx("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const ax="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class lx extends he{constructor(t,e){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=e.bearingSnap,P(["_renderFrameCallback"],this)}getCenter(){return new ua(this.transform.center.lng,this.transform.center.lat)}setCenter(t,e){return this.jumpTo({center:t},e)}panBy(t,e,i){return t=o.convert(t).mult(-1),this.panTo(this.transform.center,I({offset:t},e),i)}panTo(t,e,i){return this.easeTo(I({center:t},e),i)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(t,e,i){return this.easeTo(I({zoom:t},e),i)}zoomIn(t,e){return this.zoomTo(this.getZoom()+1,t,e),this}zoomOut(t,e){return this.zoomTo(this.getZoom()-1,t,e),this}getBearing(){return this.transform.bearing}setBearing(t,e){return this.jumpTo({bearing:t},e),this}getPadding(){return this.transform.padding}setPadding(t,e){return this.jumpTo({padding:t},e),this}rotateTo(t,e,i){return this.easeTo(I({bearing:t},e),i)}resetNorth(t,e){return this.rotateTo(0,I({duration:1e3},t),e),this}resetNorthPitch(t,e){return this.easeTo(I({bearing:0,pitch:0,duration:1e3},t),e),this}snapToNorth(t,e){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,e):this}getPitch(){return this.transform.pitch}setPitch(t,e){return this.jumpTo({pitch:t},e),this}cameraForBounds(t,e){t=ca.convert(t);const i=e&&e.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),i,e)}_extendCameraOptions(t){const e={top:0,bottom:0,right:0,left:0};if("number"==typeof(t=I({padding:e,offset:[0,0],maxZoom:this.transform.maxZoom},t)).padding){const e=t.padding;t.padding={top:e,bottom:e,right:e,left:e}}return t.padding=I(e,t.padding),t}_cameraForBoxAndBearing(t,e,i,r){const n=this._extendCameraOptions(r),s=this.transform,a=s.padding,l=s.project(ua.convert(t)),c=s.project(ua.convert(e)),h=new o(l.x,c.y),u=new o(c.x,l.y),d=-p(i),f=l.rotate(d),m=c.rotate(d),_=h.rotate(d),g=u.rotate(d),y=new o(Math.max(f.x,m.x,_.x,g.x),Math.max(f.y,m.y,_.y,g.y)),x=new o(Math.min(f.x,m.x,_.x,g.x),Math.min(f.y,m.y,_.y,g.y)),v=y.sub(x),b=(s.width-((a.left||0)+(a.right||0)+n.padding.left+n.padding.right))/v.x,w=(s.height-((a.top||0)+(a.bottom||0)+n.padding.top+n.padding.bottom))/v.y;if(w<0||b<0)return void O("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const T=Math.min(s.scaleZoom(s.scale*Math.min(b,w)),n.maxZoom),E="number"==typeof n.offset.x&&"number"==typeof n.offset.y?new o(n.offset.x,n.offset.y):o.convert(n.offset),I=new o((n.padding.left-n.padding.right)/2,(n.padding.top-n.padding.bottom)/2).rotate(i*Math.PI/180),S=E.add(I).mult(s.scale/s.zoomScale(T));return{center:s.unproject(l.add(c).div(2).sub(S)),zoom:T,bearing:i}}_cameraForBox(t,e,i,r,n){const s=this._extendCameraOptions(n);i=i||0,r=r||0,t=ua.convert(t),e=ua.convert(e);const o=this.transform.clone();o.padding=s.padding;const a=this.getFreeCameraOptions(),l=new ua(.5*(t.lng+e.lng),.5*(t.lat+e.lat)),c=.5*(i+r);if(o._camera.position[2]<_a(c,l.lat))return void O("Map cannot fit within canvas with the given bounds, padding, and/or offset.");a.lookAtPoint(l),o.setFreeCameraOptions(a);const h=ba.fromLngLat(t),u=ba.fromLngLat(e),p=o.pointRayIntersection(o.centerPoint,c),d=[(f=o.rayIntersectionCoordinate(p)).x,f.y,f.z];var f;const m=o.screenPointToMercatorRay(o.centerPoint),_="globe"!==o.projection.name;let g,y=0;do{const t=Math.floor(o.zoom),e=1<<t,n=Math.min(e*h.x,e*u.x),s=Math.min(e*h.y,e*u.y),a=Math.max(e*h.x,e*u.x),l=Math.max(e*h.y,e*u.y),c=new ql([n,s,i],[a,l,r]),p=Zl.fromInvProjectionMatrix(o.invProjMatrix,o.worldSize,t,_);if(2!==c.intersects(p)){g&&(o._camera.position=Il([],o._camera.position,m.dir,-g),o._updateStateFromCamera());break}g=.5*gl(Dl([],o._camera.position,d)),o._camera.position=Il([],o._camera.position,m.dir,g);try{o._updateStateFromCamera()}catch(t){return void O("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}}while(++y<10);return{center:o.center,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch}}fitBounds(t,e,i){return this._fitInternal(this.cameraForBounds(t,e),e,i)}_raycastElevationBox(t,e){const i=this.transform.elevation;if(!i)return;const r=new o(t.x,e.y),n=new o(e.x,t.y),s=i.pointCoordinate(t);if(!s)return;const a=i.pointCoordinate(e);if(!a)return;const l=i.pointCoordinate(r);if(!l)return;const c=i.pointCoordinate(n);if(!c)return;const h=new ba(s[0],s[1]).toLngLat(),u=new ba(a[0],a[1]).toLngLat(),p=new ba(l[0],l[1]).toLngLat(),d=new ba(c[0],c[1]).toLngLat(),f=Math.min(h.lng,Math.min(u.lng,Math.min(p.lng,d.lng))),m=Math.min(h.lat,Math.min(u.lat,Math.min(p.lat,d.lat))),_=Math.max(h.lng,Math.max(u.lng,Math.max(p.lng,d.lng))),g=Math.max(h.lat,Math.max(u.lat,Math.max(p.lat,d.lat))),y=Math.min(s[3],Math.min(a[3],Math.min(l[3],c[3]))),x=Math.max(s[3],Math.max(a[3],Math.max(l[3],c[3])));return{minLngLat:new ua(f,m),maxLngLat:new ua(_,g),minAltitude:y,maxAltitude:x}}fitScreenCoordinates(t,e,i,r,n){let s,a,l,c;const h=o.convert(t),u=o.convert(e),p=this._raycastElevationBox(h,u);if(p)s=p.minLngLat,a=p.maxLngLat,l=p.minAltitude,c=p.maxAltitude;else{if(this.transform.anyCornerOffEdge(h,u))return this;s=this.transform.pointLocation(h),a=this.transform.pointLocation(u)}return this._fitInternal(0===this.transform.pitch?this._cameraForBoxAndBearing(this.transform.pointLocation(o.convert(t)),this.transform.pointLocation(o.convert(e)),i,r):this._cameraForBox(s,a,l,c,r),r,n)}_fitInternal(t,e,i){return t?(delete(e=I(t,e)).padding,e.linear?this.easeTo(e,i):this.flyTo(e,i)):this}jumpTo(t,e){this.stop();const i=t.preloadOnly?this.transform.clone():this.transform;let r=!1,n=!1,s=!1;return"zoom"in t&&i.zoom!==+t.zoom&&(r=!0,i.zoom=+t.zoom),void 0!==t.center&&(i.center=ua.convert(t.center)),"bearing"in t&&i.bearing!==+t.bearing&&(n=!0,i.bearing=+t.bearing),"pitch"in t&&i.pitch!==+t.pitch&&(s=!0,i.pitch=+t.pitch),null==t.padding||i.isPaddingEqual(t.padding)||(i.padding=t.padding),t.preloadOnly?(this._preloadTiles(i),this):(this.fire(new le("movestart",e)).fire(new le("move",e)),r&&this.fire(new le("zoomstart",e)).fire(new le("zoom",e)).fire(new le("zoomend",e)),n&&this.fire(new le("rotatestart",e)).fire(new le("rotate",e)).fire(new le("rotateend",e)),s&&this.fire(new le("pitchstart",e)).fire(new le("pitch",e)).fire(new le("pitchend",e)),this.fire(new le("moveend",e)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||O(ax),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,e){const i=this.transform;if(!i.projection.supportsFreeCamera)return O(ax),this;this.stop();const r=i.zoom,n=i.pitch,s=i.bearing;i.setFreeCameraOptions(t);const o=r!==i.zoom,a=n!==i.pitch,l=s!==i.bearing;return this.fire(new le("movestart",e)).fire(new le("move",e)),o&&this.fire(new le("zoomstart",e)).fire(new le("zoom",e)).fire(new le("zoomend",e)),l&&this.fire(new le("rotatestart",e)).fire(new le("rotate",e)).fire(new le("rotateend",e)),a&&this.fire(new le("pitchstart",e)).fire(new le("pitch",e)).fire(new le("pitchend",e)),this.fire(new le("moveend",e)),this}easeTo(t,e){this._stop(!1,t.easeId),(!1===(t=I({offset:[0,0],duration:500,easing:x},t)).animate||!t.essential&&J.prefersReducedMotion)&&(t.duration=0);const i=this.transform,r=this.getZoom(),n=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?+t.zoom:r,c="bearing"in t?this._normalizeBearing(t.bearing,n):n,h="pitch"in t?+t.pitch:s,u="padding"in t?t.padding:i.padding,p=o.convert(t.offset);let d,f,m;if("globe"===i.projection.name){const e=ba.fromLngLat(i.center),r=p.rotate(-i.angle);e.x+=r.x/i.worldSize,e.y+=r.y/i.worldSize;const n=e.toLngLat(),s=ua.convert(t.center||n);this._normalizeCenter(s),d=i.centerPoint.add(r),f=new o(e.x,e.y).mult(i.worldSize),m=new o(fa(s.lng),ma(s.lat)).mult(i.worldSize).sub(f)}else{d=i.centerPoint.add(p);const e=i.pointLocation(d),r=ua.convert(t.center||e);this._normalizeCenter(r),f=i.project(e),m=i.project(r).sub(f)}const _=i.zoomScale(l-r);let g,y;t.around&&(g=ua.convert(t.around),y=i.locationPoint(g));const v=this._zooming||l!==r,b=this._rotating||n!==c,w=this._pitching||h!==s,T=!i.isPaddingEqual(u),E=i=>o=>{if(v&&(i.zoom=Ai(r,l,o)),b&&(i.bearing=Ai(n,c,o)),w&&(i.pitch=Ai(s,h,o)),T&&(i.interpolatePadding(a,u,o),d=i.centerPoint.add(p)),g)i.setLocationAtPoint(g,y);else{const t=i.zoomScale(i.zoom-r),e=l>r?Math.min(2,_):Math.max(.5,_),n=Math.pow(e,1-o),s=i.unproject(f.add(m.mult(o*n)).mult(t));i.setLocationAtPoint(i.renderWorldCopies?s.wrap():s,d)}return t.preloadOnly||this._fireMoveEvents(e),i};if(t.preloadOnly){const e=this._emulate(E,t.duration,i);return this._preloadTiles(e),this}const S={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=v,this._rotating=b,this._pitching=w,this._padding=T,this._easeId=t.easeId,this._prepareEase(e,t.noMoveStart,S),this._ease(E(i),(t=>{i.recenterOnTerrain(),this._afterEase(e,t)}),t),this}_prepareEase(t,e,i={}){this._moving=!0,this.transform.cameraElevationReference="sea",e||i.moving||this.fire(new le("movestart",t)),this._zooming&&!i.zooming&&this.fire(new le("zoomstart",t)),this._rotating&&!i.rotating&&this.fire(new le("rotatestart",t)),this._pitching&&!i.pitching&&this.fire(new le("pitchstart",t))}_fireMoveEvents(t){this.fire(new le("move",t)),this._zooming&&this.fire(new le("zoom",t)),this._rotating&&this.fire(new le("rotate",t)),this._pitching&&this.fire(new le("pitch",t))}_afterEase(t,e){if(this._easeId&&e&&this._easeId===e)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 le("zoomend",t)),r&&this.fire(new le("rotateend",t)),n&&this.fire(new le("pitchend",t)),this.fire(new le("moveend",t))}flyTo(t,e){if(!t.essential&&J.prefersReducedMotion){const i=S(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(i,e)}this.stop(),t=I({offset:[0,0],speed:1.2,curve:1.42,easing:x},t);const i=this.transform,r=this.getZoom(),n=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?v(+t.zoom,i.minZoom,i.maxZoom):r,c="bearing"in t?this._normalizeBearing(t.bearing,n):n,h="pitch"in t?+t.pitch:s,u="padding"in t?t.padding:i.padding,p=i.zoomScale(l-r),d=o.convert(t.offset);let f=i.centerPoint.add(d);const m=i.pointLocation(f),_=ua.convert(t.center||m);this._normalizeCenter(_);const g=i.project(m),y=i.project(_).sub(g);let b=t.curve;const w=Math.max(i.width,i.height),T=w/p,E=y.mag();if("minZoom"in t){const e=v(Math.min(t.minZoom,r,l),i.minZoom,i.maxZoom),n=w/i.zoomScale(e-r);b=Math.sqrt(n/E*2)}const A=b*b;function z(t){const e=(T*T-w*w+(t?-1:1)*A*A*E*E)/(2*(t?T:w)*A*E);return Math.log(Math.sqrt(e*e+1)-e)}function C(t){return(Math.exp(t)-Math.exp(-t))/2}function M(t){return(Math.exp(t)+Math.exp(-t))/2}const k=z(0);let P=function(t){return M(k)/M(k+b*t)},D=function(t){return w*((M(k)*(C(e=k+b*t)/M(e))-C(k))/A)/E;var e},B=(z(1)-k)/b;if(Math.abs(E)<1e-6||!isFinite(B)){if(Math.abs(w-T)<1e-6)return this.easeTo(t,e);const i=T<w?-1:1;B=Math.abs(Math.log(T/w))/b,D=function(){return 0},P=function(t){return Math.exp(i*b*t)}}t.duration="duration"in t?+t.duration:1e3*B/("screenSpeed"in t?+t.screenSpeed/b:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0);const L=n!==c,R=h!==s,F=!i.isPaddingEqual(u),O=i=>o=>{const p=o*B,m=1/P(p);i.zoom=1===o?l:r+i.scaleZoom(m),L&&(i.bearing=Ai(n,c,o)),R&&(i.pitch=Ai(s,h,o)),F&&(i.interpolatePadding(a,u,o),f=i.centerPoint.add(d));const x=1===o?_:i.unproject(g.add(y.mult(D(p))).mult(m));return i.setLocationAtPoint(i.renderWorldCopies?x.wrap():x,f),i._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(e),i};if(t.preloadOnly){const e=this._emulate(O,t.duration,i);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=L,this._pitching=R,this._padding=F,this._prepareEase(e,!1),this._ease(O(i),(()=>this._afterEase(e)),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,e){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const t=this._onEaseEnd;this._onEaseEnd=void 0,t.call(this,e)}if(!t){const t=this.handlers;t&&t.stop(!1)}return this}_ease(t,e,i){!1===i.animate||0===i.duration?(t(1),e()):(this._easeStart=J.now(),this._easeOptions=i,this._onEaseFrame=t,this._onEaseEnd=e,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((J.now()-this._easeStart)/this._easeOptions.duration,1),e=this._onEaseFrame;e&&e(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,e){t=w(t,-180,180);const i=Math.abs(t-e);return Math.abs(t-360-e)<i&&(t-=360),Math.abs(t+360-e)<i&&(t+=360),t}_normalizeCenter(t){const e=this.transform;if(!e.renderWorldCopies||e.maxBounds)return;const i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0}_emulate(t,e,i){const r=Math.ceil(15*e/1e3),n=[],s=t(i.clone());for(let t=0;t<=r;t++){const e=s(t/r);n.push(e.clone())}return n}}class cx{constructor(t={}){this.options=t,P(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(t){const e=this.options&&this.options.compact;return this._map=t,this._container=Q("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=Q("button","mapboxgl-ctrl-attrib-button",this._container),Q("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=Q("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),e&&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===e&&(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(t,e){const i=this._map._getUIString(`AttributionControl.${e}`);t.setAttribute("aria-label",i),t.removeAttribute("title"),t.firstElementChild&&t.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 t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));const e=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||dt.ACCESS_TOKEN}];if(t){const i=e.reduce(((t,i,r)=>(i.value&&(t+=`${i.key}=${i.value}${r<e.length-1?"&":""}`),t)),"?");t.href=`${dt.FEEDBACK_URL}/${i}${this._map._hash?this._map._hash.getHashString(!0):""}`,t.rel="noopener nofollow",this._setElementTitle(t,"MapFeedback")}}_updateData(t){!t||"metadata"!==t.sourceDataType&&"visibility"!==t.sourceDataType&&"style"!==t.dataType||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let t=[];if(this._map.style.stylesheet){const t=this._map.style.stylesheet;this.styleOwner=t.owner,this.styleId=t.id}const e=this._map.style._sourceCaches;for(const i in e){const r=e[i];if(r.used){const e=r.getSource();e.attribution&&t.indexOf(e.attribution)<0&&t.push(e.attribution)}}t.sort(((t,e)=>t.length-e.length)),t=t.filter(((e,i)=>{for(let r=i+1;r<t.length;r++)if(t[r].indexOf(e)>=0)return!1;return!0})),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=[...this.options.customAttribution,...t]:t.unshift(this.options.customAttribution));const i=t.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,t.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 hx{constructor(){P(["_updateLogo","_updateCompact"],this)}onAdd(t){this._map=t,this._container=Q("div","mapboxgl-ctrl");const e=Q("a","mapboxgl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://www.mapbox.com/",e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),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(t){t&&"metadata"!==t.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const t=this._map.style._sourceCaches;if(0===Object.entries(t).length)return!0;for(const e in t){const i=t[e].getSource();if(i.hasOwnProperty("mapbox_logo")&&!i.mapbox_logo)return!1}return!0}_updateCompact(){const t=this._container.children;if(t.length){const e=t[0];this._map.getCanvasContainer().offsetWidth<250?e.classList.add("mapboxgl-compact"):e.classList.remove("mapboxgl-compact")}}}class ux{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e}remove(t){const e=this._currentlyRunning,i=e?this._queue.concat(e):this._queue;for(const e of i)if(e.id===t)return void(e.cancelled=!0)}run(t=0){const e=this._currentlyRunning=this._queue;this._queue=[];for(const i of e)if(!i.cancelled&&(i.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function px(t,e,i){if(t=new ua(t.lng,t.lat),e){const r=new ua(t.lng-360,t.lat),n=new ua(t.lng+360,t.lat),s=360*Math.ceil(Math.abs(t.lng-i.center.lng)/360),o=i.locationPoint(t).distSqr(e),a=e.x<0||e.y<0||e.x>i.width||e.y>i.height;i.locationPoint(r).distSqr(e)<o&&(a||Math.abs(r.lng-i.center.lng)<s)?t=r:i.locationPoint(n).distSqr(e)<o&&(a||Math.abs(n.lng-i.center.lng)<s)&&(t=n)}for(;Math.abs(t.lng-i.center.lng)>180;){const e=i.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=i.width&&e.y<=i.height)break;t.lng>i.center.lng?t.lng-=360:t.lng+=360}return t}const dx={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 fx extends he{constructor(t,e){if(super(),(t instanceof l.HTMLElement||e)&&(t=I({element:t},e)),P(["_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&&"auto"!==t.pitchAlignment?t.pitchAlignment:this._rotationAlignment,this._updateMoving=()=>this._update(!0),t&&t.element)this._element=t.element,this._offset=o.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=Q("div");const e=41,i=27,r=tt("svg",{display:"block",height:e*this._scale+"px",width:i*this._scale+"px",viewBox:`0 0 ${i} ${e}`},this._element),n=tt("radialGradient",{id:"shadowGradient"},tt("defs",{},r));tt("stop",{offset:"10%","stop-opacity":.4},n),tt("stop",{offset:"100%","stop-opacity":.05},n),tt("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},r),tt("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"},r),tt("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"},r),tt("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},r),this._offset=o.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",(t=>{t.preventDefault()})),this._element.addEventListener("mousedown",(t=>{t.preventDefault()}));const i=this._element.classList;for(const t in dx)i.remove(`mapboxgl-marker-anchor-${t}`);i.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(t){return t===this._map||(this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._updateMoving),t.on("moveend",this._update),t.on("remove",this._clearFadeTimer),t._addMarker(this),this.setDraggable(this._draggable),this._update(),t.on("click",this._onMapClick)),this}remove(){const t=this._map;return t&&(t.off("click",this._onMapClick),t.off("move",this._updateMoving),t.off("moveend",this._update),t.off("mousedown",this._addDragHandler),t.off("touchstart",this._addDragHandler),t.off("mouseup",this._onUp),t.off("touchend",this._onUp),t.off("mousemove",this._onMove),t.off("touchmove",this._onMove),t.off("remove",this._clearFadeTimer),t._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=ua.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(t){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")),t){if(!("offset"in t.options)){const e=38.1,i=13.5,r=Math.sqrt(Math.pow(i,2)/2);t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-e],"bottom-left":[r,-1*(e-i+r)],"bottom-right":[-r,-1*(e-i+r)],left:[i,-1*(e-i)],right:[-i,-1*(e-i)]}:this._offset}this._popup=t,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(t){const e=t.code,i=t.charCode||t.keyCode;"Space"!==e&&"Enter"!==e&&32!==i&&13!==i||this.togglePopup()}_onMapClick(t){const e=t.originalEvent.target,i=this._element;this._popup&&(e===i||i.contains(e))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const t=this._popup;return t?(t.isOpen()?(t.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(t.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_evaluateOpacity(){const t=this._map;if(!t)return;const e=this._pos;if(!e||e.x<0||e.x>t.transform.width||e.y<0||e.y>t.transform.height)return void this._clearFadeTimer();const i=t.unproject(e);let r=!1;if(t.transform._terrainEnabled()&&t.getTerrain()){const e=t.getFreeCameraOptions();if(e.position){const t=e.position.toLngLat();r=t.distanceTo(i)<.9*t.distanceTo(this._lngLat)}}const n=(1-t._queryFogOpacity(i))*(r?.2:1);this._element.style.opacity=`${n}`,this._popup&&this._popup._setOpacity(`${n}`),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const t=this._pos;if(!t)return;const e=this._offset.mult(this._scale),i=this._calculatePitch(),r=this._calculateRotation();this._element.style.transform=`\n translate(${t.x}px, ${t.y}px) ${dx[this._anchor]}\n rotateX(${i}deg) rotateZ(${r}deg)\n translate(${e.x}px, ${e.y}px)\n `}_calculatePitch(){return"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?0:this._map&&"map"===this._pitchAlignment?this._map.getPitch():0}_calculateRotation(){return"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?this._rotation:this._map&&"map"===this._rotationAlignment?this._rotation-this._map.getBearing():0}_update(t){l.cancelAnimationFrame(this._updateFrameId);const e=this._map;e&&(e.transform.renderWorldCopies&&(this._lngLat=px(this._lngLat,this._pos,e.transform)),this._pos=e.project(this._lngLat),!0===t?this._updateFrameId=l.requestAnimationFrame((()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())})):this._pos=this._pos.round(),e._requestDomTask((()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),!e.getTerrain()&&!e.getFog()||this._fadeTimer||(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))})))}getOffset(){return this._offset}setOffset(t){return this._offset=o.convert(t),this._update(),this}_onMove(t){const e=this._map;if(e){if(!this._isDragging){const i=this._clickTolerance||e._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=i}this._isDragging&&(this._pos=t.point.sub(this._positionDelta),this._lngLat=e.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new le("dragstart"))),this.fire(new le("drag")))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const t=this._map;t&&(t.off("mousemove",this._onMove),t.off("touchmove",this._onMove)),"active"===this._state&&this.fire(new le("dragend")),this._state="inactive"}_addDragHandler(t){const e=this._map;e&&this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos),this._pointerdownPos=t.point,this._state="pending",e.on("mousemove",this._onMove),e.on("touchmove",this._onMove),e.once("mouseup",this._onUp),e.once("touchend",this._onUp))}setDraggable(t){this._draggable=!!t;const e=this._map;return e&&(t?(e.on("mousedown",this._addDragHandler),e.on("touchstart",this._addDragHandler)):(e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&"auto"!==t?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}class mx{constructor(t){this.jumpTo(t)}getValue(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;const e=m((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-e)+this._end*e}isEasing(t){return t>=this._startTime&&t<=this._endTime}jumpTo(t){this._startTime=-1/0,this._endTime=-1/0,this._start=t,this._end=t}easeTo(t,e,i){this._start=this.getValue(e),this._end=t,this._startTime=e,this._endTime=e+i}}const _x={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},gx={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 yx(t){t.parentNode&&t.parentNode.removeChild(t)}const xx={showCompass:!0,showZoom:!0,visualizePitch:!1};class vx{constructor(t,e,i=!1){this._clickTolerance=10,this.element=e,this.mouseRotate=new By({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,i&&(this.mousePitch=new Ly({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),P(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),e.addEventListener("mousedown",this.mousedown),e.addEventListener("touchstart",this.touchstart,{passive:!1}),e.addEventListener("touchmove",this.touchmove),e.addEventListener("touchend",this.touchend),e.addEventListener("touchcancel",this.reset)}down(t,e){this.mouseRotate.mousedown(t,e),this.mousePitch&&this.mousePitch.mousedown(t,e),st()}move(t,e){const i=this.map,r=this.mouseRotate.mousemoveWindow(t,e);if(r&&r.bearingDelta&&i.setBearing(i.getBearing()+r.bearingDelta),this.mousePitch){const r=this.mousePitch.mousemoveWindow(t,e);r&&r.pitchDelta&&i.setPitch(i.getPitch()+r.pitchDelta)}}off(){const t=this.element;t.removeEventListener("mousedown",this.mousedown),t.removeEventListener("touchstart",this.touchstart,{passive:!1}),t.removeEventListener("touchmove",this.touchmove),t.removeEventListener("touchend",this.touchend),t.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){ot(),l.removeEventListener("mousemove",this.mousemove),l.removeEventListener("mouseup",this.mouseup)}mousedown(t){this.down(I({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),ct(this.element,t)),l.addEventListener("mousemove",this.mousemove),l.addEventListener("mouseup",this.mouseup)}mousemove(t){this.move(t,ct(this.element,t))}mouseup(t){this.mouseRotate.mouseupWindow(t),this.mousePitch&&this.mousePitch.mouseupWindow(t),this.offTemp()}touchstart(t){1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=ht(this.element,t.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>t.preventDefault()},this._startPos))}touchmove(t){1!==t.targetTouches.length?this.reset():(this._lastPos=ht(this.element,t.targetTouches)[0],this.move({preventDefault:()=>t.preventDefault()},this._lastPos))}touchend(t){0===t.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 bx={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1};let wx,Tx=0,Ex=!1;const Ix={maxWidth:100,unit:"metric"};function Sx(t,e,i){const r=i&&i.maxWidth||100,n=t._containerHeight/2,s=t.unproject([0,n]),o=t.unproject([r,n]),a=s.distanceTo(o);if(i&&"imperial"===i.unit){const i=3.2808*a;i>5280?Ax(e,r,i/5280,t._getUIString("ScaleControl.Miles"),t):Ax(e,r,i,t._getUIString("ScaleControl.Feet"),t)}else i&&"nautical"===i.unit?Ax(e,r,a/1852,t._getUIString("ScaleControl.NauticalMiles"),t):a>=1e3?Ax(e,r,a/1e3,t._getUIString("ScaleControl.Kilometers"),t):Ax(e,r,a,t._getUIString("ScaleControl.Meters"),t)}function Ax(t,e,i,r,n){const s=function(t){const e=Math.pow(10,`${Math.floor(t)}`.length-1);let i=t/e;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(t){const e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}(i),e*i}(i),o=s/i;n._requestDomTask((()=>{t.style.width=e*o+"px",t.innerHTML=`${s}&nbsp;${r}`}))}const zx={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},Cx=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Mx(t=new o(0,0),e="bottom"){if("number"==typeof t){const i=Math.round(Math.sqrt(.5*Math.pow(t,2)));switch(e){case"top":return new o(0,t);case"top-left":return new o(i,i);case"top-right":return new o(-i,i);case"bottom":return new o(0,-t);case"bottom-left":return new o(i,-i);case"bottom-right":return new o(-i,-i);case"left":return new o(t,0);case"right":return new o(-t,0)}return new o(0,0)}return t instanceof o||Array.isArray(t)?o.convert(t):o.convert(t[e]||[0,0])}const kx={version:r,supported:t,setRTLTextPlugin:function(t,e,i=!1){if(rs===Qn||rs===ts||rs===es)throw new Error("setRTLTextPlugin cannot be called multiple times.");ns=J.resolveURL(t),rs=Qn,is=e,os(),i||cs()},getRTLTextPluginStatus:ls,Map:class extends lx{constructor(t){if(null!=(t=I({},gx,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(super(new hy(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._renderTaskQueue=new ux,this._domRenderTaskQueue=new ux,this._controls=[],this._markers=[],this._mapId=z(),this._locale=I({},_x,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevation=new mx(0),this._explicitProjection=null,this._requestManager=new wt(t.transformRequest,t.accessToken,t.testMode),this._silenceAuthErrors=!!t.testMode,"string"==typeof t.container){if(this._container=l.document.getElementById(t.container),!this._container)throw new Error(`Container '${t.container}' not found.`)}else{if(!(t.container instanceof l.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(this._container.childNodes.length>0&&O("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),P(["_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!==l&&(l.addEventListener("online",this._onWindowOnline,!1),l.addEventListener("resize",this._onWindowResize,!1),l.addEventListener("orientationchange",this._onWindowResize,!1),l.addEventListener("webkitfullscreenchange",this._onWindowResize,!1)),this.handlers=new ox(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 py("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,I({},t.fitBoundsOptions,{duration:0})))),this.resize(),t.attributionControl&&this.addControl(new cx({customAttribution:t.customAttribution})),this._logoControl=new hx,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)})),this.on("data",(t=>{this._update("style"===t.dataType),this.fire(new le(`${t.dataType}data`,t))})),this.on("dataloading",(t=>{this.fire(new le(`${t.dataType}dataloading`,t))}))}_getMapId(){return this._mapId}addControl(t,e){if(void 0===e&&(e=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new ce(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const i=t.onAdd(this);this._controls.push(t);const r=this._controlPositions[e];return-1!==e.indexOf("bottom")?r.insertBefore(i,r.firstChild):r.appendChild(i),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new ce(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const e=this._controls.indexOf(t);return e>-1&&this._controls.splice(e,1),t.onRemove(this),this}hasControl(t){return this._controls.indexOf(t)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(t){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 e=!this._moving;return e&&this.fire(new le("movestart",t)).fire(new le("move",t)),this.fire(new le("resize",t)),e&&this.fire(new le("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(ca.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()<t?this.setZoom(t):this.fire(new le("zoomstart")).fire(new le("zoom")).fire(new le("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(t){if((t=null==t?22:t)>=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new le("zoomstart")).fire(new le("zoom")).fire(new le("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?0:t)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()<t?this.setPitch(t):this.fire(new le("pitchstart")).fire(new le("pitch")).fire(new le("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(t){if((t=null==t?85:t)>85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new le("pitchstart")).fire(new le("pitch")).fire(new le("pitchend")),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(t){return this.transform.renderWorldCopies=t,this._update()}getProjection(){return this._explicitProjection?this._explicitProjection:this.style&&this.style.stylesheet&&this.style.stylesheet.projection?this.style.stylesheet.projection:{name:"mercator",center:[0,0]}}setProjection(t){return this._lazyInitEmptyStyle(),t?"string"==typeof t&&(t={name:t}):t=null,this._updateProjection(t)}_updateProjection(t){const e=this.getProjection();void 0===t&&(t=e);const i=this.transform.setProjection(t&&"globe"===t.name?{name:this.transform.zoom>=6?"mercator":"globe"}:t);if(t!==e&&(this._explicitProjection=t?"globe"===t.name?{name:"globe",center:[0,0]}:this.transform.getProjection():null),i){if(c(e,this.getProjection()))this.style._forceSymbolLayerUpdate();else{this.painter.clearBackgroundTiles();for(const t in this.style._sourceCaches)this.style._sourceCaches[t].clearTiles()}this.style.dispatcher.broadcast("setProjection",this.transform.projectionOptions),this.style.enableDraping(),this._update(!0)}return this}project(t){return this.transform.locationPoint3D(ua.convert(t))}unproject(t){return this.transform.pointLocation3D(o.convert(t))}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(t,e,i){if("mouseenter"===t||"mouseover"===t){let r=!1;const n=n=>{const s=e.filter((t=>this.getLayer(t))),o=s.length?this.queryRenderedFeatures(n.point,{layers:s}):[];o.length?r||(r=!0,i.call(this,new by(t,this,n.originalEvent,{features:o}))):r=!1},s=()=>{r=!1};return{layers:new Set(e),listener:i,delegates:{mousemove:n,mouseout:s}}}if("mouseleave"===t||"mouseout"===t){let r=!1;const n=n=>{const s=e.filter((t=>this.getLayer(t)));(s.length?this.queryRenderedFeatures(n.point,{layers:s}):[]).length?r=!0:r&&(r=!1,i.call(this,new by(t,this,n.originalEvent)))},s=e=>{r&&(r=!1,i.call(this,new by(t,this,e.originalEvent)))};return{layers:new Set(e),listener:i,delegates:{mousemove:n,mouseout:s}}}{const r=t=>{const r=e.filter((t=>this.getLayer(t))),n=r.length?this.queryRenderedFeatures(t.point,{layers:r}):[];n.length&&(t.features=n,i.call(this,t),delete t.features)};return{layers:new Set(e),listener:i,delegates:{[t]:r}}}}on(t,e,i){if(void 0===i)return super.on(t,e);Array.isArray(e)||(e=[e]);const r=this._createDelegatedListener(t,e,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(r);for(const t in r.delegates)this.on(t,r.delegates[t]);return this}once(t,e,i){if(void 0===i)return super.once(t,e);Array.isArray(e)||(e=[e]);const r=this._createDelegatedListener(t,e,i);for(const t in r.delegates)this.once(t,r.delegates[t]);return this}off(t,e,i){if(void 0===i)return super.off(t,e);e=new Set(Array.isArray(e)?e:[e]);const r=(t,e)=>{if(t.size!==e.size)return!1;for(const i of t)if(!e.has(i))return!1;return!0},n=this._delegatedListeners?this._delegatedListeners[t]:void 0;return n&&(t=>{for(let n=0;n<t.length;n++){const s=t[n];if(s.listener===i&&r(s.layers,e)){for(const t in s.delegates)this.off(t,s.delegates[t]);return t.splice(n,1),this}}})(n),this}queryRenderedFeatures(t,e){return this.style?(void 0!==e||void 0===t||t instanceof o||Array.isArray(t)||(e=t,t=void 0),this.style.queryRenderedFeatures(t=t||[[0,0],[this.transform.width,this.transform.height]],e=e||{},this.transform)):[]}querySourceFeatures(t,e){return this.style.querySourceFeatures(t,e)}queryTerrainElevation(t,e){const i=this.transform.elevation;return i?(e=I({},{exaggerated:!0},e),i.getAtPoint(ba.fromLngLat(t),null,e.exaggerated)):null}setStyle(t,e){return!1!==(e=I({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},e)).diff&&e.localIdeographFontFamily===this._localIdeographFontFamily&&e.localFontFamily===this._localFontFamily&&this.style&&t?(this._diffStyle(t,e),this):(this._localIdeographFontFamily=e.localIdeographFontFamily,this._localFontFamily=e.localFontFamily,this._updateStyle(t,e))}_getUIString(t){const e=this._locale[t];if(null==e)throw new Error(`Missing UI string '${t}'`);return e}_updateStyle(t,e){return this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),t&&(this.style=new Jm(this,e||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof t?this.style.loadURL(t):this.style.loadJSON(t)),this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Jm(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(t,e){if("string"==typeof t){const i=this._requestManager.normalizeStyleURL(t),r=this._requestManager.transformRequest(i,Wt.Style);Yt(r,((t,i)=>{t?this.fire(new ce(t)):i&&this._updateDiff(i,e)}))}else"object"==typeof t&&this._updateDiff(t,e)}_updateDiff(t,e){try{this.style.setState(t)&&this._update(!0)}catch(i){O(`Unable to perform style diff: ${i.message||i.error||i}. Rebuilding the style from scratch.`),this._updateStyle(t,e)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():O("There is no style added to the map.")}addSource(t,e){return this._lazyInitEmptyStyle(),this.style.addSource(t,e),this._update(!0)}isSourceLoaded(t){return this.style&&this.style._isSourceCacheLoaded(t)}areTilesLoaded(){const t=this.style&&this.style._sourceCaches;for(const e in t){const i=t[e]._tiles;for(const t in i){const e=i[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}}return!0}addSourceType(t,e,i){return this._lazyInitEmptyStyle(),this.style.addSourceType(t,e,i)}removeSource(t){return this.style.removeSource(t),this._updateTerrain(),this._update(!0)}getSource(t){return this.style.getSource(t)}addImage(t,e,{pixelRatio:i=1,sdf:r=!1,stretchX:n,stretchY:s,content:o}={}){if(this._lazyInitEmptyStyle(),e instanceof l.HTMLImageElement||l.ImageBitmap&&e instanceof l.ImageBitmap){const{width:a,height:l,data:c}=J.getImageData(e);this.style.addImage(t,{data:new ec({width:a,height:l},c),pixelRatio:i,stretchX:n,stretchY:s,content:o,sdf:r,version:0})}else{if(void 0===e.width||void 0===e.height)return this.fire(new ce(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:a,height:l}=e,c=e;this.style.addImage(t,{data:new ec({width:a,height:l},new Uint8Array(c.data)),pixelRatio:i,stretchX:n,stretchY:s,content:o,sdf:r,version:0,userImage:c}),c.onAdd&&c.onAdd(this,t)}}}updateImage(t,e){const i=this.style.getImage(t);if(!i)return this.fire(new ce(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const r=e instanceof l.HTMLImageElement||l.ImageBitmap&&e instanceof l.ImageBitmap?J.getImageData(e):e,{width:n,height:s}=r,o=r.data;return void 0===n||void 0===s?this.fire(new ce(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`"))):n!==i.data.width||s!==i.data.height?this.fire(new ce(new Error("The width and height of the updated image must be that same as the previous version of the image"))):(i.data.replace(o,!(e instanceof l.HTMLImageElement||l.ImageBitmap&&e instanceof l.ImageBitmap)),void this.style.updateImage(t,i))}hasImage(t){return t?!!this.style.getImage(t):(this.fire(new ce(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}loadImage(t,e){se(this._requestManager.transformRequest(t,Wt.Image),((t,i)=>{e(t,i instanceof l.HTMLImageElement?J.getImageData(i):i)}))}listImages(){return this.style.listImages()}addLayer(t,e){return this._lazyInitEmptyStyle(),this.style.addLayer(t,e),this._update(!0)}moveLayer(t,e){return this.style.moveLayer(t,e),this._update(!0)}removeLayer(t){return this.style.removeLayer(t),this._update(!0)}getLayer(t){return this.style.getLayer(t)}setLayerZoomRange(t,e,i){return this.style.setLayerZoomRange(t,e,i),this._update(!0)}setFilter(t,e,i={}){return this.style.setFilter(t,e,i),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,e,i,r={}){return this.style.setPaintProperty(t,e,i,r),this._update(!0)}getPaintProperty(t,e){return this.style.getPaintProperty(t,e)}setLayoutProperty(t,e,i,r={}){return this.style.setLayoutProperty(t,e,i,r),this._update(!0)}getLayoutProperty(t,e){return this.style.getLayoutProperty(t,e)}setLight(t,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,e),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(t){return this._lazyInitEmptyStyle(),!t&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(t),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(t){return this._lazyInitEmptyStyle(),this.style.setFog(t),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(ua.convert(t),this.transform):0}setFeatureState(t,e){return this.style.setFeatureState(t,e),this._update()}removeFeatureState(t,e){return this.style.removeFeatureState(t,e),this._update()}getFeatureState(t){return this.style.getFeatureState(t)}_updateContainerDimensions(){if(!this._container)return;const t=this._container.getBoundingClientRect().width||400,e=this._container.getBoundingClientRect().height||300;let i,r=this._container;for(;r&&!i;){const t=l.getComputedStyle(r).transform;t&&"none"!==t&&(i=t.match(/matrix.*\((.+)\)/)[1].split(", ")),r=r.parentElement}i?(this._containerWidth=i[0]&&"0"!==i[0]?Math.abs(t/i[0]):t,this._containerHeight=i[3]&&"0"!==i[3]?Math.abs(e/i[3]):e):(this._containerWidth=t,this._containerHeight=e)}_detectMissingCSS(){"rgb(250, 128, 114)"!==l.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&O("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 t=this._container;t.classList.add("mapboxgl-map"),(this._missingCSSCanary=Q("div","mapboxgl-canary",t)).style.visibility="hidden",this._detectMissingCSS();const e=this._canvasContainer=Q("div","mapboxgl-canvas-container",t);this._interactive&&e.classList.add("mapboxgl-interactive"),this._canvas=Q("canvas","mapboxgl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const i=this._controlContainer=Q("div","mapboxgl-control-container",t),r=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((t=>{r[t]=Q("div",`mapboxgl-ctrl-${t}`,i)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,e){const i=J.devicePixelRatio||1;this._canvas.width=i*Math.ceil(t),this._canvas.height=i*Math.ceil(e),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${e}px`}_addMarker(t){this._markers.push(t)}_removeMarker(t){const e=this._markers.indexOf(t);-1!==e&&this._markers.splice(e,1)}_setupPainter(){const e=I({},t.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),i=this._canvas.getContext("webgl",e)||this._canvas.getContext("experimental-webgl",e);i?(Ft(i,!0),this.painter=new Cg(i,this.transform),this.on("data",(t=>{"source"===t.dataType&&this.painter.setTileLoadedFlag(!0)})),ft.testSupport(i)):this.fire(new ce(new Error("Failed to initialize WebGL")))}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new le("webglcontextlost",{originalEvent:t}))}_contextRestored(t){this._setupPainter(),this.resize(),this._update(),this.fire(new le("webglcontextrestored",{originalEvent:t}))}_onMapScroll(t){if(t.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(t){return this.style?(this._styleDirty=this._styleDirty||t,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(t){return this._update(),this._renderTaskQueue.add(t)}_cancelRenderFrame(t){this._renderTaskQueue.remove(t)}_requestDomTask(t){!this.loaded()||this.loaded()&&!this.isMoving()?t():this._domRenderTaskQueue.add(t)}_render(t){let e;const i=this.painter.context.extTimerQuery,r=J.now();this.listens("gpu-timing-frame")&&(e=i.createQueryEXT(),i.beginQueryEXT(i.TIME_ELAPSED_EXT,e));let n=this._updateAverageElevation(r);if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;"globe"===this.getProjection().name&&(this.transform.zoom>=6?"globe"===this.transform.projection.name&&this._updateProjection():"mercator"===this.transform.projection.name&&this._updateProjection());let s=!1;const o=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,e=this.transform.pitch,i=J.now();this.style.zoomHistory.update(t,i);const r=new us(t,{now:i,fadeDuration:o,pitch:e,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),n=r.crossFadingFactor();1===n&&n===this._crossFadingFactor||(s=!0,this._crossFadingFactor=n),this.style.update(r)}if(this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0),this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),this.style._updateSources(this.transform),this._forceMarkerUpdate()),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,o,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:o,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),speedIndexTiming:this.speedIndexTiming}),this.fire(new le("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new le("load"))),this.style&&(this.style.hasTransitions()||s)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){const t=J.now()-r;i.endQueryEXT(i.TIME_ELAPSED_EXT,e),setTimeout((()=>{const r=i.getQueryObjectEXT(e,i.QUERY_RESULT_EXT)/1e6;i.deleteQueryEXT(e),this.fire(new le("gpu-timing-frame",{cpuTime:t,gpuTime:r}))}),50)}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout((()=>{const e=this.painter.queryGpuTimers(t);this.fire(new le("gpu-timing-layer",{layerTimes:e}))}),50)}const a=this._sourcesDirty||this._styleDirty||this._placementDirty||n;if(a||this._repaint)this.triggerRepaint();else{const t=!this.isMoving()&&this.loaded();if(t&&(n=this._updateAverageElevation(r,!0)),n)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new le("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new le("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1}}return!this._loaded||this._fullyLoaded||a||(this._fullyLoaded=!0,this._authenticate()),this}_forceMarkerUpdate(){for(const t of this._markers)t._update()}_updateAverageElevation(t,e=!1){const i=t=>(this.transform.averageElevation=t,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);if((e||t-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(t)){const e=this.transform.averageElevation;let r=this.transform.sampleAverageElevation();isNaN(r)?r=0:this._averageElevationLastSampledAt=t;const n=Math.abs(e-r);if(n>1){if(this._isInitialLoad)return this._averageElevation.jumpTo(r),i(r);this._averageElevation.easeTo(r,t,300)}else if(n>1e-4)return this._averageElevation.jumpTo(r),i(r)}return!!this._averageElevation.isEasing(t)&&i(this._averageElevation.getValue(t))}_authenticate(){Lt(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(t=>{if(t&&(t.message===bt||401===t.status)){const t=this.painter.context.gl;Ft(t,!1),this._logoControl instanceof hx&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new ce(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/")))}})),Dt(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(()=>{}))}_updateTerrain(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){const t=this.painter.canvasCopy(),e=this.painter.getCanvasCopiesAndTimestamps();e.timeStamps.push(performance.now());const i=this.painter.context.gl,r=i.createFramebuffer();function n(t){i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,t,0);const e=new Uint8Array(i.drawingBufferWidth*i.drawingBufferHeight*4);return i.readPixels(0,0,i.drawingBufferWidth,i.drawingBufferHeight,i.RGBA,i.UNSIGNED_BYTE,e),e}return i.bindFramebuffer(i.FRAMEBUFFER,r),this._canvasPixelComparison(n(t),e.canvasCopies.map(n),e.timeStamps)}_canvasPixelComparison(t,e,i){let r=i[1]-i[0];const n=t.length/4;for(let s=0;s<e.length;s++){const o=e[s];let a=0;for(let e=0;e<o.length;e+=4)o[e]===t[e]&&o[e+1]===t[e+1]&&o[e+2]===t[e+2]&&o[e+3]===t[e+3]&&(a+=1);r+=(i[s+2]-i[s+1])*(1-a/n)}return r}remove(){this._hash&&this._hash.remove();for(const t of this._controls)t.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!==l&&(l.removeEventListener("resize",this._onWindowResize,!1),l.removeEventListener("orientationchange",this._onWindowResize,!1),l.removeEventListener("webkitfullscreenchange",this._onWindowResize,!1),l.removeEventListener("online",this._onWindowOnline,!1));const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t&&t.loseContext(),yx(this._canvasContainer),yx(this._controlContainer),yx(this._missingCSSCanary),this._container.classList.remove("mapboxgl-map"),Rt.delete(this.painter.context.gl),this._removed=!0,this.fire(new le("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(t){this._renderNextFrame=this._renderNextFrame||t,this.style&&!this._frame&&(this._frame=J.frame((t=>{const e=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,e&&this._render(t)})))}_preloadTiles(t){return T(this.style?Object.values(this.style._sourceCaches):[],((e,i)=>e._preloadTiles(t,i)),(()=>{this.triggerRepaint()})),this}_onWindowOnline(){this._update()}_onWindowResize(t){this._trackResize&&this.resize({originalEvent:t})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(t){this._showTerrainWireframe!==t&&(this._showTerrainWireframe=t,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(t){this._speedIndexTiming!==t&&(this._speedIndexTiming=t,this._update())}get showPadding(){return!!this._showPadding}set showPadding(t){this._showPadding!==t&&(this._showPadding=t,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,t?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update())}get repaint(){return!!this._repaint}set repaint(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(t){this._vertices=t,this._update()}_setCacheLimits(t,e){!function(t,e){Ut=t,Nt=e}(t,e)}get version(){return r}},NavigationControl:class{constructor(t){this.options=I({},xx,t),this._container=Q("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this.options.showZoom&&(P(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",(t=>{this._map&&this._map.zoomIn({},{originalEvent:t})})),Q("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",(t=>{this._map&&this._map.zoomOut({},{originalEvent:t})})),Q("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(P(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",(t=>{const e=this._map;e&&(this.options.visualizePitch?e.resetNorthPitch({},{originalEvent:t}):e.resetNorth({},{originalEvent:t}))})),this._compassIcon=Q("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const t=this._map;if(!t)return;const e=t.getZoom(),i=e===t.getMaxZoom(),r=e===t.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 t=this._map;if(!t)return;const e=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(t.transform.pitch*(Math.PI/180)),.5)}) rotateX(${t.transform.pitch}deg) rotateZ(${t.transform.angle*(180/Math.PI)}deg)`:`rotate(${t.transform.angle*(180/Math.PI)}deg)`;t._requestDomTask((()=>{this._compassIcon&&(this._compassIcon.style.transform=e)}))}onAdd(t){return this._map=t,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),t.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&t.on("pitch",this._rotateCompassArrow),t.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new vx(t,this._compass,this.options.visualizePitch)),this._container}onRemove(){const t=this._map;t&&(this._container.remove(),this.options.showZoom&&t.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&t.off("pitch",this._rotateCompassArrow),t.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(t,e){const i=Q("button",t,this._container);return i.type="button",i.addEventListener("click",e),i}_setButtonTitle(t,e){if(!this._map)return;const i=this._map._getUIString(`NavigationControl.${e}`);t.setAttribute("aria-label",i),t.firstElementChild&&t.firstElementChild.setAttribute("title",i)}},GeolocateControl:class extends he{constructor(t){super(),this.options=I({},bx,t),P(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=uy(this._updateMarkerRotation,20)}onAdd(t){var e;return this._map=t,this._container=Q("div","mapboxgl-ctrl mapboxgl-ctrl-group"),e=this._setupUI,void 0!==wx?e(wx):void 0!==l.navigator.permissions?l.navigator.permissions.query({name:"geolocation"}).then((t=>{wx="denied"!==t.state,e(wx)})):(wx=!!l.navigator.geolocation,e(wx)),this._container}onRemove(){void 0!==this._geolocationWatchID&&(l.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,Tx=0,Ex=!1}_isOutOfMapMaxBounds(t){const e=this._map.getMaxBounds(),i=t.coords;return!!e&&(i.longitude<e.getWest()||i.longitude>e.getEast()||i.latitude<e.getSouth()||i.latitude>e.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(t){if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new le("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,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(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new le("geolocate",t)),this._finish()}}_updateCamera(t){const e=new ua(t.coords.longitude,t.coords.latitude),i=t.coords.accuracy,r=I({bearing:this._map.getBearing()},this.options.fitBoundsOptions);this._map.fitBounds(e.toBounds(i),r,{geolocateSource:!0})}_updateMarker(t){if(t){const e=new ua(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(e).addTo(this._map),this._userLocationDotMarker.setLngLat(e).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const t=this._map._containerHeight/2,e=this._map.unproject([0,t]),i=this._map.unproject([100,t]),r=e.distanceTo(i)/100,n=Math.ceil(2*this._accuracy/r);this._circleElement.style.width=`${n}px`,this._circleElement.style.height=`${n}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(t){if(this._map){if(this.options.trackUserLocation)if(1===t.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 t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&Ex)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new le("error",t)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(t){if(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=Q("button","mapboxgl-ctrl-geolocate",this._container),Q("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t){O("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}else{const t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=Q("div","mapboxgl-user-location"),this._dotElement.appendChild(Q("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(Q("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new fx({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=Q("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new fx({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",(t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new le("trackuserlocationend")))}))}_onDeviceOrientation(t){this._userLocationDotMarker&&(t.webkitCompassHeading?this._heading=t.webkitCompassHeading:!0===t.absolute&&(this._heading=-1*t.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return O("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 le("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Tx--,Ex=!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 le("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 le("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 t;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Tx++,Tx>1?(t={maximumAge:6e5,timeout:0},Ex=!0):(t=this.options.positionOptions,Ex=!1),this._geolocationWatchID=l.navigator.geolocation.watchPosition(this._onSuccess,this._onError,t),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else l.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const t=()=>{l.addEventListener("ondeviceorientationabsolute"in l?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};void 0!==l.DeviceMotionEvent&&"function"==typeof l.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((e=>{"granted"===e&&t()})).catch(console.error):t()}_clearWatch(){l.navigator.geolocation.clearWatch(this._geolocationWatchID),l.removeEventListener("deviceorientation",this._onDeviceOrientation),l.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:cx,ScaleControl:class{constructor(t){this.options=I({},Ix,t),P(["_onMove","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_onMove(){Sx(this._map,this._container,this.options)}onAdd(t){return this._map=t,this._container=Q("div","mapboxgl-ctrl mapboxgl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._onMove),this._map=void 0}setUnit(t){this.options.unit=t,Sx(this._map,this._container,this.options)}},FullscreenControl:class{constructor(t){this._fullscreen=!1,t&&t.container&&(t.container instanceof l.HTMLElement?this._container=t.container:O("Full screen control 'container' must be a DOM element.")),P(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in l.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in l.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=Q("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",O("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,l.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!l.document.fullscreenEnabled&&!l.document.webkitFullscreenEnabled)}_setupUI(){const t=this._fullscreenButton=Q("button","mapboxgl-ctrl-fullscreen",this._controlContainer);Q("span","mapboxgl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),l.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const t=this._getTitle();this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",t)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(l.document.fullscreenElement||l.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()?l.document.exitFullscreen?l.document.exitFullscreen():l.document.webkitCancelFullScreen&&l.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends he{constructor(t){super(),this.options=I(Object.create(zx),t),P(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(/\s+/):[])}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&t.on("preclick",this._onClose),this.options.closeOnMove&&t.on("move",this._onClose),t.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(t.on("mousemove",this._onMouseEvent),t.on("mouseup",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")):t.on("move",this._update),this.fire(new le("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const t=this._map;return t&&(t.off("move",this._update),t.off("move",this._onClose),t.off("preclick",this._onClose),t.off("click",this._onClose),t.off("remove",this.remove),t.off("mousemove",this._onMouseEvent),t.off("mouseup",this._onMouseEvent),t.off("drag",this._onMouseEvent),this._map=void 0),this.fire(new le("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=ua.convert(t),this._pos=null,this._trackPointer=!1,this._update();const e=this._map;return e&&(e.on("move",this._update),e.off("mousemove",this._onMouseEvent),e._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const t=this._map;return t&&(t.off("move",this._update),t.on("mousemove",this._onMouseEvent),t.on("drag",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(l.document.createTextNode(t))}setHTML(t){const e=l.document.createDocumentFragment(),i=l.document.createElement("body");let r;for(i.innerHTML=t;r=i.firstChild,r;)e.appendChild(r);return this.setDOMContent(e)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(t){return this.options.maxWidth=t,this._update(),this}setDOMContent(t){let e=this._content;if(e)for(;e.hasChildNodes();)e.firstChild&&e.removeChild(e.firstChild);else e=this._content=Q("div","mapboxgl-popup-content",this._container||void 0);if(e.appendChild(t),this.options.closeButton){const t=this._closeButton=Q("button","mapboxgl-popup-close-button",e);t.type="button",t.setAttribute("aria-label","Close popup"),t.setAttribute("aria-hidden","true"),t.innerHTML="&#215;",t.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(t){return this._classList.add(t),this._updateClassList(),this}removeClassName(t){return this._classList.delete(t),this._updateClassList(),this}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){let e;return this._classList.delete(t)?e=!1:(this._classList.add(t),e=!0),this._updateClassList(),e}_onMouseEvent(t){this._update(t.point)}_getAnchor(t){if(this.options.anchor)return this.options.anchor;const e=this._map,i=this._container,r=this._pos;if(!e||!i||!r)return"bottom";const n=i.offsetWidth,s=i.offsetHeight,o=r.x<n/2,a=r.x>e.transform.width-n/2;if(r.y+t<s)return o?"top-left":a?"top-right":"top";if(r.y>e.transform.height-s){if(o)return"bottom-left";if(a)return"bottom-right"}return o?"left":a?"right":"bottom"}_updateClassList(){const t=this._container;if(!t)return;const e=[...this._classList];e.push("mapboxgl-popup"),this._anchor&&e.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&e.push("mapboxgl-popup-track-pointer"),t.className=e.join(" ")}_update(t){const e=this._map,i=this._content;if(!e||!this._lngLat&&!this._trackPointer||!i)return;let r=this._container;if(r||(r=this._container=Q("div","mapboxgl-popup",e.getContainer()),this._tip=Q("div","mapboxgl-popup-tip",r),r.appendChild(i)),this.options.maxWidth&&r.style.maxWidth!==this.options.maxWidth&&(r.style.maxWidth=this.options.maxWidth),e.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=px(this._lngLat,this._pos,e.transform)),!this._trackPointer||t){const i=this._pos=this._trackPointer&&t?t:e.project(this._lngLat),r=Mx(this.options.offset),n=this._anchor=this._getAnchor(r.y),s=Mx(this.options.offset,n),o=i.add(s).round();e._requestDomTask((()=>{this._container&&n&&(this._container.style.transform=`${dx[n]} translate(${o.x}px,${o.y}px)`)}))}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const t=this._container.querySelector(Cx);t&&t.focus()}_onClose(){this.remove()}_setOpacity(t){this._content&&(this._content.style.opacity=t),this._tip&&(this._tip.style.opacity=t)}},Marker:fx,Style:Jm,LngLat:ua,LngLatBounds:ca,Point:o,MercatorCoordinate:ba,FreeCameraOptions:iy,Evented:he,config:dt,prewarm:function(){Zf().acquire(jf)},clearPrewarmedResources:function(){const t=Nf;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(jf),Nf=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 dt.ACCESS_TOKEN},set accessToken(t){dt.ACCESS_TOKEN=t},get baseApiUrl(){return dt.API_URL},set baseApiUrl(t){dt.API_URL=t},get workerCount(){return Uf.workerCount},set workerCount(t){Uf.workerCount=t},get maxParallelImageRequests(){return dt.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){dt.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(t){!function(t){const e=l.caches.delete(Ot);t&&e.catch(t).then((()=>t()))}(t)},workerUrl:"",workerClass:null,setNow:J.setNow,restoreNow:J.restoreNow};return kx}));
2
2
  //# sourceMappingURL=mapbox-gl-csp.js.map