dawarich/vendor/javascript/maplibre-gl.js
Evgenii Burmakin 4421a5bf3c
Feature/maplibre frontend (#1953)
* Add a plan to use MapLibre GL JS for the frontend map rendering, replacing Leaflet

* Implement phase 1

* Phases 1-3 + part of 4

* Fix e2e tests

* Phase 6

* Implement fog of war

* Phase 7

* Next step: fix specs, phase 7 done

* Use our own map tiles

* Extract v2 map logic to separate manager classes

* Update settings panel on v2 map

* Update v2 e2e tests structure

* Reimplement location search in maps v2

* Update speed routes

* Implement visits and places creation in v2

* Fix last failing test

* Implement visits merging

* Fix a routes e2e test and simplify the routes layer styling.

* Extract js to modules from maps_v2_controller.js

* Implement area creation

* Fix spec problem

* Fix some e2e tests

* Implement live mode in v2 map

* Update icons and panel

* Extract some styles

* Remove unused file

* Start adding dark theme to popups on MapLibre maps

* Make popups respect dark theme

* Move v2 maps to maplibre namespace

* Update v2 references to maplibre

* Put place, area and visit info into side panel

* Update API to use safe settings config method

* Fix specs

* Fix method name to config in SafeSettings and update usages accordingly

* Add missing public files

* Add handling for real time points

* Fix remembering enabled/disabled layers of the v2 map

* Fix lots of e2e tests

* Add settings to select map version

* Use maps/v2 as main path for MapLibre maps

* Update routing

* Update live mode
2025-12-06 20:34:49 +01:00

8 lines
987 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// maplibre-gl@5.12.0 downloaded from https://ga.jspm.io/npm:maplibre-gl@5.12.0/dist/maplibre-gl.js
var e=typeof globalThis!=="undefined"?globalThis:typeof self!=="undefined"?self:global;var s={};
/**
* MapLibre GL JS
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.12.0/LICENSE.txt
*/(function(e,a){s=a()})(0,(function(){var s={};var a={};function l(e,l,c){a[e]=c;if(e==="index"){var u="var sharedModule = {}; ("+a.shared+")(sharedModule); ("+a.worker+")(sharedModule);";var d={};a.shared(d);a.index(s,d);typeof window!=="undefined"&&s.setWorkerUrl(window.URL.createObjectURL(new Blob([u],{type:"text/javascript"})));return s}}l("shared",["exports"],(function(s){function a(e,s,a,l){return new(a||(a=Promise))((function(c,u){function d(e){try{_(l.next(e))}catch(e){u(e)}}function f(e){try{_(l.throw(e))}catch(e){u(e)}}function _(e){var s;e.done?c(e.value):(s=e.value,s instanceof a?s:new a((function(e){e(s)}))).then(d,f)}_((l=l.apply(e,s||[])).next())}))}function l(s,a){(this||e).x=s,(this||e).y=a}function c(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var u,d;"function"==typeof SuppressedError&&SuppressedError,l.prototype={clone(){return new l((this||e).x,(this||e).y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,s){return this.clone()._rotateAround(e,s)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt((this||e).x*(this||e).x+(this||e).y*(this||e).y)},equals(s){return(this||e).x===s.x&&(this||e).y===s.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(s){const a=s.x-(this||e).x,l=s.y-(this||e).y;return a*a+l*l},angle(){return Math.atan2((this||e).y,(this||e).x)},angleTo(s){return Math.atan2((this||e).y-s.y,(this||e).x-s.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(s,a){return Math.atan2((this||e).x*a-(this||e).y*s,(this||e).x*s+(this||e).y*a)},_matMult(s){const a=s[2]*(this||e).x+s[3]*(this||e).y;return(this||e).x=s[0]*(this||e).x+s[1]*(this||e).y,(this||e).y=a,this||e},_add(s){return(this||e).x+=s.x,(this||e).y+=s.y,this||e},_sub(s){return(this||e).x-=s.x,(this||e).y-=s.y,this||e},_mult(s){return(this||e).x*=s,(this||e).y*=s,this||e},_div(s){return(this||e).x/=s,(this||e).y/=s,this||e},_multByPoint(s){return(this||e).x*=s.x,(this||e).y*=s.y,this||e},_divByPoint(s){return(this||e).x/=s.x,(this||e).y/=s.y,this||e},_unit(){return this._div(this.mag()),this||e},_perp(){const s=(this||e).y;return(this||e).y=(this||e).x,(this||e).x=-s,this||e},_rotate(s){const a=Math.cos(s),l=Math.sin(s),c=l*(this||e).x+a*(this||e).y;return(this||e).x=a*(this||e).x-l*(this||e).y,(this||e).y=c,this||e},_rotateAround(s,a){const l=Math.cos(s),c=Math.sin(s),u=a.y+c*((this||e).x-a.x)+l*((this||e).y-a.y);return(this||e).x=a.x+l*((this||e).x-a.x)-c*((this||e).y-a.y),(this||e).y=u,this||e},_round(){return(this||e).x=Math.round((this||e).x),(this||e).y=Math.round((this||e).y),this||e},constructor:l},l.convert=function(e){if(e instanceof l)return e;if(Array.isArray(e))return new l(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new l(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};var f=function(){if(d)return u;function s(s,a,l,c){(this||e).cx=3*s,(this||e).bx=3*(l-s)-(this||e).cx,(this||e).ax=1-(this||e).cx-(this||e).bx,(this||e).cy=3*a,(this||e).by=3*(c-a)-(this||e).cy,(this||e).ay=1-(this||e).cy-(this||e).by,(this||e).p1x=s,(this||e).p1y=a,(this||e).p2x=l,(this||e).p2y=c}return d=1,u=s,s.prototype={sampleCurveX:function(s){return(((this||e).ax*s+(this||e).bx)*s+(this||e).cx)*s},sampleCurveY:function(s){return(((this||e).ay*s+(this||e).by)*s+(this||e).cy)*s},sampleCurveDerivativeX:function(s){return(3*(this||e).ax*s+2*(this||e).bx)*s+(this||e).cx},solveCurveX:function(e,s){if(void 0===s&&(s=1e-6),e<0)return 0;if(e>1)return 1;for(var a=e,l=0;l<8;l++){var c=this.sampleCurveX(a)-e;if(Math.abs(c)<s)return a;var u=this.sampleCurveDerivativeX(a);if(Math.abs(u)<1e-6)break;a-=c/u}var d=0,f=1;for(a=e,l=0;l<20&&(c=this.sampleCurveX(a),!(Math.abs(c-e)<s));l++)e>c?d=a:f=a,a=.5*(f-d)+d;return a},solve:function(e,s){return this.sampleCurveY(this.solveCurveX(e,s))}},u}(),_=c(f);let y,b;function S(){return null==y&&(y="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),y}function P(){if(null==b&&(b=!1,S())){const e=5,s=new OffscreenCanvas(e,e).getContext("2d",{willReadFrequently:!0});if(s){for(let a=0;a<e*e;a++){const l=4*a;s.fillStyle=`rgb(${l},${l+1},${l+2})`,s.fillRect(a%e,Math.floor(a/e),1,1)}const a=s.getImageData(0,0,e,e).data;for(let s=0;s<e*e*4;s++)if(s%4!=3&&a[s]!==s){b=!0;break}}}return b||!1}var M=1e-6,C="undefined"!=typeof Float32Array?Float32Array:Array;function D(){var e=new C(9);return C!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function L(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function F(){var e=new C(3);return C!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function B(e){var s=e[0],a=e[1],l=e[2];return Math.sqrt(s*s+a*a+l*l)}function O(e,s,a){var l=new C(3);return l[0]=e,l[1]=s,l[2]=a,l}function V(e,s,a){return e[0]=s[0]+a[0],e[1]=s[1]+a[1],e[2]=s[2]+a[2],e}function N(e,s,a){return e[0]=s[0]*a,e[1]=s[1]*a,e[2]=s[2]*a,e}function j(e,s,a){var l=s[0],c=s[1],u=s[2],d=a[0],f=a[1],_=a[2];return e[0]=c*_-u*f,e[1]=u*d-l*_,e[2]=l*f-c*d,e}var G,Z=B;function q(e,s,a){var l=s[0],c=s[1],u=s[2],d=s[3];return e[0]=a[0]*l+a[4]*c+a[8]*u+a[12]*d,e[1]=a[1]*l+a[5]*c+a[9]*u+a[13]*d,e[2]=a[2]*l+a[6]*c+a[10]*u+a[14]*d,e[3]=a[3]*l+a[7]*c+a[11]*u+a[15]*d,e}function W(){var e=new C(4);return C!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function J(e,s,a,l){var c=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"zyx",u=Math.PI/360;s*=u,l*=u,a*=u;var d=Math.sin(s),f=Math.cos(s),_=Math.sin(a),y=Math.cos(a),b=Math.sin(l),S=Math.cos(l);switch(c){case"xyz":e[0]=d*y*S+f*_*b,e[1]=f*_*S-d*y*b,e[2]=f*y*b+d*_*S,e[3]=f*y*S-d*_*b;break;case"xzy":e[0]=d*y*S-f*_*b,e[1]=f*_*S-d*y*b,e[2]=f*y*b+d*_*S,e[3]=f*y*S+d*_*b;break;case"yxz":e[0]=d*y*S+f*_*b,e[1]=f*_*S-d*y*b,e[2]=f*y*b-d*_*S,e[3]=f*y*S+d*_*b;break;case"yzx":e[0]=d*y*S+f*_*b,e[1]=f*_*S+d*y*b,e[2]=f*y*b-d*_*S,e[3]=f*y*S-d*_*b;break;case"zxy":e[0]=d*y*S-f*_*b,e[1]=f*_*S+d*y*b,e[2]=f*y*b+d*_*S,e[3]=f*y*S-d*_*b;break;case"zyx":e[0]=d*y*S-f*_*b,e[1]=f*_*S+d*y*b,e[2]=f*y*b-d*_*S,e[3]=f*y*S+d*_*b;break;default:throw new Error("Unknown angle order "+c)}return e}function Q(){var e=new C(2);return C!=Float32Array&&(e[0]=0,e[1]=0),e}function se(e,s){var a=new C(2);return a[0]=e,a[1]=s,a}F(),G=new C(4),C!=Float32Array&&(G[0]=0,G[1]=0,G[2]=0,G[3]=0),F(),O(1,0,0),O(0,1,0),W(),W(),D(),Q();const oe=8192;function ce(e,s,a){return s*(oe/(e.tileSize*Math.pow(2,a-e.tileID.overscaledZ)))}function pe(e,s){return(e%s+s)%s}function fe(e,s,a){return e*(1-a)+s*a}function xe(e){if(e<=0)return 0;if(e>=1)return 1;const s=e*e,a=s*e;return 4*(e<.5?a:3*(e-s)+a-.75)}function ve(e,s,a,l){const c=new _(e,s,a,l);return e=>c.solve(e)}const be=ve(.25,.1,.25,1);function we(e,s,a){return Math.min(a,Math.max(s,e))}function Te(e,s,a){const l=a-s,c=((e-s)%l+l)%l+s;return c===s?a:c}function Se(e,...s){for(const a of s)for(const s in a)e[s]=a[s];return e}let Me=1;function Ee(s,a,l){const c={};for(const l in s)c[l]=a.call(this||e,s[l],l,s);return c}function Ce(s,a,l){const c={};for(const l in s)a.call(this||e,s[l],l,s)&&(c[l]=s[l]);return c}function Ae(e){return Array.isArray(e)?e.map(Ae):"object"==typeof e&&e?Ee(e,Ae):e}const ke={};function Le(e){ke[e]||("undefined"!=typeof console&&console.warn(e),ke[e]=!0)}function Fe(e,s,a){return(a.y-e.y)*(s.x-e.x)>(s.y-e.y)*(a.x-e.x)}function Oe(e){return"undefined"!=typeof WorkerGlobalScope&&void 0!==e&&e instanceof WorkerGlobalScope}let Ve=null;function Ne(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap}const je="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function Ue(s,l,c,u,d){return a(this||e,void 0,void 0,(function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const e=new VideoFrame(s,{timestamp:0});try{const a=null==e?void 0:e.format;if(!a||!a.startsWith("BGR")&&!a.startsWith("RGB"))throw new Error(`Unrecognized format ${a}`);const f=a.startsWith("BGR"),_=new Uint8ClampedArray(u*d*4);if(yield e.copyTo(_,function(e,s,a,l,c){const u=4*Math.max(-s,0),d=(Math.max(0,a)-a)*l*4+u,f=4*l,_=Math.max(0,s),y=Math.max(0,a);return{rect:{x:_,y:y,width:Math.min(e.width,s+l)-_,height:Math.min(e.height,a+c)-y},layout:[{offset:d,stride:f}]}}(s,l,c,u,d)),f)for(let e=0;e<_.length;e+=4){const s=_[e];_[e]=_[e+2],_[e+2]=s}return _}finally{e.close()}}))}let Ge,Ze;function qe(e,s,a,l){return e.addEventListener(s,a,l),{unsubscribe:()=>{e.removeEventListener(s,a,l)}}}function $e(e){return e*Math.PI/180}function We(e){return e/Math.PI*180}const He={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},Xe={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},Ye="AbortError";function Ke(){return new Error(Ye)}const Je={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function Qe(e){return Je.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf("://"))]}const et="global-dispatcher";class ue extends Error{constructor(e,s,a,l){super(`AJAXError: ${s} (${e}): ${a}`),this.status=e,this.statusText=s,this.url=a,this.body=l}}const nt=()=>Oe(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,ct=function(s,l){if(/:\/\//.test(s.url)&&!/^https?:|^file:/.test(s.url)){const e=Qe(s.url);if(e)return e(s,l);if(Oe(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:s,targetMapId:et},l)}if(!(/^file:/.test(c=s.url)||/^file:/.test(nt())&&!/^\w+:/.test(c))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(s,l){return a(this||e,void 0,void 0,(function*(){const e=new Request(s.url,{method:s.method||"GET",body:s.body,credentials:s.credentials,headers:s.headers,cache:s.cache,referrer:nt(),signal:l.signal});let a,c;"json"!==s.type||e.headers.has("Accept")||e.headers.set("Accept","application/json");try{a=yield fetch(e)}catch(e){throw new ue(0,e.message,s.url,new Blob)}if(!a.ok){const e=yield a.blob();throw new ue(a.status,a.statusText,s.url,e)}c="arrayBuffer"===s.type||"image"===s.type?a.arrayBuffer():"json"===s.type?a.json():a.text();const u=yield c;if(l.signal.aborted)throw Ke();return{data:u,cacheControl:a.headers.get("Cache-Control"),expires:a.headers.get("Expires")}}))}(s,l);if(Oe(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:s,mustQueue:!0,targetMapId:et},l)}var c;return function(e,s){return new Promise(((a,l)=>{var c;const u=new XMLHttpRequest;u.open(e.method||"GET",e.url,!0),"arrayBuffer"!==e.type&&"image"!==e.type||(u.responseType="arraybuffer");for(const s in e.headers)u.setRequestHeader(s,e.headers[s]);"json"===e.type&&(u.responseType="text",(null===(c=e.headers)||void 0===c?void 0:c.Accept)||u.setRequestHeader("Accept","application/json")),u.withCredentials="include"===e.credentials,u.onerror=()=>{l(new Error(u.statusText))},u.onload=()=>{if(!s.signal.aborted)if((u.status>=200&&u.status<300||0===u.status)&&null!==u.response){let s=u.response;if("json"===e.type)try{s=JSON.parse(u.response)}catch(e){return void l(e)}a({data:s,cacheControl:u.getResponseHeader("Cache-Control"),expires:u.getResponseHeader("Expires")})}else{const s=new Blob([u.response],{type:u.getResponseHeader("Content-Type")});l(new ue(u.status,u.statusText,e.url,s))}},s.signal.addEventListener("abort",(()=>{u.abort(),l(Ke())})),u.send(e.body)}))}(s,l)};function ht(e){if(!e||e.indexOf("://")<=0||0===e.indexOf("data:image/")||0===e.indexOf("blob:"))return!0;const s=new URL(e),a=window.location;return s.protocol===a.protocol&&s.host===a.host}function ut(e,s,a){a[e]&&-1!==a[e].indexOf(s)||(a[e]=a[e]||[],a[e].push(s))}function dt(e,s,a){if(a&&a[e]){const l=a[e].indexOf(s);-1!==l&&a[e].splice(l,1)}}class ye{constructor(e,s={}){Se(this,s),this.type=e}}class me extends ye{constructor(e,s={}){super("error",Se({error:e},s))}}class ge{on(e,s){return this._listeners=this._listeners||{},ut(e,s,this._listeners),{unsubscribe:()=>{this.off(e,s)}}}off(e,s){return dt(e,s,this._listeners),dt(e,s,this._oneTimeListeners),this}once(e,s){return s?(this._oneTimeListeners=this._oneTimeListeners||{},ut(e,s,this._oneTimeListeners),this):new Promise((s=>this.once(e,s)))}fire(e,s){"string"==typeof e&&(e=new ye(e,s||{}));const a=e.type;if(this.listens(a)){e.target=this;const s=this._listeners&&this._listeners[a]?this._listeners[a].slice():[];for(const a of s)a.call(this,e);const l=this._oneTimeListeners&&this._oneTimeListeners[a]?this._oneTimeListeners[a].slice():[];for(const s of l)dt(a,s,this._oneTimeListeners),s.call(this,e);const c=this._eventedParent;c&&(Se(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),c.fire(e))}else e instanceof me&&console.error(e.error);return this}listens(e){return this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e)}setEventedParent(e,s){return this._eventedParent=e,this._eventedParentData=s,this}}var pt={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},"font-faces":{type:"array",value:"fontFaces"},transition:{type:"transition"},layers:{required:!0,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:!0,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:!1},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{type:"*"}},source_raster:{type:{required:!0,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:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,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:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},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_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,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:!1,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:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,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:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,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:!0,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:!1,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:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,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:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,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:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,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:!0,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:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"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:!1,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:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,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:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,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"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},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:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,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"}}};const ft=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function mt(e,s){const a={};for(const s in e)"ref"!==s&&(a[s]=e[s]);return ft.forEach((e=>{e in s&&(a[e]=s[e])})),a}function _t(e,s){if(Array.isArray(e)){if(!Array.isArray(s)||e.length!==s.length)return!1;for(let a=0;a<e.length;a++)if(!_t(e[a],s[a]))return!1;return!0}if("object"==typeof e&&null!==e&&null!==s){if("object"!=typeof s)return!1;if(Object.keys(e).length!==Object.keys(s).length)return!1;for(const a in e)if(!_t(e[a],s[a]))return!1;return!0}return e===s}function gt(e,s){e.push(s)}function yt(e,s,a){gt(a,{command:"addSource",args:[e,s[e]]})}function vt(e,s,a){gt(s,{command:"removeSource",args:[e]}),a[e]=!0}function Et(e,s,a,l){vt(e,a,l),yt(e,s,a)}function Rt(e,s,a){let l;for(l in e[a])if(Object.prototype.hasOwnProperty.call(e[a],l)&&"data"!==l&&!_t(e[a][l],s[a][l]))return!1;for(l in s[a])if(Object.prototype.hasOwnProperty.call(s[a],l)&&"data"!==l&&!_t(e[a][l],s[a][l]))return!1;return!0}function Vt(e,s,a,l,c,u){e=e||{},s=s||{};for(const d in e)Object.prototype.hasOwnProperty.call(e,d)&&(_t(e[d],s[d])||a.push({command:u,args:[l,d,s[d],c]}));for(const d in s)Object.prototype.hasOwnProperty.call(s,d)&&!Object.prototype.hasOwnProperty.call(e,d)&&(_t(e[d],s[d])||a.push({command:u,args:[l,d,s[d],c]}))}function Zt(e){return e.id}function $t(e,s){return e[s.id]=s,e}class De{constructor(e,s,a,l){this.message=(e?`${e}: `:"")+a,l&&(this.identifier=l),null!=s&&s.__line__&&(this.line=s.__line__)}}function ti(e,...s){for(const a of s)for(const s in a)e[s]=a[s];return e}class Be extends Error{constructor(e,s){super(s),this.message=s,this.key=e}}class Pe{constructor(e,s=[]){this.parent=e,this.bindings={};for(const[e,a]of s)this.bindings[e]=a}concat(e){return new Pe(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}const oi={kind:"null"},li={kind:"number"},ci={kind:"string"},hi={kind:"boolean"},ui={kind:"color"},di={kind:"projectionDefinition"},pi={kind:"object"},fi={kind:"value"},mi={kind:"collator"},_i={kind:"formatted"},xi={kind:"padding"},bi={kind:"colorArray"},wi={kind:"numberArray"},Ii={kind:"resolvedImage"},Ei={kind:"variableAnchorOffsetCollection"};function Ai(e,s){return{kind:"array",itemType:e,N:s}}function zi(e){if("array"===e.kind){const s=zi(e.itemType);return"number"==typeof e.N?`array<${s}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${s}>`}return e.kind}const Ri=[oi,li,ci,hi,ui,di,_i,pi,Ai(fi),xi,wi,bi,Ii,Ei];function Li(e,s){if("error"===s.kind)return null;if("array"===e.kind){if("array"===s.kind&&(0===s.N&&"value"===s.itemType.kind||!Li(e.itemType,s.itemType))&&("number"!=typeof e.N||e.N===s.N))return null}else{if(e.kind===s.kind)return null;if("value"===e.kind)for(const e of Ri)if(!Li(e,s))return null}return`Expected ${zi(e)} but found ${zi(s)} instead.`}function Fi(e,s){return s.some((s=>s.kind===e.kind))}function Bi(e,s){return s.some((s=>"null"===s?null===e:"array"===s?Array.isArray(e):"object"===s?e&&!Array.isArray(e)&&"object"==typeof e:s===typeof e))}function Oi(e,s){return"array"===e.kind&&"array"===s.kind?e.itemType.kind===s.itemType.kind&&"number"==typeof e.N:e.kind===s.kind}const Vi=.96422,Ni=.82521,ji=4/29,Ui=6/29,Gi=3*Ui*Ui,Zi=Ui*Ui*Ui,qi=Math.PI/180,$i=180/Math.PI;function Wi(e){return(e%=360)<0&&(e+=360),e}function Hi([e,s,a,l]){let c,u;const d=Yi((.2225045*(e=Xi(e))+.7168786*(s=Xi(s))+.0606169*(a=Xi(a)))/1);e===s&&s===a?c=u=d:(c=Yi((.4360747*e+.3850649*s+.1430804*a)/Vi),u=Yi((.0139322*e+.0971045*s+.7141733*a)/Ni));const f=116*d-16;return[f<0?0:f,500*(c-d),200*(d-u),l]}function Xi(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Yi(e){return e>Zi?Math.pow(e,1/3):e/Gi+ji}function Ki([e,s,a,l]){let c=(e+16)/116,u=isNaN(s)?c:c+s/500,d=isNaN(a)?c:c-a/200;return c=1*Qi(c),u=Vi*Qi(u),d=Ni*Qi(d),[Ji(3.1338561*u-1.6168667*c-.4906146*d),Ji(-.9787684*u+1.9161415*c+.033454*d),Ji(.0719453*u-.2289914*c+1.4052427*d),l]}function Ji(e){return(e=e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055)<0?0:e>1?1:e}function Qi(e){return e>Ui?e*e*e:Gi*(e-ji)}const sr=Object.hasOwn||function(e,s){return Object.prototype.hasOwnProperty.call(e,s)};function or(e,s){return sr(e,s)?e[s]:void 0}function lr(e){return parseInt(e.padEnd(2,e),16)/255}function cr(e,s){return hr(s?e/100:e,0,1)}function hr(e,s,a){return Math.min(Math.max(s,e),a)}function ur(e){return!e.some(Number.isNaN)}const dr={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function fr(e,s,a){return e+a*(s-e)}function mr(e,s,a){return e.map(((e,l)=>fr(e,s[l],a)))}class It{constructor(e,s,a,l=1,c=!0){this.r=e,this.g=s,this.b=a,this.a=l,c||(this.r*=l,this.g*=l,this.b*=l,l||this.overwriteGetter("rgb",[e,s,a,l]))}static parse(e){if(e instanceof It)return e;if("string"!=typeof e)return;const s=function(e){if("transparent"===(e=e.toLowerCase().trim()))return[0,0,0,0];const s=or(dr,e);if(s){const[e,a,l]=s;return[e/255,a/255,l/255,1]}if(e.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){const s=e.length<6?1:2;let a=1;return[lr(e.slice(a,a+=s)),lr(e.slice(a,a+=s)),lr(e.slice(a,a+=s)),lr(e.slice(a,a+s)||"ff")]}if(e.startsWith("rgb")){const s=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(s){const[e,a,l,c,u,d,f,_,y,b,S,P]=s,M=[c||" ",f||" ",b].join("");if(" "===M||" /"===M||",,"===M||",,,"===M){const e=[l,d,y].join(""),s="%%%"===e?100:""===e?255:0;if(s){const e=[hr(+a/s,0,1),hr(+u/s,0,1),hr(+_/s,0,1),S?cr(+S,P):1];if(ur(e))return e}}return}}const a=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(a){const[e,s,l,c,u,d,f,_,y]=a,b=[l||" ",u||" ",f].join("");if(" "===b||" /"===b||",,"===b||",,,"===b){const e=[+s,hr(+c,0,100),hr(+d,0,100),_?cr(+_,y):1];if(ur(e))return function([e,s,a,l]){function c(l){const c=(l+e/30)%12,u=s*Math.min(a,1-a);return a-u*Math.max(-1,Math.min(c-3,9-c,1))}return e=Wi(e),s/=100,a/=100,[c(0),c(8),c(4),l]}(e)}}}(e);return s?new It(...s,!1):void 0}get rgb(){const{r:e,g:s,b:a,a:l}=this,c=l||1/0;return this.overwriteGetter("rgb",[e/c,s/c,a/c,l])}get hcl(){return this.overwriteGetter("hcl",function(e){const[s,a,l,c]=Hi(e),u=Math.sqrt(a*a+l*l);return[Math.round(1e4*u)?Wi(Math.atan2(l,a)*$i):NaN,u,s,c]}(this.rgb))}get lab(){return this.overwriteGetter("lab",Hi(this.rgb))}overwriteGetter(e,s){return Object.defineProperty(this,e,{value:s}),s}toString(){const[e,s,a,l]=this.rgb;return`rgba(${[e,s,a].map((e=>Math.round(255*e))).join(",")},${l})`}static interpolate(e,s,a,l="rgb"){switch(l){case"rgb":{const[l,c,u,d]=mr(e.rgb,s.rgb,a);return new It(l,c,u,d,!1)}case"hcl":{const[l,c,u,d]=e.hcl,[f,_,y,b]=s.hcl;let S,P;if(isNaN(l)||isNaN(f))isNaN(l)?isNaN(f)?S=NaN:(S=f,1!==u&&0!==u||(P=_)):(S=l,1!==y&&0!==y||(P=c));else{let e=f-l;f>l&&e>180?e-=360:f<l&&l-f>180&&(e+=360),S=l+a*e}const[M,C,D,L]=function([e,s,a,l]){return e=isNaN(e)?0:e*qi,Ki([a,Math.cos(e)*s,Math.sin(e)*s,l])}([S,null!=P?P:fr(c,_,a),fr(u,y,a),fr(d,b,a)]);return new It(M,C,D,L,!1)}case"lab":{const[l,c,u,d]=Ki(mr(e.lab,s.lab,a));return new It(l,c,u,d,!1)}}}}It.black=new It(0,0,0,1),It.white=new It(1,1,1,1),It.transparent=new It(0,0,0,0),It.red=new It(1,0,0,1);class Mt{constructor(e,s,a){this.sensitivity=e?s?"variant":"case":s?"accent":"base",this.locale=a,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,s){return this.collator.compare(e,s)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const _r=["bottom","center","top"];class kt{constructor(e,s,a,l,c,u){this.text=e,this.image=s,this.scale=a,this.fontStack=l,this.textColor=c,this.verticalAlign=u}}class Dt{constructor(e){this.sections=e}static fromString(e){return new Dt([new kt(e,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((e=>0!==e.text.length||e.image&&0!==e.image.name.length))}static factory(e){return e instanceof Dt?e:Dt.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map((e=>e.text)).join("")}}class Ft{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Ft)return e;if("number"==typeof e)return new Ft([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const s of e)if("number"!=typeof s)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new Ft(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,s,a){return new Ft(mr(e.values,s.values,a))}}class Bt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Bt)return e;if("number"==typeof e)return new Bt([e]);if(Array.isArray(e)){for(const s of e)if("number"!=typeof s)return;return new Bt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,s,a){return new Bt(mr(e.values,s.values,a))}}class Pt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Pt)return e;if("string"==typeof e){const s=It.parse(e);if(!s)return;return new Pt([s])}if(!Array.isArray(e))return;const s=[];for(const a of e){if("string"!=typeof a)return;const e=It.parse(a);if(!e)return;s.push(e)}return new Pt(s)}toString(){return JSON.stringify(this.values)}static interpolate(e,s,a,l="rgb"){const c=[];if(e.values.length!=s.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${s.values.length}), cannot interpolate.`);for(let u=0;u<e.values.length;u++)c.push(It.interpolate(e.values[u],s.values[u],a,l));return new Pt(c)}}class zt extends Error{constructor(e){super(e),this.name="RuntimeError"}toJSON(){return this.message}}const gr=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class Ct{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Ct)return e;if(Array.isArray(e)&&!(e.length<1)&&e.length%2==0){for(let s=0;s<e.length;s+=2){const a=e[s],l=e[s+1];if("string"!=typeof a||!gr.has(a))return;if(!Array.isArray(l)||2!==l.length||"number"!=typeof l[0]||"number"!=typeof l[1])return}return new Ct(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,s,a){const l=e.values,c=s.values;if(l.length!==c.length)throw new zt(`Cannot interpolate values of different length. from: ${e.toString()}, to: ${s.toString()}`);const u=[];for(let e=0;e<l.length;e+=2){if(l[e]!==c[e])throw new zt(`Cannot interpolate values containing mismatched anchors. from[${e}]: ${l[e]}, to[${e}]: ${c[e]}`);u.push(l[e]);const[s,d]=l[e+1],[f,_]=c[e+1];u.push([fr(s,f,a),fr(d,_,a)])}return new Ct(u)}}class Lt{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new Lt({name:e,available:!1}):null}}class Ot{constructor(e,s,a){this.from=e,this.to=s,this.transition=a}static interpolate(e,s,a){return new Ot(e,s,a)}static parse(e){return e instanceof Ot?e:Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]?new Ot(e[0],e[1],e[2]):"object"==typeof e&&"string"==typeof e.from&&"string"==typeof e.to&&"number"==typeof e.transition?new Ot(e.from,e.to,e.transition):"string"==typeof e?new Ot(e,e,1):void 0}}function xr(e,s,a,l){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof s&&s>=0&&s<=255&&"number"==typeof a&&a>=0&&a<=255?void 0===l||"number"==typeof l&&l>=0&&l<=1?null:`Invalid rgba value [${[e,s,a,l].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof l?[e,s,a,l]:[e,s,a]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function vr(e){if(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||e instanceof Ot||e instanceof It||e instanceof Mt||e instanceof Dt||e instanceof Ft||e instanceof Bt||e instanceof Pt||e instanceof Ct||e instanceof Lt)return!0;if(Array.isArray(e)){for(const s of e)if(!vr(s))return!1;return!0}if("object"==typeof e){for(const s in e)if(!vr(e[s]))return!1;return!0}return!1}function br(e){if(null===e)return oi;if("string"==typeof e)return ci;if("boolean"==typeof e)return hi;if("number"==typeof e)return li;if(e instanceof It)return ui;if(e instanceof Ot)return di;if(e instanceof Mt)return mi;if(e instanceof Dt)return _i;if(e instanceof Ft)return xi;if(e instanceof Bt)return wi;if(e instanceof Pt)return bi;if(e instanceof Ct)return Ei;if(e instanceof Lt)return Ii;if(Array.isArray(e)){const s=e.length;let a;for(const s of e){const e=br(s);if(a){if(a===e)continue;a=fi;break}a=e}return Ai(a||fi,s)}return pi}function wr(e){const s=typeof e;return null===e?"":"string"===s||"number"===s||"boolean"===s?String(e):e instanceof It||e instanceof Ot||e instanceof Dt||e instanceof Ft||e instanceof Bt||e instanceof Pt||e instanceof Ct||e instanceof Lt?e.toString():JSON.stringify(e)}class qt{constructor(e,s){this.type=e,this.value=s}static parse(e,s){if(2!==e.length)return s.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!vr(e[1]))return s.error("invalid value");const a=e[1];let l=br(a);const c=s.expectedType;return"array"!==l.kind||0!==l.N||!c||"array"!==c.kind||"number"==typeof c.N&&0!==c.N||(l=c),new qt(l,a)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const Sr={string:ci,number:li,boolean:hi,object:pi};class Gt{constructor(e,s){this.type=e,this.args=s}static parse(e,s){if(e.length<2)return s.error("Expected at least one argument.");let a,l=1;const c=e[0];if("array"===c){let c,u;if(e.length>2){const a=e[1];if("string"!=typeof a||!(a in Sr)||"object"===a)return s.error('The item type argument of "array" must be one of string, number, boolean',1);c=Sr[a],l++}else c=fi;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return s.error('The length argument to "array" must be a positive integer literal',2);u=e[2],l++}a=Ai(c,u)}else{if(!Sr[c])throw new Error(`Types doesn't contain name = ${c}`);a=Sr[c]}const u=[];for(;l<e.length;l++){const a=s.parse(e[l],l,fi);if(!a)return null;u.push(a)}return new Gt(a,u)}evaluate(e){for(let s=0;s<this.args.length;s++){const a=this.args[s].evaluate(e);if(!Li(this.type,br(a)))return a;if(s===this.args.length-1)throw new zt(`Expected value to be of type ${zi(this.type)}, but found ${zi(br(a))} instead.`)}throw new Error}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const Pr={"to-boolean":hi,"to-color":ui,"to-number":li,"to-string":ci};class Yt{constructor(e,s){this.type=e,this.args=s}static parse(e,s){if(e.length<2)return s.error("Expected at least one argument.");const a=e[0];if(!Pr[a])throw new Error(`Can't parse ${a} as it is not part of the known types`);if(("to-boolean"===a||"to-string"===a)&&2!==e.length)return s.error("Expected one argument.");const l=Pr[a],c=[];for(let a=1;a<e.length;a++){const l=s.parse(e[a],a,fi);if(!l)return null;c.push(l)}return new Yt(l,c)}evaluate(e){switch(this.type.kind){case"boolean":return Boolean(this.args[0].evaluate(e));case"color":{let s,a;for(const l of this.args){if(s=l.evaluate(e),a=null,s instanceof It)return s;if("string"==typeof s){const a=e.parseColor(s);if(a)return a}else if(Array.isArray(s)&&(a=s.length<3||s.length>4?`Invalid rgba value ${JSON.stringify(s)}: expected an array containing either three or four numeric values.`:xr(s[0],s[1],s[2],s[3]),!a))return new It(s[0]/255,s[1]/255,s[2]/255,s[3])}throw new zt(a||`Could not parse color from value '${"string"==typeof s?s:JSON.stringify(s)}'`)}case"padding":{let s;for(const a of this.args){s=a.evaluate(e);const l=Ft.parse(s);if(l)return l}throw new zt(`Could not parse padding from value '${"string"==typeof s?s:JSON.stringify(s)}'`)}case"numberArray":{let s;for(const a of this.args){s=a.evaluate(e);const l=Bt.parse(s);if(l)return l}throw new zt(`Could not parse numberArray from value '${"string"==typeof s?s:JSON.stringify(s)}'`)}case"colorArray":{let s;for(const a of this.args){s=a.evaluate(e);const l=Pt.parse(s);if(l)return l}throw new zt(`Could not parse colorArray from value '${"string"==typeof s?s:JSON.stringify(s)}'`)}case"variableAnchorOffsetCollection":{let s;for(const a of this.args){s=a.evaluate(e);const l=Ct.parse(s);if(l)return l}throw new zt(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof s?s:JSON.stringify(s)}'`)}case"number":{let s=null;for(const a of this.args){if(s=a.evaluate(e),null===s)return 0;const l=Number(s);if(!isNaN(l))return l}throw new zt(`Could not convert ${JSON.stringify(s)} to number.`)}case"formatted":return Dt.fromString(wr(this.args[0].evaluate(e)));case"resolvedImage":return Lt.fromString(wr(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return wr(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const Cr=["Unknown","Point","LineString","Polygon"];class Ht{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Cr[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||{}}parseColor(e){let s=this._parseColorCache.get(e);return s||(s=It.parse(e),this._parseColorCache.set(e,s)),s}}class Kt{constructor(e,s,a=[],l,c=new Pe,u=[]){this.registry=e,this.path=a,this.key=a.map((e=>`[${e}]`)).join(""),this.scope=c,this.errors=u,this.expectedType=l,this._isConstant=s}parse(e,s,a,l,c={}){return s?this.concat(s,a,l)._parse(e,c):this._parse(e,c)}_parse(e,s){function a(e,s,a){return"assert"===a?new Gt(s,[e]):"coerce"===a?new Yt(s,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const l=e[0];if("string"!=typeof l)return this.error(`Expression name must be a string, but found ${typeof l} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const c=this.registry[l];if(c){let l=c.parse(e,this);if(!l)return null;if(this.expectedType){const e=this.expectedType,c=l.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==c.kind){if("projectionDefinition"===e.kind&&["string","array"].includes(c.kind)||["color","formatted","resolvedImage"].includes(e.kind)&&["value","string"].includes(c.kind)||["padding","numberArray"].includes(e.kind)&&["value","number","array"].includes(c.kind)||"colorArray"===e.kind&&["value","string","array"].includes(c.kind)||"variableAnchorOffsetCollection"===e.kind&&["value","array"].includes(c.kind))l=a(l,e,s.typeAnnotation||"coerce");else if(this.checkSubtype(e,c))return null}else l=a(l,e,s.typeAnnotation||"assert")}if(!(l instanceof qt)&&"resolvedImage"!==l.type.kind&&this._isConstant(l)){const s=new Ht;try{l=new qt(l.type,l.evaluate(s))}catch(e){return this.error(e.message),null}}return l}return this.error(`Unknown expression "${l}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,s,a){const l="number"==typeof e?this.path.concat(e):this.path,c=a?this.scope.concat(a):this.scope;return new Kt(this.registry,this._isConstant,l,s||null,c,this.errors)}error(e,...s){const a=`${this.key}${s.map((e=>`[${e}]`)).join("")}`;this.errors.push(new Be(a,e))}checkSubtype(e,s){const a=Li(e,s);return a&&this.error(a),a}}class Jt{constructor(e,s){this.type=s.type,this.bindings=[].concat(e),this.result=s}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const s of this.bindings)e(s[1]);e(this.result)}static parse(e,s){if(e.length<4)return s.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const a=[];for(let l=1;l<e.length-1;l+=2){const c=e[l];if("string"!=typeof c)return s.error(`Expected string, but found ${typeof c} instead.`,l);if(/[^a-zA-Z0-9_]/.test(c))return s.error("Variable names must contain only alphanumeric characters or '_'.",l);const u=s.parse(e[l+1],l+1);if(!u)return null;a.push([c,u])}const l=s.parse(e[e.length-1],e.length-1,s.expectedType,a);return l?new Jt(a,l):null}outputDefined(){return this.result.outputDefined()}}class Wt{constructor(e,s){this.type=s.type,this.name=e,this.boundExpression=s}static parse(e,s){if(2!==e.length||"string"!=typeof e[1])return s.error("'var' expression requires exactly one string literal argument.");const a=e[1];return s.scope.has(a)?new Wt(a,s.scope.get(a)):s.error(`Unknown variable "${a}". Make sure "${a}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}}class Qt{constructor(e,s,a){this.type=e,this.index=s,this.input=a}static parse(e,s){if(3!==e.length)return s.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const a=s.parse(e[1],1,li),l=s.parse(e[2],2,Ai(s.expectedType||fi));return a&&l?new Qt(l.type.itemType,a,l):null}evaluate(e){const s=this.index.evaluate(e),a=this.input.evaluate(e);if(s<0)throw new zt(`Array index out of bounds: ${s} < 0.`);if(s>=a.length)throw new zt(`Array index out of bounds: ${s} > ${a.length-1}.`);if(s!==Math.floor(s))throw new zt(`Array index must be an integer, but found ${s} instead.`);return a[s]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class er{constructor(e,s){this.type=hi,this.needle=e,this.haystack=s}static parse(e,s){if(3!==e.length)return s.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const a=s.parse(e[1],1,fi),l=s.parse(e[2],2,fi);return a&&l?Fi(a.type,[hi,ci,li,oi,fi])?new er(a,l):s.error(`Expected first argument to be of type boolean, string, number or null, but found ${zi(a.type)} instead`):null}evaluate(e){const s=this.needle.evaluate(e),a=this.haystack.evaluate(e);if(!a)return!1;if(!Bi(s,["boolean","string","number","null"]))throw new zt(`Expected first argument to be of type boolean, string, number or null, but found ${zi(br(s))} instead.`);if(!Bi(a,["string","array"]))throw new zt(`Expected second argument to be of type array or string, but found ${zi(br(a))} instead.`);return a.indexOf(s)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class tr{constructor(e,s,a){this.type=li,this.needle=e,this.haystack=s,this.fromIndex=a}static parse(e,s){if(e.length<=2||e.length>=5)return s.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const a=s.parse(e[1],1,fi),l=s.parse(e[2],2,fi);if(!a||!l)return null;if(!Fi(a.type,[hi,ci,li,oi,fi]))return s.error(`Expected first argument to be of type boolean, string, number or null, but found ${zi(a.type)} instead`);if(4===e.length){const c=s.parse(e[3],3,li);return c?new tr(a,l,c):null}return new tr(a,l)}evaluate(e){const s=this.needle.evaluate(e),a=this.haystack.evaluate(e);if(!Bi(s,["boolean","string","number","null"]))throw new zt(`Expected first argument to be of type boolean, string, number or null, but found ${zi(br(s))} instead.`);let l;if(this.fromIndex&&(l=this.fromIndex.evaluate(e)),Bi(a,["string"])){const e=a.indexOf(s,l);return-1===e?-1:[...a.slice(0,e)].length}if(Bi(a,["array"]))return a.indexOf(s,l);throw new zt(`Expected second argument to be of type array or string, but found ${zi(br(a))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class rr{constructor(e,s,a,l,c,u){this.inputType=e,this.type=s,this.input=a,this.cases=l,this.outputs=c,this.otherwise=u}static parse(e,s){if(e.length<5)return s.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return s.error("Expected an even number of arguments.");let a,l;s.expectedType&&"value"!==s.expectedType.kind&&(l=s.expectedType);const c={},u=[];for(let d=2;d<e.length-1;d+=2){let f=e[d];const _=e[d+1];Array.isArray(f)||(f=[f]);const y=s.concat(d);if(0===f.length)return y.error("Expected at least one branch label.");for(const e of f){if("number"!=typeof e&&"string"!=typeof e)return y.error("Branch labels must be numbers or strings.");if("number"==typeof e&&Math.abs(e)>Number.MAX_SAFE_INTEGER)return y.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return y.error("Numeric branch labels must be integer values.");if(a){if(y.checkSubtype(a,br(e)))return null}else a=br(e);if(void 0!==c[String(e)])return y.error("Branch labels must be unique.");c[String(e)]=u.length}const b=s.parse(_,d,l);if(!b)return null;l=l||b.type,u.push(b)}const d=s.parse(e[1],1,fi);if(!d)return null;const f=s.parse(e[e.length-1],e.length-1,l);return f?"value"!==d.type.kind&&s.concat(1).checkSubtype(a,d.type)?null:new rr(a,l,d,c,u,f):null}evaluate(e){const s=this.input.evaluate(e);return(br(s)===this.inputType&&this.outputs[this.cases[s]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))&&this.otherwise.outputDefined()}}class nr{constructor(e,s,a){this.type=e,this.branches=s,this.otherwise=a}static parse(e,s){if(e.length<4)return s.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return s.error("Expected an odd number of arguments.");let a;s.expectedType&&"value"!==s.expectedType.kind&&(a=s.expectedType);const l=[];for(let c=1;c<e.length-1;c+=2){const u=s.parse(e[c],c,hi);if(!u)return null;const d=s.parse(e[c+1],c+1,a);if(!d)return null;l.push([u,d]),a=a||d.type}const c=s.parse(e[e.length-1],e.length-1,a);if(!c)return null;if(!a)throw new Error("Can't infer output type");return new nr(a,l,c)}evaluate(e){for(const[s,a]of this.branches)if(s.evaluate(e))return a.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[s,a]of this.branches)e(s),e(a);e(this.otherwise)}outputDefined(){return this.branches.every((([e,s])=>s.outputDefined()))&&this.otherwise.outputDefined()}}class ir{constructor(e,s,a,l){this.type=e,this.input=s,this.beginIndex=a,this.endIndex=l}static parse(e,s){if(e.length<=2||e.length>=5)return s.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const a=s.parse(e[1],1,fi),l=s.parse(e[2],2,li);if(!a||!l)return null;if(!Fi(a.type,[Ai(fi),ci,fi]))return s.error(`Expected first argument to be of type array or string, but found ${zi(a.type)} instead`);if(4===e.length){const c=s.parse(e[3],3,li);return c?new ir(a.type,a,l,c):null}return new ir(a.type,a,l)}evaluate(e){const s=this.input.evaluate(e),a=this.beginIndex.evaluate(e);let l;if(this.endIndex&&(l=this.endIndex.evaluate(e)),Bi(s,["string"]))return[...s].slice(a,l).join("");if(Bi(s,["array"]))return s.slice(a,l);throw new zt(`Expected first argument to be of type array or string, but found ${zi(br(s))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function Ar(e,s){const a=e.length-1;let l,c,u=0,d=a,f=0;for(;u<=d;)if(f=Math.floor((u+d)/2),l=e[f],c=e[f+1],l<=s){if(f===a||s<c)return f;u=f+1}else{if(!(l>s))throw new zt("Input is not a number.");d=f-1}return 0}class ar{constructor(e,s,a){this.type=e,this.input=s,this.labels=[],this.outputs=[];for(const[e,s]of a)this.labels.push(e),this.outputs.push(s)}static parse(e,s){if(e.length-1<4)return s.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return s.error("Expected an even number of arguments.");const a=s.parse(e[1],1,li);if(!a)return null;const l=[];let c=null;s.expectedType&&"value"!==s.expectedType.kind&&(c=s.expectedType);for(let a=1;a<e.length;a+=2){const u=1===a?-1/0:e[a],d=e[a+1],f=a,_=a+1;if("number"!=typeof u)return s.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',f);if(l.length&&l[l.length-1][0]>=u)return s.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',f);const y=s.parse(d,_,c);if(!y)return null;c=c||y.type,l.push([u,y])}return new ar(c,a,l)}evaluate(e){const s=this.labels,a=this.outputs;if(1===s.length)return a[0].evaluate(e);const l=this.input.evaluate(e);if(l<=s[0])return a[0].evaluate(e);const c=s.length;return l>=s[c-1]?a[c-1].evaluate(e):a[Ar(s,l)].evaluate(e)}eachChild(e){e(this.input);for(const s of this.outputs)e(s)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function Dr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var zr,Rr,Lr=function(){if(Rr)return zr;function s(s,a,l,c){(this||e).cx=3*s,(this||e).bx=3*(l-s)-(this||e).cx,(this||e).ax=1-(this||e).cx-(this||e).bx,(this||e).cy=3*a,(this||e).by=3*(c-a)-(this||e).cy,(this||e).ay=1-(this||e).cy-(this||e).by,(this||e).p1x=s,(this||e).p1y=a,(this||e).p2x=l,(this||e).p2y=c}return Rr=1,zr=s,s.prototype={sampleCurveX:function(s){return(((this||e).ax*s+(this||e).bx)*s+(this||e).cx)*s},sampleCurveY:function(s){return(((this||e).ay*s+(this||e).by)*s+(this||e).cy)*s},sampleCurveDerivativeX:function(s){return(3*(this||e).ax*s+2*(this||e).bx)*s+(this||e).cx},solveCurveX:function(e,s){if(void 0===s&&(s=1e-6),e<0)return 0;if(e>1)return 1;for(var a=e,l=0;l<8;l++){var c=this.sampleCurveX(a)-e;if(Math.abs(c)<s)return a;var u=this.sampleCurveDerivativeX(a);if(Math.abs(u)<1e-6)break;a-=c/u}var d=0,f=1;for(a=e,l=0;l<20&&(c=this.sampleCurveX(a),!(Math.abs(c-e)<s));l++)e>c?d=a:f=a,a=.5*(f-d)+d;return a},solve:function(e,s){return this.sampleCurveY(this.solveCurveX(e,s))}},zr}(),Fr=Dr(Lr);class pr{constructor(e,s,a,l,c){this.type=e,this.operator=s,this.interpolation=a,this.input=l,this.labels=[],this.outputs=[];for(const[e,s]of c)this.labels.push(e),this.outputs.push(s)}static interpolationFactor(e,s,a,l){let c=0;if("exponential"===e.name)c=Br(s,e.base,a,l);else if("linear"===e.name)c=Br(s,1,a,l);else if("cubic-bezier"===e.name){const u=e.controlPoints;c=new Fr(u[0],u[1],u[2],u[3]).solve(Br(s,1,a,l))}return c}static parse(e,s){let[a,l,c,...u]=e;if(!Array.isArray(l)||0===l.length)return s.error("Expected an interpolation type expression.",1);if("linear"===l[0])l={name:"linear"};else if("exponential"===l[0]){const e=l[1];if("number"!=typeof e)return s.error("Exponential interpolation requires a numeric base.",1,1);l={name:"exponential",base:e}}else{if("cubic-bezier"!==l[0])return s.error(`Unknown interpolation type ${String(l[0])}`,1,0);{const e=l.slice(1);if(4!==e.length||e.some((e=>"number"!=typeof e||e<0||e>1)))return s.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);l={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return s.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return s.error("Expected an even number of arguments.");if(c=s.parse(c,2,li),!c)return null;const d=[];let f=null;"interpolate-hcl"!==a&&"interpolate-lab"!==a||s.expectedType==bi?s.expectedType&&"value"!==s.expectedType.kind&&(f=s.expectedType):f=ui;for(let e=0;e<u.length;e+=2){const a=u[e],l=u[e+1],c=e+3,_=e+4;if("number"!=typeof a)return s.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',c);if(d.length&&d[d.length-1][0]>=a)return s.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',c);const y=s.parse(l,_,f);if(!y)return null;f=f||y.type,d.push([a,y])}return Oi(f,li)||Oi(f,di)||Oi(f,ui)||Oi(f,xi)||Oi(f,wi)||Oi(f,bi)||Oi(f,Ei)||Oi(f,Ai(li))?new pr(f,a,l,c,d):s.error(`Type ${zi(f)} is not interpolatable.`)}evaluate(e){const s=this.labels,a=this.outputs;if(1===s.length)return a[0].evaluate(e);const l=this.input.evaluate(e);if(l<=s[0])return a[0].evaluate(e);const c=s.length;if(l>=s[c-1])return a[c-1].evaluate(e);const u=Ar(s,l),d=pr.interpolationFactor(this.interpolation,l,s[u],s[u+1]),f=a[u].evaluate(e),_=a[u+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return fr(f,_,d);case"color":return It.interpolate(f,_,d);case"padding":return Ft.interpolate(f,_,d);case"colorArray":return Pt.interpolate(f,_,d);case"numberArray":return Bt.interpolate(f,_,d);case"variableAnchorOffsetCollection":return Ct.interpolate(f,_,d);case"array":return mr(f,_,d);case"projectionDefinition":return Ot.interpolate(f,_,d)}case"interpolate-hcl":switch(this.type.kind){case"color":return It.interpolate(f,_,d,"hcl");case"colorArray":return Pt.interpolate(f,_,d,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return It.interpolate(f,_,d,"lab");case"colorArray":return Pt.interpolate(f,_,d,"lab")}}}eachChild(e){e(this.input);for(const s of this.outputs)e(s)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function Br(e,s,a,l){const c=l-a,u=e-a;return 0===c?0:1===s?u/c:(Math.pow(s,u)-1)/(Math.pow(s,c)-1)}const Or={color:It.interpolate,number:fr,padding:Ft.interpolate,numberArray:Bt.interpolate,colorArray:Pt.interpolate,variableAnchorOffsetCollection:Ct.interpolate,array:mr};class yr{constructor(e,s){this.type=e,this.args=s}static parse(e,s){if(e.length<2)return s.error("Expected at least one argument.");let a=null;const l=s.expectedType;l&&"value"!==l.kind&&(a=l);const c=[];for(const l of e.slice(1)){const e=s.parse(l,1+c.length,a,void 0,{typeAnnotation:"omit"});if(!e)return null;a=a||e.type,c.push(e)}if(!a)throw new Error("No output type");const u=l&&c.some((e=>Li(l,e.type)));return new yr(u?fi:a,c)}evaluate(e){let s,a=null,l=0;for(const c of this.args)if(l++,a=c.evaluate(e),a&&a instanceof Lt&&!a.available&&(s||(s=a.name),a=null,l===this.args.length&&(a=s)),null!==a)break;return a}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}function Vr(e,s){return"=="===e||"!="===e?"boolean"===s.kind||"string"===s.kind||"number"===s.kind||"null"===s.kind||"value"===s.kind:"string"===s.kind||"number"===s.kind||"value"===s.kind}function Ur(e,s,a,l){return 0===l.compare(s,a)}function Gr(e,s,a){const l="=="!==e&&"!="!==e;return class i{constructor(e,s,a){this.type=hi,this.lhs=e,this.rhs=s,this.collator=a,this.hasUntypedArgument="value"===e.type.kind||"value"===s.type.kind}static parse(e,s){if(3!==e.length&&4!==e.length)return s.error("Expected two or three arguments.");const a=e[0];let c=s.parse(e[1],1,fi);if(!c)return null;if(!Vr(a,c.type))return s.concat(1).error(`"${a}" comparisons are not supported for type '${zi(c.type)}'.`);let u=s.parse(e[2],2,fi);if(!u)return null;if(!Vr(a,u.type))return s.concat(2).error(`"${a}" comparisons are not supported for type '${zi(u.type)}'.`);if(c.type.kind!==u.type.kind&&"value"!==c.type.kind&&"value"!==u.type.kind)return s.error(`Cannot compare types '${zi(c.type)}' and '${zi(u.type)}'.`);l&&("value"===c.type.kind&&"value"!==u.type.kind?c=new Gt(u.type,[c]):"value"!==c.type.kind&&"value"===u.type.kind&&(u=new Gt(c.type,[u])));let d=null;if(4===e.length){if("string"!==c.type.kind&&"string"!==u.type.kind&&"value"!==c.type.kind&&"value"!==u.type.kind)return s.error("Cannot use collator to compare non-string types.");if(d=s.parse(e[3],3,mi),!d)return null}return new i(c,u,d)}evaluate(c){const u=this.lhs.evaluate(c),d=this.rhs.evaluate(c);if(l&&this.hasUntypedArgument){const s=br(u),a=br(d);if(s.kind!==a.kind||"string"!==s.kind&&"number"!==s.kind)throw new zt(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${s.kind}, ${a.kind}) instead.`)}if(this.collator&&!l&&this.hasUntypedArgument){const e=br(u),a=br(d);if("string"!==e.kind||"string"!==a.kind)return s(c,u,d)}return this.collator?a(c,u,d,this.collator.evaluate(c)):s(c,u,d)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}const qr=Gr("==",(function(e,s,a){return s===a}),Ur),$r=Gr("!=",(function(e,s,a){return s!==a}),(function(e,s,a,l){return!Ur(0,s,a,l)})),Wr=Gr("<",(function(e,s,a){return s<a}),(function(e,s,a,l){return l.compare(s,a)<0})),Xr=Gr(">",(function(e,s,a){return s>a}),(function(e,s,a,l){return l.compare(s,a)>0})),Kr=Gr("<=",(function(e,s,a){return s<=a}),(function(e,s,a,l){return l.compare(s,a)<=0})),en=Gr(">=",(function(e,s,a){return s>=a}),(function(e,s,a,l){return l.compare(s,a)>=0}));class Tr{constructor(e,s,a){this.type=mi,this.locale=a,this.caseSensitive=e,this.diacriticSensitive=s}static parse(e,s){if(2!==e.length)return s.error("Expected one argument.");const a=e[1];if("object"!=typeof a||Array.isArray(a))return s.error("Collator options argument must be an object.");const l=s.parse(void 0!==a["case-sensitive"]&&a["case-sensitive"],1,hi);if(!l)return null;const c=s.parse(void 0!==a["diacritic-sensitive"]&&a["diacritic-sensitive"],1,hi);if(!c)return null;let u=null;return a.locale&&(u=s.parse(a.locale,1,ci),!u)?null:new Tr(l,c,u)}evaluate(e){return new Mt(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}class Ir{constructor(e,s,a,l,c){this.type=ci,this.number=e,this.locale=s,this.currency=a,this.minFractionDigits=l,this.maxFractionDigits=c}static parse(e,s){if(3!==e.length)return s.error("Expected two arguments.");const a=s.parse(e[1],1,li);if(!a)return null;const l=e[2];if("object"!=typeof l||Array.isArray(l))return s.error("NumberFormat options argument must be an object.");let c=null;if(l.locale&&(c=s.parse(l.locale,1,ci),!c))return null;let u=null;if(l.currency&&(u=s.parse(l.currency,1,ci),!u))return null;let d=null;if(l["min-fraction-digits"]&&(d=s.parse(l["min-fraction-digits"],1,li),!d))return null;let f=null;return l["max-fraction-digits"]&&(f=s.parse(l["max-fraction-digits"],1,li),!f)?null:new Ir(a,c,u,d,f)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class Mr{constructor(e){this.type=_i,this.sections=e}static parse(e,s){if(e.length<2)return s.error("Expected at least one argument.");const a=e[1];if(!Array.isArray(a)&&"object"==typeof a)return s.error("First argument must be an image or text section.");const l=[];let c=!1;for(let a=1;a<=e.length-1;++a){const u=e[a];if(c&&"object"==typeof u&&!Array.isArray(u)){c=!1;let e=null;if(u["font-scale"]&&(e=s.parse(u["font-scale"],1,li),!e))return null;let a=null;if(u["text-font"]&&(a=s.parse(u["text-font"],1,Ai(ci)),!a))return null;let d=null;if(u["text-color"]&&(d=s.parse(u["text-color"],1,ui),!d))return null;let f=null;if(u["vertical-align"]){if("string"==typeof u["vertical-align"]&&!_r.includes(u["vertical-align"]))return s.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${u["vertical-align"]}' instead.`);if(f=s.parse(u["vertical-align"],1,ci),!f)return null}const _=l[l.length-1];_.scale=e,_.font=a,_.textColor=d,_.verticalAlign=f}else{const u=s.parse(e[a],1,fi);if(!u)return null;const d=u.type.kind;if("string"!==d&&"value"!==d&&"null"!==d&&"resolvedImage"!==d)return s.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");c=!0,l.push({content:u,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Mr(l)}evaluate(e){return new Dt(this.sections.map((s=>{const a=s.content.evaluate(e);return br(a)===Ii?new kt("",a,null,null,null,s.verticalAlign?s.verticalAlign.evaluate(e):null):new kt(wr(a),null,s.scale?s.scale.evaluate(e):null,s.font?s.font.evaluate(e).join(","):null,s.textColor?s.textColor.evaluate(e):null,s.verticalAlign?s.verticalAlign.evaluate(e):null)})))}eachChild(e){for(const s of this.sections)e(s.content),s.scale&&e(s.scale),s.font&&e(s.font),s.textColor&&e(s.textColor),s.verticalAlign&&e(s.verticalAlign)}outputDefined(){return!1}}class Er{constructor(e){this.type=Ii,this.input=e}static parse(e,s){if(2!==e.length)return s.error("Expected two arguments.");const a=s.parse(e[1],1,ci);return a?new Er(a):s.error("No image name provided.")}evaluate(e){const s=this.input.evaluate(e),a=Lt.fromString(s);return a&&e.availableImages&&(a.available=e.availableImages.indexOf(s)>-1),a}eachChild(e){e(this.input)}outputDefined(){return!1}}class kr{constructor(e){this.type=li,this.input=e}static parse(e,s){if(2!==e.length)return s.error(`Expected 1 argument, but found ${e.length-1} instead.`);const a=s.parse(e[1],1);return a?"array"!==a.type.kind&&"string"!==a.type.kind&&"value"!==a.type.kind?s.error(`Expected argument of type string or array, but found ${zi(a.type)} instead.`):new kr(a):null}evaluate(e){const s=this.input.evaluate(e);if("string"==typeof s)return[...s].length;if(Array.isArray(s))return s.length;throw new zt(`Expected value to be of type string or array, but found ${zi(br(s))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const tn=8192;function rn(e,s){const a=(180+e[0])/360,l=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,c=Math.pow(2,s.z);return[Math.round(a*c*tn),Math.round(l*c*tn)]}function nn(e,s){const a=Math.pow(2,s.z);return[(c=(e[0]/tn+s.x)/a,360*c-180),(l=(e[1]/tn+s.y)/a,360/Math.PI*Math.atan(Math.exp((180-360*l)*Math.PI/180))-90)];var l,c}function sn(e,s){e[0]=Math.min(e[0],s[0]),e[1]=Math.min(e[1],s[1]),e[2]=Math.max(e[2],s[0]),e[3]=Math.max(e[3],s[1])}function on(e,s){return!(e[0]<=s[0]||e[2]>=s[2]||e[1]<=s[1]||e[3]>=s[3])}function ln(e,s,a){const l=e[0]-s[0],c=e[1]-s[1],u=e[0]-a[0],d=e[1]-a[1];return l*d-u*c==0&&l*u<=0&&c*d<=0}function cn(e,s,a,l){return 0!=(c=[l[0]-a[0],l[1]-a[1]])[0]*(u=[s[0]-e[0],s[1]-e[1]])[1]-c[1]*u[0]&&!(!mn(e,s,a,l)||!mn(a,l,e,s));var c,u}function hn(e,s,a){for(const l of a)for(let a=0;a<l.length-1;++a)if(cn(e,s,l[a],l[a+1]))return!0;return!1}function un(e,s,a=!1){let l=!1;for(const f of s)for(let s=0;s<f.length-1;s++){if(ln(e,f[s],f[s+1]))return a;(u=f[s])[1]>(c=e)[1]!=(d=f[s+1])[1]>c[1]&&c[0]<(d[0]-u[0])*(c[1]-u[1])/(d[1]-u[1])+u[0]&&(l=!l)}var c,u,d;return l}function dn(e,s){for(const a of s)if(un(e,a))return!0;return!1}function pn(e,s){for(const a of e)if(!un(a,s))return!1;for(let a=0;a<e.length-1;++a)if(hn(e[a],e[a+1],s))return!1;return!0}function fn(e,s){for(const a of s)if(pn(e,a))return!0;return!1}function mn(e,s,a,l){const c=l[0]-a[0],u=l[1]-a[1],d=(e[0]-a[0])*u-c*(e[1]-a[1]),f=(s[0]-a[0])*u-c*(s[1]-a[1]);return d>0&&f<0||d<0&&f>0}function _n(e,s,a){const l=[];for(let c=0;c<e.length;c++){const u=[];for(let l=0;l<e[c].length;l++){const d=rn(e[c][l],a);sn(s,d),u.push(d)}l.push(u)}return l}function gn(e,s,a){const l=[];for(let c=0;c<e.length;c++){const u=_n(e[c],s,a);l.push(u)}return l}function yn(e,s,a,l){if(e[0]<a[0]||e[0]>a[2]){const s=.5*l;let c=e[0]-a[0]>s?-l:a[0]-e[0]>s?l:0;0===c&&(c=e[0]-a[2]>s?-l:a[2]-e[0]>s?l:0),e[0]+=c}sn(s,e)}function xn(e,s,a,l){const c=Math.pow(2,l.z)*tn,u=[l.x*tn,l.y*tn],d=[];for(const l of e)for(const e of l){const l=[e.x+u[0],e.y+u[1]];yn(l,s,a,c),d.push(l)}return d}function vn(e,s,a,l){const c=Math.pow(2,l.z)*tn,u=[l.x*tn,l.y*tn],d=[];for(const a of e){const e=[];for(const l of a){const a=[l.x+u[0],l.y+u[1]];sn(s,a),e.push(a)}d.push(e)}if(s[2]-s[0]<=c/2){(f=s)[0]=f[1]=1/0,f[2]=f[3]=-1/0;for(const e of d)for(const l of e)yn(l,s,a,c)}var f;return d}class Zr{constructor(e,s){this.type=hi,this.geojson=e,this.geometries=s}static parse(e,s){if(2!==e.length)return s.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(vr(e[1])){const s=e[1];if("FeatureCollection"===s.type){const e=[];for(const a of s.features){const{type:s,coordinates:l}=a.geometry;"Polygon"===s&&e.push(l),"MultiPolygon"===s&&e.push(...l)}if(e.length)return new Zr(s,{type:"MultiPolygon",coordinates:e})}else if("Feature"===s.type){const e=s.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Zr(s,s.geometry)}else if("Polygon"===s.type||"MultiPolygon"===s.type)return new Zr(s,s)}return s.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,s){const a=[1/0,1/0,-1/0,-1/0],l=[1/0,1/0,-1/0,-1/0],c=e.canonicalID();if("Polygon"===s.type){const u=_n(s.coordinates,l,c),d=xn(e.geometry(),a,l,c);if(!on(a,l))return!1;for(const e of d)if(!un(e,u))return!1}if("MultiPolygon"===s.type){const u=gn(s.coordinates,l,c),d=xn(e.geometry(),a,l,c);if(!on(a,l))return!1;for(const e of d)if(!dn(e,u))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,s){const a=[1/0,1/0,-1/0,-1/0],l=[1/0,1/0,-1/0,-1/0],c=e.canonicalID();if("Polygon"===s.type){const u=_n(s.coordinates,l,c),d=vn(e.geometry(),a,l,c);if(!on(a,l))return!1;for(const e of d)if(!pn(e,u))return!1}if("MultiPolygon"===s.type){const u=gn(s.coordinates,l,c),d=vn(e.geometry(),a,l,c);if(!on(a,l))return!1;for(const e of d)if(!fn(e,u))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let bn=class{constructor(e=[],s=(e,s)=>e<s?-1:e>s?1:0){if(this.data=e,this.length=this.data.length,this.compare=s,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],s=this.data.pop();return--this.length>0&&(this.data[0]=s,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:s,compare:a}=this,l=s[e];for(;e>0;){const c=e-1>>1,u=s[c];if(a(l,u)>=0)break;s[e]=u,e=c}s[e]=l}_down(e){const{data:s,compare:a}=this,l=this.length>>1,c=s[e];for(;e<l;){let l=1+(e<<1);const u=l+1;if(u<this.length&&a(s[u],s[l])<0&&(l=u),a(s[l],c)>=0)break;s[e]=s[l],e=l}s[e]=c}};function wn(e,s,a=0,l=e.length-1,c=Sn){for(;l>a;){if(l-a>600){const u=l-a+1,d=s-a+1,f=Math.log(u),_=.5*Math.exp(2*f/3),y=.5*Math.sqrt(f*_*(u-_)/u)*(d-u/2<0?-1:1);wn(e,s,Math.max(a,Math.floor(s-d*_/u+y)),Math.min(l,Math.floor(s+(u-d)*_/u+y)),c)}const u=e[s];let d=a,f=l;for(Tn(e,a,s),c(e[l],u)>0&&Tn(e,a,l);d<f;){for(Tn(e,d,f),d++,f--;c(e[d],u)<0;)d++;for(;c(e[f],u)>0;)f--}0===c(e[a],u)?Tn(e,a,f):(f++,Tn(e,f,l)),f<=s&&(a=f+1),s<=f&&(l=f-1)}}function Tn(e,s,a){const l=e[s];e[s]=e[a],e[a]=l}function Sn(e,s){return e<s?-1:e>s?1:0}function Pn(e,s){if(e.length<=1)return[e];const a=[];let l,c;for(const s of e){const e=Mn(s);0!==e&&(s.area=Math.abs(e),void 0===c&&(c=e<0),c===e<0?(l&&a.push(l),l=[s]):l.push(s))}if(l&&a.push(l),s>1)for(let e=0;e<a.length;e++)a[e].length<=s||(wn(a[e],s,1,a[e].length-1,In),a[e]=a[e].slice(0,s));return a}function In(e,s){return s.area-e.area}function Mn(e){let s=0;for(let a,l,c=0,u=e.length,d=u-1;c<u;d=c++)a=e[c],l=e[d],s+=(l.x-a.x)*(a.y+l.y);return s}const Cn=1/298.257223563,An=Cn*(2-Cn),Dn=Math.PI/180;class an{constructor(e){const s=6378.137*Dn*1e3,a=Math.cos(e*Dn),l=1/(1-An*(1-a*a)),c=Math.sqrt(l);this.kx=s*c*a,this.ky=s*c*l*(1-An)}distance(e,s){const a=this.wrap(e[0]-s[0])*this.kx,l=(e[1]-s[1])*this.ky;return Math.sqrt(a*a+l*l)}pointOnLine(e,s){let a,l,c,u,d=1/0;for(let f=0;f<e.length-1;f++){let _=e[f][0],y=e[f][1],b=this.wrap(e[f+1][0]-_)*this.kx,S=(e[f+1][1]-y)*this.ky,P=0;0===b&&0===S||(P=(this.wrap(s[0]-_)*this.kx*b+(s[1]-y)*this.ky*S)/(b*b+S*S),P>1?(_=e[f+1][0],y=e[f+1][1]):P>0&&(_+=b/this.kx*P,y+=S/this.ky*P)),b=this.wrap(s[0]-_)*this.kx,S=(s[1]-y)*this.ky;const M=b*b+S*S;M<d&&(d=M,a=_,l=y,c=f,u=P)}return{point:[a,l],index:c,t:Math.max(0,Math.min(1,u))}}wrap(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}}function zn(e,s){return s[0]-e[0]}function Rn(e){return e[1]-e[0]+1}function Ln(e,s){return e[1]>=e[0]&&e[1]<s}function Bn(e,s){if(e[0]>e[1])return[null,null];const a=Rn(e);if(s){if(2===a)return[e,null];const s=Math.floor(a/2);return[[e[0],e[0]+s],[e[0]+s,e[1]]]}if(1===a)return[e,null];const l=Math.floor(a/2)-1;return[[e[0],e[0]+l],[e[0]+l+1,e[1]]]}function On(e,s){if(!Ln(s,e.length))return[1/0,1/0,-1/0,-1/0];const a=[1/0,1/0,-1/0,-1/0];for(let l=s[0];l<=s[1];++l)sn(a,e[l]);return a}function Vn(e){const s=[1/0,1/0,-1/0,-1/0];for(const a of e)for(const e of a)sn(s,e);return s}function Nn(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function jn(e,s,a){if(!Nn(e)||!Nn(s))return NaN;let l=0,c=0;return e[2]<s[0]&&(l=s[0]-e[2]),e[0]>s[2]&&(l=e[0]-s[2]),e[1]>s[3]&&(c=e[1]-s[3]),e[3]<s[1]&&(c=s[1]-e[3]),a.distance([0,0],[l,c])}function Un(e,s,a){const l=a.pointOnLine(s,e);return a.distance(e,l.point)}function Gn(e,s,a,l,c){const u=Math.min(Un(e,[a,l],c),Un(s,[a,l],c)),d=Math.min(Un(a,[e,s],c),Un(l,[e,s],c));return Math.min(u,d)}function Zn(e,s,a,l,c){if(!Ln(s,e.length)||!Ln(l,a.length))return 1/0;let u=1/0;for(let d=s[0];d<s[1];++d){const s=e[d],f=e[d+1];for(let e=l[0];e<l[1];++e){const l=a[e],d=a[e+1];if(cn(s,f,l,d))return 0;u=Math.min(u,Gn(s,f,l,d,c))}}return u}function qn(e,s,a,l,c){if(!Ln(s,e.length)||!Ln(l,a.length))return NaN;let u=1/0;for(let d=s[0];d<=s[1];++d)for(let s=l[0];s<=l[1];++s)if(u=Math.min(u,c.distance(e[d],a[s])),0===u)return u;return u}function $n(e,s,a){if(un(e,s,!0))return 0;let l=1/0;for(const c of s){const s=c[0],u=c[c.length-1];if(s!==u&&(l=Math.min(l,Un(e,[u,s],a)),0===l))return l;const d=a.pointOnLine(c,e);if(l=Math.min(l,a.distance(e,d.point)),0===l)return l}return l}function Wn(e,s,a,l){if(!Ln(s,e.length))return NaN;for(let l=s[0];l<=s[1];++l)if(un(e[l],a,!0))return 0;let c=1/0;for(let u=s[0];u<s[1];++u){const s=e[u],d=e[u+1];for(const e of a)for(let a=0,u=e.length,f=u-1;a<u;f=a++){const u=e[f],_=e[a];if(cn(s,d,u,_))return 0;c=Math.min(c,Gn(s,d,u,_,l))}}return c}function Hn(e,s){for(const a of e)for(const e of a)if(un(e,s,!0))return!0;return!1}function Xn(e,s,a,l=1/0){const c=Vn(e),u=Vn(s);if(l!==1/0&&jn(c,u,a)>=l)return l;if(on(c,u)){if(Hn(e,s))return 0}else if(Hn(s,e))return 0;let d=1/0;for(const l of e)for(let e=0,c=l.length,u=c-1;e<c;u=e++){const c=l[u],f=l[e];for(const e of s)for(let s=0,l=e.length,u=l-1;s<l;u=s++){const l=e[u],_=e[s];if(cn(c,f,l,_))return 0;d=Math.min(d,Gn(c,f,l,_,a))}}return d}function Yn(e,s,a,l,c,u){if(!u)return;const d=jn(On(l,u),c,a);d<s&&e.push([d,u,[0,0]])}function Kn(e,s,a,l,c,u,d){if(!u||!d)return;const f=jn(On(l,u),On(c,d),a);f<s&&e.push([f,u,d])}function Jn(e,s,a,l,c=1/0){let u=Math.min(l.distance(e[0],a[0][0]),c);if(0===u)return u;const d=new bn([[0,[0,e.length-1],[0,0]]],zn),f=Vn(a);for(;d.length>0;){const c=d.pop();if(c[0]>=u)continue;const _=c[1],y=s?50:100;if(Rn(_)<=y){if(!Ln(_,e.length))return NaN;if(s){const s=Wn(e,_,a,l);if(isNaN(s)||0===s)return s;u=Math.min(u,s)}else for(let s=_[0];s<=_[1];++s){const c=$n(e[s],a,l);if(u=Math.min(u,c),0===u)return 0}}else{const a=Bn(_,s);Yn(d,u,l,e,f,a[0]),Yn(d,u,l,e,f,a[1])}}return u}function Qn(e,s,a,l,c,u=1/0){let d=Math.min(u,c.distance(e[0],a[0]));if(0===d)return d;const f=new bn([[0,[0,e.length-1],[0,a.length-1]]],zn);for(;f.length>0;){const u=f.pop();if(u[0]>=d)continue;const _=u[1],y=u[2],b=s?50:100,S=l?50:100;if(Rn(_)<=b&&Rn(y)<=S){if(!Ln(_,e.length)&&Ln(y,a.length))return NaN;let u;if(s&&l)u=Zn(e,_,a,y,c),d=Math.min(d,u);else if(s&&!l){const s=e.slice(_[0],_[1]+1);for(let e=y[0];e<=y[1];++e)if(u=Un(a[e],s,c),d=Math.min(d,u),0===d)return d}else if(!s&&l){const s=a.slice(y[0],y[1]+1);for(let a=_[0];a<=_[1];++a)if(u=Un(e[a],s,c),d=Math.min(d,u),0===d)return d}else u=qn(e,_,a,y,c),d=Math.min(d,u)}else{const u=Bn(_,s),b=Bn(y,l);Kn(f,d,c,e,a,u[0],b[0]),Kn(f,d,c,e,a,u[0],b[1]),Kn(f,d,c,e,a,u[1],b[0]),Kn(f,d,c,e,a,u[1],b[1])}}return d}function es(e){return"MultiPolygon"===e.type?e.coordinates.map((e=>({type:"Polygon",coordinates:e}))):"MultiLineString"===e.type?e.coordinates.map((e=>({type:"LineString",coordinates:e}))):"MultiPoint"===e.type?e.coordinates.map((e=>({type:"Point",coordinates:e}))):[e]}class En{constructor(e,s){this.type=li,this.geojson=e,this.geometries=s}static parse(e,s){if(2!==e.length)return s.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(vr(e[1])){const s=e[1];if("FeatureCollection"===s.type)return new En(s,s.features.map((e=>es(e.geometry))).flat());if("Feature"===s.type)return new En(s,es(s.geometry));if("type"in s&&"coordinates"in s)return new En(s,es(s))}return s.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,s){const a=e.geometry(),l=a.flat().map((s=>nn([s.x,s.y],e.canonical)));if(0===a.length)return NaN;const c=new an(l[0][1]);let u=1/0;for(const e of s){switch(e.type){case"Point":u=Math.min(u,Qn(l,!1,[e.coordinates],!1,c,u));break;case"LineString":u=Math.min(u,Qn(l,!1,e.coordinates,!0,c,u));break;case"Polygon":u=Math.min(u,Jn(l,!1,e.coordinates,c,u))}if(0===u)return u}return u}(e,this.geometries);if("LineString"===e.geometryType())return function(e,s){const a=e.geometry(),l=a.flat().map((s=>nn([s.x,s.y],e.canonical)));if(0===a.length)return NaN;const c=new an(l[0][1]);let u=1/0;for(const e of s){switch(e.type){case"Point":u=Math.min(u,Qn(l,!0,[e.coordinates],!1,c,u));break;case"LineString":u=Math.min(u,Qn(l,!0,e.coordinates,!0,c,u));break;case"Polygon":u=Math.min(u,Jn(l,!0,e.coordinates,c,u))}if(0===u)return u}return u}(e,this.geometries);if("Polygon"===e.geometryType())return function(e,s){const a=e.geometry();if(0===a.length||0===a[0].length)return NaN;const l=Pn(a,0).map((s=>s.map((s=>s.map((s=>nn([s.x,s.y],e.canonical))))))),c=new an(l[0][0][0][1]);let u=1/0;for(const e of s)for(const s of l){switch(e.type){case"Point":u=Math.min(u,Jn([e.coordinates],!1,s,c,u));break;case"LineString":u=Math.min(u,Jn(e.coordinates,!0,s,c,u));break;case"Polygon":u=Math.min(u,Xn(s,e.coordinates,c,u))}if(0===u)return u}return u}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class kn{constructor(e){this.type=fi,this.key=e}static parse(e,s){if(2!==e.length)return s.error(`Expected 1 argument, but found ${e.length-1} instead.`);const a=e[1];return null==a?s.error("Global state property must be defined."):"string"!=typeof a?s.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new kn(a)}evaluate(e){var s;const a=null===(s=e.globals)||void 0===s?void 0:s.globalState;return a&&0!==Object.keys(a).length?or(a,this.key):null}eachChild(){}outputDefined(){return!1}}const ts={"==":qr,"!=":$r,">":Xr,"<":Wr,">=":en,"<=":Kr,array:Gt,at:Qt,boolean:Gt,case:nr,coalesce:yr,collator:Tr,format:Mr,image:Er,in:er,"index-of":tr,interpolate:pr,"interpolate-hcl":pr,"interpolate-lab":pr,length:kr,let:Jt,literal:qt,match:rr,number:Gt,"number-format":Ir,object:Gt,slice:ir,step:ar,string:Gt,"to-boolean":Yt,"to-color":Yt,"to-number":Yt,"to-string":Yt,var:Wt,within:Zr,distance:En,"global-state":kn};class Fn{constructor(e,s,a,l){this.name=e,this.type=s,this._evaluate=a,this.args=l}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,s){const a=e[0],l=Fn.definitions[a];if(!l)return s.error(`Unknown expression "${a}". If you wanted a literal array, use ["literal", [...]].`,0);const c=Array.isArray(l)?l[0]:l.type,u=Array.isArray(l)?[[l[1],l[2]]]:l.overloads,d=u.filter((([s])=>!Array.isArray(s)||s.length===e.length-1));let f=null;for(const[l,u]of d){f=new Kt(s.registry,ls,s.path,null,s.scope);const d=[];let _=!1;for(let s=1;s<e.length;s++){const a=e[s],c=Array.isArray(l)?l[s-1]:l.type,u=f.parse(a,1+d.length,c);if(!u){_=!0;break}d.push(u)}if(!_)if(Array.isArray(l)&&l.length!==d.length)f.error(`Expected ${l.length} arguments, but found ${d.length} instead.`);else{for(let e=0;e<d.length;e++){const s=Array.isArray(l)?l[e]:l.type,a=d[e];f.concat(e+1).checkSubtype(s,a.type)}if(0===f.errors.length)return new Fn(a,c,u,d)}}if(1===d.length)s.errors.push(...f.errors);else{const a=(d.length?d:u).map((([e])=>{return s=e,Array.isArray(s)?`(${s.map(zi).join(", ")})`:`(${zi(s.type)}...)`;var s})).join(" | "),l=[];for(let a=1;a<e.length;a++){const c=s.parse(e[a],1+l.length);if(!c)return null;l.push(zi(c.type))}s.error(`Expected arguments of type ${a}, but found (${l.join(", ")}) instead.`)}return null}static register(e,s){Fn.definitions=s;for(const a in s)e[a]=Fn}}function is(e,[s,a,l,c]){s=s.evaluate(e),a=a.evaluate(e),l=l.evaluate(e);const u=c?c.evaluate(e):1,d=xr(s,a,l,u);if(d)throw new zt(d);return new It(s/255,a/255,l/255,u,!1)}function ns(e,s){return e in s}function ss(e,s){const a=s[e];return void 0===a?null:a}function os(e){return{type:e}}function ls(e){if(e instanceof Wt)return ls(e.boundExpression);if(e instanceof Fn&&"error"===e.name)return!1;if(e instanceof Tr)return!1;if(e instanceof Zr)return!1;if(e instanceof En)return!1;if(e instanceof kn)return!1;const s=e instanceof Yt||e instanceof Gt;let a=!0;return e.eachChild((e=>{a=s?a&&ls(e):a&&e instanceof qt})),!!a&&hs(e)&&ps(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function hs(e){if(e instanceof Fn){if("get"===e.name&&1===e.args.length)return!1;if("feature-state"===e.name)return!1;if("has"===e.name&&1===e.args.length)return!1;if("properties"===e.name||"geometry-type"===e.name||"id"===e.name)return!1;if(/^filter-/.test(e.name))return!1}if(e instanceof Zr)return!1;if(e instanceof En)return!1;let s=!0;return e.eachChild((e=>{s&&!hs(e)&&(s=!1)})),s}function us(e){if(e instanceof Fn&&"feature-state"===e.name)return!1;let s=!0;return e.eachChild((e=>{s&&!us(e)&&(s=!1)})),s}function ps(e,s){if(e instanceof Fn&&s.indexOf(e.name)>=0)return!1;let a=!0;return e.eachChild((e=>{a&&!ps(e,s)&&(a=!1)})),a}function fs(e){return{result:"success",value:e}}function ms(e){return{result:"error",value:e}}function _s(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function gs(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function ys(e){return!!e.expression&&e.expression.interpolated}function xs(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function vs(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&br(e)===pi}function bs(e){return e}function ws(e,s){const a=e.stops&&"object"==typeof e.stops[0][0],l=a||!(a||void 0!==e.property),c=e.type||(ys(s)?"exponential":"interval"),u=function(e){switch(e.type){case"color":return It.parse;case"padding":return Ft.parse;case"numberArray":return Bt.parse;case"colorArray":return Pt.parse;default:return null}}(s);if(u&&((e=ti({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],u(e[1])]))),e.default=u(e.default?e.default:s.default)),e.colorSpace&&"rgb"!==(d=e.colorSpace)&&"hcl"!==d&&"lab"!==d)throw new Error(`Unknown color space: "${e.colorSpace}"`);var d;const f=function(e){switch(e){case"exponential":return Ms;case"interval":return Is;case"categorical":return Ss;case"identity":return As;default:throw new Error(`Unknown function type "${e}"`)}}(c);let _,y;if("categorical"===c){_=Object.create(null);for(const s of e.stops)_[s[0]]=s[1];y=typeof e.stops[0][0]}if(a){const a={},l=[];for(let s=0;s<e.stops.length;s++){const c=e.stops[s],u=c[0].zoom;void 0===a[u]&&(a[u]={zoom:u,type:e.type,property:e.property,default:e.default,stops:[]},l.push(u)),a[u].stops.push([c[0].value,c[1]])}const c=[];for(const e of l)c.push([a[e].zoom,ws(a[e],s)]);const u={name:"linear"};return{kind:"composite",interpolationType:u,interpolationFactor:pr.interpolationFactor.bind(void 0,u),zoomStops:c.map((e=>e[0])),evaluate:({zoom:a},l)=>Ms({stops:c,base:e.base},s,a).evaluate(a,l)}}if(l){const a="exponential"===c?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:a,interpolationFactor:pr.interpolationFactor.bind(void 0,a),zoomStops:e.stops.map((e=>e[0])),evaluate:({zoom:a})=>f(e,s,a,_,y)}}return{kind:"source",evaluate(a,l){const c=l&&l.properties?l.properties[e.property]:void 0;return void 0===c?Ts(e.default,s.default):f(e,s,c,_,y)}}}function Ts(e,s,a){return void 0!==e?e:void 0!==s?s:void 0!==a?a:void 0}function Ss(e,s,a,l,c){return Ts(typeof a===c?l[a]:void 0,e.default,s.default)}function Is(e,s,a){if("number"!==xs(a))return Ts(e.default,s.default);const l=e.stops.length;if(1===l)return e.stops[0][1];if(a<=e.stops[0][0])return e.stops[0][1];if(a>=e.stops[l-1][0])return e.stops[l-1][1];const c=Ar(e.stops.map((e=>e[0])),a);return e.stops[c][1]}function Ms(e,s,a){const l=void 0!==e.base?e.base:1;if("number"!==xs(a))return Ts(e.default,s.default);const c=e.stops.length;if(1===c)return e.stops[0][1];if(a<=e.stops[0][0])return e.stops[0][1];if(a>=e.stops[c-1][0])return e.stops[c-1][1];const u=Ar(e.stops.map((e=>e[0])),a),d=function(e,s,a,l){const c=l-a,u=e-a;return 0===c?0:1===s?u/c:(Math.pow(s,u)-1)/(Math.pow(s,c)-1)}(a,l,e.stops[u][0],e.stops[u+1][0]),f=e.stops[u][1],_=e.stops[u+1][1],y=Or[s.type]||bs;return"function"==typeof f.evaluate?{evaluate(...s){const a=f.evaluate.apply(void 0,s),l=_.evaluate.apply(void 0,s);if(void 0!==a&&void 0!==l)return y(a,l,d,e.colorSpace)}}:y(f,_,d,e.colorSpace)}function As(e,s,a){switch(s.type){case"color":a=It.parse(a);break;case"formatted":a=Dt.fromString(a.toString());break;case"resolvedImage":a=Lt.fromString(a.toString());break;case"padding":a=Ft.parse(a);break;case"colorArray":a=Pt.parse(a);break;case"numberArray":a=Bt.parse(a);break;default:xs(a)===s.type||"enum"===s.type&&s.values[a]||(a=void 0)}return Ts(a,e.default,s.default)}Fn.register(ts,{error:[{kind:"error"},[ci],(e,[s])=>{throw new zt(s.evaluate(e))}],typeof:[ci,[fi],(e,[s])=>zi(br(s.evaluate(e)))],"to-rgba":[Ai(li,4),[ui],(e,[s])=>{const[a,l,c,u]=s.evaluate(e).rgb;return[255*a,255*l,255*c,u]}],rgb:[ui,[li,li,li],is],rgba:[ui,[li,li,li,li],is],has:{type:hi,overloads:[[[ci],(e,[s])=>ns(s.evaluate(e),e.properties())],[[ci,pi],(e,[s,a])=>ns(s.evaluate(e),a.evaluate(e))]]},get:{type:fi,overloads:[[[ci],(e,[s])=>ss(s.evaluate(e),e.properties())],[[ci,pi],(e,[s,a])=>ss(s.evaluate(e),a.evaluate(e))]]},"feature-state":[fi,[ci],(e,[s])=>ss(s.evaluate(e),e.featureState||{})],properties:[pi,[],e=>e.properties()],"geometry-type":[ci,[],e=>e.geometryType()],id:[fi,[],e=>e.id()],zoom:[li,[],e=>e.globals.zoom],"heatmap-density":[li,[],e=>e.globals.heatmapDensity||0],elevation:[li,[],e=>e.globals.elevation||0],"line-progress":[li,[],e=>e.globals.lineProgress||0],accumulated:[fi,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[li,os(li),(e,s)=>{let a=0;for(const l of s)a+=l.evaluate(e);return a}],"*":[li,os(li),(e,s)=>{let a=1;for(const l of s)a*=l.evaluate(e);return a}],"-":{type:li,overloads:[[[li,li],(e,[s,a])=>s.evaluate(e)-a.evaluate(e)],[[li],(e,[s])=>-s.evaluate(e)]]},"/":[li,[li,li],(e,[s,a])=>s.evaluate(e)/a.evaluate(e)],"%":[li,[li,li],(e,[s,a])=>s.evaluate(e)%a.evaluate(e)],ln2:[li,[],()=>Math.LN2],pi:[li,[],()=>Math.PI],e:[li,[],()=>Math.E],"^":[li,[li,li],(e,[s,a])=>Math.pow(s.evaluate(e),a.evaluate(e))],sqrt:[li,[li],(e,[s])=>Math.sqrt(s.evaluate(e))],log10:[li,[li],(e,[s])=>Math.log(s.evaluate(e))/Math.LN10],ln:[li,[li],(e,[s])=>Math.log(s.evaluate(e))],log2:[li,[li],(e,[s])=>Math.log(s.evaluate(e))/Math.LN2],sin:[li,[li],(e,[s])=>Math.sin(s.evaluate(e))],cos:[li,[li],(e,[s])=>Math.cos(s.evaluate(e))],tan:[li,[li],(e,[s])=>Math.tan(s.evaluate(e))],asin:[li,[li],(e,[s])=>Math.asin(s.evaluate(e))],acos:[li,[li],(e,[s])=>Math.acos(s.evaluate(e))],atan:[li,[li],(e,[s])=>Math.atan(s.evaluate(e))],min:[li,os(li),(e,s)=>Math.min(...s.map((s=>s.evaluate(e))))],max:[li,os(li),(e,s)=>Math.max(...s.map((s=>s.evaluate(e))))],abs:[li,[li],(e,[s])=>Math.abs(s.evaluate(e))],round:[li,[li],(e,[s])=>{const a=s.evaluate(e);return a<0?-Math.round(-a):Math.round(a)}],floor:[li,[li],(e,[s])=>Math.floor(s.evaluate(e))],ceil:[li,[li],(e,[s])=>Math.ceil(s.evaluate(e))],"filter-==":[hi,[ci,fi],(e,[s,a])=>e.properties()[s.value]===a.value],"filter-id-==":[hi,[fi],(e,[s])=>e.id()===s.value],"filter-type-==":[hi,[ci],(e,[s])=>e.geometryType()===s.value],"filter-<":[hi,[ci,fi],(e,[s,a])=>{const l=e.properties()[s.value],c=a.value;return typeof l==typeof c&&l<c}],"filter-id-<":[hi,[fi],(e,[s])=>{const a=e.id(),l=s.value;return typeof a==typeof l&&a<l}],"filter->":[hi,[ci,fi],(e,[s,a])=>{const l=e.properties()[s.value],c=a.value;return typeof l==typeof c&&l>c}],"filter-id->":[hi,[fi],(e,[s])=>{const a=e.id(),l=s.value;return typeof a==typeof l&&a>l}],"filter-<=":[hi,[ci,fi],(e,[s,a])=>{const l=e.properties()[s.value],c=a.value;return typeof l==typeof c&&l<=c}],"filter-id-<=":[hi,[fi],(e,[s])=>{const a=e.id(),l=s.value;return typeof a==typeof l&&a<=l}],"filter->=":[hi,[ci,fi],(e,[s,a])=>{const l=e.properties()[s.value],c=a.value;return typeof l==typeof c&&l>=c}],"filter-id->=":[hi,[fi],(e,[s])=>{const a=e.id(),l=s.value;return typeof a==typeof l&&a>=l}],"filter-has":[hi,[fi],(e,[s])=>s.value in e.properties()],"filter-has-id":[hi,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[hi,[Ai(ci)],(e,[s])=>s.value.indexOf(e.geometryType())>=0],"filter-id-in":[hi,[Ai(fi)],(e,[s])=>s.value.indexOf(e.id())>=0],"filter-in-small":[hi,[ci,Ai(fi)],(e,[s,a])=>a.value.indexOf(e.properties()[s.value])>=0],"filter-in-large":[hi,[ci,Ai(fi)],(e,[s,a])=>function(e,s,a,l){for(;a<=l;){const c=a+l>>1;if(s[c]===e)return!0;s[c]>e?l=c-1:a=c+1}return!1}(e.properties()[s.value],a.value,0,a.value.length-1)],all:{type:hi,overloads:[[[hi,hi],(e,[s,a])=>s.evaluate(e)&&a.evaluate(e)],[os(hi),(e,s)=>{for(const a of s)if(!a.evaluate(e))return!1;return!0}]]},any:{type:hi,overloads:[[[hi,hi],(e,[s,a])=>s.evaluate(e)||a.evaluate(e)],[os(hi),(e,s)=>{for(const a of s)if(a.evaluate(e))return!0;return!1}]]},"!":[hi,[hi],(e,[s])=>!s.evaluate(e)],"is-supported-script":[hi,[ci],(e,[s])=>{const a=e.globals&&e.globals.isSupportedScript;return!a||a(s.evaluate(e))}],upcase:[ci,[ci],(e,[s])=>s.evaluate(e).toUpperCase()],downcase:[ci,[ci],(e,[s])=>s.evaluate(e).toLowerCase()],concat:[ci,os(fi),(e,s)=>s.map((s=>wr(s.evaluate(e)))).join("")],"resolved-locale":[ci,[mi],(e,[s])=>s.evaluate(e).resolvedLocale()]});class ei{constructor(e,s,a){this.expression=e,this._warningHistory={},this._evaluator=new Ht,this._defaultValue=s?function(e){if("color"===e.type&&vs(e.default))return new It(0,0,0,0);switch(e.type){case"color":return It.parse(e.default)||null;case"padding":return Ft.parse(e.default)||null;case"numberArray":return Bt.parse(e.default)||null;case"colorArray":return Pt.parse(e.default)||null;case"variableAnchorOffsetCollection":return Ct.parse(e.default)||null;case"projectionDefinition":return Ot.parse(e.default)||null;default:return void 0===e.default?null:e.default}}(s):null,this._enumValues=s&&"enum"===s.type?s.values:null,this._globalState=a}evaluateWithoutErrorHandling(e,s,a,l,c,u){return this._globalState&&(e=Ys(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=s,this._evaluator.featureState=a,this._evaluator.canonical=l,this._evaluator.availableImages=c||null,this._evaluator.formattedSection=u,this.expression.evaluate(this._evaluator)}evaluate(e,s,a,l,c,u){this._globalState&&(e=Ys(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=s||null,this._evaluator.featureState=a||null,this._evaluator.canonical=l,this._evaluator.availableImages=c||null,this._evaluator.formattedSection=u||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new zt(`Expected value to be one of ${Object.keys(this._enumValues).map((e=>JSON.stringify(e))).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(e.message)),this._defaultValue}}}function ks(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in ts}function js(e,s,a){const l=new Kt(ts,ls,[],s?function(e){const s={color:ui,string:ci,number:li,enum:ci,boolean:hi,formatted:_i,padding:xi,numberArray:wi,colorArray:bi,projectionDefinition:di,resolvedImage:Ii,variableAnchorOffsetCollection:Ei};return"array"===e.type?Ai(s[e.value]||fi,e.length):s[e.type]}(s):void 0),c=l.parse(e,void 0,void 0,void 0,s&&"string"===s.type?{typeAnnotation:"coerce"}:void 0);return c?fs(new ei(c,s,a)):ms(l.errors)}class ni{constructor(e,s,a){this.kind=e,this._styleExpression=s,this.isStateDependent="constant"!==e&&!us(s.expression),this.globalStateRefs=Xs(s.expression),this._globalState=a}evaluateWithoutErrorHandling(e,s,a,l,c,u){return this._globalState&&(e=Ys(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,s,a,l,c,u)}evaluate(e,s,a,l,c,u){return this._globalState&&(e=Ys(e,this._globalState)),this._styleExpression.evaluate(e,s,a,l,c,u)}}class ii{constructor(e,s,a,l,c){this.kind=e,this.zoomStops=a,this._styleExpression=s,this.isStateDependent="camera"!==e&&!us(s.expression),this.globalStateRefs=Xs(s.expression),this.interpolationType=l,this._globalState=c}evaluateWithoutErrorHandling(e,s,a,l,c,u){return this._globalState&&(e=Ys(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,s,a,l,c,u)}evaluate(e,s,a,l,c,u){return this._globalState&&(e=Ys(e,this._globalState)),this._styleExpression.evaluate(e,s,a,l,c,u)}interpolationFactor(e,s,a){return this.interpolationType?pr.interpolationFactor(this.interpolationType,e,s,a):0}}function Ws(e,s,a){const l=js(e,s,a);if("error"===l.result)return l;const c=l.value.expression,u=hs(c);if(!u&&!_s(s))return ms([new Be("","data expressions not supported")]);const d=ps(c,["zoom"]);if(!d&&!gs(s))return ms([new Be("","zoom expressions not supported")]);const f=Hs(c);return f||d?f instanceof Be?ms([f]):f instanceof pr&&!ys(s)?ms([new Be("",'"interpolate" expressions cannot be used with this property')]):fs(f?new ii(u?"camera":"composite",l.value,f.labels,f instanceof pr?f.interpolation:void 0,a):new ni(u?"constant":"source",l.value,a)):ms([new Be("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class ai{constructor(e,s){this._parameters=e,this._specification=s,ti(this,ws(this._parameters,this._specification))}static deserialize(e){return new ai(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Hs(e){let s=null;if(e instanceof Jt)s=Hs(e.result);else if(e instanceof yr){for(const a of e.args)if(s=Hs(a),s)break}else(e instanceof ar||e instanceof pr)&&e.input instanceof Fn&&"zoom"===e.input.name&&(s=e);return s instanceof Be||e.eachChild((e=>{const a=Hs(e);a instanceof Be?s=a:!s&&a?s=new Be("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):s&&a&&s!==a&&(s=new Be("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),s}function Xs(e,s=new Set){return e instanceof kn&&s.add(e.key),e.eachChild((e=>{Xs(e,s)})),s}function Ys(e,s){const{zoom:a,heatmapDensity:l,elevation:c,lineProgress:u,isSupportedScript:d,accumulated:f}=null!=e?e:{};return{zoom:a,heatmapDensity:l,elevation:c,lineProgress:u,isSupportedScript:d,accumulated:f,globalState:s}}function Qs(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const s of e.slice(1))if(!Qs(s)&&"boolean"!=typeof s)return!1;return!0;default:return!0}}const ro={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function co(e,s){if(null==e)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};Qs(e)||(e=bo(e));const a=js(e,ro,s);if("error"===a.result)throw new Error(a.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return{filter:(e,s,l)=>a.value.evaluate(e,s,{},l),needGeometry:fo(e),getGlobalStateRefs:()=>Xs(a.value.expression)}}function uo(e,s){return e<s?-1:e>s?1:0}function fo(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let s=1;s<e.length;s++)if(fo(e[s]))return!0;return!1}function bo(e){if(!e)return!0;const s=e[0];return e.length<=1?"any"!==s:"=="===s?wo(e[1],e[2],"=="):"!="===s?Vo(wo(e[1],e[2],"==")):"<"===s||">"===s||"<="===s||">="===s?wo(e[1],e[2],s):"any"===s?(a=e.slice(1),["any"].concat(a.map(bo))):"all"===s?["all"].concat(e.slice(1).map(bo)):"none"===s?["all"].concat(e.slice(1).map(bo).map(Vo)):"in"===s?Po(e[1],e.slice(2)):"!in"===s?Vo(Po(e[1],e.slice(2))):"has"===s?Co(e[1]):"!has"!==s||Vo(Co(e[1]));var a}function wo(e,s,a){switch(e){case"$type":return[`filter-type-${a}`,s];case"$id":return[`filter-id-${a}`,s];default:return[`filter-${a}`,e,s]}}function Po(e,s){if(0===s.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",s]];case"$id":return["filter-id-in",["literal",s]];default:return s.length>200&&!s.some((e=>typeof e!=typeof s[0]))?["filter-in-large",e,["literal",s.sort(uo)]]:["filter-in-small",e,["literal",s]]}}function Co(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function Vo(e){return["!",e]}function No(e){const s=typeof e;if("number"===s||"boolean"===s||"string"===s||null==e)return JSON.stringify(e);if(Array.isArray(e)){let s="[";for(const a of e)s+=`${No(a)},`;return`${s}]`}const a=Object.keys(e).sort();let l="{";for(let s=0;s<a.length;s++)l+=`${JSON.stringify(a[s])}:${No(e[a[s]])},`;return`${l}}`}function jo(e){let s="";for(const a of ft)s+=`/${No(e[a])}`;return s}function Ho(e){const s=e.value;return s?[new De(e.key,s,"constants have been deprecated as of v8")]:[]}function Qo(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function Ja(e){if(Array.isArray(e))return e.map(Ja);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const s={};for(const a in e)s[a]=Ja(e[a]);return s}return Qo(e)}function el(e){const s=e.key,a=e.value,l=e.valueSpec||{},c=e.objectElementValidators||{},u=e.style,d=e.styleSpec,f=e.validateSpec;let _=[];const y=xs(a);if("object"!==y)return[new De(s,a,`object expected, ${y} found`)];for(const e in a){const y=e.split(".")[0],b=or(l,y)||l["*"];let S;if(or(c,y))S=c[y];else if(or(l,y))S=f;else if(c["*"])S=c["*"];else{if(!l["*"]){_.push(new De(s,a[e],`unknown property "${e}"`));continue}S=f}_=_.concat(S({key:(s?`${s}.`:s)+e,value:a[e],valueSpec:b,style:u,styleSpec:d,object:a,objectKey:e,validateSpec:f},a))}for(const e in l)c[e]||l[e].required&&void 0===l[e].default&&void 0===a[e]&&_.push(new De(s,a,`missing required property "${e}"`));return _}function tl(e){const s=e.value,a=e.valueSpec,l=e.style,c=e.styleSpec,u=e.key,d=e.arrayElementValidator||e.validateSpec;if("array"!==xs(s))return[new De(u,s,`array expected, ${xs(s)} found`)];if(a.length&&s.length!==a.length)return[new De(u,s,`array length ${a.length} expected, length ${s.length} found`)];if(a["min-length"]&&s.length<a["min-length"])return[new De(u,s,`array length at least ${a["min-length"]} expected, length ${s.length} found`)];let f={type:a.value,values:a.values};c.$version<7&&(f.function=a.function),"object"===xs(a.value)&&(f=a.value);let _=[];for(let a=0;a<s.length;a++)_=_.concat(d({array:s,arrayIndex:a,value:s[a],valueSpec:f,validateSpec:e.validateSpec,style:l,styleSpec:c,key:`${u}[${a}]`}));return _}function il(e){const s=e.key,a=e.value,l=e.valueSpec;let c=xs(a);return"number"===c&&a!=a&&(c="NaN"),"number"!==c?[new De(s,a,`number expected, ${c} found`)]:"minimum"in l&&a<l.minimum?[new De(s,a,`${a} is less than the minimum value ${l.minimum}`)]:"maximum"in l&&a>l.maximum?[new De(s,a,`${a} is greater than the maximum value ${l.maximum}`)]:[]}function rl(e){const s=e.valueSpec,a=Qo(e.value.type);let l,c,u,d={};const f="categorical"!==a&&void 0===e.value.property,_=!f,y="array"===xs(e.value.stops)&&"array"===xs(e.value.stops[0])&&"object"===xs(e.value.stops[0][0]),b=el({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===a)return[new De(e.key,e.value,'identity function may not have a "stops" property')];let s=[];const l=e.value;return s=s.concat(tl({key:e.key,value:l,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:S})),"array"===xs(l)&&0===l.length&&s.push(new De(e.key,l,"array must have at least one stop")),s},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:s,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===a&&f&&b.push(new De(e.key,e.value,'missing required property "property"')),"identity"===a||e.value.stops||b.push(new De(e.key,e.value,'missing required property "stops"')),"exponential"===a&&e.valueSpec.expression&&!ys(e.valueSpec)&&b.push(new De(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(_&&!_s(e.valueSpec)?b.push(new De(e.key,e.value,"property functions not supported")):f&&!gs(e.valueSpec)&&b.push(new De(e.key,e.value,"zoom functions not supported"))),"categorical"!==a&&!y||void 0!==e.value.property||b.push(new De(e.key,e.value,'"property" property is required')),b;function S(e){let a=[];const l=e.value,f=e.key;if("array"!==xs(l))return[new De(f,l,`array expected, ${xs(l)} found`)];if(2!==l.length)return[new De(f,l,`array length 2 expected, length ${l.length} found`)];if(y){if("object"!==xs(l[0]))return[new De(f,l,`object expected, ${xs(l[0])} found`)];if(void 0===l[0].zoom)return[new De(f,l,"object stop key must have zoom")];if(void 0===l[0].value)return[new De(f,l,"object stop key must have value")];if(u&&u>Qo(l[0].zoom))return[new De(f,l[0].zoom,"stop zoom values must appear in ascending order")];Qo(l[0].zoom)!==u&&(u=Qo(l[0].zoom),c=void 0,d={}),a=a.concat(el({key:`${f}[0]`,value:l[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:il,value:P}}))}else a=a.concat(P({key:`${f}[0]`,value:l[0],validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},l));return ks(Ja(l[1]))?a.concat([new De(`${f}[1]`,l[1],"expressions are not allowed in function stops.")]):a.concat(e.validateSpec({key:`${f}[1]`,value:l[1],valueSpec:s,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function P(e,u){const f=xs(e.value),_=Qo(e.value),y=null!==e.value?e.value:u;if(l){if(f!==l)return[new De(e.key,y,`${f} stop domain type must match previous stop domain type ${l}`)]}else l=f;if("number"!==f&&"string"!==f&&"boolean"!==f)return[new De(e.key,y,"stop domain value must be a number, string, or boolean")];if("number"!==f&&"categorical"!==a){let l=`number expected, ${f} found`;return _s(s)&&void 0===a&&(l+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new De(e.key,y,l)]}return"categorical"!==a||"number"!==f||isFinite(_)&&Math.floor(_)===_?"categorical"!==a&&"number"===f&&void 0!==c&&_<c?[new De(e.key,y,"stop domain values must appear in ascending order")]:(c=_,"categorical"===a&&_ in d?[new De(e.key,y,"stop domain values must be unique")]:(d[_]=!0,[])):[new De(e.key,y,`integer expected, found ${_}`)]}}function nl(e){const s=("property"===e.expressionContext?Ws:js)(Ja(e.value),e.valueSpec);if("error"===s.result)return s.value.map((s=>new De(`${e.key}${s.key}`,e.value,s.message)));const a=s.value.expression||s.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!a.outputDefined())return[new De(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!us(a))return[new De(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext&&!us(a))return[new De(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!ps(a,["zoom","feature-state"]))return[new De(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!hs(a))return[new De(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function sl(e){const s=e.key,a=e.value,l=xs(a);return"string"!==l?[new De(s,a,`color expected, ${l} found`)]:It.parse(String(a))?[]:[new De(s,a,`color expected, "${a}" found`)]}function ol(e){const s=e.key,a=e.value,l=e.valueSpec,c=[];return Array.isArray(l.values)?-1===l.values.indexOf(Qo(a))&&c.push(new De(s,a,`expected one of [${l.values.join(", ")}], ${JSON.stringify(a)} found`)):-1===Object.keys(l.values).indexOf(Qo(a))&&c.push(new De(s,a,`expected one of [${Object.keys(l.values).join(", ")}], ${JSON.stringify(a)} found`)),c}function al(e){return Qs(Ja(e.value))?nl(ti({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}})):ll(e)}function ll(e){const s=e.value,a=e.key;if("array"!==xs(s))return[new De(a,s,`array expected, ${xs(s)} found`)];const l=e.styleSpec;let c,u=[];if(s.length<1)return[new De(a,s,"filter array must have at least 1 element")];switch(u=u.concat(ol({key:`${a}[0]`,value:s[0],valueSpec:l.filter_operator,style:e.style,styleSpec:e.styleSpec})),Qo(s[0])){case"<":case"<=":case">":case">=":s.length>=2&&"$type"===Qo(s[1])&&u.push(new De(a,s,`"$type" cannot be use with operator "${s[0]}"`));case"==":case"!=":3!==s.length&&u.push(new De(a,s,`filter array for operator "${s[0]}" must have 3 elements`));case"in":case"!in":s.length>=2&&(c=xs(s[1]),"string"!==c&&u.push(new De(`${a}[1]`,s[1],`string expected, ${c} found`)));for(let d=2;d<s.length;d++)c=xs(s[d]),"$type"===Qo(s[1])?u=u.concat(ol({key:`${a}[${d}]`,value:s[d],valueSpec:l.geometry_type,style:e.style,styleSpec:e.styleSpec})):"string"!==c&&"number"!==c&&"boolean"!==c&&u.push(new De(`${a}[${d}]`,s[d],`string, number, or boolean expected, ${c} found`));break;case"any":case"all":case"none":for(let l=1;l<s.length;l++)u=u.concat(ll({key:`${a}[${l}]`,value:s[l],style:e.style,styleSpec:e.styleSpec}));break;case"has":case"!has":c=xs(s[1]),2!==s.length?u.push(new De(a,s,`filter array for "${s[0]}" operator must have 2 elements`)):"string"!==c&&u.push(new De(`${a}[1]`,s[1],`string expected, ${c} found`))}return u}function hl(e,s){const a=e.key,l=e.validateSpec,c=e.style,u=e.styleSpec,d=e.value,f=e.objectKey,_=u[`${s}_${e.layerType}`];if(!_)return[];const y=f.match(/^(.*)-transition$/);if("paint"===s&&y&&_[y[1]]&&_[y[1]].transition)return l({key:a,value:d,valueSpec:u.transition,style:c,styleSpec:u});const b=e.valueSpec||_[f];if(!b)return[new De(a,d,`unknown property "${f}"`)];let S;if("string"===xs(d)&&_s(b)&&!b.tokens&&(S=/^{([^}]+)}$/.exec(d)))return[new De(a,d,`"${f}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(S[1])} }\`.`)];const P=[];return"symbol"===e.layerType&&"text-font"===f&&vs(Ja(d))&&"identity"===Qo(d.type)&&P.push(new De(a,d,'"text-font" does not support identity functions')),P.concat(l({key:e.key,value:d,valueSpec:b,style:c,styleSpec:u,expressionContext:"property",propertyType:s,propertyKey:f}))}function dl(e){return hl(e,"paint")}function pl(e){return hl(e,"layout")}function fl(e){let s=[];const a=e.value,l=e.key,c=e.style,u=e.styleSpec;if("object"!==xs(a))return[new De(l,a,`object expected, ${xs(a)} found`)];a.type||a.ref||s.push(new De(l,a,'either "type" or "ref" is required'));let d=Qo(a.type);const f=Qo(a.ref);if(a.id){const u=Qo(a.id);for(let d=0;d<e.arrayIndex;d++){const e=c.layers[d];Qo(e.id)===u&&s.push(new De(l,a.id,`duplicate layer id "${a.id}", previously used at line ${e.id.__line__}`))}}if("ref"in a){let e;["type","source","source-layer","filter","layout"].forEach((e=>{e in a&&s.push(new De(l,a[e],`"${e}" is prohibited for ref layers`))})),c.layers.forEach((s=>{Qo(s.id)===f&&(e=s)})),e?e.ref?s.push(new De(l,a.ref,"ref cannot reference another ref layer")):d=Qo(e.type):s.push(new De(l,a.ref,`ref layer "${f}" not found`))}else if("background"!==d)if(a.source){const e=c.sources&&c.sources[a.source],u=e&&Qo(e.type);e?"vector"===u&&"raster"===d?s.push(new De(l,a.source,`layer "${a.id}" requires a raster source`)):"raster-dem"!==u&&"hillshade"===d||"raster-dem"!==u&&"color-relief"===d?s.push(new De(l,a.source,`layer "${a.id}" requires a raster-dem source`)):"raster"===u&&"raster"!==d?s.push(new De(l,a.source,`layer "${a.id}" requires a vector source`)):"vector"!==u||a["source-layer"]?"raster-dem"===u&&"hillshade"!==d&&"color-relief"!==d?s.push(new De(l,a.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"!==d||!a.paint||!a.paint["line-gradient"]||"geojson"===u&&e.lineMetrics||s.push(new De(l,a,`layer "${a.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):s.push(new De(l,a,`layer "${a.id}" must specify a "source-layer"`)):s.push(new De(l,a.source,`source "${a.source}" not found`))}else s.push(new De(l,a,'missing required property "source"'));return s=s.concat(el({key:l,value:a,valueSpec:u.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${l}.type`,value:a.type,valueSpec:u.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:a,objectKey:"type"}),filter:al,layout:e=>el({layer:a,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>pl(ti({layerType:d},e))}}),paint:e=>el({layer:a,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>dl(ti({layerType:d},e))}})}})),s}function _l(e){const s=e.value,a=e.key,l=xs(s);return"string"!==l?[new De(a,s,`string expected, ${l} found`)]:[]}const yl={promoteId:function({key:e,value:s}){if("string"===xs(s))return _l({key:e,value:s});{const a=[];for(const l in s)a.push(..._l({key:`${e}.${l}`,value:s[l]}));return a}}};function xl(e){const s=e.value,a=e.key,l=e.styleSpec,c=e.style,u=e.validateSpec;if(!s.type)return[new De(a,s,'"type" is required')];const d=Qo(s.type);let f;switch(d){case"vector":case"raster":return f=el({key:a,value:s,valueSpec:l[`source_${d.replace("-","_")}`],style:e.style,styleSpec:l,objectElementValidators:yl,validateSpec:u}),f;case"raster-dem":return f=function(e){var s;const a=null!==(s=e.sourceName)&&void 0!==s?s:"",l=e.value,c=e.styleSpec,u=c.source_raster_dem,d=e.style;let f=[];const _=xs(l);if(void 0===l)return f;if("object"!==_)return f.push(new De("source_raster_dem",l,`object expected, ${_} found`)),f;const y="custom"===Qo(l.encoding),b=["redFactor","greenFactor","blueFactor","baseShift"],S=e.value.encoding?`"${e.value.encoding}"`:"Default";for(const s in l)!y&&b.includes(s)?f.push(new De(s,l[s],`In "${a}": "${s}" is only valid when "encoding" is set to "custom". ${S} encoding found`)):u[s]?f=f.concat(e.validateSpec({key:s,value:l[s],valueSpec:u[s],validateSpec:e.validateSpec,style:d,styleSpec:c})):f.push(new De(s,l[s],`unknown property "${s}"`));return f}({sourceName:a,value:s,style:e.style,styleSpec:l,validateSpec:u}),f;case"geojson":if(f=el({key:a,value:s,valueSpec:l.source_geojson,style:c,styleSpec:l,validateSpec:u,objectElementValidators:yl}),s.cluster)for(const e in s.clusterProperties){const[l,c]=s.clusterProperties[e],u="string"==typeof l?[l,["accumulated"],["get",e]]:l;f.push(...nl({key:`${a}.${e}.map`,value:c,expressionContext:"cluster-map"})),f.push(...nl({key:`${a}.${e}.reduce`,value:u,expressionContext:"cluster-reduce"}))}return f;case"video":return el({key:a,value:s,valueSpec:l.source_video,style:c,validateSpec:u,styleSpec:l});case"image":return el({key:a,value:s,valueSpec:l.source_image,style:c,validateSpec:u,styleSpec:l});case"canvas":return[new De(a,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return ol({key:`${a}.type`,value:s.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function vl(e){const s=e.value,a=e.styleSpec,l=a.light,c=e.style;let u=[];const d=xs(s);if(void 0===s)return u;if("object"!==d)return u=u.concat([new De("light",s,`object expected, ${d} found`)]),u;for(const d in s){const f=d.match(/^(.*)-transition$/);u=u.concat(f&&l[f[1]]&&l[f[1]].transition?e.validateSpec({key:d,value:s[d],valueSpec:a.transition,validateSpec:e.validateSpec,style:c,styleSpec:a}):l[d]?e.validateSpec({key:d,value:s[d],valueSpec:l[d],validateSpec:e.validateSpec,style:c,styleSpec:a}):[new De(d,s[d],`unknown property "${d}"`)])}return u}function wl(e){const s=e.value,a=e.styleSpec,l=a.sky,c=e.style,u=xs(s);if(void 0===s)return[];if("object"!==u)return[new De("sky",s,`object expected, ${u} found`)];let d=[];for(const u in s)d=d.concat(l[u]?e.validateSpec({key:u,value:s[u],valueSpec:l[u],style:c,styleSpec:a}):[new De(u,s[u],`unknown property "${u}"`)]);return d}function Tl(e){const s=e.value,a=e.styleSpec,l=a.terrain,c=e.style;let u=[];const d=xs(s);if(void 0===s)return u;if("object"!==d)return u=u.concat([new De("terrain",s,`object expected, ${d} found`)]),u;for(const d in s)u=u.concat(l[d]?e.validateSpec({key:d,value:s[d],valueSpec:l[d],validateSpec:e.validateSpec,style:c,styleSpec:a}):[new De(d,s[d],`unknown property "${d}"`)]);return u}function Pl(e){let s=[];const a=e.value,l=e.key;if(Array.isArray(a)){const c=[],u=[];for(const d in a)a[d].id&&c.includes(a[d].id)&&s.push(new De(l,a,`all the sprites' ids must be unique, but ${a[d].id} is duplicated`)),c.push(a[d].id),a[d].url&&u.includes(a[d].url)&&s.push(new De(l,a,`all the sprites' URLs must be unique, but ${a[d].url} is duplicated`)),u.push(a[d].url),s=s.concat(el({key:`${l}[${d}]`,value:a[d],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return s}return _l({key:l,value:a})}function El(e){return s=e.value,Boolean(s)&&s.constructor===Object?[]:[new De(e.key,e.value,`object expected, ${xs(e.value)} found`)];var s}const Cl={"*":()=>[],array:tl,boolean:function(e){const s=e.value,a=e.key,l=xs(s);return"boolean"!==l?[new De(a,s,`boolean expected, ${l} found`)]:[]},number:il,color:sl,constants:Ho,enum:ol,filter:al,function:rl,layer:fl,object:el,source:xl,light:vl,sky:wl,terrain:Tl,projection:function(e){const s=e.value,a=e.styleSpec,l=a.projection,c=e.style,u=xs(s);if(void 0===s)return[];if("object"!==u)return[new De("projection",s,`object expected, ${u} found`)];let d=[];for(const u in s)d=d.concat(l[u]?e.validateSpec({key:u,value:s[u],valueSpec:l[u],style:c,styleSpec:a}):[new De(u,s[u],`unknown property "${u}"`)]);return d},projectionDefinition:function(e){const s=e.key;let a=e.value;a=a instanceof String?a.valueOf():a;const l=xs(a);return"array"!==l||function(e){return Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]}(a)||function(e){return!!["interpolate","step","literal"].includes(e[0])}(a)?["array","string"].includes(l)?[]:[new De(s,a,`projection expected, invalid type "${l}" found`)]:[new De(s,a,`projection expected, invalid array ${JSON.stringify(a)} found`)]},string:_l,formatted:function(e){return 0===_l(e).length?[]:nl(e)},resolvedImage:function(e){return 0===_l(e).length?[]:nl(e)},padding:function(e){const s=e.key,a=e.value;if("array"===xs(a)){if(a.length<1||a.length>4)return[new De(s,a,`padding requires 1 to 4 values; ${a.length} values found`)];const l={type:"number"};let c=[];for(let u=0;u<a.length;u++)c=c.concat(e.validateSpec({key:`${s}[${u}]`,value:a[u],validateSpec:e.validateSpec,valueSpec:l}));return c}return il({key:s,value:a,valueSpec:{}})},numberArray:function(e){const s=e.key,a=e.value;if("array"===xs(a)){const l={type:"number"};if(a.length<1)return[new De(s,a,"array length at least 1 expected, length 0 found")];let c=[];for(let u=0;u<a.length;u++)c=c.concat(e.validateSpec({key:`${s}[${u}]`,value:a[u],validateSpec:e.validateSpec,valueSpec:l}));return c}return il({key:s,value:a,valueSpec:{}})},colorArray:function(e){const s=e.key,a=e.value;if("array"===xs(a)){if(a.length<1)return[new De(s,a,"array length at least 1 expected, length 0 found")];let e=[];for(let l=0;l<a.length;l++)e=e.concat(sl({key:`${s}[${l}]`,value:a[l]}));return e}return sl({key:s,value:a})},variableAnchorOffsetCollection:function(e){const s=e.key,a=e.value,l=xs(a),c=e.styleSpec;if("array"!==l||a.length<1||a.length%2!=0)return[new De(s,a,"variableAnchorOffsetCollection requires a non-empty array of even length")];let u=[];for(let l=0;l<a.length;l+=2)u=u.concat(ol({key:`${s}[${l}]`,value:a[l],valueSpec:c.layout_symbol["text-anchor"]})),u=u.concat(tl({key:`${s}[${l+1}]`,value:a[l+1],valueSpec:{length:2,value:"number"},validateSpec:e.validateSpec,style:e.style,styleSpec:c}));return u},sprite:Pl,state:El};function Al(e){const s=e.value,a=e.valueSpec,l=e.styleSpec;return e.validateSpec=Al,a.expression&&vs(Qo(s))?rl(e):a.expression&&ks(Ja(s))?nl(e):a.type&&Cl[a.type]?Cl[a.type](e):el(ti({},e,{valueSpec:a.type?l[a.type]:a}))}function Dl(e){const s=e.value,a=e.key,l=_l(e);return l.length||(-1===s.indexOf("{fontstack}")&&l.push(new De(a,s,'"glyphs" url must include a "{fontstack}" token')),-1===s.indexOf("{range}")&&l.push(new De(a,s,'"glyphs" url must include a "{range}" token'))),l}function zl(e,s=pt){let a=[];return a=a.concat(Al({key:"",value:e,valueSpec:s.$root,styleSpec:s,style:e,validateSpec:Al,objectElementValidators:{glyphs:Dl,"*":()=>[]}})),e.constants&&(a=a.concat(Ho({key:"constants",value:e.constants}))),Ll(a)}function Rl(e){return function(s){return e(Object.assign({},s,{validateSpec:Al}))}}function Ll(e){return[].concat(e).sort(((e,s)=>e.line-s.line))}function Fl(s){return function(...a){return Ll(s.apply(this||e,a))}}zl.source=Fl(Rl(xl)),zl.sprite=Fl(Rl(Pl)),zl.glyphs=Fl(Rl(Dl)),zl.light=Fl(Rl(vl)),zl.sky=Fl(Rl(wl)),zl.terrain=Fl(Rl(Tl)),zl.state=Fl(Rl(El)),zl.layer=Fl(Rl(fl)),zl.filter=Fl(Rl(al)),zl.paintProperty=Fl(Rl(dl)),zl.layoutProperty=Fl(Rl(pl));const Bl=pt,Ol=zl,Vl=Ol.light,Nl=Ol.sky,jl=Ol.paintProperty,Ul=Ol.layoutProperty;function Gl(e,s){let a=!1;if(s&&s.length)for(const l of s)e.fire(new me(new Error(l.message))),a=!0;return a}class as{constructor(e,s,a){const l=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const c=new Int32Array(this.arrayBuffer);e=c[0],this.d=(s=c[1])+2*(a=c[2]);for(let e=0;e<this.d*this.d;e++){const s=c[3+e],a=c[3+e+1];l.push(s===a?null:c.subarray(s,a))}const u=c[3+l.length+1];this.keys=c.subarray(c[3+l.length],u),this.bboxes=c.subarray(u),this.insert=this._insertReadonly}else{this.d=s+2*a;for(let e=0;e<this.d*this.d;e++)l.push([]);this.keys=[],this.bboxes=[]}this.n=s,this.extent=e,this.padding=a,this.scale=s/e,this.uid=0;const c=a/s*e;this.min=-c,this.max=e+c}insert(e,s,a,l,c){this._forEachCell(s,a,l,c,this._insertCell,this.uid++,void 0,void 0),this.keys.push(e),this.bboxes.push(s),this.bboxes.push(a),this.bboxes.push(l),this.bboxes.push(c)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(e,s,a,l,c,u){this.cells[c].push(u)}query(e,s,a,l,c){const u=this.min,d=this.max;if(e<=u&&s<=u&&d<=a&&d<=l&&!c)return Array.prototype.slice.call(this.keys);{const u=[];return this._forEachCell(e,s,a,l,this._queryCell,u,{},c),u}}_queryCell(e,s,a,l,c,u,d,f){const _=this.cells[c];if(null!==_){const c=this.keys,y=this.bboxes;for(let b=0;b<_.length;b++){const S=_[b];if(void 0===d[S]){const _=4*S;(f?f(y[_+0],y[_+1],y[_+2],y[_+3]):e<=y[_+2]&&s<=y[_+3]&&a>=y[_+0]&&l>=y[_+1])?(d[S]=!0,u.push(c[S])):d[S]=!1}}}}_forEachCell(e,s,a,l,c,u,d,f){const _=this._convertToCellCoord(e),y=this._convertToCellCoord(s),b=this._convertToCellCoord(a),S=this._convertToCellCoord(l);for(let P=_;P<=b;P++)for(let _=y;_<=S;_++){const y=this.d*_+P;if((!f||f(this._convertFromCellCoord(P),this._convertFromCellCoord(_),this._convertFromCellCoord(P+1),this._convertFromCellCoord(_+1)))&&c.call(this,e,s,a,l,y,u,d,f))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const e=this.cells,s=3+this.cells.length+1+1;let a=0;for(let e=0;e<this.cells.length;e++)a+=this.cells[e].length;const l=new Int32Array(s+a+this.keys.length+this.bboxes.length);l[0]=this.extent,l[1]=this.n,l[2]=this.padding;let c=s;for(let s=0;s<e.length;s++){const a=e[s];l[3+s]=c,l.set(a,c),c+=a.length}return l[3+e.length]=c,l.set(this.keys,c),c+=this.keys.length,l[3+e.length+1]=c,l.set(this.bboxes,c),c+=this.bboxes.length,l.buffer}static serialize(e,s){const a=e.toArrayBuffer();return s&&s.push(a),{buffer:a}}static deserialize(e){return new as(e.buffer)}}const Zl={};function ql(e,s,a={}){if(Zl[e])throw new Error(`${e} is already registered.`);Object.defineProperty(s,"_classRegistryKey",{value:e,writeable:!1}),Zl[e]={klass:s,omit:a.omit||[],shallow:a.shallow||[]}}ql("Object",Object),ql("Set",Set),ql("TransferableGridIndex",as),ql("Color",It),ql("Error",Error),ql("AJAXError",ue),ql("ResolvedImage",Lt),ql("StylePropertyFunction",ai),ql("StyleExpression",ei,{omit:["_evaluator"]}),ql("ZoomDependentExpression",ii),ql("ZoomConstantExpression",ni),ql("CompoundExpression",Fn,{omit:["_evaluate"]});for(const e in ts)ts[e]._classRegistryKey||ql(`Expression_${e}`,ts[e]);function $l(e){return e&&"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}function Wl(e){return e.$name||e.constructor._classRegistryKey}function Hl(e){return!function(e){if(null===e||"object"!=typeof e)return!1;const s=Wl(e);return!(!s||"Object"===s)}(e)&&(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||e instanceof Blob||e instanceof Error||$l(e)||Ne(e)||ArrayBuffer.isView(e)||e instanceof ImageData)}function Xl(e,s){if(Hl(e))return($l(e)||Ne(e))&&s&&s.push(e),ArrayBuffer.isView(e)&&s&&s.push(e.buffer),e instanceof ImageData&&s&&s.push(e.data.buffer),e;if(Array.isArray(e)){const a=[];for(const l of e)a.push(Xl(l,s));return a}if("object"!=typeof e)throw new Error("can't serialize object of type "+typeof e);const a=Wl(e);if(!a)throw new Error(`can't serialize object of unregistered class ${e.constructor.name}`);if(!Zl[a])throw new Error(`${a} is not registered.`);const{klass:l}=Zl[a],c=l.serialize?l.serialize(e,s):{};if(l.serialize){if(s&&c===s[s.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const l in e){if(!e.hasOwnProperty(l))continue;if(Zl[a].omit.indexOf(l)>=0)continue;const u=e[l];c[l]=Zl[a].shallow.indexOf(l)>=0?u:Xl(u,s)}e instanceof Error&&(c.message=e.message)}if(c.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==a&&(c.$name=a),c}function Yl(e){if(Hl(e))return e;if(Array.isArray(e))return e.map(Yl);if("object"!=typeof e)throw new Error("can't deserialize object of type "+typeof e);const s=Wl(e)||"Object";if(!Zl[s])throw new Error(`can't deserialize unregistered class ${s}`);const{klass:a}=Zl[s];if(!a)throw new Error(`can't deserialize unregistered class ${s}`);if(a.deserialize)return a.deserialize(e);const l=Object.create(a.prototype);for(const a of Object.keys(e)){if("$name"===a)continue;const c=e[a];l[a]=Zl[s].shallow.indexOf(a)>=0?c:Yl(c)}return l}class ds{constructor(){this.first=!0}update(e,s){const a=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=a,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=a,!0):(this.lastFloorZoom>a?(this.lastIntegerZoom=a+1,this.lastIntegerZoomTime=s):this.lastFloorZoom<a&&(this.lastIntegerZoom=a,this.lastIntegerZoomTime=s),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=a,!0))}}function Kl(e){return/[\u02EA\u02EB\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u303F\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FD-\u30FF\u3105-\u312F\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFE4\uDFF0-\uDFF6]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD83C\uDE00|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))}function Jl(e){return/[\u02EA\u02EB\u1100-\u11FF\u1400-\u167F\u18B0-\u18F5\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303F\u3041-\u3096\u309D-\u30FB\u30FD-\u30FF\u3105-\u312F\u3131-\u318E\u3190-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE48\uFE50-\uFE57\uFE5F-\uFE62\uFE67-\uFE6F\uFF00-\uFF07\uFF0A-\uFF0C\uFF0E-\uFF19\uFF1F-\uFF3A\uFF3C\uFF3E\uFF40-\uFF5A\uFFE0-\uFFE2\uFFE4-\uFFE7]|\uD806[\uDEB0-\uDEBF]|\uD81B[\uDFE0-\uDFE4\uDFF0-\uDFF6]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD83C\uDE00|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))}function Ql(e){for(const s of e)if(Jl(s.charCodeAt(0)))return!0;return!1}function ec(e){for(const s of e)if(!rc(s.charCodeAt(0)))return!1;return!0}function tc(e){const s=e.map((e=>{try{return new RegExp(`\\p{sc=${e}}`,"u").source}catch(e){return null}})).filter((e=>e));return new RegExp(s.join("|"),"u")}const ic=tc(["Arab","Dupl","Mong","Ougr","Syrc"]);function rc(e){return!ic.test(String.fromCodePoint(e))}function nc(e){return!(Jl(e)||(s=e,/[\xA7\xA9\xAE\xB1\xBC-\xBE\xD7\xF7\u2016\u2020\u2021\u2030\u2031\u203B\u203C\u2042\u2047-\u2049\u2051\u2100-\u218F\u221E\u2234\u2235\u2300-\u2307\u230C-\u231F\u2324-\u2328\u232B\u237D-\u239A\u23BE-\u23CD\u23CF\u23D1-\u23DB\u23E2-\u2422\u2424-\u24FF\u25A0-\u2619\u2620-\u2767\u2776-\u2793\u2B12-\u2B2F\u2B50-\u2B59\u2BB8-\u2BEB\u3000-\u303F\u30A0-\u30FF\uE000-\uF8FF\uFE30-\uFE6F\uFF00-\uFFEF\uFFFC\uFFFD]/gim.test(String.fromCodePoint(s))));var s}const sc=tc(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function oc(e){return sc.test(String.fromCodePoint(e))}function ac(e,s){return!(!s&&oc(e)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(e)))}function lc(e){for(const s of e)if(oc(s.charCodeAt(0)))return!0;return!1}const cc=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(e){this.pluginStatus=e.pluginStatus,this.pluginURL=e.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(e){if(cc.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=e.applyArabicShaping,this.processBidirectionalText=e.processBidirectionalText,this.processStyledBidirectionalText=e.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(e,s){return a(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if("loading"!==e.pluginStatus)return this.setState(e),e;const a=e.pluginURL,l=new Promise((e=>{this.loadScriptResolve=e}));s(a);const c=new Promise((e=>setTimeout((()=>e()),this.TIMEOUT)));if(yield Promise.race([l,c]),this.isParsed()){const e={pluginStatus:"loaded",pluginURL:a};return this.setState(e),e}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${a}`)}))}};class Es{constructor(e,s){this.isSupportedScript=hc,this.zoom=e,s?(this.now=s.now||0,this.fadeDuration=s.fadeDuration||0,this.zoomHistory=s.zoomHistory||new ds,this.transition=s.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new ds,this.transition={})}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,s=e-Math.floor(e),a=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:s+(1-s)*a}:{fromScale:.5,toScale:1,t:1-(1-a)*s}}}function hc(e){return function(e,s){for(const a of e)if(!ac(a.charCodeAt(0),s))return!1;return!0}(e,"loaded"===cc.getRTLTextPluginStatus())}class Ds{constructor(e,s,a){this.property=e,this.value=s,this.expression=function(e,s,a){if(vs(e))return new ai(e,s);if(ks(e)){const l=Ws(e,s,a);if("error"===l.result)throw new Error(l.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return l.value}{let a=e;return"color"===s.type&&"string"==typeof e?a=It.parse(e):"padding"!==s.type||"number"!=typeof e&&!Array.isArray(e)?"numberArray"!==s.type||"number"!=typeof e&&!Array.isArray(e)?"colorArray"!==s.type||"string"!=typeof e&&!Array.isArray(e)?"variableAnchorOffsetCollection"===s.type&&Array.isArray(e)?a=Ct.parse(e):"projectionDefinition"===s.type&&"string"==typeof e&&(a=Ot.parse(e)):a=Pt.parse(e):a=Bt.parse(e):a=Ft.parse(e),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>a}}}(void 0===s?e.specification.default:s,e.specification,a)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,s,a){return this.property.possiblyEvaluate(this,e,s,a)}}class Fs{constructor(e,s){this.property=e,this.value=new Ds(e,void 0,s)}transitioned(e,s){return new Ps(this.property,this.value,s,Se({},e.transition,this.transition),e.now)}untransitioned(){return new Ps(this.property,this.value,null,{},0)}}class Bs{constructor(e,s){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=s}getValue(e){return Ae(this._values[e].value.value)}setValue(e,s){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Fs(this._values[e].property,this._globalState)),this._values[e].value=new Ds(this._values[e].property,null===s?void 0:Ae(s),this._globalState)}getTransition(e){return Ae(this._values[e].transition)}setTransition(e,s){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Fs(this._values[e].property,this._globalState)),this._values[e].transition=Ae(s)||void 0}serialize(){const e={};for(const s of Object.keys(this._values)){const a=this.getValue(s);void 0!==a&&(e[s]=a);const l=this.getTransition(s);void 0!==l&&(e[`${s}-transition`]=l)}return e}transitioned(e,s){const a=new zs(this._properties);for(const l of Object.keys(this._values))a._values[l]=this._values[l].transitioned(e,s._values[l]);return a}untransitioned(){const e=new zs(this._properties);for(const s of Object.keys(this._values))e._values[s]=this._values[s].untransitioned();return e}}class Ps{constructor(e,s,a,l,c){this.property=e,this.value=s,this.begin=c+l.delay||0,this.end=this.begin+l.duration||0,e.specification.transition&&(l.delay||l.duration)&&(this.prior=a)}possiblyEvaluate(e,s,a){const l=e.now||0,c=this.value.possiblyEvaluate(e,s,a),u=this.prior;if(u){if(l>this.end)return this.prior=null,c;if(this.value.isDataDriven())return this.prior=null,c;if(l<this.begin)return u.possiblyEvaluate(e,s,a);{const d=(l-this.begin)/(this.end-this.begin);return this.property.interpolate(u.possiblyEvaluate(e,s,a),c,xe(d))}}return c}}class zs{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,s,a){const l=new Ls(this._properties);for(const c of Object.keys(this._values))l._values[c]=this._values[c].possiblyEvaluate(e,s,a);return l}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class Vs{constructor(e,s){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._globalState=s}hasValue(e){return void 0!==this._values[e].value}getValue(e){return Ae(this._values[e].value)}setValue(e,s){this._values[e]=new Ds(this._values[e].property,null===s?void 0:Ae(s),this._globalState)}serialize(){const e={};for(const s of Object.keys(this._values)){const a=this.getValue(s);void 0!==a&&(e[s]=a)}return e}possiblyEvaluate(e,s,a){const l=new Ls(this._properties);for(const c of Object.keys(this._values))l._values[c]=this._values[c].possiblyEvaluate(e,s,a);return l}}class Cs{constructor(e,s,a){this.property=e,this.value=s,this.parameters=a}isConstant(){return"constant"===this.value.kind}constantOr(e){return"constant"===this.value.kind?this.value.value:e}evaluate(e,s,a,l){return this.property.evaluate(this.value,this.parameters,e,s,a,l)}}class Ls{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class Os{constructor(e){this.specification=e}possiblyEvaluate(e,s){if(e.isDataDriven())throw new Error("Value should not be data driven");return e.expression.evaluate(s)}interpolate(e,s,a){const l=Or[this.specification.type];return l?l(e,s,a):e}}class Rs{constructor(e,s){this.specification=e,this.overrides=s}possiblyEvaluate(e,s,a,l){return new Cs(this,"constant"===e.expression.kind||"camera"===e.expression.kind?{kind:"constant",value:e.expression.evaluate(s,null,{},a,l)}:e.expression,s)}interpolate(e,s,a){if("constant"!==e.value.kind||"constant"!==s.value.kind)return e;if(void 0===e.value.value||void 0===s.value.value)return new Cs(this,{kind:"constant",value:void 0},e.parameters);const l=Or[this.specification.type];if(l){const c=l(e.value.value,s.value.value,a);return new Cs(this,{kind:"constant",value:c},e.parameters)}return e}evaluate(e,s,a,l,c,u){return"constant"===e.kind?e.value:e.evaluate(s,a,l,c,u)}}class Ns extends Rs{possiblyEvaluate(e,s,a,l){if(void 0===e.value)return new Cs(this,{kind:"constant",value:void 0},s);if("constant"===e.expression.kind){const c=e.expression.evaluate(s,null,{},a,l),u="resolvedImage"===e.property.specification.type&&"string"!=typeof c?c.name:c,d=this._calculate(u,u,u,s);return new Cs(this,{kind:"constant",value:d},s)}if("camera"===e.expression.kind){const a=this._calculate(e.expression.evaluate({zoom:s.zoom-1}),e.expression.evaluate({zoom:s.zoom}),e.expression.evaluate({zoom:s.zoom+1}),s);return new Cs(this,{kind:"constant",value:a},s)}return new Cs(this,e.expression,s)}evaluate(e,s,a,l,c,u){if("source"===e.kind){const d=e.evaluate(s,a,l,c,u);return this._calculate(d,d,d,s)}return"composite"===e.kind?this._calculate(e.evaluate({zoom:Math.floor(s.zoom)-1},a,l),e.evaluate({zoom:Math.floor(s.zoom)},a,l),e.evaluate({zoom:Math.floor(s.zoom)+1},a,l),s):e.value}_calculate(e,s,a,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:e,to:s}:{from:a,to:s}}interpolate(e){return e}}class $s{constructor(e){this.specification=e}possiblyEvaluate(e,s,a,l){if(void 0!==e.value){if("constant"===e.expression.kind){const c=e.expression.evaluate(s,null,{},a,l);return this._calculate(c,c,c,s)}return this._calculate(e.expression.evaluate(new Es(Math.floor(s.zoom-1),s)),e.expression.evaluate(new Es(Math.floor(s.zoom),s)),e.expression.evaluate(new Es(Math.floor(s.zoom+1),s)),s)}}_calculate(e,s,a,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:e,to:s}:{from:a,to:s}}interpolate(e){return e}}class Us{constructor(e){this.specification=e}possiblyEvaluate(e,s,a,l){return!!e.expression.evaluate(s,null,{},a,l)}interpolate(){return!1}}class qs{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const s in e){const a=e[s];a.specification.overridable&&this.overridableProperties.push(s);const l=this.defaultPropertyValues[s]=new Ds(a,void 0,void 0),c=this.defaultTransitionablePropertyValues[s]=new Fs(a,void 0);this.defaultTransitioningPropertyValues[s]=c.untransitioned(),this.defaultPossiblyEvaluatedValues[s]=l.possiblyEvaluate({})}}}ql("DataDrivenProperty",Rs),ql("DataConstantProperty",Os),ql("CrossFadedDataDrivenProperty",Ns),ql("CrossFadedProperty",$s),ql("ColorRampProperty",Us);const uc="-transition";class Gs extends ge{constructor(e,s,a){if(super(),this.id=e.id,this.type=e.type,this._globalState=a,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter,this._featureFilter=co(e.filter,a)),s.layout&&(this._unevaluatedLayout=new Vs(s.layout,a)),s.paint)){this._transitionablePaint=new Bs(s.paint,a);for(const s in e.paint)this.setPaintProperty(s,e.paint[s],{validate:!1});for(const s in e.layout)this.setLayoutProperty(s,e.layout[s],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Ls(s.paint)}}setFilter(e){this.filter=e,this._featureFilter=co(e,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){const e=new Set;if(this._unevaluatedLayout)for(const s in this._unevaluatedLayout._values){const a=this._unevaluatedLayout._values[s];for(const s of a.getGlobalStateRefs())e.add(s)}for(const s of this._featureFilter.getGlobalStateRefs())e.add(s);return e}getPaintAffectingGlobalStateRefs(){var e;const s=new globalThis.Map;if(this._transitionablePaint)for(const a in this._transitionablePaint._values){const l=this._transitionablePaint._values[a].value;for(const c of l.getGlobalStateRefs()){const u=null!==(e=s.get(c))&&void 0!==e?e:[];u.push({name:a,value:l.value}),s.set(c,u)}}return s}setLayoutProperty(e,s,a={}){null!=s&&this._validate(Ul,`layers.${this.id}.layout.${e}`,e,s,a)||("visibility"!==e?this._unevaluatedLayout.setValue(e,s):this.visibility=s)}getPaintProperty(e){return e.endsWith(uc)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,s,a={}){if(null!=s&&this._validate(jl,`layers.${this.id}.paint.${e}`,e,s,a))return!1;if(e.endsWith(uc))return this._transitionablePaint.setTransition(e.slice(0,-11),s||void 0),!1;{const a=this._transitionablePaint._values[e],l="cross-faded-data-driven"===a.property.specification["property-type"],c=a.value.isDataDriven(),u=a.value;this._transitionablePaint.setValue(e,s),this._handleSpecialPaintPropertyUpdate(e);const d=this._transitionablePaint._values[e].value;return d.isDataDriven()||c||l||this._handleOverridablePaintPropertyUpdate(e,u,d)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,s,a){return!1}isHidden(e,s=!1){return!!(this.minzoom&&e<(s?Math.floor(this.minzoom):this.minzoom))||!!(this.maxzoom&&e>=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,s){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,s)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,s)}serialize(){const e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),Ce(e,((e,s)=>!(void 0===e||"layout"===s&&!Object.keys(e).length||"paint"===s&&!Object.keys(e).length)))}_validate(e,s,a,l,c={}){return(!c||!1!==c.validate)&&Gl(this,e.call(Ol,{key:s,layerType:this.type,objectKey:a,value:l,styleSpec:pt,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const s=this.paint.get(e);if(s instanceof Cs&&_s(s.property.specification)&&("source"===s.value.kind||"composite"===s.value.kind)&&s.value.isStateDependent)return!0}return!1}}let dc;var fc={get paint(){return dc=dc||new qs({"raster-opacity":new Os(pt.paint_raster["raster-opacity"]),"raster-hue-rotate":new Os(pt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Os(pt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Os(pt.paint_raster["raster-brightness-max"]),"raster-saturation":new Os(pt.paint_raster["raster-saturation"]),"raster-contrast":new Os(pt.paint_raster["raster-contrast"]),"raster-resampling":new Os(pt.paint_raster["raster-resampling"]),"raster-fade-duration":new Os(pt.paint_raster["raster-fade-duration"])})}};class Zs extends Gs{constructor(e,s){super(e,fc,s)}}const mc={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Ks{constructor(e,s){this._structArray=e,this._pos1=s*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Js{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,s){return e._trim(),s&&(e.isTransferred=!0,s.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const s=Object.create(this.prototype);return s.arrayBuffer=e.arrayBuffer,s.length=e.length,s.capacity=e.arrayBuffer.byteLength/s.bytesPerElement,s._refreshViews(),s}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const s=this.uint8;this._refreshViews(),s&&this.uint8.set(s)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function _c(e,s=1){let a=0,l=0;return{members:e.map((e=>{const c=mc[e.type].BYTES_PER_ELEMENT,u=a=gc(a,Math.max(s,c)),d=e.components||1;return l=Math.max(l,c),a+=c*d,{name:e.name,type:e.type,components:d,offset:u}})),size:gc(a,Math.max(l,s)),alignment:s}}function gc(e,s){return Math.ceil(e/s)*s}class ea extends Js{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,s)}emplace(e,s,a){const l=2*e;return this.int16[l+0]=s,this.int16[l+1]=a,e}}ea.prototype.bytesPerElement=4,ql("StructArrayLayout2i4",ea);class ta extends Js{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,s,a)}emplace(e,s,a,l){const c=3*e;return this.int16[c+0]=s,this.int16[c+1]=a,this.int16[c+2]=l,e}}ta.prototype.bytesPerElement=6,ql("StructArrayLayout3i6",ta);class ra extends Js{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,s,a,l)}emplace(e,s,a,l,c){const u=4*e;return this.int16[u+0]=s,this.int16[u+1]=a,this.int16[u+2]=l,this.int16[u+3]=c,e}}ra.prototype.bytesPerElement=8,ql("StructArrayLayout4i8",ra);class na extends Js{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,a,l,c,u){const d=this.length;return this.resize(d+1),this.emplace(d,e,s,a,l,c,u)}emplace(e,s,a,l,c,u,d){const f=6*e;return this.int16[f+0]=s,this.int16[f+1]=a,this.int16[f+2]=l,this.int16[f+3]=c,this.int16[f+4]=u,this.int16[f+5]=d,e}}na.prototype.bytesPerElement=12,ql("StructArrayLayout2i4i12",na);class ia extends Js{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,a,l,c,u){const d=this.length;return this.resize(d+1),this.emplace(d,e,s,a,l,c,u)}emplace(e,s,a,l,c,u,d){const f=4*e,_=8*e;return this.int16[f+0]=s,this.int16[f+1]=a,this.uint8[_+4]=l,this.uint8[_+5]=c,this.uint8[_+6]=u,this.uint8[_+7]=d,e}}ia.prototype.bytesPerElement=8,ql("StructArrayLayout2i4ub8",ia);class sa extends Js{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,s)}emplace(e,s,a){const l=2*e;return this.float32[l+0]=s,this.float32[l+1]=a,e}}sa.prototype.bytesPerElement=8,ql("StructArrayLayout2f8",sa);class aa extends Js{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,a,l,c,u,d,f,_,y){const b=this.length;return this.resize(b+1),this.emplace(b,e,s,a,l,c,u,d,f,_,y)}emplace(e,s,a,l,c,u,d,f,_,y,b){const S=10*e;return this.uint16[S+0]=s,this.uint16[S+1]=a,this.uint16[S+2]=l,this.uint16[S+3]=c,this.uint16[S+4]=u,this.uint16[S+5]=d,this.uint16[S+6]=f,this.uint16[S+7]=_,this.uint16[S+8]=y,this.uint16[S+9]=b,e}}aa.prototype.bytesPerElement=20,ql("StructArrayLayout10ui20",aa);class oa extends Js{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,a,l,c,u,d,f){const _=this.length;return this.resize(_+1),this.emplace(_,e,s,a,l,c,u,d,f)}emplace(e,s,a,l,c,u,d,f,_){const y=8*e;return this.uint16[y+0]=s,this.uint16[y+1]=a,this.uint16[y+2]=l,this.uint16[y+3]=c,this.uint16[y+4]=u,this.uint16[y+5]=d,this.uint16[y+6]=f,this.uint16[y+7]=_,e}}oa.prototype.bytesPerElement=16,ql("StructArrayLayout8ui16",oa);class la extends Js{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,a,l,c,u,d,f,_,y,b,S){const P=this.length;return this.resize(P+1),this.emplace(P,e,s,a,l,c,u,d,f,_,y,b,S)}emplace(e,s,a,l,c,u,d,f,_,y,b,S,P){const M=12*e;return this.int16[M+0]=s,this.int16[M+1]=a,this.int16[M+2]=l,this.int16[M+3]=c,this.uint16[M+4]=u,this.uint16[M+5]=d,this.uint16[M+6]=f,this.uint16[M+7]=_,this.int16[M+8]=y,this.int16[M+9]=b,this.int16[M+10]=S,this.int16[M+11]=P,e}}la.prototype.bytesPerElement=24,ql("StructArrayLayout4i4ui4i24",la);class ua extends Js{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,s,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,s,a)}emplace(e,s,a,l){const c=3*e;return this.float32[c+0]=s,this.float32[c+1]=a,this.float32[c+2]=l,e}}ua.prototype.bytesPerElement=12,ql("StructArrayLayout3f12",ua);class ca extends Js{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const s=this.length;return this.resize(s+1),this.emplace(s,e)}emplace(e,s){return this.uint32[1*e+0]=s,e}}ca.prototype.bytesPerElement=4,ql("StructArrayLayout1ul4",ca);class ha extends Js{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,a,l,c,u,d,f,_){const y=this.length;return this.resize(y+1),this.emplace(y,e,s,a,l,c,u,d,f,_)}emplace(e,s,a,l,c,u,d,f,_,y){const b=10*e,S=5*e;return this.int16[b+0]=s,this.int16[b+1]=a,this.int16[b+2]=l,this.int16[b+3]=c,this.int16[b+4]=u,this.int16[b+5]=d,this.uint32[S+3]=f,this.uint16[b+8]=_,this.uint16[b+9]=y,e}}ha.prototype.bytesPerElement=20,ql("StructArrayLayout6i1ul2ui20",ha);class pa extends Js{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,a,l,c,u){const d=this.length;return this.resize(d+1),this.emplace(d,e,s,a,l,c,u)}emplace(e,s,a,l,c,u,d){const f=6*e;return this.int16[f+0]=s,this.int16[f+1]=a,this.int16[f+2]=l,this.int16[f+3]=c,this.int16[f+4]=u,this.int16[f+5]=d,e}}pa.prototype.bytesPerElement=12,ql("StructArrayLayout2i2i2i12",pa);class fa extends Js{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,a,l,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,s,a,l,c)}emplace(e,s,a,l,c,u){const d=4*e,f=8*e;return this.float32[d+0]=s,this.float32[d+1]=a,this.float32[d+2]=l,this.int16[f+6]=c,this.int16[f+7]=u,e}}fa.prototype.bytesPerElement=16,ql("StructArrayLayout2f1f2i16",fa);class da extends Js{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,a,l,c,u){const d=this.length;return this.resize(d+1),this.emplace(d,e,s,a,l,c,u)}emplace(e,s,a,l,c,u,d){const f=16*e,_=4*e,y=8*e;return this.uint8[f+0]=s,this.uint8[f+1]=a,this.float32[_+1]=l,this.float32[_+2]=c,this.int16[y+6]=u,this.int16[y+7]=d,e}}da.prototype.bytesPerElement=16,ql("StructArrayLayout2ub2f2i16",da);class ya extends Js{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,s,a)}emplace(e,s,a,l){const c=3*e;return this.uint16[c+0]=s,this.uint16[c+1]=a,this.uint16[c+2]=l,e}}ya.prototype.bytesPerElement=6,ql("StructArrayLayout3ui6",ya);class ma extends Js{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,s,a,l,c,u,d,f,_,y,b,S,P,M,C,D,L){const F=this.length;return this.resize(F+1),this.emplace(F,e,s,a,l,c,u,d,f,_,y,b,S,P,M,C,D,L)}emplace(e,s,a,l,c,u,d,f,_,y,b,S,P,M,C,D,L,F){const B=24*e,O=12*e,V=48*e;return this.int16[B+0]=s,this.int16[B+1]=a,this.uint16[B+2]=l,this.uint16[B+3]=c,this.uint32[O+2]=u,this.uint32[O+3]=d,this.uint32[O+4]=f,this.uint16[B+10]=_,this.uint16[B+11]=y,this.uint16[B+12]=b,this.float32[O+7]=S,this.float32[O+8]=P,this.uint8[V+36]=M,this.uint8[V+37]=C,this.uint8[V+38]=D,this.uint32[O+10]=L,this.int16[B+22]=F,e}}ma.prototype.bytesPerElement=48,ql("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",ma);class ga extends Js{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,s,a,l,c,u,d,f,_,y,b,S,P,M,C,D,L,F,B,O,V,N,j,G,Z,q,W,J){const Q=this.length;return this.resize(Q+1),this.emplace(Q,e,s,a,l,c,u,d,f,_,y,b,S,P,M,C,D,L,F,B,O,V,N,j,G,Z,q,W,J)}emplace(e,s,a,l,c,u,d,f,_,y,b,S,P,M,C,D,L,F,B,O,V,N,j,G,Z,q,W,J,Q){const se=32*e,oe=16*e;return this.int16[se+0]=s,this.int16[se+1]=a,this.int16[se+2]=l,this.int16[se+3]=c,this.int16[se+4]=u,this.int16[se+5]=d,this.int16[se+6]=f,this.int16[se+7]=_,this.uint16[se+8]=y,this.uint16[se+9]=b,this.uint16[se+10]=S,this.uint16[se+11]=P,this.uint16[se+12]=M,this.uint16[se+13]=C,this.uint16[se+14]=D,this.uint16[se+15]=L,this.uint16[se+16]=F,this.uint16[se+17]=B,this.uint16[se+18]=O,this.uint16[se+19]=V,this.uint16[se+20]=N,this.uint16[se+21]=j,this.uint16[se+22]=G,this.uint32[oe+12]=Z,this.float32[oe+13]=q,this.float32[oe+14]=W,this.uint16[se+30]=J,this.uint16[se+31]=Q,e}}ga.prototype.bytesPerElement=64,ql("StructArrayLayout8i15ui1ul2f2ui64",ga);class xa extends Js{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const s=this.length;return this.resize(s+1),this.emplace(s,e)}emplace(e,s){return this.float32[1*e+0]=s,e}}xa.prototype.bytesPerElement=4,ql("StructArrayLayout1f4",xa);class va extends Js{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,s,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,s,a)}emplace(e,s,a,l){const c=3*e;return this.uint16[6*e+0]=s,this.float32[c+1]=a,this.float32[c+2]=l,e}}va.prototype.bytesPerElement=12,ql("StructArrayLayout1ui2f12",va);class ba extends Js{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,s,a)}emplace(e,s,a,l){const c=4*e;return this.uint32[2*e+0]=s,this.uint16[c+2]=a,this.uint16[c+3]=l,e}}ba.prototype.bytesPerElement=8,ql("StructArrayLayout1ul2ui8",ba);class wa extends Js{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,s)}emplace(e,s,a){const l=2*e;return this.uint16[l+0]=s,this.uint16[l+1]=a,e}}wa.prototype.bytesPerElement=4,ql("StructArrayLayout2ui4",wa);class _a extends Js{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const s=this.length;return this.resize(s+1),this.emplace(s,e)}emplace(e,s){return this.uint16[1*e+0]=s,e}}_a.prototype.bytesPerElement=2,ql("StructArrayLayout1ui2",_a);class Sa extends Js{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,s,a,l)}emplace(e,s,a,l,c){const u=4*e;return this.float32[u+0]=s,this.float32[u+1]=a,this.float32[u+2]=l,this.float32[u+3]=c,e}}Sa.prototype.bytesPerElement=16,ql("StructArrayLayout4f16",Sa);class Aa extends Ks{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new l(this.anchorPointX,this.anchorPointY)}}Aa.prototype.size=20;class Ta extends ha{get(e){return new Aa(this,e)}}ql("CollisionBoxArray",Ta);class Ia extends Ks{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}Ia.prototype.size=48;class Ma extends ma{get(e){return new Ia(this,e)}}ql("PlacedSymbolArray",Ma);class Ea extends Ks{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}Ea.prototype.size=64;class ka extends ga{get(e){return new Ea(this,e)}}ql("SymbolInstanceArray",ka);class Da extends xa{getoffsetX(e){return this.float32[1*e+0]}}ql("GlyphOffsetArray",Da);class Fa extends ta{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}ql("SymbolLineVertexArray",Fa);class Ba extends Ks{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}Ba.prototype.size=12;class Pa extends va{get(e){return new Ba(this,e)}}ql("TextAnchorOffsetArray",Pa);class za extends Ks{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]}}za.prototype.size=8;class Va extends ba{get(e){return new za(this,e)}}ql("FeatureIndexArray",Va);class Ca extends ea{}class La extends ea{}class Oa extends ea{}class Ra extends na{}class Na extends ia{}class $a extends sa{}class Ua extends aa{}class qa extends oa{}class ja extends la{}class Ga extends ua{}class Xa extends ca{}class Ya extends pa{}class Za extends da{}class Ha extends ya{}class Ka extends wa{}const yc=_c([{name:"a_pos",components:2,type:"Int16"}],4),{members:xc}=yc;class Qa{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,s,a,l){const c=this.segments[this.segments.length-1];return e>Qa.MAX_VERTEX_ARRAY_LENGTH&&Le(`Max vertices per segment is ${Qa.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${Qa.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!c||c.vertexLength+e>Qa.MAX_VERTEX_ARRAY_LENGTH||c.sortKey!==l?this.createNewSegment(s,a,l):c}createNewSegment(e,s,a){const l={vertexOffset:e.length,primitiveOffset:s.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==a&&(l.sortKey=a),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(l),l}getOrCreateLatestSegment(e,s,a){return this.prepareSegment(0,e,s,a)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(const e of this.segments)for(const s in e.vaos)e.vaos[s].destroy()}static simpleSegment(e,s,a,l){return new Qa([{vertexOffset:e,primitiveOffset:s,vertexLength:a,primitiveLength:l,vaos:{},sortKey:0}])}}function vc(e,s){return 256*(e=we(Math.floor(e),0,255))+we(Math.floor(s),0,255)}Qa.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ql("SegmentVector",Qa);const bc=_c([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]),wc=_c([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var Tc,Sc,Pc,Ic={exports:{}},Mc={exports:{}},Cc={exports:{}},Ac=function(){if(Pc)return Ic.exports;Pc=1;var e=(Tc||(Tc=1,Mc.exports=function(e,s){var a,l,c,u,d,f,_,y;for(l=e.length-(a=3&e.length),c=s,d=3432918353,f=461845907,y=0;y<l;)_=255&e.charCodeAt(y)|(255&e.charCodeAt(++y))<<8|(255&e.charCodeAt(++y))<<16|(255&e.charCodeAt(++y))<<24,++y,c=27492+(65535&(u=5*(65535&(c=(c^=_=(65535&(_=(_=(65535&_)*d+(((_>>>16)*d&65535)<<16)&4294967295)<<15|_>>>17))*f+(((_>>>16)*f&65535)<<16)&4294967295)<<13|c>>>19))+((5*(c>>>16)&65535)<<16)&4294967295))+((58964+(u>>>16)&65535)<<16);switch(_=0,a){case 3:_^=(255&e.charCodeAt(y+2))<<16;case 2:_^=(255&e.charCodeAt(y+1))<<8;case 1:c^=_=(65535&(_=(_=(65535&(_^=255&e.charCodeAt(y)))*d+(((_>>>16)*d&65535)<<16)&4294967295)<<15|_>>>17))*f+(((_>>>16)*f&65535)<<16)&4294967295}return c^=e.length,c=2246822507*(65535&(c^=c>>>16))+((2246822507*(c>>>16)&65535)<<16)&4294967295,c=3266489909*(65535&(c^=c>>>13))+((3266489909*(c>>>16)&65535)<<16)&4294967295,(c^=c>>>16)>>>0}),Mc.exports),s=(Sc||(Sc=1,Cc.exports=function(e,s){for(var a,l=e.length,c=s^l,u=0;l>=4;)a=1540483477*(65535&(a=255&e.charCodeAt(u)|(255&e.charCodeAt(++u))<<8|(255&e.charCodeAt(++u))<<16|(255&e.charCodeAt(++u))<<24))+((1540483477*(a>>>16)&65535)<<16),c=1540483477*(65535&c)+((1540483477*(c>>>16)&65535)<<16)^(a=1540483477*(65535&(a^=a>>>24))+((1540483477*(a>>>16)&65535)<<16)),l-=4,++u;switch(l){case 3:c^=(255&e.charCodeAt(u+2))<<16;case 2:c^=(255&e.charCodeAt(u+1))<<8;case 1:c=1540483477*(65535&(c^=255&e.charCodeAt(u)))+((1540483477*(c>>>16)&65535)<<16)}return c=1540483477*(65535&(c^=c>>>13))+((1540483477*(c>>>16)&65535)<<16),(c^=c>>>15)>>>0}),Cc.exports);return Ic.exports=e,Ic.exports.murmur3=e,Ic.exports.murmur2=s,Ic.exports}(),Dc=c(Ac);class ho{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,s,a,l){this.ids.push(zc(e)),this.positions.push(s,a,l)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const s=zc(e);let a=0,l=this.ids.length-1;for(;a<l;){const e=a+l>>1;this.ids[e]>=s?l=e:a=e+1}const c=[];for(;this.ids[a]===s;)c.push({index:this.positions[3*a],start:this.positions[3*a+1],end:this.positions[3*a+2]}),a++;return c}static serialize(e,s){const a=new Float64Array(e.ids),l=new Uint32Array(e.positions);return Rc(a,l,0,a.length-1),s&&s.push(a.buffer,l.buffer),{ids:a,positions:l}}static deserialize(e){const s=new ho;return s.ids=e.ids,s.positions=e.positions,s.indexed=!0,s}}function zc(e){const s=+e;return!isNaN(s)&&s<=Number.MAX_SAFE_INTEGER?s:Dc(String(e))}function Rc(e,s,a,l){for(;a<l;){const c=e[a+l>>1];let u=a-1,d=l+1;for(;;){do{u++}while(e[u]<c);do{d--}while(e[d]>c);if(u>=d)break;Lc(e,u,d),Lc(s,3*u,3*d),Lc(s,3*u+1,3*d+1),Lc(s,3*u+2,3*d+2)}d-a<l-d?(Rc(e,s,a,d),a=d+1):(Rc(e,s,d+1,l),l=d)}}function Lc(e,s,a){const l=e[s];e[s]=e[a],e[a]=l}ql("FeaturePositionMap",ho);class mo{constructor(e,s){this.gl=e.gl,this.location=s}}class go extends mo{constructor(e,s){super(e,s),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}}class xo extends mo{constructor(e,s){super(e,s),this.current=[0,0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]&&e[3]===this.current[3]||(this.current=e,this.gl.uniform4f(this.location,e[0],e[1],e[2],e[3]))}}class vo extends mo{constructor(e,s){super(e,s),this.current=It.transparent}set(e){e.r===this.current.r&&e.g===this.current.g&&e.b===this.current.b&&e.a===this.current.a||(this.current=e,this.gl.uniform4f(this.location,e.r,e.g,e.b,e.a))}}const Oc=new Float32Array(16);function Vc(e){return[vc(255*e.r,255*e.g),vc(255*e.b,255*e.a)]}class _o{constructor(e,s,a){this.value=e,this.uniformNames=s.map((e=>`u_${e}`)),this.type=a}setUniform(e,s,a){e.set(a.constantOr(this.value))}getBinding(e,s,a){return"color"===this.type?new vo(e,s):new go(e,s)}}class So{constructor(e,s){this.uniformNames=s.map((e=>`u_${e}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,s){this.pixelRatioFrom=s.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=s.tlbr,this.patternTo=e.tlbr}setConstantDashPositions(e,s){this.dashTo=[0,e.y,e.height,e.width],this.dashFrom=[0,s.y,s.height,s.width]}setUniform(e,s,a,l){let c=null;"u_pattern_to"===l?c=this.patternTo:"u_pattern_from"===l?c=this.patternFrom:"u_dasharray_to"===l?c=this.dashTo:"u_dasharray_from"===l?c=this.dashFrom:"u_pixel_ratio_to"===l?c=this.pixelRatioTo:"u_pixel_ratio_from"===l&&(c=this.pixelRatioFrom),null!==c&&e.set(c)}getBinding(e,s,a){return"u_pattern"===a.substr(0,9)||"u_dasharray_"===a.substr(0,12)?new xo(e,s):new go(e,s)}}class Ao{constructor(e,s,a,l){this.expression=e,this.type=a,this.maxValue=0,this.paintVertexAttributes=s.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===a?2:1,offset:0}))),this.paintVertexArray=new l}populatePaintArray(e,s,a){const l=this.paintVertexArray.length,c=this.expression.evaluate(new Es(0,a),s,{},a.canonical,[],a.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(l,e,c)}updatePaintArray(e,s,a,l,c){const u=this.expression.evaluate(new Es(0,c),a,l);this._setPaintValue(e,s,u)}_setPaintValue(e,s,a){if("color"===this.type){const l=Vc(a);for(let a=e;a<s;a++)this.paintVertexArray.emplace(a,l[0],l[1])}else{for(let l=e;l<s;l++)this.paintVertexArray.emplace(l,a);this.maxValue=Math.max(this.maxValue,Math.abs(a))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class To{constructor(e,s,a,l,c,u){this.expression=e,this.uniformNames=s.map((e=>`u_${e}_t`)),this.type=a,this.useIntegerZoom=l,this.zoom=c,this.maxValue=0,this.paintVertexAttributes=s.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===a?4:2,offset:0}))),this.paintVertexArray=new u}populatePaintArray(e,s,a){const l=this.expression.evaluate(new Es(this.zoom,a),s,{},a.canonical,[],a.formattedSection),c=this.expression.evaluate(new Es(this.zoom+1,a),s,{},a.canonical,[],a.formattedSection),u=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(u,e,l,c)}updatePaintArray(e,s,a,l,c){const u=this.expression.evaluate(new Es(this.zoom,c),a,l),d=this.expression.evaluate(new Es(this.zoom+1,c),a,l);this._setPaintValue(e,s,u,d)}_setPaintValue(e,s,a,l){if("color"===this.type){const c=Vc(a),u=Vc(l);for(let a=e;a<s;a++)this.paintVertexArray.emplace(a,c[0],c[1],u[0],u[1])}else{for(let c=e;c<s;c++)this.paintVertexArray.emplace(c,a,l);this.maxValue=Math.max(this.maxValue,Math.abs(a),Math.abs(l))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,s){const a=this.useIntegerZoom?Math.floor(s.zoom):s.zoom,l=we(this.expression.interpolationFactor(a,this.zoom,this.zoom+1),0,1);e.set(l)}getBinding(e,s,a){return new go(e,s)}}class Io{constructor(e,s,a,l,c,u){this.expression=e,this.type=s,this.useIntegerZoom=a,this.zoom=l,this.layerId=u,this.zoomInPaintVertexArray=new c,this.zoomOutPaintVertexArray=new c}populatePaintArray(e,s,a){const l=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(l,e,this.getPositionIds(s),a)}updatePaintArray(e,s,a,l,c){this._setPaintValues(e,s,this.getPositionIds(a),c)}_setPaintValues(e,s,a,l){const c=this.getPositions(l);if(!c||!a)return;const u=c[a.min],d=c[a.mid],f=c[a.max];if(u&&d&&f)for(let a=e;a<s;a++)this.emplace(this.zoomInPaintVertexArray,a,d,u),this.emplace(this.zoomOutPaintVertexArray,a,d,f)}upload(e){if(this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer){const s=this.getVertexAttributes();this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,s,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,s,this.expression.isStateDependent)}}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class Mo extends Io{getPositions(e){return e.imagePositions}getPositionIds(e){return e.patterns&&e.patterns[this.layerId]}getVertexAttributes(){return bc.members}emplace(e,s,a,l){e.emplace(s,a.tlbr[0],a.tlbr[1],a.tlbr[2],a.tlbr[3],l.tlbr[0],l.tlbr[1],l.tlbr[2],l.tlbr[3],a.pixelRatio,l.pixelRatio)}}class Eo extends Io{getPositions(e){return e.dashPositions}getPositionIds(e){return e.dashes&&e.dashes[this.layerId]}getVertexAttributes(){return wc.members}emplace(e,s,a,l){e.emplace(s,0,a.y,a.height,a.width,0,l.y,l.height,l.width)}}class ko{constructor(e,s,a){this.binders={},this._buffers=[];const l=[];for(const c in e.paint._values){if(!a(c))continue;const u=e.paint.get(c);if(!(u instanceof Cs&&_s(u.property.specification)))continue;const d=Nc(c,e.type),f=u.value,_=u.property.specification.type,y=u.property.useIntegerZoom,b=u.property.specification["property-type"],S="cross-faded"===b||"cross-faded-data-driven"===b;if("constant"===f.kind)this.binders[c]=S?new So(f.value,d):new _o(f.value,d,_),l.push(`/u_${c}`);else if("source"===f.kind||S){const a=jc(c,_,"source");this.binders[c]=S?"line-dasharray"===c?new Eo(f,_,y,s,a,e.id):new Mo(f,_,y,s,a,e.id):new Ao(f,d,_,a),l.push(`/a_${c}`)}else{const e=jc(c,_,"composite");this.binders[c]=new To(f,d,_,y,s,e),l.push(`/z_${c}`)}}this.cacheKey=l.sort().join("")}getMaxValue(e){const s=this.binders[e];return s instanceof Ao||s instanceof To?s.maxValue:0}populatePaintArrays(e,s,a){for(const l in this.binders){const c=this.binders[l];(c instanceof Ao||c instanceof To||c instanceof Io)&&c.populatePaintArray(e,s,a)}}setConstantPatternPositions(e,s){for(const a in this.binders){const l=this.binders[a];l instanceof So&&l.setConstantPatternPositions(e,s)}}setConstantDashPositions(e,s){for(const a in this.binders){const l=this.binders[a];l instanceof So&&l.setConstantDashPositions(e,s)}}updatePaintArrays(e,s,a,l,c){let u=!1;for(const d in e){const f=s.getPositions(d);for(const s of f){const f=a.feature(s.index);for(const a in this.binders){const _=this.binders[a];if((_ instanceof Ao||_ instanceof To||_ instanceof Io)&&!0===_.expression.isStateDependent){const y=l.paint.get(a);_.expression=y.value,_.updatePaintArray(s.start,s.end,f,e[d],c),u=!0}}}}return u}defines(){const e=[];for(const s in this.binders){const a=this.binders[s];(a instanceof _o||a instanceof So)&&e.push(...a.uniformNames.map((e=>`#define HAS_UNIFORM_${e}`)))}return e}getBinderAttributes(){const e=[];for(const s in this.binders){const a=this.binders[s];if(a instanceof Ao||a instanceof To)for(let s=0;s<a.paintVertexAttributes.length;s++)e.push(a.paintVertexAttributes[s].name);else if(a instanceof Io){const s=a.getVertexAttributes();for(const a of s)e.push(a.name)}}return e}getBinderUniforms(){const e=[];for(const s in this.binders){const a=this.binders[s];if(a instanceof _o||a instanceof So||a instanceof To)for(const s of a.uniformNames)e.push(s)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,s){const a=[];for(const l in this.binders){const c=this.binders[l];if(c instanceof _o||c instanceof So||c instanceof To)for(const u of c.uniformNames)if(s[u]){const d=c.getBinding(e,s[u],u);a.push({name:u,property:l,binding:d})}}return a}setUniforms(e,s,a,l){for(const{name:e,property:c,binding:u}of s)this.binders[c].setUniform(u,l,a.get(c),e)}updatePaintBuffers(e){this._buffers=[];for(const s in this.binders){const a=this.binders[s];if(e&&a instanceof Io){const s=2===e.fromScale?a.zoomInPaintVertexBuffer:a.zoomOutPaintVertexBuffer;s&&this._buffers.push(s)}else(a instanceof Ao||a instanceof To)&&a.paintVertexBuffer&&this._buffers.push(a.paintVertexBuffer)}}upload(e){for(const s in this.binders){const a=this.binders[s];(a instanceof Ao||a instanceof To||a instanceof Io)&&a.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const s=this.binders[e];(s instanceof Ao||s instanceof To||s instanceof Io)&&s.destroy()}}}class Do{constructor(e,s,a=()=>!0){this.programConfigurations={};for(const l of e)this.programConfigurations[l.id]=new ko(l,s,a);this.needsUpload=!1,this._featureMap=new ho,this._bufferOffset=0}populatePaintArrays(e,s,a,l){for(const a in this.programConfigurations)this.programConfigurations[a].populatePaintArrays(e,s,l);void 0!==s.id&&this._featureMap.add(s.id,a,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,s,a,l){for(const c of a)this.needsUpload=this.programConfigurations[c.id].updatePaintArrays(e,this._featureMap,s,c,l)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const s in this.programConfigurations)this.programConfigurations[s].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}function Nc(e,s){return{"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-dasharray":["dasharray_to","dasharray_from"],"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"]}[e]||[e.replace(`${s}-`,"").replace(/-/g,"_")]}function jc(e,s,a){const l={color:{source:sa,composite:Sa},number:{source:xa,composite:sa}},c=function(e){return{"line-pattern":{source:Ua,composite:Ua},"fill-pattern":{source:Ua,composite:Ua},"fill-extrusion-pattern":{source:Ua,composite:Ua},"line-dasharray":{source:qa,composite:qa}}[e]}(e);return c&&c[a]||l[s][a]}ql("ConstantBinder",_o),ql("CrossFadedConstantBinder",So),ql("SourceExpressionBinder",Ao),ql("CrossFadedPatternBinder",Mo),ql("CrossFadedDasharrayBinder",Eo),ql("CompositeExpressionBinder",To),ql("ProgramConfiguration",ko,{omit:["_buffers"]}),ql("ProgramConfigurationSet",Do);const Uc=Math.pow(2,14)-1,Gc=-Uc-1;function Zc(e){const s=oe/e.extent,a=e.loadGeometry();for(let e=0;e<a.length;e++){const l=a[e];for(let e=0;e<l.length;e++){const a=l[e],c=Math.round(a.x*s),u=Math.round(a.y*s);a.x=we(c,Gc,Uc),a.y=we(u,Gc,Uc),(c<a.x||c>a.x+1||u<a.y||u>a.y+1)&&Le("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return a}function qc(e,s){return{type:e.type,id:e.id,properties:e.properties,geometry:s?Zc(e):[]}}const $c=-32768;function Wc(e,s,a,l,c){e.emplaceBack($c+8*s+l,$c+8*a+c)}class Ro{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new La,this.indexArray=new Ha,this.segments=new Qa,this.programConfigurations=new Do(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,s,a){const l=this.layers[0],c=[];let u=null,d=!1,f="heatmap"===l.type;if("circle"===l.type){const e=l;u=e.layout.get("circle-sort-key"),d=!u.isConstant(),f=f||"map"===e.paint.get("circle-pitch-alignment")}const _=f?s.subdivisionGranularity.circle:1;for(const{feature:s,id:l,index:f,sourceLayerIndex:_}of e){const e=this.layers[0]._featureFilter.needGeometry,y=qc(s,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom),y,a))continue;const b=d?u.evaluate(y,{},a):void 0,S={id:l,properties:s.properties,type:s.type,sourceLayerIndex:_,index:f,geometry:e?y.geometry:Zc(s),patterns:{},sortKey:b};c.push(S)}d&&c.sort(((e,s)=>e.sortKey-s.sortKey));for(const l of c){const{geometry:c,index:u,sourceLayerIndex:d}=l,f=e[u].feature;this.addFeature(l,c,u,a,_),s.featureIndex.insert(f,c,u,d,this.index)}}update(e,s,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,s,this.stateDependentLayers,{imagePositions:a})}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,xc),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,s,a,l,c=1){let u;switch(c){case 1:u=[0,7];break;case 3:u=[0,2,5,7];break;case 5:u=[0,1,3,4,6,7];break;case 7:u=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${c}; valid values are 1, 3, 5, 7.`)}const d=u.length;for(const a of s)for(const s of a){const a=s.x,l=s.y;if(a<0||a>=oe||l<0||l>=oe)continue;const c=this.segments.prepareSegment(d*d,this.layoutVertexArray,this.indexArray,e.sortKey),f=c.vertexLength;for(let e=0;e<d;e++)for(let s=0;s<d;s++)Wc(this.layoutVertexArray,a,l,u[s],u[e]);for(let e=0;e<d-1;e++)for(let s=0;s<d-1;s++){const a=f+e*d+s,l=f+(e+1)*d+s;this.indexArray.emplaceBack(a,l+1,a+1),this.indexArray.emplaceBack(a,l,l+1)}c.vertexLength+=d*d,c.primitiveLength+=(d-1)*(d-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,{imagePositions:{},canonical:l})}}function Hc(e,s){for(let a=0;a<e.length;a++)if(rh(s,e[a]))return!0;for(let a=0;a<s.length;a++)if(rh(e,s[a]))return!0;return!!Jc(e,s)}function Xc(e,s,a){return!!rh(e,s)||!!eh(s,e,a)}function Yc(e,s){if(1===e.length)return ih(s,e[0]);for(let a=0;a<s.length;a++){const l=s[a];for(let s=0;s<l.length;s++)if(rh(e,l[s]))return!0}for(let a=0;a<e.length;a++)if(ih(s,e[a]))return!0;for(let a=0;a<s.length;a++)if(Jc(e,s[a]))return!0;return!1}function Kc(e,s,a){if(e.length>1){if(Jc(e,s))return!0;for(let l=0;l<s.length;l++)if(eh(s[l],e,a))return!0}for(let l=0;l<e.length;l++)if(eh(e[l],s,a))return!0;return!1}function Jc(e,s){if(0===e.length||0===s.length)return!1;for(let a=0;a<e.length-1;a++){const l=e[a],c=e[a+1];for(let e=0;e<s.length-1;e++)if(Qc(l,c,s[e],s[e+1]))return!0}return!1}function Qc(e,s,a,l){return Fe(e,a,l)!==Fe(s,a,l)&&Fe(e,s,a)!==Fe(e,s,l)}function eh(e,s,a){const l=a*a;if(1===s.length)return e.distSqr(s[0])<l;for(let a=1;a<s.length;a++)if(th(e,s[a-1],s[a])<l)return!0;return!1}function th(e,s,a){const l=s.distSqr(a);if(0===l)return e.distSqr(s);const c=((e.x-s.x)*(a.x-s.x)+(e.y-s.y)*(a.y-s.y))/l;return e.distSqr(c<0?s:c>1?a:a.sub(s)._mult(c)._add(s))}function ih(e,s){let a,l,c,u=!1;for(let d=0;d<e.length;d++){a=e[d];for(let e=0,d=a.length-1;e<a.length;d=e++)l=a[e],c=a[d],l.y>s.y!=c.y>s.y&&s.x<(c.x-l.x)*(s.y-l.y)/(c.y-l.y)+l.x&&(u=!u)}return u}function rh(e,s){let a=!1;for(let l=0,c=e.length-1;l<e.length;c=l++){const u=e[l],d=e[c];u.y>s.y!=d.y>s.y&&s.x<(d.x-u.x)*(s.y-u.y)/(d.y-u.y)+u.x&&(a=!a)}return a}function nh(e,s,a){const l=a[0],c=a[2];if(e.x<l.x&&s.x<l.x||e.x>c.x&&s.x>c.x||e.y<l.y&&s.y<l.y||e.y>c.y&&s.y>c.y)return!1;const u=Fe(e,s,a[0]);return u!==Fe(e,s,a[1])||u!==Fe(e,s,a[2])||u!==Fe(e,s,a[3])}function sh(e,s,a){const l=s.paint.get(e).value;return"constant"===l.kind?l.value:a.programConfigurations.get(s.id).getMaxValue(e)}function ah(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function ch(e,s,a,c,u){if(!s[0]&&!s[1])return e;const d=l.convert(s)._mult(u);"viewport"===a&&d._rotate(-c);const f=[];for(let s=0;s<e.length;s++)f.push(e[s].sub(d));return f}function hh({queryGeometry:e,size:s},a){return Xc(e,a,s)}function ph({queryGeometry:e,size:s,transform:a,unwrappedTileID:l,getElevation:c},u){return Xc(e,u,s*(a.projectTileCoordinates(u.x,u.y,l,c).signedDistanceFromCamera/a.cameraToCenterDistance))}function mh({queryGeometry:e,size:s,transform:a,unwrappedTileID:l,getElevation:c},u){const d=a.projectTileCoordinates(u.x,u.y,l,c).signedDistanceFromCamera,f=s*(a.cameraToCenterDistance/d);return Xc(e,wh(u,a,l,c),f)}function yh({queryGeometry:e,size:s,transform:a,unwrappedTileID:l,getElevation:c},u){return Xc(e,wh(u,a,l,c),s)}function bh({queryGeometry:e,size:s,transform:a,unwrappedTileID:l,getElevation:c,pitchAlignment:u="map",pitchScale:d="map"},f){const _="map"===u?"map"===d?hh:ph:"map"===d?mh:yh,y={queryGeometry:e,size:s,transform:a,unwrappedTileID:l,getElevation:c};for(const e of f)for(const s of e)if(_(y,s))return!0;return!1}function wh(e,s,a,c){const u=s.projectTileCoordinates(e.x,e.y,a,c).point;return new l((.5*u.x+.5)*s.width,(.5*-u.y+.5)*s.height)}let Th,Sh;ql("CircleBucket",Ro,{omit:["layers"]});var Ih={get paint(){return Sh=Sh||new qs({"circle-radius":new Rs(pt.paint_circle["circle-radius"]),"circle-color":new Rs(pt.paint_circle["circle-color"]),"circle-blur":new Rs(pt.paint_circle["circle-blur"]),"circle-opacity":new Rs(pt.paint_circle["circle-opacity"]),"circle-translate":new Os(pt.paint_circle["circle-translate"]),"circle-translate-anchor":new Os(pt.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Os(pt.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Os(pt.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Rs(pt.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Rs(pt.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Rs(pt.paint_circle["circle-stroke-opacity"])})},get layout(){return Th=Th||new qs({"circle-sort-key":new Rs(pt.layout_circle["circle-sort-key"])})}};class ul extends Gs{constructor(e,s){super(e,Ih,s)}createBucket(e){return new Ro(e)}queryRadius(e){const s=e;return sh("circle-radius",this,s)+sh("circle-stroke-width",this,s)+ah(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:e,feature:s,featureState:a,geometry:l,transform:c,pixelsToTileUnits:u,unwrappedTileID:d,getElevation:f}){const _=ch(e,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-c.bearingInRadians,u),y=this.paint.get("circle-radius").evaluate(s,a)+this.paint.get("circle-stroke-width").evaluate(s,a),b=this.paint.get("circle-pitch-scale"),S=this.paint.get("circle-pitch-alignment");let P,M;return"map"===S?(P=_,M=y*u):(P=function(e,s,a,l){return e.map((e=>wh(e,s,a,l)))}(_,c,d,f),M=y),bh({queryGeometry:P,size:M,transform:c,unwrappedTileID:d,getElevation:f,pitchAlignment:S,pitchScale:b},l)}}class cl extends Ro{}let Mh;ql("HeatmapBucket",cl,{omit:["layers"]});var Eh={get paint(){return Mh=Mh||new qs({"heatmap-radius":new Rs(pt.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Rs(pt.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Os(pt.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Us(pt.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Os(pt.paint_heatmap["heatmap-opacity"])})}};function Ch(e,{width:s,height:a},l,c){if(c){if(c instanceof Uint8ClampedArray)c=new Uint8Array(c.buffer);else if(c.length!==s*a*l)throw new RangeError(`mismatched image size. expected: ${c.length} but got: ${s*a*l}`)}else c=new Uint8Array(s*a*l);return e.width=s,e.height=a,e.data=c,e}function Ah(e,{width:s,height:a},l){if(s===e.width&&a===e.height)return;const c=Ch({},{width:s,height:a},l);Dh(e,c,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,s),height:Math.min(e.height,a)},l),e.width=s,e.height=a,e.data=c.data}function Dh(e,s,a,l,c,u){if(0===c.width||0===c.height)return s;if(c.width>e.width||c.height>e.height||a.x>e.width-c.width||a.y>e.height-c.height)throw new RangeError("out of range source coordinates for image copy");if(c.width>s.width||c.height>s.height||l.x>s.width-c.width||l.y>s.height-c.height)throw new RangeError("out of range destination coordinates for image copy");const d=e.data,f=s.data;if(d===f)throw new Error("srcData equals dstData, so image is already copied");for(let _=0;_<c.height;_++){const y=((a.y+_)*e.width+a.x)*u,b=((l.y+_)*s.width+l.x)*u;for(let e=0;e<c.width*u;e++)f[b+e]=d[y+e]}return s}class ml{constructor(e,s){Ch(this,e,1,s)}resize(e){Ah(this,e,1)}clone(){return new ml({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,s,a,l,c){Dh(e,s,a,l,c,1)}}class gl{constructor(e,s){Ch(this,e,4,s)}resize(e){Ah(this,e,4)}replace(e,s){s?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new gl({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,s,a,l,c){Dh(e,s,a,l,c,4)}setPixel(e,s,a){const l=4*(e*this.width+s);this.data[l+0]=Math.round(255*a.r/a.a),this.data[l+1]=Math.round(255*a.g/a.a),this.data[l+2]=Math.round(255*a.b/a.a),this.data[l+3]=Math.round(255*a.a)}}function kh(e){const s={},a=e.resolution||256,l=e.clips?e.clips.length:1,c=e.image||new gl({width:a,height:l});if(Math.log(a)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${a}`);const u=(l,u,d)=>{s[e.evaluationKey]=d;const f=e.expression.evaluate(s);c.setPixel(l/4/a,u/4,f)};if(e.clips)for(let s=0,c=0;s<l;++s,c+=4*a)for(let l=0,d=0;l<a;l++,d+=4){const f=l/(a-1),{start:_,end:y}=e.clips[s];u(c,d,_*(1-f)+y*f)}else for(let e=0,s=0;e<a;e++,s+=4)u(0,s,e/(a-1));return c}ql("AlphaImage",ml),ql("RGBAImage",gl);const Lh="big-fb";class bl extends Gs{createBucket(e){return new cl(e)}constructor(e,s){super(e,Eh,s),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=kh({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(Lh)&&this.heatmapFbos.delete(Lh)}queryRadius(e){return sh("heatmap-radius",this,e)}queryIntersectsFeature({queryGeometry:e,feature:s,featureState:a,geometry:l,transform:c,pixelsToTileUnits:u,unwrappedTileID:d,getElevation:f}){return bh({queryGeometry:e,size:this.paint.get("heatmap-radius").evaluate(s,a)*u,transform:c,unwrappedTileID:d,getElevation:f},l)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}}let Bh;var Wh={get paint(){return Bh=Bh||new qs({"hillshade-illumination-direction":new Os(pt.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-altitude":new Os(pt.paint_hillshade["hillshade-illumination-altitude"]),"hillshade-illumination-anchor":new Os(pt.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Os(pt.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Os(pt.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Os(pt.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Os(pt.paint_hillshade["hillshade-accent-color"]),"hillshade-method":new Os(pt.paint_hillshade["hillshade-method"])})}};class Sl extends Gs{constructor(e,s){super(e,Wh,s),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let e=this.paint.get("hillshade-illumination-direction").values,s=this.paint.get("hillshade-illumination-altitude").values,a=this.paint.get("hillshade-highlight-color").values,l=this.paint.get("hillshade-shadow-color").values;const c=Math.max(e.length,s.length,a.length,l.length);e=e.concat(Array(c-e.length).fill(e.at(-1))),s=s.concat(Array(c-s.length).fill(s.at(-1))),a=a.concat(Array(c-a.length).fill(a.at(-1))),l=l.concat(Array(c-l.length).fill(l.at(-1)));const u=s.map($e);return{directionRadians:e.map($e),altitudeRadians:u,shadowColor:l,highlightColor:a}}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}}let Kh;var Jh={get paint(){return Kh=Kh||new qs({"color-relief-opacity":new Os(pt["paint_color-relief"]["color-relief-opacity"]),"color-relief-color":new Us(pt["paint_color-relief"]["color-relief-color"])})}};class Il{constructor(e,s,a,l){this.context=e,this.format=a,this.texture=e.gl.createTexture(),this.update(s,l)}update(e,s,a){const{width:l,height:c}=e,u=!(this.size&&this.size[0]===l&&this.size[1]===c||a),{context:d}=this,{gl:f}=d;if(this.useMipmap=Boolean(s&&s.useMipmap),f.bindTexture(f.TEXTURE_2D,this.texture),d.pixelStoreUnpackFlipY.set(!1),d.pixelStoreUnpack.set(1),d.pixelStoreUnpackPremultiplyAlpha.set(this.format===f.RGBA&&(!s||!1!==s.premultiply)),u)this.size=[l,c],e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||Ne(e)?f.texImage2D(f.TEXTURE_2D,0,this.format,this.format,f.UNSIGNED_BYTE,e):f.texImage2D(f.TEXTURE_2D,0,this.format,l,c,0,this.format,f.UNSIGNED_BYTE,e.data);else{const{x:s,y:u}=a||{x:0,y:0};e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||Ne(e)?f.texSubImage2D(f.TEXTURE_2D,0,s,u,f.RGBA,f.UNSIGNED_BYTE,e):f.texSubImage2D(f.TEXTURE_2D,0,s,u,l,c,f.RGBA,f.UNSIGNED_BYTE,e.data)}this.useMipmap&&this.isSizePowerOfTwo()&&f.generateMipmap(f.TEXTURE_2D),d.pixelStoreUnpackFlipY.setDefault(),d.pixelStoreUnpack.setDefault(),d.pixelStoreUnpackPremultiplyAlpha.setDefault()}bind(e,s,a){const{context:l}=this,{gl:c}=l;c.bindTexture(c.TEXTURE_2D,this.texture),a!==c.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(a=c.LINEAR),e!==this.filter&&(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,e),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,a||e),this.filter=e),s!==this.wrap&&(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,s),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,s),this.wrap=s)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class Ml{constructor(e,s,a,l=1,c=1,u=1,d=0){if(this.uid=e,s.height!==s.width)throw new RangeError("DEM tiles must be square");if(a&&!["mapbox","terrarium","custom"].includes(a))return void Le(`"${a}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=s.height;const f=this.dim=s.height-2;switch(this.data=new Uint32Array(s.data.buffer),a){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=l,this.greenFactor=c,this.blueFactor=u,this.baseShift=d;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let e=0;e<f;e++)this.data[this._idx(-1,e)]=this.data[this._idx(0,e)],this.data[this._idx(f,e)]=this.data[this._idx(f-1,e)],this.data[this._idx(e,-1)]=this.data[this._idx(e,0)],this.data[this._idx(e,f)]=this.data[this._idx(e,f-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(f,-1)]=this.data[this._idx(f-1,0)],this.data[this._idx(-1,f)]=this.data[this._idx(0,f-1)],this.data[this._idx(f,f)]=this.data[this._idx(f-1,f-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let e=0;e<f;e++)for(let s=0;s<f;s++){const a=this.get(e,s);a>this.max&&(this.max=a),a<this.min&&(this.min=a)}}get(e,s){const a=new Uint8Array(this.data.buffer),l=4*this._idx(e,s);return this.unpack(a[l],a[l+1],a[l+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(e,s){if(e<-1||e>=this.dim+1||s<-1||s>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(s+1)*this.stride+(e+1)}unpack(e,s,a){return e*this.redFactor+s*this.greenFactor+a*this.blueFactor-this.baseShift}pack(e){return Qh(e,this.getUnpackVector())}getPixels(){return new gl({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,s,a){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let l=s*this.dim,c=s*this.dim+this.dim,u=a*this.dim,d=a*this.dim+this.dim;switch(s){case-1:l=c-1;break;case 1:c=l+1}switch(a){case-1:u=d-1;break;case 1:d=u+1}const f=-s*this.dim,_=-a*this.dim;for(let s=u;s<d;s++)for(let a=l;a<c;a++)this.data[this._idx(a,s)]=e.data[this._idx(a+f,s+_)]}}function Qh(e,s){const a=s[0],l=s[1],c=s[2],u=s[3],d=Math.min(a,l,c),f=Math.round((e+u)/d);return{r:Math.floor(f*d/a)%256,g:Math.floor(f*d/l)%256,b:Math.floor(f*d/c)%256}}ql("DEMData",Ml);class kl extends Gs{constructor(e,s){super(e,Jh,s)}_createColorRamp(e){const s={elevationStops:[],colorStops:[]},a=this._transitionablePaint._values["color-relief-color"].value.expression;if(a instanceof ni&&a._styleExpression.expression instanceof pr){this.colorRampExpression=a;const e=a._styleExpression.expression;s.elevationStops=e.labels,s.colorStops=[];for(const a of s.elevationStops)s.colorStops.push(e.evaluate({globals:{elevation:a}}))}if(s.elevationStops.length<1&&(s.elevationStops=[0],s.colorStops=[It.transparent]),s.elevationStops.length<2&&(s.elevationStops.push(s.elevationStops[0]+1),s.colorStops.push(s.colorStops[0])),s.elevationStops.length<=e)return s;const l={elevationStops:[],colorStops:[]},c=(s.elevationStops.length-1)/(e-1);for(let e=0;e<s.elevationStops.length-.5;e+=c)l.elevationStops.push(s.elevationStops[Math.round(e)]),l.colorStops.push(s.colorStops[Math.round(e)]);return Le(`Too many colors in specification of ${this.id} color-relief layer, may not render properly. Max possible colors: ${e}, provided: ${s.elevationStops.length}`),l}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values["color-relief-color"].value.expression}getColorRampTextures(e,s,a){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;const l=this._createColorRamp(s),c=new gl({width:l.colorStops.length,height:1}),u=new gl({width:l.colorStops.length,height:1});for(let e=0;e<l.elevationStops.length;e++){const s=Qh(l.elevationStops[e],a);u.setPixel(0,e,new It(s.r/255,s.g/255,s.b/255,1)),c.setPixel(0,e,l.colorStops[e])}return this.colorRampTextures={elevationTexture:new Il(e,u,e.gl.RGBA),colorTexture:new Il(e,c,e.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return"none"!==this.visibility&&!!this.colorRampTextures}}const eu=_c([{name:"a_pos",components:2,type:"Int16"}],4),{members:tu}=eu;function iu(e,s,a){const l=a.patternDependencies;let c=!1;for(const a of s){const s=a.paint.get(`${e}-pattern`);s.isConstant()||(c=!0);const u=s.constantOr(null);u&&(c=!0,l[u.to]=!0,l[u.from]=!0)}return c}function ru(e,s,a,l,c){const{zoom:u}=l,d=c.patternDependencies;for(const l of s){const s=l.paint.get(`${e}-pattern`).value;if("constant"!==s.kind){let e=s.evaluate({zoom:u-1},a,{},c.availableImages),f=s.evaluate({zoom:u},a,{},c.availableImages),_=s.evaluate({zoom:u+1},a,{},c.availableImages);e=e&&e.name?e.name:e,f=f&&f.name?f.name:f,_=_&&_.name?_.name:_,d[e]=!0,d[f]=!0,d[_]=!0,a.patterns[l.id]={min:e,mid:f,max:_}}}return a}function nu(e,s,a,l,c){let u;if(c===function(e,s,a,l){let c=0;for(let u=s,d=a-l;u<a;u+=l)c+=(e[d]-e[u])*(e[u+1]+e[d+1]),d=u;return c}(e,s,a,l)>0)for(let c=s;c<a;c+=l)u=Ru(c/l|0,e[c],e[c+1],u);else for(let c=a-l;c>=s;c-=l)u=Ru(c/l|0,e[c],e[c+1],u);return u&&Mu(u,u.next)&&(Lu(u),u=u.next),u}function ou(e,s){if(!e)return e;s||(s=e);let a,l=e;do{if(a=!1,l.steiner||!Mu(l,l.next)&&0!==Pu(l.prev,l,l.next))l=l.next;else{if(Lu(l),l=s=l.prev,l===l.next)break;a=!0}}while(a||l!==s);return s}function lu(e,s,a,l,c,u,d){if(!e)return;!d&&u&&function(e,s,a,l){let c=e;do{0===c.z&&(c.z=gu(c.x,c.y,s,a,l)),c.prevZ=c.prev,c.nextZ=c.next,c=c.next}while(c!==e);c.prevZ.nextZ=null,c.prevZ=null,function(e){let s,a=1;do{let l,c=e;e=null;let u=null;for(s=0;c;){s++;let d=c,f=0;for(let e=0;e<a&&(f++,d=d.nextZ,d);e++);let _=a;for(;f>0||_>0&&d;)0!==f&&(0===_||!d||c.z<=d.z)?(l=c,c=c.nextZ,f--):(l=d,d=d.nextZ,_--),u?u.nextZ=l:e=l,l.prevZ=u,u=l;c=d}u.nextZ=null,a*=2}while(s>1)}(c)}(e,l,c,u);let f=e;for(;e.prev!==e.next;){const _=e.prev,y=e.next;if(u?hu(e,l,c,u):cu(e))s.push(_.i,e.i,y.i),Lu(e),e=y.next,f=y.next;else if((e=y)===f){d?1===d?lu(e=du(ou(e),s),s,a,l,c,u,2):2===d&&pu(e,s,a,l,c,u):lu(ou(e),s,a,l,c,u,1);break}}}function cu(e){const s=e.prev,a=e,l=e.next;if(Pu(s,a,l)>=0)return!1;const c=s.x,u=a.x,d=l.x,f=s.y,_=a.y,y=l.y,b=Math.min(c,u,d),S=Math.min(f,_,y),P=Math.max(c,u,d),M=Math.max(f,_,y);let C=l.next;for(;C!==s;){if(C.x>=b&&C.x<=P&&C.y>=S&&C.y<=M&&wu(c,f,u,_,d,y,C.x,C.y)&&Pu(C.prev,C,C.next)>=0)return!1;C=C.next}return!0}function hu(e,s,a,l){const c=e.prev,u=e,d=e.next;if(Pu(c,u,d)>=0)return!1;const f=c.x,_=u.x,y=d.x,b=c.y,S=u.y,P=d.y,M=Math.min(f,_,y),C=Math.min(b,S,P),D=Math.max(f,_,y),L=Math.max(b,S,P),F=gu(M,C,s,a,l),B=gu(D,L,s,a,l);let O=e.prevZ,V=e.nextZ;for(;O&&O.z>=F&&V&&V.z<=B;){if(O.x>=M&&O.x<=D&&O.y>=C&&O.y<=L&&O!==c&&O!==d&&wu(f,b,_,S,y,P,O.x,O.y)&&Pu(O.prev,O,O.next)>=0)return!1;if(O=O.prevZ,V.x>=M&&V.x<=D&&V.y>=C&&V.y<=L&&V!==c&&V!==d&&wu(f,b,_,S,y,P,V.x,V.y)&&Pu(V.prev,V,V.next)>=0)return!1;V=V.nextZ}for(;O&&O.z>=F;){if(O.x>=M&&O.x<=D&&O.y>=C&&O.y<=L&&O!==c&&O!==d&&wu(f,b,_,S,y,P,O.x,O.y)&&Pu(O.prev,O,O.next)>=0)return!1;O=O.prevZ}for(;V&&V.z<=B;){if(V.x>=M&&V.x<=D&&V.y>=C&&V.y<=L&&V!==c&&V!==d&&wu(f,b,_,S,y,P,V.x,V.y)&&Pu(V.prev,V,V.next)>=0)return!1;V=V.nextZ}return!0}function du(e,s){let a=e;do{const l=a.prev,c=a.next.next;!Mu(l,c)&&Cu(l,a,a.next,c)&&zu(l,c)&&zu(c,l)&&(s.push(l.i,a.i,c.i),Lu(a),Lu(a.next),a=e=c),a=a.next}while(a!==e);return ou(a)}function pu(e,s,a,l,c,u){let d=e;do{let e=d.next.next;for(;e!==d.prev;){if(d.i!==e.i&&Tu(d,e)){let f=ku(d,e);return d=ou(d,d.next),f=ou(f,f.next),lu(d,s,a,l,c,u,0),void lu(f,s,a,l,c,u,0)}e=e.next}d=d.next}while(d!==e)}function fu(e,s){let a=e.x-s.x;return 0===a&&(a=e.y-s.y,0===a)&&(a=(e.next.y-e.y)/(e.next.x-e.x)-(s.next.y-s.y)/(s.next.x-s.x)),a}function mu(e,s){const a=function(e,s){let a=s;const l=e.x,c=e.y;let u,d=-1/0;if(Mu(e,a))return a;do{if(Mu(e,a.next))return a.next;if(c<=a.y&&c>=a.next.y&&a.next.y!==a.y){const e=a.x+(c-a.y)*(a.next.x-a.x)/(a.next.y-a.y);if(e<=l&&e>d&&(d=e,u=a.x<a.next.x?a:a.next,e===l))return u}a=a.next}while(a!==s);if(!u)return null;const f=u,_=u.x,y=u.y;let b=1/0;a=u;do{if(l>=a.x&&a.x>=_&&l!==a.x&&bu(c<y?l:d,c,_,y,c<y?d:l,c,a.x,a.y)){const s=Math.abs(c-a.y)/(l-a.x);zu(a,e)&&(s<b||s===b&&(a.x>u.x||a.x===u.x&&_u(u,a)))&&(u=a,b=s)}a=a.next}while(a!==f);return u}(e,s);if(!a)return s;const l=ku(a,e);return ou(l,l.next),ou(a,a.next)}function _u(e,s){return Pu(e.prev,e,s.prev)<0&&Pu(s.next,e,e.next)<0}function gu(e,s,a,l,c){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-a)*c|0)|e<<8))|e<<4))|e<<2))|e<<1))|(s=1431655765&((s=858993459&((s=252645135&((s=16711935&((s=(s-l)*c|0)|s<<8))|s<<4))|s<<2))|s<<1))<<1}function xu(e){let s=e,a=e;do{(s.x<a.x||s.x===a.x&&s.y<a.y)&&(a=s),s=s.next}while(s!==e);return a}function bu(e,s,a,l,c,u,d,f){return(c-d)*(s-f)>=(e-d)*(u-f)&&(e-d)*(l-f)>=(a-d)*(s-f)&&(a-d)*(u-f)>=(c-d)*(l-f)}function wu(e,s,a,l,c,u,d,f){return!(e===d&&s===f)&&bu(e,s,a,l,c,u,d,f)}function Tu(e,s){return e.next.i!==s.i&&e.prev.i!==s.i&&!function(e,s){let a=e;do{if(a.i!==e.i&&a.next.i!==e.i&&a.i!==s.i&&a.next.i!==s.i&&Cu(a,a.next,e,s))return!0;a=a.next}while(a!==e);return!1}(e,s)&&(zu(e,s)&&zu(s,e)&&function(e,s){let a=e,l=!1;const c=(e.x+s.x)/2,u=(e.y+s.y)/2;do{a.y>u!=a.next.y>u&&a.next.y!==a.y&&c<(a.next.x-a.x)*(u-a.y)/(a.next.y-a.y)+a.x&&(l=!l),a=a.next}while(a!==e);return l}(e,s)&&(Pu(e.prev,e,s.prev)||Pu(e,s.prev,s))||Mu(e,s)&&Pu(e.prev,e,e.next)>0&&Pu(s.prev,s,s.next)>0)}function Pu(e,s,a){return(s.y-e.y)*(a.x-s.x)-(s.x-e.x)*(a.y-s.y)}function Mu(e,s){return e.x===s.x&&e.y===s.y}function Cu(e,s,a,l){const c=Du(Pu(e,s,a)),u=Du(Pu(e,s,l)),d=Du(Pu(a,l,e)),f=Du(Pu(a,l,s));return c!==u&&d!==f||!(0!==c||!Au(e,a,s))||!(0!==u||!Au(e,l,s))||!(0!==d||!Au(a,e,l))||!(0!==f||!Au(a,s,l))}function Au(e,s,a){return s.x<=Math.max(e.x,a.x)&&s.x>=Math.min(e.x,a.x)&&s.y<=Math.max(e.y,a.y)&&s.y>=Math.min(e.y,a.y)}function Du(e){return e>0?1:e<0?-1:0}function zu(e,s){return Pu(e.prev,e,e.next)<0?Pu(e,s,e.next)>=0&&Pu(e,e.prev,s)>=0:Pu(e,s,e.prev)<0||Pu(e,e.next,s)<0}function ku(e,s){const a=Fu(e.i,e.x,e.y),l=Fu(s.i,s.x,s.y),c=e.next,u=s.prev;return e.next=s,s.prev=e,a.next=c,c.prev=a,l.next=a,a.prev=l,u.next=l,l.prev=u,l}function Ru(e,s,a,l){const c=Fu(e,s,a);return l?(c.next=l.next,c.prev=l,l.next.prev=c,l.next=c):(c.prev=c,c.next=c),c}function Lu(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Fu(e,s,a){return{i:e,x:s,y:a,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class su{constructor(e,s){if(s>e)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=s}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<<e)),this._minGranularity,1)}}class au{constructor(e){this.fill=e.fill,this.line=e.line,this.tile=e.tile,this.stencil=e.stencil,this.circle=e.circle}}au.noSubdivision=new au({fill:new su(0,0),line:new su(0,0),tile:new su(0,0),stencil:new su(0,0),circle:1}),ql("SubdivisionGranularityExpression",su),ql("SubdivisionGranularitySetting",au);const Vu=-32768,Nu=32767;class uu{constructor(e,s){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=e,this._granularityCellSize=oe/e,this._canonical=s}_getKey(e,s){return(e+=32768)<<16|s+32768}_vertexToIndex(e,s){if(e<-32768||s<-32768||e>32767||s>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const a=0|Math.round(e),l=0|Math.round(s),c=this._getKey(a,l);if(this._vertexDictionary.has(c))return this._vertexDictionary.get(c);const u=this._vertexBuffer.length/2;return this._vertexDictionary.set(c,u),this._vertexBuffer.push(a,l),u}_subdivideTrianglesScanline(e){if(this._granularity<2)return function(e,s){const a=[];for(let l=0;l<s.length;l+=3){const c=s[l],u=s[l+1],d=s[l+2],f=e[2*c],_=e[2*c+1];(e[2*u]-f)*(e[2*d+1]-_)-(e[2*u+1]-_)*(e[2*d]-f)>0?(a.push(c),a.push(d),a.push(u)):(a.push(c),a.push(u),a.push(d))}return a}(this._vertexBuffer,e);const s=[],a=e.length;for(let l=0;l<a;l+=3){const a=[e[l+0],e[l+1],e[l+2]],c=[this._vertexBuffer[2*e[l+0]+0],this._vertexBuffer[2*e[l+0]+1],this._vertexBuffer[2*e[l+1]+0],this._vertexBuffer[2*e[l+1]+1],this._vertexBuffer[2*e[l+2]+0],this._vertexBuffer[2*e[l+2]+1]];let u=1/0,d=1/0,f=-1/0,_=-1/0;for(let e=0;e<3;e++){const s=c[2*e],a=c[2*e+1];u=Math.min(u,s),f=Math.max(f,s),d=Math.min(d,a),_=Math.max(_,a)}if(u===f||d===_)continue;const y=Math.floor(u/this._granularityCellSize),b=Math.ceil(f/this._granularityCellSize),S=Math.floor(d/this._granularityCellSize),P=Math.ceil(_/this._granularityCellSize);if(y!==b||S!==P)for(let e=S;e<P;e++){const l=this._scanlineGenerateVertexRingForCellRow(e,c,a);Gu(this._vertexBuffer,l,s)}else s.push(...a)}return s}_scanlineGenerateVertexRingForCellRow(e,s,a){const l=e*this._granularityCellSize,c=l+this._granularityCellSize,u=[];for(let e=0;e<3;e++){const d=s[2*e],f=s[2*e+1],_=s[2*(e+1)%6],y=s[(2*(e+1)+1)%6],b=s[2*(e+2)%6],S=s[(2*(e+2)+1)%6],P=_-d,M=y-f,C=0===P,D=0===M,L=(l-f)/M,F=(c-f)/M,B=Math.min(L,F),O=Math.max(L,F);if(!D&&(B>=1||O<=0)||D&&(f<l||f>c)){y>=l&&y<=c&&u.push(a[(e+1)%3]);continue}!D&&B>0&&u.push(this._vertexToIndex(d+P*B,f+M*B));const V=d+P*Math.max(B,0),N=d+P*Math.min(O,1);C||this._generateIntraEdgeVertices(u,d,f,_,y,V,N),!D&&O<1&&u.push(this._vertexToIndex(d+P*O,f+M*O)),(D||y>=l&&y<=c)&&u.push(a[(e+1)%3]),!D&&(y<=l||y>=c)&&this._generateInterEdgeVertices(u,d,f,_,y,b,S,N,l,c)}return u}_generateIntraEdgeVertices(e,s,a,l,c,u,d){const f=l-s,_=c-a,y=0===_,b=y?Math.min(s,l):Math.min(u,d),S=y?Math.max(s,l):Math.max(u,d),P=Math.floor(b/this._granularityCellSize)+1,M=Math.ceil(S/this._granularityCellSize)-1;if(y?s<l:u<d)for(let l=P;l<=M;l++){const c=l*this._granularityCellSize;e.push(this._vertexToIndex(c,a+_*(c-s)/f))}else for(let l=M;l>=P;l--){const c=l*this._granularityCellSize;e.push(this._vertexToIndex(c,a+_*(c-s)/f))}}_generateInterEdgeVertices(e,s,a,l,c,u,d,f,_,y){const b=c-a,S=u-l,P=d-c,M=(_-c)/P,C=(y-c)/P,D=Math.min(M,C),L=Math.max(M,C),F=l+S*D;let B=Math.floor(Math.min(F,f)/this._granularityCellSize)+1,O=Math.ceil(Math.max(F,f)/this._granularityCellSize)-1,V=f<F;const N=0===P;if(N&&(d===_||d===y))return;if(N||D>=1||L<=0){const e=a-d,l=u+(s-u)*Math.min((_-d)/e,(y-d)/e);B=Math.floor(Math.min(l,f)/this._granularityCellSize)+1,O=Math.ceil(Math.max(l,f)/this._granularityCellSize)-1,V=f<l}const j=b>0?y:_;if(V)for(let s=B;s<=O;s++)e.push(this._vertexToIndex(s*this._granularityCellSize,j));else for(let s=O;s>=B;s--)e.push(this._vertexToIndex(s*this._granularityCellSize,j))}_generateOutline(e){const s=[];for(const a of e){const e=Uu(a,this._granularity,!0),l=this._pointArrayToIndices(e),c=[];for(let e=1;e<l.length;e++)c.push(l[e-1]),c.push(l[e]);s.push(c)}return s}_handlePoles(e){let s=!1,a=!1;this._canonical&&(0===this._canonical.y&&(s=!0),this._canonical.y===(1<<this._canonical.z)-1&&(a=!0)),(s||a)&&this._fillPoles(e,s,a)}_ensureNoPoleVertices(){const e=this._vertexBuffer;for(let s=0;s<e.length;s+=2){const a=e[s+1];a===Vu&&(e[s+1]=-32767),a===Nu&&(e[s+1]=32766)}}_generatePoleQuad(e,s,a,l,c,u){l>c!=(u===Vu)?(e.push(s),e.push(a),e.push(this._vertexToIndex(l,u)),e.push(a),e.push(this._vertexToIndex(c,u)),e.push(this._vertexToIndex(l,u))):(e.push(a),e.push(s),e.push(this._vertexToIndex(l,u)),e.push(this._vertexToIndex(c,u)),e.push(a),e.push(this._vertexToIndex(l,u)))}_fillPoles(e,s,a){const l=this._vertexBuffer,c=oe,u=e.length;for(let d=2;d<u;d+=3){const u=e[d-2],f=e[d-1],_=e[d],y=l[2*u],b=l[2*u+1],S=l[2*f],P=l[2*f+1],M=l[2*_],C=l[2*_+1];s&&(0===b&&0===P&&this._generatePoleQuad(e,u,f,y,S,Vu),0===P&&0===C&&this._generatePoleQuad(e,f,_,S,M,Vu),0===C&&0===b&&this._generatePoleQuad(e,_,u,M,y,Vu)),a&&(b===c&&P===c&&this._generatePoleQuad(e,u,f,y,S,Nu),P===c&&C===c&&this._generatePoleQuad(e,f,_,S,M,Nu),C===c&&b===c&&this._generatePoleQuad(e,_,u,M,y,Nu))}}_initializeVertices(e){for(let s=0;s<e.length;s+=2)this._vertexToIndex(e[s],e[s+1])}subdividePolygonInternal(e,s){if(this._used)throw new Error("Subdivision: multiple use not allowed.");this._used=!0;const{flattened:a,holeIndices:l}=function(e){const s=[],a=[];for(const l of e)if(0!==l.length){l!==e[0]&&s.push(a.length/2);for(let e=0;e<l.length;e++)a.push(l[e].x),a.push(l[e].y)}return{flattened:a,holeIndices:s}}(e);let c;this._initializeVertices(a);try{const e=function(e,s,a=2){const l=s&&s.length,c=l?s[0]*a:e.length;let u=nu(e,0,c,a,!0);const d=[];if(!u||u.next===u.prev)return d;let f,_,y;if(l&&(u=function(e,s,a,l){const c=[];for(let a=0,u=s.length;a<u;a++){const d=nu(e,s[a]*l,a<u-1?s[a+1]*l:e.length,l,!1);d===d.next&&(d.steiner=!0),c.push(xu(d))}c.sort(fu);for(let e=0;e<c.length;e++)a=mu(c[e],a);return a}(e,s,u,a)),e.length>80*a){f=e[0],_=e[1];let s=f,l=_;for(let u=a;u<c;u+=a){const a=e[u],c=e[u+1];a<f&&(f=a),c<_&&(_=c),a>s&&(s=a),c>l&&(l=c)}y=Math.max(s-f,l-_),y=0!==y?32767/y:0}return lu(u,d,a,f,_,y,0),d}(a,l),s=this._convertIndices(a,e);c=this._subdivideTrianglesScanline(s)}catch(e){console.error(e)}let u=[];return s&&(u=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(c),{verticesFlattened:this._vertexBuffer,indicesTriangles:c,indicesLineList:u}}_convertIndices(e,s){const a=[];for(let l=0;l<s.length;l++)a.push(this._vertexToIndex(e[2*s[l]],e[2*s[l]+1]));return a}_pointArrayToIndices(e){const s=[];for(let a=0;a<e.length;a++){const l=e[a];s.push(this._vertexToIndex(l.x,l.y))}return s}}function ju(e,s,a,l=!0){return new uu(a,s).subdividePolygonInternal(e,l)}function Uu(e,s,a=!1){if(!e||e.length<1)return[];if(e.length<2)return[];const c=e[0],u=e[e.length-1],d=a&&(c.x!==u.x||c.y!==u.y);if(s<2)return d?[...e,e[0]]:[...e];const f=Math.floor(oe/s),_=[];_.push(new l(e[0].x,e[0].y));const y=e.length,b=d?y:y-1;for(let s=0;s<b;s++){const a=e[s],c=s<y-1?e[s+1]:e[0],u=a.x,d=a.y,b=c.x,S=c.y,P=u!==b,M=d!==S;if(!P&&!M)continue;const C=b-u,D=S-d,L=Math.abs(C),F=Math.abs(D);let B=u,O=d;for(;;){const e=C>0?(Math.floor(B/f)+1)*f:(Math.ceil(B/f)-1)*f,s=D>0?(Math.floor(O/f)+1)*f:(Math.ceil(O/f)-1)*f,a=Math.abs(B-e),c=Math.abs(O-s),u=Math.abs(B-b),d=Math.abs(O-S),y=P?a/L:Number.POSITIVE_INFINITY,V=M?c/F:Number.POSITIVE_INFINITY;if((u<=a||!P)&&(d<=c||!M))break;if(y<V&&P||!M){B=e,O+=D*y;const s=new l(B,Math.round(O));_[_.length-1].x===s.x&&_[_.length-1].y===s.y||_.push(s)}else{B+=C*V,O=s;const e=new l(Math.round(B),O);_[_.length-1].x===e.x&&_[_.length-1].y===e.y||_.push(e)}}const V=new l(b,S);_[_.length-1].x===V.x&&_[_.length-1].y===V.y||_.push(V)}return _}function Gu(e,s,a){if(0===s.length)throw new Error("Subdivision vertex ring is empty.");let l=0,c=e[2*s[0]];for(let a=1;a<s.length;a++){const u=e[2*s[a]];u<c&&(c=u,l=a)}const u=s.length;let d=l,f=(d+1)%u;for(;;){const l=d-1>=0?d-1:u-1,c=(f+1)%u,_=e[2*s[l]],y=e[2*s[c]],b=e[2*s[d]],S=e[2*s[d]+1],P=e[2*s[f]+1];let M=!1;if(_<y)M=!0;else if(_>y)M=!1;else{const a=P-S,u=-(e[2*s[f]]-b),d=S<P?1:-1;((_-b)*a+(e[2*s[l]+1]-S)*u)*d>((y-b)*a+(e[2*s[c]+1]-S)*u)*d&&(M=!0)}if(M){const e=s[l],c=s[d],_=s[f];e!==c&&e!==_&&c!==_&&a.push(_,c,e),d--,d<0&&(d=u-1)}else{const e=s[c],l=s[d],_=s[f];e!==l&&e!==_&&l!==_&&a.push(_,l,e),f++,f>=u&&(f=0)}if(l===c)break}}function Zu(e,s,a,l,c,u,d,f,_){const y=c.length/2,b=d&&f&&_;if(y<Qa.MAX_VERTEX_ARRAY_LENGTH){const S=s.prepareSegment(y,a,l),P=S.vertexLength;for(let e=0;e<u.length;e+=3)l.emplaceBack(P+u[e],P+u[e+1],P+u[e+2]);let M,C;S.vertexLength+=y,S.primitiveLength+=u.length/3,b&&(C=d.prepareSegment(y,a,f),M=C.vertexLength,C.vertexLength+=y);for(let s=0;s<c.length;s+=2)e(c[s],c[s+1]);if(b)for(let e=0;e<_.length;e++){const s=_[e];for(let e=1;e<s.length;e+=2)f.emplaceBack(M+s[e-1],M+s[e]);C.primitiveLength+=s.length/2}}else!function(e,s,a,l,c,u){const d=[];for(let e=0;e<l.length/2;e++)d.push(-1);const f={count:0};let _=0,y=e.getOrCreateLatestSegment(s,a),b=y.vertexLength;for(let S=2;S<c.length;S+=3){const P=c[S-2],M=c[S-1],C=c[S];let D=d[P]<_,L=d[M]<_,F=d[C]<_;y.vertexLength+((D?1:0)+(L?1:0)+(F?1:0))>Qa.MAX_VERTEX_ARRAY_LENGTH&&(y=e.createNewSegment(s,a),_=f.count,D=!0,L=!0,F=!0,b=0);const B=qu(d,l,u,f,P,D,y),O=qu(d,l,u,f,M,L,y),V=qu(d,l,u,f,C,F,y);a.emplaceBack(b+B-_,b+O-_,b+V-_),y.primitiveLength++}}(s,a,l,c,u,e),b&&function(e,s,a,l,c,u){const d=[];for(let e=0;e<l.length/2;e++)d.push(-1);const f={count:0};let _=0,y=e.getOrCreateLatestSegment(s,a),b=y.vertexLength;for(let S=0;S<c.length;S++){const P=c[S];for(let M=1;M<c[S].length;M+=2){const c=P[M-1],S=P[M];let C=d[c]<_,D=d[S]<_;y.vertexLength+((C?1:0)+(D?1:0))>Qa.MAX_VERTEX_ARRAY_LENGTH&&(y=e.createNewSegment(s,a),_=f.count,C=!0,D=!0,b=0);const L=qu(d,l,u,f,c,C,y),F=qu(d,l,u,f,S,D,y);a.emplaceBack(b+L-_,b+F-_),y.primitiveLength++}}}(d,a,f,c,_,e),s.forceNewSegmentOnNextPrepare(),null==d||d.forceNewSegmentOnNextPrepare()}function qu(e,s,a,l,c,u,d){if(u){const u=l.count;return a(s[2*c],s[2*c+1]),e[c]=l.count,l.count++,d.vertexLength++,u}return e[c]}class yu{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new Oa,this.indexArray=new Ha,this.indexArray2=new Ka,this.programConfigurations=new Do(e.layers,e.zoom),this.segments=new Qa,this.segments2=new Qa,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,s,a){this.hasDependencies=iu("fill",this.layers,s);const l=this.layers[0].layout.get("fill-sort-key"),c=!l.isConstant(),u=[];for(const{feature:d,id:f,index:_,sourceLayerIndex:y}of e){const e=this.layers[0]._featureFilter.needGeometry,b=qc(d,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom),b,a))continue;const S=c?l.evaluate(b,{},a,s.availableImages):void 0,P={id:f,properties:d.properties,type:d.type,sourceLayerIndex:y,index:_,geometry:e?b.geometry:Zc(d),patterns:{},sortKey:S};u.push(P)}c&&u.sort(((e,s)=>e.sortKey-s.sortKey));for(const l of u){const{geometry:c,index:u,sourceLayerIndex:d}=l;if(this.hasDependencies){const e=ru("fill",this.layers,l,{zoom:this.zoom},s);this.patternFeatures.push(e)}else this.addFeature(l,c,u,a,{},s.subdivisionGranularity);s.featureIndex.insert(e[u].feature,c,u,d,this.index)}}update(e,s,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,s,this.stateDependentLayers,{imagePositions:a})}addFeatures(e,s,a){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,s,a,e.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,tu),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,s,a,l,c,u){for(const e of Pn(s,500)){const s=ju(e,l,u.fill.getGranularityForZoomLevel(l.z)),a=this.layoutVertexArray;Zu(((e,s)=>{a.emplaceBack(e,s)}),this.segments,this.layoutVertexArray,this.indexArray,s.verticesFlattened,s.indicesTriangles,this.segments2,this.indexArray2,s.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,{imagePositions:c,canonical:l})}}let $u,Wu;ql("FillBucket",yu,{omit:["layers","patternFeatures"]});var Hu={get paint(){return Wu=Wu||new qs({"fill-antialias":new Os(pt.paint_fill["fill-antialias"]),"fill-opacity":new Rs(pt.paint_fill["fill-opacity"]),"fill-color":new Rs(pt.paint_fill["fill-color"]),"fill-outline-color":new Rs(pt.paint_fill["fill-outline-color"]),"fill-translate":new Os(pt.paint_fill["fill-translate"]),"fill-translate-anchor":new Os(pt.paint_fill["fill-translate-anchor"]),"fill-pattern":new Ns(pt.paint_fill["fill-pattern"])})},get layout(){return $u=$u||new qs({"fill-sort-key":new Rs(pt.layout_fill["fill-sort-key"])})}};class vu extends Gs{constructor(e,s){super(e,Hu,s)}recalculate(e,s){super.recalculate(e,s);const a=this.paint._values["fill-outline-color"];"constant"===a.value.kind&&void 0===a.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new yu(e)}queryRadius(){return ah(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:s,transform:a,pixelsToTileUnits:l}){return Yc(ch(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-a.bearingInRadians,l),s)}isTileClipped(){return!0}}const Xu=_c([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Ku=_c([{name:"a_centroid",components:2,type:"Int16"}],4),{members:ed}=Xu;class Su{constructor(e,s,a,l,c){this.properties={},this.extent=a,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=l,this._values=c,e.readFields(td,this,s)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const s=e.readVarint()+e.pos,a=[];let c,u=1,d=0,f=0,_=0;for(;e.pos<s;){if(d<=0){const s=e.readVarint();u=7&s,d=s>>3}if(d--,1===u||2===u)f+=e.readSVarint(),_+=e.readSVarint(),1===u&&(c&&a.push(c),c=[]),c&&c.push(new l(f,_));else{if(7!==u)throw new Error(`unknown command ${u}`);c&&c.push(c[0].clone())}}return c&&a.push(c),a}bbox(){const e=this._pbf;e.pos=this._geometry;const s=e.readVarint()+e.pos;let a=1,l=0,c=0,u=0,d=1/0,f=-1/0,_=1/0,y=-1/0;for(;e.pos<s;){if(l<=0){const s=e.readVarint();a=7&s,l=s>>3}if(l--,1===a||2===a)c+=e.readSVarint(),u+=e.readSVarint(),c<d&&(d=c),c>f&&(f=c),u<_&&(_=u),u>y&&(y=u);else if(7!==a)throw new Error(`unknown command ${a}`)}return[d,_,f,y]}toGeoJSON(e,s,a){const l=this.extent*Math.pow(2,a),c=this.extent*e,u=this.extent*s,d=this.loadGeometry();function f(e){return[360*(e.x+c)/l-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+u)/l)*Math.PI))-90]}function _(e){return e.map(f)}let y;if(1===this.type){const e=[];for(const s of d)e.push(s[0]);const s=_(e);y=1===e.length?{type:"Point",coordinates:s[0]}:{type:"MultiPoint",coordinates:s}}else if(2===this.type){const e=d.map(_);y=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e}}else{if(3!==this.type)throw new Error("unknown feature type");{const e=function(e){const s=e.length;if(s<=1)return[e];const a=[];let l,c;for(let u=0;u<s;u++){const s=id(e[u]);0!==s&&(void 0===c&&(c=s<0),c===s<0?(l&&a.push(l),l=[e[u]]):l&&l.push(e[u]))}return l&&a.push(l),a}(d),s=[];for(const a of e)s.push(a.map(_));y=1===s.length?{type:"Polygon",coordinates:s[0]}:{type:"MultiPolygon",coordinates:s}}}const b={type:"Feature",geometry:y,properties:this.properties};return null!=this.id&&(b.id=this.id),b}}function td(e,s,a){1===e?s.id=a.readVarint():2===e?function(e,s){const a=e.readVarint()+e.pos;for(;e.pos<a;){const a=s._keys[e.readVarint()],l=s._values[e.readVarint()];s.properties[a]=l}}(a,s):3===e?s.type=a.readVarint():4===e&&(s._geometry=a.pos)}function id(e){let s=0;for(let a,l,c=0,u=e.length,d=u-1;c<u;d=c++)a=e[c],l=e[d],s+=(l.x-a.x)*(a.y+l.y);return s}Su.types=["Unknown","Point","LineString","Polygon"];class Iu{constructor(e,s){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(rd,this,s),this.length=this._features.length}feature(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const s=this._pbf.readVarint()+this._pbf.pos;return new Su(this._pbf,s,this.extent,this._keys,this._values)}}function rd(e,s,a){15===e?s.version=a.readVarint():1===e?s.name=a.readString():5===e?s.extent=a.readVarint():2===e?s._features.push(a.pos):3===e?s._keys.push(a.readString()):4===e&&s._values.push(function(e){let s=null;const a=e.readVarint()+e.pos;for(;e.pos<a;){const a=e.readVarint()>>3;s=1===a?e.readString():2===a?e.readFloat():3===a?e.readDouble():4===a?e.readVarint64():5===a?e.readVarint():6===a?e.readSVarint():7===a?e.readBoolean():null}if(null==s)throw new Error("unknown feature value");return s}(a))}class Eu{constructor(e,s){this.layers=e.readFields(sd,{},s)}}function sd(e,s,a){if(3===e){const e=new Iu(a,a.readVarint()+a.pos);e.length&&(s[e.name]=e)}}const od=Math.pow(2,13);function ad(e,s,a,l,c,u,d,f){e.emplaceBack(s,a,2*Math.floor(l*od)+d,c*od*2,u*od*2,Math.round(f))}class Bu{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new Ra,this.centroidVertexArray=new Ca,this.indexArray=new Ha,this.programConfigurations=new Do(e.layers,e.zoom),this.segments=new Qa,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,s,a){this.features=[],this.hasDependencies=iu("fill-extrusion",this.layers,s);for(const{feature:l,id:c,index:u,sourceLayerIndex:d}of e){const e=this.layers[0]._featureFilter.needGeometry,f=qc(l,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom),f,a))continue;const _={id:c,sourceLayerIndex:d,index:u,geometry:e?f.geometry:Zc(l),properties:l.properties,type:l.type,patterns:{}};this.hasDependencies?this.features.push(ru("fill-extrusion",this.layers,_,{zoom:this.zoom},s)):this.addFeature(_,_.geometry,u,a,{},s.subdivisionGranularity),s.featureIndex.insert(l,_.geometry,u,d,this.index,!0)}}addFeatures(e,s,a){for(const l of this.features){const{geometry:c}=l;this.addFeature(l,c,l.index,s,a,e.subdivisionGranularity)}}update(e,s,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,s,this.stateDependentLayers,{imagePositions:a})}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ed),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Ku.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,s,a,l,c,u){for(const a of Pn(s,500)){const s={x:0,y:0,sampleCount:0},c=this.layoutVertexArray.length;this.processPolygon(s,l,e,a,u);const d=this.layoutVertexArray.length-c,f=Math.floor(s.x/s.sampleCount),_=Math.floor(s.y/s.sampleCount);for(let e=0;e<d;e++)this.centroidVertexArray.emplaceBack(f,_)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,{imagePositions:c,canonical:l})}processPolygon(e,s,a,l,c){if(l.length<1)return;if(hd(l[0]))return;for(const s of l)0!==s.length&&ld(e,s);const u={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},d=c.fill.getGranularityForZoomLevel(s.z),f="Polygon"===Su.types[a.type];for(const e of l){if(0===e.length)continue;if(hd(e))continue;const s=Uu(e,d,f);this._generateSideFaces(s,u)}if(!f)return;const _=ju(l,s,d,!1),y=this.layoutVertexArray;Zu(((e,s)=>{ad(y,e,s,0,0,1,1,0)}),this.segments,this.layoutVertexArray,this.indexArray,_.verticesFlattened,_.indicesTriangles)}_generateSideFaces(e,s){let a=0;for(let l=1;l<e.length;l++){const c=e[l],u=e[l-1];if(cd(c,u))continue;s.segment.vertexLength+4>Qa.MAX_VERTEX_ARRAY_LENGTH&&(s.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const d=c.sub(u)._perp()._unit(),f=u.dist(c);a+f>32768&&(a=0),ad(this.layoutVertexArray,c.x,c.y,d.x,d.y,0,0,a),ad(this.layoutVertexArray,c.x,c.y,d.x,d.y,0,1,a),a+=f,ad(this.layoutVertexArray,u.x,u.y,d.x,d.y,0,0,a),ad(this.layoutVertexArray,u.x,u.y,d.x,d.y,0,1,a);const _=s.segment.vertexLength;this.indexArray.emplaceBack(_,_+2,_+1),this.indexArray.emplaceBack(_+1,_+2,_+3),s.segment.vertexLength+=4,s.segment.primitiveLength+=2}}}function ld(e,s){for(let a=0;a<s.length;a++){const l=s[a];a===s.length-1&&s[0].x===l.x&&s[0].y===l.y||(e.x+=l.x,e.y+=l.y,e.sampleCount++)}}function cd(e,s){return e.x===s.x&&(e.x<0||e.x>oe)||e.y===s.y&&(e.y<0||e.y>oe)}function hd(e){return e.every((e=>e.x<0))||e.every((e=>e.x>oe))||e.every((e=>e.y<0))||e.every((e=>e.y>oe))}let ud;ql("FillExtrusionBucket",Bu,{omit:["layers","features"]});var dd={get paint(){return ud=ud||new qs({"fill-extrusion-opacity":new Os(pt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Rs(pt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Os(pt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Os(pt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Ns(pt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Rs(pt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Rs(pt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Os(pt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Ou extends Gs{constructor(e,s){super(e,dd,s)}createBucket(e){return new Bu(e)}queryRadius(){return ah(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:s,featureState:a,geometry:c,transform:u,pixelsToTileUnits:d,pixelPosMatrix:f}){const _=ch(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-u.bearingInRadians,d),y=this.paint.get("fill-extrusion-height").evaluate(s,a),b=this.paint.get("fill-extrusion-base").evaluate(s,a),S=function(e,s){const a=[];for(const c of e){const e=[c.x,c.y,0,1];q(e,e,s),a.push(new l(e[0]/e[3],e[1]/e[3]))}return a}(_,f),P=function(e,s,a,c){const u=[],d=[],f=c[8]*s,_=c[9]*s,y=c[10]*s,b=c[11]*s,S=c[8]*a,P=c[9]*a,M=c[10]*a,C=c[11]*a;for(const s of e){const e=[],a=[];for(const u of s){const s=u.x,d=u.y,D=c[0]*s+c[4]*d+c[12],L=c[1]*s+c[5]*d+c[13],F=c[2]*s+c[6]*d+c[14],B=c[3]*s+c[7]*d+c[15],O=F+y,V=B+b,N=D+S,j=L+P,G=F+M,Z=B+C,q=new l((D+f)/V,(L+_)/V);q.z=O/V,e.push(q);const W=new l(N/Z,j/Z);W.z=G/Z,a.push(W)}u.push(e),d.push(a)}return[u,d]}(c,b,y,f);return function(e,s,a){let l=1/0;Yc(a,s)&&(l=fd(a,s[0]));for(let c=0;c<s.length;c++){const u=s[c],d=e[c];for(let e=0;e<u.length-1;e++){const s=u[e],c=[s,u[e+1],d[e+1],d[e],s];Hc(a,c)&&(l=Math.min(l,fd(a,c)))}}return l!==1/0&&l}(P[0],P[1],S)}}function pd(e,s){return e.x*s.x+e.y*s.y}function fd(e,s){if(1===e.length){let a=0;const l=s[a++];let c;for(;!c||l.equals(c);)if(c=s[a++],!c)return 1/0;for(;a<s.length;a++){const u=s[a],d=e[0],f=c.sub(l),_=u.sub(l),y=d.sub(l),b=pd(f,f),S=pd(f,_),P=pd(_,_),M=pd(y,f),C=pd(y,_),D=b*P-S*S,L=(P*M-S*C)/D,F=(b*C-S*M)/D,B=l.z*(1-L-F)+c.z*L+u.z*F;if(isFinite(B))return B}return 1/0}{let e=1/0;for(const a of s)e=Math.min(e,a.z);return e}}const md=_c([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:_d}=md,gd=_c([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:yd}=gd,xd=Math.cos(Math.PI/180*37.5),vd=Math.pow(2,14)/.5;class Yu{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((e=>{this.gradients[e.id]={}})),this.layoutVertexArray=new Na,this.layoutVertexArray2=new $a,this.indexArray=new Ha,this.programConfigurations=new Do(e.layers,e.zoom),this.segments=new Qa,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,s,a){this.hasDependencies=iu("line",this.layers,s)||this.hasLineDasharray(this.layers);const l=this.layers[0].layout.get("line-sort-key"),c=!l.isConstant(),u=[];for(const{feature:s,id:d,index:f,sourceLayerIndex:_}of e){const e=this.layers[0]._featureFilter.needGeometry,y=qc(s,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom),y,a))continue;const b=c?l.evaluate(y,{},a):void 0,S={id:d,properties:s.properties,type:s.type,sourceLayerIndex:_,index:f,geometry:e?y.geometry:Zc(s),patterns:{},dashes:{},sortKey:b};u.push(S)}c&&u.sort(((e,s)=>e.sortKey-s.sortKey));for(const l of u){const{geometry:c,index:u,sourceLayerIndex:d}=l;this.hasDependencies?(iu("line",this.layers,s)?ru("line",this.layers,l,{zoom:this.zoom},s):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,l,this.zoom,s),this.patternFeatures.push(l)):this.addFeature(l,c,u,a,{},{},s.subdivisionGranularity),s.featureIndex.insert(e[u].feature,c,u,d,this.index)}}update(e,s,a,l){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,s,this.stateDependentLayers,{imagePositions:a,dashPositions:l})}addFeatures(e,s,a,l){for(const c of this.patternFeatures)this.addFeature(c,c.geometry,c.index,s,a,l,e.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,yd)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,_d),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,s,a,l,c,u,d){const f=this.layers[0].layout,_=f.get("line-join").evaluate(e,{}),y=f.get("line-cap"),b=f.get("line-miter-limit"),S=f.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const a of s)this.addLine(a,e,_,y,b,S,l,d);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,a,{imagePositions:c,dashPositions:u,canonical:l})}addLine(e,s,a,l,c,u,d,f){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=Uu(e,d?f.line.getGranularityForZoomLevel(d.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let s=0;s<e.length-1;s++)this.totalDistance+=e[s].dist(e[s+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const _="Polygon"===Su.types[s.type];let y=e.length;for(;y>=2&&e[y-1].equals(e[y-2]);)y--;let b=0;for(;b<y-1&&e[b].equals(e[b+1]);)b++;if(y<(_?3:2))return;"bevel"===a&&(c=1.05);const S=this.overscaling<=16?122880/(512*this.overscaling):0,P=this.segments.prepareSegment(10*y,this.layoutVertexArray,this.indexArray);let M,C,D,L,F;this.e1=this.e2=-1,_&&(M=e[y-2],F=e[b].sub(M)._unit()._perp());for(let s=b;s<y;s++){if(D=s===y-1?_?e[b+1]:void 0:e[s+1],D&&e[s].equals(D))continue;F&&(L=F),M&&(C=M),M=e[s],F=D?D.sub(M)._unit()._perp():L,L=L||F;let d=L.add(F);0===d.x&&0===d.y||d._unit();const f=L.x*F.x+L.y*F.y,B=d.x*F.x+d.y*F.y,O=0!==B?1/B:1/0,V=2*Math.sqrt(2-2*B),N=B<xd&&C&&D,j=L.x*F.y-L.y*F.x>0;if(N&&s>b){const e=M.dist(C);if(e>2*S){const s=M.sub(M.sub(C)._mult(S/e)._round());this.updateDistance(C,s),this.addCurrentVertex(s,L,0,0,P),C=s}}const G=C&&D;let Z=G?a:_?"butt":l;if(G&&"round"===Z&&(O<u?Z="miter":O<=2&&(Z="fakeround")),"miter"===Z&&O>c&&(Z="bevel"),"bevel"===Z&&(O>2&&(Z="flipbevel"),O<c&&(Z="miter")),C&&this.updateDistance(C,M),"miter"===Z)d._mult(O),this.addCurrentVertex(M,d,0,0,P);else if("flipbevel"===Z){if(O>100)d=F.mult(-1);else{const e=O*L.add(F).mag()/L.sub(F).mag();d._perp()._mult(e*(j?-1:1))}this.addCurrentVertex(M,d,0,0,P),this.addCurrentVertex(M,d.mult(-1),0,0,P)}else if("bevel"===Z||"fakeround"===Z){const e=-Math.sqrt(O*O-1),s=j?e:0,a=j?0:e;if(C&&this.addCurrentVertex(M,L,s,a,P),"fakeround"===Z){const e=Math.round(180*V/Math.PI/20);for(let s=1;s<e;s++){let a=s/e;if(.5!==a){const e=a-.5;a+=a*e*(a-1)*((1.0904+f*(f*(3.55645-1.43519*f)-3.2452))*e*e+(.848013+f*(.215638*f-1.06021)))}const l=F.sub(L)._mult(a)._add(L)._unit()._mult(j?-1:1);this.addHalfVertex(M,l.x,l.y,!1,j,0,P)}}D&&this.addCurrentVertex(M,F,-s,-a,P)}else if("butt"===Z)this.addCurrentVertex(M,d,0,0,P);else if("square"===Z){const e=C?1:-1;this.addCurrentVertex(M,d,e,e,P)}else"round"===Z&&(C&&(this.addCurrentVertex(M,L,0,0,P),this.addCurrentVertex(M,L,1,1,P,!0)),D&&(this.addCurrentVertex(M,F,-1,-1,P,!0),this.addCurrentVertex(M,F,0,0,P)));if(N&&s<y-1){const e=M.dist(D);if(e>2*S){const s=M.add(D.sub(M)._mult(S/e)._round());this.updateDistance(M,s),this.addCurrentVertex(s,F,0,0,P),M=s}}}}addCurrentVertex(e,s,a,l,c,u=!1){const d=s.y*l-s.x,f=-s.y-s.x*l;this.addHalfVertex(e,s.x+s.y*a,s.y-s.x*a,u,!1,a,c),this.addHalfVertex(e,d,f,u,!0,-l,c),this.distance>vd/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,s,a,l,c,u))}addHalfVertex({x:e,y:s},a,l,c,u,d,f){const _=.5*(this.lineClips?this.scaledDistance*(vd-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(c?1:0),(s<<1)+(u?1:0),Math.round(63*a)+128,Math.round(63*l)+128,1+(0===d?0:d<0?-1:1)|(63&_)<<2,_>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const y=f.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,y,this.e2),f.primitiveLength++),u?this.e2=y:this.e1=y}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,s){this.distance+=e.dist(s),this.updateScaledDistance()}hasLineDasharray(e){for(const s of e){const e=s.paint.get("line-dasharray");if(e&&!e.isConstant())return!0}return!1}addLineDashDependencies(e,s,a,l){for(const c of e){const e=c.paint.get("line-dasharray");if(!e||"constant"===e.value.kind)continue;const u="round"===c.layout.get("line-cap"),d={dasharray:e.value.evaluate({zoom:a-1},s,{}),round:u},f={dasharray:e.value.evaluate({zoom:a},s,{}),round:u},_={dasharray:e.value.evaluate({zoom:a+1},s,{}),round:u},y=`${d.dasharray.join(",")},${d.round}`,b=`${f.dasharray.join(",")},${f.round}`,S=`${_.dasharray.join(",")},${_.round}`;l.dashDependencies[y]=d,l.dashDependencies[b]=f,l.dashDependencies[S]=_,s.dashes[c.id]={min:y,mid:b,max:S}}}}let bd,wd;ql("LineBucket",Yu,{omit:["layers","patternFeatures"]});var Td={get paint(){return wd=wd||new qs({"line-opacity":new Rs(pt.paint_line["line-opacity"]),"line-color":new Rs(pt.paint_line["line-color"]),"line-translate":new Os(pt.paint_line["line-translate"]),"line-translate-anchor":new Os(pt.paint_line["line-translate-anchor"]),"line-width":new Rs(pt.paint_line["line-width"]),"line-gap-width":new Rs(pt.paint_line["line-gap-width"]),"line-offset":new Rs(pt.paint_line["line-offset"]),"line-blur":new Rs(pt.paint_line["line-blur"]),"line-dasharray":new Ns(pt.paint_line["line-dasharray"]),"line-pattern":new Ns(pt.paint_line["line-pattern"]),"line-gradient":new Us(pt.paint_line["line-gradient"])})},get layout(){return bd=bd||new qs({"line-cap":new Os(pt.layout_line["line-cap"]),"line-join":new Rs(pt.layout_line["line-join"]),"line-miter-limit":new Os(pt.layout_line["line-miter-limit"]),"line-round-limit":new Os(pt.layout_line["line-round-limit"]),"line-sort-key":new Rs(pt.layout_line["line-sort-key"])})}};class Ju extends Rs{possiblyEvaluate(e,s){return s=new Es(Math.floor(s.zoom),{now:s.now,fadeDuration:s.fadeDuration,zoomHistory:s.zoomHistory,transition:s.transition}),super.possiblyEvaluate(e,s)}evaluate(e,s,a,l){return s=Se({},s,{zoom:Math.floor(s.zoom)}),super.evaluate(e,s,a,l)}}let Sd;class Qu extends Gs{constructor(e,s){super(e,Td,s),this.gradientVersion=0,Sd||(Sd=new Ju(Td.paint.properties["line-width"].specification),Sd.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this.gradientExpression();this.stepInterpolant=!!function(e){return void 0!==e._styleExpression}(e)&&e._styleExpression.expression instanceof ar,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,s){super.recalculate(e,s),this.paint._values["line-floorwidth"]=Sd.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Yu(e)}queryRadius(e){const s=e,a=Pd(sh("line-width",this,s),sh("line-gap-width",this,s)),l=sh("line-offset",this,s);return a/2+Math.abs(l)+ah(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:s,featureState:a,geometry:c,transform:u,pixelsToTileUnits:d}){const f=ch(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-u.bearingInRadians,d),_=d/2*Pd(this.paint.get("line-width").evaluate(s,a),this.paint.get("line-gap-width").evaluate(s,a)),y=this.paint.get("line-offset").evaluate(s,a);return y&&(c=function(e,s){const a=[];for(let c=0;c<e.length;c++){const u=e[c],d=[];for(let e=0;e<u.length;e++){const a=u[e-1],c=u[e],f=u[e+1],_=0===e?new l(0,0):c.sub(a)._unit()._perp(),y=e===u.length-1?new l(0,0):f.sub(c)._unit()._perp(),b=_._add(y)._unit(),S=b.x*y.x+b.y*y.y;0!==S&&b._mult(1/S),d.push(b._mult(s)._add(c))}a.push(d)}return a}(c,y*d)),function(e,s,a){for(let l=0;l<s.length;l++){const c=s[l];if(e.length>=3)for(let s=0;s<c.length;s++)if(rh(e,c[s]))return!0;if(Kc(e,c,a))return!0}return!1}(f,c,_)}isTileClipped(){return!0}}function Pd(e,s){return s>0?s+2*e:e}const Id=_c([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Md=_c([{name:"a_projected_pos",components:3,type:"Float32"}],4);_c([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Ed=_c([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);_c([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Cd=_c([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Ad=_c([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Dd(e,s,a){return e.sections.forEach((e=>{e.text=function(e,s,a){const l=s.layout.get("text-transform").evaluate(a,{});return"uppercase"===l?e=e.toLocaleUpperCase():"lowercase"===l&&(e=e.toLocaleLowerCase()),cc.applyArabicShaping&&(e=cc.applyArabicShaping(e)),e}(e.text,s,a)})),e}_c([{name:"triangle",components:3,type:"Uint16"}]),_c([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{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"}]),_c([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{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",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),_c([{type:"Float32",name:"offsetX"}]),_c([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),_c([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const zd={"!":"︕","#":"",$:"","%":"","&":"","(":"︵",")":"︶","*":"","+":"",",":"︐","-":"︲",".":"・","/":"",":":"︓",";":"︔","<":"︿","=":"",">":"﹀","?":"︖","@":"","[":"﹇","\\":"","]":"﹈","^":"",_:"︳","`":"","{":"︷","|":"―","}":"︸","~":"","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","":"︲","—":"︱","":"﹃","":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","":"︹","":"︺","〖":"︗","〗":"︘","":"︕","":"︵","":"︶","":"︐","":"︲","":"・","":"︓","":"︔","":"︿","":"﹀","":"︖","":"﹇","":"﹈","_":"︳","":"︷","":"―","":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var kd=24;const Rd=4294967296,Ld=1/Rd,Fd="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class pc{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,s,a=this.length){for(;this.pos<a;){const a=this.readVarint(),l=a>>3,c=this.pos;this.type=7&a,e(l,s,this),this.pos===c&&this.skip(a)}return s}readMessage(e,s){return this.readFields(e,s,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Rd;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Rd;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const s=this.buf;let a,l;return l=s[this.pos++],a=127&l,l<128?a:(l=s[this.pos++],a|=(127&l)<<7,l<128?a:(l=s[this.pos++],a|=(127&l)<<14,l<128?a:(l=s[this.pos++],a|=(127&l)<<21,l<128?a:(l=s[this.pos],a|=(15&l)<<28,function(e,s,a){const l=a.buf;let c,u;if(u=l[a.pos++],c=(112&u)>>4,u<128)return Bd(e,c,s);if(u=l[a.pos++],c|=(127&u)<<3,u<128)return Bd(e,c,s);if(u=l[a.pos++],c|=(127&u)<<10,u<128)return Bd(e,c,s);if(u=l[a.pos++],c|=(127&u)<<17,u<128)return Bd(e,c,s);if(u=l[a.pos++],c|=(127&u)<<24,u<128)return Bd(e,c,s);if(u=l[a.pos++],c|=(1&u)<<31,u<128)return Bd(e,c,s);throw new Error("Expected varint not more than 10 bytes")}(a,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return Boolean(this.readVarint())}readString(){const e=this.readVarint()+this.pos,s=this.pos;return this.pos=e,e-s>=12&&Fd?Fd.decode(this.buf.subarray(s,e)):function(e,s,a){let l="",c=s;for(;c<a;){const s=e[c];let u,d,f,_=null,y=s>239?4:s>223?3:s>191?2:1;if(c+y>a)break;1===y?s<128&&(_=s):2===y?(u=e[c+1],128==(192&u)&&(_=(31&s)<<6|63&u,_<=127&&(_=null))):3===y?(u=e[c+1],d=e[c+2],128==(192&u)&&128==(192&d)&&(_=(15&s)<<12|(63&u)<<6|63&d,(_<=2047||_>=55296&&_<=57343)&&(_=null))):4===y&&(u=e[c+1],d=e[c+2],f=e[c+3],128==(192&u)&&128==(192&d)&&128==(192&f)&&(_=(15&s)<<18|(63&u)<<12|(63&d)<<6|63&f,(_<=65535||_>=1114112)&&(_=null))),null===_?(_=65533,y=1):_>65535&&(_-=65536,l+=String.fromCharCode(_>>>10&1023|55296),_=56320|1023&_),l+=String.fromCharCode(_),c+=y}return l}(this.buf,s,e)}readBytes(){const e=this.readVarint()+this.pos,s=this.buf.subarray(this.pos,e);return this.pos=e,s}readPackedVarint(e=[],s){const a=this.readPackedEnd();for(;this.pos<a;)e.push(this.readVarint(s));return e}readPackedSVarint(e=[]){const s=this.readPackedEnd();for(;this.pos<s;)e.push(this.readSVarint());return e}readPackedBoolean(e=[]){const s=this.readPackedEnd();for(;this.pos<s;)e.push(this.readBoolean());return e}readPackedFloat(e=[]){const s=this.readPackedEnd();for(;this.pos<s;)e.push(this.readFloat());return e}readPackedDouble(e=[]){const s=this.readPackedEnd();for(;this.pos<s;)e.push(this.readDouble());return e}readPackedFixed32(e=[]){const s=this.readPackedEnd();for(;this.pos<s;)e.push(this.readFixed32());return e}readPackedSFixed32(e=[]){const s=this.readPackedEnd();for(;this.pos<s;)e.push(this.readSFixed32());return e}readPackedFixed64(e=[]){const s=this.readPackedEnd();for(;this.pos<s;)e.push(this.readFixed64());return e}readPackedSFixed64(e=[]){const s=this.readPackedEnd();for(;this.pos<s;)e.push(this.readSFixed64());return e}readPackedEnd(){return 2===this.type?this.readVarint()+this.pos:this.pos+1}skip(e){const s=7&e;if(0===s)for(;this.buf[this.pos++]>127;);else if(2===s)this.pos=this.readVarint()+this.pos;else if(5===s)this.pos+=4;else{if(1!==s)throw new Error(`Unimplemented type: ${s}`);this.pos+=8}}writeTag(e,s){this.writeVarint(e<<3|s)}realloc(e){let s=this.length||16;for(;s<this.pos+e;)s*=2;if(s!==this.length){const e=new Uint8Array(s);e.set(this.buf),this.buf=e,this.dataView=new DataView(e.buffer),this.length=s}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeSFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,-1&e,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*Ld),!0),this.pos+=8}writeSFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,-1&e,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*Ld),!0),this.pos+=8}writeVarint(e){(e=+e||0)>268435455||e<0?function(e,s){let a,l;if(e>=0?(a=e%4294967296|0,l=e/4294967296|0):(a=~(-e%4294967296),l=~(-e/4294967296),4294967295^a?a=a+1|0:(a=0,l=l+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");s.realloc(10),function(e,s,a){a.buf[a.pos++]=127&e|128,e>>>=7,a.buf[a.pos++]=127&e|128,e>>>=7,a.buf[a.pos++]=127&e|128,e>>>=7,a.buf[a.pos++]=127&e|128,a.buf[a.pos]=127&(e>>>=7)}(a,0,s),function(e,s){const a=(7&e)<<4;s.buf[s.pos++]|=a|((e>>>=3)?128:0),e&&(s.buf[s.pos++]=127&e|((e>>>=7)?128:0),e&&(s.buf[s.pos++]=127&e|((e>>>=7)?128:0),e&&(s.buf[s.pos++]=127&e|((e>>>=7)?128:0),e&&(s.buf[s.pos++]=127&e|((e>>>=7)?128:0),e&&(s.buf[s.pos++]=127&e)))))}(l,s)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))}writeSVarint(e){this.writeVarint(e<0?2*-e-1:2*e)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;const s=this.pos;this.pos=function(e,s,a){for(let l,c,u=0;u<s.length;u++){if(l=s.charCodeAt(u),l>55295&&l<57344){if(!c){l>56319||u+1===s.length?(e[a++]=239,e[a++]=191,e[a++]=189):c=l;continue}if(l<56320){e[a++]=239,e[a++]=191,e[a++]=189,c=l;continue}l=c-55296<<10|l-56320|65536,c=null}else c&&(e[a++]=239,e[a++]=191,e[a++]=189,c=null);l<128?e[a++]=l:(l<2048?e[a++]=l>>6|192:(l<65536?e[a++]=l>>12|224:(e[a++]=l>>18|240,e[a++]=l>>12&63|128),e[a++]=l>>6&63|128),e[a++]=63&l|128)}return a}(this.buf,e,this.pos);const a=this.pos-s;a>=128&&Od(s,a,this),this.pos=s-1,this.writeVarint(a),this.pos+=a}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){const s=e.length;this.writeVarint(s),this.realloc(s);for(let a=0;a<s;a++)this.buf[this.pos++]=e[a]}writeRawMessage(e,s){this.pos++;const a=this.pos;e(s,this);const l=this.pos-a;l>=128&&Od(a,l,this),this.pos=a-1,this.writeVarint(l),this.pos+=l}writeMessage(e,s,a){this.writeTag(e,2),this.writeRawMessage(s,a)}writePackedVarint(e,s){s.length&&this.writeMessage(e,Vd,s)}writePackedSVarint(e,s){s.length&&this.writeMessage(e,Nd,s)}writePackedBoolean(e,s){s.length&&this.writeMessage(e,Gd,s)}writePackedFloat(e,s){s.length&&this.writeMessage(e,jd,s)}writePackedDouble(e,s){s.length&&this.writeMessage(e,Ud,s)}writePackedFixed32(e,s){s.length&&this.writeMessage(e,Zd,s)}writePackedSFixed32(e,s){s.length&&this.writeMessage(e,qd,s)}writePackedFixed64(e,s){s.length&&this.writeMessage(e,$d,s)}writePackedSFixed64(e,s){s.length&&this.writeMessage(e,Wd,s)}writeBytesField(e,s){this.writeTag(e,2),this.writeBytes(s)}writeFixed32Field(e,s){this.writeTag(e,5),this.writeFixed32(s)}writeSFixed32Field(e,s){this.writeTag(e,5),this.writeSFixed32(s)}writeFixed64Field(e,s){this.writeTag(e,1),this.writeFixed64(s)}writeSFixed64Field(e,s){this.writeTag(e,1),this.writeSFixed64(s)}writeVarintField(e,s){this.writeTag(e,0),this.writeVarint(s)}writeSVarintField(e,s){this.writeTag(e,0),this.writeSVarint(s)}writeStringField(e,s){this.writeTag(e,2),this.writeString(s)}writeFloatField(e,s){this.writeTag(e,5),this.writeFloat(s)}writeDoubleField(e,s){this.writeTag(e,1),this.writeDouble(s)}writeBooleanField(e,s){this.writeVarintField(e,+s)}}function Bd(e,s,a){return a?4294967296*s+(e>>>0):4294967296*(s>>>0)+(e>>>0)}function Od(e,s,a){const l=s<=16383?1:s<=2097151?2:s<=268435455?3:Math.floor(Math.log(s)/(7*Math.LN2));a.realloc(l);for(let s=a.pos-1;s>=e;s--)a.buf[s+l]=a.buf[s]}function Vd(e,s){for(let a=0;a<e.length;a++)s.writeVarint(e[a])}function Nd(e,s){for(let a=0;a<e.length;a++)s.writeSVarint(e[a])}function jd(e,s){for(let a=0;a<e.length;a++)s.writeFloat(e[a])}function Ud(e,s){for(let a=0;a<e.length;a++)s.writeDouble(e[a])}function Gd(e,s){for(let a=0;a<e.length;a++)s.writeBoolean(e[a])}function Zd(e,s){for(let a=0;a<e.length;a++)s.writeFixed32(e[a])}function qd(e,s){for(let a=0;a<e.length;a++)s.writeSFixed32(e[a])}function $d(e,s){for(let a=0;a<e.length;a++)s.writeFixed64(e[a])}function Wd(e,s){for(let a=0;a<e.length;a++)s.writeSFixed64(e[a])}function Hd(e,s,a){1===e&&a.readMessage(Xd,s)}function Xd(e,s,a){if(3===e){const{id:e,bitmap:l,width:c,height:u,left:d,top:f,advance:_}=a.readMessage(Yd,{});s.push({id:e,bitmap:new ml({width:c+6,height:u+6},l),metrics:{width:c,height:u,left:d,top:f,advance:_}})}}function Yd(e,s,a){1===e?s.id=a.readVarint():2===e?s.bitmap=a.readBytes():3===e?s.width=a.readVarint():4===e?s.height=a.readVarint():5===e?s.left=a.readSVarint():6===e?s.top=a.readSVarint():7===e&&(s.advance=a.readVarint())}function Kd(e){let s=0,a=0;for(const l of e)s+=l.w*l.h,a=Math.max(a,l.w);e.sort(((e,s)=>s.h-e.h));const l=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(s/.95)),a),h:1/0}];let c=0,u=0;for(const s of e)for(let e=l.length-1;e>=0;e--){const a=l[e];if(!(s.w>a.w||s.h>a.h)){if(s.x=a.x,s.y=a.y,u=Math.max(u,s.y+s.h),c=Math.max(c,s.x+s.w),s.w===a.w&&s.h===a.h){const s=l.pop();s&&e<l.length&&(l[e]=s)}else s.h===a.h?(a.x+=s.w,a.w-=s.w):s.w===a.w?(a.y+=s.h,a.h-=s.h):(l.push({x:a.x+s.w,y:a.y,w:a.w-s.w,h:s.h}),a.y+=s.h,a.h-=s.h);break}}return{w:c,h:u,fill:s/(c*u)||0}}class Ec{constructor(e,{pixelRatio:s,version:a,stretchX:l,stretchY:c,content:u,textFitWidth:d,textFitHeight:f}){this.paddedRect=e,this.pixelRatio=s,this.stretchX=l,this.stretchY=c,this.content=u,this.version=a,this.textFitWidth=d,this.textFitHeight=f}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 tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class kc{constructor(e,s){const a={},l={};this.haveRenderCallbacks=[];const c=[];this.addImages(e,a,c),this.addImages(s,l,c);const{w:u,h:d}=Kd(c),f=new gl({width:u||1,height:d||1});for(const s in e){const l=e[s],c=a[s].paddedRect;gl.copy(l.data,f,{x:0,y:0},{x:c.x+1,y:c.y+1},l.data)}for(const e in s){const a=s[e],c=l[e].paddedRect,u=c.x+1,d=c.y+1,_=a.data.width,y=a.data.height;gl.copy(a.data,f,{x:0,y:0},{x:u,y:d},a.data),gl.copy(a.data,f,{x:0,y:y-1},{x:u,y:d-1},{width:_,height:1}),gl.copy(a.data,f,{x:0,y:0},{x:u,y:d+y},{width:_,height:1}),gl.copy(a.data,f,{x:_-1,y:0},{x:u-1,y:d},{width:1,height:y}),gl.copy(a.data,f,{x:0,y:0},{x:u+_,y:d},{width:1,height:y})}this.image=f,this.iconPositions=a,this.patternPositions=l}addImages(e,s,a){for(const l in e){const c=e[l],u={x:0,y:0,w:c.data.width+2,h:c.data.height+2};a.push(u),s[l]=new Ec(u,c),c.hasRenderCallback&&this.haveRenderCallbacks.push(l)}}patchUpdatedImages(e,s){e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const a in e.updatedImages)this.patchUpdatedImage(this.iconPositions[a],e.getImage(a),s),this.patchUpdatedImage(this.patternPositions[a],e.getImage(a),s)}patchUpdatedImage(e,s,a){if(!e||!s)return;if(e.version===s.version)return;e.version=s.version;const[l,c]=e.tl;a.update(s.data,void 0,{x:l,y:c})}}var Jd;ql("ImagePosition",Ec),ql("ImageAtlas",kc),s.at=void 0,(Jd=s.at||(s.at={}))[Jd.none=0]="none",Jd[Jd.horizontal=1]="horizontal",Jd[Jd.vertical=2]="vertical",Jd[Jd.horizontalOnly=3]="horizontalOnly";class Fc{constructor(){this.scale=1,this.fontStack="",this.imageName=null,this.verticalAlign="bottom"}static forText(e,s,a){const l=new Fc;return l.scale=e||1,l.fontStack=s,l.verticalAlign=a||"bottom",l}static forImage(e,s){const a=new Fc;return a.imageName=e,a.verticalAlign=s||"bottom",a}}class Bc{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,s){const a=new Bc;for(let l=0;l<e.sections.length;l++){const c=e.sections[l];c.image?a.addImageSection(c):a.addTextSection(c,s)}return a}length(){return this.text.length}getSection(e){return this.sections[this.sectionIndex[e]]}getSectionIndex(e){return this.sectionIndex[e]}getCharCode(e){return this.text.charCodeAt(e)}verticalizePunctuation(){this.text=function(e){let s="";for(let a=0;a<e.length;a++){const l=e.charCodeAt(a+1)||null,c=e.charCodeAt(a-1)||null;s+=l&&nc(l)&&!zd[e[a+1]]||c&&nc(c)&&!zd[e[a-1]]||!zd[e[a]]?e[a]:zd[e[a]]}return s}(this.text)}trim(){let e=0;for(let s=0;s<this.text.length&&ep[this.text.charCodeAt(s)];s++)e++;let s=this.text.length;for(let a=this.text.length-1;a>=0&&a>=e&&ep[this.text.charCodeAt(a)];a--)s--;this.text=this.text.substring(e,s),this.sectionIndex=this.sectionIndex.slice(e,s)}substring(e,s){const a=new Bc;return a.text=this.text.substring(e,s),a.sectionIndex=this.sectionIndex.slice(e,s),a.sections=this.sections,a}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((e,s)=>Math.max(e,this.sections[s].scale)),0)}getMaxImageSize(e){let s=0,a=0;for(let l=0;l<this.length();l++){const c=this.getSection(l);if(c.imageName){const l=e[c.imageName];if(!l)continue;const u=l.displaySize;s=Math.max(s,u[0]),a=Math.max(a,u[1])}}return{maxImageWidth:s,maxImageHeight:a}}addTextSection(e,s){this.text+=e.text,this.sections.push(Fc.forText(e.scale,e.fontStack||s,e.verticalAlign));const a=this.sections.length-1;for(let s=0;s<e.text.length;++s)this.sectionIndex.push(a)}addImageSection(e){const s=e.image?e.image.name:"";if(0===s.length)return void Le("Can't add FormattedSection with an empty image.");const a=this.getNextImageSectionCharCode();a?(this.text+=String.fromCharCode(a),this.sections.push(Fc.forImage(s,e.verticalAlign)),this.sectionIndex.push(this.sections.length-1)):Le("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Qd(e,a,l,c,u,d,f,_,y,b,S,P,M,C,D){const L=Bc.fromFeature(e,u);let F;P===s.at.vertical&&L.verticalizePunctuation();const{processBidirectionalText:B,processStyledBidirectionalText:O}=cc;if(B&&1===L.sections.length){F=[];const e=B(L.toString(),cp(L,b,d,a,c,C));for(const s of e){const e=new Bc;e.text=s,e.sections=L.sections;for(let a=0;a<s.length;a++)e.sectionIndex.push(0);F.push(e)}}else if(O){F=[];const e=O(L.text,L.sectionIndex,cp(L,b,d,a,c,C));for(const s of e){const e=new Bc;e.text=s[0],e.sectionIndex=s[1],e.sections=L.sections,F.push(e)}}else F=function(e,s){const a=[],l=e.text;let c=0;for(const l of s)a.push(e.substring(c,l)),c=l;return c<l.length&&a.push(e.substring(c,l.length)),a}(L,cp(L,b,d,a,c,C));const V=[],N={positionedLines:V,text:L.toString(),top:S[1],bottom:S[1],left:S[0],right:S[0],writingMode:P,iconsInText:!1,verticalizable:!1};return function(e,s,a,l,c,u,d,f,_,y,b,S){let P=0,M=0,C=0,D=0;const L="right"===f?1:"left"===f?0:.5,F=kd/S;let B=0;for(const d of c){d.trim();const c=d.getMaxScale(),f={positionedGlyphs:[],lineOffset:0};e.positionedLines[B]=f;const S=f.positionedGlyphs;let O=0;if(!d.length()){M+=u,++B;continue}const V=up(l,d,F);for(let u=0;u<d.length();u++){const f=d.getSection(u),C=d.getSectionIndex(u),D=d.getCharCode(u),L=pp(_,b,D);let B;if(f.imageName){if(e.iconsInText=!0,f.scale=f.scale*F,B=mp(f,L,c,V,l),!B)continue;O=Math.max(O,B.imageOffset)}else if(B=fp(f,D,L,V,s,a),!B)continue;const{rect:N,metrics:j,baselineOffset:G}=B;S.push({glyph:D,imageName:f.imageName,x:P,y:M+G+-17,vertical:L,scale:f.scale,fontStack:f.fontStack,sectionIndex:C,metrics:j,rect:N}),L?(e.verticalizable=!0,P+=(f.imageName?j.advance:kd)*f.scale+y):P+=j.advance*f.scale+y}0!==S.length&&(C=Math.max(P-y,C),gp(S,0,S.length-1,L)),P=0,f.lineOffset=Math.max(O,(c-1)*kd);const N=u*c+O;M+=N,D=Math.max(N,D),++B}const{horizontalAlign:O,verticalAlign:V}=hp(d);(function(e,s,a,l,c,u,d,f,_){const y=(s-a)*c;let b=0;b=u!==d?-f*l- -17:-l*_*d+.5*d;for(const s of e)for(const e of s.positionedGlyphs)e.x+=y,e.y+=b})(e.positionedLines,L,O,V,C,D,u,M,c.length),e.top+=-V*M,e.bottom=e.top+M,e.left+=-O*C,e.right=e.left+C}(N,a,l,c,F,f,_,y,P,b,M,D),!function(e){for(const s of e)if(0!==s.positionedGlyphs.length)return!1;return!0}(V)&&N}const ep={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},tp={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},ip={40:!0};function rp(e,s,a,l,c,u){if(s.imageName){const e=l[s.imageName];return e?e.displaySize[0]*s.scale*kd/u+c:0}{const l=a[s.fontStack],u=l&&l[e];return u?u.metrics.advance*s.scale+c:0}}function np(e,s,a,l){const c=Math.pow(e-s,2);return l?e<s?c/2:2*c:c+Math.abs(a)*a}function sp(e,s,a){let l=0;return 10===e&&(l-=1e4),a&&(l+=150),40!==e&&65288!==e||(l+=50),41!==s&&65289!==s||(l+=50),l}function op(e,s,a,l,c,u){let d=null,f=np(s,a,c,u);for(const e of l){const l=np(s-e.x,a,c,u)+e.badness;l<=f&&(d=e,f=l)}return{index:e,x:s,priorBreak:d,badness:f}}function lp(e){return e?lp(e.priorBreak).concat(e.index):[]}function cp(e,s,a,l,c,u){if(!e)return[];const d=[],f=function(e,s,a,l,c,u){let d=0;for(let a=0;a<e.length();a++){const f=e.getSection(a);d+=rp(e.getCharCode(a),f,l,c,s,u)}return d/Math.max(1,Math.ceil(d/a))}(e,s,a,l,c,u),_=e.text.indexOf("")>=0;let y=0;for(let a=0;a<e.length();a++){const b=e.getSection(a),S=e.getCharCode(a);if(ep[S]||(y+=rp(S,b,l,c,s,u)),a<e.length()-1){const s=Kl(S);(tp[S]||s||b.imageName||a!==e.length()-2&&ip[e.getCharCode(a+1)])&&d.push(op(a+1,y,f,d,sp(S,e.getCharCode(a+1),s&&_),!1))}}return lp(op(e.length(),y,f,d,0,!0))}function hp(e){let s=.5,a=.5;switch(e){case"right":case"top-right":case"bottom-right":s=1;break;case"left":case"top-left":case"bottom-left":s=0}switch(e){case"bottom":case"bottom-right":case"bottom-left":a=1;break;case"top":case"top-right":case"top-left":a=0}return{horizontalAlign:s,verticalAlign:a}}function up(e,s,a){const l=s.getMaxScale()*kd,{maxImageWidth:c,maxImageHeight:u}=s.getMaxImageSize(e),d=Math.max(l,u*a);return{verticalLineContentWidth:Math.max(l,c*a),horizontalLineContentHeight:d}}function dp(e){switch(e){case"top":return 0;case"center":return.5;default:return 1}}function pp(e,a,l){return!(e===s.at.horizontal||!a&&!Jl(l)||a&&(ep[l]||(c=l,/\p{sc=Arab}/u.test(String.fromCodePoint(c)))));var c}function fp(e,s,a,l,c,u){const d=u[e.fontStack],f=function(e,s,a,l){if(e&&e.rect)return e;const c=s[a.fontStack],u=c&&c[l];return u?{rect:null,metrics:u.metrics}:null}(d&&d[s],c,e,s);if(null===f)return null;let _;if(a)_=l.verticalLineContentWidth-e.scale*kd;else{const s=dp(e.verticalAlign);_=(l.horizontalLineContentHeight-e.scale*kd)*s}return{rect:f.rect,metrics:f.metrics,baselineOffset:_}}function mp(e,s,a,l,c){const u=c[e.imageName];if(!u)return null;const d=u.paddedRect,f=u.displaySize,_={width:f[0],height:f[1],left:1,top:-3,advance:s?f[1]:f[0]};let y;if(s)y=l.verticalLineContentWidth-f[1]*e.scale;else{const s=dp(e.verticalAlign);y=(l.horizontalLineContentHeight-f[1]*e.scale)*s}return{rect:d,metrics:_,baselineOffset:y,imageOffset:(s?f[0]:f[1])*e.scale-kd*a}}function gp(e,s,a,l){if(0===l)return;const c=e[a],u=(e[a].x+c.metrics.advance*c.scale)*l;for(let l=s;l<=a;l++)e[l].x-=u}function yp(e,s,a){const{horizontalAlign:l,verticalAlign:c}=hp(a),u=s[0]-e.displaySize[0]*l,d=s[1]-e.displaySize[1]*c;return{image:e,top:d,bottom:d+e.displaySize[1],left:u,right:u+e.displaySize[0]}}function xp(e){var s,a;let l=e.left,c=e.top,u=e.right-l,d=e.bottom-c;const f=null!==(s=e.image.textFitWidth)&&void 0!==s?s:"stretchOrShrink",_=null!==(a=e.image.textFitHeight)&&void 0!==a?a:"stretchOrShrink",y=(e.image.content[2]-e.image.content[0])/(e.image.content[3]-e.image.content[1]);if("proportional"===_){if("stretchOnly"===f&&u/d<y||"proportional"===f){const e=Math.ceil(d*y);l*=e/u,u=e}}else if("proportional"===f&&"stretchOnly"===_&&0!==y&&u/d>y){const e=Math.ceil(u/y);c*=e/d,d=e}return{x1:l,y1:c,x2:l+u,y2:c+d}}function vp(e,s,a,l,c,u){const d=e.image;let f;if(d.content){const e=d.content,s=d.pixelRatio||1;f=[e[0]/s,e[1]/s,d.displaySize[0]-e[2]/s,d.displaySize[1]-e[3]/s]}const _=s.left*u,y=s.right*u;let b,S,P,M;"width"===a||"both"===a?(M=c[0]+_-l[3],S=c[0]+y+l[1]):(M=c[0]+(_+y-d.displaySize[0])/2,S=M+d.displaySize[0]);const C=s.top*u,D=s.bottom*u;return"height"===a||"both"===a?(b=c[1]+C-l[0],P=c[1]+D+l[2]):(b=c[1]+(C+D-d.displaySize[1])/2,P=b+d.displaySize[1]),{image:d,top:b,right:S,bottom:P,left:M,collisionPadding:f}}const Pp=128,Cp=32640;function zp(e,s){const{expression:a}=s;if("constant"===a.kind)return{kind:"constant",layoutSize:a.evaluate(new Es(e+1))};if("source"===a.kind)return{kind:"source"};{const{zoomStops:s,interpolationType:l}=a;let c=0;for(;c<s.length&&s[c]<=e;)c++;c=Math.max(0,c-1);let u=c;for(;u<s.length&&s[u]<e+1;)u++;u=Math.min(s.length-1,u);const d=s[c],f=s[u];return"composite"===a.kind?{kind:"composite",minZoom:d,maxZoom:f,interpolationType:l}:{kind:"camera",minZoom:d,maxZoom:f,minSize:a.evaluate(new Es(d)),maxSize:a.evaluate(new Es(f)),interpolationType:l}}}function Lp(e,s,a){let l="never";const c=e.get(s);return c?l=c:e.get(a)&&(l="always"),l}const Bp=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Op(e,s,a,l,c,u,d,f,_,y,b,S,P){const M=f?Math.min(Cp,Math.round(f[0])):0,C=f?Math.min(Cp,Math.round(f[1])):0;e.emplaceBack(s,a,Math.round(32*l),Math.round(32*c),u,d,(M<<1)+(_?1:0),C,16*y,16*b,256*S,256*P)}function Vp(e,s,a){e.emplaceBack(s.x,s.y,a),e.emplaceBack(s.x,s.y,a),e.emplaceBack(s.x,s.y,a),e.emplaceBack(s.x,s.y,a)}function Gp(e){for(const s of e.sections)if(lc(s.text))return!0;return!1}class oh{constructor(e){this.layoutVertexArray=new ja,this.indexArray=new Ha,this.programConfigurations=e,this.segments=new Qa,this.dynamicLayoutVertexArray=new Ga,this.opacityVertexArray=new Xa,this.hasVisibleVertices=!1,this.placedSymbolArray=new Ma}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(e,s,a,l){this.isEmpty()||(a&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Id.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,s),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Md.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,Bp,!0),this.opacityVertexBuffer.itemSize=1),(a||l)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}ql("SymbolBuffers",oh);class lh{constructor(e,s,a){this.layoutVertexArray=new e,this.layoutAttributes=s,this.indexArray=new a,this.segments=new Qa,this.collisionVertexArray=new Za}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Ed.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}ql("CollisionBuffers",lh);class uh{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const a=this.layers[0]._unevaluatedLayout._values;this.textSizeData=zp(this.zoom,a["text-size"]),this.iconSizeData=zp(this.zoom,a["icon-size"]);const l=this.layers[0].layout,c=l.get("symbol-sort-key"),u=l.get("symbol-z-order");this.canOverlap="never"!==Lp(l,"text-overlap","text-allow-overlap")||"never"!==Lp(l,"icon-overlap","icon-allow-overlap")||l.get("text-ignore-placement")||l.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==u&&!c.isConstant(),this.sortFeaturesByY=("viewport-y"===u||"auto"===u&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===l.get("symbol-placement")&&(this.writingModes=l.get("text-writing-mode").map((e=>s.at[e]))),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.sourceID=e.sourceID}createArrays(){this.text=new oh(new Do(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new oh(new Do(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new Da,this.lineVertexArray=new Fa,this.symbolInstances=new ka,this.textAnchorOffsets=new Pa}calculateGlyphDependencies(e,s,a,l,c){for(let u=0;u<e.length;u++)if(s[e.charCodeAt(u)]=!0,(a||l)&&c){const a=zd[e.charAt(u)];a&&(s[a.charCodeAt(0)]=!0)}}populate(e,a,l){const c=this.layers[0],u=c.layout,d=u.get("text-font"),f=u.get("text-field"),_=u.get("icon-image"),y=("constant"!==f.value.kind||f.value.value instanceof Dt&&!f.value.value.isEmpty()||f.value.value.toString().length>0)&&("constant"!==d.value.kind||d.value.value.length>0),b="constant"!==_.value.kind||!!_.value.value||Object.keys(_.parameters).length>0,S=u.get("symbol-sort-key");if(this.features=[],!y&&!b)return;const P=a.iconDependencies,M=a.glyphDependencies,C=a.availableImages,D=new Es(this.zoom);for(const{feature:a,id:f,index:_,sourceLayerIndex:L}of e){const e=c._featureFilter.needGeometry,F=qc(a,e);if(!c._featureFilter.filter(D,F,l))continue;let B,O;if(e||(F.geometry=Zc(a)),y){const e=c.getValueAndResolveTokens("text-field",F,l,C),s=Dt.factory(e),a=this.hasRTLText=this.hasRTLText||Gp(s);(!a||"unavailable"===cc.getRTLTextPluginStatus()||a&&cc.isParsed())&&(B=Dd(s,c,F))}if(b){const e=c.getValueAndResolveTokens("icon-image",F,l,C);O=e instanceof Lt?e:Lt.fromString(e)}if(!B&&!O)continue;const V=this.sortFeaturesByKey?S.evaluate(F,{},l):void 0;if(this.features.push({id:f,text:B,icon:O,index:_,sourceLayerIndex:L,geometry:F.geometry,properties:a.properties,type:Su.types[a.type],sortKey:V}),O&&(P[O.name]=!0),B){const e=d.evaluate(F,{},l).join(","),a="viewport"!==u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(s.at.vertical)>=0;for(const s of B.sections)if(s.image)P[s.image.name]=!0;else{const l=Ql(B.toString()),c=s.fontStack||e,u=M[c]=M[c]||{};this.calculateGlyphDependencies(s.text,u,a,this.allowVerticalPlacement,l)}}}"line"===u.get("symbol-placement")&&(this.features=function(e){const s={},a={},l=[];let c=0;function u(s){l.push(e[s]),c++}function d(e,s,c){const u=a[e];return delete a[e],a[s]=u,l[u].geometry[0].pop(),l[u].geometry[0]=l[u].geometry[0].concat(c[0]),u}function f(e,a,c){const u=s[a];return delete s[a],s[e]=u,l[u].geometry[0].shift(),l[u].geometry[0]=c[0].concat(l[u].geometry[0]),u}function _(e,s,a){const l=a?s[0][s[0].length-1]:s[0][0];return`${e}:${l.x}:${l.y}`}for(let y=0;y<e.length;y++){const b=e[y],S=b.geometry,P=b.text?b.text.toString():null;if(!P){u(y);continue}const M=_(P,S),C=_(P,S,!0);if(M in a&&C in s&&a[M]!==s[C]){const e=f(M,C,S),c=d(M,C,l[e].geometry);delete s[M],delete a[C],a[_(P,l[c].geometry,!0)]=c,l[e].geometry=null}else M in a?d(M,C,S):C in s?f(M,C,S):(u(y),s[M]=c-1,a[C]=c-1)}return l.filter((e=>e.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((e,s)=>e.sortKey-s.sortKey))}update(e,s,a){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,s,this.layers,{imagePositions:a}),this.icon.programConfigurations.updatePaintArrays(e,s,this.layers,{imagePositions:a}))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,s){const a=this.lineVertexArray.length;if(void 0!==e.segment){let a=e.dist(s[e.segment+1]),l=e.dist(s[e.segment]);const c={};for(let l=e.segment+1;l<s.length;l++)c[l]={x:s[l].x,y:s[l].y,tileUnitDistanceFromAnchor:a},l<s.length-1&&(a+=s[l+1].dist(s[l]));for(let a=e.segment||0;a>=0;a--)c[a]={x:s[a].x,y:s[a].y,tileUnitDistanceFromAnchor:l},a>0&&(l+=s[a-1].dist(s[a]));for(let e=0;e<s.length;e++){const s=c[e];this.lineVertexArray.emplaceBack(s.x,s.y,s.tileUnitDistanceFromAnchor)}}return{lineStartIndex:a,lineLength:this.lineVertexArray.length-a}}addSymbols(e,a,l,c,u,d,f,_,y,b,S,P){const M=e.indexArray,C=e.layoutVertexArray,D=e.segments.prepareSegment(4*a.length,C,M,this.canOverlap?d.sortKey:void 0),L=this.glyphOffsetArray.length,F=D.vertexLength,B=this.allowVerticalPlacement&&f===s.at.vertical?Math.PI/2:0,O=d.text&&d.text.sections;for(let s=0;s<a.length;s++){const{tl:c,tr:u,bl:f,br:y,tex:b,pixelOffsetTL:S,pixelOffsetBR:L,minFontScaleX:F,minFontScaleY:V,glyphOffset:N,isSDF:j,sectionIndex:G}=a[s],Z=D.vertexLength,q=N[1];Op(C,_.x,_.y,c.x,q+c.y,b.x,b.y,l,j,S.x,S.y,F,V),Op(C,_.x,_.y,u.x,q+u.y,b.x+b.w,b.y,l,j,L.x,S.y,F,V),Op(C,_.x,_.y,f.x,q+f.y,b.x,b.y+b.h,l,j,S.x,L.y,F,V),Op(C,_.x,_.y,y.x,q+y.y,b.x+b.w,b.y+b.h,l,j,L.x,L.y,F,V),Vp(e.dynamicLayoutVertexArray,_,B),M.emplaceBack(Z,Z+2,Z+1),M.emplaceBack(Z+1,Z+2,Z+3),D.vertexLength+=4,D.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(N[0]),s!==a.length-1&&G===a[s+1].sectionIndex||e.programConfigurations.populatePaintArrays(C.length,d,d.index,{imagePositions:{},canonical:P,formattedSection:O&&O[G]})}e.placedSymbolArray.emplaceBack(_.x,_.y,L,this.glyphOffsetArray.length-L,F,y,b,_.segment,l?l[0]:0,l?l[1]:0,c[0],c[1],f,0,!1,0,S)}_addCollisionDebugVertex(e,s,a,l,c,u){return s.emplaceBack(0,0),e.emplaceBack(a.x,a.y,l,c,Math.round(u.x),Math.round(u.y))}addCollisionDebugVertices(e,s,a,c,u,d,f){const _=u.segments.prepareSegment(4,u.layoutVertexArray,u.indexArray),y=_.vertexLength,b=u.layoutVertexArray,S=u.collisionVertexArray,P=f.anchorX,M=f.anchorY;this._addCollisionDebugVertex(b,S,d,P,M,new l(e,s)),this._addCollisionDebugVertex(b,S,d,P,M,new l(a,s)),this._addCollisionDebugVertex(b,S,d,P,M,new l(a,c)),this._addCollisionDebugVertex(b,S,d,P,M,new l(e,c)),_.vertexLength+=4;const C=u.indexArray;C.emplaceBack(y,y+1),C.emplaceBack(y+1,y+2),C.emplaceBack(y+2,y+3),C.emplaceBack(y+3,y),_.primitiveLength+=4}addDebugCollisionBoxes(e,s,a,l){for(let c=e;c<s;c++){const e=this.collisionBoxArray.get(c);this.addCollisionDebugVertices(e.x1,e.y1,e.x2,e.y2,l?this.textCollisionBox:this.iconCollisionBox,e.anchorPoint,a)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new lh(Ya,Cd.members,Ka),this.iconCollisionBox=new lh(Ya,Cd.members,Ka);for(let e=0;e<this.symbolInstances.length;e++){const s=this.symbolInstances.get(e);this.addDebugCollisionBoxes(s.textBoxStartIndex,s.textBoxEndIndex,s,!0),this.addDebugCollisionBoxes(s.verticalTextBoxStartIndex,s.verticalTextBoxEndIndex,s,!0),this.addDebugCollisionBoxes(s.iconBoxStartIndex,s.iconBoxEndIndex,s,!1),this.addDebugCollisionBoxes(s.verticalIconBoxStartIndex,s.verticalIconBoxEndIndex,s,!1)}}_deserializeCollisionBoxesForSymbol(e,s,a,l,c,u,d,f,_){const y={};for(let l=s;l<a;l++){const s=e.get(l);y.textBox={x1:s.x1,y1:s.y1,x2:s.x2,y2:s.y2,anchorPointX:s.anchorPointX,anchorPointY:s.anchorPointY},y.textFeatureIndex=s.featureIndex;break}for(let s=l;s<c;s++){const a=e.get(s);y.verticalTextBox={x1:a.x1,y1:a.y1,x2:a.x2,y2:a.y2,anchorPointX:a.anchorPointX,anchorPointY:a.anchorPointY},y.verticalTextFeatureIndex=a.featureIndex;break}for(let s=u;s<d;s++){const a=e.get(s);y.iconBox={x1:a.x1,y1:a.y1,x2:a.x2,y2:a.y2,anchorPointX:a.anchorPointX,anchorPointY:a.anchorPointY},y.iconFeatureIndex=a.featureIndex;break}for(let s=f;s<_;s++){const a=e.get(s);y.verticalIconBox={x1:a.x1,y1:a.y1,x2:a.x2,y2:a.y2,anchorPointX:a.anchorPointX,anchorPointY:a.anchorPointY},y.verticalIconFeatureIndex=a.featureIndex;break}return y}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let s=0;s<this.symbolInstances.length;s++){const a=this.symbolInstances.get(s);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,a.textBoxStartIndex,a.textBoxEndIndex,a.verticalTextBoxStartIndex,a.verticalTextBoxEndIndex,a.iconBoxStartIndex,a.iconBoxEndIndex,a.verticalIconBoxStartIndex,a.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,s){const a=e.placedSymbolArray.get(s),l=a.vertexStartIndex+4*a.numGlyphs;for(let s=a.vertexStartIndex;s<l;s+=4)e.indexArray.emplaceBack(s,s+2,s+1),e.indexArray.emplaceBack(s+1,s+2,s+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const s=Math.sin(e),a=Math.cos(e),l=[],c=[],u=[];for(let e=0;e<this.symbolInstances.length;++e){u.push(e);const d=this.symbolInstances.get(e);l.push(0|Math.round(s*d.anchorX+a*d.anchorY)),c.push(d.featureIndex)}return u.sort(((e,s)=>l[e]-l[s]||c[s]-c[e])),u}addToSortKeyRanges(e,s){const a=this.sortKeyRanges[this.sortKeyRanges.length-1];a&&a.sortKey===s?a.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:s,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const s=this.symbolInstances.get(e);this.featureSortOrder.push(s.featureIndex),[s.rightJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.leftJustifiedTextSymbolIndex].forEach(((e,s,a)=>{e>=0&&a.indexOf(e)===s&&this.addIndicesForPlacedSymbol(this.text,e)})),s.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,s.verticalPlacedTextSymbolIndex),s.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,s.placedIconSymbolIndex),s.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,s.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Wp,Xp;ql("SymbolBucket",uh,{omit:["layers","collisionBoxArray","features","compareText"]}),uh.MAX_GLYPHS=65535,uh.addDynamicAttributes=Vp;var Yp={get paint(){return Xp=Xp||new qs({"icon-opacity":new Rs(pt.paint_symbol["icon-opacity"]),"icon-color":new Rs(pt.paint_symbol["icon-color"]),"icon-halo-color":new Rs(pt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Rs(pt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Rs(pt.paint_symbol["icon-halo-blur"]),"icon-translate":new Os(pt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Os(pt.paint_symbol["icon-translate-anchor"]),"text-opacity":new Rs(pt.paint_symbol["text-opacity"]),"text-color":new Rs(pt.paint_symbol["text-color"],{runtimeType:ui,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Rs(pt.paint_symbol["text-halo-color"]),"text-halo-width":new Rs(pt.paint_symbol["text-halo-width"]),"text-halo-blur":new Rs(pt.paint_symbol["text-halo-blur"]),"text-translate":new Os(pt.paint_symbol["text-translate"]),"text-translate-anchor":new Os(pt.paint_symbol["text-translate-anchor"])})},get layout(){return Wp=Wp||new qs({"symbol-placement":new Os(pt.layout_symbol["symbol-placement"]),"symbol-spacing":new Os(pt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Os(pt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Rs(pt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Os(pt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Os(pt.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Os(pt.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Os(pt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Os(pt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Os(pt.layout_symbol["icon-rotation-alignment"]),"icon-size":new Rs(pt.layout_symbol["icon-size"]),"icon-text-fit":new Os(pt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Os(pt.layout_symbol["icon-text-fit-padding"]),"icon-image":new Rs(pt.layout_symbol["icon-image"]),"icon-rotate":new Rs(pt.layout_symbol["icon-rotate"]),"icon-padding":new Rs(pt.layout_symbol["icon-padding"]),"icon-keep-upright":new Os(pt.layout_symbol["icon-keep-upright"]),"icon-offset":new Rs(pt.layout_symbol["icon-offset"]),"icon-anchor":new Rs(pt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Os(pt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Os(pt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Os(pt.layout_symbol["text-rotation-alignment"]),"text-field":new Rs(pt.layout_symbol["text-field"]),"text-font":new Rs(pt.layout_symbol["text-font"]),"text-size":new Rs(pt.layout_symbol["text-size"]),"text-max-width":new Rs(pt.layout_symbol["text-max-width"]),"text-line-height":new Os(pt.layout_symbol["text-line-height"]),"text-letter-spacing":new Rs(pt.layout_symbol["text-letter-spacing"]),"text-justify":new Rs(pt.layout_symbol["text-justify"]),"text-radial-offset":new Rs(pt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Os(pt.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Rs(pt.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Rs(pt.layout_symbol["text-anchor"]),"text-max-angle":new Os(pt.layout_symbol["text-max-angle"]),"text-writing-mode":new Os(pt.layout_symbol["text-writing-mode"]),"text-rotate":new Rs(pt.layout_symbol["text-rotate"]),"text-padding":new Os(pt.layout_symbol["text-padding"]),"text-keep-upright":new Os(pt.layout_symbol["text-keep-upright"]),"text-transform":new Rs(pt.layout_symbol["text-transform"]),"text-offset":new Rs(pt.layout_symbol["text-offset"]),"text-allow-overlap":new Os(pt.layout_symbol["text-allow-overlap"]),"text-overlap":new Os(pt.layout_symbol["text-overlap"]),"text-ignore-placement":new Os(pt.layout_symbol["text-ignore-placement"]),"text-optional":new Os(pt.layout_symbol["text-optional"])})}};class fh{constructor(e){if(void 0===e.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:oi,this.defaultValue=e}evaluate(e){if(e.formattedSection){const s=this.defaultValue.property.overrides;if(s&&s.hasOverride(e.formattedSection))return s.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ql("FormatSectionOverride",fh,{omit:["defaultValue"]});class dh extends Gs{constructor(e,s){super(e,Yp,s)}recalculate(e,s){if(super.recalculate(e,s),"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"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const e=this.layout.get("text-writing-mode");if(e){const s=[];for(const a of e)s.indexOf(a)<0&&s.push(a);this.layout._values["text-writing-mode"]=s}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,s,a,l){const c=this.layout.get(e).evaluate(s,{},a,l),u=this._unevaluatedLayout._values[e];return u.isDataDriven()||ks(u.value)||!c?c:function(e,s){return s.replace(/{([^{}]+)}/g,((s,a)=>e&&a in e?String(e[a]):""))}(s.properties,c)}createBucket(e){return new uh(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of Yp.paint.overridableProperties){if(!dh.hasPaintOverride(this.layout,e))continue;const s=this.paint.get(e),a=new fh(s),l=new ei(a,s.property.specification);let c=null;c="constant"===s.value.kind||"source"===s.value.kind?new ni("source",l):new ii("composite",l,s.value.zoomStops),this.paint._values[e]=new Cs(s.property,c,s.parameters)}}_handleOverridablePaintPropertyUpdate(e,s,a){return!(!this.layout||s.isDataDriven()||a.isDataDriven())&&dh.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,s){const a=e.get("text-field"),l=Yp.paint.properties[s];let c=!1;const u=e=>{for(const s of e)if(l.overrides&&l.overrides.hasOverride(s))return void(c=!0)};if("constant"===a.value.kind&&a.value.value instanceof Dt)u(a.value.value.sections);else if("source"===a.value.kind||"composite"===a.value.kind){const e=s=>{c||(s instanceof qt&&br(s.value)===_i?u(s.value.sections):s instanceof Mr?u(s.sections):s.eachChild(e))},s=a.value;s._styleExpression&&e(s._styleExpression.expression)}return c}}let Jp;var Qp={get paint(){return Jp=Jp||new qs({"background-color":new Os(pt.paint_background["background-color"]),"background-pattern":new $s(pt.paint_background["background-pattern"]),"background-opacity":new Os(pt.paint_background["background-opacity"])})}};class gh extends Gs{constructor(e,s){super(e,Qp,s)}}class xh extends Gs{constructor(e,s){super(e,{},s),this.onAdd=e=>{this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)},this.onRemove=e=>{this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)},this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class vh{constructor(e){this._methodToThrottle=e,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._methodToThrottle()}),0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const ef={once:!0},tf=6371008.8;class _h{constructor(e,s){if(isNaN(e)||isNaN(s))throw new Error(`Invalid LngLat object: (${e}, ${s})`);if(this.lng=+e,this.lat=+s,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new _h(Te(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const s=Math.PI/180,a=this.lat*s,l=e.lat*s,c=Math.sin(a)*Math.sin(l)+Math.cos(a)*Math.cos(l)*Math.cos((e.lng-this.lng)*s);return tf*Math.acos(Math.min(c,1))}static convert(e){if(e instanceof _h)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new _h(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new _h(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const lf=2*Math.PI*tf;function hf(e){return lf*Math.cos(e*Math.PI/180)}function uf(e){return(180+e)/360}function df(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function pf(e,s){return e/hf(s)}function ff(e){return 360*e-180}function mf(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function _f(e,s){return e*hf(mf(s))}class Fh{constructor(e,s,a=0){this.x=+e,this.y=+s,this.z=+a}static fromLngLat(e,s=0){const a=_h.convert(e);return new Fh(uf(a.lng),df(a.lat),pf(s,a.lat))}toLngLat(){return new _h(ff(this.x),mf(this.y))}toAltitude(){return _f(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/lf*(e=mf(this.y),1/Math.cos(e*Math.PI/180));var e}}function yf(e,s,a){var l=2*Math.PI*6378137/256/Math.pow(2,a);return[e*l-2*Math.PI*6378137/2,s*l-2*Math.PI*6378137/2]}class Ph{constructor(e,s,a){if(!function(e,s,a){return!(e<0||e>25||a<0||a>=Math.pow(2,e)||s<0||s>=Math.pow(2,e))}(e,s,a))throw new Error(`x=${s}, y=${a}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=s,this.y=a,this.key=wf(0,e,e,s,a)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,s,a){const l=(u=this.y,d=this.z,f=yf(256*(c=this.x),256*(u=Math.pow(2,d)-u-1),d),_=yf(256*(c+1),256*(u+1),d),f[0]+","+f[1]+","+_[0]+","+_[1]);var c,u,d,f,_;const y=function(e,s,a){let l,c="";for(let u=e;u>0;u--)l=1<<u-1,c+=(s&l?1:0)+(a&l?2:0);return c}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String("tms"===a?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,s>1?"@2x":"").replace(/{quadkey}/g,y).replace(/{bbox-epsg-3857}/g,l)}isChildOf(e){const s=this.z-e.z;return s>0&&e.x===this.x>>s&&e.y===this.y>>s}getTilePoint(e){const s=Math.pow(2,this.z);return new l((e.x*s-this.x)*oe,(e.y*s-this.y)*oe)}toString(){return`${this.z}/${this.x}/${this.y}`}}class zh{constructor(e,s){this.wrap=e,this.canonical=s,this.key=wf(e,s.z,s.z,s.x,s.y)}}class Vh{constructor(e,s,a,l,c){if(this.terrainRttPosMatrix32f=null,e<a)throw new Error(`overscaledZ should be >= z; overscaledZ = ${e}; z = ${a}`);this.overscaledZ=e,this.wrap=s,this.canonical=new Ph(a,+l,+c),this.key=wf(s,e,a,l,c)}clone(){return new Vh(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const s=this.canonical.z-e;return e>this.canonical.z?new Vh(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Vh(e,this.wrap,e,this.canonical.x>>s,this.canonical.y>>s)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,s){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const a=this.canonical.z-e;return e>this.canonical.z?wf(this.wrap*+s,e,this.canonical.z,this.canonical.x,this.canonical.y):wf(this.wrap*+s,e,e,this.canonical.x>>a,this.canonical.y>>a)}isChildOf(e){if(e.wrap!==this.wrap)return!1;if(this.overscaledZ-e.overscaledZ<=0)return!1;if(0===e.overscaledZ)return this.overscaledZ>0;const s=this.canonical.z-e.canonical.z;return!(s<0)&&e.canonical.x===this.canonical.x>>s&&e.canonical.y===this.canonical.y>>s}children(e){if(this.overscaledZ>=e)return[new Vh(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const s=this.canonical.z+1,a=2*this.canonical.x,l=2*this.canonical.y;return[new Vh(s,this.wrap,s,a,l),new Vh(s,this.wrap,s,a+1,l),new Vh(s,this.wrap,s,a,l+1),new Vh(s,this.wrap,s,a+1,l+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new Vh(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new Vh(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new zh(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(e){return this.canonical.getTilePoint(new Fh(e.x-this.wrap,e.y))}}function wf(e,s,a,l,c){(e*=2)<0&&(e=-1*e-1);const u=1<<a;return(u*u*e+u*c+l).toString(36)+a.toString(36)+s.toString(36)}function Tf(e,s){return s?e.properties[s]:e.id}ql("CanonicalTileID",Ph),ql("OverscaledTileID",Vh,{omit:["terrainRttPosMatrix32f"]});class Oh{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(e){return this.minX=Math.min(this.minX,e.x),this.minY=Math.min(this.minY,e.y),this.maxX=Math.max(this.maxX,e.x),this.maxY=Math.max(this.maxY,e.y),this}expandBy(e){return this.minX-=e,this.minY-=e,this.maxX+=e,this.maxY+=e,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(e){return this.expandBy(-e)}map(e){const s=new Oh;return s.extend(e(new l(this.minX,this.minY))),s.extend(e(new l(this.maxX,this.minY))),s.extend(e(new l(this.minX,this.maxY))),s.extend(e(new l(this.maxX,this.maxY))),s}static fromPoints(e){const s=new Oh;for(const a of e)s.extend(a);return s}contains(e){return e.x>=this.minX&&e.x<=this.maxX&&e.y>=this.minY&&e.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(e){return!this.empty()&&!e.empty()&&e.minX>=this.minX&&e.maxX<=this.maxX&&e.minY>=this.minY&&e.maxY<=this.maxY}intersects(e){return!this.empty()&&!e.empty()&&e.minX<=this.maxX&&e.maxX>=this.minX&&e.minY<=this.maxY&&e.maxY>=this.minY}}class Rh{constructor(e){this._stringToNumber={},this._numberToString=[];for(let s=0;s<e.length;s++){const a=e[s];this._stringToNumber[a]=s,this._numberToString[s]=a}}encode(e){return this._stringToNumber[e]}decode(e){if(e>=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class Nh{constructor(e,s,a,l,c){this.type="Feature",this._vectorTileFeature=e,e._z=s,e._x=a,e._y=l,this.properties=e.properties,this.id=c}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const s in this)"_geometry"!==s&&"_vectorTileFeature"!==s&&(e[s]=this[s]);return e}}class $h{_name;dataBuffer;nullabilityBuffer;_size;constructor(e,s,a){this._name=e,this.dataBuffer=s,"number"==typeof a?this._size=a:(this.nullabilityBuffer=a,this._size=a.size())}getValue(e){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(e)?null:this.getValueFromBuffer(e)}has(e){return this.nullabilityBuffer&&this.nullabilityBuffer.get(e)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}}class Uh extends $h{}class qh extends Uh{getValueFromBuffer(e){return this.dataBuffer[e]}}class jh extends Uh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Gh extends $h{delta;constructor(e,s,a,l){super(e,s,l),this.delta=a}}class Xh extends Gh{constructor(e,s,a,l){super(e,Int32Array.of(s),a,l)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}}class Yh extends $h{constructor(e,s,a){super(e,Int32Array.of(s),a)}getValueFromBuffer(e){return this.dataBuffer[0]}}class Zh{_name;_geometryVector;_idVector;_propertyVectors;_extent;propertyVectorsMap;constructor(e,s,a,l,c=4096){this._name=e,this._geometryVector=s,this._idVector=a,this._propertyVectors=l,this._extent=c}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors}getPropertyVector(e){return this.propertyVectorsMap||(this.propertyVectorsMap=new Map(this._propertyVectors.map((e=>[e.name,e])))),this.propertyVectorsMap.get(e)}*[Symbol.iterator](){const e=this.geometryVector[Symbol.iterator]();let s=0;for(;s<this.numFeatures;){let a;this.idVector&&(a=this.containsMaxSaveIntegerValues(this.idVector)?Number(this.idVector.getValue(s)):this.idVector.getValue(s));const l=e?.next().value,c={};for(const e of this.propertyVectors){if(!e)continue;const a=e.name,l=e.getValue(s);null!==l&&(c[a]=l)}s++,yield{id:a,geometry:l,properties:c}}}get numFeatures(){return this.geometryVector.numGeometries}get extent(){return this._extent}getFeatures(){const e=[],s=this.geometryVector.getGeometries();for(let a=0;a<this.numFeatures;a++){let l;this.idVector&&(l=this.containsMaxSaveIntegerValues(this.idVector)?Number(this.idVector.getValue(a)):this.idVector.getValue(a));const c={coordinates:s[a],type:this.geometryVector.geometryType(a)},u={};for(const e of this.propertyVectors){if(!e)continue;const s=e.name,l=e.getValue(a);null!==l&&(u[s]=l)}e.push({id:l,geometry:c,properties:u})}return e}containsMaxSaveIntegerValues(e){return e instanceof qh||e instanceof Yh&&e instanceof Xh||e instanceof jh}}class Hh{value;constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}increment(){return this.value++}add(e){this.value+=e}}var Sf,Pf,If,Mf,Ef,Cf,Af,Df,zf,Rf;!function(e){e.PRESENT="PRESENT",e.DATA="DATA",e.OFFSET="OFFSET",e.LENGTH="LENGTH"}(Sf||(Sf={}));class ap{_dictionaryType;_offsetType;_lengthType;constructor(e,s,a){this._dictionaryType=e,this._offsetType=s,this._lengthType=a}get dictionaryType(){return this._dictionaryType}get offsetType(){return this._offsetType}get lengthType(){return this._lengthType}}function Lf(e,s,a){const l=new Int32Array(a);let c=0,u=s.get();for(let s=0;s<l.length;s++){let s=e[u++],a=127&s;s<128||(s=e[u++],a|=(127&s)<<7,s<128||(s=e[u++],a|=(127&s)<<14,s<128||(s=e[u++],a|=(127&s)<<21,s<128||(s=e[u++],a|=(15&s)<<28)))),l[c++]=a}return s.set(u),l}function Ff(e,s,a){const l=new BigInt64Array(a);for(let a=0;a<l.length;a++)l[a]=jf(e,s);return l}function Bf(e,s){let a,l;return l=e[s.get()],s.increment(),a=127&l,l<128?a:(l=e[s.get()],s.increment(),a|=(127&l)<<7,l<128?a:(l=e[s.get()],s.increment(),a|=(127&l)<<14,l<128?a:(l=e[s.get()],s.increment(),a|=(127&l)<<21,l<128?a:(l=e[s.get()],a|=(15&l)<<28,function(e,s,a){let l,c;if(c=s[a.get()],a.increment(),l=(112&c)>>4,c<128)return 4294967296*l+(e>>>0);if(c=s[a.get()],a.increment(),l|=(127&c)<<3,c<128)return 4294967296*l+(e>>>0);if(c=s[a.get()],a.increment(),l|=(127&c)<<10,c<128)return 4294967296*l+(e>>>0);if(c=s[a.get()],a.increment(),l|=(127&c)<<17,c<128)return 4294967296*l+(e>>>0);if(c=s[a.get()],a.increment(),l|=(127&c)<<24,c<128)return 4294967296*l+(e>>>0);if(c=s[a.get()],a.increment(),l|=(1&c)<<31,c<128)return 4294967296*l+(e>>>0);throw new Error("Expected varint not more than 10 bytes")}(a,e,s)))))}function Of(e,s,a,l){throw new Error("FastPFor is not implemented yet.")}function Vf(e){return e>>>1^-(1&e)}function Nf(e){return e>>1n^-(1n&e)}function jf(e,s){let a=0n,l=0,c=s.get();for(;c<e.length;){const s=e[c++];if(a|=BigInt(127&s)<<BigInt(l),!(128&s))break;if(l+=7,l>=64)throw new Error("Varint too long")}return s.set(c),a}function Gf(e,s,a){const l=new Int32Array(a);let c=0;for(let a=0;a<s;a++){const u=e[a];l.fill(e[a+s],c,c+u),c+=u}return l}function Zf(e,s,a){const l=new BigInt64Array(a);let c=0;for(let a=0;a<s;a++){const u=Number(e[a]);l.fill(e[a+s],c,c+u),c+=u}return l}function $f(e,s,a){const l=new Float64Array(a);let c=0;for(let a=0;a<s;a++){const u=e[a];l.fill(e[a+s],c,c+u),c+=u}return l}function Wf(e){const s=e.length/4*4;let a=1;if(s>=4)for(let l=e[0];a<s-4;a+=4)l=e[a]+=l,l=e[a+1]+=l,l=e[a+2]+=l,l=e[a+3]+=l;for(;a!=e.length;)e[a]+=e[a-1],++a}function Hf(e){e[0]=e[0]>>>1^-(1&e[0]),e[1]=e[1]>>>1^-(1&e[1]);const s=e.length/4*4;let a=2;if(s>=4)for(;a<s-4;a+=4){const s=e[a],l=e[a+1],c=e[a+2],u=e[a+3];e[a]=(s>>>1^-(1&s))+e[a-2],e[a+1]=(l>>>1^-(1&l))+e[a-1],e[a+2]=(c>>>1^-(1&c))+e[a],e[a+3]=(u>>>1^-(1&u))+e[a+1]}for(;a!=e.length;a+=2)e[a]=(e[a]>>>1^-(1&e[a]))+e[a-2],e[a+1]=(e[a+1]>>>1^-(1&e[a+1]))+e[a-1]}function Xf(e,s,a){return Math.min(a,Math.max(s,e))}!function(e){e.NONE="NONE",e.DELTA="DELTA",e.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",e.RLE="RLE",e.MORTON="MORTON",e.PDE="PDE"}(Pf||(Pf={})),function(e){e.NONE="NONE",e.FAST_PFOR="FAST_PFOR",e.VARINT="VARINT",e.ALP="ALP"}(If||(If={})),function(e){e.NONE="NONE",e.SINGLE="SINGLE",e.SHARED="SHARED",e.VERTEX="VERTEX",e.MORTON="MORTON",e.FSST="FSST"}(Mf||(Mf={})),function(e){e.VERTEX="VERTEX",e.INDEX="INDEX",e.STRING="STRING",e.KEY="KEY"}(Ef||(Ef={})),function(e){e.VAR_BINARY="VAR_BINARY",e.GEOMETRIES="GEOMETRIES",e.PARTS="PARTS",e.RINGS="RINGS",e.TRIANGLES="TRIANGLES",e.SYMBOL="SYMBOL",e.DICTIONARY="DICTIONARY"}(Cf||(Cf={}));class bp{_physicalStreamType;_logicalStreamType;_logicalLevelTechnique1;_logicalLevelTechnique2;_physicalLevelTechnique;_numValues;_byteLength;constructor(e,s,a,l,c,u,d){this._physicalStreamType=e,this._logicalStreamType=s,this._logicalLevelTechnique1=a,this._logicalLevelTechnique2=l,this._physicalLevelTechnique=c,this._numValues=u,this._byteLength=d}static decode(e,s){const a=e[s.get()],l=Object.values(Sf)[a>>4];let c=null;switch(l){case Sf.DATA:c=new ap(Object.values(Mf)[15&a]);break;case Sf.OFFSET:c=new ap(null,Object.values(Ef)[15&a]);break;case Sf.LENGTH:c=new ap(null,null,Object.values(Cf)[15&a])}s.increment();const u=e[s.get()],d=Object.values(Pf)[u>>5],f=Object.values(Pf)[u>>2&7],_=Object.values(If)[3&u];s.increment();const y=Lf(e,s,2);return new bp(l,c,d,f,_,y[0],y[1])}get physicalStreamType(){return this._physicalStreamType}get logicalStreamType(){return this._logicalStreamType}get logicalLevelTechnique1(){return this._logicalLevelTechnique1}get logicalLevelTechnique2(){return this._logicalLevelTechnique2}get physicalLevelTechnique(){return this._physicalLevelTechnique}get numValues(){return this._numValues}get byteLength(){return this._byteLength}getDecompressedCount(){return this._numValues}}class wp extends bp{num_bits;coordinate_shift;constructor(e,s,a,l,c,u,d,f,_){super(e,s,a,l,c,u,d),this.num_bits=f,this.coordinate_shift=_}static decode(e,s){const a=bp.decode(e,s),l=Lf(e,s,2);return new wp(a.physicalStreamType,a.logicalStreamType,a.logicalLevelTechnique1,a.logicalLevelTechnique2,a.physicalLevelTechnique,a.numValues,a.byteLength,l[0],l[1])}static decodePartial(e,s,a){const l=Lf(s,a,2);return new wp(e.physicalStreamType,e.logicalStreamType,e.logicalLevelTechnique1,e.logicalLevelTechnique2,e.physicalLevelTechnique,e.numValues,e.byteLength,l[0],l[1])}numBits(){return this.num_bits}coordinateShift(){return this.coordinate_shift}}class _p extends bp{_runs;_numRleValues;constructor(e,s,a,l,c,u,d,f,_){super(e,s,a,l,c,u,d),this._runs=f,this._numRleValues=_}static decode(e,s){const a=bp.decode(e,s),l=Lf(e,s,2);return new _p(a.physicalStreamType,a.logicalStreamType,a.logicalLevelTechnique1,a.logicalLevelTechnique2,a.physicalLevelTechnique,a.numValues,a.byteLength,l[0],l[1])}static decodePartial(e,s,a){const l=Lf(s,a,2);return new _p(e.physicalStreamType,e.logicalStreamType,e.logicalLevelTechnique1,e.logicalLevelTechnique2,e.physicalLevelTechnique,e.numValues,e.byteLength,l[0],l[1])}get runs(){return this._runs}get numRleValues(){return this._numRleValues}getDecompressedCount(){return this._numRleValues}}class Sp{static decode(e,s){const a=bp.decode(e,s);return a.logicalLevelTechnique1===Pf.MORTON?wp.decodePartial(a,e,s):Pf.RLE!==a.logicalLevelTechnique1&&Pf.RLE!==a.logicalLevelTechnique2||If.NONE===a.physicalLevelTechnique?a:_p.decodePartial(a,e,s)}}!function(e){e[e.FLAT=0]="FLAT",e[e.CONST=1]="CONST",e[e.SEQUENCE=2]="SEQUENCE",e[e.DICTIONARY=3]="DICTIONARY",e[e.FSST_DICTIONARY=4]="FSST_DICTIONARY"}(Af||(Af={}));class Ap{values;_size;constructor(e,s){this.values=e,this._size=s}get(e){const s=Math.floor(e/8);return 1==(this.values[s]>>e%8&1)}set(e,s){const a=Math.floor(e/8);this.values[a]=this.values[a]|(s?1:0)<<e%8}getInt(e){const s=Math.floor(e/8);return this.values[s]>>e%8&1}size(){return this._size}getBuffer(){return this.values}}class Tp{constructor(){}static decodeIntStream(e,s,a,l,c){const u=Tp.decodePhysicalLevelTechnique(e,s,a);return this.decodeIntBuffer(u,a,l,c)}static decodeLengthStreamToOffsetBuffer(e,s,a){const l=Tp.decodePhysicalLevelTechnique(e,s,a);return this.decodeLengthToOffsetBuffer(l,a)}static decodePhysicalLevelTechnique(e,s,a){const l=a.physicalLevelTechnique;if(l===If.FAST_PFOR)return Of();if(l===If.VARINT)return Lf(e,s,a.numValues);if(l===If.NONE){const l=s.get();s.add(a.byteLength);const c=e.subarray(l,s.get());return new Int32Array(c)}throw new Error("Specified physicalLevelTechnique is not supported (yet).")}static decodeConstIntStream(e,s,a,l){const c=Tp.decodePhysicalLevelTechnique(e,s,a);if(1===c.length){const e=c[0];return l?Vf(e):e}return l?function(e){return Vf(e[1])}(c):function(e){return e[1]}(c)}static decodeSequenceIntStream(e,s,a){return function(e){if(2==e.length){const s=Vf(e[1]);return[s,s]}return[Vf(e[2]),Vf(e[3])]}(Tp.decodePhysicalLevelTechnique(e,s,a))}static decodeSequenceLongStream(e,s,a){return function(e){if(2==e.length){const s=Nf(e[1]);return[s,s]}return[Nf(e[2]),Nf(e[3])]}(Ff(e,s,a.numValues))}static decodeLongStream(e,s,a,l){const c=Ff(e,s,a.numValues);return this.decodeLongBuffer(c,a,l)}static decodeLongFloat64Stream(e,s,a,l){const c=function(e,s,a){const l=new Float64Array(s);for(let c=0;c<s;c++)l[c]=Bf(e,a);return l}(e,a.numValues,s);return this.decodeFloat64Buffer(c,a,l)}static decodeConstLongStream(e,s,a,l){const c=Ff(e,s,a.numValues);if(1===c.length){const e=c[0];return l?Nf(e):e}return l?function(e){return Nf(e[1])}(c):function(e){return e[1]}(c)}static decodeIntBuffer(e,s,a,l){switch(s.logicalLevelTechnique1){case Pf.DELTA:return s.logicalLevelTechnique2===Pf.RLE?function(e,s,a){const l=new Int32Array(a);let c=0,u=0;for(let a=0;a<s;a++){const d=e[a],f=Vf(e[a+s]);for(let e=0;e<d;e++)u+=f,l[c++]=u}return l}(e,s.runs,s.numRleValues):(function(e){e[0]=e[0]>>>1^-(1&e[0]);const s=e.length/4*4;let a=1;if(s>=4)for(;a<s-4;a+=4){const s=e[a],l=e[a+1],c=e[a+2],u=e[a+3];e[a]=(s>>>1^-(1&s))+e[a-1],e[a+1]=(l>>>1^-(1&l))+e[a],e[a+2]=(c>>>1^-(1&c))+e[a+1],e[a+3]=(u>>>1^-(1&u))+e[a+2]}for(;a!=e.length;++a)e[a]=(e[a]>>>1^-(1&e[a]))+e[a-1]}(e),e);case Pf.RLE:return function(e,s,a){return a?function(e,s,a){const l=new Int32Array(a);let c=0;for(let a=0;a<s;a++){const u=e[a];let d=e[a+s];d=d>>>1^-(1&d),l.fill(d,c,c+u),c+=u}return l}(e,s.runs,s.numRleValues):Gf(e,s.runs,s.numRleValues)}(e,s,a);case Pf.MORTON:return Wf(e),e;case Pf.COMPONENTWISE_DELTA:return l?(function(e,s,a,l){let c=e[0]>>>1^-(1&e[0]),u=e[1]>>>1^-(1&e[1]);e[0]=Xf(Math.round(c*s),a,l),e[1]=Xf(Math.round(u*s),a,l);const d=e.length/16;let f=2;if(d>=4)for(;f<d-4;f+=4){const d=e[f],_=e[f+1],y=(d>>>1^-(1&d))+c,b=(_>>>1^-(1&_))+u;e[f]=Xf(Math.round(y*s),a,l),e[f+1]=Xf(Math.round(b*s),a,l);const S=e[f+2],P=e[f+3];c=(S>>>1^-(1&S))+y,u=(P>>>1^-(1&P))+b,e[f+2]=Xf(Math.round(c*s),a,l),e[f+3]=Xf(Math.round(u*s),a,l)}for(;f!=e.length;f+=2)c+=e[f]>>>1^-(1&e[f]),u+=e[f+1]>>>1^-(1&e[f+1]),e[f]=Xf(Math.round(c*s),a,l),e[f+1]=Xf(Math.round(u*s),a,l)}(e,l.scale,l.min,l.max),e):(Hf(e),e);case Pf.NONE:return a&&function(e){for(let s=0;s<e.length;s++){const a=e[s];e[s]=a>>>1^-(1&a)}}(e),e;default:throw new Error(`The specified Logical level technique is not supported: ${s.logicalLevelTechnique1}`)}}static decodeLongBuffer(e,s,a){switch(s.logicalLevelTechnique1){case Pf.DELTA:return s.logicalLevelTechnique2===Pf.RLE?function(e,s,a){const l=new BigInt64Array(a);let c=0,u=0n;for(let a=0;a<s;a++){const d=Number(e[a]),f=Nf(e[a+s]);for(let e=0;e<d;e++)u+=f,l[c++]=u}return l}(e,s.runs,s.numRleValues):(function(e){e[0]=e[0]>>1n^-(1n&e[0]);const s=e.length/4*4;let a=1;if(s>=4)for(;a<s-4;a+=4){const s=e[a],l=e[a+1],c=e[a+2],u=e[a+3];e[a]=(s>>1n^-(1n&s))+e[a-1],e[a+1]=(l>>1n^-(1n&l))+e[a],e[a+2]=(c>>1n^-(1n&c))+e[a+1],e[a+3]=(u>>1n^-(1n&u))+e[a+2]}for(;a!=e.length;++a)e[a]=(e[a]>>1n^-(1n&e[a]))+e[a-1]}(e),e);case Pf.RLE:return function(e,s,a){return a?function(e,s,a){const l=new BigInt64Array(a);let c=0;for(let a=0;a<s;a++){const u=Number(e[a]);let d=e[a+s];d=d>>1n^-(1n&d),l.fill(d,c,c+u),c+=u}return l}(e,s.runs,s.numRleValues):Zf(e,s.runs,s.numRleValues)}(e,s,a);case Pf.NONE:return a&&function(e){for(let s=0;s<e.length;s++){const a=e[s];e[s]=a>>1n^-(1n&a)}}(e),e;default:throw new Error(`The specified Logical level technique is not supported: ${s.logicalLevelTechnique1}`)}}static decodeFloat64Buffer(e,s,a){switch(s.logicalLevelTechnique1){case Pf.DELTA:return s.logicalLevelTechnique2===Pf.RLE&&(e=$f(e,s.runs,s.numRleValues)),function(e){e[0]=e[0]%2==1?(e[0]+1)/-2:e[0]/2;const s=e.length/4*4;let a=1;if(s>=4)for(;a<s-4;a+=4){const s=e[a],l=e[a+1],c=e[a+2],u=e[a+3];e[a]=(s%2==1?(s+1)/-2:s/2)+e[a-1],e[a+1]=(l%2==1?(l+1)/-2:l/2)+e[a],e[a+2]=(c%2==1?(c+1)/-2:c/2)+e[a+1],e[a+3]=(u%2==1?(u+1)/-2:u/2)+e[a+2]}for(;a!=e.length;++a)e[a]=(e[a]%2==1?(e[a]+1)/-2:e[a]/2)+e[a-1]}(e),e;case Pf.RLE:return function(e,s,a){return a?function(e,s,a){const l=new Float64Array(a);let c=0;for(let a=0;a<s;a++){const u=e[a];let d=e[a+s];d=d%2==1?(d+1)/-2:d/2,l.fill(d,c,c+u),c+=u}return l}(e,s.runs,s.numRleValues):$f(e,s.runs,s.numRleValues)}(e,s,a);case Pf.NONE:return a&&function(e){for(let s=0;s<e.length;s++){const a=e[s];e[s]=a%2==1?(a+1)/-2:a/2}}(e),e;default:throw new Error(`The specified Logical level technique is not supported: ${s.logicalLevelTechnique1}`)}}static decodeLengthToOffsetBuffer(e,s){if(s.logicalLevelTechnique1===Pf.DELTA&&s.logicalLevelTechnique2===Pf.NONE)return function(e){const s=new Int32Array(e.length+1);s[0]=0,s[1]=Vf(e[0]);let a=s[1],l=2;for(;l!=s.length;++l){const c=e[l-1];a+=c>>>1^-(1&c),s[l]=s[l-1]+a}return s}(e);if(s.logicalLevelTechnique1===Pf.RLE&&s.logicalLevelTechnique2===Pf.NONE)return function(e,s,a){const l=new Int32Array(a+1);l[0]=0;let c=1,u=l[0];for(let a=0;a<s;a++){const d=e[a],f=e[a+s];for(let e=c;e<c+d;e++)l[e]=f+u,u=l[e];c+=d}return l}(e,s.runs,s.numRleValues);if(s.logicalLevelTechnique1===Pf.NONE&&s.logicalLevelTechnique2===Pf.NONE){!function(e){let s=0;for(let a=0;a<e.length;a++)e[a]+=s,s=e[a]}(e);const a=new Int32Array(s.numValues+1);return a[0]=0,a.set(e,1),a}if(s.logicalLevelTechnique1===Pf.DELTA&&s.logicalLevelTechnique2===Pf.RLE){const a=function(e,s,a){const l=new Int32Array(a+1);l[0]=0;let c=1,u=l[0];for(let a=0;a<s;a++){const d=e[a];let f=e[a+s];f=f>>>1^-(1&f);for(let e=c;e<c+d;e++)l[e]=f+u,u=l[e];c+=d}return l}(e,s.runs,s.numRleValues);return Wf(a),a}throw new Error("Only delta encoding is supported for transforming length to offset streams yet.")}static decodeNullableIntStream(e,s,a,l,c){const u=a.physicalLevelTechnique===If.FAST_PFOR?Of():Lf(e,s,a.numValues);return this.decodeNullableIntBuffer(u,a,l,c)}static decodeNullableLongStream(e,s,a,l,c){const u=Ff(e,s,a.numValues);return this.decodeNullableLongBuffer(u,a,l,c)}static decodeNullableIntBuffer(e,s,a,l){switch(s.logicalLevelTechnique1){case Pf.DELTA:return s.logicalLevelTechnique2===Pf.RLE&&(e=Gf(e,s.runs,s.numRleValues)),function(e,s){const a=new Int32Array(e.size());let l=0;e.get(0)?(a[0]=e.get(0)?s[0]>>>1^-(1&s[0]):0,l=1):a[0]=0;let c=1;for(;c!=a.length;++c)a[c]=e.get(c)?a[c-1]+(s[l]>>>1^-(1&s[l++])):a[c-1];return a}(l,e);case Pf.RLE:return function(e,s,a,l){const c=s;return a?function(e,s,a){const l=new Int32Array(e.size());let c=0;for(let u=0;u<a;u++){const d=s[u];let f=s[u+a];f=f>>>1^-(1&f);for(let s=c;s<c+d;s++)e.get(s)?l[s]=f:(l[s]=0,c++);c+=d}return l}(l,e,c.runs):function(e,s,a){const l=new Int32Array(e.size());let c=0;for(let u=0;u<a;u++){const d=s[u],f=s[u+a];for(let s=c;s<c+d;s++)e.get(s)?l[s]=f:(l[s]=0,c++);c+=d}return l}(l,e,c.runs)}(e,s,a,l);case Pf.MORTON:return Wf(e),e;case Pf.COMPONENTWISE_DELTA:return Hf(e),e;case Pf.NONE:return e=a?function(e,s){const a=new Int32Array(e.size());let l=0,c=0;for(;c!=a.length;++c)if(e.get(c)){const e=s[l++];a[c]=e>>>1^-(1&e)}else a[c]=0;return a}(l,e):function(e,s){const a=new Int32Array(e.size());let l=0,c=0;for(;c!=a.length;++c)a[c]=e.get(c)?s[l++]:0;return a}(l,e),e;default:throw new Error("The specified Logical level technique is not supported")}}static decodeNullableLongBuffer(e,s,a,l){switch(s.logicalLevelTechnique1){case Pf.DELTA:return s.logicalLevelTechnique2===Pf.RLE&&(e=Zf(e,s.runs,s.numRleValues)),function(e,s){const a=new BigInt64Array(e.size());let l=0;e.get(0)?(a[0]=e.get(0)?s[0]>>1n^-(1n&s[0]):0n,l=1):a[0]=0n;let c=1;for(;c!=a.length;++c)a[c]=e.get(c)?a[c-1]+(s[l]>>1n^-(1n&s[l++])):a[c-1];return a}(l,e);case Pf.RLE:return function(e,s,a,l){const c=s;return a?function(e,s,a){const l=new BigInt64Array(e.size());let c=0;for(let u=0;u<a;u++){const d=Number(s[u]);let f=s[u+a];f=f>>1n^-(1n&f);for(let s=c;s<c+d;s++)e.get(s)?l[s]=f:(l[s]=0n,c++);c+=d}return l}(l,e,c.runs):function(e,s,a){const l=new BigInt64Array(e.size());let c=0;for(let u=0;u<a;u++){const d=Number(s[u]),f=s[u+a];for(let s=c;s<c+d;s++)e.get(s)?l[s]=f:(l[s]=0n,c++);c+=d}return l}(l,e,c.runs)}(e,s,a,l);case Pf.NONE:return e=a?function(e,s){const a=new BigInt64Array(e.size());let l=0,c=0;for(;c!=a.length;++c)if(e.get(c)){const e=s[l++];a[c]=e>>1n^-(1n&e)}else a[c]=0n;return a}(l,e):function(e,s){const a=new BigInt64Array(e.size());let l=0,c=0;for(;c!=a.length;++c)a[c]=e.get(c)?s[l++]:0n;return a}(l,e),e;default:throw new Error("The specified Logical level technique is not supported")}}static getVectorType(e,s,a,l){const c=e.logicalLevelTechnique1;if(c===Pf.RLE)return 1===e.runs?Af.CONST:Af.FLAT;const u=s instanceof Ap?s.size():s;if(c===Pf.DELTA&&e.logicalLevelTechnique2===Pf.RLE){const s=e.runs,c=2;if(e.numRleValues!==u)return Af.FLAT;if(1===s)return Af.SEQUENCE;if(2===s){const s=l.get();let u;if(e.physicalLevelTechnique===If.VARINT)u=Lf(a,l,4);else{const e=l.get();u=new Int32Array(a.buffer,a.byteOffset+e,4)}if(l.set(s),u[2]===c&&u[3]===c)return Af.SEQUENCE}}return 1===e.numValues?Af.CONST:Af.FLAT}}class Ip extends Uh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Mp extends Gh{constructor(e,s,a,l){super(e,BigInt64Array.of(s),a,l)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}}class Ep{_geometryOffsets;_partOffsets;_ringOffsets;constructor(e,s,a){this._geometryOffsets=e,this._partOffsets=s,this._ringOffsets=a}get geometryOffsets(){return this._geometryOffsets}get partOffsets(){return this._partOffsets}get ringOffsets(){return this._ringOffsets}}class kp{tileExtent;_numBits;_coordinateShift;minBound;maxBound;constructor(e,s){this._coordinateShift=e<0?Math.abs(e):0,this.tileExtent=s+this._coordinateShift,this._numBits=Math.ceil(Math.log2(this.tileExtent)),this.minBound=e,this.maxBound=s}validateCoordinates(e){if(e.x<this.minBound||e.y<this.minBound||e.x>this.maxBound||e.y>this.maxBound)throw new Error("The specified tile buffer size is currently not supported.")}numBits(){return this._numBits}coordinateShift(){return this._coordinateShift}}class Dp extends kp{encode(e){this.validateCoordinates(e);const s=e.x+this._coordinateShift,a=e.y+this._coordinateShift;let l=0;for(let e=0;e<this._numBits;e++)l|=(s&1<<e)<<e|(a&1<<e)<<e+1;return l}decode(e){return{x:this.decodeMorton(e)-this._coordinateShift,y:this.decodeMorton(e>>1)-this._coordinateShift}}decodeMorton(e){let s=0;for(let a=0;a<this._numBits;a++)s|=(e&1<<2*a)>>a;return s}static decode(e,s,a){return{x:Dp.decodeMorton(e,s)-a,y:Dp.decodeMorton(e>>1,s)-a}}static decodeMorton(e,s){let a=0;for(let l=0;l<s;l++)a|=(e&1<<2*l)>>l;return a}}!function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON",e[e.MULTIPOINT=3]="MULTIPOINT",e[e.MULTILINESTRING=4]="MULTILINESTRING",e[e.MULTIPOLYGON=5]="MULTIPOLYGON"}(Df||(Df={})),function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON"}(zf||(zf={})),function(e){e[e.MORTON=0]="MORTON",e[e.VEC_2=1]="VEC_2",e[e.VEC_3=2]="VEC_3"}(Rf||(Rf={}));class Fp{createPoint(e){return[[e]]}createMultiPoint(e){return e.map((e=>[e]))}createLineString(e){return[e]}createMultiLineString(e){return e}createPolygon(e,s){return[e,...s]}createMultiPolygon(e){return e.flat()}}function Yf(e){const s=new Array(e.numGeometries);let a=1,c=1,u=1,d=0;const f=new Fp;let _=0,y=0;const b=e.mortonSettings,S=e.topologyVector,P=S.geometryOffsets,M=S.partOffsets,C=S.ringOffsets,D=e.vertexOffsets,L=e.containsPolygonGeometry(),F=e.vertexBuffer;for(let S=0;S<e.numGeometries;S++){const B=e.geometryType(S);if(B===Df.POINT){if(D&&0!==D.length)if(e.vertexBufferType===Rf.VEC_2){const e=2*D[y++],a=new l(F[e],F[e+1]);s[d++]=f.createPoint(a)}else{const e=D[y++],a=Dp.decode(F[e],b.numBits,b.coordinateShift),c=new l(a.x,a.y);s[d++]=f.createPoint(c)}else{const e=new l(F[_++],F[_++]);s[d++]=f.createPoint(e)}P&&u++,M&&a++,C&&c++}else if(B===Df.MULTIPOINT){const e=P[u]-P[u-1];u++;const a=new Array(e);if(D&&0!==D.length){for(let s=0;s<e;s++){const e=2*D[y++];a[s]=new l(F[e],F[e+1])}s[d++]=f.createMultiPoint(a)}else{for(let s=0;s<e;s++){const e=F[_++],c=F[_++];a[s]=new l(e,c)}s[d++]=f.createMultiPoint(a)}}else if(B===Df.LINESTRING){let l,S=0;L?(S=C[c]-C[c-1],c++):S=M[a]-M[a-1],a++,D&&0!==D.length?(l=e.vertexBufferType===Rf.VEC_2?tm(F,D,y,S,!1):im(F,D,y,S,!1,b),y+=S):(l=em(F,_,S,!1),_+=2*S),s[d++]=f.createLineString(l),P&&u++}else if(B===Df.POLYGON){const l=M[a]-M[a-1];a++;const S=new Array(l-1);let L=C[c]-C[c-1];if(c++,D&&0!==D.length){const a=e.vertexBufferType===Rf.VEC_2?Jf(F,D,y,L):Qf(F,D,y,L,0,b);y+=L;for(let s=0;s<S.length;s++)L=C[c]-C[c-1],c++,S[s]=e.vertexBufferType===Rf.VEC_2?Jf(F,D,y,L):Qf(F,D,y,L,0,b),y+=L;s[d++]=f.createPolygon(a,S)}else{const e=Kf(F,_,L);_+=2*L;for(let e=0;e<S.length;e++)L=C[c]-C[c-1],c++,S[e]=Kf(F,_,L),_+=2*L;s[d++]=f.createPolygon(e,S)}P&&u++}else if(B===Df.MULTILINESTRING){const l=P[u]-P[u-1];u++;const S=new Array(l);if(D&&0!==D.length){for(let s=0;s<l;s++){let l=0;L?(l=C[c]-C[c-1],c++):l=M[a]-M[a-1],a++;const u=e.vertexBufferType===Rf.VEC_2?tm(F,D,y,l,!1):im(F,D,y,l,!1,b);S[s]=u,y+=l}s[d++]=f.createMultiLineString(S)}else{for(let e=0;e<l;e++){let s=0;L?(s=C[c]-C[c-1],c++):s=M[a]-M[a-1],a++,S[e]=em(F,_,s,!1),_+=2*s}s[d++]=f.createMultiLineString(S)}}else{if(B!==Df.MULTIPOLYGON)throw new Error("The specified geometry type is currently not supported.");{const l=P[u]-P[u-1];u++;const S=new Array(l);let L=0;if(D&&0!==D.length){for(let s=0;s<l;s++){const l=M[a]-M[a-1];a++;const u=new Array(l-1);L=C[c]-C[c-1],c++;const d=e.vertexBufferType===Rf.VEC_2?Jf(F,D,y,L):Qf(F,D,y,L,0,b);y+=L;for(let s=0;s<u.length;s++)L=C[c]-C[c-1],c++,u[s]=e.vertexBufferType===Rf.VEC_2?Jf(F,D,y,L):Qf(F,D,y,L,0,b),y+=L;S[s]=f.createPolygon(d,u)}s[d++]=f.createMultiPolygon(S)}else{for(let e=0;e<l;e++){const s=M[a]-M[a-1];a++;const l=new Array(s-1);L=C[c]-C[c-1],c++;const u=Kf(F,_,L);_+=2*L;for(let e=0;e<l.length;e++){const s=C[c]-C[c-1];c++,l[e]=Kf(F,_,s),_+=2*s}S[e]=f.createPolygon(u,l)}s[d++]=f.createMultiPolygon(S)}}}}return s}function Kf(e,s,a){return em(e,s,a,!0)}function Jf(e,s,a,l){return tm(e,s,a,l,!0)}function Qf(e,s,a,l,c,u){return im(e,s,a,l,!0,u)}function em(e,s,a,c){const u=new Array(c?a+1:a);for(let c=0;c<2*a;c+=2)u[c/2]=new l(e[s+c],e[s+c+1]);return c&&(u[u.length-1]=u[0]),u}function tm(e,s,a,c,u){const d=new Array(u?c+1:c);for(let u=0;u<2*c;u+=2){const c=2*s[a+u/2];d[u/2]=new l(e[c],e[c+1])}return u&&(d[d.length-1]=d[0]),d}function im(e,s,a,c,u,d){const f=new Array(u?c+1:c);for(let u=0;u<c;u++){const c=Dp.decode(e[s[a+u]],d.numBits,d.coordinateShift);f[u]=new l(c.x,c.y)}return u&&(f[f.length-1]=f[0]),f}class Rp{_vertexBufferType;_topologyVector;_vertexOffsets;_vertexBuffer;_mortonSettings;constructor(e,s,a,l,c){this._vertexBufferType=e,this._topologyVector=s,this._vertexOffsets=a,this._vertexBuffer=l,this._mortonSettings=c}get vertexBufferType(){return this._vertexBufferType}get topologyVector(){return this._topologyVector}get vertexOffsets(){return this._vertexOffsets}get vertexBuffer(){return this._vertexBuffer}*[Symbol.iterator](){const e=Yf(this);let s=0;for(;s<this.numGeometries;)yield{coordinates:e[s],type:this.geometryType(s)},s++}getSimpleEncodedVertex(e){const s=this.vertexOffsets?2*this.vertexOffsets[e]:2*e;return[this.vertexBuffer[s],this.vertexBuffer[s+1]]}getVertex(e){if(this.vertexOffsets&&this.mortonSettings){const s=Dp.decode(this.vertexBuffer[this.vertexOffsets[e]],this.mortonSettings.numBits,this.mortonSettings.coordinateShift);return[s.x,s.y]}const s=this.vertexOffsets?2*this.vertexOffsets[e]:2*e;return[this.vertexBuffer[s],this.vertexBuffer[s+1]]}getGeometries(){return Yf(this)}get mortonSettings(){return this._mortonSettings}}class Np extends Rp{_numGeometries;_geometryType;constructor(e,s,a,l,c,u,d){super(a,l,c,u,d),this._numGeometries=e,this._geometryType=s}static createMortonEncoded(e,s,a,l,c,u){return new Np(e,s,Rf.MORTON,a,l,c,u)}static create(e,s,a,l,c){return new Np(e,s,Rf.VEC_2,a,l,c)}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===Df.POLYGON||this._geometryType===Df.MULTIPOLYGON}containsSingleGeometryType(){return!0}}class $p extends Rp{_geometryTypes;constructor(e,s,a,l,c,u){super(e,a,l,c,u),this._geometryTypes=s}static createMortonEncoded(e,s,a,l,c){return new $p(Rf.MORTON,e,s,a,l,c)}static create(e,s,a,l){return new $p(Rf.VEC_2,e,s,a,l)}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsPolygonGeometry(){for(let e=0;e<this.numGeometries;e++)if(this.geometryType(e)===Df.POLYGON||this.geometryType(e)===Df.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}}class Up{_triangleOffsets;_indexBuffer;_vertexBuffer;_topologyVector;constructor(e,s,a,l){this._triangleOffsets=e,this._indexBuffer=s,this._vertexBuffer=a,this._topologyVector=l}get triangleOffsets(){return this._triangleOffsets}get indexBuffer(){return this._indexBuffer}get vertexBuffer(){return this._vertexBuffer}get topologyVector(){return this._topologyVector}getGeometries(){if(!this._topologyVector)throw new Error("Cannot convert GpuVector to coordinates without topology information");const e=new Array(this.numGeometries),s=this._topologyVector,a=s.partOffsets,c=s.ringOffsets,u=s.geometryOffsets;let d=0,f=1,_=1,y=1;for(let s=0;s<this.numGeometries;s++)switch(this.geometryType(s)){case Df.POLYGON:{const b=a[f]-a[f-1];f++;const S=[];for(let e=0;e<b;e++){const e=c[_]-c[_-1];_++;const s=[];for(let a=0;a<e;a++){const e=this._vertexBuffer[d++],a=this._vertexBuffer[d++];s.push(new l(e,a))}s.length>0&&s.push(s[0]),S.push(s)}e[s]=S,u&&y++}break;case Df.MULTIPOLYGON:{const b=u[y]-u[y-1];y++;const S=[];for(let e=0;e<b;e++){const e=a[f]-a[f-1];f++;for(let s=0;s<e;s++){const e=c[_]-c[_-1];_++;const s=[];for(let a=0;a<e;a++){const e=this._vertexBuffer[d++],a=this._vertexBuffer[d++];s.push(new l(e,a))}s.length>0&&s.push(s[0]),S.push(s)}}e[s]=S}}return e}[Symbol.iterator](){return null}}class qp extends Up{_numGeometries;_geometryType;constructor(e,s,a,l,c,u){super(a,l,c,u),this._numGeometries=e,this._geometryType=s}static create(e,s,a,l,c,u){return new qp(e,s,a,l,c,u)}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}}class jp extends Up{_geometryTypes;constructor(e,s,a,l,c){super(s,a,l,c),this._geometryTypes=e}static create(e,s,a,l,c){return new jp(e,s,a,l,c)}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}}function rm(e,s,a,l,c){const u=Sp.decode(e,a);let d=null,f=null,_=null,y=null,b=null,S=null,P=null,M=null;if(Tp.getVectorType(u,l,e,a)===Af.CONST){const C=Tp.decodeConstIntStream(e,a,u,!1);for(let l=0;l<s-1;l++){const s=Sp.decode(e,a);switch(s.physicalStreamType){case Sf.LENGTH:switch(s.logicalStreamType.lengthType){case Cf.GEOMETRIES:d=Tp.decodeLengthStreamToOffsetBuffer(e,a,s);break;case Cf.PARTS:f=Tp.decodeLengthStreamToOffsetBuffer(e,a,s);break;case Cf.RINGS:_=Tp.decodeLengthStreamToOffsetBuffer(e,a,s);break;case Cf.TRIANGLES:P=Tp.decodeLengthStreamToOffsetBuffer(e,a,s)}break;case Sf.OFFSET:switch(s.logicalStreamType.offsetType){case Ef.VERTEX:y=Tp.decodeIntStream(e,a,s,!1);break;case Ef.INDEX:M=Tp.decodeIntStream(e,a,s,!1)}break;case Sf.DATA:if(Mf.VERTEX===s.logicalStreamType.dictionaryType)b=Tp.decodeIntStream(e,a,s,!0,c);else{const l=s;S={numBits:l.numBits(),coordinateShift:l.coordinateShift()},b=Tp.decodeIntStream(e,a,s,!1,c)}}}if(null!==M){if(null!=d||null!=f){const e=new Ep(d,f,_);return qp.create(l,C,P,M,b,e)}return qp.create(l,C,P,M,b)}return null===S?Np.create(l,C,new Ep(d,f,_),y,b):Np.createMortonEncoded(l,C,new Ep(d,f,_),y,b,S)}const C=Tp.decodeIntStream(e,a,u,!1);for(let l=0;l<s-1;l++){const s=Sp.decode(e,a);switch(s.physicalStreamType){case Sf.LENGTH:switch(s.logicalStreamType.lengthType){case Cf.GEOMETRIES:d=Tp.decodeIntStream(e,a,s,!1);break;case Cf.PARTS:f=Tp.decodeIntStream(e,a,s,!1);break;case Cf.RINGS:_=Tp.decodeIntStream(e,a,s,!1);break;case Cf.TRIANGLES:P=Tp.decodeLengthStreamToOffsetBuffer(e,a,s)}break;case Sf.OFFSET:switch(s.logicalStreamType.offsetType){case Ef.VERTEX:y=Tp.decodeIntStream(e,a,s,!1);break;case Ef.INDEX:M=Tp.decodeIntStream(e,a,s,!1)}break;case Sf.DATA:if(Mf.VERTEX===s.logicalStreamType.dictionaryType)b=Tp.decodeIntStream(e,a,s,!0,c);else{const l=s;S={numBits:l.numBits(),coordinateShift:l.coordinateShift()},b=Tp.decodeIntStream(e,a,s,!1,c)}}}return null!==M&&null===f?jp.create(C,P,M,b):(null!==d?(d=nm(C,d,2),null!==f&&null!==_?(f=sm(C,d,f,!1),_=function(e,s,a,l){const c=new Int32Array(a[a.length-1]+1);let u=0;c[0]=u;let d=1,f=1,_=0;for(let y=0;y<e.length;y++){const b=e[y],S=s[y+1]-s[y];if(0!==b&&3!==b)for(let e=0;e<S;e++){const e=a[d]-a[d-1];d++;for(let s=0;s<e;s++)u=c[f++]=u+l[_++]}else for(let e=0;e<S;e++)c[f++]=++u,d++}return c}(C,d,f,_)):null!==f&&(f=function(e,s,a){const l=new Int32Array(s[s.length-1]+1);let c=0;l[0]=c;let u=1,d=0;for(let f=0;f<e.length;f++){const _=e[f],y=s[f+1]-s[f];if(4===_||1===_)for(let e=0;e<y;e++)c=l[u++]=c+a[d++];else for(let e=0;e<y;e++)l[u++]=++c}return l}(C,d,f))):null!==f&&null!==_?(f=nm(C,f,1),_=sm(C,f,_,!0)):null!==f&&(f=nm(C,f,0)),null!==M?jp.create(C,P,M,b,new Ep(d,f,_)):null===S?$p.create(C,new Ep(d,f,_),y,b):$p.createMortonEncoded(C,new Ep(d,f,_),y,b,S))}function nm(e,s,a){const l=new Int32Array(e.length+1);let c=0;l[0]=c;let u=0;for(let d=0;d<e.length;d++)c=l[d+1]=c+(e[d]>a?s[u++]:1);return l}function sm(e,s,a,l){const c=new Int32Array(s[s.length-1]+1);let u=0;c[0]=u;let d=1,f=0;for(let _=0;_<e.length;_++){const y=e[_],b=s[_+1]-s[_];if(5===y||2===y||l&&(4===y||1===y))for(let e=0;e<b;e++)u=c[d++]=u+a[f++];else for(let e=0;e<b;e++)c[d++]=++u}return c}class Zp extends $h{dataVector;constructor(e,s,a){super(e,s.getBuffer(),a),this.dataVector=s}getValueFromBuffer(e){return this.dataVector.get(e)}}class Hp extends Uh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Kp extends $h{constructor(e,s,a){super(e,BigInt64Array.of(s),a)}getValueFromBuffer(e){return this.dataBuffer[0]}}function om(e,s,a){for(let l=0;l<e;l++){const e=Sp.decode(s,a);a.add(e.byteLength)}}function am(e,s,a){return lm(e,Math.ceil(s/8),a)}function lm(e,s,a){const l=new Uint8Array(s);let c=0;for(;c<s;){const s=e[a.increment()];if(s<=127){const u=s+3,d=e[a.increment()],f=c+u;l.fill(d,c,f),c=f}else{const u=256-s;for(let s=0;s<u;s++)l[c++]=e[a.increment()]}}return l}const cm=new TextDecoder;function hm(e,s,a){return a-s>=12?cm.decode(e.subarray(s,a)):function(e,s,a){let l="",c=s;for(;c<a;){const s=e[c];let u,d,f,_=null,y=s>239?4:s>223?3:s>191?2:1;if(c+y>a)break;1===y?s<128&&(_=s):2===y?(u=e[c+1],128==(192&u)&&(_=(31&s)<<6|63&u,_<=127&&(_=null))):3===y?(u=e[c+1],d=e[c+2],128==(192&u)&&128==(192&d)&&(_=(15&s)<<12|(63&u)<<6|63&d,(_<=2047||_>=55296&&_<=57343)&&(_=null))):4===y&&(u=e[c+1],d=e[c+2],f=e[c+3],128==(192&u)&&128==(192&d)&&128==(192&f)&&(_=(15&s)<<18|(63&u)<<12|(63&d)<<6|63&f,(_<=65535||_>=1114112)&&(_=null))),null===_?(_=65533,y=1):_>65535&&(_-=65536,l+=String.fromCharCode(_>>>10&1023|55296),_=56320|1023&_),l+=String.fromCharCode(_),c+=y}return l}(e,s,a)}class rf extends $h{offsetBuffer;constructor(e,s,a,l){super(e,a,l),this.offsetBuffer=s}}class nf extends rf{textEncoder;constructor(e,s,a,l){super(e,s,a,l??s.length-1),this.textEncoder=new TextEncoder}getValueFromBuffer(e){return hm(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}}class sf extends rf{indexBuffer;textEncoder;constructor(e,s,a,l,c){super(e,a,l,c??s.length),this.indexBuffer=s,this.indexBuffer=s,this.textEncoder=new TextEncoder}getValueFromBuffer(e){const s=this.indexBuffer[e];return hm(this.dataBuffer,this.offsetBuffer[s],this.offsetBuffer[s+1])}}class af extends rf{indexBuffer;symbolOffsetBuffer;symbolTableBuffer;textEncoder;symbolLengthBuffer;lengthBuffer;decodedDictionary;constructor(e,s,a,l,c,u,d){super(e,a,l,d),this.indexBuffer=s,this.symbolOffsetBuffer=c,this.symbolTableBuffer=u,this.textEncoder=new TextEncoder}getValueFromBuffer(e){null==this.decodedDictionary&&(null==this.symbolLengthBuffer&&(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer),this.lengthBuffer=this.offsetToLengthBuffer(this.offsetBuffer)),this.decodedDictionary=function(e,s,a){const l=[],c=new Array(s.length).fill(0);for(let e=1;e<s.length;e++)c[e]=c[e-1]+s[e-1];for(let u=0;u<a.length;u++)if(255===a[u])l.push(a[++u]);else{const d=s[a[u]],f=c[a[u]];for(let s=0;s<d;s++)l.push(e[f+s])}return new Uint8Array(l)}(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer));const s=this.indexBuffer[e];return hm(this.decodedDictionary,this.offsetBuffer[s],this.offsetBuffer[s+1])}offsetToLengthBuffer(e){const s=new Uint32Array(e.length-1);let a=e[0];for(let l=1;l<e.length;l++){const c=e[l];s[l-1]=c-a,a=c}return s}}class of{static ROOT_COLUMN_NAME="default";static NESTED_COLUMN_SEPARATOR=":";constructor(){}static decode(e,s,a,l,c){let u=null,d=null,f=null,_=null,y=null,b=null,S=null,P=null;for(let e=0;e<l;e++){const e=Sp.decode(s,a);if(0!==e.byteLength)switch(e.physicalStreamType){case Sf.PRESENT:{const l=am(s,e.numValues,a);b=new Ap(l,e.numValues);break}case Sf.OFFSET:d=null!=c||null!=b?Tp.decodeNullableIntStream(s,a,e,!1,c??b):Tp.decodeIntStream(s,a,e,!1);break;case Sf.LENGTH:{const l=Tp.decodeLengthStreamToOffsetBuffer(s,a,e);Cf.DICTIONARY===e.logicalStreamType.lengthType?u=l:Cf.SYMBOL===e.logicalStreamType.lengthType?_=l:S=l;break}case Sf.DATA:{const l=s.subarray(a.get(),a.get()+e.byteLength);a.add(e.byteLength);const c=e.logicalStreamType.dictionaryType;Mf.FSST===c?y=l:Mf.SINGLE===c||Mf.SHARED===c?f=l:Mf.NONE===c&&(P=l);break}}}return this.decodeFsstDictionaryVector(e,y,d,u,f,_,c??b)??this.decodeDictionaryVector(e,f,d,u,c??b)??this.decodePlainStringVector(e,S,P,d,c??b)}static decodeFsstDictionaryVector(e,s,a,l,c,u,d){return s?new af(e,a,l,c,u,s,d):null}static decodeDictionaryVector(e,s,a,l,c){return s?c?new sf(e,a,l,s,c):new sf(e,a,l,s):null}static decodePlainStringVector(e,s,a,l,c){if(!s||!a)return null;if(l)return c?new sf(e,l,s,a,c):new sf(e,l,s,a);if(c&&c.size()!==s.length-1){const l=new Int32Array(c.size());let u=0;for(let e=0;e<c.size();e++)l[e]=c.get(e)?u++:0;return new sf(e,l,s,a,c)}return c?new nf(e,s,a,c):new nf(e,s,a)}static decodeSharedDictionary(e,s,a,l,c){let u=null,d=null,f=null,_=null,y=!1;for(;!y;){const a=Sp.decode(e,s);switch(a.physicalStreamType){case Sf.LENGTH:Cf.DICTIONARY===a.logicalStreamType.lengthType?u=Tp.decodeLengthStreamToOffsetBuffer(e,s,a):f=Tp.decodeLengthStreamToOffsetBuffer(e,s,a);break;case Sf.DATA:Mf.SINGLE===a.logicalStreamType.dictionaryType||Mf.SHARED===a.logicalStreamType.dictionaryType?(d=e.subarray(s.get(),s.get()+a.byteLength),y=!0):_=e.subarray(s.get(),s.get()+a.byteLength),s.add(a.byteLength)}}const b=a.complexType.children,S=[];let P=0;for(const y of b){const b=Lf(e,s,1)[0];if(0==b)continue;const M=`${a.name}${y.name===of.ROOT_COLUMN_NAME?"":of.NESTED_COLUMN_SEPARATOR+y.name}`;if(c&&!c.has(M)){om(b,e,s);continue}if(2!==b||"scalarField"!==y.type||9!==y.scalarField.physicalType)throw new Error("Currently only optional string fields are implemented for a struct.");const C=Sp.decode(e,s),D=am(e,C.numValues,s),L=Sp.decode(e,s),F=(L instanceof _p?L.numRleValues:L.numValues)!==l?Tp.decodeNullableIntStream(e,s,L,!1,new Ap(D,C.numValues)):Tp.decodeIntStream(e,s,L,!1);S[P++]=_?new af(M,F,u,d,f,_,new Ap(D,C.numValues)):new sf(M,F,u,d,new Ap(D,C.numValues))}return S}}function um(e,s,a,l,c,u){return"scalarType"===a.type?function(e,s,a,l,c,u){let d=null,f=0;if(0===e)return null;if(u.nullable){const e=Sp.decode(s,a);f=e.numValues;const l=a.get(),c=am(s,f,a);a.set(l+e.byteLength),d=new Ap(c,e.numValues)}const _=d??l;switch(c.physicalType){case 4:case 3:return function(e,s,a,l,c){const u=Sp.decode(e,s),d=Tp.getVectorType(u,c,e,s),f=3===l.physicalType;if(d===Af.FLAT){const l=dm(c)?Tp.decodeNullableIntStream(e,s,u,f,c):Tp.decodeIntStream(e,s,u,f);return new qh(a.name,l,c)}if(d===Af.SEQUENCE){const l=Tp.decodeSequenceIntStream(e,s,u);return new Xh(a.name,l[0],l[1],u.numRleValues)}{const l=Tp.decodeConstIntStream(e,s,u,f);return new Yh(a.name,l,c)}}(s,a,u,c,_);case 9:return of.decode(u.name,s,a,u.nullable?e-1:e,d);case 0:return function(e,s,a,l,c){const u=Sp.decode(e,s),d=u.numValues,f=s.get(),_=dm(c)?function(e,s,a,l){const c=lm(e,Math.ceil(s/8),a),u=new Ap(c,s),d=l.size(),f=new Ap(new Uint8Array(d),d);let _=0;for(let e=0;e<l.size();e++){const s=!!l.get(e)&&u.get(_++);f.set(e,s)}return f.getBuffer()}(e,d,s,c):am(e,d,s);s.set(f+u.byteLength);const y=new Ap(_,d);return new Zp(a.name,y,c)}(s,a,u,0,_);case 6:case 5:return function(e,s,a,l,c){const u=Sp.decode(e,s),d=Tp.getVectorType(u,l,e,s),f=5===c.physicalType;if(d===Af.FLAT){const c=dm(l)?Tp.decodeNullableLongStream(e,s,u,f,l):Tp.decodeLongStream(e,s,u,f);return new Ip(a.name,c,l)}if(d===Af.SEQUENCE){const l=Tp.decodeSequenceLongStream(e,s,u);return new Mp(a.name,l[0],l[1],u.numRleValues)}{const c=Tp.decodeConstLongStream(e,s,u,f);return new Kp(a.name,c,l)}}(s,a,u,_,c);case 7:return function(e,s,a,l){const c=Sp.decode(e,s),u=dm(l)?function(e,s,a,l){const c=s.get(),u=c+l*Float32Array.BYTES_PER_ELEMENT,d=new Uint8Array(e.subarray(c,u)).buffer,f=new Float32Array(d);s.set(u);const _=a.size(),y=new Float32Array(_);let b=0;for(let e=0;e<_;e++)y[e]=a.get(e)?f[b++]:0;return y}(e,s,l,c.numValues):function(e,s,a){const l=s.get(),c=l+a*Float32Array.BYTES_PER_ELEMENT,u=new Uint8Array(e.subarray(l,c)).buffer,d=new Float32Array(u);return s.set(c),d}(e,s,c.numValues);return new Hp(a.name,u,l)}(s,a,u,_);case 8:return function(e,s,a,l){const c=Sp.decode(e,s),u=dm(l)?function(e,s,a,l){const c=s.get(),u=c+l*Float64Array.BYTES_PER_ELEMENT,d=new Uint8Array(e.subarray(c,u)).buffer,f=new Float64Array(d);s.set(u);const _=a.size(),y=new Float64Array(_);let b=0;for(let e=0;e<_;e++)y[e]=a.get(e)?f[b++]:0;return y}(e,s,l,c.numValues):function(e,s,a){const l=s.get(),c=l+a*Float64Array.BYTES_PER_ELEMENT,u=new Uint8Array(e.subarray(l,c)).buffer,d=new Float64Array(u);return s.set(c),d}(e,s,c.numValues);return new jh(a.name,u,l)}(s,a,u,_);default:throw new Error(`The specified data type for the field is currently not supported: ${c}`)}}(l,e,s,c,a.scalarType,a):1!=l?null:of.decodeSharedDictionary(e,s,a,c,u)}function dm(e){return e instanceof Ap}class cf{static decodeColumnType(e){switch(e){case 0:case 1:case 2:case 3:{const s={};s.nullable=!!(1&e),s.columnScope=0;const a={};return a.physicalType=e>1?6:4,a.type="physicalType",s.scalarType=a,s.type="scalarType",s}case 4:{const e={nullable:!1,columnScope:0},s={type:"physicalType",physicalType:0};return e.type="complexType",e.complexType=s,e}case 30:{const e={nullable:!1,columnScope:0},s={type:"physicalType",physicalType:1};return e.type="complexType",e.complexType=s,e}default:return this.mapScalarType(e)}}static columnTypeHasName(e){return e>=10}static columnTypeHasChildren(e){return 30===e}static hasStreamCount(e){if("id"===e.name)return!1;if("scalarType"===e.type){const s=e.scalarType;if("physicalType"===s.type)switch(s.physicalType){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:default:return!1;case 9:return!0}else if("logicalType"===s.type)return!1}else if("complexType"===e.type){const s=e.complexType;if("physicalType"===s.type)switch(s.physicalType){case 0:case 1:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",e),!1}static mapScalarType(e){let s=null;switch(e){case 10:case 11:s=0;break;case 12:case 13:s=1;break;case 14:case 15:s=2;break;case 16:case 17:s=3;break;case 18:case 19:s=4;break;case 20:case 21:s=5;break;case 22:case 23:s=6;break;case 24:case 25:s=7;break;case 26:case 27:s=8;break;case 28:case 29:s=9;break;default:return null}const a={};a.nullable=!!(1&e),a.columnScope=0;const l={type:"physicalType"};return l.physicalType=s,a.type="scalarType",a.scalarType=l,a}}const pm=new TextDecoder;function fm(e,s){const a=Lf(e,s,1)[0];if(0===a)return"";const l=s.get(),c=e.subarray(l,l+a);return s.add(a),pm.decode(c)}function mm(e,s){const a=Lf(e,s,1)[0]>>>0,l=!!(4&a),c=!!(2&a),u=Lf(e,s,1)[0]>>>0,d={};if(1&a&&(d.nullable=!0),c){const c={};if(l?(c.type="logicalType",c.logicalType=u):(c.type="physicalType",c.physicalType=u),8&a){const a=Lf(e,s,1)[0]>>>0;c.children=new Array(a);for(let l=0;l<a;l++)c.children[l]=mm(e,s)}d.type="complexField",d.complexField=c}else{const e={};l?(e.type="logicalType",e.logicalType=u):(e.type="physicalType",e.physicalType=u),d.type="scalarField",d.scalarField=e}return d}function _m(e,s){const a=Lf(e,s,1)[0]>>>0,l=cf.decodeColumnType(a);if(!l)throw new Error(`Unsupported column type code: ${a}`);if(cf.columnTypeHasName(a)?l.name=fm(e,s):a>=0&&a<=3?l.name="id":4===a&&(l.name="geometry"),cf.columnTypeHasChildren(a)){const a=Lf(e,s,1)[0]>>>0,c=l.complexType;c.children=new Array(a);for(let l=0;l<a;l++)c.children[l]=mm(e,s)}return l}function gm(e,s){const a={featureTables:[]},l={};l.name=fm(e,s);const c=Lf(e,s,1)[0]>>>0,u=Lf(e,s,1)[0]>>>0;l.columns=new Array(u);for(let a=0;a<u;a++)l.columns[a]=_m(e,s);return a.featureTables.push(l),[a,c]}function ym(e,s,a,l,c,u,d=!1){const f=s.scalarType.physicalType,_=Tp.getVectorType(c,u,e,a);if(4===f)switch(_){case Af.FLAT:{const s=Tp.decodeIntStream(e,a,c,!1);return new qh(l,s,u)}case Af.SEQUENCE:{const s=Tp.decodeSequenceIntStream(e,a,c);return new Xh(l,s[0],s[1],c.numRleValues)}case Af.CONST:{const s=Tp.decodeConstIntStream(e,a,c,!1);return new Yh(l,s,u)}}else switch(_){case Af.FLAT:{if(d){const s=Tp.decodeLongFloat64Stream(e,a,c,!1);return new jh(l,s,u)}const s=Tp.decodeLongStream(e,a,c,!1);return new Ip(l,s,u)}case Af.SEQUENCE:{const s=Tp.decodeSequenceLongStream(e,a,c);return new Mp(l,s[0],s[1],c.numRleValues)}case Af.CONST:{const s=Tp.decodeConstLongStream(e,a,c,!1);return new Kp(l,s,u)}}throw new Error("Vector type not supported for id column.")}class gf{constructor(e,s){var a;switch(this._featureData=e,this.properties=this._featureData.properties||{},null===(a=this._featureData.geometry)||void 0===a?void 0:a.type){case Df.POINT:case Df.MULTIPOINT:this.type=1;break;case Df.LINESTRING:case Df.MULTILINESTRING:this.type=2;break;case Df.POLYGON:case Df.MULTIPOLYGON:this.type=3;break;default:this.type=0}this.extent=s,this.id=Number(this._featureData.id)}projectPoint(e,s,a,l){return[360*(e.x+s)/l-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+a)/l)*Math.PI))-90]}projectLine(e,s,a,l){return e.map((e=>this.projectPoint(e,s,a,l)))}toGeoJSON(e,s,a){const l=this.extent*Math.pow(2,a),c=this.extent*e,u=this.extent*s,d=this.loadGeometry();let f;switch(this.type){case 1:{const e=[];for(const s of d)e.push(s[0]);const s=this.projectLine(e,c,u,l);f=1===e.length?{type:"Point",coordinates:s[0]}:{type:"MultiPoint",coordinates:s};break}case 2:{const e=d.map((e=>this.projectLine(e,c,u,l)));f=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e};break}case 3:{const e=Pn(d),s=[];for(const a of e)s.push(a.map((e=>this.projectLine(e,c,u,l))));f=1===s.length?{type:"Polygon",coordinates:s[0]}:{type:"MultiPolygon",coordinates:s};break}default:throw new Error(`unknown feature type: ${this.type}`)}const _={type:"Feature",geometry:f,properties:this.properties};return null!=this.id&&(_.id=this.id),_}loadGeometry(){const e=[];for(const s of this._featureData.geometry.coordinates){const a=[];for(const e of s)a.push(new l(e.x,e.y));e.push(a)}return e}bbox(){return[0,0,0,0]}}class xf{constructor(e){this.features=[],this.featureTable=e,this.name=e.name,this.extent=e.extent,this.version=2,this.features=e.getFeatures(),this.length=this.features.length}feature(e){return new gf(this.features[e],this.extent)}}class vf{constructor(e){this.layers={};const s=function(e,s,a=!0){const l=new Hh(0),c=[];for(;l.get()<e.length;){const u=Lf(e,l,1)[0]>>>0,d=l.get()+u;if(d>e.length)throw new Error(`Block overruns tile: ${d} > ${e.length}`);if(1!=Lf(e,l,1)[0]>>>0){l.set(d);continue}const f=gm(e,l),_=f[1],y=f[0].featureTables[0];let b=null,S=null;const P=[];let M=0;for(const c of y.columns){const u=c.name;if("id"===u){let s=null;if(c.nullable){const a=Sp.decode(e,l),c=l.get(),u=am(e,a.numValues,l);l.set(c+a.byteLength),s=new Ap(u,a.numValues)}const d=Sp.decode(e,l);M=d.getDecompressedCount(),b=ym(e,c,l,u,d,s??M,a)}else if("geometry"===u){const a=Lf(e,l,1)[0];if(0===M){const s=l.get();M=Sp.decode(e,l).getDecompressedCount(),l.set(s)}S=rm(e,a,l,M,s)}else{const s=cf.hasStreamCount(c)?Lf(e,l,1)[0]:1;if(0===s&&"scalarType"===c.type)continue;const a=um(e,l,c,s,M,void 0);a&&(Array.isArray(a)?P.push(...a):P.push(a))}}const C=new Zh(y.name,S,b,P,_);c.push(C),l.set(d)}return c}(new Uint8Array(e));this.layers=s.reduce(((e,s)=>Object.assign(Object.assign({},e),{[s.name]:new xf(s)})),{})}}class bf{constructor(e,s){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new as(oe,16,0),this.grid3D=new as(oe,16,0),this.featureIndexArray=new Va,this.promoteId=s}insert(e,s,a,l,c,u){const d=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(a,l,c);const f=u?this.grid3D:this.grid;for(let e=0;e<s.length;e++){const a=s[e],l=[1/0,1/0,-1/0,-1/0];for(let e=0;e<a.length;e++){const s=a[e];l[0]=Math.min(l[0],s.x),l[1]=Math.min(l[1],s.y),l[2]=Math.max(l[2],s.x),l[3]=Math.max(l[3],s.y)}l[0]<oe&&l[1]<oe&&l[2]>=0&&l[3]>=0&&f.insert(d,l[0],l[1],l[2],l[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers="mlt"!==this.encoding?new Eu(new pc(this.rawTileData)).layers:new vf(this.rawTileData).layers,this.sourceLayerCoder=new Rh(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(e,s,a,c){this.loadVTLayers();const u=e.params,d=oe/e.tileSize/e.scale,f=co(u.filter,u.globalState),_=e.queryGeometry,y=e.queryPadding*d,b=Oh.fromPoints(_),S=this.grid.query(b.minX-y,b.minY-y,b.maxX+y,b.maxY+y),P=Oh.fromPoints(e.cameraQueryGeometry).expandBy(y),M=this.grid3D.query(P.minX,P.minY,P.maxX,P.maxY,((s,a,c,u)=>function(e,s,a,c,u){for(const l of e)if(s<=l.x&&a<=l.y&&c>=l.x&&u>=l.y)return!0;const d=[new l(s,a),new l(s,u),new l(c,u),new l(c,a)];if(e.length>2)for(const s of d)if(rh(e,s))return!0;for(let s=0;s<e.length-1;s++)if(nh(e[s],e[s+1],d))return!0;return!1}(e.cameraQueryGeometry,s-y,a-y,c+y,u+y)));for(const e of M)S.push(e);S.sort(vm);const C={};let D;for(let l=0;l<S.length;l++){const y=S[l];if(y===D)continue;D=y;const b=this.featureIndexArray.get(y);let P=null;this.loadMatchingFeature(C,b.bucketIndex,b.sourceLayerIndex,b.featureIndex,f,u.layers,u.availableImages,s,a,c,((s,a,l)=>(P||(P=Zc(s)),a.queryIntersectsFeature({queryGeometry:_,feature:s,featureState:l,geometry:P,zoom:this.z,transform:e.transform,pixelsToTileUnits:d,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation}))))}return C}loadMatchingFeature(e,s,a,l,c,u,d,f,_,y,b){const S=this.bucketLayerIDs[s];if(u&&!S.some((e=>u.has(e))))return;const P=this.sourceLayerCoder.decode(a),M=this.vtLayers[P].feature(l);if(c.needGeometry){const e=qc(M,!0);if(!c.filter(new Es(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!c.filter(new Es(this.tileID.overscaledZ),M))return;const C=this.getId(M,P);for(let s=0;s<S.length;s++){const a=S[s];if(u&&!u.has(a))continue;const c=f[a];if(!c)continue;let P={};C&&y&&(P=y.getState(c.sourceLayer||"_geojsonTileLayer",C));const D=Se({},_[a]);D.paint=xm(D.paint,c.paint,M,P,d),D.layout=xm(D.layout,c.layout,M,P,d);const L=!b||b(M,c,P);if(!L)continue;const F=new Nh(M,this.z,this.x,this.y,C);F.layer=D;let B=e[a];void 0===B&&(B=e[a]=[]),B.push({featureIndex:l,feature:F,intersectionZ:L})}}lookupSymbolFeatures(e,s,a,l,c,u,d,f){const _={};this.loadVTLayers();const y=co(c.filterSpec,c.globalState);for(const c of e)this.loadMatchingFeature(_,a,l,c,y,u,d,f,s);return _}hasLayer(e){for(const s of this.bucketLayerIDs)for(const a of s)if(e===a)return!0;return!1}getId(e,s){var a;let l=e.id;return this.promoteId&&(l=e.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[s]],"boolean"==typeof l&&(l=Number(l)),void 0===l&&(null===(a=e.properties)||void 0===a?void 0:a.cluster)&&this.promoteId&&(l=Number(e.properties.cluster_id))),l}}function xm(e,s,a,l,c){return Ee(e,((e,u)=>{const d=s instanceof Ls?s.get(u):null;return d&&d.evaluate?d.evaluate(a,l,c):d}))}function vm(e,s){return s-e}function bm(e,s,a,c,u){const d=[];for(let f=0;f<e.length;f++){const _=e[f];let y;for(let e=0;e<_.length-1;e++){let f=_[e],b=_[e+1];f.x<s&&b.x<s||(f.x<s?f=new l(s,f.y+(s-f.x)/(b.x-f.x)*(b.y-f.y))._round():b.x<s&&(b=new l(s,f.y+(s-f.x)/(b.x-f.x)*(b.y-f.y))._round()),f.y<a&&b.y<a||(f.y<a?f=new l(f.x+(a-f.y)/(b.y-f.y)*(b.x-f.x),a)._round():b.y<a&&(b=new l(f.x+(a-f.y)/(b.y-f.y)*(b.x-f.x),a)._round()),f.x>=c&&b.x>=c||(f.x>=c?f=new l(c,f.y+(c-f.x)/(b.x-f.x)*(b.y-f.y))._round():b.x>=c&&(b=new l(c,f.y+(c-f.x)/(b.x-f.x)*(b.y-f.y))._round()),f.y>=u&&b.y>=u||(f.y>=u?f=new l(f.x+(u-f.y)/(b.y-f.y)*(b.x-f.x),u)._round():b.y>=u&&(b=new l(f.x+(u-f.y)/(b.y-f.y)*(b.x-f.x),u)._round()),y&&f.equals(y[y.length-1])||(y=[f],d.push(y)),y.push(b)))))}}return d}function wm(e,s,a,l,c){switch(s){case 1:return function(e,s,a,l){const c=[];for(const u of e)for(const e of u){const u=0===l?e.x:e.y;u>=s&&u<=a&&c.push([e])}return c}(e,a,l,c);case 2:return Sm(e,a,l,c,!1);case 3:return Sm(e,a,l,c,!0)}return[]}function Tm(e,s,a,c,u){const d=0===c?Pm:Im;let f=[];const _=[];for(let l=0;l<e.length-1;l++){const y=e[l],b=e[l+1],S=0===c?y.x:y.y,P=0===c?b.x:b.y;let M=!1;S<s?P>s&&f.push(d(y,b,s)):S>a?P<a&&f.push(d(y,b,a)):f.push(y),P<s&&S>=s&&(f.push(d(y,b,s)),M=!0),P>a&&S<=a&&(f.push(d(y,b,a)),M=!0),!u&&M&&(_.push(f),f=[])}const y=e.length-1,b=0===c?e[y].x:e[y].y;return b>=s&&b<=a&&f.push(e[y]),u&&f.length>0&&!f[0].equals(f[f.length-1])&&f.push(new l(f[0].x,f[0].y)),f.length>0&&_.push(f),_}function Sm(e,s,a,l,c){const u=[];for(const d of e){const e=Tm(d,s,a,l,c);e.length>0&&u.push(...e)}return u}function Pm(e,s,a){return new l(a,e.y+(a-e.x)/(s.x-e.x)*(s.y-e.y))}function Im(e,s,a){return new l(e.x+(a-e.y)/(s.y-e.y)*(s.x-e.x),a)}ql("FeatureIndex",bf,{omit:["rawTileData","sourceLayerCoder"]});class kf extends l{constructor(e,s,a,l){super(e,s),this.angle=a,void 0!==l&&(this.segment=l)}clone(){return new kf(this.x,this.y,this.angle,this.segment)}}function Mm(e,s,a,l,c){if(void 0===s.segment||0===a)return!0;let u=s,d=s.segment+1,f=0;for(;f>-a/2;){if(d--,d<0)return!1;f-=e[d].dist(u),u=e[d]}f+=e[d].dist(e[d+1]),d++;const _=[];let y=0;for(;f<a/2;){const s=e[d],a=e[d+1];if(!a)return!1;let u=e[d-1].angleTo(s)-s.angleTo(a);for(u=Math.abs((u+3*Math.PI)%(2*Math.PI)-Math.PI),_.push({distance:f,angleDelta:u}),y+=u;f-_[0].distance>l;)y-=_.shift().angleDelta;if(y>c)return!1;d++,f+=s.dist(a)}return!0}function Em(e){let s=0;for(let a=0;a<e.length-1;a++)s+=e[a].dist(e[a+1]);return s}function Cm(e,s,a){return e?.6*s*a:0}function Am(e,s){return Math.max(e?e.right-e.left:0,s?s.right-s.left:0)}function Dm(e,s,a,l,c,u){const d=Cm(a,c,u),f=Am(a,l)*u;let _=0;const y=Em(e)/2;for(let a=0;a<e.length-1;a++){const l=e[a],c=e[a+1],u=l.dist(c);if(_+u>y){const b=(y-_)/u,S=Or.number(l.x,c.x,b),P=Or.number(l.y,c.y,b),M=new kf(S,P,c.angleTo(l),a);return M._round(),!d||Mm(e,M,f,d,s)?M:void 0}_+=u}}function zm(e,s,a,l,c,u,d,f,_){const y=Cm(l,u,d),b=Am(l,c),S=b*d,P=0===e[0].x||e[0].x===_||0===e[0].y||e[0].y===_;return s-S<s/4&&(s=S+s/4),km(e,P?s/2*f%s:(b/2+2*u)*d*f%s,s,y,a,S,P,!1,_)}function km(e,s,a,l,c,u,d,f,_){const y=u/2,b=Em(e);let S=0,P=s-a,M=[];for(let s=0;s<e.length-1;s++){const d=e[s],f=e[s+1],C=d.dist(f),D=f.angleTo(d);for(;P+a<S+C;){P+=a;const L=(P-S)/C,F=Or.number(d.x,f.x,L),B=Or.number(d.y,f.y,L);if(F>=0&&F<_&&B>=0&&B<_&&P-y>=0&&P+y<=b){const a=new kf(F,B,D,s);a._round(),l&&!Mm(e,a,u,l,c)||M.push(a)}}S+=C}return f||M.length||d||(M=km(e,S/2,a,l,c,u,d,!0,_)),M}function Rm(e,s,a,c){const u=[],d=e.image,f=d.pixelRatio,_=d.paddedRect.w-2,y=d.paddedRect.h-2;let b={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom};const S=d.stretchX||[[0,_]],P=d.stretchY||[[0,y]],M=(e,s)=>e+s[1]-s[0],C=S.reduce(M,0),D=P.reduce(M,0),L=_-C,F=y-D;let B=0,O=C,V=0,N=D,j=0,G=L,Z=0,q=F;if(d.content&&c){const s=d.content,a=s[2]-s[0],l=s[3]-s[1];(d.textFitWidth||d.textFitHeight)&&(b=xp(e)),B=Lm(S,0,s[0]),V=Lm(P,0,s[1]),O=Lm(S,s[0],s[2]),N=Lm(P,s[1],s[3]),j=s[0]-B,Z=s[1]-V,G=a-O,q=l-N}const W=b.x1,J=b.y1,Q=b.x2-W,se=b.y2-J,oe=(e,c,u,_)=>{const y=Bm(e.stretch-B,O,Q,W),b=Om(e.fixed-j,G,e.stretch,C),S=Bm(c.stretch-V,N,se,J),P=Om(c.fixed-Z,q,c.stretch,D),M=Bm(u.stretch-B,O,Q,W),L=Om(u.fixed-j,G,u.stretch,C),F=Bm(_.stretch-V,N,se,J),oe=Om(_.fixed-Z,q,_.stretch,D),ce=new l(y,S),pe=new l(M,S),fe=new l(M,F),xe=new l(y,F),ve=new l(b/f,P/f),be=new l(L/f,oe/f),we=s*Math.PI/180;if(we){const e=Math.sin(we),s=Math.cos(we),a=[s,-e,e,s];ce._matMult(a),pe._matMult(a),xe._matMult(a),fe._matMult(a)}const Te=e.stretch+e.fixed,Se=c.stretch+c.fixed;return{tl:ce,tr:pe,bl:xe,br:fe,tex:{x:d.paddedRect.x+1+Te,y:d.paddedRect.y+1+Se,w:u.stretch+u.fixed-Te,h:_.stretch+_.fixed-Se},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:ve,pixelOffsetBR:be,minFontScaleX:G/f/Q,minFontScaleY:q/f/se,isSDF:a}};if(c&&(d.stretchX||d.stretchY)){const e=Fm(S,L,C),s=Fm(P,F,D);for(let a=0;a<e.length-1;a++){const l=e[a],c=e[a+1];for(let e=0;e<s.length-1;e++)u.push(oe(l,s[e],c,s[e+1]))}}else u.push(oe({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:_+1},{fixed:0,stretch:y+1}));return u}function Lm(e,s,a){let l=0;for(const c of e)l+=Math.max(s,Math.min(a,c[1]))-Math.max(s,Math.min(a,c[0]));return l}function Fm(e,s,a){const l=[{fixed:-1,stretch:0}];for(const[s,a]of e){const e=l[l.length-1];l.push({fixed:s-e.stretch,stretch:e.stretch}),l.push({fixed:s-e.stretch,stretch:e.stretch+(a-s)})}return l.push({fixed:s+1,stretch:a}),l}function Bm(e,s,a,l){return e/s*a+l}function Om(e,s,a,l){return e-s*a/l}ql("Anchor",kf);class Uf{constructor(e,s,a,c,u,d,f,_,y,b){var S;if(this.boxStartIndex=e.length,y){let e=d.top,s=d.bottom;const a=d.collisionPadding;a&&(e-=a[1],s+=a[3]);let l=s-e;l>0&&(l=Math.max(10,l),this.circleDiameter=l)}else{const y=(null===(S=d.image)||void 0===S?void 0:S.content)&&(d.image.textFitWidth||d.image.textFitHeight)?xp(d):{x1:d.left,y1:d.top,x2:d.right,y2:d.bottom};y.y1=y.y1*f-_[0],y.y2=y.y2*f+_[2],y.x1=y.x1*f-_[3],y.x2=y.x2*f+_[1];const P=d.collisionPadding;if(P&&(y.x1-=P[0]*f,y.y1-=P[1]*f,y.x2+=P[2]*f,y.y2+=P[3]*f),b){const e=new l(y.x1,y.y1),s=new l(y.x2,y.y1),a=new l(y.x1,y.y2),c=new l(y.x2,y.y2),u=b*Math.PI/180;e._rotate(u),s._rotate(u),a._rotate(u),c._rotate(u),y.x1=Math.min(e.x,s.x,a.x,c.x),y.x2=Math.max(e.x,s.x,a.x,c.x),y.y1=Math.min(e.y,s.y,a.y,c.y),y.y2=Math.max(e.y,s.y,a.y,c.y)}e.emplaceBack(s.x,s.y,y.x1,y.y1,y.x2,y.y2,a,c,u)}this.boxEndIndex=e.length}}class qf{constructor(e=[],s=(e,s)=>e<s?-1:e>s?1:0){if(this.data=e,this.length=this.data.length,this.compare=s,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],s=this.data.pop();return--this.length>0&&(this.data[0]=s,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:s,compare:a}=this,l=s[e];for(;e>0;){const c=e-1>>1,u=s[c];if(a(l,u)>=0)break;s[e]=u,e=c}s[e]=l}_down(e){const{data:s,compare:a}=this,l=this.length>>1,c=s[e];for(;e<l;){let l=1+(e<<1);const u=l+1;if(u<this.length&&a(s[u],s[l])<0&&(l=u),a(s[l],c)>=0)break;s[e]=s[l],e=l}s[e]=c}}function Vm(e,s=1,a=!1){const c=Oh.fromPoints(e[0]),u=Math.min(c.width(),c.height());let d=u/2;const f=new qf([],Nm),{minX:_,minY:y,maxX:b,maxY:S}=c;if(0===u)return new l(_,y);for(let s=_;s<b;s+=u)for(let a=y;a<S;a+=u)f.push(new jm(s+d,a+d,d,e));let P=function(e){let s=0,a=0,l=0;const c=e[0];for(let e=0,u=c.length,d=u-1;e<u;d=e++){const u=c[e],f=c[d],_=u.x*f.y-f.x*u.y;a+=(u.x+f.x)*_,l+=(u.y+f.y)*_,s+=3*_}return new jm(a/s,l/s,0,e)}(e),M=f.length;for(;f.length;){const l=f.pop();(l.d>P.d||!P.d)&&(P=l,a&&console.log("found best %d after %d probes",Math.round(1e4*l.d)/1e4,M)),l.max-P.d<=s||(d=l.h/2,f.push(new jm(l.p.x-d,l.p.y-d,d,e)),f.push(new jm(l.p.x+d,l.p.y-d,d,e)),f.push(new jm(l.p.x-d,l.p.y+d,d,e)),f.push(new jm(l.p.x+d,l.p.y+d,d,e)),M+=4)}return a&&(console.log(`num probes: ${M}`),console.log(`best distance: ${P.d}`)),P.p}function Nm(e,s){return s.max-e.max}function jm(s,a,c,u){(this||e).p=new l(s,a),(this||e).h=c,(this||e).d=function(e,s){let a=!1,l=1/0;for(let c=0;c<s.length;c++){const u=s[c];for(let s=0,c=u.length,d=c-1;s<c;d=s++){const c=u[s],f=u[d];c.y>e.y!=f.y>e.y&&e.x<(f.x-c.x)*(e.y-c.y)/(f.y-c.y)+c.x&&(a=!a),l=Math.min(l,th(e,c,f))}}return(a?1:-1)*Math.sqrt(l)}((this||e).p,u),(this||e).max=(this||e).d+(this||e).h*Math.SQRT2}var Um;s.aJ=void 0,(Um=s.aJ||(s.aJ={}))[Um.center=1]="center",Um[Um.left=2]="left",Um[Um.right=3]="right",Um[Um.top=4]="top",Um[Um.bottom=5]="bottom",Um[Um["top-left"]=6]="top-left",Um[Um["top-right"]=7]="top-right",Um[Um["bottom-left"]=8]="bottom-left",Um[Um["bottom-right"]=9]="bottom-right";const Gm=Number.POSITIVE_INFINITY;function Zm(e,s){return s[1]!==Gm?function(e,s,a){let l=0,c=0;switch(s=Math.abs(s),a=Math.abs(a),e){case"top-right":case"top-left":case"top":c=a-7;break;case"bottom-right":case"bottom-left":case"bottom":c=7-a}switch(e){case"top-right":case"bottom-right":case"right":l=-s;break;case"top-left":case"bottom-left":case"left":l=s}return[l,c]}(e,s[0],s[1]):function(e,s){let a=0,l=0;s<0&&(s=0);const c=s/Math.SQRT2;switch(e){case"top-right":case"top-left":l=c-7;break;case"bottom-right":case"bottom-left":l=7-c;break;case"bottom":l=7-s;break;case"top":l=s-7}switch(e){case"top-right":case"bottom-right":a=-c;break;case"top-left":case"bottom-left":a=c;break;case"left":a=s;break;case"right":a=-s}return[a,l]}(e,s[0])}function qm(e,s,a){var l;const c=e.layout,u=null===(l=c.get("text-variable-anchor-offset"))||void 0===l?void 0:l.evaluate(s,{},a);if(u){const e=u.values,s=[];for(let a=0;a<e.length;a+=2){const l=s[a]=e[a],c=e[a+1].map((e=>e*kd));l.startsWith("top")?c[1]-=7:l.startsWith("bottom")&&(c[1]+=7),s[a+1]=c}return new Ct(s)}const d=c.get("text-variable-anchor");if(d){let l;l=void 0!==e._unevaluatedLayout.getValue("text-radial-offset")?[c.get("text-radial-offset").evaluate(s,{},a)*kd,Gm]:c.get("text-offset").evaluate(s,{},a).map((e=>e*kd));const u=[];for(const e of d)u.push(e,Zm(e,l));return new Ct(u)}return null}function $m(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Wm(e,a,l,c,u,d,f,_,y,b,S,P){let M=d.textMaxSize.evaluate(a,{});void 0===M&&(M=f);const C=e.layers[0].layout,D=C.get("icon-offset").evaluate(a,{},S),L=Xm(l.horizontal),F=f/24,B=e.tilePixelRatio*F,O=e.tilePixelRatio*M/24,V=e.tilePixelRatio*_,N=e.tilePixelRatio*C.get("symbol-spacing"),j=C.get("text-padding")*e.tilePixelRatio,G=function(e,s,a,l=1){const c=e.get("icon-padding").evaluate(s,{},a),u=c&&c.values;return[u[0]*l,u[1]*l,u[2]*l,u[3]*l]}(C,a,S,e.tilePixelRatio),Z=C.get("text-max-angle")/180*Math.PI,q="viewport"!==C.get("text-rotation-alignment")&&"point"!==C.get("symbol-placement"),W="map"===C.get("icon-rotation-alignment")&&"point"!==C.get("symbol-placement"),J=C.get("symbol-placement"),Q=N/2,se=C.get("icon-text-fit");let ce;c&&"none"!==se&&(e.allowVerticalPlacement&&l.vertical&&(ce=vp(c,l.vertical,se,C.get("icon-text-fit-padding"),D,F)),L&&(c=vp(c,L,se,C.get("icon-text-fit-padding"),D,F)));const pe=S?P.line.getGranularityForZoomLevel(S.z):1,fe=(_,P)=>{P.x<0||P.x>=oe||P.y<0||P.y>=oe||function(e,a,l,c,u,d,f,_,y,b,S,P,M,C,D,L,F,B,O,V,N,j,G,Z,q){const W=e.addToLineVertexArray(a,l);let J,Q,se,oe,ce=0,pe=0,fe=0,xe=0,ve=-1,be=-1;const we={};let Te=Dc("");if(e.allowVerticalPlacement&&c.vertical){const e=_.layout.get("text-rotate").evaluate(N,{},Z)+90;se=new Uf(y,a,b,S,P,c.vertical,M,C,D,e),f&&(oe=new Uf(y,a,b,S,P,f,F,B,D,e))}if(u){const l=_.layout.get("icon-rotate").evaluate(N,{}),c="none"!==_.layout.get("icon-text-fit"),d=Rm(u,l,G,c),M=f?Rm(f,l,G,c):void 0;Q=new Uf(y,a,b,S,P,u,F,B,!1,l),ce=4*d.length;const C=e.iconSizeData;let D=null;"source"===C.kind?(D=[Pp*_.layout.get("icon-size").evaluate(N,{})],D[0]>Cp&&Le(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===C.kind&&(D=[Pp*j.compositeIconSizes[0].evaluate(N,{},Z),Pp*j.compositeIconSizes[1].evaluate(N,{},Z)],(D[0]>Cp||D[1]>Cp)&&Le(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,d,D,V,O,N,s.at.none,a,W.lineStartIndex,W.lineLength,-1,Z),ve=e.icon.placedSymbolArray.length-1,M&&(pe=4*M.length,e.addSymbols(e.icon,M,D,V,O,N,s.at.vertical,a,W.lineStartIndex,W.lineLength,-1,Z),be=e.icon.placedSymbolArray.length-1)}const Se=Object.keys(c.horizontal);for(const l of Se){const u=c.horizontal[l];if(!J){Te=Dc(u.text);const e=_.layout.get("text-rotate").evaluate(N,{},Z);J=new Uf(y,a,b,S,P,u,M,C,D,e)}const f=1===u.positionedLines.length;if(fe+=Hm(e,a,u,d,_,D,N,L,W,c.vertical?s.at.horizontal:s.at.horizontalOnly,f?Se:[l],we,ve,j,Z),f)break}c.vertical&&(xe+=Hm(e,a,c.vertical,d,_,D,N,L,W,s.at.vertical,["vertical"],we,be,j,Z));const Me=J?J.boxStartIndex:e.collisionBoxArray.length,Ee=J?J.boxEndIndex:e.collisionBoxArray.length,Ce=se?se.boxStartIndex:e.collisionBoxArray.length,Ae=se?se.boxEndIndex:e.collisionBoxArray.length,ke=Q?Q.boxStartIndex:e.collisionBoxArray.length,Fe=Q?Q.boxEndIndex:e.collisionBoxArray.length,Oe=oe?oe.boxStartIndex:e.collisionBoxArray.length,Ve=oe?oe.boxEndIndex:e.collisionBoxArray.length;let Ne=-1;const je=(e,s)=>e&&e.circleDiameter?Math.max(e.circleDiameter,s):s;Ne=je(J,Ne),Ne=je(se,Ne),Ne=je(Q,Ne),Ne=je(oe,Ne);const Ue=Ne>-1?1:0;Ue&&(Ne*=q/kd),e.glyphOffsetArray.length>=uh.MAX_GLYPHS&&Le("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==N.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,N.sortKey);const Ge=qm(_,N,Z),[Ze,qe]=function(e,a){const l=e.length,c=null==a?void 0:a.values;if((null==c?void 0:c.length)>0)for(let a=0;a<c.length;a+=2){const l=c[a+1];e.emplaceBack(s.aJ[c[a]],l[0],l[1])}return[l,e.length]}(e.textAnchorOffsets,Ge);e.symbolInstances.emplaceBack(a.x,a.y,we.right>=0?we.right:-1,we.center>=0?we.center:-1,we.left>=0?we.left:-1,we.vertical||-1,ve,be,Te,Me,Ee,Ce,Ae,ke,Fe,Oe,Ve,b,fe,xe,ce,pe,Ue,0,M,Ne,Ze,qe)}(e,P,_,l,c,u,ce,e.layers[0],e.collisionBoxArray,a.index,a.sourceLayerIndex,e.index,B,[j,j,j,j],q,y,V,G,W,D,a,d,b,S,f)};if("line"===J)for(const s of bm(a.geometry,0,0,oe,oe)){const a=Uu(s,pe),u=zm(a,N,Z,l.vertical||L,c,24,O,e.overscaling,oe);for(const s of u)L&&Ym(e,L.text,Q,s)||fe(a,s)}else if("line-center"===J){for(const e of a.geometry)if(e.length>1){const s=Uu(e,pe),a=Dm(s,Z,l.vertical||L,c,24,O);a&&fe(s,a)}}else if("Polygon"===a.type)for(const e of Pn(a.geometry,0)){const s=Vm(e,16);fe(Uu(e[0],pe,!0),new kf(s.x,s.y,0))}else if("LineString"===a.type)for(const e of a.geometry){const s=Uu(e,pe);fe(s,new kf(s[0].x,s[0].y,0))}else if("Point"===a.type)for(const e of a.geometry)for(const s of e)fe([s],new kf(s.x,s.y,0))}function Hm(e,s,a,c,u,d,f,_,y,b,S,P,M,C,D){const L=function(e,s,a,c,u,d,f,_){const y=c.layout.get("text-rotate").evaluate(d,{})*Math.PI/180,b=[];for(const e of s.positionedLines)for(const c of e.positionedGlyphs){if(!c.rect)continue;const d=c.rect||{};let S=4,P=!0,M=1,C=0;const D=(u||_)&&c.vertical,L=c.metrics.advance*c.scale/2;if(_&&s.verticalizable&&(C=e.lineOffset/2-(c.imageName?-(kd-c.metrics.width*c.scale)/2:(c.scale-1)*kd)),c.imageName){const e=f[c.imageName];P=e.sdf,M=e.pixelRatio,S=1/M}const F=u?[c.x+L,c.y]:[0,0];let B=u?[0,0]:[c.x+L+a[0],c.y+a[1]-C],O=[0,0];D&&(O=B,B=[0,0]);const V=c.metrics.isDoubleResolution?2:1,N=(c.metrics.left-S)*c.scale-L+B[0],j=(-c.metrics.top-S)*c.scale+B[1],G=N+d.w/V*c.scale/M,Z=j+d.h/V*c.scale/M,q=new l(N,j),W=new l(G,j),J=new l(N,Z),Q=new l(G,Z);if(D){const e=new l(-L,L- -17),s=-Math.PI/2,a=12-L,u=new l(22-a,-(c.imageName?a:0)),d=new l(...O);q._rotateAround(s,e)._add(u)._add(d),W._rotateAround(s,e)._add(u)._add(d),J._rotateAround(s,e)._add(u)._add(d),Q._rotateAround(s,e)._add(u)._add(d)}if(y){const e=Math.sin(y),s=Math.cos(y),a=[s,-e,e,s];q._matMult(a),W._matMult(a),J._matMult(a),Q._matMult(a)}const se=new l(0,0),oe=new l(0,0);b.push({tl:q,tr:W,bl:J,br:Q,tex:d,writingMode:s.writingMode,glyphOffset:F,sectionIndex:c.sectionIndex,isSDF:P,pixelOffsetTL:se,pixelOffsetBR:oe,minFontScaleX:0,minFontScaleY:0})}return b}(0,a,_,u,d,f,c,e.allowVerticalPlacement),F=e.textSizeData;let B=null;"source"===F.kind?(B=[Pp*u.layout.get("text-size").evaluate(f,{})],B[0]>Cp&&Le(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===F.kind&&(B=[Pp*C.compositeTextSizes[0].evaluate(f,{},D),Pp*C.compositeTextSizes[1].evaluate(f,{},D)],(B[0]>Cp||B[1]>Cp)&&Le(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,L,B,_,d,f,b,s,y.lineStartIndex,y.lineLength,M,D);for(const s of S)P[s]=e.text.placedSymbolArray.length-1;return 4*L.length}function Xm(e){for(const s in e)return e[s];return null}function Ym(e,s,a,l){const c=e.compareText;if(s in c){const e=c[s];for(let s=e.length-1;s>=0;s--)if(l.dist(e[s])<a)return!0}else c[s]=[];return c[s].push(l),!1}const Km=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class nd{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[s,a]=new Uint8Array(e,0,2);if(219!==s)throw new Error("Data does not appear to be in a KDBush format.");const l=a>>4;if(1!==l)throw new Error(`Got v${l} data when expected v1.`);const c=Km[15&a];if(!c)throw new Error("Unrecognized array type.");const[u]=new Uint16Array(e,2,1),[d]=new Uint32Array(e,4,1);return new nd(d,u,c,e)}constructor(e,s=64,a=Float64Array,l){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+s,2),65535),this.ArrayType=a,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const c=Km.indexOf(this.ArrayType),u=2*e*this.ArrayType.BYTES_PER_ELEMENT,d=e*this.IndexArrayType.BYTES_PER_ELEMENT,f=(8-d%8)%8;if(c<0)throw new Error(`Unexpected typed array class: ${a}.`);l&&l instanceof ArrayBuffer?(this.data=l,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+d+f,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+u+d+f),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+d+f,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+c]),new Uint16Array(this.data,2,1)[0]=s,new Uint32Array(this.data,4,1)[0]=e)}add(e,s){const a=this._pos>>1;return this.ids[a]=a,this.coords[this._pos++]=e,this.coords[this._pos++]=s,a}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return Jm(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,s,a,l){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:c,coords:u,nodeSize:d}=this,f=[0,c.length-1,0],_=[];for(;f.length;){const y=f.pop()||0,b=f.pop()||0,S=f.pop()||0;if(b-S<=d){for(let d=S;d<=b;d++){const f=u[2*d],y=u[2*d+1];f>=e&&f<=a&&y>=s&&y<=l&&_.push(c[d])}continue}const P=S+b>>1,M=u[2*P],C=u[2*P+1];M>=e&&M<=a&&C>=s&&C<=l&&_.push(c[P]),(0===y?e<=M:s<=C)&&(f.push(S),f.push(P-1),f.push(1-y)),(0===y?a>=M:l>=C)&&(f.push(P+1),f.push(b),f.push(1-y))}return _}within(e,s,a){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:l,coords:c,nodeSize:u}=this,d=[0,l.length-1,0],f=[],_=a*a;for(;d.length;){const y=d.pop()||0,b=d.pop()||0,S=d.pop()||0;if(b-S<=u){for(let a=S;a<=b;a++)i_(c[2*a],c[2*a+1],e,s)<=_&&f.push(l[a]);continue}const P=S+b>>1,M=c[2*P],C=c[2*P+1];i_(M,C,e,s)<=_&&f.push(l[P]),(0===y?e-a<=M:s-a<=C)&&(d.push(S),d.push(P-1),d.push(1-y)),(0===y?e+a>=M:s+a>=C)&&(d.push(P+1),d.push(b),d.push(1-y))}return f}}function Jm(e,s,a,l,c,u){if(c-l<=a)return;const d=l+c>>1;Qm(e,s,d,l,c,u),Jm(e,s,a,l,d-1,1-u),Jm(e,s,a,d+1,c,1-u)}function Qm(e,s,a,l,c,u){for(;c>l;){if(c-l>600){const d=c-l+1,f=a-l+1,_=Math.log(d),y=.5*Math.exp(2*_/3),b=.5*Math.sqrt(_*y*(d-y)/d)*(f-d/2<0?-1:1);Qm(e,s,a,Math.max(l,Math.floor(a-f*y/d+b)),Math.min(c,Math.floor(a+(d-f)*y/d+b)),u)}const d=s[2*a+u];let f=l,_=c;for(e_(e,s,l,a),s[2*c+u]>d&&e_(e,s,l,c);f<_;){for(e_(e,s,f,_),f++,_--;s[2*f+u]<d;)f++;for(;s[2*_+u]>d;)_--}s[2*l+u]===d?e_(e,s,l,_):(_++,e_(e,s,_,c)),_<=a&&(l=_+1),a<=_&&(c=_-1)}}function e_(e,s,a,l){t_(e,a,l),t_(s,2*a,2*l),t_(s,2*a+1,2*l+1)}function t_(e,s,a){const l=e[s];e[s]=e[a],e[a]=l}function i_(e,s,a,l){const c=e-a,u=s-l;return c*c+u*u}var r_;s.cB=void 0,(r_=s.cB||(s.cB={})).create="create",r_.load="load",r_.fullLoad="fullLoad";let n_=null,s_=[];const o_=1e3/60,a_="loadTime",l_="fullLoadTime",c_={mark(e){performance.mark(e)},frame(e){const s=e;null!=n_&&s_.push(s-n_),n_=s},clearMetrics(){n_=null,s_=[],performance.clearMeasures(a_),performance.clearMeasures(l_);for(const e in s.cB)performance.clearMarks(s.cB[e])},getPerformanceMetrics(){performance.measure(a_,s.cB.create,s.cB.load),performance.measure(l_,s.cB.create,s.cB.fullLoad);const e=performance.getEntriesByName(a_)[0].duration,a=performance.getEntriesByName(l_)[0].duration,l=s_.length,c=1/(s_.reduce(((e,s)=>e+s),0)/l/1e3),u=s_.filter((e=>e>o_)).reduce(((e,s)=>e+(s-o_)/o_),0);return{loadTime:e,fullLoadTime:a,fps:c,percentDroppedFrames:u/(l+u)*100,totalFrames:l}}};s.$=Ue,s.A=C,s.B=Ol,s.C=function([e,s,a]){return s+=90,s*=Math.PI/180,a*=Math.PI/180,{x:e*Math.cos(s)*Math.sin(a),y:e*Math.sin(s)*Math.sin(a),z:e*Math.cos(a)}},s.D=Os,s.E=ge,s.F=Or,s.G=Es,s.H=Nl,s.I=Ec,s.J=function(e){if(null==Ve){const s=e.navigator?e.navigator.userAgent:null;Ve=!!e.safari||!(!s||!(/\b(iPad|iPhone|iPod)\b/.test(s)||s.match("Safari")&&!s.match("Chrome")))}return Ve},s.K=class{constructor(e,s){this.target=e,this.mapId=s,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new vh((()=>this.process())),this.subscription=qe(this.target,"message",(e=>this.receive(e)),!1),this.globalScope=Oe(self)?e:window}registerMessageHandler(e,s){this.messageHandlers[e]=s}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,s){return new Promise(((a,l)=>{const c=Math.round(1e18*Math.random()).toString(36).substring(0,10),u=s?qe(s.signal,"abort",(()=>{null==u||u.unsubscribe(),delete this.resolveRejects[c];const s={id:c,type:"<cancel>",origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(s)}),ef):null;this.resolveRejects[c]={resolve:e=>{null==u||u.unsubscribe(),a(e)},reject:e=>{null==u||u.unsubscribe(),l(e)}};const d=[],f=Object.assign(Object.assign({},e),{id:c,sourceMapId:this.mapId,origin:location.origin,data:Xl(e.data,d)});this.target.postMessage(f,{transfer:d})}))}receive(e){const s=e.data,a=s.id;if(!("file://"!==s.origin&&"file://"!==location.origin&&"resource://android"!==s.origin&&"resource://android"!==location.origin&&s.origin!==location.origin||s.targetMapId&&this.mapId!==s.targetMapId)){if("<cancel>"===s.type){delete this.tasks[a];const e=this.abortControllers[a];return delete this.abortControllers[a],void(e&&e.abort())}if(Oe(self)||s.mustQueue)return this.tasks[a]=s,this.taskQueue.push(a),void this.invoker.trigger();this.processTask(a,s)}}process(){if(0===this.taskQueue.length)return;const e=this.taskQueue.shift(),s=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),s&&this.processTask(e,s)}processTask(e,s){return a(this,void 0,void 0,(function*(){if("<response>"===s.type){const a=this.resolveRejects[e];if(delete this.resolveRejects[e],!a)return;return void(s.error?a.reject(Yl(s.error)):a.resolve(Yl(s.data)))}if(!this.messageHandlers[s.type])return void this.completeTask(e,new Error(`Could not find a registered handler for ${s.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const a=Yl(s.data),l=new AbortController;this.abortControllers[e]=l;try{const c=yield this.messageHandlers[s.type](s.sourceMapId,a,l);this.completeTask(e,null,c)}catch(a){this.completeTask(e,a)}}))}completeTask(e,s,a){const l=[];delete this.abortControllers[e];const c={id:e,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:s?Xl(s):null,data:Xl(a,l)};this.target.postMessage(c,{transfer:l})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},s.L=et,s.M=function(){var e=new C(16);return C!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},s.N=function(e,s,a){var l,c,u,d,f,_,y,b,S,P,M,C,D=a[0],L=a[1],F=a[2];return s===e?(e[12]=s[0]*D+s[4]*L+s[8]*F+s[12],e[13]=s[1]*D+s[5]*L+s[9]*F+s[13],e[14]=s[2]*D+s[6]*L+s[10]*F+s[14],e[15]=s[3]*D+s[7]*L+s[11]*F+s[15]):(c=s[1],u=s[2],d=s[3],f=s[4],_=s[5],y=s[6],b=s[7],S=s[8],P=s[9],M=s[10],C=s[11],e[0]=l=s[0],e[1]=c,e[2]=u,e[3]=d,e[4]=f,e[5]=_,e[6]=y,e[7]=b,e[8]=S,e[9]=P,e[10]=M,e[11]=C,e[12]=l*D+f*L+S*F+s[12],e[13]=c*D+_*L+P*F+s[13],e[14]=u*D+y*L+M*F+s[14],e[15]=d*D+b*L+C*F+s[15]),e},s.O=function(e,s,a){var l=a[0],c=a[1],u=a[2];return e[0]=s[0]*l,e[1]=s[1]*l,e[2]=s[2]*l,e[3]=s[3]*l,e[4]=s[4]*c,e[5]=s[5]*c,e[6]=s[6]*c,e[7]=s[7]*c,e[8]=s[8]*u,e[9]=s[9]*u,e[10]=s[10]*u,e[11]=s[11]*u,e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],e},s.P=l,s.Q=function(e,s,a){var l=s[0],c=s[1],u=s[2],d=s[3],f=s[4],_=s[5],y=s[6],b=s[7],S=s[8],P=s[9],M=s[10],C=s[11],D=s[12],L=s[13],F=s[14],B=s[15],O=a[0],V=a[1],N=a[2],j=a[3];return e[0]=O*l+V*f+N*S+j*D,e[1]=O*c+V*_+N*P+j*L,e[2]=O*u+V*y+N*M+j*F,e[3]=O*d+V*b+N*C+j*B,e[4]=(O=a[4])*l+(V=a[5])*f+(N=a[6])*S+(j=a[7])*D,e[5]=O*c+V*_+N*P+j*L,e[6]=O*u+V*y+N*M+j*F,e[7]=O*d+V*b+N*C+j*B,e[8]=(O=a[8])*l+(V=a[9])*f+(N=a[10])*S+(j=a[11])*D,e[9]=O*c+V*_+N*P+j*L,e[10]=O*u+V*y+N*M+j*F,e[11]=O*d+V*b+N*C+j*B,e[12]=(O=a[12])*l+(V=a[13])*f+(N=a[14])*S+(j=a[15])*D,e[13]=O*c+V*_+N*P+j*L,e[14]=O*u+V*y+N*M+j*F,e[15]=O*d+V*b+N*C+j*B,e},s.R=gl,s.S=function(e,s){const a={};for(let l=0;l<s.length;l++){const c=s[l];c in e&&(a[c]=e[c])}return a},s.T=Il,s.U=_h,s.V=Te,s.W=df,s.X=uf,s.Y=S,s.Z=P,s._=a,s.a=Je,s.a$=function(e,s){return e[0]*s[0]+e[1]*s[1]+e[2]*s[2]},s.a0=Vh,s.a1=ff,s.a2=mf,s.a3=oe,s.a4=function(e,s){var a,l,c,u,d;if(!e)return null!=s?s:{};if(!s)return e;let f=Object.assign({},e);if(s.removeAll&&(f={removeAll:!0}),s.remove){const l=new Set(s.remove);f.add&&(f.add=f.add.filter((e=>!l.has(e.id)))),f.update&&(f.update=f.update.filter((e=>!l.has(e.id))));const c=new Set((null!==(a=e.add)&&void 0!==a?a:[]).map((e=>e.id)));s.remove=s.remove.filter((e=>!c.has(e)))}if(s.remove){const e=new Set(f.remove?f.remove.concat(s.remove):s.remove);f.remove=Array.from(e.values())}if(s.add){const e=f.add?f.add.concat(s.add):s.add,a=new Map(e.map((e=>[e.id,e])));f.add=Array.from(a.values())}if(s.update){const e=new Map(null===(l=f.update)||void 0===l?void 0:l.map((e=>[e.id,e])));for(const a of s.update){const s=null!==(c=e.get(a.id))&&void 0!==c?c:{id:a.id};a.newGeometry&&(s.newGeometry=a.newGeometry),a.addOrUpdateProperties&&(s.addOrUpdateProperties=(null!==(u=s.addOrUpdateProperties)&&void 0!==u?u:[]).concat(a.addOrUpdateProperties)),a.removeProperties&&(s.removeProperties=(null!==(d=s.removeProperties)&&void 0!==d?d:[]).concat(a.removeProperties)),a.removeAllProperties&&(s.removeAllProperties=!0),e.set(a.id,s)}f.update=Array.from(e.values())}return f.remove&&f.add&&(f.remove=f.remove.filter((e=>-1===f.add.findIndex((s=>s.id===e))))),f},s.a5=Fh,s.a6=Oh,s.a7=25,s.a8=Ph,s.a9=e=>{const s=window.document.createElement("video");return s.muted=!0,new Promise((a=>{s.onloadstart=()=>{a(s)};for(const a of e){const e=window.document.createElement("source");ht(a)||(s.crossOrigin="Anonymous"),e.src=a,s.appendChild(e)}}))},s.aA=Vp,s.aB=q,s.aC=function(e,s,a,c){const u=s.y-e.y,d=s.x-e.x,f=c.y-a.y,_=c.x-a.x,y=f*d-_*u;if(0===y)return null;const b=(_*(e.y-a.y)-f*(e.x-a.x))/y;return new l(e.x+b*d,e.y+b*u)},s.aD=bm,s.aE=Hc,s.aF=function(e){let s=1/0,a=1/0,l=-1/0,c=-1/0;for(const u of e)s=Math.min(s,u.x),a=Math.min(a,u.y),l=Math.max(l,u.x),c=Math.max(c,u.y);return[s,a,l,c]},s.aG=kd,s.aH=ce,s.aI=function(e,s,a,l,c=!1){if(!a[0]&&!a[1])return[0,0];const u=c?"map"===l?-e.bearingInRadians:0:"viewport"===l?e.bearingInRadians:0;if(u){const e=Math.sin(u),s=Math.cos(u);a=[a[0]*s-a[1]*e,a[0]*e+a[1]*s]}return[c?a[0]:ce(s,a[0],e.zoom),c?a[1]:ce(s,a[1],e.zoom)]},s.aK=Lp,s.aL=$m,s.aM=hp,s.aN=nd,s.aO=_c,s.aP=au,s.aQ=Ca,s.aR=Qa,s.aS=Ha,s.aT=We,s.aU=_f,s.aV=N,s.aW=V,s.aX=function(e){var s=new C(3);return s[0]=e[0],s[1]=e[1],s[2]=e[2],s},s.aY=function(e,s,a){return e[0]=s[0]-a[0],e[1]=s[1]-a[1],e[2]=s[2]-a[2],e},s.aZ=function(e,s){var a=s[0],l=s[1],c=s[2],u=a*a+l*l+c*c;return u>0&&(u=1/Math.sqrt(u)),e[0]=s[0]*u,e[1]=s[1]*u,e[2]=s[2]*u,e},s.a_=j,s.aa=De,s.ab=function(){return Me++},s.ac=Ta,s.ad=uh,s.ae=co,s.af=qc,s.ag=Nh,s.ah=function(e){const s={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,a,l,c)=>{const u=l||c;return s[a]=!u||u.toLowerCase(),""})),s["max-age"]){const e=parseInt(s["max-age"],10);isNaN(e)?delete s["max-age"]:s["max-age"]=e}return s},s.ai=we,s.aj=85.051129,s.ak=$e,s.al=function(e){return Math.pow(2,e)},s.am=L,s.an=pf,s.ao=function(e){return Math.log(e)/Math.LN2},s.ap=function(e){var s=e[0],a=e[1];return s*s+a*a},s.aq=class{constructor(e,s){this.max=e,this.onRemove=s,this.reset()}reset(){for(const e in this.data)for(const s of this.data[e])s.timeout&&clearTimeout(s.timeout),this.onRemove(s.value);return this.data={},this.order=[],this}add(e,s,a){const l=e.wrapped().key;void 0===this.data[l]&&(this.data[l]=[]);const c={value:s,timeout:void 0};if(void 0!==a&&(c.timeout=setTimeout((()=>{this.remove(e,c)}),a)),this.data[l].push(c),this.order.push(l),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const s=this.data[e].shift();return s.timeout&&clearTimeout(s.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),s.value}getByKey(e){const s=this.data[e];return s?s[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,s){if(!this.has(e))return this;const a=e.wrapped().key,l=void 0===s?0:this.data[a].indexOf(s),c=this.data[a][l];return this.data[a].splice(l,1),c.timeout&&clearTimeout(c.timeout),0===this.data[a].length&&delete this.data[a],this.onRemove(c.value),this.order.splice(this.order.indexOf(a),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){const s=[];for(const a in this.data)for(const l of this.data[a])e(l.value)||s.push(l);for(const e of s)this.remove(e.value.tileID,e)}},s.ar=function(e){if(!e.length)return new Set;const s=Math.max(...e.map((e=>e.canonical.z)));let a=1/0,l=-1/0,c=1/0,u=-1/0;const d=[];for(const f of e){const{x:e,y:_,z:y}=f.canonical,b=Math.pow(2,s-y),S=e*b,P=_*b;d.push({id:f,x:S,y:P}),S<a&&(a=S),S>l&&(l=S),P<c&&(c=P),P>u&&(u=P)}const f=new Set;for(const e of d)e.x!==a&&e.x!==l&&e.y!==c&&e.y!==u||f.add(e.id);return f},s.as=function(e,s){let a=0,l=0;if("constant"===e.kind)l=e.layoutSize;else if("source"!==e.kind){const{interpolationType:c,minZoom:u,maxZoom:d}=e,f=c?we(pr.interpolationFactor(c,s,u,d),0,1):0;"camera"===e.kind?l=Or.number(e.minSize,e.maxSize,f):a=f}return{uSizeT:a,uSize:l}},s.au=function(e,{uSize:s,uSizeT:a},{lowerSize:l,upperSize:c}){return"source"===e.kind?l/Pp:"composite"===e.kind?Or.number(l/Pp,c/Pp,a):s},s.av=function(e,s){var a=s[0],l=s[1],c=s[2],u=s[3],d=s[4],f=s[5],_=s[6],y=s[7],b=s[8],S=s[9],P=s[10],M=s[11],C=s[12],D=s[13],L=s[14],F=s[15],B=a*f-l*d,O=a*_-c*d,V=a*y-u*d,N=l*_-c*f,j=l*y-u*f,G=c*y-u*_,Z=b*D-S*C,q=b*L-P*C,W=b*F-M*C,J=S*L-P*D,Q=S*F-M*D,se=P*F-M*L,oe=B*se-O*Q+V*J+N*W-j*q+G*Z;return oe?(e[0]=(f*se-_*Q+y*J)*(oe=1/oe),e[1]=(c*Q-l*se-u*J)*oe,e[2]=(D*G-L*j+F*N)*oe,e[3]=(P*j-S*G-M*N)*oe,e[4]=(_*W-d*se-y*q)*oe,e[5]=(a*se-c*W+u*q)*oe,e[6]=(L*V-C*G-F*O)*oe,e[7]=(b*G-P*V+M*O)*oe,e[8]=(d*Q-f*W+y*Z)*oe,e[9]=(l*W-a*Q-u*Z)*oe,e[10]=(C*j-D*V+F*B)*oe,e[11]=(S*V-b*j-M*B)*oe,e[12]=(f*q-d*J-_*Z)*oe,e[13]=(a*J-l*q+c*Z)*oe,e[14]=(D*O-C*N-L*B)*oe,e[15]=(b*N-S*O+P*B)*oe,e):null},s.aw=Q,s.ax=function(e){var s=e[0],a=e[1];return Math.sqrt(s*s+a*a)},s.ay=function(e){return e[0]=0,e[1]=0,e},s.az=function(e,s,a){return e[0]=s[0]*a,e[1]=s[1]*a,e},s.b=Ne,s.b$=function(e,s){var a=Math.sin(s),l=Math.cos(s);return e[0]=l,e[1]=a,e[2]=0,e[3]=-a,e[4]=l,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},s.b0=function(e,s,a){return e[0]=s[0]*a[0],e[1]=s[1]*a[1],e[2]=s[2]*a[2],e[3]=s[3]*a[3],e},s.b1=B,s.b2=function(e,s,a){const l=s[0]*a[0]+s[1]*a[1]+s[2]*a[2];return 0===l?null:(-(e[0]*a[0]+e[1]*a[1]+e[2]*a[2])-a[3])/l},s.b3=Z,s.b4=function(e,s,a){return e[0]=s[0]*a,e[1]=s[1]*a,e[2]=s[2]*a,e[3]=s[3]*a,e},s.b5=function(e,s){return e[0]*s[0]+e[1]*s[1]+e[2]*s[2]+e[3]},s.b6=zh,s.b7=wf,s.b8=function(e,s,a,l,c){var u=1/Math.tan(s/2);if(e[0]=u/a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=u,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=c&&c!==1/0){var d=1/(l-c);e[10]=(c+l)*d,e[14]=2*c*l*d}else e[10]=-1,e[14]=-2*l;return e},s.b9=function(e){var s=new C(16);return s[0]=e[0],s[1]=e[1],s[2]=e[2],s[3]=e[3],s[4]=e[4],s[5]=e[5],s[6]=e[6],s[7]=e[7],s[8]=e[8],s[9]=e[9],s[10]=e[10],s[11]=e[11],s[12]=e[12],s[13]=e[13],s[14]=e[14],s[15]=e[15],s},s.bA=function(e,s,a,l){var c=[],u=[];return c[0]=s[0]-a[0],c[1]=s[1]-a[1],c[2]=s[2]-a[2],u[0]=c[0]*Math.cos(l)-c[1]*Math.sin(l),u[1]=c[0]*Math.sin(l)+c[1]*Math.cos(l),u[2]=c[2],e[0]=u[0]+a[0],e[1]=u[1]+a[1],e[2]=u[2]+a[2],e},s.bB=function(e,s,a,l){var c=[],u=[];return c[0]=s[0]-a[0],c[1]=s[1]-a[1],c[2]=s[2]-a[2],u[0]=c[0],u[1]=c[1]*Math.cos(l)-c[2]*Math.sin(l),u[2]=c[1]*Math.sin(l)+c[2]*Math.cos(l),e[0]=u[0]+a[0],e[1]=u[1]+a[1],e[2]=u[2]+a[2],e},s.bC=function(e,s,a,l){var c=[],u=[];return c[0]=s[0]-a[0],c[1]=s[1]-a[1],c[2]=s[2]-a[2],u[0]=c[2]*Math.sin(l)+c[0]*Math.cos(l),u[1]=c[1],u[2]=c[2]*Math.cos(l)-c[0]*Math.sin(l),e[0]=u[0]+a[0],e[1]=u[1]+a[1],e[2]=u[2]+a[2],e},s.bD=function(e,s,a){var l=Math.sin(a),c=Math.cos(a),u=s[0],d=s[1],f=s[2],_=s[3],y=s[8],b=s[9],S=s[10],P=s[11];return s!==e&&(e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15]),e[0]=u*c-y*l,e[1]=d*c-b*l,e[2]=f*c-S*l,e[3]=_*c-P*l,e[8]=u*l+y*c,e[9]=d*l+b*c,e[10]=f*l+S*c,e[11]=_*l+P*c,e},s.bE=function(e,s){const a=pe(e,360),l=pe(s,360),c=l-a,u=l>a?c-360:c+360;return Math.abs(c)<Math.abs(u)?c:u},s.bF=function(e){return e[0]=0,e[1]=0,e[2]=0,e},s.bG=function(e,s,a,l){const c=Math.sqrt(e*e+s*s),u=Math.sqrt(a*a+l*l);e/=c,s/=c,a/=u,l/=u;const d=Math.acos(e*a+s*l);return-s*a+e*l>0?d:-d},s.bH=function(e,s){const a=pe(e,2*Math.PI),l=pe(s,2*Math.PI);return Math.min(Math.abs(a-l),Math.abs(a-l+2*Math.PI),Math.abs(a-l-2*Math.PI))},s.bI=function(){const e={},s=pt.$version;for(const a in pt.$root){const l=pt.$root[a];if(l.required){let c=null;c="version"===a?s:"array"===l.type?[]:{},null!=c&&(e[a]=c)}}return e},s.bJ=nt,s.bK=ds,s.bL=function e(s,a){if(Array.isArray(s)){if(!Array.isArray(a)||s.length!==a.length)return!1;for(let l=0;l<s.length;l++)if(!e(s[l],a[l]))return!1;return!0}if("object"==typeof s&&null!==s&&null!==a){if("object"!=typeof a)return!1;if(Object.keys(s).length!==Object.keys(a).length)return!1;for(const l in s)if(!e(s[l],a[l]))return!1;return!0}return s===a},s.bM=function(e){e=e.slice();const s=Object.create(null);for(let a=0;a<e.length;a++)s[e[a].id]=e[a];for(let a=0;a<e.length;a++)"ref"in e[a]&&(e[a]=mt(e[a],s[e[a].ref]));return e},s.bN=function(e,s){if("custom"===e.type)return new xh(e,s);switch(e.type){case"background":return new gh(e,s);case"circle":return new ul(e,s);case"color-relief":return new kl(e,s);case"fill":return new vu(e,s);case"fill-extrusion":return new Ou(e,s);case"heatmap":return new bl(e,s);case"hillshade":return new Sl(e,s);case"line":return new Qu(e,s);case"raster":return new Zs(e,s);case"symbol":return new dh(e,s)}},s.bO=e=>"raster"===e.type,s.bP=Ae,s.bQ=function(e,s){if(!e)return[{command:"setStyle",args:[s]}];let a=[];try{if(!_t(e.version,s.version))return[{command:"setStyle",args:[s]}];_t(e.center,s.center)||a.push({command:"setCenter",args:[s.center]}),_t(e.state,s.state)||a.push({command:"setGlobalState",args:[s.state]}),_t(e.centerAltitude,s.centerAltitude)||a.push({command:"setCenterAltitude",args:[s.centerAltitude]}),_t(e.zoom,s.zoom)||a.push({command:"setZoom",args:[s.zoom]}),_t(e.bearing,s.bearing)||a.push({command:"setBearing",args:[s.bearing]}),_t(e.pitch,s.pitch)||a.push({command:"setPitch",args:[s.pitch]}),_t(e.roll,s.roll)||a.push({command:"setRoll",args:[s.roll]}),_t(e.sprite,s.sprite)||a.push({command:"setSprite",args:[s.sprite]}),_t(e.glyphs,s.glyphs)||a.push({command:"setGlyphs",args:[s.glyphs]}),_t(e.transition,s.transition)||a.push({command:"setTransition",args:[s.transition]}),_t(e.light,s.light)||a.push({command:"setLight",args:[s.light]}),_t(e.terrain,s.terrain)||a.push({command:"setTerrain",args:[s.terrain]}),_t(e.sky,s.sky)||a.push({command:"setSky",args:[s.sky]}),_t(e.projection,s.projection)||a.push({command:"setProjection",args:[s.projection]});const l={},c=[];!function(e,s,a,l){let c;for(c in s=s||{},e=e||{})Object.prototype.hasOwnProperty.call(e,c)&&(Object.prototype.hasOwnProperty.call(s,c)||vt(c,a,l));for(c in s)Object.prototype.hasOwnProperty.call(s,c)&&(Object.prototype.hasOwnProperty.call(e,c)?_t(e[c],s[c])||("geojson"===e[c].type&&"geojson"===s[c].type&&Rt(e,s,c)?gt(a,{command:"setGeoJSONSourceData",args:[c,s[c].data]}):Et(c,s,a,l)):yt(c,s,a))}(e.sources,s.sources,c,l);const u=[];e.layers&&e.layers.forEach((e=>{"source"in e&&l[e.source]?a.push({command:"removeLayer",args:[e.id]}):u.push(e)})),a=a.concat(c),function(e,s,a){s=s||[];const l=(e=e||[]).map(Zt),c=s.map(Zt),u=e.reduce($t,{}),d=s.reduce($t,{}),f=l.slice(),_=Object.create(null);let y,b,S,P,M;for(let e=0,s=0;e<l.length;e++)y=l[e],Object.prototype.hasOwnProperty.call(d,y)?s++:(gt(a,{command:"removeLayer",args:[y]}),f.splice(f.indexOf(y,s),1));for(let e=0,s=0;e<c.length;e++)y=c[c.length-1-e],f[f.length-1-e]!==y&&(Object.prototype.hasOwnProperty.call(u,y)?(gt(a,{command:"removeLayer",args:[y]}),f.splice(f.lastIndexOf(y,f.length-s),1)):s++,P=f[f.length-e],gt(a,{command:"addLayer",args:[d[y],P]}),f.splice(f.length-e,0,y),_[y]=!0);for(let e=0;e<c.length;e++)if(y=c[e],b=u[y],S=d[y],!_[y]&&!_t(b,S))if(_t(b.source,S.source)&&_t(b["source-layer"],S["source-layer"])&&_t(b.type,S.type)){for(M in Vt(b.layout,S.layout,a,y,null,"setLayoutProperty"),Vt(b.paint,S.paint,a,y,null,"setPaintProperty"),_t(b.filter,S.filter)||gt(a,{command:"setFilter",args:[y,S.filter]}),_t(b.minzoom,S.minzoom)&&_t(b.maxzoom,S.maxzoom)||gt(a,{command:"setLayerZoomRange",args:[y,S.minzoom,S.maxzoom]}),b)Object.prototype.hasOwnProperty.call(b,M)&&"layout"!==M&&"paint"!==M&&"filter"!==M&&"metadata"!==M&&"minzoom"!==M&&"maxzoom"!==M&&(0===M.indexOf("paint.")?Vt(b[M],S[M],a,y,M.slice(6),"setPaintProperty"):_t(b[M],S[M])||gt(a,{command:"setLayerProperty",args:[y,M,S[M]]}));for(M in S)Object.prototype.hasOwnProperty.call(S,M)&&!Object.prototype.hasOwnProperty.call(b,M)&&"layout"!==M&&"paint"!==M&&"filter"!==M&&"metadata"!==M&&"minzoom"!==M&&"maxzoom"!==M&&(0===M.indexOf("paint.")?Vt(b[M],S[M],a,y,M.slice(6),"setPaintProperty"):_t(b[M],S[M])||gt(a,{command:"setLayerProperty",args:[y,M,S[M]]}))}else gt(a,{command:"removeLayer",args:[y]}),P=f[f.lastIndexOf(y)+1],gt(a,{command:"addLayer",args:[S,P]})}(u,s.layers,a)}catch(e){console.warn("Unable to compute style diff:",e),a=[{command:"setStyle",args:[s]}]}return a},s.bR=function(e){const s=[],a=e.id;return void 0===a&&s.push({message:`layers.${a}: missing required property "id"`}),void 0===e.render&&s.push({message:`layers.${a}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&s.push({message:`layers.${a}: property "renderingMode" must be either "2d" or "3d"`}),s},s.bS=Ee,s.bT=Ce,s.bU=class extends mo{constructor(e,s){super(e,s),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1i(this.location,e))}},s.bV=vo,s.bW=class extends mo{constructor(e,s){super(e,s),this.current=Oc}set(e){if(e[12]!==this.current[12]||e[0]!==this.current[0])return this.current=e,void this.gl.uniformMatrix4fv(this.location,!1,e);for(let s=1;s<16;s++)if(e[s]!==this.current[s]){this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);break}}},s.bX=xo,s.bY=class extends mo{constructor(e,s){super(e,s),this.current=[0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]||(this.current=e,this.gl.uniform3f(this.location,e[0],e[1],e[2]))}},s.bZ=class extends mo{constructor(e,s){super(e,s),this.current=[0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]||(this.current=e,this.gl.uniform2f(this.location,e[0],e[1]))}},s.b_=D,s.ba=function(e,s,a){var l=Math.sin(a),c=Math.cos(a),u=s[0],d=s[1],f=s[2],_=s[3],y=s[4],b=s[5],S=s[6],P=s[7];return s!==e&&(e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15]),e[0]=u*c+y*l,e[1]=d*c+b*l,e[2]=f*c+S*l,e[3]=_*c+P*l,e[4]=y*c-u*l,e[5]=b*c-d*l,e[6]=S*c-f*l,e[7]=P*c-_*l,e},s.bb=function(e,s,a){var l=Math.sin(a),c=Math.cos(a),u=s[4],d=s[5],f=s[6],_=s[7],y=s[8],b=s[9],S=s[10],P=s[11];return s!==e&&(e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15]),e[4]=u*c+y*l,e[5]=d*c+b*l,e[6]=f*c+S*l,e[7]=_*c+P*l,e[8]=y*c-u*l,e[9]=b*c-d*l,e[10]=S*c-f*l,e[11]=P*c-_*l,e},s.bc=function(){const e=new Float32Array(16);return L(e),e},s.bd=function(){const e=new Float64Array(16);return L(e),e},s.be=function(){return new Float64Array(16)},s.bf=function(e,s,a){const l=new Float64Array(4);return J(l,e,s-90,a),l},s.bg=function(e,s,a,l){var c,u,d,f,_,y=s[0],b=s[1],S=s[2],P=s[3],C=a[0],D=a[1],L=a[2],F=a[3];return(u=y*C+b*D+S*L+P*F)<0&&(u=-u,C=-C,D=-D,L=-L,F=-F),1-u>M?(c=Math.acos(u),d=Math.sin(c),f=Math.sin((1-l)*c)/d,_=Math.sin(l*c)/d):(f=1-l,_=l),e[0]=f*y+_*C,e[1]=f*b+_*D,e[2]=f*S+_*L,e[3]=f*P+_*F,e},s.bh=function(e){const s=new Float64Array(9);var a,l,c,u,d,f,_,y,b,S,P,M,C,D,L,F,B,O;S=(c=(l=e)[0])*(_=c+c),P=(u=l[1])*_,C=(d=l[2])*_,D=d*(y=u+u),F=(f=l[3])*_,B=f*y,O=f*(b=d+d),(a=s)[0]=1-(M=u*y)-(L=d*b),a[3]=P-O,a[6]=C+B,a[1]=P+O,a[4]=1-S-L,a[7]=D-F,a[2]=C-B,a[5]=D+F,a[8]=1-S-M;const V=We(-Math.asin(we(s[2],-1,1)));let N,j;return Math.hypot(s[5],s[8])<.001?(N=0,j=-We(Math.atan2(s[3],s[4]))):(N=We(0===s[5]&&0===s[8]?0:Math.atan2(s[5],s[8])),j=We(0===s[1]&&0===s[0]?0:Math.atan2(s[1],s[0]))),{roll:N,pitch:V+90,bearing:j}},s.bi=function(e,s){return e.roll==s.roll&&e.pitch==s.pitch&&e.bearing==s.bearing},s.bj=It,s.bk=go,s.bl=Vu,s.bm=Nu,s.bn=su,s.bo=fe,s.bp=xe,s.bq=Ot,s.br=function(e,s,a,l,c){return fe(l,c,we((e-s)/(a-s),0,1))},s.bs=pe,s.bt=function(){return new Float64Array(3)},s.bu=function(e,s,a,l){return e[0]=s[0]+a[0]*l,e[1]=s[1]+a[1]*l,e[2]=s[2]+a[2]*l,e},s.bv=J,s.bw=function(e,s,a){var l=a[0],c=a[1],u=a[2],d=a[3],f=s[0],_=s[1],y=s[2],b=c*y-u*_,S=u*f-l*y,P=l*_-c*f;return e[0]=f+d*(b+=b)+c*(P+=P)-u*(S+=S),e[1]=_+d*S+u*b-l*P,e[2]=y+d*P+l*S-c*b,e},s.bx=function(e,s,a){const l=(c=[e[0],e[1],e[2],s[0],s[1],s[2],a[0],a[1],a[2]])[0]*((b=c[8])*(d=c[4])-(f=c[5])*(y=c[7]))+c[1]*(-b*(u=c[3])+f*(_=c[6]))+c[2]*(y*u-d*_);var c,u,d,f,_,y,b;if(0===l)return null;const S=j([],[s[0],s[1],s[2]],[a[0],a[1],a[2]]),P=j([],[a[0],a[1],a[2]],[e[0],e[1],e[2]]),M=j([],[e[0],e[1],e[2]],[s[0],s[1],s[2]]),C=N([],S,-e[3]);return V(C,C,N([],P,-s[3])),V(C,C,N([],M,-a[3])),N(C,C,1/l),C},s.by=tf,s.bz=function(){return new Float64Array(4)},s.c=Ke,s.c$=function(e,s){const a=new Map;if(null==e);else if("Feature"===e.type)a.set(Tf(e,s),e);else for(const l of e.features)a.set(Tf(l,s),l);return a},s.c0=function(e,s,a){var l=s[0],c=s[1],u=s[2];return e[0]=l*a[0]+c*a[3]+u*a[6],e[1]=l*a[1]+c*a[4]+u*a[7],e[2]=l*a[2]+c*a[5]+u*a[8],e},s.c1=function(e,s,a,l,c,u,d){var f=1/(s-a),_=1/(l-c),y=1/(u-d);return e[0]=-2*f,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*_,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*y,e[11]=0,e[12]=(s+a)*f,e[13]=(c+l)*_,e[14]=(d+u)*y,e[15]=1,e},s.c2=class extends mo{constructor(e,s){super(e,s),this.current=new Array}set(e){if(e!=this.current){this.current=e;const s=new Float32Array(4*e.length);for(let a=0;a<e.length;a++)s[4*a]=e[a].r,s[4*a+1]=e[a].g,s[4*a+2]=e[a].b,s[4*a+3]=e[a].a;this.gl.uniform4fv(this.location,s)}}},s.c3=class extends mo{constructor(e,s){super(e,s),this.current=new Array}set(e){if(e!=this.current){this.current=e;const s=new Float32Array(e);this.gl.uniform1fv(this.location,s)}}},s.c4=class extends fa{},s.c5=Ad,s.c6=class extends ya{},s.c7=Lh,s.c8=function(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},s.c9=kh,s.cA=c_,s.cC=function(e){return e.message===Ye},s.cD=ue,s.cE=function(e,s){Je.REGISTERED_PROTOCOLS[e]=s},s.cF=function(e){delete Je.REGISTERED_PROTOCOLS[e]},s.cG=function(e,s){const a={};for(let l=0;l<e.length;l++){const c=s&&s[e[l].id]||jo(e[l]);s&&(s[e[l].id]=c);let u=a[c];u||(u=a[c]=[]),u.push(e[l])}const l=[];for(const e in a)l.push(a[e]);return l},s.cH=ql,s.cI=Rh,s.cJ=bf,s.cK=kc,s.cL=function(e){e.bucket.createArrays(),e.bucket.tilePixelRatio=oe/(512*e.bucket.overscaling),e.bucket.compareText={},e.bucket.iconsNeedLinear=!1;const a=e.bucket.layers[0],l=a.layout,c=a._unevaluatedLayout._values,u={layoutIconSize:c["icon-size"].possiblyEvaluate(new Es(e.bucket.zoom+1),e.canonical),layoutTextSize:c["text-size"].possiblyEvaluate(new Es(e.bucket.zoom+1),e.canonical),textMaxSize:c["text-size"].possiblyEvaluate(new Es(18))};if("composite"===e.bucket.textSizeData.kind){const{minZoom:s,maxZoom:a}=e.bucket.textSizeData;u.compositeTextSizes=[c["text-size"].possiblyEvaluate(new Es(s),e.canonical),c["text-size"].possiblyEvaluate(new Es(a),e.canonical)]}if("composite"===e.bucket.iconSizeData.kind){const{minZoom:s,maxZoom:a}=e.bucket.iconSizeData;u.compositeIconSizes=[c["icon-size"].possiblyEvaluate(new Es(s),e.canonical),c["icon-size"].possiblyEvaluate(new Es(a),e.canonical)]}const d=l.get("text-line-height")*kd,f="viewport"!==l.get("text-rotation-alignment")&&"point"!==l.get("symbol-placement"),_=l.get("text-keep-upright"),y=l.get("text-size");for(const c of e.bucket.features){const b=l.get("text-font").evaluate(c,{},e.canonical).join(","),S=y.evaluate(c,{},e.canonical),P=u.layoutTextSize.evaluate(c,{},e.canonical),M=u.layoutIconSize.evaluate(c,{},e.canonical),C={horizontal:{},vertical:void 0},D=c.text;let L,F=[0,0];if(D){const u=D.toString(),y=l.get("text-letter-spacing").evaluate(c,{},e.canonical)*kd,M=ec(u)?y:0,L=l.get("text-anchor").evaluate(c,{},e.canonical),B=qm(a,c,e.canonical);if(!B){const s=l.get("text-radial-offset").evaluate(c,{},e.canonical);F=s?Zm(L,[s*kd,Gm]):l.get("text-offset").evaluate(c,{},e.canonical).map((e=>e*kd))}let O=f?"center":l.get("text-justify").evaluate(c,{},e.canonical);const V="point"===l.get("symbol-placement")?l.get("text-max-width").evaluate(c,{},e.canonical)*kd:1/0,N=()=>{e.bucket.allowVerticalPlacement&&Ql(u)&&(C.vertical=Qd(D,e.glyphMap,e.glyphPositions,e.imagePositions,b,V,d,L,"left",M,F,s.at.vertical,!0,P,S))};if(!f&&B){const a=new Set;if("auto"===O)for(let e=0;e<B.values.length;e+=2)a.add($m(B.values[e]));else a.add(O);let l=!1;for(const c of a)if(!C.horizontal[c])if(l)C.horizontal[c]=C.horizontal[0];else{const a=Qd(D,e.glyphMap,e.glyphPositions,e.imagePositions,b,V,d,"center",c,M,F,s.at.horizontal,!1,P,S);a&&(C.horizontal[c]=a,l=1===a.positionedLines.length)}N()}else{"auto"===O&&(O=$m(L));const a=Qd(D,e.glyphMap,e.glyphPositions,e.imagePositions,b,V,d,L,O,M,F,s.at.horizontal,!1,P,S);a&&(C.horizontal[O]=a),N(),Ql(u)&&f&&_&&(C.vertical=Qd(D,e.glyphMap,e.glyphPositions,e.imagePositions,b,V,d,L,O,M,F,s.at.vertical,!1,P,S))}}let B=!1;if(c.icon&&c.icon.name){const s=e.imageMap[c.icon.name];s&&(L=yp(e.imagePositions[c.icon.name],l.get("icon-offset").evaluate(c,{},e.canonical),l.get("icon-anchor").evaluate(c,{},e.canonical)),B=!!s.sdf,void 0===e.bucket.sdfIcons?e.bucket.sdfIcons=B:e.bucket.sdfIcons!==B&&Le("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(s.pixelRatio!==e.bucket.pixelRatio||0!==l.get("icon-rotate").constantOr(1))&&(e.bucket.iconsNeedLinear=!0))}const O=Xm(C.horizontal)||C.vertical;e.bucket.iconsInText=!!O&&O.iconsInText,(O||L)&&Wm(e.bucket,c,C,L,e.imageMap,u,P,M,F,B,e.canonical,e.subdivisionGranularity)}e.showCollisionBoxes&&e.bucket.generateCollisionDebugBuffers()},s.cM=yu,s.cN=Bu,s.cO=Yu,s.cP=Iu,s.cQ=pc,s.cR=Su,s.cS=function(e,s,a,l,c,u){let d=wm(e,s,a,c,0);return d=wm(d,s,l,u,1),d},s.cT=class{constructor(e){this.maxEntries=e,this.map=new Map}get(e){const s=this.map.get(e);return void 0!==s&&(this.map.delete(e),this.map.set(e,s)),s}set(e,s){if(this.map.has(e))this.map.delete(e);else if(this.map.size>=this.maxEntries){const e=this.map.keys().next().value;this.map.delete(e)}this.map.set(e,s)}clear(){this.map.clear()}},s.cU=Eu,s.cV=vf,s.cW=class{constructor(e){this._marks={start:[e.url,"start"].join("#"),end:[e.url,"end"].join("#"),measure:e.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let e=performance.getEntriesByName(this._marks.measure);return 0===e.length&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),e=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),e}},s.cX=function(s,l,c,u,d){return a(this||e,void 0,void 0,(function*(){if(P())try{return yield Ue(s,l,c,u,d)}catch(e){}return function(e,s,a,l,c){const u=e.width,d=e.height;Ge&&Ze||(Ge=new OffscreenCanvas(u,d),Ze=Ge.getContext("2d",{willReadFrequently:!0})),Ge.width=u,Ge.height=d,Ze.drawImage(e,0,0,u,d);const f=Ze.getImageData(s,a,l,c);return Ze.clearRect(0,0,u,d),f.data}(s,l,c,u,d)}))},s.cY=Ml,s.cZ=c,s.c_=js,s.ca=function(e,s,a){var l=s[0],c=s[1],u=s[2],d=a[3]*l+a[7]*c+a[11]*u+a[15];return e[0]=(a[0]*l+a[4]*c+a[8]*u+a[12])/(d=d||1),e[1]=(a[1]*l+a[5]*c+a[9]*u+a[13])/d,e[2]=(a[2]*l+a[6]*c+a[10]*u+a[14])/d,e},s.cb=class extends ra{},s.cc=class extends _a{},s.cd=function(e,s){return e[0]===s[0]&&e[1]===s[1]&&e[2]===s[2]&&e[3]===s[3]&&e[4]===s[4]&&e[5]===s[5]&&e[6]===s[6]&&e[7]===s[7]&&e[8]===s[8]&&e[9]===s[9]&&e[10]===s[10]&&e[11]===s[11]&&e[12]===s[12]&&e[13]===s[13]&&e[14]===s[14]&&e[15]===s[15]},s.ce=function(e,s){var a=e[0],l=e[1],c=e[2],u=e[3],d=e[4],f=e[5],_=e[6],y=e[7],b=e[8],S=e[9],P=e[10],C=e[11],D=e[12],L=e[13],F=e[14],B=e[15],O=s[0],V=s[1],N=s[2],j=s[3],G=s[4],Z=s[5],q=s[6],W=s[7],J=s[8],Q=s[9],se=s[10],oe=s[11],ce=s[12],pe=s[13],fe=s[14],xe=s[15];return Math.abs(a-O)<=M*Math.max(1,Math.abs(a),Math.abs(O))&&Math.abs(l-V)<=M*Math.max(1,Math.abs(l),Math.abs(V))&&Math.abs(c-N)<=M*Math.max(1,Math.abs(c),Math.abs(N))&&Math.abs(u-j)<=M*Math.max(1,Math.abs(u),Math.abs(j))&&Math.abs(d-G)<=M*Math.max(1,Math.abs(d),Math.abs(G))&&Math.abs(f-Z)<=M*Math.max(1,Math.abs(f),Math.abs(Z))&&Math.abs(_-q)<=M*Math.max(1,Math.abs(_),Math.abs(q))&&Math.abs(y-W)<=M*Math.max(1,Math.abs(y),Math.abs(W))&&Math.abs(b-J)<=M*Math.max(1,Math.abs(b),Math.abs(J))&&Math.abs(S-Q)<=M*Math.max(1,Math.abs(S),Math.abs(Q))&&Math.abs(P-se)<=M*Math.max(1,Math.abs(P),Math.abs(se))&&Math.abs(C-oe)<=M*Math.max(1,Math.abs(C),Math.abs(oe))&&Math.abs(D-ce)<=M*Math.max(1,Math.abs(D),Math.abs(ce))&&Math.abs(L-pe)<=M*Math.max(1,Math.abs(L),Math.abs(pe))&&Math.abs(F-fe)<=M*Math.max(1,Math.abs(F),Math.abs(fe))&&Math.abs(B-xe)<=M*Math.max(1,Math.abs(B),Math.abs(xe))},s.cf=function(e,s){return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],e},s.cg=e=>"symbol"===e.type,s.ch=e=>"circle"===e.type,s.ci=e=>"heatmap"===e.type,s.cj=e=>"line"===e.type,s.ck=e=>"fill"===e.type,s.cl=e=>"fill-extrusion"===e.type,s.cm=e=>"hillshade"===e.type,s.cn=e=>"color-relief"===e.type,s.co=e=>"background"===e.type,s.cp=e=>"custom"===e.type,s.cq=ve,s.cr=function(e,s,a){const l=se(s.x-a.x,s.y-a.y),c=se(e.x-a.x,e.y-a.y);var u,d;return We(Math.atan2(l[0]*c[1]-l[1]*c[0],(u=l)[0]*(d=c)[0]+u[1]*d[1]))},s.cs=be,s.ct=function(e,s){return Xe[s]&&(e instanceof MouseEvent||e instanceof WheelEvent)},s.cu=function(e,s){return He[s]&&"touches"in e},s.cv=function(e){return He[e]||Xe[e]},s.cw=function(e,s,a){var l=s[0],c=s[1];return e[0]=a[0]*l+a[4]*c+a[12],e[1]=a[1]*l+a[5]*c+a[13],e},s.cx=function(e,s){const{x:a,y:l}=Fh.fromLngLat(s);return!(e<0||e>25||l<0||l>=1||a<0||a>=1)},s.cy=function(e,s){return e[0]=s[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=s[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},s.cz=class extends ta{},s.d=ht,s.d0=function(e,s){if(null==e)return!0;if("Feature"===e.type)return null!=Tf(e,s);if("FeatureCollection"===e.type){const a=new Set;for(const l of e.features){const e=Tf(l,s);if(null==e)return!1;if(a.has(e))return!1;a.add(e)}return!0}return!1},s.d1=function(e,s,a){var l,c,u,d;if(s.removeAll&&e.clear(),s.remove)for(const a of s.remove)e.delete(a);if(s.add)for(const l of s.add){const s=Tf(l,a);null!=s&&e.set(s,l)}if(s.update)for(const a of s.update){let s=e.get(a.id);if(null==s)continue;const f=!a.removeAllProperties&&((null===(l=a.removeProperties)||void 0===l?void 0:l.length)>0||(null===(c=a.addOrUpdateProperties)||void 0===c?void 0:c.length)>0);if((a.newGeometry||a.removeAllProperties||f)&&(s=Object.assign({},s),e.set(a.id,s),f&&(s.properties=Object.assign({},s.properties))),a.newGeometry&&(s.geometry=a.newGeometry),a.removeAllProperties)s.properties={};else if((null===(u=a.removeProperties)||void 0===u?void 0:u.length)>0)for(const e of a.removeProperties)Object.prototype.hasOwnProperty.call(s.properties,e)&&delete s.properties[e];if((null===(d=a.addOrUpdateProperties)||void 0===d?void 0:d.length)>0)for(const{key:e,value:l}of a.addOrUpdateProperties)s.properties[e]=l}},s.d2=cc,s.e=Se,s.f=e=>a(void 0,void 0,void 0,(function*(){if(0===e.byteLength)return createImageBitmap(new ImageData(1,1));const s=new Blob([new Uint8Array(e)],{type:"image/png"});try{return createImageBitmap(s)}catch(e){throw new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),s.g=Qe,s.h=e=>new Promise(((s,a)=>{const l=new Image;l.onload=()=>{s(l),URL.revokeObjectURL(l.src),l.onload=null,window.requestAnimationFrame((()=>{l.src=je}))},l.onerror=()=>a(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 c=new Blob([new Uint8Array(e)],{type:"image/png"});l.src=e.byteLength?URL.createObjectURL(c):je})),s.i=Oe,s.j=(e,s)=>ct(Se(e,{type:"json"}),s),s.k=me,s.l=ye,s.m=ct,s.n=(e,s)=>ct(Se(e,{type:"arrayBuffer"}),s),s.o=function(e){return new pc(e).readFields(Hd,[])},s.p=Kd,s.q=function(e){return/[\u1100-\u11FF\u3000-\u30FF\u3131-\u318E\u31F0-\u321E\u3260-\u327E\u32D0-\u32FE\u3300-\u3357\u3400-\u4DBF\u4E00-\u9FFF\uA960-\uA97C\uAC00-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFF00-\uFFEF]|\uD81B[\uDFE4\uDFF2-\uDFF6]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD83C\uDE00|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))},s.r=ml,s.s=qe,s.t=qs,s.u=pt,s.v=Bl,s.w=Le,s.x=Bs,s.y=Vl,s.z=Gl}));l("worker",["./shared"],(function(e){class t{constructor(e,s){this.keyCache={},e&&this.replace(e,s)}replace(e,s){this._layerConfigs={},this._layers={},this.update(e,[],s)}update(s,a,l){for(const a of s){this._layerConfigs[a.id]=a;const s=this._layers[a.id]=e.bN(a,l);s._featureFilter=e.ae(s.filter,l),this.keyCache[a.id]&&delete this.keyCache[a.id]}for(const e of a)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const c=e.cG(Object.values(this._layerConfigs),this.keyCache);for(const e of c){const s=e.map((e=>this._layers[e.id])),a=s[0];if("none"===a.visibility)continue;const l=a.source||"";let c=this.familiesBySource[l];c||(c=this.familiesBySource[l]={});const u=a.sourceLayer||"_geojsonTileLayer";let d=c[u];d||(d=c[u]=[]),d.push(s)}}}class i{constructor(s){const a={},l=[];for(const e in s){const c=s[e],u=a[e]={};for(const e in c){const s=c[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const a={x:0,y:0,w:s.bitmap.width+2,h:s.bitmap.height+2};l.push(a),u[e]={rect:a,metrics:s.metrics}}}const{w:c,h:u}=e.p(l),d=new e.r({width:c||1,height:u||1});for(const l in s){const c=s[l];for(const s in c){const u=c[+s];if(!u||0===u.bitmap.width||0===u.bitmap.height)continue;const f=a[l][s].rect;e.r.copy(u.bitmap,d,{x:0,y:0},{x:f.x+1,y:f.y+1},u.bitmap)}}this.image=d,this.positions=a}}e.cH("GlyphAtlas",i);class o{constructor(s){this.tileID=new e.a0(s.tileID.overscaledZ,s.tileID.wrap,s.tileID.canonical.z,s.tileID.canonical.x,s.tileID.canonical.y),this.uid=s.uid,this.zoom=s.zoom,this.pixelRatio=s.pixelRatio,this.tileSize=s.tileSize,this.source=s.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=s.showCollisionBoxes,this.collectResourceTiming=!!s.collectResourceTiming,this.returnDependencies=!!s.returnDependencies,this.promoteId=s.promoteId,this.inFlightDependencies=[]}parse(a,l,c,u,d){return e._(this,void 0,void 0,(function*(){this.status="parsing",this.data=a,this.collisionBoxArray=new e.ac;const f=new e.cI(Object.keys(a.layers).sort()),_=new e.cJ(this.tileID,this.promoteId);_.bucketLayerIDs=[];const y={},b={featureIndex:_,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:c,subdivisionGranularity:d},S=l.familiesBySource[this.source];for(const l in S){const u=a.layers[l];if(!u)continue;1===u.version&&e.w(`Vector tile source "${this.source}" layer "${l}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const d=f.encode(l),P=[];for(let e=0;e<u.length;e++){const s=u.feature(e),a=_.getId(s,l);P.push({feature:s,id:a,index:e,sourceLayerIndex:d})}for(const a of S[l]){const l=a[0];l.source!==this.source&&e.w(`layer.source = ${l.source} does not equal this.source = ${this.source}`),l.isHidden(this.zoom,!0)||(s(a,this.zoom,c),(y[l.id]=l.createBucket({index:_.bucketLayerIDs.length,layers:a,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:d,sourceID:this.source})).populate(P,b,this.tileID.canonical),_.bucketLayerIDs.push(a.map((e=>e.id))))}}const P=e.bS(b.glyphDependencies,(e=>Object.keys(e).map(Number)));this.inFlightDependencies.forEach((e=>null==e?void 0:e.abort())),this.inFlightDependencies=[];let M=Promise.resolve({});if(Object.keys(P).length){const e=new AbortController;this.inFlightDependencies.push(e),M=u.sendAsync({type:"GG",data:{stacks:P,source:this.source,tileID:this.tileID,type:"glyphs"}},e)}const C=Object.keys(b.iconDependencies);let D=Promise.resolve({});if(C.length){const e=new AbortController;this.inFlightDependencies.push(e),D=u.sendAsync({type:"GI",data:{icons:C,source:this.source,tileID:this.tileID,type:"icons"}},e)}const L=Object.keys(b.patternDependencies);let F=Promise.resolve({});if(L.length){const e=new AbortController;this.inFlightDependencies.push(e),F=u.sendAsync({type:"GI",data:{icons:L,source:this.source,tileID:this.tileID,type:"patterns"}},e)}const B=b.dashDependencies;let O=Promise.resolve({});if(Object.keys(B).length){const e=new AbortController;this.inFlightDependencies.push(e),O=u.sendAsync({type:"GDA",data:{dashes:B}},e)}const[V,N,j,G]=yield Promise.all([M,D,F,O]),Z=new i(V),q=new e.cK(N,j);for(const a in y){const l=y[a];l instanceof e.ad?(s(l.layers,this.zoom,c),e.cL({bucket:l,glyphMap:V,glyphPositions:Z.positions,imageMap:N,imagePositions:q.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:b.subdivisionGranularity})):l.hasDependencies&&(l instanceof e.cM||l instanceof e.cN||l instanceof e.cO)&&(s(l.layers,this.zoom,c),l.addFeatures(b,this.tileID.canonical,q.patternPositions,G))}return this.status="done",{buckets:Object.values(y).filter((e=>!e.isEmpty())),featureIndex:_,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Z.image,imageAtlas:q,dashPositions:G,glyphMap:this.returnDependencies?V:null,iconMap:this.returnDependencies?N:null,glyphPositions:this.returnDependencies?Z.positions:null}}))}}function s(s,a,l){const c=new e.G(a);for(const e of s)e.recalculate(c,l)}class n extends e.cR{constructor(s,a){super(new e.cQ,0,a,[],[]),this.feature=s,this.type=s.type,this.properties=s.tags?s.tags:{},"id"in s&&("string"==typeof s.id?this.id=parseInt(s.id,10):"number"!=typeof s.id||isNaN(s.id)||(this.id=s.id))}loadGeometry(){const s=[],a=1===this.feature.type?[this.feature.geometry]:this.feature.geometry;for(const l of a){const a=[];for(const s of l)a.push(new e.P(s[0],s[1]));s.push(a)}return s}}class r extends e.cP{constructor(s,a){super(new e.cQ),this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.version=a?a.version:1,this.extent=a?a.extent:4096,this.length=s.length,this.features=s}feature(e){return new n(this.features[e],this.extent)}}function a(e,s){s.writeVarintField(15,e.version||1),s.writeStringField(1,e.name||""),s.writeVarintField(5,e.extent||4096);const a={keys:[],values:[],keycache:{},valuecache:{}};for(let c=0;c<e.length;c++)a.feature=e.feature(c),s.writeMessage(2,l,a);const c=a.keys;for(const e of c)s.writeStringField(3,e);const u=a.values;for(const e of u)s.writeMessage(4,_,e)}function l(e,s){if(!e.feature)return;const a=e.feature;void 0!==a.id&&s.writeVarintField(1,a.id),s.writeMessage(2,c,e),s.writeVarintField(3,a.type),s.writeMessage(4,f,a)}function c(e,s){for(const a in e.feature?.properties){let l=e.feature.properties[a],c=e.keycache[a];if(null===l)continue;void 0===c&&(e.keys.push(a),c=e.keys.length-1,e.keycache[a]=c),s.writeVarint(c),"string"!=typeof l&&"boolean"!=typeof l&&"number"!=typeof l&&(l=JSON.stringify(l));const u=typeof l+":"+l;let d=e.valuecache[u];void 0===d&&(e.values.push(l),d=e.values.length-1,e.valuecache[u]=d),s.writeVarint(d)}}function u(e,s){return(s<<3)+(7&e)}function d(e){return e<<1^e>>31}function f(e,s){const a=e.loadGeometry(),l=e.type;let c=0,f=0;for(const _ of a){let a=1;1===l&&(a=_.length),s.writeVarint(u(1,a));const y=3===l?_.length-1:_.length;for(let e=0;e<y;e++){1===e&&1!==l&&s.writeVarint(u(2,y-1));const a=_[e].x-c,b=_[e].y-f;s.writeVarint(d(a)),s.writeVarint(d(b)),c+=a,f+=b}3===e.type&&s.writeVarint(u(7,1))}}function _(e,s){const a=typeof e;"string"===a?s.writeStringField(1,e):"boolean"===a?s.writeBooleanField(7,e):"number"===a&&(e%1!=0?s.writeDoubleField(3,e):e<0?s.writeSVarintField(6,e):s.writeVarintField(5,e))}class g extends e.cR{constructor(s,a,l,c,u){super(new e.cQ,0,u,[],[]),this.type=s,this.properties=l||{},this.extent=u,this.pointsArray=a,this.id=c}loadGeometry(){return this.pointsArray.map((s=>s.map((s=>new e.P(s.x,s.y)))))}}class p extends e.cP{constructor(s,a,l){super(new e.cQ),this.version=2,this._myFeatures=s,this.name=a,this.length=s.length,this.extent=l}feature(e){return this._myFeatures[e]}}class m{constructor(){this.layers={}}addLayer(e){this.layers[e.name]=e}}function y(s){let l=function(s){const l=new e.cQ;return function(e,s){for(const l in e.layers)s.writeMessage(3,a,e.layers[l])}(s,l),l.finish()}(s);return 0===l.byteOffset&&l.byteLength===l.buffer.byteLength||(l=new Uint8Array(l)),{vectorTile:s,rawData:l.buffer}}function b(s,a,l){const{extent:c}=s,u=Math.pow(2,l.z-a.z),d=(l.x-a.x*u)*c,f=(l.y-a.y*u)*c,_=[];for(let a=0;a<s.length;a++){const l=s.feature(a);let y=l.loadGeometry();for(const e of y)for(const s of e)s.x=s.x*u-d,s.y=s.y*u-f;const b=128;y=e.cS(y,l.type,-b,-b,c+b,c+b),0!==y.length&&_.push(new g(l.type,y,l.properties,l.id,c))}return new p(_,s.name,c)}class w{constructor(s,a,l){this.actor=s,this.layerIndex=a,this.availableImages=l,this.fetching={},this.loading={},this.loaded={},this.overzoomedTileResultCache=new e.cT(1e3)}loadVectorTile(s,a){return e._(this,void 0,void 0,(function*(){const l=yield e.n(s.request,a);try{return{vectorTile:"mlt"!==s.encoding?new e.cU(new e.cQ(l.data)):new e.cV(l.data),rawData:l.data,cacheControl:l.cacheControl,expires:l.expires}}catch(e){const a=new Uint8Array(l.data);let c=`Unable to parse the tile at ${s.request.url}, `;throw c+=31===a[0]&&139===a[1]?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${e.message}`,new Error(c)}}))}loadTile(s){return e._(this,void 0,void 0,(function*(){const{uid:a,overzoomParameters:l}=s;l&&(s.request=l.overzoomRequest);const c=!!(s&&s.request&&s.request.collectResourceTiming)&&new e.cW(s.request),u=new o(s);this.loading[a]=u;const d=new AbortController;u.abort=d;try{const f=yield this.loadVectorTile(s,d);if(delete this.loading[a],!f)return null;if(l){const e=this._getOverzoomTile(s,f.vectorTile);f.rawData=e.rawData,f.vectorTile=e.vectorTile}const _=f.rawData,y={};f.expires&&(y.expires=f.expires),f.cacheControl&&(y.cacheControl=f.cacheControl);const b={};if(c){const e=c.finish();e&&(b.resourceTiming=JSON.parse(JSON.stringify(e)))}u.vectorTile=f.vectorTile;const S=u.parse(f.vectorTile,this.layerIndex,this.availableImages,this.actor,s.subdivisionGranularity);this.loaded[a]=u,this.fetching[a]={rawTileData:_,cacheControl:y,resourceTiming:b};try{const a=yield S;return e.e({rawTileData:_.slice(0),encoding:s.encoding},a,y,b)}finally{delete this.fetching[a]}}catch(e){throw delete this.loading[a],u.status="done",this.loaded[a]=u,e}}))}_getOverzoomTile(e,s){const{tileID:a,source:l,overzoomParameters:c}=e,{maxZoomTileID:u}=c,d=`${u.key}_${a.key}`,f=this.overzoomedTileResultCache.get(d);if(f)return f;const _=new m,S=this.layerIndex.familiesBySource[l];for(const e in S){const l=s.layers[e];if(!l)continue;const c=b(l,u,a.canonical);c.length>0&&_.addLayer(c)}const P=y(_);return this.overzoomedTileResultCache.set(d,P),P}reloadTile(s){return e._(this,void 0,void 0,(function*(){const a=s.uid;if(!this.loaded||!this.loaded[a])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const l=this.loaded[a];if(l.showCollisionBoxes=s.showCollisionBoxes,"parsing"===l.status){const c=yield l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,s.subdivisionGranularity);let u;if(this.fetching[a]){const{rawTileData:l,cacheControl:d,resourceTiming:f}=this.fetching[a];delete this.fetching[a],u=e.e({rawTileData:l.slice(0),encoding:s.encoding},c,d,f)}else u=c;return u}if("done"===l.status&&l.vectorTile)return l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,s.subdivisionGranularity)}))}abortTile(s){return e._(this,void 0,void 0,(function*(){const e=this.loading,a=s.uid;e&&e[a]&&e[a].abort&&(e[a].abort.abort(),delete e[a])}))}removeTile(s){return e._(this,void 0,void 0,(function*(){this.loaded&&this.loaded[s.uid]&&delete this.loaded[s.uid]}))}}class x{constructor(){this.loaded={}}loadTile(s){return e._(this,void 0,void 0,(function*(){const{uid:a,encoding:l,rawImageData:c,redFactor:u,greenFactor:d,blueFactor:f,baseShift:_}=s,y=c.width+2,b=c.height+2,S=e.b(c)?new e.R({width:y,height:b},yield e.cX(c,-1,-1,y,b)):c,P=new e.cY(a,S,l,u,d,f,_);return this.loaded=this.loaded||{},this.loaded[a]=P,P}))}removeTile(e){const s=this.loaded,a=e.uid;s&&s[a]&&delete s[a]}}var S,P,M=function(){if(P)return S;function e(e,a){if(0!==e.length){s(e[0],a);for(var l=1;l<e.length;l++)s(e[l],!a)}}function s(e,s){for(var a=0,l=0,c=0,u=e.length,d=u-1;c<u;d=c++){var f=(e[c][0]-e[d][0])*(e[d][1]+e[c][1]),_=a+f;l+=Math.abs(a)>=Math.abs(f)?a-_+f:f-_+a,a=_}a+l>=0!=!!s&&e.reverse()}return P=1,S=function s(a,l){var c,u=a&&a.type;if("FeatureCollection"===u)for(c=0;c<a.features.length;c++)s(a.features[c],l);else if("GeometryCollection"===u)for(c=0;c<a.geometries.length;c++)s(a.geometries[c],l);else if("Feature"===u)s(a.geometry,l);else if("Polygon"===u)e(a.coordinates,l);else if("MultiPolygon"===u)for(c=0;c<a.coordinates.length;c++)e(a.coordinates[c],l);return a}}(),C=e.cZ(M);const D={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},L=Math.fround||(F=new Float32Array(1),e=>(F[0]=+e,F[0]));var F;class T{constructor(e){this.options=Object.assign(Object.create(D),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:s,minZoom:a,maxZoom:l}=this.options;s&&console.time("total time");const c=`prepare ${e.length} points`;s&&console.time(c),this.points=e;const u=[];for(let s=0;s<e.length;s++){const a=e[s];if(!a.geometry)continue;const[l,c]=a.geometry.coordinates,d=L(V(l)),f=L(N(c));u.push(d,f,1/0,s,-1,1),this.options.reduce&&u.push(0)}let d=this.trees[l+1]=this._createTree(u);s&&console.timeEnd(c);for(let e=l;e>=a;e--){const a=+Date.now();d=this.trees[e]=this._createTree(this._cluster(d,e)),s&&console.log("z%d: %d clusters in %dms",e,d.numItems,+Date.now()-a)}return s&&console.timeEnd("total time"),this}getClusters(e,s){let a=((e[0]+180)%360+360)%360-180;const l=Math.max(-90,Math.min(90,e[1]));let c=180===e[2]?180:((e[2]+180)%360+360)%360-180;const u=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)a=-180,c=180;else if(a>c){const e=this.getClusters([a,l,180,u],s),d=this.getClusters([-180,l,c,u],s);return e.concat(d)}const d=this.trees[this._limitZoom(s)],f=d.range(V(a),N(u),V(c),N(l)),_=d.data,y=[];for(const e of f){const s=this.stride*e;y.push(_[s+5]>1?B(_,s,this.clusterProps):this.points[_[s+3]])}return y}getChildren(e){const s=this._getOriginId(e),a=this._getOriginZoom(e),l="No cluster with the specified id.",c=this.trees[a];if(!c)throw new Error(l);const u=c.data;if(s*this.stride>=u.length)throw new Error(l);const d=this.options.radius/(this.options.extent*Math.pow(2,a-1)),f=c.within(u[s*this.stride],u[s*this.stride+1],d),_=[];for(const s of f){const a=s*this.stride;u[a+4]===e&&_.push(u[a+5]>1?B(u,a,this.clusterProps):this.points[u[a+3]])}if(0===_.length)throw new Error(l);return _}getLeaves(e,s,a){const l=[];return this._appendLeaves(l,e,s=s||10,a=a||0,0),l}getTile(e,s,a){const l=this.trees[this._limitZoom(e)],c=Math.pow(2,e),{extent:u,radius:d}=this.options,f=d/u,_=(a-f)/c,y=(a+1+f)/c,b={features:[]};return this._addTileFeatures(l.range((s-f)/c,_,(s+1+f)/c,y),l.data,s,a,c,b),0===s&&this._addTileFeatures(l.range(1-f/c,_,1,y),l.data,c,a,c,b),s===c-1&&this._addTileFeatures(l.range(0,_,f/c,y),l.data,-1,a,c,b),b.features.length?b:null}getClusterExpansionZoom(e){let s=this._getOriginZoom(e)-1;for(;s<=this.options.maxZoom;){const a=this.getChildren(e);if(s++,1!==a.length)break;e=a[0].properties.cluster_id}return s}_appendLeaves(e,s,a,l,c){const u=this.getChildren(s);for(const s of u){const u=s.properties;if(u&&u.cluster?c+u.point_count<=l?c+=u.point_count:c=this._appendLeaves(e,u.cluster_id,a,l,c):c<l?c++:e.push(s),e.length===a)break}return c}_createTree(s){const a=new e.aN(s.length/this.stride|0,this.options.nodeSize,Float32Array);for(let e=0;e<s.length;e+=this.stride)a.add(s[e],s[e+1]);return a.finish(),a.data=s,a}_addTileFeatures(e,s,a,l,c,u){for(const d of e){const e=d*this.stride,f=s[e+5]>1;let _,y,b;if(f)_=O(s,e,this.clusterProps),y=s[e],b=s[e+1];else{const a=this.points[s[e+3]];_=a.properties;const[l,c]=a.geometry.coordinates;y=V(l),b=N(c)}const S={type:1,geometry:[[Math.round(this.options.extent*(y*c-a)),Math.round(this.options.extent*(b*c-l))]],tags:_};let P;P=f||this.options.generateId?s[e+3]:this.points[s[e+3]].id,void 0!==P&&(S.id=P),u.features.push(S)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,s){const{radius:a,extent:l,reduce:c,minPoints:u}=this.options,d=a/(l*Math.pow(2,s)),f=e.data,_=[],y=this.stride;for(let a=0;a<f.length;a+=y){if(f[a+2]<=s)continue;f[a+2]=s;const l=f[a],b=f[a+1],S=e.within(f[a],f[a+1],d),P=f[a+5];let M=P;for(const e of S){const a=e*y;f[a+2]>s&&(M+=f[a+5])}if(M>P&&M>=u){let e,u=l*P,d=b*P,C=-1;const D=(a/y<<5)+(s+1)+this.points.length;for(const l of S){const _=l*y;if(f[_+2]<=s)continue;f[_+2]=s;const b=f[_+5];u+=f[_]*b,d+=f[_+1]*b,f[_+4]=D,c&&(e||(e=this._map(f,a,!0),C=this.clusterProps.length,this.clusterProps.push(e)),c(e,this._map(f,_)))}f[a+4]=D,_.push(u/M,d/M,1/0,D,-1,M),c&&_.push(C)}else{for(let e=0;e<y;e++)_.push(f[a+e]);if(M>1)for(const e of S){const a=e*y;if(!(f[a+2]<=s)){f[a+2]=s;for(let e=0;e<y;e++)_.push(f[a+e])}}}}return _}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,s,a){if(e[s+5]>1){const l=this.clusterProps[e[s+6]];return a?Object.assign({},l):l}const l=this.points[e[s+3]].properties,c=this.options.map(l);return a&&c===l?Object.assign({},c):c}}function B(e,s,a){return{type:"Feature",id:e[s+3],properties:O(e,s,a),geometry:{type:"Point",coordinates:[(l=e[s],360*(l-.5)),j(e[s+1])]}};var l}function O(e,s,a){const l=e[s+5],c=l>=1e4?`${Math.round(l/1e3)}k`:l>=1e3?Math.round(l/100)/10+"k":l,u=e[s+6],d=-1===u?{}:Object.assign({},a[u]);return Object.assign(d,{cluster:!0,cluster_id:e[s+3],point_count:l,point_count_abbreviated:c})}function V(e){return e/360+.5}function N(e){const s=Math.sin(e*Math.PI/180),a=.5-.25*Math.log((1+s)/(1-s))/Math.PI;return a<0?0:a>1?1:a}function j(e){const s=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(s))/Math.PI-90}function G(e,s,a,l){let c=l;const u=s+(a-s>>1);let d,f=a-s;const _=e[s],y=e[s+1],b=e[a],S=e[a+1];for(let l=s+3;l<a;l+=3){const s=Z(e[l],e[l+1],_,y,b,S);if(s>c)d=l,c=s;else if(s===c){const e=Math.abs(l-u);e<f&&(d=l,f=e)}}c>l&&(d-s>3&&G(e,s,d,l),e[d+2]=c,a-d>3&&G(e,d,a,l))}function Z(e,s,a,l,c,u){let d=c-a,f=u-l;if(0!==d||0!==f){const _=((e-a)*d+(s-l)*f)/(d*d+f*f);_>1?(a=c,l=u):_>0&&(a+=d*_,l+=f*_)}return d=e-a,f=s-l,d*d+f*f}function q(e,s,a,l){const c={id:null==e?null:e,type:s,geometry:a,tags:l,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===s||"MultiPoint"===s||"LineString"===s)W(c,a);else if("Polygon"===s)W(c,a[0]);else if("MultiLineString"===s)for(const e of a)W(c,e);else if("MultiPolygon"===s)for(const e of a)W(c,e[0]);return c}function W(e,s){for(let a=0;a<s.length;a+=3)e.minX=Math.min(e.minX,s[a]),e.minY=Math.min(e.minY,s[a+1]),e.maxX=Math.max(e.maxX,s[a]),e.maxY=Math.max(e.maxY,s[a+1])}function J(e,s,a,l){if(!s.geometry)return;const c=s.geometry.coordinates;if(c&&0===c.length)return;const u=s.geometry.type,d=Math.pow(a.tolerance/((1<<a.maxZoom)*a.extent),2);let f=[],_=s.id;if(a.promoteId?_=s.properties[a.promoteId]:a.generateId&&(_=l||0),"Point"===u)Q(c,f);else if("MultiPoint"===u)for(const e of c)Q(e,f);else if("LineString"===u)se(c,f,d,!1);else if("MultiLineString"===u){if(a.lineMetrics){for(const a of c)f=[],se(a,f,d,!1),e.push(q(_,"LineString",f,s.properties));return}oe(c,f,d,!1)}else if("Polygon"===u)oe(c,f,d,!0);else{if("MultiPolygon"!==u){if("GeometryCollection"===u){for(const c of s.geometry.geometries)J(e,{id:_,geometry:c,properties:s.properties},a,l);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const e of c){const s=[];oe(e,s,d,!0),f.push(s)}}e.push(q(_,u,f,s.properties))}function Q(e,s){s.push(ce(e[0]),pe(e[1]),0)}function se(e,s,a,l){let c,u,d=0;for(let a=0;a<e.length;a++){const f=ce(e[a][0]),_=pe(e[a][1]);s.push(f,_,0),a>0&&(d+=l?(c*_-f*u)/2:Math.sqrt(Math.pow(f-c,2)+Math.pow(_-u,2))),c=f,u=_}const f=s.length-3;s[2]=1,G(s,0,f,a),s[f+2]=1,s.size=Math.abs(d),s.start=0,s.end=s.size}function oe(e,s,a,l){for(let c=0;c<e.length;c++){const u=[];se(e[c],u,a,l),s.push(u)}}function ce(e){return e/360+.5}function pe(e){const s=Math.sin(e*Math.PI/180),a=.5-.25*Math.log((1+s)/(1-s))/Math.PI;return a<0?0:a>1?1:a}function fe(e,s,a,l,c,u,d,f){if(l/=s,u>=(a/=s)&&d<l)return e;if(d<a||u>=l)return null;const _=[];for(const s of e){const e=s.geometry;let u=s.type;const d=0===c?s.minX:s.minY,y=0===c?s.maxX:s.maxY;if(d>=a&&y<l){_.push(s);continue}if(y<a||d>=l)continue;let b=[];if("Point"===u||"MultiPoint"===u)xe(e,b,a,l,c);else if("LineString"===u)ve(e,b,a,l,c,!1,f.lineMetrics);else if("MultiLineString"===u)we(e,b,a,l,c,!1);else if("Polygon"===u)we(e,b,a,l,c,!0);else if("MultiPolygon"===u)for(const s of e){const e=[];we(s,e,a,l,c,!0),e.length&&b.push(e)}if(b.length){if(f.lineMetrics&&"LineString"===u){for(const e of b)_.push(q(s.id,u,e,s.tags));continue}"LineString"!==u&&"MultiLineString"!==u||(1===b.length?(u="LineString",b=b[0]):u="MultiLineString"),"Point"!==u&&"MultiPoint"!==u||(u=3===b.length?"Point":"MultiPoint"),_.push(q(s.id,u,b,s.tags))}}return _.length?_:null}function xe(e,s,a,l,c){for(let u=0;u<e.length;u+=3){const d=e[u+c];d>=a&&d<=l&&Te(s,e[u],e[u+1],e[u+2])}}function ve(e,s,a,l,c,u,d){let f=be(e);const _=0===c?Se:Me;let y,b,S=e.start;for(let P=0;P<e.length-3;P+=3){const M=e[P],C=e[P+1],D=e[P+2],L=e[P+3],F=e[P+4],B=0===c?M:C,O=0===c?L:F;let V=!1;d&&(y=Math.sqrt(Math.pow(M-L,2)+Math.pow(C-F,2))),B<a?O>a&&(b=_(f,M,C,L,F,a),d&&(f.start=S+y*b)):B>l?O<l&&(b=_(f,M,C,L,F,l),d&&(f.start=S+y*b)):Te(f,M,C,D),O<a&&B>=a&&(b=_(f,M,C,L,F,a),V=!0),O>l&&B<=l&&(b=_(f,M,C,L,F,l),V=!0),!u&&V&&(d&&(f.end=S+y*b),s.push(f),f=be(e)),d&&(S+=y)}let P=e.length-3;const M=e[P],C=e[P+1],D=0===c?M:C;D>=a&&D<=l&&Te(f,M,C,e[P+2]),P=f.length-3,u&&P>=3&&(f[P]!==f[0]||f[P+1]!==f[1])&&Te(f,f[0],f[1],f[2]),f.length&&s.push(f)}function be(e){const s=[];return s.size=e.size,s.start=e.start,s.end=e.end,s}function we(e,s,a,l,c,u){for(const d of e)ve(d,s,a,l,c,u,!1)}function Te(e,s,a,l){e.push(s,a,l)}function Se(e,s,a,l,c,u){const d=(u-s)/(l-s);return Te(e,u,a+(c-a)*d,1),d}function Me(e,s,a,l,c,u){const d=(u-a)/(c-a);return Te(e,s+(l-s)*d,u,1),d}function Ee(e,s){const a=[];for(let l=0;l<e.length;l++){const c=e[l],u=c.type;let d;if("Point"===u||"MultiPoint"===u||"LineString"===u)d=Ce(c.geometry,s);else if("MultiLineString"===u||"Polygon"===u){d=[];for(const e of c.geometry)d.push(Ce(e,s))}else if("MultiPolygon"===u){d=[];for(const e of c.geometry){const a=[];for(const l of e)a.push(Ce(l,s));d.push(a)}}a.push(q(c.id,u,d,c.tags))}return a}function Ce(e,s){const a=[];a.size=e.size,void 0!==e.start&&(a.start=e.start,a.end=e.end);for(let l=0;l<e.length;l+=3)a.push(e[l]+s,e[l+1],e[l+2]);return a}function Ae(e,s){if(e.transformed)return e;const a=1<<e.z,l=e.x,c=e.y;for(const u of e.features){const e=u.geometry,d=u.type;if(u.geometry=[],1===d)for(let d=0;d<e.length;d+=2)u.geometry.push(ke(e[d],e[d+1],s,a,l,c));else for(let d=0;d<e.length;d++){const f=[];for(let u=0;u<e[d].length;u+=2)f.push(ke(e[d][u],e[d][u+1],s,a,l,c));u.geometry.push(f)}}return e.transformed=!0,e}function ke(e,s,a,l,c,u){return[Math.round(a*(e*l-c)),Math.round(a*(s*l-u))]}function Le(e,s,a,l,c){const u=s===c.maxZoom?0:c.tolerance/((1<<s)*c.extent),d={features:[],numPoints:0,numSimplified:0,numFeatures:e.length,source:null,x:a,y:l,z:s,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const s of e)Fe(d,s,u,c);return d}function Fe(e,s,a,l){const c=s.geometry,u=s.type,d=[];if(e.minX=Math.min(e.minX,s.minX),e.minY=Math.min(e.minY,s.minY),e.maxX=Math.max(e.maxX,s.maxX),e.maxY=Math.max(e.maxY,s.maxY),"Point"===u||"MultiPoint"===u)for(let s=0;s<c.length;s+=3)d.push(c[s],c[s+1]),e.numPoints++,e.numSimplified++;else if("LineString"===u)Oe(d,c,e,a,!1,!1);else if("MultiLineString"===u||"Polygon"===u)for(let s=0;s<c.length;s++)Oe(d,c[s],e,a,"Polygon"===u,0===s);else if("MultiPolygon"===u)for(let s=0;s<c.length;s++){const l=c[s];for(let s=0;s<l.length;s++)Oe(d,l[s],e,a,!0,0===s)}if(d.length){let a=s.tags||null;if("LineString"===u&&l.lineMetrics){a={};for(const e in s.tags)a[e]=s.tags[e];a.mapbox_clip_start=c.start/c.size,a.mapbox_clip_end=c.end/c.size}const f={geometry:d,type:"Polygon"===u||"MultiPolygon"===u?3:"LineString"===u||"MultiLineString"===u?2:1,tags:a};null!==s.id&&(f.id=s.id),e.features.push(f)}}function Oe(e,s,a,l,c,u){const d=l*l;if(l>0&&s.size<(c?d:l))return void(a.numPoints+=s.length/3);const f=[];for(let e=0;e<s.length;e+=3)(0===l||s[e+2]>d)&&(a.numSimplified++,f.push(s[e],s[e+1])),a.numPoints++;c&&function(e,s){let a=0;for(let s=0,l=e.length,c=l-2;s<l;c=s,s+=2)a+=(e[s]-e[c])*(e[s+1]+e[c+1]);if(a>0===s)for(let s=0,a=e.length;s<a/2;s+=2){const l=e[s],c=e[s+1];e[s]=e[a-2-s],e[s+1]=e[a-1-s],e[a-2-s]=l,e[a-1-s]=c}}(f,u),e.push(f)}const Ve={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class re{constructor(e,s){const a=(s=this.options=function(e,s){for(const a in s)e[a]=s[a];return e}(Object.create(Ve),s)).debug;if(a&&console.time("preprocess data"),s.maxZoom<0||s.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(s.promoteId&&s.generateId)throw new Error("promoteId and generateId cannot be used together.");let l=function(e,s){const a=[];if("FeatureCollection"===e.type)for(let l=0;l<e.features.length;l++)J(a,e.features[l],s,l);else J(a,"Feature"===e.type?e:{geometry:e},s);return a}(e,s);this.tiles={},this.tileCoords=[],a&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",s.indexMaxZoom,s.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),l=function(e,s){const a=s.buffer/s.extent;let l=e;const c=fe(e,1,-1-a,a,0,-1,2,s),u=fe(e,1,1-a,2+a,0,-1,2,s);return(c||u)&&(l=fe(e,1,-a,1+a,0,-1,2,s)||[],c&&(l=Ee(c,1).concat(l)),u&&(l=l.concat(Ee(u,-1)))),l}(l,s),l.length&&this.splitTile(l,0,0,0),a&&(l.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}splitTile(e,s,a,l,c,u,d){const f=[e,s,a,l],_=this.options,y=_.debug;for(;f.length;){l=f.pop(),a=f.pop(),s=f.pop(),e=f.pop();const b=1<<s,S=Ne(s,a,l);let P=this.tiles[S];if(!P&&(y>1&&console.time("creation"),P=this.tiles[S]=Le(e,s,a,l,_),this.tileCoords.push({z:s,x:a,y:l}),y)){y>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",s,a,l,P.numFeatures,P.numPoints,P.numSimplified),console.timeEnd("creation"));const e=`z${s}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(P.source=e,null==c){if(s===_.indexMaxZoom||P.numPoints<=_.indexMaxPoints)continue}else{if(s===_.maxZoom||s===c)continue;if(null!=c){const e=c-s;if(a!==u>>e||l!==d>>e)continue}}if(P.source=null,0===e.length)continue;y>1&&console.time("clipping");const M=.5*_.buffer/_.extent,C=.5-M,D=.5+M,L=1+M;let F=null,B=null,O=null,V=null,N=fe(e,b,a-M,a+D,0,P.minX,P.maxX,_),j=fe(e,b,a+C,a+L,0,P.minX,P.maxX,_);e=null,N&&(F=fe(N,b,l-M,l+D,1,P.minY,P.maxY,_),B=fe(N,b,l+C,l+L,1,P.minY,P.maxY,_),N=null),j&&(O=fe(j,b,l-M,l+D,1,P.minY,P.maxY,_),V=fe(j,b,l+C,l+L,1,P.minY,P.maxY,_),j=null),y>1&&console.timeEnd("clipping"),f.push(F||[],s+1,2*a,2*l),f.push(B||[],s+1,2*a,2*l+1),f.push(O||[],s+1,2*a+1,2*l),f.push(V||[],s+1,2*a+1,2*l+1)}}getTile(e,s,a){e=+e,s=+s,a=+a;const l=this.options,{extent:c,debug:u}=l;if(e<0||e>24)return null;const d=1<<e,f=Ne(e,s=s+d&d-1,a);if(this.tiles[f])return Ae(this.tiles[f],c);u>1&&console.log("drilling down to z%d-%d-%d",e,s,a);let _,y=e,b=s,S=a;for(;!_&&y>0;)y--,b>>=1,S>>=1,_=this.tiles[Ne(y,b,S)];return _&&_.source?(u>1&&(console.log("found parent tile z%d-%d-%d",y,b,S),console.time("drilling down")),this.splitTile(_.source,y,b,S,e,s,a),u>1&&console.timeEnd("drilling down"),this.tiles[f]?Ae(this.tiles[f],c):null):null}}function Ne(e,s,a){return 32*((1<<e)*a+s)+e}class le extends w{constructor(e,s,a,l=je){super(e,s,a),this._dataUpdateable=new Map,this._createGeoJSONIndex=l}loadVectorTile(s,a){return e._(this,void 0,void 0,(function*(){const a=s.tileID.canonical;if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");const l=this._geoJSONIndex.getTile(a.z,a.x,a.y);return l?y(new r(l.features,{version:2,extent:e.a3})):null}))}loadData(s){return e._(this,void 0,void 0,(function*(){var a;null===(a=this._pendingRequest)||void 0===a||a.abort();const l=!!(s&&s.request&&s.request.collectResourceTiming)&&new e.cW(s.request);this._pendingRequest=new AbortController;try{(!this._pendingData||s.request||s.data||s.dataDiff)&&(this._pendingData=this.loadAndProcessGeoJSON(s,this._pendingRequest));const e=yield this._pendingData;this._geoJSONIndex=this._createGeoJSONIndex(e,s),this.loaded={};const a={data:e};if(l){const e=l.finish();e&&(a.resourceTiming={},a.resourceTiming[s.source]=JSON.parse(JSON.stringify(e)))}return a}catch(s){if(delete this._pendingRequest,e.cC(s))return{abandoned:!0};throw s}}))}getData(){return e._(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(e){const s=this.loaded;return s&&s[e.uid]?super.reloadTile(e):this.loadTile(e)}loadAndProcessGeoJSON(s,a){return e._(this,void 0,void 0,(function*(){let l=yield this.loadGeoJSON(s,a);if(delete this._pendingRequest,"object"!=typeof l)throw new Error(`Input data given to '${s.source}' is not a valid GeoJSON object.`);if(C(l,!0),s.filter){const a=e.c_(s.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===a.result)throw new Error(a.value.map((e=>`${e.key}: ${e.message}`)).join(", "));const c=l.features.filter((e=>a.value.evaluate({zoom:0},e)));l={type:"FeatureCollection",features:c}}return l}))}loadGeoJSON(s,a){return e._(this,void 0,void 0,(function*(){const{promoteId:l}=s;if(s.request){const c=yield e.j(s.request,a);return this._dataUpdateable=e.d0(c.data,l)?e.c$(c.data,l):void 0,c.data}if("string"==typeof s.data)try{const a=JSON.parse(s.data);return this._dataUpdateable=e.d0(a,l)?e.c$(a,l):void 0,a}catch(e){throw new Error(`Input data given to '${s.source}' is not a valid GeoJSON object.`)}if(!s.dataDiff)throw new Error(`Input data given to '${s.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${s.source}`);return e.d1(this._dataUpdateable,s.dataDiff,l),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}}))}removeSource(s){return e._(this,void 0,void 0,(function*(){this._pendingRequest&&this._pendingRequest.abort()}))}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset)}}function je(s,a){return a.cluster?new T(function({superclusterOptions:s,clusterProperties:a}){if(!a||!s)return s;const l={},c={},u={accumulated:null,zoom:0},d={properties:null},f=Object.keys(a);for(const s of f){const[u,d]=a[s],f=e.c_(d),_=e.c_("string"==typeof u?[u,["accumulated"],["get",s]]:u);l[s]=f.value,c[s]=_.value}return s.map=e=>{d.properties=e;const s={};for(const e of f)s[e]=l[e].evaluate(u,d);return s},s.reduce=(e,s)=>{d.properties=s;for(const s of f)u.accumulated=e[s],e[s]=c[s].evaluate(u,d)},s}(a)).load(s.features):function(e,s){return new re(e,s)}(s,a.geojsonVtOptions)}class he{constructor(s){this.self=s,this.actor=new e.K(s),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(e,s)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=s},this.self.addProtocol=e.cE,this.self.removeProtocol=e.cF,this.self.registerRTLTextPlugin=s=>{e.d2.setMethods(s)},this.actor.registerMessageHandler("LDT",((e,s)=>this._getDEMWorkerSource(e,s.source).loadTile(s))),this.actor.registerMessageHandler("RDT",((s,a)=>e._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(s,a.source).removeTile(a)})))),this.actor.registerMessageHandler("GCEZ",((s,a)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(s,a.type,a.source).getClusterExpansionZoom(a)})))),this.actor.registerMessageHandler("GCC",((s,a)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(s,a.type,a.source).getClusterChildren(a)})))),this.actor.registerMessageHandler("GCL",((s,a)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(s,a.type,a.source).getClusterLeaves(a)})))),this.actor.registerMessageHandler("LD",((e,s)=>this._getWorkerSource(e,s.type,s.source).loadData(s))),this.actor.registerMessageHandler("GD",((e,s)=>this._getWorkerSource(e,s.type,s.source).getData())),this.actor.registerMessageHandler("LT",((e,s)=>this._getWorkerSource(e,s.type,s.source).loadTile(s))),this.actor.registerMessageHandler("RT",((e,s)=>this._getWorkerSource(e,s.type,s.source).reloadTile(s))),this.actor.registerMessageHandler("AT",((e,s)=>this._getWorkerSource(e,s.type,s.source).abortTile(s))),this.actor.registerMessageHandler("RMT",((e,s)=>this._getWorkerSource(e,s.type,s.source).removeTile(s))),this.actor.registerMessageHandler("RS",((s,a)=>e._(this,void 0,void 0,(function*(){if(!this.workerSources[s]||!this.workerSources[s][a.type]||!this.workerSources[s][a.type][a.source])return;const e=this.workerSources[s][a.type][a.source];delete this.workerSources[s][a.type][a.source],void 0!==e.removeSource&&e.removeSource(a)})))),this.actor.registerMessageHandler("RM",(s=>e._(this,void 0,void 0,(function*(){delete this.layerIndexes[s],delete this.availableImages[s],delete this.workerSources[s],delete this.demWorkerSources[s],this.globalStates.delete(s)})))),this.actor.registerMessageHandler("SR",((s,a)=>e._(this,void 0,void 0,(function*(){this.referrer=a})))),this.actor.registerMessageHandler("SRPS",((e,s)=>this._syncRTLPluginState(e,s))),this.actor.registerMessageHandler("IS",((s,a)=>e._(this,void 0,void 0,(function*(){this.self.importScripts(a)})))),this.actor.registerMessageHandler("SI",((e,s)=>this._setImages(e,s))),this.actor.registerMessageHandler("UL",((s,a)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(s).update(a.layers,a.removedIds,this._getGlobalState(s))})))),this.actor.registerMessageHandler("UGS",((s,a)=>e._(this,void 0,void 0,(function*(){const e=this._getGlobalState(s);for(const s in a)e[s]=a[s]})))),this.actor.registerMessageHandler("SL",((s,a)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(s).replace(a,this._getGlobalState(s))}))))}_getGlobalState(e){let s=this.globalStates.get(e);return s||(s={},this.globalStates.set(e,s)),s}_setImages(s,a){return e._(this,void 0,void 0,(function*(){this.availableImages[s]=a;for(const e in this.workerSources[s]){const l=this.workerSources[s][e];for(const e in l)l[e].availableImages=a}}))}_syncRTLPluginState(s,a){return e._(this,void 0,void 0,(function*(){return yield e.d2.syncState(a,this.self.importScripts)}))}_getAvailableImages(e){let s=this.availableImages[e];return s||(s=[]),s}_getLayerIndex(e){let s=this.layerIndexes[e];return s||(s=this.layerIndexes[e]=new t),s}_getWorkerSource(e,s,a){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][s]||(this.workerSources[e][s]={}),!this.workerSources[e][s][a]){const l={sendAsync:(s,a)=>(s.targetMapId=e,this.actor.sendAsync(s,a))};switch(s){case"vector":this.workerSources[e][s][a]=new w(l,this._getLayerIndex(e),this._getAvailableImages(e));break;case"geojson":this.workerSources[e][s][a]=new le(l,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][s][a]=new this.externalWorkerSourceTypes[s](l,this._getLayerIndex(e),this._getAvailableImages(e))}}return this.workerSources[e][s][a]}_getDEMWorkerSource(e,s){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][s]||(this.demWorkerSources[e][s]=new x),this.demWorkerSources[e][s]}}return e.i(self)&&(self.worker=new he(self)),he}));l("index",["exports","./shared"],(function(s,a){var l="5.12.0";function c(){var e=new a.A(4);return a.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let u,d,f;const _={frame(e,s,l){const c=requestAnimationFrame((e=>{u(),s(e)})),{unsubscribe:u}=a.s(e.signal,"abort",(()=>{u(),cancelAnimationFrame(c),l(a.c())}),!1)},frameAsync(e){return new Promise(((s,a)=>{this.frame(e,s,a)}))},getImageData(e,s=0){return this.getImageCanvasContext(e).getImageData(-s,-s,e.width+2*s,e.height+2*s)},getImageCanvasContext(e){const s=window.document.createElement("canvas"),a=s.getContext("2d",{willReadFrequently:!0});if(!a)throw new Error("failed to create canvas 2d context");return s.width=e.width,s.height=e.height,a.drawImage(e,0,0,e.width,e.height),a},resolveURL:e=>(u||(u=document.createElement("a")),u.href=e,u.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return void 0!==f?f:!!matchMedia&&(null==d&&(d=matchMedia("(prefers-reduced-motion: reduce)")),d.matches)},set prefersReducedMotion(e){f=e}},y=new class{constructor(){this._realTime="undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),this._frozenAt=null}getCurrentTime(){return null!==this._frozenAt?this._frozenAt:this._realTime()}setNow(e){this._frozenAt=e}restoreNow(){this._frozenAt=null}isFrozen(){return null!==this._frozenAt}};function b(){return y.getCurrentTime()}class h{static testProp(e){if(!h.docStyle)return e[0];for(let s=0;s<e.length;s++)if(e[s]in h.docStyle)return e[s];return e[0]}static create(e,s,a){const l=window.document.createElement(e);return void 0!==s&&(l.className=s),a&&a.appendChild(l),l}static createNS(e,s){return window.document.createElementNS(e,s)}static disableDrag(){h.docStyle&&h.selectProp&&(h.userSelect=h.docStyle[h.selectProp],h.docStyle[h.selectProp]="none")}static enableDrag(){h.docStyle&&h.selectProp&&(h.docStyle[h.selectProp]=h.userSelect)}static setTransform(e,s){e.style[h.transformProp]=s}static addEventListener(e,s,a,l={}){e.addEventListener(s,a,"passive"in l?l:l.capture)}static removeEventListener(e,s,a,l={}){e.removeEventListener(s,a,"passive"in l?l:l.capture)}static suppressClickInternal(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",h.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",h.suppressClickInternal,!0),window.setTimeout((()=>{window.removeEventListener("click",h.suppressClickInternal,!0)}),0)}static getScale(e){const s=e.getBoundingClientRect();return{x:s.width/e.offsetWidth||1,y:s.height/e.offsetHeight||1,boundingClientRect:s}}static getPoint(e,s,l){const c=s.boundingClientRect;return new a.P((l.clientX-c.left)/s.x-e.clientLeft,(l.clientY-c.top)/s.y-e.clientTop)}static mousePos(e,s){const a=h.getScale(e);return h.getPoint(e,a,s)}static touchPos(e,s){const a=[],l=h.getScale(e);for(let c=0;c<s.length;c++)a.push(h.getPoint(e,l,s[c]));return a}static mouseButton(e){return e.button}static remove(e){e.parentNode&&e.parentNode.removeChild(e)}static sanitize(e){const s=(new DOMParser).parseFromString(e,"text/html").body||document.createElement("body"),a=s.querySelectorAll("script");for(const e of a)e.remove();return h.clean(s),s.innerHTML}static isPossiblyDangerous(e,s){const a=s.replace(/\s+/g,"").toLowerCase();return!(!["src","href","xlink:href"].includes(e)||!a.includes("javascript:")&&!a.includes("data:"))||!!e.startsWith("on")||void 0}static clean(e){const s=e.children;for(const e of s)h.removeAttributes(e),h.clean(e)}static removeAttributes(e){for(const{name:s,value:a}of e.attributes)h.isPossiblyDangerous(s,a)&&e.removeAttribute(s)}}h.docStyle="undefined"!=typeof window&&window.document&&window.document.documentElement.style,h.selectProp=h.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),h.transformProp=h.testProp(["transform","WebkitTransform"]);const S={supported:!1,testSupport:function(e){!C&&M&&(D?L(e):P=e)}};let P,M,C=!1,D=!1;function L(e){const s=e.createTexture();e.bindTexture(e.TEXTURE_2D,s);try{if(e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,M),e.isContextLost())return;S.supported=!0}catch(e){}e.deleteTexture(s),C=!0}var F;"undefined"!=typeof document&&(M=document.createElement("img"),M.onload=()=>{P&&L(P),P=null,D=!0},M.onerror=()=>{C=!0,P=null},M.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(s){let l,c,u,d;s.resetRequestQueue=()=>{l=[],c=0,u=0,d={}},s.addThrottleControl=e=>{const s=u++;return d[s]=e,s},s.removeThrottleControl=e=>{delete d[e],_()},s.getImage=(e,s,c=!0)=>new Promise(((u,d)=>{S.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),a.e(e,{type:"image"}),l.push({abortController:s,requestParameters:e,supportImageRefresh:c,state:"queued",onError:e=>{d(e)},onSuccess:e=>{u(e)}}),_()}));const f=s=>a._(this||e,void 0,void 0,(function*(){s.state="running";const{requestParameters:e,supportImageRefresh:l,onError:u,onSuccess:d,abortController:f}=s,b=!1===l&&!a.i(self)&&!a.g(e.url)&&(!e.headers||Object.keys(e.headers).reduce(((e,s)=>e&&"accept"===s),!0));c++;const S=b?y(e,f):a.m(e,f);try{const e=yield S;delete s.abortController,s.state="completed",e.data instanceof HTMLImageElement||a.b(e.data)?d(e):e.data&&d({data:yield(P=e.data,"function"==typeof createImageBitmap?a.f(P):a.h(P)),cacheControl:e.cacheControl,expires:e.expires})}catch(e){delete s.abortController,u(e)}finally{c--,_()}var P})),_=()=>{const e=(()=>{for(const e of Object.keys(d))if(d[e]())return!0;return!1})()?a.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:a.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let s=c;s<e&&l.length>0;s++){const e=l.shift();e.abortController.signal.aborted?s--:f(e)}},y=(e,s)=>new Promise(((l,c)=>{const u=new Image,d=e.url,f=e.credentials;f&&"include"===f?u.crossOrigin="use-credentials":(f&&"same-origin"===f||!a.d(d))&&(u.crossOrigin="anonymous"),s.signal.addEventListener("abort",(()=>{u.src="",c(a.c())})),u.fetchPriority="high",u.onload=()=>{u.onerror=u.onload=null,l({data:u})},u.onerror=()=>{u.onerror=u.onload=null,s.signal.aborted||c(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."))},u.src=d}))}(F||(F={})),F.resetRequestQueue();class v{constructor(e){this._transformRequestFn=null!=e?e:null}transformRequest(e,s){return this._transformRequestFn&&this._transformRequestFn(e,s)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function B(e){const s=[];if("string"==typeof e)s.push({id:"default",url:e});else if(e&&e.length>0){const a=[];for(const{id:l,url:c}of e){const e=`${l}${c}`;-1===a.indexOf(e)&&(a.push(e),s.push({id:l,url:c}))}}return s}function O(e,s,a){try{const l=new URL(e);return l.pathname+=`${s}${a}`,l.toString()}catch(s){throw new Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function V(e){const{userImage:s}=e;return!!(s&&s.render&&s.render())&&(e.data.replace(new Uint8Array(s.data.buffer)),!0)}class w extends a.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new a.R({width:1,height:1}),this.dirty=!0}destroy(){this.atlasTexture&&(this.atlasTexture.destroy(),this.atlasTexture=null);for(const e of Object.keys(this.images))this.removeImage(e);this.patterns={},this.atlasImage=new a.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,promiseResolve:s}of this.requestors)s(this._getImagesForIds(e));this.requestors=[]}}getImage(e){const s=this.images[e];if(s&&!s.data&&s.spriteData){const e=s.spriteData;s.data=new a.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),s.spriteData=null}return s}addImage(e,s){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,s)&&(this.images[e]=s)}_validate(e,s){let l=!0;const c=s.data||s.spriteData;return this._validateStretch(s.stretchX,c&&c.width)||(this.fire(new a.k(new Error(`Image "${e}" has invalid "stretchX" value`))),l=!1),this._validateStretch(s.stretchY,c&&c.height)||(this.fire(new a.k(new Error(`Image "${e}" has invalid "stretchY" value`))),l=!1),this._validateContent(s.content,s)||(this.fire(new a.k(new Error(`Image "${e}" has invalid "content" value`))),l=!1),l}_validateStretch(e,s){if(!e)return!0;let a=0;for(const l of e){if(l[0]<a||l[1]<l[0]||s<l[1])return!1;a=l[1]}return!0}_validateContent(e,s){if(!e)return!0;if(4!==e.length)return!1;const a=s.spriteData,l=a&&a.width||s.data.width,c=a&&a.height||s.data.height;return!(e[0]<0||l<e[0]||e[1]<0||c<e[1]||e[2]<0||l<e[2]||e[3]<0||c<e[3]||e[2]<e[0]||e[3]<e[1])}updateImage(e,s,a=!0){const l=this.getImage(e);if(a&&(l.data.width!==s.data.width||l.data.height!==s.data.height))throw new Error(`size mismatch between old image (${l.data.width}x${l.data.height}) and new image (${s.data.width}x${s.data.height}).`);s.version=l.version+1,this.images[e]=s,this.updatedImages[e]=!0}removeImage(e){const s=this.images[e];delete this.images[e],delete this.patterns[e],s.userImage&&s.userImage.onRemove&&s.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(e){return new Promise(((s,a)=>{let l=!0;if(!this.isLoaded())for(const s of e)this.images[s]||(l=!1);this.isLoaded()||l?s(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:s})}))}_getImagesForIds(e){const s={};for(const l of e){let e=this.getImage(l);e||(this.fire(new a.l("styleimagemissing",{id:l})),e=this.getImage(l)),e?s[l]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:a.w(`Image "${l}" 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.`)}return s}getPixelSize(){const{width:e,height:s}=this.atlasImage;return{width:e,height:s}}getPattern(e){const s=this.patterns[e],l=this.getImage(e);if(!l)return null;if(s&&s.position.version===l.version)return s.position;if(s)s.position.version=l.version;else{const s={w:l.data.width+2,h:l.data.height+2,x:0,y:0},c=new a.I(s,l);this.patterns[e]={bin:s,position:c}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const s=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new a.T(e,this.atlasImage,s.RGBA),this.atlasTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const s in this.patterns)e.push(this.patterns[s].bin);const{w:s,h:l}=a.p(e),c=this.atlasImage;c.resize({width:s||1,height:l||1});for(const e in this.patterns){const{bin:s}=this.patterns[e],l=s.x+1,u=s.y+1,d=this.getImage(e).data,f=d.width,_=d.height;a.R.copy(d,c,{x:0,y:0},{x:l,y:u},{width:f,height:_}),a.R.copy(d,c,{x:0,y:_-1},{x:l,y:u-1},{width:f,height:1}),a.R.copy(d,c,{x:0,y:0},{x:l,y:u+_},{width:f,height:1}),a.R.copy(d,c,{x:f-1,y:0},{x:l-1,y:u},{width:1,height:_}),a.R.copy(d,c,{x:0,y:0},{x:l+f,y:u},{width:1,height:_})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const s of e){if(this.callbackDispatchedThisFrame[s])continue;this.callbackDispatchedThisFrame[s]=!0;const e=this.getImage(s);e||a.w(`Image with ID: "${s}" was not found`),V(e)&&this.updateImage(s,e)}}cloneImages(){const e={};for(const s in this.images){const a=this.images[s];e[s]=Object.assign(Object.assign({},a),{data:a.data?a.data.clone():null})}return e}}const N=1e20;function j(e,s,a,l,c,u,d,f,_){for(let y=s;y<s+l;y++)G(e,a*u+y,u,c,d,f,_);for(let y=a;y<a+c;y++)G(e,y*u+s,1,l,d,f,_)}function G(e,s,a,l,c,u,d){u[0]=0,d[0]=-N,d[1]=N,c[0]=e[s];for(let f=1,_=0,y=0;f<l;f++){c[f]=e[s+f*a];const l=f*f;do{const e=u[_];y=(c[f]-c[e]+l-e*e)/(f-e)/2}while(y<=d[_]&&--_>-1);_++,u[_]=f,d[_]=y,d[_+1]=N}for(let f=0,_=0;f<l;f++){for(;d[_+1]<f;)_++;const l=u[_],y=f-l;e[s+f*a]=c[l]+y*y}}const Z=a.v.layout_symbol["text-font"].default.join(",");class I{constructor(e,s,a){this.requestManager=e,this.localIdeographFontFamily=s,this.entries={},this.lang=a}setURL(e){this.url=e}getGlyphs(e){return a._(this,void 0,void 0,(function*(){const s=[];for(const a in e)for(const l of e[a])s.push(this._getAndCacheGlyphsPromise(a,l));const a=yield Promise.all(s),l={};for(const{stack:e,id:s,glyph:c}of a)l[e]||(l[e]={}),l[e][s]=c&&{id:c.id,bitmap:c.bitmap.clone(),metrics:c.metrics};return l}))}_getAndCacheGlyphsPromise(e,s){return a._(this,void 0,void 0,(function*(){let a=this.entries[e];a||(a=this.entries[e]={glyphs:{},requests:{},ranges:{}});let l=a.glyphs[s];return void 0!==l?{stack:e,id:s,glyph:l}:!this.url||this._charUsesLocalIdeographFontFamily(s)?(l=a.glyphs[s]=this._drawGlyph(a,e,s),{stack:e,id:s,glyph:l}):yield this._downloadAndCacheRangePromise(e,s)}))}_downloadAndCacheRangePromise(e,s){return a._(this,void 0,void 0,(function*(){const a=Math.floor(s/256);if(256*a>65535)throw new Error("glyphs > 65535 not supported");const l=this.entries[e];if(l.ranges[a])return{stack:e,id:s,glyph:null};if(!l.requests[a]){const s=I.loadGlyphRange(e,a,this.url,this.requestManager);l.requests[a]=s}try{const c=yield l.requests[a];for(const e in c)l.glyphs[+e]=c[+e];return l.ranges[a]=!0,{stack:e,id:s,glyph:c[s]||null}}catch(c){const u=l.glyphs[s]=this._drawGlyph(l,e,s);return this._warnOnMissingGlyphRange(u,a,s,c),{stack:e,id:s,glyph:u}}}))}_warnOnMissingGlyphRange(e,s,l,c){const u=256*s,d=u+255,f=l.toString(16).padStart(4,"0").toUpperCase();a.w(`Unable to load glyph range ${s}, ${u}-${d}. Rendering codepoint U+${f} locally instead. ${c}`)}_charUsesLocalIdeographFontFamily(e){return!!this.localIdeographFontFamily&&a.q(e)}_drawGlyph(e,s,l){const c=s===Z&&""!==this.localIdeographFontFamily&&this._charUsesLocalIdeographFontFamily(l),u=c?"ideographTinySDF":"tinySDF";e[u]||(e[u]=this._createTinySDF(c?this.localIdeographFontFamily:s));const d=e[u].draw(String.fromCharCode(l));return{id:l,bitmap:new a.r({width:d.width||60,height:d.height||60},d.data),metrics:{width:d.glyphWidth/2||24,height:d.glyphHeight/2||24,left:d.glyphLeft/2+.5||0,top:d.glyphTop/2-27.5||-8,advance:d.glyphAdvance/2||24,isDoubleResolution:!0}}}_createTinySDF(e){const s=e?e.split(","):[];s.push("sans-serif");const a=s.map((e=>/[-\w]+/.test(e)?e:`'${CSS.escape(e)}'`)).join(",");return new I.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:a,fontWeight:this._fontWeight(s[0]),fontStyle:this._fontStyle(s[0]),lang:this.lang})}_fontStyle(e){return/italic/i.test(e)?"italic":/oblique/i.test(e)?"oblique":"normal"}_fontWeight(e){const s={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950};let a;for(const[l,c]of Object.entries(s))new RegExp(`\\b${l}\\b`,"i").test(e)&&(a=`${c}`);return a}destroy(){for(const e in this.entries){const s=this.entries[e];s.tinySDF&&(s.tinySDF=null),s.ideographTinySDF&&(s.ideographTinySDF=null),s.glyphs={},s.requests={},s.ranges={}}this.entries={}}}I.loadGlyphRange=function(s,l,c,u){return a._(this||e,void 0,void 0,(function*(){const e=256*l,d=e+255,f=u.transformRequest(c.replace("{fontstack}",s).replace("{range}",`${e}-${d}`),"Glyphs"),_=yield a.n(f,new AbortController);if(!_||!_.data)throw new Error(`Could not load glyph range. range: ${l}, ${e}-${d}`);const y={};for(const e of a.o(_.data))y[e.id]=e;return y}))},I.TinySDF=class{constructor({fontSize:e=24,buffer:s=3,radius:a=8,cutoff:l=.25,fontFamily:c="sans-serif",fontWeight:u="normal",fontStyle:d="normal",lang:f=null}={}){this.buffer=s,this.cutoff=l,this.radius=a,this.lang=f;const _=this.size=e+4*s,y=this._createCanvas(_),b=this.ctx=y.getContext("2d",{willReadFrequently:!0});b.font=`${d} ${u} ${e}px ${c}`,b.textBaseline="alphabetic",b.textAlign="left",b.fillStyle="black",this.gridOuter=new Float64Array(_*_),this.gridInner=new Float64Array(_*_),this.f=new Float64Array(_),this.z=new Float64Array(_+1),this.v=new Uint16Array(_)}_createCanvas(e){const s=document.createElement("canvas");return s.width=s.height=e,s}draw(e){const{width:s,actualBoundingBoxAscent:a,actualBoundingBoxDescent:l,actualBoundingBoxLeft:c,actualBoundingBoxRight:u}=this.ctx.measureText(e),d=Math.ceil(a),f=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(u-c))),_=Math.min(this.size-this.buffer,d+Math.ceil(l)),y=f+2*this.buffer,b=_+2*this.buffer,S=Math.max(y*b,0),P=new Uint8ClampedArray(S),M={data:P,width:y,height:b,glyphWidth:f,glyphHeight:_,glyphTop:d,glyphLeft:0,glyphAdvance:s};if(0===f||0===_)return M;const{ctx:C,buffer:D,gridInner:L,gridOuter:F}=this;this.lang&&(C.lang=this.lang),C.clearRect(D,D,f,_),C.fillText(e,D,D+d);const B=C.getImageData(D,D,f,_);F.fill(N,0,S),L.fill(0,0,S);for(let e=0;e<_;e++)for(let s=0;s<f;s++){const a=B.data[4*(e*f+s)+3]/255;if(0===a)continue;const l=(e+D)*y+s+D;if(1===a)F[l]=0,L[l]=N;else{const e=.5-a;F[l]=e>0?e*e:0,L[l]=e<0?e*e:0}}j(F,0,0,y,b,y,this.f,this.v,this.z),j(L,D,D,f,_,y,this.f,this.v,this.z);for(let e=0;e<S;e++){const s=Math.sqrt(F[e])-Math.sqrt(L[e]);P[e]=Math.round(255-255*(s/this.radius+this.cutoff))}return M}};class E{constructor(){this.specification=a.u.light.position}possiblyEvaluate(e,s){return a.C(e.expression.evaluate(s))}interpolate(e,s,l){return{x:a.F.number(e.x,s.x,l),y:a.F.number(e.y,s.y,l),z:a.F.number(e.z,s.z,l)}}}let q;class R extends a.E{constructor(e){super(),q=q||new a.t({anchor:new a.D(a.u.light.anchor),position:new E,color:new a.D(a.u.light.color),intensity:new a.D(a.u.light.intensity)}),this._transitionable=new a.x(q,void 0),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,s={}){if(!this._validate(a.y,e,s))for(const s in e){const a=e[s];s.endsWith("-transition")?this._transitionable.setTransition(s.slice(0,-11),a):this._transitionable.setValue(s,a)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,s,l){return(!l||!1!==l.validate)&&a.z(this,e.call(a.B,{value:s,style:{glyphs:!0,sprite:!0},styleSpec:a.u}))}}const W=new a.t({"sky-color":new a.D(a.u.sky["sky-color"]),"horizon-color":new a.D(a.u.sky["horizon-color"]),"fog-color":new a.D(a.u.sky["fog-color"]),"fog-ground-blend":new a.D(a.u.sky["fog-ground-blend"]),"horizon-fog-blend":new a.D(a.u.sky["horizon-fog-blend"]),"sky-horizon-blend":new a.D(a.u.sky["sky-horizon-blend"]),"atmosphere-blend":new a.D(a.u.sky["atmosphere-blend"])});class z extends a.E{constructor(e){super(),this._transitionable=new a.x(W,void 0),this.setSky(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new a.G(0))}setSky(e,s={}){if(!this._validate(a.H,e,s)){e||(e={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0});for(const s in e){const a=e[s];s.endsWith("-transition")?this._transitionable.setTransition(s.slice(0,-11),a):this._transitionable.setValue(s,a)}}}getSky(){return this._transitionable.serialize()}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,s,l={}){return!1!==(null==l?void 0:l.validate)&&a.z(this,e.call(a.B,a.e({value:s,style:{glyphs:!0,sprite:!0},styleSpec:a.u})))}calculateFogBlendOpacity(e){return e<60?0:e<70?(e-60)/10:1}}class A{constructor(e,s){this.width=e,this.height=s,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(e,s){const a=e.join(",")+String(s);return this.dashEntry[a]||(this.dashEntry[a]=this.addDash(e,s)),this.dashEntry[a]}getDashRanges(e,s,a){const l=[];let c=e.length%2==1?-e[e.length-1]*a:0,u=e[0]*a,d=!0;l.push({left:c,right:u,isDash:d,zeroLength:0===e[0]});let f=e[0];for(let s=1;s<e.length;s++){d=!d;const _=e[s];c=f*a,f+=_,u=f*a,l.push({left:c,right:u,isDash:d,zeroLength:0===_})}return l}addRoundDash(e,s,a){const l=s/2;for(let s=-a;s<=a;s++){const c=this.width*(this.nextRow+a+s);let u=0,d=e[u];for(let f=0;f<this.width;f++){f/d.right>1&&(d=e[++u]);const _=Math.abs(f-d.left),y=Math.abs(f-d.right),b=Math.min(_,y);let S;const P=s/a*(l+1);if(d.isDash){const e=l-Math.abs(P);S=Math.sqrt(b*b+e*e)}else S=l-Math.sqrt(b*b+P*P);this.data[c+f]=Math.max(0,Math.min(255,S+128))}}}addRegularDash(e){for(let s=e.length-1;s>=0;--s){const a=e[s],l=e[s+1];a.zeroLength?e.splice(s,1):l&&l.isDash===a.isDash&&(l.left=a.left,e.splice(s,1))}const s=e[0],a=e[e.length-1];s.isDash===a.isDash&&(s.left=a.left-this.width,a.right=s.right+this.width);const l=this.width*this.nextRow;let c=0,u=e[c];for(let s=0;s<this.width;s++){s/u.right>1&&(u=e[++c]);const a=Math.abs(s-u.left),d=Math.abs(s-u.right),f=Math.min(a,d);this.data[l+s]=Math.max(0,Math.min(255,(u.isDash?f:-f)+128))}}addDash(e,s){const l=s?7:0,c=2*l+1;if(this.nextRow+c>this.height)return a.w("LineAtlas out of space"),null;let u=0;for(let s=0;s<e.length;s++)u+=e[s];if(0!==u){const a=this.width/u,c=this.getDashRanges(e,this.width,a);s?this.addRoundDash(c,a,l):this.addRegularDash(c)}const d={y:this.nextRow+l,height:2*l,width:u};return this.nextRow+=c,this.dirty=!0,d}bind(e){const s=e.gl;this.texture?(s.bindTexture(s.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,s.texSubImage2D(s.TEXTURE_2D,0,0,0,this.width,this.height,s.ALPHA,s.UNSIGNED_BYTE,this.data))):(this.texture=s.createTexture(),s.bindTexture(s.TEXTURE_2D,this.texture),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.REPEAT),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.REPEAT),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texImage2D(s.TEXTURE_2D,0,s.ALPHA,this.width,this.height,0,s.ALPHA,s.UNSIGNED_BYTE,this.data))}}const J="maplibre_preloaded_worker_pool";class k{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length<k.workerCount;)this.workers.push(new Worker(a.a.WORKER_URL));return this.active[e]=!0,this.workers.slice()}release(e){delete this.active[e],0===this.numActive()&&(this.workers.forEach((e=>{e.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[J]}numActive(){return Object.keys(this.active).length}}const Q=Math.floor(_.hardwareConcurrency/2);let se,oe;function ce(){return se||(se=new k),se}k.workerCount=a.J(globalThis)?Math.max(Math.min(Q,3),1):1;class U{constructor(e,s){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=s;const l=this.workerPool.acquire(s);for(let e=0;e<l.length;e++){const c=new a.K(l[e],s);c.name=`Worker ${e}`,this.actors.push(c)}if(!this.actors.length)throw new Error("No actors found")}broadcast(e,s){const a=[];for(const l of this.actors)a.push(l.sendAsync({type:e,data:s}));return Promise.all(a)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(e=!0){this.actors.forEach((e=>{e.remove()})),this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,s){for(const a of this.actors)a.registerMessageHandler(e,s)}unregisterMessageHandler(e){for(const s of this.actors)s.unregisterMessageHandler(e)}}function pe(){return oe||(oe=new U(ce(),a.L),oe.registerMessageHandler("GR",((e,s,l)=>a.m(s,l)))),oe}function fe(e,s){const l=a.M();return a.N(l,l,[1,1,0]),a.O(l,l,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?a.Q(l,l,e.calculatePosMatrix(s.toUnwrapped())):l}function xe(e,s,a,l,c,u,d){var f;const _=function(e,s,a){if(e)for(const l of e){const e=s[l];if(e&&e.source===a&&"fill-extrusion"===e.type)return!0}else for(const e in s){const l=s[e];if(l.source===a&&"fill-extrusion"===l.type)return!0}return!1}(null!==(f=null==c?void 0:c.layers)&&void 0!==f?f:null,s,e.id),y=u.maxPitchScaleFactor(),b=e.tilesIn(l,y,_);b.sort(ve);const S=[];for(const l of b)S.push({wrappedTileID:l.tileID.wrapped().key,queryResults:l.tile.queryRenderedFeatures(s,a,e.getState(),l.queryGeometry,l.cameraQueryGeometry,l.scale,c,u,y,fe(u,l.tileID),d?(e,s)=>d(l.tileID,e,s):void 0)});return function(e,s){for(const a in e)for(const l of e[a])be(l,s);return e}(function(e){const s={},a={};for(const l of e){const e=l.queryResults,c=l.wrappedTileID,u=a[c]=a[c]||{};for(const a in e){const l=e[a],c=u[a]=u[a]||{},d=s[a]=s[a]||[];for(const e of l)c[e.featureIndex]||(c[e.featureIndex]=!0,d.push(e))}}return s}(S),e)}function ve(e,s){const a=e.tileID,l=s.tileID;return a.overscaledZ-l.overscaledZ||a.canonical.y-l.canonical.y||a.wrap-l.wrap||a.canonical.x-l.canonical.x}function be(e,s){const a=e.feature,l=s.getFeatureState(a.layer["source-layer"],a.id);a.source=a.layer.source,a.layer["source-layer"]&&(a.sourceLayer=a.layer["source-layer"]),a.state=l}function we(s,l,c){return a._(this||e,void 0,void 0,(function*(){let e=s;if(s.url?e=(yield a.j(l.transformRequest(s.url,"Source"),c)).data:yield _.frameAsync(c),!e)return null;const u=a.S(a.e(e,s),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in e&&e.vector_layers&&(u.vectorLayerIds=e.vector_layers.map((e=>e.id))),u}))}class ${constructor(e,s){e&&(s?this.setSouthWest(e).setNorthEast(s):Array.isArray(e)&&(4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1])))}setNorthEast(e){return this._ne=e instanceof a.U?new a.U(e.lng,e.lat):a.U.convert(e),this}setSouthWest(e){return this._sw=e instanceof a.U?new a.U(e.lng,e.lat):a.U.convert(e),this}extend(e){const s=this._sw,l=this._ne;let c,u;if(e instanceof a.U)c=e,u=e;else{if(!(e instanceof $))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend($.convert(e)):this.extend(a.U.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(a.U.convert(e)):this;if(c=e._sw,u=e._ne,!c||!u)return this}return s||l?(s.lng=Math.min(c.lng,s.lng),s.lat=Math.min(c.lat,s.lat),l.lng=Math.max(u.lng,l.lng),l.lat=Math.max(u.lat,l.lat)):(this._sw=new a.U(c.lng,c.lat),this._ne=new a.U(u.lng,u.lat)),this}getCenter(){return new a.U((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 a.U(this.getWest(),this.getNorth())}getSouthEast(){return new a.U(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){const{lng:s,lat:l}=a.U.convert(e);let c=this._sw.lng<=s&&s<=this._ne.lng;return this._sw.lng>this._ne.lng&&(c=this._sw.lng>=s&&s>=this._ne.lng),this._sw.lat<=l&&l<=this._ne.lat&&c}intersects(e){if((e=$.convert(e)).getNorth()<this.getSouth()||e.getSouth()>this.getNorth())return!1;const s=a.V(this.getWest(),-180,180),l=a.V(this.getEast(),-180,180),c=a.V(e.getWest(),-180,180),u=a.V(e.getEast(),-180,180),d=s>l,f=c>u;return!(!d||!f)||(d?u>=s||c<=l:f?l>=c||s<=u:!(c>l||u<s))}static convert(e){return e instanceof $?e:e?new $(e):e}static fromLngLat(e,s=0){const l=360*s/40075017,c=l/Math.cos(Math.PI/180*e.lat);return new $(new a.U(e.lng-c,e.lat-l),new a.U(e.lng+c,e.lat+l))}adjustAntiMeridian(){const e=new a.U(this._sw.lng,this._sw.lat),s=new a.U(this._ne.lng,this._ne.lat);return new $(e,e.lng>s.lng?new a.U(s.lng+360,s.lat):s)}}class H{constructor(e,s,a){this.bounds=$.convert(this.validateBounds(e)),this.minzoom=s||0,this.maxzoom=a||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const s=Math.pow(2,e.z),l=Math.floor(a.X(this.bounds.getWest())*s),c=Math.floor(a.W(this.bounds.getNorth())*s),u=Math.ceil(a.X(this.bounds.getEast())*s),d=Math.ceil(a.W(this.bounds.getSouth())*s);return e.x>=l&&e.x<u&&e.y>=c&&e.y<d}}class X extends a.E{constructor(e,s,l,c){if(super(),this.id=e,this.dispatcher=l,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,a.e(this,a.S(s,["url","scheme","tileSize","promoteId","encoding"])),this._options=a.e({type:"vector"},s),this._collectResourceTiming=s.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(c)}load(){return a._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new a.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const e=yield we(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,this.map.style.tileManagers[this.id].clearTiles(),e&&(a.e(this,e),e.bounds&&(this.tileBounds=new H(e.bounds,this.minzoom,this.maxzoom)),this.fire(new a.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.l("data",{dataType:"source",sourceDataType:"content"})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,this.fire(new a.k(e))}}))}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}setSourceProperty(e){this._tileJSONRequest&&this._tileJSONRequest.abort(),e(),this.load()}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return a.e({},this._options)}loadTile(e){return a._(this,void 0,void 0,(function*(){const s=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),a={request:this.map._requestManager.transformRequest(s,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,encoding:this.encoding,overzoomParameters:this._getOverzoomParameters(e)};a.request.collectResourceTiming=this._collectResourceTiming;let l="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise(((s,a)=>{e.reloadPromise={resolve:s,reject:a}}))}else e.actor=this.dispatcher.getActor(),l="LT";e.abortController=new AbortController;try{const s=yield e.actor.sendAsync({type:l,data:a},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,s)}catch(s){if(delete e.abortController,e.aborted)return;if(s&&404!==s.status)throw s;this._afterTileLoadWorkerResponse(e,null)}}))}_getOverzoomParameters(e){if(e.tileID.canonical.z<=this.maxzoom)return;if(void 0===this.map._zoomLevelsToOverscale)return;const s=e.tileID.scaledTo(this.maxzoom).canonical,a=s.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:s,overzoomRequest:this.map._requestManager.transformRequest(a,"Tile")}}_afterTileLoadWorkerResponse(e,s){if(s&&s.resourceTiming&&(e.resourceTiming=s.resourceTiming),s&&this.map._refreshExpiredTiles&&e.setExpiryData(s),e.loadVectorData(s,this.map.painter),e.reloadPromise){const s=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(s.resolve).catch(s.reject)}}abortTile(e){return a._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}}))}))}unloadTile(e){return a._(this,void 0,void 0,(function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}))}))}hasTransition(){return!1}}class K extends a.E{constructor(e,s,l,c){super(),this.id=e,this.dispatcher=l,this.setEventedParent(c),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=a.e({type:"raster"},s),a.e(this,a.S(s,["url","scheme","tileSize"]))}load(){return a._(this,arguments,void 0,(function*(e=!1){this._loaded=!1,this.fire(new a.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const s=yield we(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,s&&(a.e(this,s),s.bounds&&(this.tileBounds=new H(s.bounds,this.minzoom,this.maxzoom)),this.fire(new a.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,this.fire(new a.k(e))}}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load(!0)}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e})),this}serialize(){return a.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return a._(this,void 0,void 0,(function*(){const s=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const l=yield F.getImage(this.map._requestManager.transformRequest(s,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(l&&l.data){this.map._refreshExpiredTiles&&(l.cacheControl||l.expires)&&e.setExpiryData({cacheControl:l.cacheControl,expires:l.expires});const s=this.map.painter.context,c=s.gl,u=l.data;e.texture=this.map.painter.getTileTexture(u.width),e.texture?e.texture.update(u,{useMipmap:!0}):(e.texture=new a.T(s,u,c.RGBA,{useMipmap:!0}),e.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE,c.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(s){if(delete e.abortController,e.aborted)e.state="unloaded";else if(s)throw e.state="errored",s}}))}abortTile(e){return a._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)}))}unloadTile(e){return a._(this,void 0,void 0,(function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)}))}hasTransition(){return!1}}class Y extends K{constructor(e,s,l,c){super(e,s,l,c),this.type="raster-dem",this.maxzoom=22,this._options=a.e({type:"raster-dem"},s),this.encoding=s.encoding||"mapbox",this.redFactor=s.redFactor,this.greenFactor=s.greenFactor,this.blueFactor=s.blueFactor,this.baseShift=s.baseShift}loadTile(e){return a._(this,void 0,void 0,(function*(){const s=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),l=this.map._requestManager.transformRequest(s,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const s=yield F.getImage(l,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(s&&s.data){const l=s.data;this.map._refreshExpiredTiles&&(s.cacheControl||s.expires)&&e.setExpiryData({cacheControl:s.cacheControl,expires:s.expires});const c=a.b(l)&&a.Y()?l:yield this.readImageNow(l),u={type:this.type,uid:e.uid,source:this.id,rawImageData:c,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||"expired"===e.state){e.actor=this.dispatcher.getActor();const s=yield e.actor.sendAsync({type:"LDT",data:u});e.dem=s,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}}catch(s){if(delete e.abortController,e.aborted)e.state="unloaded";else if(s)throw e.state="errored",s}}))}readImageNow(e){return a._(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&a.Z()){const s=e.width+2,l=e.height+2;try{return new a.R({width:s,height:l},yield a.$(e,-1,-1,s,l))}catch(e){}}return _.getImageData(e,1)}))}_getNeighboringTiles(e){const s=e.canonical,l=Math.pow(2,s.z),c=(s.x-1+l)%l,u=0===s.x?e.wrap-1:e.wrap,d=(s.x+1+l)%l,f=s.x+1===l?e.wrap+1:e.wrap,_={};return _[new a.a0(e.overscaledZ,u,s.z,c,s.y).key]={backfilled:!1},_[new a.a0(e.overscaledZ,f,s.z,d,s.y).key]={backfilled:!1},s.y>0&&(_[new a.a0(e.overscaledZ,u,s.z,c,s.y-1).key]={backfilled:!1},_[new a.a0(e.overscaledZ,e.wrap,s.z,s.x,s.y-1).key]={backfilled:!1},_[new a.a0(e.overscaledZ,f,s.z,d,s.y-1).key]={backfilled:!1}),s.y+1<l&&(_[new a.a0(e.overscaledZ,u,s.z,c,s.y+1).key]={backfilled:!1},_[new a.a0(e.overscaledZ,e.wrap,s.z,s.x,s.y+1).key]={backfilled:!1},_[new a.a0(e.overscaledZ,f,s.z,d,s.y+1).key]={backfilled:!1}),_}unloadTile(e){return a._(this,void 0,void 0,(function*(){e.demTexture&&this.map.painter.saveTileTexture(e.demTexture),e.fbo&&(e.fbo.destroy(),delete e.fbo),e.dem&&delete e.dem,delete e.neighboringTiles,e.state="unloaded",e.actor&&(yield e.actor.sendAsync({type:"RDT",data:{type:this.type,uid:e.uid,source:this.id}}))}))}}function Te(e){return"GeometryCollection"===e.type?e.geometries.map((e=>e.coordinates)).flat(1/0):e.coordinates.flat(1/0)}function Se(e){const s=new $;let a;switch(e.type){case"FeatureCollection":a=e.features.map((e=>Te(e.geometry))).flat(1/0);break;case"Feature":a=Te(e.geometry);break;default:a=Te(e)}if(0==a.length)return s;for(let e=0;e<a.length-1;e+=2)s.extend([a[e],a[e+1]]);return s}class ee extends a.E{constructor(e,s,l,c){super(),this.id=e,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._isUpdatingWorker=!1,this._pendingWorkerUpdate={data:s.data},this.actor=l.getActor(),this.setEventedParent(c),this._data=s.data,this._options=a.e({},s),this._collectResourceTiming=s.collectResourceTiming,void 0!==s.maxzoom&&(this.maxzoom=s.maxzoom),s.type&&(this.type=s.type),s.attribution&&(this.attribution=s.attribution),this.promoteId=s.promoteId,void 0!==s.clusterMaxZoom&&this.maxzoom<=s.clusterMaxZoom&&a.w(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${s.clusterMaxZoom}".`),this.workerOptions=a.e({source:this.id,cluster:s.cluster||!1,geojsonVtOptions:{buffer:this._pixelsToTileUnits(void 0!==s.buffer?s.buffer:128),tolerance:this._pixelsToTileUnits(void 0!==s.tolerance?s.tolerance:.375),extent:a.a3,maxZoom:this.maxzoom,lineMetrics:s.lineMetrics||!1,generateId:s.generateId||!1},superclusterOptions:{maxZoom:this._getClusterMaxZoom(s.clusterMaxZoom),minPoints:Math.max(2,s.clusterMinPoints||2),extent:a.a3,radius:this._pixelsToTileUnits(s.clusterRadius||50),log:!1,generateId:s.generateId||!1},clusterProperties:s.clusterProperties,filter:s.filter},s.workerOptions),"string"==typeof this.promoteId&&(this.workerOptions.promoteId=this.promoteId)}_hasPendingWorkerUpdate(){return void 0!==this._pendingWorkerUpdate.data||void 0!==this._pendingWorkerUpdate.diff||this._pendingWorkerUpdate.optionsChanged}_pixelsToTileUnits(e){return e*(a.a3/this.tileSize)}_getClusterMaxZoom(e){const s=e?Math.round(e):this.maxzoom-1;return Number.isInteger(e)||void 0===e||a.w(`Integer expected for option 'clusterMaxZoom': provided value "${e}" rounded to "${s}"`),s}load(){return a._(this,void 0,void 0,(function*(){yield this._updateWorkerData()}))}onAdd(e){this.map=e,this.load()}setData(e){return this._data=e,this._pendingWorkerUpdate={data:e},this._updateWorkerData(),this}updateData(e){return this._pendingWorkerUpdate.diff=a.a4(this._pendingWorkerUpdate.diff,e),this._updateWorkerData(),this}getData(){return a._(this,void 0,void 0,(function*(){const e=a.e({type:this.type},this.workerOptions);return this.actor.sendAsync({type:"GD",data:e})}))}getBounds(){return a._(this,void 0,void 0,(function*(){return Se(yield this.getData())}))}setClusterOptions(e){return this.workerOptions.cluster=e.cluster,void 0!==e.clusterRadius&&(this.workerOptions.superclusterOptions.radius=this._pixelsToTileUnits(e.clusterRadius)),void 0!==e.clusterMaxZoom&&(this.workerOptions.superclusterOptions.maxZoom=this._getClusterMaxZoom(e.clusterMaxZoom)),this._pendingWorkerUpdate.optionsChanged=!0,this._updateWorkerData(),this}getClusterExpansionZoom(e){return this.actor.sendAsync({type:"GCEZ",data:{type:this.type,clusterId:e,source:this.id}})}getClusterChildren(e){return this.actor.sendAsync({type:"GCC",data:{type:this.type,clusterId:e,source:this.id}})}getClusterLeaves(e,s,a){return this.actor.sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:e,limit:s,offset:a}})}_updateWorkerData(){return a._(this,void 0,void 0,(function*(){if(this._isUpdatingWorker)return;if(!this._hasPendingWorkerUpdate())return void a.w(`No pending worker updates for GeoJSONSource ${this.id}.`);const{data:e,diff:s}=this._pendingWorkerUpdate,l=a.e({type:this.type},this.workerOptions);e?("string"==typeof e?(l.request=this.map._requestManager.transformRequest(_.resolveURL(e),"Source"),l.request.collectResourceTiming=this._collectResourceTiming):l.data=JSON.stringify(e),this._pendingWorkerUpdate.data=void 0):s&&(l.dataDiff=s,this._pendingWorkerUpdate.diff=void 0),this._pendingWorkerUpdate.optionsChanged=void 0,this._isUpdatingWorker=!0,this.fire(new a.l("dataloading",{dataType:"source"}));try{const e=yield this.actor.sendAsync({type:"LD",data:l});if(this._isUpdatingWorker=!1,this._removed||e.abandoned)return void this.fire(new a.l("dataabort",{dataType:"source"}));this._data=e.data;let c=null;e.resourceTiming&&e.resourceTiming[this.id]&&(c=e.resourceTiming[this.id].slice(0));const u={dataType:"source"};this._collectResourceTiming&&c&&c.length>0&&a.e(u,{resourceTiming:c}),this.fire(new a.l("data",Object.assign(Object.assign({},u),{sourceDataType:"metadata"}))),this.fire(new a.l("data",Object.assign(Object.assign({},u),{sourceDataType:"content",shouldReloadTileOptions:this._getShouldReloadTileOptions(s)})))}catch(e){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new a.l("dataabort",{dataType:"source"}));this.fire(new a.k(e))}finally{this._hasPendingWorkerUpdate()&&this._updateWorkerData()}}))}_getShouldReloadTileOptions(e){if(!e||e.removeAll)return;const{add:s=[],update:a=[],remove:l=[]}=e||{},c=new Set([...a.map((e=>e.id)),...l]);return{nextBounds:[...a.map((e=>e.newGeometry)),...s.map((e=>e.geometry))].map((e=>Se(e))),prevIds:c}}shouldReloadTile(e,{nextBounds:s,prevIds:l}){const c=e.latestFeatureIndex.loadVTLayers();for(let s=0;s<e.latestFeatureIndex.featureIndexArray.length;s++){const a=e.latestFeatureIndex.featureIndexArray.get(s),u=c._geojsonTileLayer.feature(a.featureIndex);if(l.has(u.id))return!0}const{buffer:u,extent:d}=this.workerOptions.geojsonVtOptions,f=function({x:e,y:s,z:l},c=0){const u=a.a1((e-c)/Math.pow(2,l)),d=a.a2((s+1+c)/Math.pow(2,l)),f=a.a1((e+1+c)/Math.pow(2,l)),_=a.a2((s-c)/Math.pow(2,l));return new $([u,d],[f,_])}(e.tileID.canonical,u/d);for(const e of s)if(f.intersects(e))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}loadTile(e){return a._(this,void 0,void 0,(function*(){const s=e.actor?"RT":"LT";e.actor=this.actor;const a={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};e.abortController=new AbortController;const l=yield this.actor.sendAsync({type:s,data:a},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(l,this.map.painter,"RT"===s)}))}abortTile(e){return a._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0}))}unloadTile(e){return a._(this,void 0,void 0,(function*(){e.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}})}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}})}serialize(){return a.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}class te extends a.E{constructor(e,s,a,l){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=a,this.coordinates=s.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(l),this.options=s}load(e){return a._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new a.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const s=yield F.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,s&&s.data&&(this.image=s.data,e&&(this.coordinates=e),this._finishLoading())}catch(e){this._request=null,this._loaded=!0,this.fire(new a.k(e))}}))}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=e.url,this.load(e.coordinates).finally((()=>{this.texture=null})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new a.l("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(e){this.coordinates=e;const s=e.map(a.a5.fromLngLat);var l;return this.tileID=function(e){const s=a.a6.fromPoints(e),l=s.width(),c=s.height(),u=Math.max(l,c),d=Math.max(0,Math.floor(-Math.log(u)/Math.LN2)),f=Math.pow(2,d);return new a.a8(d,Math.floor((s.minX+s.maxX)/2*f),Math.floor((s.minY+s.maxY)/2*f))}(s),this.terrainTileRanges=this._getOverlappingTileRanges(s),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=s.map((e=>this.tileID.getTilePoint(e)._round())),this.flippedWindingOrder=((l=this.tileCoords)[1].x-l[0].x)*(l[2].y-l[0].y)-(l[1].y-l[0].y)*(l[2].x-l[0].x)<0,this.fire(new a.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,s=e.gl;this.texture||(this.texture=new a.T(e,this.image,s.RGBA),this.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE));let l=!1;for(const e in this.tiles){const s=this.tiles[e];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture,l=!0)}l&&this.fire(new a.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return a._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"}))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(e){const{minX:s,minY:l,maxX:c,maxY:u}=a.a6.fromPoints(e),d={};for(let e=0;e<=a.a7;e++){const a=Math.pow(2,e),f=Math.floor(s*a),_=Math.floor(l*a),y=Math.floor(c*a),b=Math.floor(u*a);d[e]={minTileX:f,minTileY:_,maxTileX:y,maxTileY:b}}return d}}class ie extends te{constructor(e,s,a,l){super(e,s,a,l),this.roundZoom=!0,this.type="video",this.options=s}load(){return a._(this,void 0,void 0,(function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const s of e.urls)this.urls.push(this.map._requestManager.transformRequest(s,"Source").url);try{const e=yield a.a9(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading()}catch(e){this.fire(new a.k(e))}}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const s=this.video.seekable;e<s.start(0)||e>s.end(0)?this.fire(new a.k(new a.aa(`sources.${this.id}`,null,`Playback for this video can be set only between the ${s.start(0)} and ${s.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,s=e.gl;this.texture?this.video.paused||(this.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE),s.texSubImage2D(s.TEXTURE_2D,0,0,0,s.RGBA,s.UNSIGNED_BYTE,this.video)):(this.texture=new a.T(e,this.video,s.RGBA),this.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE));let l=!1;for(const e in this.tiles){const s=this.tiles[e];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture,l=!0)}l&&this.fire(new a.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class ae extends te{constructor(e,s,l,c){super(e,s,l,c),s.coordinates?Array.isArray(s.coordinates)&&4===s.coordinates.length&&!s.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new a.k(new a.aa(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new a.k(new a.aa(`sources.${e}`,null,'missing required property "coordinates"'))),s.animate&&"boolean"!=typeof s.animate&&this.fire(new a.k(new a.aa(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),s.canvas?"string"==typeof s.canvas||s.canvas instanceof HTMLCanvasElement||this.fire(new a.k(new a.aa(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new a.k(new a.aa(`sources.${e}`,null,'missing required property "canvas"'))),this.options=s,this.animate=void 0===s.animate||s.animate}load(){return a._(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new a.k(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}))}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const s=this.map.painter.context,l=s.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new a.T(s,this.canvas,l.RGBA,{premultiply:!0});let c=!1;for(const e in this.tiles){const s=this.tiles[e];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture,c=!0)}c&&this.fire(new a.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",animate:this.animate,canvas:this.options.canvas,coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}}const Me={},Ee=e=>{switch(e){case"geojson":return ee;case"image":return te;case"raster":return K;case"raster-dem":return Y;case"vector":return X;case"video":return ie;case"canvas":return ae}return Me[e]},Ce="RTLPluginLoaded";class ne extends a.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=pe()}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch((e=>{throw this.status="error",e}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(e){return a._(this,arguments,void 0,(function*(e,s=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=_.resolveURL(e),!this.url)throw new Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!s)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()}))}_requestImport(){return a._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new a.l(Ce))}))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}}let Ae=null;function ke(){return Ae||(Ae=new ne),Ae}var Le,Fe;!function(e){e[e.Base=0]="Base",e[e.Parent=1]="Parent"}(Le||(Le={})),function(e){e[e.Departing=0]="Departing",e[e.Incoming=1]="Incoming"}(Fe||(Fe={}));class de{constructor(e,s){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=a.ab(),this.uses=0,this.tileSize=s,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}isRenderable(e){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(e||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:e,fadingDirection:s,fadingParentID:a,fadeEndTime:l}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=s,this.fadingParentID=a,this.fadeEndTime=l}setSelfFadeLogic(e){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=e}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=b(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(e,s,l){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData,this.latestFeatureIndex.encoding=e.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(e,s){const a={};if(!s)return a;for(const l of e){const e=l.layerIds.map((e=>s.getLayer(e))).filter(Boolean);if(0!==e.length){l.layers=e,l.stateDependentLayerIds&&(l.stateDependentLayers=l.stateDependentLayerIds.map((s=>e.filter((e=>e.id===s))[0])));for(const s of e)a[s.id]=l}}return a}(e.buckets,null==s?void 0:s.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const s=this.buckets[e];if(s instanceof a.ad){if(this.hasSymbolBuckets=!0,!l)break;s.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const s=this.buckets[e];if(s instanceof a.ad&&s.hasRTLText){this.hasRTLText=!0,ke().lazyLoad();break}}this.queryPadding=0;for(const e in this.buckets){const a=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,s.style.getLayer(e).queryRadius(a))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),this.dashPositions=e.dashPositions}else this.collisionBoxArray=new a.ac}unloadVectorData(){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.dashPositions&&(this.dashPositions=null),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(const s in this.buckets){const a=this.buckets[s];a.uploadPending()&&a.upload(e)}const s=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new a.T(e,this.imageAtlas.image,s.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new a.T(e,this.glyphAtlasImage,s.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,s,a,l,c,u,d,f,_,y,b){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:l,cameraQueryGeometry:c,scale:u,tileSize:this.tileSize,pixelPosMatrix:y,transform:f,params:d,queryPadding:this.queryPadding*_,getElevation:b},e,s,a):{}}querySourceFeatures(e,s){const l=this.latestFeatureIndex;if(!l||!l.rawTileData)return;const c=l.loadVTLayers(),u=s&&s.sourceLayer?s.sourceLayer:"",d=c._geojsonTileLayer||c[u];if(!d)return;const f=a.ae(null==s?void 0:s.filter,null==s?void 0:s.globalState),{z:_,x:y,y:b}=this.tileID.canonical,S={z:_,x:y,y:b};for(let s=0;s<d.length;s++){const c=d.feature(s);if(f.needGeometry){const e=a.af(c,!0);if(!f.filter(new a.G(this.tileID.overscaledZ),e,this.tileID.canonical))continue}else if(!f.filter(new a.G(this.tileID.overscaledZ),c))continue;const P=l.getId(c,u),M=new a.ag(c,_,y,b,P);M.tile=S,e.push(M)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){const s=this.expirationTime;if(e.cacheControl){const s=a.ah(e.cacheControl);s["max-age"]&&(this.expirationTime=Date.now()+1e3*s["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){const e=Date.now();let a=!1;if(this.expirationTime>e)a=!1;else if(s)if(this.expirationTime<s)a=!0;else{const l=this.expirationTime-s;l?this.expirationTime=e+Math.max(l,3e4):a=!0}else a=!0;a?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-(new Date).getTime(),Math.pow(2,31)-1)}setFeatureState(e,s){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||0===Object.keys(e).length)return;const a=this.latestFeatureIndex.loadVTLayers();for(const l in this.buckets){if(!s.style.hasLayer(l))continue;const c=this.buckets[l],u=c.layers[0].sourceLayer||"_geojsonTileLayer",d=a[u],f=e[u];if(!d||!f||0===Object.keys(f).length)continue;c.update(f,d,this.imageAtlas&&this.imageAtlas.patternPositions||{},this.dashPositions||{});const _=s&&s.style&&s.style.getLayer(l);_&&(this.queryPadding=Math.max(this.queryPadding,_.queryRadius(c)))}}holdingForSymbolFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<b()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(e){this.symbolFadeHoldUntil=b()+e}setDependencies(e,s){const a={};for(const e of s)a[e]=!0;this.dependencies[e]=a}hasDependency(e,s){for(const a of e){const e=this.dependencies[a];if(e)for(const a of s)if(e[a])return!0}return!1}}class _e{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,s,l){const c=String(s);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][c]=this.stateChanges[e][c]||{},a.e(this.stateChanges[e][c],l),null===this.deletedStates[e]){this.deletedStates[e]={};for(const s in this.state[e])s!==c&&(this.deletedStates[e][s]=null)}else if(this.deletedStates[e]&&null===this.deletedStates[e][c]){this.deletedStates[e][c]={};for(const s in this.state[e][c])l[s]||(this.deletedStates[e][c][s]=null)}else for(const s in l)this.deletedStates[e]&&this.deletedStates[e][c]&&null===this.deletedStates[e][c][s]&&delete this.deletedStates[e][c][s]}removeFeatureState(e,s,a){if(null===this.deletedStates[e])return;const l=String(s);if(this.deletedStates[e]=this.deletedStates[e]||{},a&&void 0!==s)null!==this.deletedStates[e][l]&&(this.deletedStates[e][l]=this.deletedStates[e][l]||{},this.deletedStates[e][l][a]=null);else if(void 0!==s)if(this.stateChanges[e]&&this.stateChanges[e][l])for(a in this.deletedStates[e][l]={},this.stateChanges[e][l])this.deletedStates[e][l][a]=null;else this.deletedStates[e][l]=null;else this.deletedStates[e]=null}getState(e,s){const l=String(s),c=a.e({},(this.state[e]||{})[l],(this.stateChanges[e]||{})[l]);if(null===this.deletedStates[e])return{};if(this.deletedStates[e]){const a=this.deletedStates[e][s];if(null===a)return{};for(const e in a)delete c[e]}return c}initializeTileState(e,s){e.setFeatureState(this.state,s)}coalesceChanges(e,s){const l={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const s={};for(const l in this.stateChanges[e])this.state[e][l]||(this.state[e][l]={}),a.e(this.state[e][l],this.stateChanges[e][l]),s[l]=this.state[e][l];l[e]=s}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const s={};if(null===this.deletedStates[e])for(const a in this.state[e])s[a]={},this.state[e][a]={};else for(const a in this.deletedStates[e]){if(null===this.deletedStates[e][a])this.state[e][a]={};else for(const s of Object.keys(this.deletedStates[e][a]))delete this.state[e][a][s];s[a]=this.state[e][a]}l[e]=l[e]||{},a.e(l[e],s)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(l).length)for(const a in e)e[a].setFeatureState(l,s)}}const Oe=89.25;function Ve(e,s){const l=a.ai(s.lat,-a.aj,a.aj);return new a.P(a.X(s.lng)*e,a.W(l)*e)}function Ne(e,s){return new a.a5(s.x/e,s.y/e).toLngLat()}function je(e){return e.cameraToCenterDistance*Math.min(.85*Math.tan(a.ak(90-e.pitch)),Math.tan(a.ak(Oe-e.pitch)))}function Ue(e,s){const l=e.canonical,c=s/a.al(l.z),u=l.x+Math.pow(2,l.z)*e.wrap,d=a.am(new Float64Array(16));return a.N(d,d,[u*c,l.y*c,0]),a.O(d,d,[c/a.a3,c/a.a3,1]),d}function Ge(e,s,l,c,u){const d=a.a5.fromLngLat(e,s),f=u*a.an(1,e.lat),_=f*Math.cos(a.ak(l)),y=Math.sqrt(f*f-_*_),b=y*Math.sin(a.ak(-c)),S=y*Math.cos(a.ak(-c));return new a.a5(d.x+b,d.y+S,d.z+_)}function Ze(e,s,a){const l=s.intersectsFrustum(e);if(!a||0===l)return l;const c=s.intersectsPlane(a);return 0===c?0:2===l&&2===c?2:1}function qe(e,s,a){let l=0;const c=(a-s)/10;for(let u=0;u<10;u++)l+=c*Math.pow(Math.cos(s+(u+.5)/10*(a-s)),e);return l}function $e(e,s){return function(l,c,u,d,f){const _=2*((e-1)/a.ao(Math.cos(a.ak(Oe-f))/Math.cos(a.ak(Oe)))-1),y=Math.acos(u/d),b=2*qe(_-1,0,a.ak(f/2)),S=Math.min(a.ak(Oe),y+a.ak(f/2)),P=qe(_-1,Math.min(S,y-a.ak(f/2)),S),M=Math.atan(c/u),C=Math.hypot(c,u);let D=l;return D+=a.ao(d/C/Math.max(.5,Math.cos(a.ak(f/2)))),D+=_*a.ao(Math.cos(M))/2,D-=a.ao(Math.max(1,P/b/s))/2,D}}const We=$e(9.314,3);function He(e,s){const l=(s.roundZoom?Math.round:Math.floor)(e.zoom+a.ao(e.tileSize/s.tileSize));return Math.max(0,l)}function Xe(e,s){const l=e.getCameraFrustum(),c=e.getClippingPlane(),u=e.screenPointToMercatorCoordinate(e.getCameraPoint()),d=a.a5.fromLngLat(e.center,e.elevation);u.z=d.z+Math.cos(e.pitchInRadians)*e.cameraToCenterDistance/e.worldSize;const f=e.getCoveringTilesDetailsProvider(),_=f.allowVariableZoom(e,s),y=He(e,s),b=s.minzoom||0,S=void 0!==s.maxzoom?s.maxzoom:e.maxZoom,P=Math.min(Math.max(0,y),S),M=Math.pow(2,P),C=[M*u.x,M*u.y,0],D=[M*d.x,M*d.y,0],L=Math.hypot(d.x-u.x,d.y-u.y),F=Math.abs(d.z-u.z),B=Math.hypot(L,F),O=e=>({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),V=[],N=[];if(e.renderWorldCopies&&f.allowWorldCopies())for(let e=1;e<=3;e++)V.push(O(-e)),V.push(O(e));for(V.push(O(0));V.length>0;){const M=V.pop(),L=M.x,O=M.y;let j=M.fullyVisible;const G={x:L,y:O,z:M.zoom},Z=f.getTileBoundingVolume(G,M.wrap,e.elevation,s);if(!j){const e=Ze(l,Z,c);if(0===e)continue;j=2===e}const q=f.distanceToTile2d(u.x,u.y,G,Z);let W=y;_&&(W=(s.calculateTileZoom||We)(e.zoom+a.ao(e.tileSize/s.tileSize),q,F,B,e.fov)),W=(s.roundZoom?Math.round:Math.floor)(W),W=Math.max(0,W);const J=Math.min(W,S);if(M.wrap=f.getWrap(d,G,M.wrap),M.zoom>=J){if(M.zoom<b)continue;const e=P-M.zoom,l=C[0]-.5-(L<<e),c=C[1]-.5-(O<<e),u=s.reparseOverscaled?Math.max(M.zoom,W):M.zoom;N.push({tileID:new a.a0(M.zoom===S?u:M.zoom,M.wrap,M.zoom,L,O),distanceSq:a.ap([D[0]-.5-L,D[1]-.5-O]),tileDistanceToCamera:Math.sqrt(l*l+c*c)})}else for(let e=0;e<4;e++)V.push({zoom:M.zoom+1,x:(L<<1)+e%2,y:(O<<1)+(e>>1),wrap:M.wrap,fullyVisible:j})}return N.sort(((e,s)=>e.distanceSq-s.distanceSq)).map((e=>e.tileID))}const Ye=a.a6.fromPoints([new a.P(0,0),new a.P(a.a3,a.a3)]);class Ie extends a.E{constructor(e,s,l){super(),this.id=e,this.dispatcher=l,this.on("data",(e=>this._dataHandler(e))),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=((e,s,a,l)=>{const c=new(Ee(s.type))(e,s,a,l);if(c.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${c.id}`);return c})(e,s,l,this),this._tiles={},this._cache=new a.aq(0,(e=>this._unloadTile(e))),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new _e,this._didEmitContent=!1,this._updated=!1}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e)}onRemove(e){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const e in this._tiles){const s=this._tiles[e];if("loaded"!==s.state&&"errored"!==s.state)return!1}return!0}getSource(){return this._source}getState(){return this._state}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(e,s,l){return a._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,s,l)}catch(s){e.state="errored",404!==s.status?this._source.fire(new a.k(s,{tile:e})):this.update(this.transform,this.terrain)}}))}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new a.l("dataabort",{tile:e,coord:e.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const s in this._tiles){const a=this._tiles[s];a.upload(e),a.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map((e=>e.tileID)).sort(Ke).map((e=>e.key))}getRenderableIds(e){const s=[];for(const a in this._tiles)this._isIdRenderable(a,e)&&s.push(this._tiles[a]);return e?s.sort(((e,s)=>{const l=e.tileID,c=s.tileID,u=new a.P(l.canonical.x,l.canonical.y)._rotate(-this.transform.bearingInRadians),d=new a.P(c.canonical.x,c.canonical.y)._rotate(-this.transform.bearingInRadians);return l.overscaledZ-c.overscaledZ||d.y-u.y||d.x-u.x})).map((e=>e.tileID.key)):s.map((e=>e.tileID)).sort(Ke).map((e=>e.key))}hasRenderableParent(e){const s=e.overscaledZ-1;if(s>=this._source.minzoom){const a=this.getLoadedTile(e.scaledTo(s));if(a)return this._isIdRenderable(a.tileID.key)}return!1}_isIdRenderable(e,s=!1){var a;return null===(a=this._tiles[e])||void 0===a?void 0:a.isRenderable(s)}reload(e,s=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const a in this._tiles)s&&this._source.shouldReloadTile&&!this._source.shouldReloadTile(this._tiles[a],s)||(e?this._reloadTile(a,"expired"):"errored"!==this._tiles[a].state&&this._reloadTile(a,"reloading"))}}_reloadTile(e,s){return a._(this,void 0,void 0,(function*(){const a=this._tiles[e];a&&("loading"!==a.state&&(a.state=s),yield this._loadTile(a,e,s))}))}_tileLoaded(e,s,l){e.timeAdded=b(),e.selfFading&&(e.fadeEndTime=e.timeAdded+this._rasterFadeDuration),"expired"===l&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(s,e),"raster-dem"===this.getSource().type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new a.l("data",{dataType:"source",tile:e,coord:e.tileID}))}_backfillDEM(e){const s=this.getRenderableIds();for(let l=0;l<s.length;l++){const c=s[l];if(e.neighboringTiles&&e.neighboringTiles[c]){const s=this.getTileByID(c);a(e,s),a(s,e)}}function a(e,s){e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0;let a=s.tileID.canonical.x-e.tileID.canonical.x;const l=s.tileID.canonical.y-e.tileID.canonical.y,c=Math.pow(2,e.tileID.canonical.z),u=s.tileID.key;0===a&&0===l||Math.abs(l)>1||(Math.abs(a)>1&&(1===Math.abs(a+c)?a+=c:1===Math.abs(a-c)&&(a-=c)),s.dem&&e.dem&&(e.dem.backfillBorder(s.dem,a,l),e.neighboringTiles&&e.neighboringTiles[u]&&(e.neighboringTiles[u].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,s){const a=Object.values(e),l=this._getLoadedDescendents(a),c={};for(const e of a){const a=l[e.key];if(!(null==a?void 0:a.length)){c[e.key]=e;continue}const u=e.overscaledZ+Ie.maxUnderzooming,d=a.filter((e=>e.tileID.overscaledZ<=u));if(!d.length){c[e.key]=e;continue}const f=Math.min(...d.map((e=>e.tileID.overscaledZ))),_=d.filter((e=>e.tileID.overscaledZ===f)).map((e=>e.tileID));for(const e of _)s[e.key]=e;this._areDescendentsComplete(_,f,e.overscaledZ)||(c[e.key]=e)}return c}_getLoadedDescendents(e){var s;const a={};for(const l in this._tiles){const c=this._tiles[l];if(c.hasData())for(const l of e)c.tileID.isChildOf(l)&&(a[s=l.key]||(a[s]=[])).push(c)}return a}_areDescendentsComplete(e,s,a){return 1===e.length&&e[0].isOverscaled()?e[0].overscaledZ===s:Math.pow(4,s-a)===e.length}getLoadedTile(e){const s=this._tiles[e.key];return(null==s?void 0:s.hasData())?s:null}updateCacheSize(e){const s=Math.ceil(e.width/this._source.tileSize)+1,l=Math.ceil(e.height/this._source.tileSize)+1,c=Math.floor(s*l*(null===this._maxTileCacheZoomLevels?a.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),u="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,c):c;this._cache.setMaxSize(u)}handleWrapJump(e){const s=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,s){const e={};for(const a in this._tiles){const l=this._tiles[a];l.tileID=l.tileID.unwrapTo(l.tileID.wrap+s),e[l.tileID.key]=l}this._tiles=e,this._resetTileReloadTimers()}}update(e,s){if(!this._sourceLoaded||this._paused)return;let l;this.transform=e,this.terrain=s,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?l=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new a.a0(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(l=Xe(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:"vector"===this._source.type&&void 0!==this.map._zoomLevelsToOverscale?e.maxZoom-this.map._zoomLevelsToOverscale:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:s,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(l=l.filter((e=>this._source.hasTile(e))))):l=[],this.usedForTerrain&&(l=this._addTerrainIdealTiles(l));const c=0===l.length&&!this._updated&&this._didEmitContent;this._updated=!0,c&&this.fire(new a.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const u=He(e,this._source),d=this._updateRetainedTiles(l,u),f=Je(this._source.type);f&&this._rasterFadeDuration>0&&!s&&this._updateFadingTiles(l,d),f?this._cleanUpRasterTiles(d):this._cleanUpVectorTiles(d)}_cleanUpRasterTiles(e){for(const s in this._tiles)e[s]||this._removeTile(s)}_cleanUpVectorTiles(e){for(const s in this._tiles){const a=this._tiles[s];e[s]?a.clearSymbolFadeHold():a.hasSymbolBuckets?a.holdingForSymbolFade()?a.symbolFadeFinished()&&this._removeTile(s):a.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(s)}}_addTerrainIdealTiles(e){const s=[];for(const a of e)if(a.canonical.z>this._source.minzoom){const e=a.scaledTo(a.canonical.z-1);s.push(e);const l=a.scaledTo(Math.max(this._source.minzoom,Math.min(a.canonical.z,5)));s.push(l)}return e.concat(s)}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForSymbolFade()&&this._removeTile(e)}_updateRetainedTiles(e,s){var a;const l={},c={},u=Math.max(s-Ie.maxOverzooming,this._source.minzoom);let d={};for(const s of e){const e=this._addTile(s);l[s.key]=s,e.hasData()||(d[s.key]=s)}d=this._retainLoadedChildren(d,l);for(const e in d){const s=d[e];let f=this._tiles[e],_=null==f?void 0:f.wasRequested();for(let e=s.overscaledZ-1;e>=u;--e){const u=s.scaledTo(e);if(c[u.key])break;if(c[u.key]=!0,f=this.getTile(u),!f&&_&&(f=this._addTile(u)),f){const e=f.hasData();if((e||!(null===(a=this.map)||void 0===a?void 0:a.cancelPendingTileRequestsWhileZooming)||_)&&(l[u.key]=u),_=f.wasRequested(),e)break}}}return l}_updateFadingTiles(e,s){const l=b(),c=a.ar(e);for(const a of e){const e=this._tiles[a.key];e.fadingDirection!==Fe.Departing&&0!==e.fadeOpacity||e.resetFadeLogic(),this._updateFadingAncestor(e,s,l)||this._updateFadingDescendents(e,s,l)||this._updateFadingEdge(e,c,l)||e.resetFadeLogic()}}_updateFadingAncestor(e,s,a){if(!e.hasData())return!1;const{tileID:l,fadingRole:c,fadingDirection:u,fadingParentID:d}=e;if(c===Le.Base&&u===Fe.Incoming&&d)return s[d.key]=d,!0;const f=Math.max(l.overscaledZ-this._maxFadingAncestorLevels,this._source.minzoom);for(let c=l.overscaledZ-1;c>=f;c--){const u=l.scaledTo(c),d=this.getLoadedTile(u);if(d)return e.setCrossFadeLogic({fadingRole:Le.Base,fadingDirection:Fe.Incoming,fadingParentID:d.tileID,fadeEndTime:a+this._rasterFadeDuration}),d.setCrossFadeLogic({fadingRole:Le.Parent,fadingDirection:Fe.Departing,fadeEndTime:a+this._rasterFadeDuration}),s[u.key]=u,!0}return!1}_updateFadingDescendents(e,s,a){if(!e.hasData())return!1;const l=e.tileID.children(this._source.maxzoom);let c=this._updateFadingChildren(e,l,s,a);if(c)return!0;for(const u of l){const l=u.children(this._source.maxzoom);this._updateFadingChildren(e,l,s,a)&&(c=!0)}return c}_updateFadingChildren(e,s,a,l){if(s[0].overscaledZ>=this._source.maxzoom)return!1;let c=!1;for(const u of s){const s=this.getLoadedTile(u);if(!s)continue;const{fadingRole:d,fadingDirection:f,fadingParentID:_}=s;d===Le.Base&&f===Fe.Departing&&_||(s.setCrossFadeLogic({fadingRole:Le.Base,fadingDirection:Fe.Departing,fadingParentID:e.tileID,fadeEndTime:l+this._rasterFadeDuration}),e.setCrossFadeLogic({fadingRole:Le.Parent,fadingDirection:Fe.Incoming,fadeEndTime:l+this._rasterFadeDuration})),a[u.key]=u,c=!0}return c}_updateFadingEdge(e,s,a){const l=e.tileID;return!!e.selfFading||!e.hasData()&&!!s.has(l)&&(e.setSelfFadeLogic(a+this._rasterFadeDuration),!0)}_addTile(e){let s=this._tiles[e.key];if(s)return s;s=this._cache.getAndRemove(e),s&&(s.resetFadeLogic(),this._setTileReloadTimer(e.key,s),s.tileID=e,this._state.initializeTileState(s,this.map?this.map.painter:null));const l=s;return s||(s=new de(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(s,e.key,s.state)),s.uses++,this._tiles[e.key]=s,l||this._source.fire(new a.l("dataloading",{tile:s,coord:s.tileID,dataType:"source"})),s}_setTileReloadTimer(e,s){this._clearTileReloadTimer(e);const a=s.getExpiryTimeout();a&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e]}),a))}_clearTileReloadTimer(e){const s=this._timers[e];s&&(clearTimeout(s),delete this._timers[e])}_resetTileReloadTimers(){for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(e,this._tiles[e])}refreshTiles(e){for(const s in this._tiles)(this._isIdRenderable(s)||"errored"==this._tiles[s].state)&&e.some((e=>e.equals(this._tiles[s].tileID.canonical)))&&this._reloadTile(s,"expired")}_removeTile(e){const s=this._tiles[e];s&&(s.uses--,delete this._tiles[e],this._clearTileReloadTimer(e),s.uses>0||(s.hasData()&&"reloading"!==s.state?this._cache.add(s.tileID,s,s.getExpiryTimeout()):(s.aborted=!0,this._abortTile(s),this._unloadTile(s))))}_dataHandler(e){"source"===e.dataType&&("metadata"!==e.sourceDataType?"content"===e.sourceDataType&&this._sourceLoaded&&!this._paused&&(this.reload(e.sourceDataChanged,e.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0):this._sourceLoaded=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(e);this._cache.reset()}tilesIn(e,s,l){const c=[],u=this.transform;if(!u)return c;const d=u.getCoveringTilesDetailsProvider().allowWorldCopies(),f=l?u.getCameraQueryGeometry(e):e,_=e=>u.screenPointToMercatorCoordinate(e,this.terrain),y=this.transformBbox(e,_,!d),b=this.transformBbox(f,_,!d),S=this.getIds(),P=a.a6.fromPoints(b);for(let e=0;e<S.length;e++){const l=this._tiles[S[e]];if(l.holdingForSymbolFade())continue;const f=d?[l.tileID]:[l.tileID.unwrapTo(-1),l.tileID.unwrapTo(0)],_=Math.pow(2,u.zoom-l.tileID.overscaledZ),M=s*l.queryPadding*a.a3/l.tileSize/_;for(const e of f){const s=P.map((s=>e.getTilePoint(new a.a5(s.x,s.y))));if(s.expandBy(M),s.intersects(Ye)){const s=y.map((s=>e.getTilePoint(s))),a=b.map((s=>e.getTilePoint(s)));c.push({tile:l,tileID:d?e:e.unwrapTo(0),queryGeometry:s,cameraQueryGeometry:a,scale:_})}}}return c}transformBbox(e,s,l){let c=e.map(s);if(l){const l=a.a6.fromPoints(e);l.shrinkBy(.001*Math.min(l.width(),l.height()));const u=l.map(s);a.a6.fromPoints(c).covers(u)||(c=c.map((e=>e.x>.5?new a.a5(e.x-1,e.y,e.z):e)))}return c}getVisibleCoordinates(e){const s=this.getRenderableIds(e).map((e=>this._tiles[e].tileID));return this.transform&&this.transform.populateCache(s),s}hasTransition(){if(this._source.hasTransition())return!0;if(Je(this._source.type)&&this._rasterFadeDuration>0){const e=b();for(const s in this._tiles)if(this._tiles[s].fadeEndTime>=e)return!0}return!1}setRasterFadeDuration(e){this._rasterFadeDuration=e}setFeatureState(e,s,a){this._state.updateState(e=e||"_geojsonTileLayer",s,a)}removeFeatureState(e,s,a){this._state.removeFeatureState(e=e||"_geojsonTileLayer",s,a)}getFeatureState(e,s){return this._state.getState(e=e||"_geojsonTileLayer",s)}setDependencies(e,s,a){const l=this._tiles[e];l&&l.setDependencies(s,a)}reloadTilesForDependencies(e,s){for(const a in this._tiles)this._tiles[a].hasDependency(e,s)&&this._reloadTile(a,"reloading");this._cache.filter((a=>!a.hasDependency(e,s)))}}function Ke(e,s){const a=Math.abs(2*e.wrap)-+(e.wrap<0),l=Math.abs(2*s.wrap)-+(s.wrap<0);return e.overscaledZ-s.overscaledZ||l-a||s.canonical.y-e.canonical.y||s.canonical.x-e.canonical.x}function Je(e){return"raster"===e||"image"===e||"video"===e}Ie.maxOverzooming=10,Ie.maxUnderzooming=3;class Re{constructor(e,s){this.reset(e,s)}reset(e,s){this.points=e||[],this._distances=[0];for(let e=1;e<this.points.length;e++)this._distances[e]=this._distances[e-1]+this.points[e].dist(this.points[e-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(s||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(e){if(1===this.points.length)return this.points[0];e=a.ai(e,0,1);let s=1,l=this._distances[s];const c=e*this.paddedLength+this.padding;for(;l<c&&s<this._distances.length;)l=this._distances[++s];const u=s-1,d=this._distances[u],f=l-d,_=f>0?(c-d)/f:0;return this.points[u].mult(1-_).add(this.points[s].mult(_))}}function Qe(e,s){let a=!0;return"always"===e||"never"!==e&&"never"!==s||(a=!1),a}class ze{constructor(e,s,a){const l=this.boxCells=[],c=this.circleCells=[];this.xCellCount=Math.ceil(e/a),this.yCellCount=Math.ceil(s/a);for(let e=0;e<this.xCellCount*this.yCellCount;e++)l.push([]),c.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=s,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/s,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,s,a,l,c){this._forEachCell(s,a,l,c,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(s),this.bboxes.push(a),this.bboxes.push(l),this.bboxes.push(c)}insertCircle(e,s,a,l){this._forEachCell(s-l,a-l,s+l,a+l,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(s),this.circles.push(a),this.circles.push(l)}_insertBoxCell(e,s,a,l,c,u){this.boxCells[c].push(u)}_insertCircleCell(e,s,a,l,c,u){this.circleCells[c].push(u)}_query(e,s,a,l,c,u,d){if(a<0||e>this.width||l<0||s>this.height)return[];const f=[];if(e<=0&&s<=0&&this.width<=a&&this.height<=l){if(c)return[{key:null,x1:e,y1:s,x2:a,y2:l}];for(let e=0;e<this.boxKeys.length;e++)f.push({key:this.boxKeys[e],x1:this.bboxes[4*e],y1:this.bboxes[4*e+1],x2:this.bboxes[4*e+2],y2:this.bboxes[4*e+3]});for(let e=0;e<this.circleKeys.length;e++){const s=this.circles[3*e],a=this.circles[3*e+1],l=this.circles[3*e+2];f.push({key:this.circleKeys[e],x1:s-l,y1:a-l,x2:s+l,y2:a+l})}}else this._forEachCell(e,s,a,l,this._queryCell,f,{hitTest:c,overlapMode:u,seenUids:{box:{},circle:{}}},d);return f}query(e,s,a,l){return this._query(e,s,a,l,!1,null)}hitTest(e,s,a,l,c,u){return this._query(e,s,a,l,!0,c,u).length>0}hitTestCircle(e,s,a,l,c){const u=e-a,d=e+a,f=s-a,_=s+a;if(d<0||u>this.width||_<0||f>this.height)return!1;const y=[];return this._forEachCell(u,f,d,_,this._queryCellCircle,y,{hitTest:!0,overlapMode:l,circle:{x:e,y:s,radius:a},seenUids:{box:{},circle:{}}},c),y.length>0}_queryCell(e,s,a,l,c,u,d,f){const{seenUids:_,hitTest:y,overlapMode:b}=d,S=this.boxCells[c];if(null!==S){const c=this.bboxes;for(const d of S)if(!_.box[d]){_.box[d]=!0;const S=4*d,P=this.boxKeys[d];if(e<=c[S+2]&&s<=c[S+3]&&a>=c[S+0]&&l>=c[S+1]&&(!f||f(P))&&(!y||!Qe(b,P.overlapMode))&&(u.push({key:P,x1:c[S],y1:c[S+1],x2:c[S+2],y2:c[S+3]}),y))return!0}}const P=this.circleCells[c];if(null!==P){const c=this.circles;for(const d of P)if(!_.circle[d]){_.circle[d]=!0;const S=3*d,P=this.circleKeys[d];if(this._circleAndRectCollide(c[S],c[S+1],c[S+2],e,s,a,l)&&(!f||f(P))&&(!y||!Qe(b,P.overlapMode))){const e=c[S],s=c[S+1],a=c[S+2];if(u.push({key:P,x1:e-a,y1:s-a,x2:e+a,y2:s+a}),y)return!0}}}return!1}_queryCellCircle(e,s,a,l,c,u,d,f){const{circle:_,seenUids:y,overlapMode:b}=d,S=this.boxCells[c];if(null!==S){const e=this.bboxes;for(const s of S)if(!y.box[s]){y.box[s]=!0;const a=4*s,l=this.boxKeys[s];if(this._circleAndRectCollide(_.x,_.y,_.radius,e[a+0],e[a+1],e[a+2],e[a+3])&&(!f||f(l))&&!Qe(b,l.overlapMode))return u.push(!0),!0}}const P=this.circleCells[c];if(null!==P){const e=this.circles;for(const s of P)if(!y.circle[s]){y.circle[s]=!0;const a=3*s,l=this.circleKeys[s];if(this._circlesCollide(e[a],e[a+1],e[a+2],_.x,_.y,_.radius)&&(!f||f(l))&&!Qe(b,l.overlapMode))return u.push(!0),!0}}}_forEachCell(e,s,a,l,c,u,d,f){const _=this._convertToXCellCoord(e),y=this._convertToYCellCoord(s),b=this._convertToXCellCoord(a),S=this._convertToYCellCoord(l);for(let P=_;P<=b;P++)for(let _=y;_<=S;_++)if(c.call(this,e,s,a,l,this.xCellCount*_+P,u,d,f))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,s,a,l,c,u){const d=l-e,f=c-s,_=a+u;return _*_>d*d+f*f}_circleAndRectCollide(e,s,a,l,c,u,d){const f=(u-l)/2,_=Math.abs(e-(l+f));if(_>f+a)return!1;const y=(d-c)/2,b=Math.abs(s-(c+y));if(b>y+a)return!1;if(_<=f||b<=y)return!0;const S=_-f,P=b-y;return S*S+P*P<=a*a}}function et(e,s,l){const u=a.M();if(!e){const{vecSouth:e,vecEast:a}=ct(s),l=c();l[0]=a[0],l[1]=a[1],l[2]=e[0],l[3]=e[1],d=l,(P=(_=(f=l)[0])*(S=f[3])-(b=f[2])*(y=f[1]))&&(d[0]=S*(P=1/P),d[1]=-y*P,d[2]=-b*P,d[3]=_*P),u[0]=l[0],u[1]=l[1],u[4]=l[2],u[5]=l[3]}var d,f,_,y,b,S,P;return a.O(u,u,[1/l,1/l,1]),u}function nt(e,s,l,c){if(e){const e=a.M();if(!s){const{vecSouth:s,vecEast:a}=ct(l);e[0]=a[0],e[1]=a[1],e[4]=s[0],e[5]=s[1]}return a.O(e,e,[c,c,1]),e}return l.pixelsToClipSpaceMatrix}function ct(e){const s=Math.cos(e.rollInRadians),l=Math.sin(e.rollInRadians),c=Math.cos(e.pitchInRadians),u=Math.cos(e.bearingInRadians),d=Math.sin(e.bearingInRadians),f=a.aw();f[0]=-u*c*l-d*s,f[1]=-d*c*l+u*s;const _=a.ax(f);_<1e-9?a.ay(f):a.az(f,f,1/_);const y=a.aw();y[0]=u*c*s-d*l,y[1]=d*c*s+u*l;const b=a.ax(y);return b<1e-9?a.ay(y):a.az(y,y,1/b),{vecEast:y,vecSouth:f}}function ht(e,s,l,c){let u;c?(u=[e,s,c(e,s),1],a.aB(u,u,l)):(u=[e,s,0,1],li(u,u,l));const d=u[3];return{point:new a.P(u[0]/d,u[1]/d),signedDistanceFromCamera:d,isOccluded:!1}}function ut(e,s){return.5+e/s*.5}function dt(e,s){return e.x>=-s[0]&&e.x<=s[0]&&e.y>=-s[1]&&e.y<=s[1]}function pt(e,s,l,c,u,d,f,_,y,b,S,P,M){const C=l?e.textSizeData:e.iconSizeData,D=a.as(C,s.transform.zoom),L=[256/s.width*2+1,256/s.height*2+1],F=l?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;F.clear();const B=e.lineVertexArray,O=l?e.text.placedSymbolArray:e.icon.placedSymbolArray,V=s.transform.width/s.transform.height;let N=!1;for(let l=0;l<O.length;l++){const j=O.get(l);if(j.hidden||j.writingMode===a.at.vertical&&!N){oi(j.numGlyphs,F);continue}N=!1;const G=new a.P(j.anchorX,j.anchorY),Z={getElevation:M,pitchedLabelPlaneMatrix:c,lineVertexArray:B,pitchWithMap:d,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:s.transform,tileAnchorPoint:G,unwrappedTileID:y,width:b,height:S,translation:P},q=Rt(j.anchorX,j.anchorY,Z);if(!dt(q.point,L)){oi(j.numGlyphs,F);continue}const W=ut(s.transform.cameraToCenterDistance,q.signedDistanceFromCamera),J=a.au(C,D,j),Q=d?J*s.transform.getPitchedTextCorrection(j.anchorX,j.anchorY,y)/W:J*W,se=_t({projectionContext:Z,pitchedLabelPlaneMatrixInverse:u,symbol:j,fontSize:Q,flip:!1,keepUpright:f,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:F,aspectRatio:V,rotateToLine:_});N=se.useVertical,(se.notEnoughRoom||N||se.needsFlipping&&_t({projectionContext:Z,pitchedLabelPlaneMatrixInverse:u,symbol:j,fontSize:Q,flip:!0,keepUpright:f,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:F,aspectRatio:V,rotateToLine:_}).notEnoughRoom)&&oi(j.numGlyphs,F)}l?e.text.dynamicLayoutVertexBuffer.updateData(F):e.icon.dynamicLayoutVertexBuffer.updateData(F)}function ft(e,s,a,l,c,u,d,f){const _=u.glyphStartIndex+u.numGlyphs,y=u.lineStartIndex,b=u.lineStartIndex+u.lineLength,S=s.getoffsetX(u.glyphStartIndex),P=s.getoffsetX(_-1),M=$t(e*S,a,l,c,u.segment,y,b,f,d);if(!M)return null;const C=$t(e*P,a,l,c,u.segment,y,b,f,d);return C?f.projectionCache.anyProjectionOccluded?null:{first:M,last:C}:null}function mt(e,s,l,c){return e===a.at.horizontal&&Math.abs(l.y-s.y)>Math.abs(l.x-s.x)*c?{useVertical:!0}:(e===a.at.vertical?s.y<l.y:s.x>l.x)?{needsFlipping:!0}:null}function _t(e){const{projectionContext:s,pitchedLabelPlaneMatrixInverse:l,symbol:c,fontSize:u,flip:d,keepUpright:f,glyphOffsetArray:_,dynamicLayoutVertexArray:y,aspectRatio:b,rotateToLine:S}=e,P=u/24,M=c.lineOffsetX*P,C=c.lineOffsetY*P;let D;if(c.numGlyphs>1){const e=c.glyphStartIndex+c.numGlyphs,a=c.lineStartIndex,u=c.lineStartIndex+c.lineLength,y=ft(P,_,M,C,d,c,S,s);if(!y)return{notEnoughRoom:!0};const L=Et(y.first.point.x,y.first.point.y,s,l),F=Et(y.last.point.x,y.last.point.y,s,l);if(f&&!d){const e=mt(c.writingMode,L,F,b);if(e)return e}D=[y.first];for(let l=c.glyphStartIndex+1;l<e-1;l++){const e=$t(P*_.getoffsetX(l),M,C,d,c.segment,a,u,s,S);if(!e)return{notEnoughRoom:!0};D.push(e)}D.push(y.last)}else{if(f&&!d){const e=vt(s.tileAnchorPoint.x,s.tileAnchorPoint.y,s).point,u=c.lineStartIndex+c.segment+1,d=new a.P(s.lineVertexArray.getx(u),s.lineVertexArray.gety(u)),f=vt(d.x,d.y,s),_=f.signedDistanceFromCamera>0?f.point:gt(s.tileAnchorPoint,d,e,1,s),y=Et(e.x,e.y,s,l),S=Et(_.x,_.y,s,l),P=mt(c.writingMode,y,S,b);if(P)return P}const e=$t(P*_.getoffsetX(c.glyphStartIndex),M,C,d,c.segment,c.lineStartIndex,c.lineStartIndex+c.lineLength,s,S);if(!e||s.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};D=[e]}for(const e of D)a.aA(y,e.point,e.angle);return{}}function gt(e,s,a,l,c){const u=e.add(e.sub(s)._unit()),d=vt(u.x,u.y,c).point,f=a.sub(d);return a.add(f._mult(l/f.mag()))}function yt(e,s,l){const c=s.projectionCache;if(c.projections[e])return c.projections[e];const u=new a.P(s.lineVertexArray.getx(e),s.lineVertexArray.gety(e)),d=vt(u.x,u.y,s);if(d.signedDistanceFromCamera>0)return c.projections[e]=d.point,c.anyProjectionOccluded=c.anyProjectionOccluded||d.isOccluded,d.point;const f=e-l.direction;return gt(0===l.distanceFromAnchor?s.tileAnchorPoint:new a.P(s.lineVertexArray.getx(f),s.lineVertexArray.gety(f)),u,l.previousVertex,l.absOffsetX-l.distanceFromAnchor+1,s)}function vt(e,s,a){const l=e+a.translation[0],c=s+a.translation[1];let u;return a.pitchWithMap?(u=ht(l,c,a.pitchedLabelPlaneMatrix,a.getElevation),u.isOccluded=!1):(u=a.transform.projectTileCoordinates(l,c,a.unwrappedTileID,a.getElevation),u.point.x=(.5*u.point.x+.5)*a.width,u.point.y=(.5*-u.point.y+.5)*a.height),u}function Et(e,s,l,c){if(l.pitchWithMap){const u=[e,s,0,1];return a.aB(u,u,c),l.transform.projectTileCoordinates(u[0]/u[3],u[1]/u[3],l.unwrappedTileID,l.getElevation).point}return{x:e/l.width*2-1,y:1-s/l.height*2}}function Rt(e,s,a){return a.transform.projectTileCoordinates(e,s,a.unwrappedTileID,a.getElevation)}function Vt(e,s,a){return e._unit()._perp()._mult(s*a)}function Zt(e,s,l,c,u,d,f,_,y){if(_.projectionCache.offsets[e])return _.projectionCache.offsets[e];const b=l.add(s);if(e+y.direction<c||e+y.direction>=u)return _.projectionCache.offsets[e]=b,b;const S=yt(e+y.direction,_,y),P=Vt(S.sub(l),f,y.direction),M=l.add(P),C=S.add(P);return _.projectionCache.offsets[e]=a.aC(d,b,M,C)||b,_.projectionCache.offsets[e]}function $t(e,s,a,l,c,u,d,f,_){const y=l?e-s:e+s;let b=y>0?1:-1,S=0;l&&(b*=-1,S=Math.PI),b<0&&(S+=Math.PI);let P,M=b>0?u+c:u+c+1;f.projectionCache.cachedAnchorPoint?P=f.projectionCache.cachedAnchorPoint:(P=vt(f.tileAnchorPoint.x,f.tileAnchorPoint.y,f).point,f.projectionCache.cachedAnchorPoint=P);let C,D,L=P,F=P,B=0,O=0;const V=Math.abs(y),N=[];let j;for(;B+O<=V;){if(M+=b,M<u||M>=d)return null;B+=O,F=L,D=C;const e={absOffsetX:V,direction:b,distanceFromAnchor:B,previousVertex:F};if(L=yt(M,f,e),0===a)N.push(F),j=L.sub(F);else{let s;const l=L.sub(F);s=0===l.mag()?Vt(yt(M+b,f,e).sub(L),a,b):Vt(l,a,b),D||(D=F.add(s)),C=Zt(M,s,L,u,d,D,a,f,e),N.push(D),j=C.sub(D)}O=j.mag()}const G=j._mult((V-B)/O)._add(D||F),Z=S+Math.atan2(L.y-F.y,L.x-F.x);return N.push(G),{point:G,angle:_?Z:0,path:N}}const ti=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function oi(e,s){for(let a=0;a<e;a++){const e=s.length;s.resize(e+4),s.float32.set(ti,3*e)}}function li(e,s,a){const l=s[0],c=s[1];return e[0]=a[0]*l+a[4]*c+a[12],e[1]=a[1]*l+a[5]*c+a[13],e[3]=a[3]*l+a[7]*c+a[15],e}const ci=100;class tt{constructor(e,s=new ze(e.width+200,e.height+200,25),a=new ze(e.width+200,e.height+200,25)){this.transform=e,this.grid=s,this.ignoredGrid=a,this.pitchFactor=Math.cos(e.pitch*Math.PI/180)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+ci,this.screenBottomBoundary=e.height+ci,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(e,s,a,l,c,u,d,f,_,y,b,S){const P=this.projectAndGetPerspectiveRatio(e.anchorPointX+f[0],e.anchorPointY+f[1],c,y,S),M=a*P.perspectiveRatio;let C;if(u||d)C=this._projectCollisionBox(e,M,l,c,u,d,f,P,y,b,S);else{const s=P.x+(b?b.x*M:0),a=P.y+(b?b.y*M:0);C={allPointsOccluded:!1,box:[s+e.x1*M,a+e.y1*M,s+e.x2*M,a+e.y2*M]}}const[D,L,F,B]=C.box,O=u?C.allPointsOccluded:P.isOccluded;let V=O;return V||(V=P.perspectiveRatio<this.perspectiveRatioCutoff),V||(V=!this.isInsideGrid(D,L,F,B)),V||"always"!==s&&this.grid.hitTest(D,L,F,B,s,_)?{box:[D,L,F,B],placeable:!1,offscreen:!1,occluded:O}:{box:[D,L,F,B],placeable:!0,offscreen:this.isOffscreen(D,L,F,B),occluded:O}}placeCollisionCircles(e,s,l,c,u,d,f,_,y,b,S,P,M,C){const D=[],L=new a.P(s.anchorX,s.anchorY),F=this.getPerspectiveRatio(L.x,L.y,d,C),B=(y?u*this.transform.getPitchedTextCorrection(s.anchorX,s.anchorY,d)/F:u*F)/a.aG,O={getElevation:C,pitchedLabelPlaneMatrix:f,lineVertexArray:l,pitchWithMap:y,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:L,unwrappedTileID:d,width:this.transform.width,height:this.transform.height,translation:M},V=ft(B,c,s.lineOffsetX*B,s.lineOffsetY*B,!1,s,!1,O);let N=!1,j=!1,G=!0;if(V){const s=.5*S*F+P,l=new a.P(-100,-100),c=new a.P(this.screenRightBoundary,this.screenBottomBoundary),u=new Re,d=V.first,f=V.last;let M=[];for(let e=d.path.length-1;e>=1;e--)M.push(d.path[e]);for(let e=1;e<f.path.length;e++)M.push(f.path[e]);const C=2.5*s;if(y){const e=this.projectPathToScreenSpace(M,O);M=e.some((e=>e.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point))}let L=[];if(M.length>0){const e=M[0].clone(),s=M[0].clone();for(let a=1;a<M.length;a++)e.x=Math.min(e.x,M[a].x),e.y=Math.min(e.y,M[a].y),s.x=Math.max(s.x,M[a].x),s.y=Math.max(s.y,M[a].y);L=e.x>=l.x&&s.x<=c.x&&e.y>=l.y&&s.y<=c.y?[M]:s.x<l.x||e.x>c.x||s.y<l.y||e.y>c.y?[]:a.aD([M],l.x,l.y,c.x,c.y)}for(const a of L){u.reset(a,.25*s);let l=0;l=u.length<=.5*s?1:Math.ceil(u.paddedLength/C)+1;for(let a=0;a<l;a++){const c=a/Math.max(l-1,1),d=u.lerp(c),f=d.x+ci,y=d.y+ci;D.push(f,y,s,0);const S=f-s,P=y-s,M=f+s,C=y+s;if(G=G&&this.isOffscreen(S,P,M,C),j=j||this.isInsideGrid(S,P,M,C),"always"!==e&&this.grid.hitTestCircle(f,y,s,e,b)&&(N=!0,!_))return{circles:[],offscreen:!1,collisionDetected:N}}}}return{circles:!_&&N||!j||F<this.perspectiveRatioCutoff?[]:D,offscreen:G,collisionDetected:N}}projectPathToScreenSpace(e,s){const l=function(e,s){const l=a.M();return a.av(l,s.pitchedLabelPlaneMatrix),e.map((e=>{const a=ht(e.x,e.y,l,s.getElevation),c=s.transform.projectTileCoordinates(a.point.x,a.point.y,s.unwrappedTileID,s.getElevation);return c.point.x=(.5*c.point.x+.5)*s.width,c.point.y=(.5*-c.point.y+.5)*s.height,c}))}(e,s);return function(e){let s=0,a=0,l=0,c=0;for(let u=0;u<e.length;u++)e[u].isOccluded?(l=u+1,c=0):(c++,c>a&&(a=c,s=l));return e.slice(s,s+a)}(l)}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const s=[],l=new a.a6;for(const c of e){const e=new a.P(c.x+ci,c.y+ci);l.extend(e),s.push(e)}const{minX:c,minY:u,maxX:d,maxY:f}=l,_=this.grid.query(c,u,d,f).concat(this.ignoredGrid.query(c,u,d,f)),y={},b={};for(const e of _){const l=e.key;if(void 0===y[l.bucketInstanceId]&&(y[l.bucketInstanceId]={}),y[l.bucketInstanceId][l.featureIndex])continue;const c=[new a.P(e.x1,e.y1),new a.P(e.x2,e.y1),new a.P(e.x2,e.y2),new a.P(e.x1,e.y2)];a.aE(s,c)&&(y[l.bucketInstanceId][l.featureIndex]=!0,void 0===b[l.bucketInstanceId]&&(b[l.bucketInstanceId]=[]),b[l.bucketInstanceId].push(l.featureIndex))}return b}insertCollisionBox(e,s,a,l,c,u){(a?this.ignoredGrid:this.grid).insert({bucketInstanceId:l,featureIndex:c,collisionGroupID:u,overlapMode:s},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,s,a,l,c,u){const d=a?this.ignoredGrid:this.grid,f={bucketInstanceId:l,featureIndex:c,collisionGroupID:u,overlapMode:s};for(let s=0;s<e.length;s+=4)d.insertCircle(f,e[s],e[s+1],e[s+2])}projectAndGetPerspectiveRatio(e,s,l,c,u){if(u){let l;c?(l=[e,s,c(e,s),1],a.aB(l,l,u)):(l=[e,s,0,1],li(l,l,u));const d=l[3];return{x:(l[0]/d+1)/2*this.transform.width+ci,y:(-l[1]/d+1)/2*this.transform.height+ci,perspectiveRatio:.5+this.transform.cameraToCenterDistance/d*.5,isOccluded:!1,signedDistanceFromCamera:d}}{const a=this.transform.projectTileCoordinates(e,s,l,c);return{x:(a.point.x+1)/2*this.transform.width+ci,y:(1-a.point.y)/2*this.transform.height+ci,perspectiveRatio:.5+this.transform.cameraToCenterDistance/a.signedDistanceFromCamera*.5,isOccluded:a.isOccluded,signedDistanceFromCamera:a.signedDistanceFromCamera}}}getPerspectiveRatio(e,s,a,l){const c=this.transform.projectTileCoordinates(e,s,a,l);return.5+this.transform.cameraToCenterDistance/c.signedDistanceFromCamera*.5}isOffscreen(e,s,a,l){return a<ci||e>=this.screenRightBoundary||l<ci||s>this.screenBottomBoundary}isInsideGrid(e,s,a,l){return a>=0&&e<this.gridRightBoundary&&l>=0&&s<this.gridBottomBoundary}getViewportMatrix(){const e=a.am([]);return a.N(e,e,[-100,-100,0]),e}_projectCollisionBox(e,s,l,c,u,d,f,_,y,b,S){let P=1,M=0,C=0,D=1;const L=e.anchorPointX+f[0],F=e.anchorPointY+f[1];if(d&&!u){const e=this.projectAndGetPerspectiveRatio(L+1,F,c,y,S),s=e.x-_.x,a=Math.atan((e.y-_.y)/s)+(s<0?Math.PI:0),l=Math.sin(a),u=Math.cos(a);P=u,M=l,C=-l,D=u}else if(!d&&u){const e=ct(this.transform);P=e.vecEast[0],M=e.vecEast[1],C=e.vecSouth[0],D=e.vecSouth[1]}let B=_.x,O=_.y,V=s;u&&(B=L,O=F,V=Math.pow(2,-(this.transform.zoom-l.overscaledZ)),V*=this.transform.getPitchedTextCorrection(L,F,c),b||(V*=a.ai(.5+_.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))),b&&(B+=P*b.x*V+C*b.y*V,O+=M*b.x*V+D*b.y*V);const N=e.x1*V,j=e.x2*V,G=(N+j)/2,Z=e.y1*V,q=e.y2*V,W=(Z+q)/2,J=[{offsetX:N,offsetY:Z},{offsetX:G,offsetY:Z},{offsetX:j,offsetY:Z},{offsetX:j,offsetY:W},{offsetX:j,offsetY:q},{offsetX:G,offsetY:q},{offsetX:N,offsetY:q},{offsetX:N,offsetY:W}];let Q=[];for(const{offsetX:e,offsetY:s}of J)Q.push(new a.P(B+P*e+C*s,O+M*e+D*s));let se=!1;if(u){const e=Q.map((e=>this.projectAndGetPerspectiveRatio(e.x,e.y,c,y,S)));se=e.some((e=>!e.isOccluded)),Q=e.map((e=>new a.P(e.x,e.y)))}else se=!0;return{box:a.aF(Q),allPointsOccluded:!se}}}class it{constructor(e,s,a,l){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?s:-s))):l&&a?1:0,this.placed=a}isHidden(){return 0===this.opacity&&!this.placed}}class at{constructor(e,s,a,l,c){this.text=new it(e?e.text:null,s,a,c),this.icon=new it(e?e.icon:null,s,l,c)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class rt{constructor(e,s,a){this.text=e,this.icon=s,this.skipFade=a}}class ot{constructor(e,s,a,l,c){this.bucketInstanceId=e,this.featureIndex=s,this.sourceLayerIndex=a,this.bucketIndex=l,this.tileID=c}}class st{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){const s=++this.maxGroupID;this.collisionGroups[e]={ID:s,predicate:e=>e.collisionGroupID===s}}return this.collisionGroups[e]}}function hi(e,s,l,c,u){const{horizontalAlign:d,verticalAlign:f}=a.aM(e);return new a.P(-(d-.5)*s+c[0]*u,-(f-.5)*l+c[1]*u)}class lt{constructor(e,s,a,l,c){this.transform=e.clone(),this.terrain=s,this.collisionIndex=new tt(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=a,this.retainedQueryData={},this.collisionGroups=new st(l),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=c,c&&(c.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){const s=this.terrain;return s?(a,l)=>s.getElevation(e,a,l):null}getBucketParts(e,s,l,c){const u=l.getBucket(s),d=l.latestFeatureIndex;if(!u||!d||s.id!==u.layerIds[0])return;const f=l.collisionBoxArray,_=u.layers[0].layout,y=u.layers[0].paint,b=Math.pow(2,this.transform.zoom-l.tileID.overscaledZ),S=l.tileSize/a.a3,P=l.tileID.toUnwrapped(),M="map"===_.get("text-rotation-alignment"),C=a.aH(l,1,this.transform.zoom),D=a.aI(this.collisionIndex.transform,l,y.get("text-translate"),y.get("text-translate-anchor")),L=a.aI(this.collisionIndex.transform,l,y.get("icon-translate"),y.get("icon-translate-anchor")),F=et(M,this.transform,C);this.retainedQueryData[u.bucketInstanceId]=new ot(u.bucketInstanceId,d,u.sourceLayerIndex,u.index,l.tileID);const B={bucket:u,layout:_,translationText:D,translationIcon:L,unwrappedTileID:P,pitchedLabelPlaneMatrix:F,scale:b,textPixelRatio:S,holdingForFade:l.holdingForSymbolFade(),collisionBoxArray:f,partiallyEvaluatedTextSize:a.as(u.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(u.sourceID)};if(c)for(const s of u.sortKeyRanges){const{sortKey:a,symbolInstanceStart:l,symbolInstanceEnd:c}=s;e.push({sortKey:a,symbolInstanceStart:l,symbolInstanceEnd:c,parameters:B})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:u.symbolInstances.length,parameters:B})}attemptAnchorPlacement(e,s,l,c,u,d,f,_,y,b,S,P,M,C,D,L,F,B,O,V){const N=a.aJ[e.textAnchor],j=[e.textOffset0,e.textOffset1],G=hi(N,l,c,j,u),Z=this.collisionIndex.placeCollisionBox(s,P,_,y,b,f,d,L,S.predicate,O,G,V);if((!B||this.collisionIndex.placeCollisionBox(B,P,_,y,b,f,d,F,S.predicate,O,G,V).placeable)&&Z.placeable){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[M.crossTileID]&&this.prevPlacement.placements[M.crossTileID]&&this.prevPlacement.placements[M.crossTileID].text&&(e=this.prevPlacement.variableOffsets[M.crossTileID].anchor),0===M.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[M.crossTileID]={textOffset:j,width:l,height:c,anchor:N,textBoxScale:u,prevAnchor:e},this.markUsedJustification(C,N,M,D),C.allowVerticalPlacement&&(this.markUsedOrientation(C,D,M),this.placedOrientations[M.crossTileID]=D),{shift:G,placedGlyphBoxes:Z}}}placeLayerBucketPart(e,s,l){const{bucket:c,layout:u,translationText:d,translationIcon:f,unwrappedTileID:_,pitchedLabelPlaneMatrix:y,textPixelRatio:b,holdingForFade:S,collisionBoxArray:P,partiallyEvaluatedTextSize:M,collisionGroup:C}=e.parameters,D=u.get("text-optional"),L=u.get("icon-optional"),F=a.aK(u,"text-overlap","text-allow-overlap"),B="always"===F,O=a.aK(u,"icon-overlap","icon-allow-overlap"),V="always"===O,N="map"===u.get("text-rotation-alignment"),j="map"===u.get("text-pitch-alignment"),G="none"!==u.get("icon-text-fit"),Z="viewport-y"===u.get("symbol-z-order"),q=B&&(V||!c.hasIconData()||L),W=V&&(B||!c.hasTextData()||D);!c.collisionArrays&&P&&c.deserializeCollisionBoxes(P);const J=this.retainedQueryData[c.bucketInstanceId].tileID,Q=this._getTerrainElevationFunc(J),se=this.transform.getFastPathSimpleProjectionMatrix(J),oe=(e,P,V)=>{var Z,oe;if(s[e.crossTileID])return;if(S)return void(this.placements[e.crossTileID]=new rt(!1,!1,!1));let ce=!1,pe=!1,fe=!0,xe=null,ve={box:null,placeable:!1,offscreen:null,occluded:!1},be={placeable:!1},we=null,Te=null,Se=null,Me=0,Ee=0,Ce=0;P.textFeatureIndex?Me=P.textFeatureIndex:e.useRuntimeCollisionCircles&&(Me=e.featureIndex),P.verticalTextFeatureIndex&&(Ee=P.verticalTextFeatureIndex);const Ae=P.textBox;if(Ae){const s=s=>{let l=a.at.horizontal;if(c.allowVerticalPlacement&&!s&&this.prevPlacement){const s=this.prevPlacement.placedOrientations[e.crossTileID];s&&(this.placedOrientations[e.crossTileID]=s,l=s,this.markUsedOrientation(c,l,e))}return l},u=(s,l)=>{if(c.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&P.verticalTextBox){for(const e of c.writingModes)if(e===a.at.vertical?(ve=l(),be=ve):ve=s(),ve&&ve.placeable)break}else ve=s()},y=e.textAnchorOffsetStartIndex,S=e.textAnchorOffsetEndIndex;if(S===y){const l=(s,a)=>{const l=this.collisionIndex.placeCollisionBox(s,F,b,J,_,j,N,d,C.predicate,Q,void 0,se);return l&&l.placeable&&(this.markUsedOrientation(c,a,e),this.placedOrientations[e.crossTileID]=a),l};u((()=>l(Ae,a.at.horizontal)),(()=>{const s=P.verticalTextBox;return c.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&s?l(s,a.at.vertical):{box:null,offscreen:null}})),s(ve&&ve.placeable)}else{let M=a.aJ[null===(oe=null===(Z=this.prevPlacement)||void 0===Z?void 0:Z.variableOffsets[e.crossTileID])||void 0===oe?void 0:oe.anchor];const D=(s,a,u)=>{const P=s.x2-s.x1,D=s.y2-s.y1,L=e.textBoxScale,B=G&&"never"===O?a:null;let V=null,Z="never"===F?1:2,q="never";M&&Z++;for(let a=0;a<Z;a++){for(let a=y;a<S;a++){const l=c.textAnchorOffsets.get(a);if(M&&l.textAnchor!==M)continue;const y=this.attemptAnchorPlacement(l,s,P,D,L,N,j,b,J,_,C,q,e,c,u,d,f,B,Q);if(y&&(V=y.placedGlyphBoxes,V&&V.placeable))return ce=!0,xe=y.shift,V}M?M=null:q=F}return l&&!V&&(V={box:this.collisionIndex.placeCollisionBox(Ae,"always",b,J,_,j,N,d,C.predicate,Q,void 0,se).box,offscreen:!1,placeable:!1,occluded:!1}),V};u((()=>D(Ae,P.iconBox,a.at.horizontal)),(()=>{const s=P.verticalTextBox;return c.allowVerticalPlacement&&(!ve||!ve.placeable)&&e.numVerticalGlyphVertices>0&&s?D(s,P.verticalIconBox,a.at.vertical):{box:null,occluded:!0,offscreen:null}})),ve&&(ce=ve.placeable,fe=ve.offscreen);const L=s(ve&&ve.placeable);if(!ce&&this.prevPlacement){const s=this.prevPlacement.variableOffsets[e.crossTileID];s&&(this.variableOffsets[e.crossTileID]=s,this.markUsedJustification(c,s.anchor,e,L))}}}if(we=ve,ce=we&&we.placeable,fe=we&&we.offscreen,e.useRuntimeCollisionCircles&&e.centerJustifiedTextSymbolIndex>=0){const s=c.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),f=a.au(c.textSizeData,M,s),b=u.get("text-padding");Te=this.collisionIndex.placeCollisionCircles(F,s,c.lineVertexArray,c.glyphOffsetArray,f,_,y,l,j,C.predicate,e.collisionCircleDiameter,b,d,Q),Te.circles.length&&Te.collisionDetected&&!l&&a.w("Collisions detected, but collision boxes are not shown"),ce=B||Te.circles.length>0&&!Te.collisionDetected,fe=fe&&Te.offscreen}if(P.iconFeatureIndex&&(Ce=P.iconFeatureIndex),P.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,O,b,J,_,j,N,f,C.predicate,Q,G&&xe?xe:void 0,se);be&&be.placeable&&P.verticalIconBox?(Se=e(P.verticalIconBox),pe=Se.placeable):(Se=e(P.iconBox),pe=Se.placeable),fe=fe&&Se.offscreen}const ke=D||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,Le=L||0===e.numIconVertices;ke||Le?Le?ke||(pe=pe&&ce):ce=pe&&ce:pe=ce=pe&&ce;const Fe=pe&&Se.placeable;if(ce&&we.placeable&&this.collisionIndex.insertCollisionBox(we.box,F,u.get("text-ignore-placement"),c.bucketInstanceId,be&&be.placeable&&Ee?Ee:Me,C.ID),Fe&&this.collisionIndex.insertCollisionBox(Se.box,O,u.get("icon-ignore-placement"),c.bucketInstanceId,Ce,C.ID),Te&&ce&&this.collisionIndex.insertCollisionCircles(Te.circles,F,u.get("text-ignore-placement"),c.bucketInstanceId,Me,C.ID),l&&this.storeCollisionData(c.bucketInstanceId,V,P,we,Se,Te),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===c.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new rt((ce||q)&&!(null==we?void 0:we.occluded),(pe||W)&&!(null==Se?void 0:Se.occluded),fe||c.justReloaded),s[e.crossTileID]=!0};if(Z){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const s=c.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=s.length-1;e>=0;--e){const a=s[e];oe(c.symbolInstances.get(a),c.collisionArrays[a],a)}}else for(let s=e.symbolInstanceStart;s<e.symbolInstanceEnd;s++)oe(c.symbolInstances.get(s),c.collisionArrays[s],s);c.justReloaded=!1}storeCollisionData(e,s,a,l,c,u){if(a.textBox||a.iconBox){let u,d;this.collisionBoxArrays.has(e)?u=this.collisionBoxArrays.get(e):(u=new Map,this.collisionBoxArrays.set(e,u)),u.has(s)?d=u.get(s):(d={text:null,icon:null},u.set(s,d)),a.textBox&&(d.text=l.box),a.iconBox&&(d.icon=c.box)}if(u){let s=this.collisionCircleArrays[e];void 0===s&&(s=this.collisionCircleArrays[e]=[]);for(let e=0;e<u.circles.length;e+=4)s.push(u.circles[e+0]-ci),s.push(u.circles[e+1]-ci),s.push(u.circles[e+2]),s.push(u.collisionDetected?1:0)}}markUsedJustification(e,s,l,c){let u;u=c===a.at.vertical?l.verticalPlacedTextSymbolIndex:{left:l.leftJustifiedTextSymbolIndex,center:l.centerJustifiedTextSymbolIndex,right:l.rightJustifiedTextSymbolIndex}[a.aL(s)];const d=[l.leftJustifiedTextSymbolIndex,l.centerJustifiedTextSymbolIndex,l.rightJustifiedTextSymbolIndex,l.verticalPlacedTextSymbolIndex];for(const s of d)s>=0&&(e.text.placedSymbolArray.get(s).crossTileID=u>=0&&s!==u?0:l.crossTileID)}markUsedOrientation(e,s,l){const c=s===a.at.horizontal||s===a.at.horizontalOnly?s:0,u=s===a.at.vertical?s:0,d=[l.leftJustifiedTextSymbolIndex,l.centerJustifiedTextSymbolIndex,l.rightJustifiedTextSymbolIndex];for(const s of d)e.text.placedSymbolArray.get(s).placedOrientation=c;l.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(l.verticalPlacedTextSymbolIndex).placedOrientation=u)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const s=this.prevPlacement;let a=!1;this.prevZoomAdjustment=s?s.zoomAdjustment(this.transform.zoom):0;const l=s?s.symbolFadeChange(e):1,c=s?s.opacities:{},u=s?s.variableOffsets:{},d=s?s.placedOrientations:{};for(const e in this.placements){const s=this.placements[e],u=c[e];u?(this.opacities[e]=new at(u,l,s.text,s.icon),a=a||s.text!==u.text.placed||s.icon!==u.icon.placed):(this.opacities[e]=new at(null,l,s.text,s.icon,s.skipFade),a=a||s.text||s.icon)}for(const e in c){const s=c[e];if(!this.opacities[e]){const c=new at(s,l,!1,!1);c.isHidden()||(this.opacities[e]=c,a=a||s.text.placed||s.icon.placed)}}for(const e in u)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=u[e]);for(const e in d)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=d[e]);if(s&&void 0===s.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");a?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=s?s.lastPlacementChangeTime:e)}updateLayerOpacities(e,s){const a={};for(const l of s){const s=l.getBucket(e);s&&l.latestFeatureIndex&&e.id===s.layerIds[0]&&this.updateBucketOpacities(s,l.tileID,a,l.collisionBoxArray)}}updateBucketOpacities(e,s,l,c){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const u=e.layers[0],d=u.layout,f=new at(null,0,!1,!1,!0),_=d.get("text-allow-overlap"),y=d.get("icon-allow-overlap"),b=u._unevaluatedLayout.hasValue("text-variable-anchor")||u._unevaluatedLayout.hasValue("text-variable-anchor-offset"),S="map"===d.get("text-rotation-alignment"),P="map"===d.get("text-pitch-alignment"),M="none"!==d.get("icon-text-fit"),C=new at(null,0,_&&(y||!e.hasIconData()||d.get("icon-optional")),y&&(_||!e.hasTextData()||d.get("text-optional")),!0);!e.collisionArrays&&c&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(c);const D=(e,s,a)=>{for(let l=0;l<s/4;l++)e.opacityVertexArray.emplaceBack(a);e.hasVisibleVertices=e.hasVisibleVertices||a!==Ii},L=this.collisionBoxArrays.get(e.bucketInstanceId);for(let s=0;s<e.symbolInstances.length;s++){const c=e.symbolInstances.get(s),{numHorizontalGlyphVertices:u,numVerticalGlyphVertices:d,crossTileID:_}=c;let y=this.opacities[_];l[_]?y=f:y||(y=C,this.opacities[_]=y),l[_]=!0;const F=c.numIconVertices>0,B=this.placedOrientations[c.crossTileID],O=B===a.at.vertical,V=B===a.at.horizontal||B===a.at.horizontalOnly;if(u>0||d>0){const s=wi(y.text);D(e.text,u,O?Ii:s),D(e.text,d,V?Ii:s);const a=y.text.isHidden();[c.rightJustifiedTextSymbolIndex,c.centerJustifiedTextSymbolIndex,c.leftJustifiedTextSymbolIndex].forEach((s=>{s>=0&&(e.text.placedSymbolArray.get(s).hidden=a||O?1:0)})),c.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(c.verticalPlacedTextSymbolIndex).hidden=a||V?1:0);const l=this.variableOffsets[c.crossTileID];l&&this.markUsedJustification(e,l.anchor,c,B);const f=this.placedOrientations[c.crossTileID];f&&(this.markUsedJustification(e,"left",c,f),this.markUsedOrientation(e,f,c))}if(F){const s=wi(y.icon),a=!(M&&c.verticalPlacedIconSymbolIndex&&O);c.placedIconSymbolIndex>=0&&(D(e.icon,c.numIconVertices,a?s:Ii),e.icon.placedSymbolArray.get(c.placedIconSymbolIndex).hidden=y.icon.isHidden()),c.verticalPlacedIconSymbolIndex>=0&&(D(e.icon,c.numVerticalIconVertices,a?Ii:s),e.icon.placedSymbolArray.get(c.verticalPlacedIconSymbolIndex).hidden=y.icon.isHidden())}const N=L&&L.has(s)?L.get(s):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const l=e.collisionArrays[s];if(l){let s=new a.P(0,0);if(l.textBox||l.verticalTextBox){let a=!0;if(b){const e=this.variableOffsets[_];e?(s=hi(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),S&&s._rotate(P?-this.transform.bearingInRadians:this.transform.bearingInRadians)):a=!1}if(l.textBox||l.verticalTextBox){let c;l.textBox&&(c=O),l.verticalTextBox&&(c=V),ui(e.textCollisionBox.collisionVertexArray,y.text.placed,!a||c,N.text,s.x,s.y)}}if(l.iconBox||l.verticalIconBox){const a=Boolean(!V&&l.verticalIconBox);let c;l.iconBox&&(c=a),l.verticalIconBox&&(c=!a),ui(e.iconCollisionBox.collisionVertexArray,y.icon.placed,c,N.icon,M?s.x:0,M?s.y:0)}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId])}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,s){const a=this.zoomAtLastRecencyCheck===s?1-this.zoomAdjustment(s):1;return this.zoomAtLastRecencyCheck=s,this.commitTime+this.fadeDuration*a>e}setStale(){this.stale=!0}}function ui(e,s,a,l,c,u){l&&0!==l.length||(l=[0,0,0,0]);const d=l[0]-ci,f=l[1]-ci,_=l[2]-ci,y=l[3]-ci;e.emplaceBack(s?1:0,a?1:0,c||0,u||0,d,f),e.emplaceBack(s?1:0,a?1:0,c||0,u||0,_,f),e.emplaceBack(s?1:0,a?1:0,c||0,u||0,_,y),e.emplaceBack(s?1:0,a?1:0,c||0,u||0,d,y)}const di=Math.pow(2,25),pi=Math.pow(2,24),fi=Math.pow(2,17),mi=Math.pow(2,16),_i=Math.pow(2,9),xi=Math.pow(2,8),bi=Math.pow(2,1);function wi(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const s=e.placed?1:0,a=Math.floor(127*e.opacity);return a*di+s*pi+a*fi+s*mi+a*_i+s*xi+a*bi+s}const Ii=0;class xt{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,s,a,l,c){const u=this._bucketParts;for(;this._currentTileIndex<e.length;)if(s.getBucketParts(u,l,e[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,c())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,u.sort(((e,s)=>e.sortKey-s.sortKey)));this._currentPartIndex<u.length;)if(s.placeLayerBucketPart(u[this._currentPartIndex],this._seenCrossTileIDs,a),this._currentPartIndex++,c())return!0;return!1}}class bt{constructor(e,s,a,l,c,u,d,f){this.placement=new lt(e,s,u,d,f),this._currentPlacementIndex=a.length-1,this._forceFullPlacement=l,this._showCollisionBoxes=c,this._done=!1}isDone(){return this._done}continuePlacement(e,s,a){const l=b(),c=()=>!this._forceFullPlacement&&b()-l>2;for(;this._currentPlacementIndex>=0;){const l=s[e[this._currentPlacementIndex]],u=this.placement.collisionIndex.transform.zoom;if("symbol"===l.type&&(!l.minzoom||l.minzoom<=u)&&(!l.maxzoom||l.maxzoom>u)){if(this._inProgressLayer||(this._inProgressLayer=new xt(l)),this._inProgressLayer.continuePlacement(a[l.source],this.placement,this._showCollisionBoxes,l,c))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Ei=512/a.a3/2;class wt{constructor(e,s,l){this.tileID=e,this.bucketInstanceId=l,this._symbolsByKey={};const c=new Map;for(let e=0;e<s.length;e++){const a=s.get(e),l=a.key,u=c.get(l);u?u.push(a):c.set(l,[a])}for(const[e,s]of c){const l={positions:s.map((e=>({x:Math.floor(e.anchorX*Ei),y:Math.floor(e.anchorY*Ei)}))),crossTileIDs:s.map((e=>e.crossTileID))};if(l.positions.length>128){const e=new a.aN(l.positions.length,16,Uint16Array);for(const{x:s,y:a}of l.positions)e.add(s,a);e.finish(),delete l.positions,l.index=e}this._symbolsByKey[e]=l}}getScaledCoordinates(e,s){const{x:l,y:c,z:u}=this.tileID.canonical,{x:d,y:f,z:_}=s.canonical,y=Ei/Math.pow(2,_-u),b=(f*a.a3+e.anchorY)*y,S=c*a.a3*Ei;return{x:Math.floor((d*a.a3+e.anchorX)*y-l*a.a3*Ei),y:Math.floor(b-S)}}findMatches(e,s,a){const l=this.tileID.canonical.z<s.canonical.z?1:Math.pow(2,this.tileID.canonical.z-s.canonical.z);for(let c=0;c<e.length;c++){const u=e.get(c);if(u.crossTileID)continue;const d=this._symbolsByKey[u.key];if(!d)continue;const f=this.getScaledCoordinates(u,s);if(d.index){const e=d.index.range(f.x-l,f.y-l,f.x+l,f.y+l).sort();for(const s of e){const e=d.crossTileIDs[s];if(!a[e]){a[e]=!0,u.crossTileID=e;break}}}else if(d.positions)for(let e=0;e<d.positions.length;e++){const s=d.positions[e],c=d.crossTileIDs[e];if(Math.abs(s.x-f.x)<=l&&Math.abs(s.y-f.y)<=l&&!a[c]){a[c]=!0,u.crossTileID=c;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map((({crossTileIDs:e})=>e))}}class Tt{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Pt{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const s=Math.round((e-this.lng)/360);if(0!==s)for(const e in this.indexes){const a=this.indexes[e],l={};for(const e in a){const c=a[e];c.tileID=c.tileID.unwrapTo(c.tileID.wrap+s),l[c.tileID.key]=c}this.indexes[e]=l}this.lng=e}addBucket(e,s,a){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===s.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let e=0;e<s.symbolInstances.length;e++)s.symbolInstances.get(e).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||(this.usedCrossTileIDs[e.overscaledZ]={});const l=this.usedCrossTileIDs[e.overscaledZ];for(const a in this.indexes){const c=this.indexes[a];if(Number(a)>e.overscaledZ)for(const a in c){const u=c[a];u.tileID.isChildOf(e)&&u.findMatches(s.symbolInstances,e,l)}else{const u=c[e.scaledTo(Number(a)).key];u&&u.findMatches(s.symbolInstances,e,l)}}for(let e=0;e<s.symbolInstances.length;e++){const c=s.symbolInstances.get(e);c.crossTileID||(c.crossTileID=a.generate(),l[c.crossTileID]=!0)}return void 0===this.indexes[e.overscaledZ]&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new wt(e,s.symbolInstances,s.bucketInstanceId),!0}removeBucketCrossTileIDs(e,s){for(const a of s.getCrossTileIDsLists())for(const s of a)delete this.usedCrossTileIDs[e][s]}removeStaleBuckets(e){let s=!1;for(const a in this.indexes){const l=this.indexes[a];for(const c in l)e[l[c].bucketInstanceId]||(this.removeBucketCrossTileIDs(a,l[c]),delete l[c],s=!0)}return s}}class Mt{constructor(){this.layerIndexes={},this.crossTileIDs=new Tt,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,s,a){let l=this.layerIndexes[e.id];void 0===l&&(l=this.layerIndexes[e.id]=new Pt);let c=!1;const u={};l.handleWrapJump(a);for(const a of s){const s=a.getBucket(e);s&&e.id===s.layerIds[0]&&(s.bucketInstanceId||(s.bucketInstanceId=++this.maxBucketInstanceId),l.addBucket(a.tileID,s,this.crossTileIDs)&&(c=!0),u[s.bucketInstanceId]=!0)}return l.removeStaleBuckets(u)&&(c=!0),c}pruneUnusedLayers(e){const s={};e.forEach((e=>{s[e]=!0}));for(const e in this.layerIndexes)s[e]||delete this.layerIndexes[e]}}var Ai="void main() {fragColor=vec4(1.0);}";const zi={prelude:Ri("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\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(unpack_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;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:Ri("","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:Ri("","#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),background:Ri("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:Ri("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;in vec2 v_pos_a;in 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=texture(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=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","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;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);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);}"),circle:Ri("in vec3 v_data;in 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);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out 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(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 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:Ri(Ai,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:Ri("uniform highp float u_intensity;in 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);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out 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 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.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 circle_center=floor(pos_raw/8.0);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:Ri("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:Ri("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:Ri("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;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);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:Ri("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {float x=(float(stop)+0.5)/float(u_color_ramp_size);vec4 data=texture(u_elevation_stops,vec2(x,0))*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else\n{l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0));\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_dimension;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),debug:Ri("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:Ri(Ai,"in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:Ri("#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\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;in vec2 a_pos;\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=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:Ri("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\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);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\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=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:Ri("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\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=texture(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=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\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=projectTile(a_pos+u_fill_translate,a_pos);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 GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:Ri("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in 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=texture(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=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out 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=projectTile(a_pos+u_fill_translate,a_pos);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);}"),fillExtrusion:Ri("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\nout 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 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((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.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:Ri("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in 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=texture(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=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","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 vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out 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 normal=a_normal_ed.xyz;float edgedistance=a_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;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,elevation*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/16383.0,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*=((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;}"),hillshadePrepare:Ri("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);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((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out 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:Ri("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];\n#define PI 3.141592653589793\n#define STANDARD 0\n#define COMBINED 1\n#define IGOR 2\n#define MULTIDIRECTIONAL 3\n#define BASIC 4\nfloat get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;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_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else\n{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else\n{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:Ri("uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\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 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);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\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 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;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:Ri("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\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);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\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 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;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);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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:Ri("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\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(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\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;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:Ri("uniform lowp float u_device_pixel_ratio;uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\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);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0/u_device_pixel_ratio)/min(dasharray_from.w,dasharray_to.w);alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\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\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\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\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_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;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),lineGradientSDF:Ri("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\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);vec4 color=texture(u_image,v_uv);float sdfdist_a=texture(u_image_dash,v_tex_a).a;float sdfdist_b=texture(u_image_dash,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0)/min(dasharray_from.w,dasharray_to.w);float dash_alpha=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*dash_alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;\n#ifdef GLOBE\nout float v_depth;\n#endif\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\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\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\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_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;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),raster:Ri("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in 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=texture(u_image0,v_pos0);vec4 color1=texture(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(dot(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);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:Ri("uniform sampler2D u_texture;in vec2 v_tex;in 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;fragColor=texture(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out 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_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);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;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_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;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:Ri("#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;in vec2 v_data0;in 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 inner_edge=(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);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in 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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out 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_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);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;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:Ri("#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;in vec4 v_data0;in 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;fragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=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=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in 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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out 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_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);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;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}"),terrain:Ri("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:Ri("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:Ri("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:Ri("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:Ri("in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:Ri("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function Ri(e,s){const a=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,l=s.match(/in ([\w]+) ([\w]+)/g),c=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),u=s.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),d=u?u.concat(c):c,f={};return{fragmentSource:e=e.replace(a,((e,s,a,l,c)=>(f[c]=!0,"define"===s?`\n#ifndef HAS_UNIFORM_u_${c}\nin ${a} ${l} ${c};\n#else\nuniform ${a} ${l} u_${c};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${c}\n ${a} ${l} ${c} = u_${c};\n#endif\n`))),vertexSource:s=s.replace(a,((e,s,a,l,c)=>{const u="float"===l?"vec2":"vec4",d=c.match(/color/)?"color":u;return f[c]?"define"===s?`\n#ifndef HAS_UNIFORM_u_${c}\nuniform lowp float u_${c}_t;\nin ${a} ${u} a_${c};\nout ${a} ${l} ${c};\n#else\nuniform ${a} ${l} u_${c};\n#endif\n`:"vec4"===d?`\n#ifndef HAS_UNIFORM_u_${c}\n ${c} = a_${c};\n#else\n ${a} ${l} ${c} = u_${c};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${c}\n ${c} = unpack_mix_${d}(a_${c}, u_${c}_t);\n#else\n ${a} ${l} ${c} = u_${c};\n#endif\n`:"define"===s?`\n#ifndef HAS_UNIFORM_u_${c}\nuniform lowp float u_${c}_t;\nin ${a} ${u} a_${c};\n#else\nuniform ${a} ${l} u_${c};\n#endif\n`:"vec4"===d?`\n#ifndef HAS_UNIFORM_u_${c}\n ${a} ${l} ${c} = a_${c};\n#else\n ${a} ${l} ${c} = u_${c};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${c}\n ${a} ${l} ${c} = unpack_mix_${d}(a_${c}, u_${c}_t);\n#else\n ${a} ${l} ${c} = u_${c};\n#endif\n`})),staticAttributes:l,staticUniforms:d}}class St{constructor(e,s,a){this.vertexBuffer=e,this.indexBuffer=s,this.segments=a}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Li=a.aO([{name:"a_pos",type:"Int16",components:2}]);const Fi="#define PROJECTION_MERCATOR",Bi="mercator";class At{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return Bi}get shaderDefine(){return Fi}get shaderPreludeCode(){return zi.projectionMercator}get vertexShaderPreludeCode(){return zi.projectionMercator.vertexSource}get subdivisionGranularity(){return a.aP.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,s,l,c,u){if(this._cachedMesh)return this._cachedMesh;const d=new a.aQ;d.emplaceBack(0,0),d.emplaceBack(a.a3,0),d.emplaceBack(0,a.a3),d.emplaceBack(a.a3,a.a3);const f=e.createVertexBuffer(d,Li.members),_=a.aR.simpleSegment(0,0,4,2),y=new a.aS;y.emplaceBack(1,0,2),y.emplaceBack(1,2,3);const b=e.createIndexBuffer(y);return this._cachedMesh=new St(f,b,_),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class Lt{constructor(e=0,s=0,a=0,l=0){if(isNaN(e)||e<0||isNaN(s)||s<0||isNaN(a)||a<0||isNaN(l)||l<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=s,this.left=a,this.right=l}interpolate(e,s,l){return null!=s.top&&null!=e.top&&(this.top=a.F.number(e.top,s.top,l)),null!=s.bottom&&null!=e.bottom&&(this.bottom=a.F.number(e.bottom,s.bottom,l)),null!=s.left&&null!=e.left&&(this.left=a.F.number(e.left,s.left,l)),null!=s.right&&null!=e.right&&(this.right=a.F.number(e.right,s.right,l)),this}getCenter(e,s){const l=a.ai((this.left+e-this.right)/2,0,e),c=a.ai((this.top+s-this.bottom)/2,0,s);return new a.P(l,c)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Lt(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Oi(e,s){if(!e.renderWorldCopies||e.lngRange)return;const a=s.lng-e.center.lng;s.lng+=a>180?-360:a<-180?360:0}function Vi(e){return Math.max(0,Math.floor(e))}class Bt{constructor(e,s){var l;this.applyConstrain=(e,s)=>null!==this._constrainOverride?this._constrainOverride(e,s):this._callbacks.defaultConstrain(e,s),this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===(null==s?void 0:s.renderWorldCopies)||!!(null==s?void 0:s.renderWorldCopies),this._minZoom=(null==s?void 0:s.minZoom)||0,this._maxZoom=(null==s?void 0:s.maxZoom)||22,this._minPitch=null==(null==s?void 0:s.minPitch)?0:null==s?void 0:s.minPitch,this._maxPitch=null==(null==s?void 0:s.maxPitch)?60:null==s?void 0:s.maxPitch,this._constrainOverride=null!==(l=null==s?void 0:s.constrainOverride)&&void 0!==l?l:null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new a.U(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Vi(this._zoom),this._scale=a.al(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Lt,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,s,l){this._constrainOverride=e.constrainOverride,this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=Vi(this._zoom),this._scale=a.al(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new Lt(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!l&&e.autoCalculateNearFarZ,s&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)))}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get constrainOverride(){return this._constrainOverride}setConstrainOverride(e){void 0===e&&(e=null),this._constrainOverride!==e&&(this._constrainOverride=e,this.constrainInternal(),this._calcMatrices())}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new a.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const s=a.V(e,-180,180)*Math.PI/180;var l,u,d,f,_,y,b,S,P;this._bearingInRadians!==s&&(this._unmodified=!1,this._bearingInRadians=s,this._calcMatrices(),this._rotationMatrix=c(),l=this._rotationMatrix,d=-this._bearingInRadians,f=(u=this._rotationMatrix)[0],_=u[1],y=u[2],b=u[3],S=Math.sin(d),P=Math.cos(d),l[0]=f*P+y*S,l[1]=_*P+b*S,l[2]=f*-S+y*P,l[3]=_*-S+b*P)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const s=a.ai(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==s&&(this._unmodified=!1,this._pitchInRadians=s,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const s=e/180*Math.PI;this._rollInRadians!==s&&(this._unmodified=!1,this._rollInRadians=s,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return a.aT(this._fovInRadians)}setFov(e){e=a.ai(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=a.ak(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){const s=this.applyConstrain(this._center,e).zoom;this._zoom!==s&&(this._unmodified=!1,this._zoom=s,this._tileZoom=Math.max(0,Math.floor(s)),this._scale=a.al(s),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,s){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=s,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,s,a){this._unmodified=!1,this._edgeInsets.interpolate(e,s,a),this.constrainInternal(),this._calcMatrices()}resize(e,s,a=!0){this._width=e,this._height=s,a&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return this._latRange&&2===this._latRange.length&&this._lngRange&&2===this._lngRange.length?new $([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-a.aj,a.aj])}getCameraQueryGeometry(e,s){if(1===s.length)return[s[0],e];{const{minX:l,minY:c,maxX:u,maxY:d}=a.a6.fromPoints(s).extend(e);return[new a.P(l,c),new a.P(u,c),new a.P(u,d),new a.P(l,d),new a.P(l,c)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:s,zoom:a}=this.applyConstrain(this.center,this.zoom);this.setCenter(s),this.setZoom(a),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=a.am(new Float64Array(16));a.O(e,e,[this._width/2,-this._height/2,1]),a.N(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=a.am(new Float64Array(16)),a.O(e,e,[1,-1,1]),a.N(e,e,[-1,-1,0]),a.O(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,s,l,c){const u=void 0!==l?l:this.bearing,d=c=void 0!==c?c:this.pitch,f=a.a5.fromLngLat(e,s),_=-Math.cos(a.ak(d)),y=Math.sin(a.ak(d)),b=y*Math.sin(a.ak(u)),S=-y*Math.cos(a.ak(u));let P=this.elevation;const M=s-P;let C;_*M>=0||Math.abs(_)<.1?(C=1e4,P=s+C*_):C=-M/_;let D,L,F=a.aU(1,f.y),B=0;do{if(B+=1,B>10)break;L=C/F,D=new a.a5(f.x+b*L,f.y+S*L),F=1/D.meterInMercatorCoordinateUnits()}while(Math.abs(C-L*F)>1e-12);return{center:D.toLngLat(),elevation:P,zoom:a.ao(this.height/2/Math.tan(this.fovInRadians/2)/L/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const s=a.an(1,this.center.lat)*this.worldSize,l=this.cameraToCenterDistance/s,c=a.a5.fromLngLat(this.center,this.elevation),u=Ge(this.center,this.elevation,this.pitch,this.bearing,l);this._elevation=e;const d=this.calculateCenterFromCameraLngLatAlt(u.toLngLat(),a.aU(u.z,c.y),this.bearing,this.pitch);this._elevation=d.elevation,this._center=d.center,this.setZoom(d.zoom)}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new a.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const e=a.an(1,this.center.lat)*this.worldSize;return Ge(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];const s=e.canonical.z>=0?1<<e.canonical.z:Math.pow(2,e.canonical.z);return[e.canonical.x/s,e.canonical.y/s,1/s/a.a3,1/s/a.a3]}}class Ot{constructor(e,s){this.min=e,this.max=s,this.center=a.aV([],a.aW([],this.min,this.max),.5)}quadrant(e){const s=[e%2==0,e<2],l=a.aX(this.min),c=a.aX(this.max);for(let e=0;e<s.length;e++)l[e]=s[e]?this.min[e]:this.center[e],c[e]=s[e]?this.center[e]:this.max[e];return c[2]=this.max[2],new Ot(l,c)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}intersectsFrustum(e){let s=!0;for(let a=0;a<e.planes.length;a++){const l=this.intersectsPlane(e.planes[a]);if(0===l)return 0;1===l&&(s=!1)}return s?2:e.aabb.min[0]>this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]<this.min[0]||e.aabb.max[1]<this.min[1]||e.aabb.max[2]<this.min[2]?0:1}intersectsPlane(e){let s=e[3],a=e[3];for(let l=0;l<3;l++)e[l]>0?(s+=e[l]*this.min[l],a+=e[l]*this.max[l]):(a+=e[l]*this.min[l],s+=e[l]*this.max[l]);return s>=0?2:a<0?0:1}}class jt{distanceToTile2d(e,s,a,l){const c=l.distanceX([e,s]),u=l.distanceY([e,s]);return Math.hypot(c,u)}getWrap(e,s,a){return a}getTileBoundingVolume(e,s,l,c){var u,d;let f=0,_=0;if(null==c?void 0:c.terrain){const y=new a.a0(e.z,s,e.z,e.x,e.y),b=c.terrain.getMinMaxElevation(y);f=null!==(u=b.minElevation)&&void 0!==u?u:Math.min(0,l),_=null!==(d=b.maxElevation)&&void 0!==d?d:Math.max(0,l)}const y=1<<e.z;return new Ot([s+e.x/y,e.y/y,f],[s+(e.x+1)/y,(e.y+1)/y,_])}allowVariableZoom(e,s){const l=e.fov*(Math.abs(Math.cos(e.rollInRadians))*e.height+Math.abs(Math.sin(e.rollInRadians))*e.width)/e.height,c=a.ai(78.5-l/2,0,60);return!!s.terrain||e.pitch>c}allowWorldCopies(){return!0}prepareNextFrame(){}}class Ut{constructor(e,s,a){this.points=e,this.planes=s,this.aabb=a}static fromInvProjectionMatrix(e,s=1,l=0,c,u){const d=u?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],f=Math.pow(2,l),_=[[-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((l=>function(e,s,l,c){const u=a.aB([],e,s),d=1/u[3]/l*c;return a.b0(u,u,[d,d,1/u[3],d])}(l,e,s,f)));c&&function(e,s,l,c){const u=c?4:0,d=c?0:4;let f=0;const _=[],y=[];for(let s=0;s<4;s++){const l=a.aY([],e[s+d],e[s+u]),c=a.b1(l);a.aV(l,l,1/c),_.push(c),y.push(l)}for(let s=0;s<4;s++){const c=a.b2(e[s+u],y[s],l);f=null!==c&&c>=0?Math.max(f,c):Math.max(f,_[s])}const b=function(e,s){const l=a.aY([],e[s[0]],e[s[1]]),c=a.aY([],e[s[2]],e[s[1]]),u=[0,0,0,0];return a.aZ(u,a.a_([],l,c)),u[3]=-a.a$(u,e[s[0]]),u}(e,s),S=function(e,s){const l=a.b3(e),c=a.b4([],e,1/l),u=a.aY([],s,a.aV([],c,a.a$(s,c))),d=a.b3(u);if(d>0){const e=Math.sqrt(1-c[3]*c[3]),l=a.aV([],c,-c[3]),f=a.aW([],l,a.aV([],u,e/d));return a.b5(s,f)}return null}(l,b);if(null!==S){const e=S/a.a$(y[0],b);f=Math.min(f,e)}for(let s=0;s<4;s++){const a=Math.min(f,_[s]);e[s+d]=[e[s+u][0]+y[s][0]*a,e[s+u][1]+y[s][1]*a,e[s+u][2]+y[s][2]*a,1]}}(_,d[0],c,u);const y=d.map((e=>{const s=a.aY([],_[e[0]],_[e[1]]),l=a.aY([],_[e[2]],_[e[1]]),c=a.aZ([],a.a_([],s,l)),u=-a.a$(c,_[e[1]]);return c.concat(u)})),b=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],S=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const e of _)for(let s=0;s<3;s++)b[s]=Math.min(b[s],e[s]),S[s]=Math.max(S[s],e[s]);return new Ut(_,y,new Ot(b,S))}}class Nt{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,s,a){return this._helper.interpolatePadding(e,s,a)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,s,a=!0){this._helper.resize(e,s,a)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,s){this._helper.overrideNearFarZ(e,s)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,s){}constructor(e){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(e,s)=>{s=a.ai(+s,this.minZoom,this.maxZoom);const l={center:new a.U(e.lng,e.lat),zoom:s};let c=this._helper._lngRange;if(!this._helper._renderWorldCopies&&null===c){const e=180-1e-10;c=[-e,e]}const u=this.tileSize*a.al(l.zoom);let d=0,f=u,_=0,y=u,b=0,S=0;const{x:P,y:M}=this.size;if(this._helper._latRange){const e=this._helper._latRange;d=a.W(e[1])*u,f=a.W(e[0])*u,f-d<M&&(b=M/(f-d))}c&&(_=a.V(a.X(c[0])*u,0,u),y=a.V(a.X(c[1])*u,0,u),y<_&&(y+=u),y-_<P&&(S=P/(y-_)));const{x:C,y:D}=Ve(u,e);let L,F;const B=Math.max(S||0,b||0);if(B){const e=new a.P(S?(y+_)/2:C,b?(f+d)/2:D);return l.center=Ne(u,e).wrap(),l.zoom+=a.ao(B),l}if(this._helper._latRange){const e=M/2;D-e<d&&(F=d+e),D+e>f&&(F=f-e)}if(c){const e=(_+y)/2;let s=C;this._helper._renderWorldCopies&&(s=a.V(C,e-u/2,e+u/2));const l=P/2;s-l<_&&(L=_+l),s+l>y&&(L=y-l)}if(void 0!==L||void 0!==F){const e=new a.P(null!=L?L:C,null!=F?F:D);l.center=Ne(u,e).wrap()}return l},this.applyConstrain=(e,s)=>this._helper.applyConstrain(e,s),this._helper=new Bt({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,s)=>this.defaultConstrain(e,s)},e),this._coveringTilesDetailsProvider=new jt}clone(){const e=new Nt;return e.apply(this),e}apply(e,s,a){this._helper.apply(e,s,a)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){const s=[new a.b6(0,e)];if(this._helper._renderWorldCopies){const l=this.screenPointToMercatorCoordinate(new a.P(0,0)),c=this.screenPointToMercatorCoordinate(new a.P(this._helper._width,0)),u=this.screenPointToMercatorCoordinate(new a.P(this._helper._width,this._helper._height)),d=this.screenPointToMercatorCoordinate(new a.P(0,this._helper._height)),f=Math.floor(Math.min(l.x,c.x,u.x,d.x)),_=Math.floor(Math.max(l.x,c.x,u.x,d.x)),y=1;for(let l=f-y;l<=_+y;l++)0!==l&&s.push(new a.b6(l,e))}return s}getCameraFrustum(){return Ut.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const s=this.screenPointToLocation(this.centerPoint,e),a=e?e.getElevationForLngLatZoom(s,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(a)}setLocationAtPoint(e,s){const l=a.an(this.elevation,this.center.lat),c=this.screenPointToMercatorCoordinateAtZ(s,l),u=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,l),d=a.a5.fromLngLat(e),f=new a.a5(d.x-(c.x-u.x),d.y-(c.y-u.y));this.setCenter(null==f?void 0:f.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,s){return s?this.coordinatePoint(a.a5.fromLngLat(e),s.getElevationForLngLatZoom(e,this._helper._tileZoom),this._pixelMatrix3D):this.coordinatePoint(a.a5.fromLngLat(e))}screenPointToLocation(e,s){var a;return null===(a=this.screenPointToMercatorCoordinate(e,s))||void 0===a?void 0:a.toLngLat()}screenPointToMercatorCoordinate(e,s){if(s){const a=s.pointCoordinate(e);if(null!=a)return a}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,s){const l=s||0,c=[e.x,e.y,0,1],u=[e.x,e.y,1,1];a.aB(c,c,this._pixelMatrixInverse),a.aB(u,u,this._pixelMatrixInverse);const d=c[3],f=u[3],_=c[1]/d,y=u[1]/f,b=c[2]/d,S=u[2]/f,P=b===S?0:(l-b)/(S-b);return new a.a5(a.F.number(c[0]/d,u[0]/f,P)/this.worldSize,a.F.number(_,y,P)/this.worldSize,l)}coordinatePoint(e,s=0,l=this._pixelMatrix){const c=[e.x*this.worldSize,e.y*this.worldSize,s,1];return a.aB(c,c,l),new a.P(c[0]/c[3],c[1]/c[3])}getBounds(){const e=Math.max(0,this._helper._height/2-je(this));return(new $).extend(this.screenPointToLocation(new a.P(0,e))).extend(this.screenPointToLocation(new a.P(this._helper._width,e))).extend(this.screenPointToLocation(new a.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new a.P(0,this._helper._height)))}isPointOnMapSurface(e,s){return s?null!=s.pointCoordinate(e):e.y>this.height/2-je(this)}calculatePosMatrix(e,s=!1,l){var c;const u=null!==(c=e.key)&&void 0!==c?c:a.b7(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),d=s?this._alignedPosMatrixCache:this._posMatrixCache;if(d.has(u)){const e=d.get(u);return l?e.f32:e.f64}const f=Ue(e,this.worldSize);a.Q(f,s?this._alignedProjMatrix:this._viewProjMatrix,f);const _={f64:f,f32:new Float32Array(f)};return d.set(u,_),l?_.f32:_.f64}calculateFogMatrix(e){const s=e.key,l=this._fogMatrixCacheF32;if(l.has(s))return l.get(s);const c=Ue(e,this.worldSize);return a.Q(c,this._fogMatrix,c),l.set(s,new Float32Array(c)),l.get(s)}calculateCenterFromCameraLngLatAlt(e,s,a,l){return this._helper.calculateCenterFromCameraLngLatAlt(e,s,a,l)}_calculateNearFarZIfNeeded(e,s,l){if(!this._helper.autoCalculateNearFarZ)return;const c=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),u=e-c*this._helper._pixelPerMeter/Math.cos(s),d=c<0?u:e,f=Math.PI/2+this.pitchInRadians,_=a.ak(this.fov)*(Math.abs(Math.cos(a.ak(this.roll)))*this.height+Math.abs(Math.sin(a.ak(this.roll)))*this.width)/this.height*(.5+l.y/this.height),y=Math.sin(_)*d/Math.sin(a.ai(Math.PI-f-_,.01,Math.PI-.01)),b=je(this),S=Math.atan(b/this._helper.cameraToCenterDistance),P=a.ak(.75),M=S>P?2*S*(.5+l.y/(2*b)):P,C=Math.sin(M)*d/Math.sin(a.ai(Math.PI-f-M,.01,Math.PI-.01)),D=Math.min(y,C);this._helper._farZ=1.01*(Math.cos(Math.PI/2-s)*D+d),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,s=Ve(this.worldSize,this.center),l=s.x,c=s.y;this._helper._pixelPerMeter=a.an(1,this.center.lat)*this.worldSize;const u=a.ak(Math.min(this.pitch,Oe)),d=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(u));let f;this._calculateNearFarZIfNeeded(d,u,e),f=new Float64Array(16),a.b8(f,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),a.av(this._invProjMatrix,f),f[8]=2*-e.x/this._helper._width,f[9]=2*e.y/this._helper._height,this._projectionMatrix=a.b9(f),a.O(f,f,[1,-1,1]),a.N(f,f,[0,0,-this._helper.cameraToCenterDistance]),a.ba(f,f,-this.rollInRadians),a.bb(f,f,this.pitchInRadians),a.ba(f,f,-this.bearingInRadians),a.N(f,f,[-l,-c,0]),this._mercatorMatrix=a.O([],f,[this.worldSize,this.worldSize,this.worldSize]),a.O(f,f,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=a.Q(new Float64Array(16),this.clipSpaceToPixelsMatrix,f),a.N(f,f,[0,0,-this.elevation]),this._viewProjMatrix=f,this._invViewProjMatrix=a.av([],f);const _=[0,0,-1,1];a.aB(_,_,this._invViewProjMatrix),this._cameraPosition=[_[0]/_[3],_[1]/_[3],_[2]/_[3]],this._fogMatrix=new Float64Array(16),a.b8(this._fogMatrix,this.fovInRadians,this.width/this.height,d,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,a.O(this._fogMatrix,this._fogMatrix,[1,-1,1]),a.N(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),a.ba(this._fogMatrix,this._fogMatrix,-this.rollInRadians),a.bb(this._fogMatrix,this._fogMatrix,this.pitchInRadians),a.ba(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),a.N(this._fogMatrix,this._fogMatrix,[-l,-c,0]),a.O(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),a.N(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=a.Q(new Float64Array(16),this.clipSpaceToPixelsMatrix,f);const y=this._helper._width%2/2,b=this._helper._height%2/2,S=Math.cos(this.bearingInRadians),P=Math.sin(-this.bearingInRadians),M=l-Math.round(l)+S*y+P*b,C=c-Math.round(c)+S*b+P*y,D=new Float64Array(f);if(a.N(D,D,[M>.5?M-1:M,C>.5?C-1:C,0]),this._alignedProjMatrix=D,f=a.av(new Float64Array(16),this._pixelMatrix),!f)throw new Error("failed to invert matrix");this._pixelMatrixInverse=f,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new a.P(0,0)),s=[e.x*this.worldSize,e.y*this.worldSize,0,1];return a.aB(s,s,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=a.an(1,this.center.lat)*this.worldSize;return Ge(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,s){const l=a.a5.fromLngLat(e),c=[l.x*this.worldSize,l.y*this.worldSize,s,1];return a.aB(c,c,this._viewProjMatrix),c[2]/c[3]}getProjectionData(e){const{overscaledTileID:s,aligned:l,applyTerrainMatrix:c}=e,u=this._helper.getMercatorTileCoordinates(s),d=s?this.calculatePosMatrix(s,l,!0):null;let f;return f=s&&s.terrainRttPosMatrix32f&&c?s.terrainRttPosMatrix32f:d||a.bc(),{mainMatrix:f,tileMercatorCoords:u,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:f}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,s,a){return 1}transformLightDirection(e){return a.aX(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,s,l,c){const u=this.calculatePosMatrix(l);let d;c?(d=[e,s,c(e,s),1],a.aB(d,d,u)):(d=[e,s,0,1],li(d,d,u));const f=d[3];return{point:new a.P(d[0]/f,d[1]/f),signedDistanceFromCamera:f,isOccluded:!1}}populateCache(e){for(const s of e)this.calculatePosMatrix(s)}getMatrixForModel(e,s){const l=a.a5.fromLngLat(e,s),c=l.meterInMercatorCoordinateUnits(),u=a.bd();return a.N(u,u,[l.x,l.y,l.z]),a.ba(u,u,Math.PI),a.bb(u,u,Math.PI/2),a.O(u,u,[-c,c,c]),u}getProjectionDataForCustomLayer(e=!0){const s=new a.a0(0,0,0,0,0),l=this.getProjectionData({overscaledTileID:s,applyGlobeMatrix:e}),c=Ue(s,this.worldSize);a.Q(c,this._viewProjMatrix,c),l.tileMercatorCoords=[0,0,1,1];const u=[a.a3,a.a3,this.worldSize/this._helper.pixelsPerMeter],d=a.be();return a.O(d,c,u),l.fallbackMatrix=d,l.mainMatrix=d,l}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function Ni(){a.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function ji(e){if(e.useSlerp)if(e.k<1){const s=a.bf(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),l=a.bf(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),c=new Float64Array(4);a.bg(c,s,l,e.k);const u=a.bh(c);e.tr.setRoll(u.roll),e.tr.setPitch(u.pitch),e.tr.setBearing(u.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(a.F.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(a.F.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(a.F.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function Ui(e,s,l,c,u){const d=u.padding,f=Ve(u.worldSize,l.getNorthWest()),_=Ve(u.worldSize,l.getNorthEast()),y=Ve(u.worldSize,l.getSouthEast()),b=Ve(u.worldSize,l.getSouthWest()),S=a.ak(-c),P=f.rotate(S),M=_.rotate(S),C=y.rotate(S),D=b.rotate(S),L=new a.P(Math.max(P.x,M.x,D.x,C.x),Math.max(P.y,M.y,D.y,C.y)),F=new a.P(Math.min(P.x,M.x,D.x,C.x),Math.min(P.y,M.y,D.y,C.y)),B=L.sub(F),O=(u.width-(d.left+d.right+s.left+s.right))/B.x,V=(u.height-(d.top+d.bottom+s.top+s.bottom))/B.y;if(V<0||O<0)return void Ni();const N=Math.min(a.ao(u.scale*Math.min(O,V)),e.maxZoom),j=a.P.convert(e.offset),G=new a.P((s.left-s.right)/2,(s.top-s.bottom)/2).rotate(a.ak(c)),Z=j.add(G).mult(u.scale/a.al(N));return{center:Ne(u.worldSize,f.add(y).div(2).sub(Z)),zoom:N,bearing:c}}class Wt{get useGlobeControls(){return!1}handlePanInertia(e,s){const a=e.mag(),l=Math.abs(je(s));return{easingOffset:e.mult(Math.min(.75*l/a,1)),easingCenter:s.center}}handleMapControlsRollPitchBearingZoom(e,s){e.bearingDelta&&s.setBearing(s.bearing+e.bearingDelta),e.pitchDelta&&s.setPitch(s.pitch+e.pitchDelta),e.rollDelta&&s.setRoll(s.roll+e.rollDelta),e.zoomDelta&&s.setZoom(s.zoom+e.zoomDelta)}handleMapControlsPan(e,s,a){e.around.distSqr(s.centerPoint)<.01||s.setLocationAtPoint(a,e.around)}cameraForBoxAndBearing(e,s,a,l,c){return Ui(e,s,a,l,c)}handleJumpToCenterZoom(e,s){e.zoom!==(void 0!==s.zoom?+s.zoom:e.zoom)&&e.setZoom(+s.zoom),void 0!==s.center&&e.setCenter(a.U.convert(s.center))}handleEaseTo(e,s){const l=e.zoom,c=e.padding,u={roll:e.roll,pitch:e.pitch,bearing:e.bearing},d={roll:void 0===s.roll?e.roll:s.roll,pitch:void 0===s.pitch?e.pitch:s.pitch,bearing:void 0===s.bearing?e.bearing:s.bearing},f=void 0!==s.zoom,_=!e.isPaddingEqual(s.padding);let y=!1;const b=f?+s.zoom:e.zoom;let S=e.centerPoint.add(s.offsetAsPoint);const P=e.screenPointToLocation(S),{center:M,zoom:C}=e.applyConstrain(a.U.convert(s.center||P),null!=b?b:l);Oi(e,M);const D=Ve(e.worldSize,P),L=Ve(e.worldSize,M).sub(D),F=a.al(C-l);return y=C!==l,{easeFunc:f=>{if(y&&e.setZoom(a.F.number(l,C,f)),a.bi(u,d)||ji({startEulerAngles:u,endEulerAngles:d,tr:e,k:f,useSlerp:u.roll!=d.roll}),_&&(e.interpolatePadding(c,s.padding,f),S=e.centerPoint.add(s.offsetAsPoint)),s.around)e.setLocationAtPoint(s.around,s.aroundPoint);else{const s=a.al(e.zoom-l),c=C>l?Math.min(2,F):Math.max(.5,F),u=Math.pow(c,1-f),d=Ne(e.worldSize,D.add(L.mult(f*u)).mult(s));e.setLocationAtPoint(e.renderWorldCopies?d.wrap():d,S)}},isZooming:y,elevationCenter:M}}handleFlyTo(e,s){const l=void 0!==s.zoom,c=e.zoom,u=e.applyConstrain(a.U.convert(s.center||s.locationAtOffset),l?+s.zoom:c),d=u.center,f=u.zoom;Oi(e,d);const _=Ve(e.worldSize,s.locationAtOffset),y=Ve(e.worldSize,d).sub(_),b=y.mag(),S=a.al(f-c);let P;if(void 0!==s.minZoom){const l=Math.min(+s.minZoom,c,f),u=e.applyConstrain(d,l).zoom;P=a.al(u-c)}return{easeFunc:(s,l,u,b)=>{e.setZoom(1===s?f:c+a.ao(l));const S=1===s?d:Ne(e.worldSize,_.add(y.mult(u)).mult(l));e.setLocationAtPoint(e.renderWorldCopies?S.wrap():S,b)},scaleOfZoom:S,targetCenter:d,scaleOfMinZoom:P,pixelPathLength:b}}}class qt{constructor(e,s,a){this.blendFunction=e,this.blendColor=s,this.mask=a}}qt.Replace=[1,0],qt.disabled=new qt(qt.Replace,a.bj.transparent,[!1,!1,!1,!1]),qt.unblended=new qt(qt.Replace,a.bj.transparent,[!0,!0,!0,!0]),qt.alphaBlended=new qt([1,771],a.bj.transparent,[!0,!0,!0,!0]);const Gi=2305;class Ht{constructor(e,s,a){this.enable=e,this.mode=s,this.frontFace=a}}Ht.disabled=new Ht(!1,1029,Gi),Ht.backCCW=new Ht(!0,1029,Gi),Ht.frontCCW=new Ht(!0,1028,Gi);class Xt{constructor(e,s,a){this.func=e,this.mask=s,this.range=a}}Xt.ReadOnly=!1,Xt.ReadWrite=!0,Xt.disabled=new Xt(519,Xt.ReadOnly,[0,1]);const Zi=7680;class Yt{constructor(e,s,a,l,c,u){this.test=e,this.ref=s,this.mask=a,this.fail=l,this.depthFail=c,this.pass=u}}Yt.disabled=new Yt({func:519,mask:0},0,0,Zi,Zi,Zi);const qi=new WeakMap;function $i(e){var s;if(qi.has(e))return qi.get(e);{const a=null===(s=e.getParameter(e.VERSION))||void 0===s?void 0:s.startsWith("WebGL 2.0");return qi.set(e,a),a}}class ei{get awaitingQuery(){return!!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;const s=e.context,l=s.gl;this._texFormat=l.RGBA,this._texType=l.UNSIGNED_BYTE;const c=new a.aQ;c.emplaceBack(-1,-1),c.emplaceBack(2,-1),c.emplaceBack(-1,2);const u=new a.aS;u.emplaceBack(0,1,2),this._fullscreenTriangle=new St(s.createVertexBuffer(c,Li.members),s.createIndexBuffer(u),a.aR.simpleSegment(0,0,c.length,u.length)),this._resultBuffer=new Uint8Array(4),s.activeTexture.set(l.TEXTURE1);const d=l.createTexture();l.bindTexture(l.TEXTURE_2D,d),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.NEAREST),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.NEAREST),l.texImage2D(l.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=s.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(d),$i(l)&&(this._pbo=l.createBuffer(),l.bindBuffer(l.PIXEL_PACK_BUFFER,this._pbo),l.bufferData(l.PIXEL_PACK_BUFFER,4,l.STREAM_READ),l.bindBuffer(l.PIXEL_PACK_BUFFER,null))}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(e,s){const a=this._updateCount;return this._readbackQueue?a>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():a>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,s),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,s=e.gl;e.activeTexture.set(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,s){const l=this._cachedRenderContext.context,c=l.gl;if(this._bindFramebuffer(),l.viewport.set([0,0,this._texWidth,this._texHeight]),l.clear({color:a.bj.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(l,c.TRIANGLES,Xt.disabled,Yt.disabled,qt.unblended,Ht.disabled,((e,s)=>({u_input:e,u_output_expected:s}))(e,s),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&$i(c)){c.bindBuffer(c.PIXEL_PACK_BUFFER,this._pbo),c.readBuffer(c.COLOR_ATTACHMENT0),c.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),c.bindBuffer(c.PIXEL_PACK_BUFFER,null);const e=c.fenceSync(c.SYNC_GPU_COMMANDS_COMPLETE,0);c.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&$i(e)){const s=e.clientWaitSync(this._readbackQueue.sync,0,0);if(s===e.WAIT_FAILED)return a.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(s===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=ei._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(e){let s=0;return s+=e[0]/256,s+=e[1]/65536,s+=e[2]/16777216,e[3]<127&&(s=-s),s/128}}const Wi=a.a3/128;function Hi(e,s){const l=void 0!==e.granularity?Math.max(e.granularity,1):1,c=l+(e.generateBorders?2:0),u=l+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),d=c+1,f=u+1,_=e.generateBorders?-1:0,y=e.generateBorders||e.extendToNorthPole?-1:0,b=l+(e.generateBorders?1:0),S=l+(e.generateBorders||e.extendToSouthPole?1:0),P=d*f,M=c*u*6,C=d*f>65536;if(C&&"16bit"===s)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const D=C||"32bit"===s,L=new Int16Array(2*P);let F=0;for(let s=y;s<=S;s++)for(let c=_;c<=b;c++){let u=c/l*a.a3;-1===c&&(u=-Wi),c===l+1&&(u=a.a3+Wi);let d=s/l*a.a3;-1===s&&(d=e.extendToNorthPole?a.bl:-Wi),s===l+1&&(d=e.extendToSouthPole?a.bm:a.a3+Wi),L[F++]=u,L[F++]=d}const B=D?new Uint32Array(M):new Uint16Array(M);let O=0;for(let e=0;e<u;e++)for(let s=0;s<c;s++){const a=s+1+e*d,l=s+(e+1)*d,c=s+1+(e+1)*d;B[O++]=s+e*d,B[O++]=l,B[O++]=a,B[O++]=a,B[O++]=l,B[O++]=c}return{vertices:L.buffer.slice(0),indices:B.buffer.slice(0),uses32bitIndices:D}}const Xi=new a.aP({fill:new a.bn(128,2),line:new a.bn(512,0),tile:new a.bn(128,32),stencil:new a.bn(128,1),circle:3});class ri{constructor(){this._tileMeshCache={},this._errorCorrectionUsable=0,this._errorMeasurementLastValue=0,this._errorCorrectionPreviousValue=0,this._errorMeasurementLastChangeTime=-1e3}get name(){return"vertical-perspective"}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return"globe"}get shaderDefine(){return"#define GLOBE"}get shaderPreludeCode(){return zi.projectionGlobe}get vertexShaderPreludeCode(){return zi.projectionMercator.vertexSource}get subdivisionGranularity(){return Xi}get useGlobeControls(){return!0}get latitudeErrorCorrectionRadians(){return this._errorCorrectionUsable}destroy(){this._errorMeasurement&&this._errorMeasurement.destroy()}updateGPUdependent(e){this._errorMeasurement||(this._errorMeasurement=new ei(e));const s=a.W(this._errorQueryLatitudeDegrees),l=2*Math.atan(Math.exp(Math.PI-s*Math.PI*2))-.5*Math.PI,c=this._errorMeasurement.updateErrorLoop(s,l),u=b();c!==this._errorMeasurementLastValue&&(this._errorCorrectionPreviousValue=this._errorCorrectionUsable,this._errorMeasurementLastValue=c,this._errorMeasurementLastChangeTime=u);const d=Math.min(Math.max((u-this._errorMeasurementLastChangeTime)/1e3/.5,0),1);this._errorCorrectionUsable=a.bo(this._errorCorrectionPreviousValue,-this._errorMeasurementLastValue,a.bp(d))}_getMeshKey(e){return`${e.granularity.toString(36)}_${e.generateBorders?"b":""}${e.extendToNorthPole?"n":""}${e.extendToSouthPole?"s":""}`}getMeshFromTileID(e,s,a,l,c){const u=("stencil"===c?Xi.stencil:Xi.tile).getGranularityForZoomLevel(s.z);return this._getMesh(e,{granularity:u,generateBorders:a,extendToNorthPole:0===s.y&&l,extendToSouthPole:s.y===(1<<s.z)-1&&l})}_getMesh(e,s){const l=this._getMeshKey(s);if(l in this._tileMeshCache)return this._tileMeshCache[l];const c=function(e,s){const l=Hi(s,"16bit"),c=a.aQ.deserialize({arrayBuffer:l.vertices,length:l.vertices.byteLength/2/2}),u=a.aS.deserialize({arrayBuffer:l.indices,length:l.indices.byteLength/2/3});return new St(e.createVertexBuffer(c,Li.members),e.createIndexBuffer(u),a.aR.simpleSegment(0,0,c.length,u.length))}(e,s);return this._tileMeshCache[l]=c,c}recalculate(e){}hasTransition(){const e=b();let s=!1;return s=s||(e-this._errorMeasurementLastChangeTime)/1e3<.7,s=s||this._errorMeasurement&&this._errorMeasurement.awaitingQuery,s}setErrorQueryLatitudeDegrees(e){this._errorQueryLatitudeDegrees=e}}const Yi=new a.t({type:new a.D(a.u.projection.type)});class si extends a.E{constructor(e){super(),this._transitionable=new a.x(Yi,void 0),this.setProjection(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new a.G(0)),this._mercatorProjection=new At,this._verticalPerspectiveProjection=new ri}get transitionState(){const e=this.properties.get("type");if("string"==typeof e&&"mercator"===e)return 0;if("string"==typeof e&&"vertical-perspective"===e)return 1;if(e instanceof a.bq){if("vertical-perspective"===e.from&&"mercator"===e.to)return 1-e.transition;if("mercator"===e.from&&"vertical-perspective"===e.to)return e.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e)}getMeshFromTileID(e,s,a,l,c){return this.currentProjection.getMeshFromTileID(e,s,a,l,c)}setProjection(e){this._transitionable.setValue("type",(null==e?void 0:e.type)||"mercator")}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e)}}function Ki(e){const s=sr(e.worldSize,e.center.lat);return 2*Math.PI*s}function Ji(e,s,l,c,u){const d=1/(1<<u),f=s/a.a3*d+c*d,_=a.bs((e/a.a3*d+l*d)*Math.PI*2+Math.PI,2*Math.PI),y=2*Math.atan(Math.exp(Math.PI-f*Math.PI*2))-.5*Math.PI,b=Math.cos(y),S=new Float64Array(3);return S[0]=Math.sin(_)*b,S[1]=Math.sin(y),S[2]=Math.cos(_)*b,S}function Qi(e){return function(e,s){const a=Math.cos(s),l=new Float64Array(3);return l[0]=Math.sin(e)*a,l[1]=Math.sin(s),l[2]=Math.cos(e)*a,l}(e.lng*Math.PI/180,e.lat*Math.PI/180)}function sr(e,s){return e/(2*Math.PI)/Math.cos(s*Math.PI/180)}function or(e){const s=Math.asin(e[1])/Math.PI*180,l=Math.sqrt(e[0]*e[0]+e[2]*e[2]);if(l>1e-6){const c=e[0]/l,u=Math.acos(e[2]/l),d=(c>0?u:-u)/Math.PI*180;return new a.U(a.V(d,-180,180),s)}return new a.U(0,s)}function lr(e){return Math.cos(e*Math.PI/180)}function cr(e,s){const l=lr(e),c=lr(s);return a.ao(c/l)}function hr(e,s){const l=e.rotate(s.bearingInRadians),c=s.zoom+cr(s.center.lat,0),u=a.bo(1/lr(s.center.lat),1/lr(Math.min(Math.abs(s.center.lat),60)),a.br(c,7,3,0,1)),d=360/Ki({worldSize:s.worldSize,center:{lat:s.center.lat}});return new a.U(s.center.lng-l.x*d*u,a.ai(s.center.lat+l.y*d,-a.aj,a.aj))}function ur(e){const s=.5*e,a=Math.sin(s),l=Math.cos(s);return Math.log(a+l)-Math.log(l-a)}function dr(e,s,l,c){const u=e.lat+l*c;if(Math.abs(l)>1){const d=(Math.sign(e.lat+l)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,f=Math.abs(e.lat+l)*Math.PI/180,_=ur(d+c*(f-d)),y=ur(d),b=ur(f);return new a.U(e.lng+s*((_-y)/(b-y)),u)}return new a.U(e.lng+s*c,u)}class gi{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,s,a,l){const c=`${e.z}_${e.x}_${e.y}_${(null==l?void 0:l.terrain)?"t":""}`,u=this._cache.get(c);if(u)return u;const d=this._cachePrevious.get(c);if(d)return this._cache.set(c,d),d;const f=this._boundingVolumeFactory(e,s,a,l);return this._cache.set(c,f),this._hadAnyChanges=!0,f}}class vi{constructor(e,s,a,l){this.min=a,this.max=l,this.points=e,this.planes=s}static fromAabb(e,s){const a=[];for(let l=0;l<8;l++)a.push([1&~l?e[0]:s[0],1==(l>>1&1)?s[1]:e[1],1==(l>>2&1)?s[2]:e[2]]);return new vi(a,[[-1,0,0,s[0]],[1,0,0,-e[0]],[0,-1,0,s[1]],[0,1,0,-e[1]],[0,0,-1,s[2]],[0,0,1,-e[2]]],e,s)}static fromCenterSizeAngles(e,s,l){const c=a.bv([],l[0],l[1],l[2]),u=a.bw([],[s[0],0,0],c),d=a.bw([],[0,s[1],0],c),f=a.bw([],[0,0,s[2]],c),_=[...e],y=[...e];for(let s=0;s<8;s++)for(let a=0;a<3;a++){const l=e[a]+u[a]*(1&~s?-1:1)+d[a]*(1==(s>>1&1)?1:-1)+f[a]*(1==(s>>2&1)?1:-1);_[a]=Math.min(_[a],l),y[a]=Math.max(y[a],l)}const b=[];for(let s=0;s<8;s++){const l=[...e];a.aW(l,l,a.aV([],u,1&~s?-1:1)),a.aW(l,l,a.aV([],d,1==(s>>1&1)?1:-1)),a.aW(l,l,a.aV([],f,1==(s>>2&1)?1:-1)),b.push(l)}return new vi(b,[[...u,-a.a$(u,b[0])],[...d,-a.a$(d,b[0])],[...f,-a.a$(f,b[0])],[-u[0],-u[1],-u[2],-a.a$(u,b[7])],[-d[0],-d[1],-d[2],-a.a$(d,b[7])],[-f[0],-f[1],-f[2],-a.a$(f,b[7])]],_,y)}intersectsFrustum(e){let s=!0;const a=this.points.length,l=this.planes.length,c=e.planes.length,u=e.points.length;for(let l=0;l<c;l++){const c=e.planes[l];let u=0;for(let e=0;e<a;e++){const s=this.points[e];c[0]*s[0]+c[1]*s[1]+c[2]*s[2]+c[3]>=0&&u++}if(0===u)return 0;u<a&&(s=!1)}if(s)return 2;for(let s=0;s<l;s++){const a=this.planes[s];let l=0;for(let s=0;s<u;s++){const c=e.points[s];a[0]*c[0]+a[1]*c[1]+a[2]*c[2]+a[3]>=0&&l++}if(0===l)return 0}return 1}intersectsPlane(e){const s=this.points.length;let a=0;for(let l=0;l<s;l++){const s=this.points[l];e[0]*s[0]+e[1]*s[1]+e[2]*s[2]+e[3]>=0&&a++}return a===s?2:0===a?0:1}}function fr(e,s,a){const l=e-s;return l<0?-l:Math.max(0,l-a)}function mr(e,s,a,l,c){const u=e-a;let d;return d=u<0?Math.min(-u,1+u-c):u>1?Math.min(Math.max(u-c,0),1-u):0,Math.max(d,fr(s,l,c))}class yi{constructor(){this._boundingVolumeCache=new gi(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,s,a,l){const c=1<<a.z,u=1/c,d=a.x/c,f=a.y/c;let _=2;return _=Math.min(_,mr(e,s,d,f,u)),_=Math.min(_,mr(e,s,d+.5,-f-u,u)),_=Math.min(_,mr(e,s,d+.5,2-f-u,u)),_}getWrap(e,s,a){const l=1<<s.z,c=1/l,u=s.x/l,d=fr(e.x,u,c),f=fr(e.x,u-1,c),_=fr(e.x,u+1,c),y=Math.min(d,f,_);return y===_?1:y===f?-1:0}allowVariableZoom(e,s){return He(e,s)>4}allowWorldCopies(){return!1}getTileBoundingVolume(e,s,a,l){return this._boundingVolumeCache.getTileBoundingVolume(e,s,a,l)}_computeTileBoundingVolume(e,s,l,c){var u,d;let f=0,_=0;if(null==c?void 0:c.terrain){const y=new a.a0(e.z,s,e.z,e.x,e.y),b=c.terrain.getMinMaxElevation(y);f=null!==(u=b.minElevation)&&void 0!==u?u:Math.min(0,l),_=null!==(d=b.maxElevation)&&void 0!==d?d:Math.max(0,l)}if(f/=a.by,_/=a.by,f+=1,_+=1,e.z<=0)return vi.fromAabb([-_,-_,-_],[_,_,_]);if(1===e.z)return vi.fromAabb([0===e.x?-_:0,0===e.y?0:-_,-_],[0===e.x?0:_,0===e.y?_:0,_]);{const s=[Ji(0,0,e.x,e.y,e.z),Ji(a.a3,0,e.x,e.y,e.z),Ji(a.a3,a.a3,e.x,e.y,e.z),Ji(0,a.a3,e.x,e.y,e.z)],l=[];for(const e of s)l.push(a.aV([],e,_));if(_!==f)for(const e of s)l.push(a.aV([],e,f));0===e.y&&l.push([0,1,0]),e.y===(1<<e.z)-1&&l.push([0,-1,0]);const c=[1,1,1],u=[-1,-1,-1];for(const e of l)for(let s=0;s<3;s++)c[s]=Math.min(c[s],e[s]),u[s]=Math.max(u[s],e[s]);const d=Ji(a.a3/2,a.a3/2,e.x,e.y,e.z),y=a.a_([],[0,1,0],d);a.aZ(y,y);const b=a.a_([],d,y);a.aZ(b,b);const S=a.a_([],s[2],s[1]);a.aZ(S,S);const P=a.a_([],s[0],s[3]);a.aZ(P,P),l.push(a.aV([],d,_)),e.y>=(1<<e.z)/2&&l.push(a.aV([],Ji(a.a3/2,0,e.x,e.y,e.z),_)),e.y<(1<<e.z)/2&&l.push(a.aV([],Ji(a.a3/2,a.a3,e.x,e.y,e.z),_));const M=_r(d,l),C=_r(b,l),D=[-d[0],-d[1],-d[2],M.max],L=[d[0],d[1],d[2],-M.min],F=[-b[0],-b[1],-b[2],C.max],B=[b[0],b[1],b[2],-C.min],O=[...S,0],V=[...P,0],N=[];return 0===e.y?N.push(a.bx(V,O,D),a.bx(V,O,L)):N.push(a.bx(F,O,D),a.bx(F,O,L),a.bx(F,V,D),a.bx(F,V,L)),e.y===(1<<e.z)-1?N.push(a.bx(V,O,D),a.bx(V,O,L)):N.push(a.bx(B,O,D),a.bx(B,O,L),a.bx(B,V,D),a.bx(B,V,L)),new vi(N,[D,L,F,B,O,V],c,u)}}}function _r(e,s){let l=1/0,c=-1/0;for(const u of s){const s=a.a$(e,u);l=Math.min(l,s),c=Math.max(c,s)}return{min:l,max:c}}class Ti{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,s,a){return this._helper.interpolatePadding(e,s,a)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,s){this._helper.resize(e,s)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,s){this._helper.overrideNearFarZ(e,s)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e){}constructor(e){this._cachedClippingPlane=a.bz(),this._projectionMatrix=a.bd(),this._globeViewProjMatrix32f=a.bc(),this._globeViewProjMatrixNoCorrection=a.bd(),this._globeViewProjMatrixNoCorrectionInverted=a.bd(),this._globeProjMatrixInverted=a.bd(),this._cameraPosition=a.bt(),this._globeLatitudeErrorCorrectionRadians=0,this.defaultConstrain=(e,s)=>{const l=a.ai(e.lat,-a.aj,a.aj),c=a.ai(+s,this.minZoom+cr(0,l),this.maxZoom);return{center:new a.U(e.lng,l),zoom:c}},this.applyConstrain=(e,s)=>this._helper.applyConstrain(e,s),this._helper=new Bt({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,s)=>this.defaultConstrain(e,s)},e),this._coveringTilesDetailsProvider=new yi}clone(){const e=new Ti;return e.apply(this),e}apply(e,s){this._globeLatitudeErrorCorrectionRadians=s||0,this._helper.apply(e)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=a.bt();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){const{overscaledTileID:s,applyGlobeMatrix:a}=e,l=this._helper.getMercatorTileCoordinates(s);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:l,clippingPlane:this._cachedClippingPlane,projectionTransition:a?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const s=this.pitchInRadians,l=this.cameraToCenterDistance/e,c=Math.sin(s)*l,u=Math.cos(s)*l+1,d=1/Math.sqrt(c*c+u*u)*1;let f=-c,_=u;const y=Math.sqrt(f*f+_*_);f/=y,_/=y;const b=[0,f,_];a.bA(b,b,[0,0,0],-this.bearingInRadians),a.bB(b,b,[0,0,0],-1*this.center.lat*Math.PI/180),a.bC(b,b,[0,0,0],this.center.lng*Math.PI/180);const S=1/a.b1(b);return a.aV(b,b,S),[...b,-d*S]}isLocationOccluded(e){return!this.isSurfacePointVisible(Qi(e))}transformLightDirection(e){const s=this._helper._center.lng*Math.PI/180,l=this._helper._center.lat*Math.PI/180,c=Math.cos(l),u=[Math.sin(s)*c,Math.sin(l),Math.cos(s)*c],d=[u[2],0,-u[0]],f=[0,0,0];a.a_(f,d,u),a.aZ(d,d),a.aZ(f,f);const _=[0,0,0];return a.aZ(_,[d[0]*e[0]+f[0]*e[1]+u[0]*e[2],d[1]*e[0]+f[1]*e[1]+u[1]*e[2],d[2]*e[0]+f[2]*e[1]+u[2]*e[2]]),_}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,s,l){const c=function(e,s,l){const c=1/(1<<l.z);return new a.a5(e/a.a3*c+l.x*c,s/a.a3*c+l.y*c)}(e,s,l.canonical),u=(d=c.y,[a.bs(c.x*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-d*Math.PI*2))-.5*Math.PI]);var d;return this.getCircleRadiusCorrection()/Math.cos(u[1])}projectTileCoordinates(e,s,l,c){const u=l.canonical,d=Ji(e,s,u.x,u.y,u.z),f=1+(c?c(e,s):0)/a.by,_=[d[0]*f,d[1]*f,d[2]*f,1];a.aB(_,_,this._globeViewProjMatrixNoCorrection);const y=this._cachedClippingPlane,b=y[0]*d[0]+y[1]*d[1]+y[2]*d[2]+y[3]<0;return{point:new a.P(_[0]/_[3],_[1]/_[3]),signedDistanceFromCamera:_[3],isOccluded:b}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;const e=sr(this.worldSize,this.center.lat),s=a.be(),l=a.be();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*e),a.b8(s,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);const c=this.centerOffset;s[8]=2*-c.x/this._helper._width,s[9]=2*c.y/this._helper._height,this._projectionMatrix=a.b9(s),this._globeProjMatrixInverted=a.be(),a.av(this._globeProjMatrixInverted,s),a.N(s,s,[0,0,-this.cameraToCenterDistance]),a.ba(s,s,this.rollInRadians),a.bb(s,s,-this.pitchInRadians),a.ba(s,s,this.bearingInRadians),a.N(s,s,[0,0,-e]);const u=a.bt();u[0]=e,u[1]=e,u[2]=e,a.bb(l,s,this.center.lat*Math.PI/180),a.bD(l,l,-this.center.lng*Math.PI/180),a.O(l,l,u),this._globeViewProjMatrixNoCorrection=l,a.bb(s,s,this.center.lat*Math.PI/180-this._globeLatitudeErrorCorrectionRadians),a.bD(s,s,-this.center.lng*Math.PI/180),a.O(s,s,u),this._globeViewProjMatrix32f=new Float32Array(s),this._globeViewProjMatrixNoCorrectionInverted=a.be(),a.av(this._globeViewProjMatrixNoCorrectionInverted,l);const d=a.bt();this._cameraPosition=a.bt(),this._cameraPosition[2]=this.cameraToCenterDistance/e,a.bA(this._cameraPosition,this._cameraPosition,d,-this.rollInRadians),a.bB(this._cameraPosition,this._cameraPosition,d,this.pitchInRadians),a.bA(this._cameraPosition,this._cameraPosition,d,-this.bearingInRadians),a.aW(this._cameraPosition,this._cameraPosition,[0,0,1]),a.bB(this._cameraPosition,this._cameraPosition,d,-this.center.lat*Math.PI/180),a.bC(this._cameraPosition,this._cameraPosition,d,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(e);const f=a.b9(this._globeViewProjMatrixNoCorrectionInverted);a.O(f,f,[1,1,-1]),this._cachedFrustum=Ut.fromInvProjectionMatrix(f,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(e){a.w("calculateFogMatrix is not supported on globe projection.");const s=a.be();return a.am(s),s}getVisibleUnwrappedCoordinates(e){return[new a.b6(0,e)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){e&&a.w("terrain is not fully supported on vertical perspective projection."),this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,s){if(!this._globeViewProjMatrixNoCorrection)return 1;const l=Qi(e);a.aV(l,l,1+s/a.by);const c=a.bz();return a.aB(c,[l[0],l[1],l[2],1],this._globeViewProjMatrixNoCorrection),c[2]/c[3]}populateCache(e){}getBounds(){const e=.5*this.width,s=.5*this.height,l=[new a.P(0,0),new a.P(e,0),new a.P(this.width,0),new a.P(this.width,s),new a.P(this.width,this.height),new a.P(e,this.height),new a.P(0,this.height),new a.P(0,s)],c=[];for(const e of l)c.push(this.unprojectScreenPoint(e));let u=0,d=0,f=0,_=0;const y=this.center;for(const e of c){const s=a.bE(y.lng,e.lng),l=a.bE(y.lat,e.lat);s<d&&(d=s),s>u&&(u=s),l<_&&(_=l),l>f&&(f=l)}const b=[y.lng+d,y.lat+_,y.lng+u,y.lat+f];return this.isSurfacePointOnScreen([0,1,0])&&(b[3]=90,b[0]=-180,b[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(b[1]=-90,b[0]=-180,b[2]=180),new $(b)}calculateCenterFromCameraLngLatAlt(e,s,a,l){return this._helper.calculateCenterFromCameraLngLatAlt(e,s,a,l)}setLocationAtPoint(e,s){const l=Qi(this.unprojectScreenPoint(s)),c=Qi(e),u=a.bt();a.bF(u);const d=a.bt();a.bC(d,l,u,-this.center.lng*Math.PI/180),a.bB(d,d,u,this.center.lat*Math.PI/180);const f=c[0]*c[0]+c[2]*c[2],_=d[0]*d[0];if(f<_)return;const y=Math.sqrt(f-_),b=-y,S=a.bG(c[0],c[2],d[0],y),P=a.bG(c[0],c[2],d[0],b),M=a.bt();a.bC(M,c,u,-S);const C=a.bG(M[1],M[2],d[1],d[2]),D=a.bt();a.bC(D,c,u,-P);const L=a.bG(D[1],D[2],d[1],d[2]),F=.5*Math.PI,B=C>=-F&&C<=F,O=L>=-F&&L<=F;let V,N;if(B&&O){const e=this.center.lng*Math.PI/180,s=this.center.lat*Math.PI/180;a.bH(S,e)+a.bH(C,s)<a.bH(P,e)+a.bH(L,s)?(V=S,N=C):(V=P,N=L)}else if(B)V=S,N=C;else{if(!O)return;V=P,N=L}const j=V/Math.PI*180,G=N/Math.PI*180,Z=this.center.lat;this.setCenter(new a.U(j,a.ai(G,-90,90))),this.setZoom(this.zoom+cr(Z,this.center.lat))}locationToScreenPoint(e,s){const l=Qi(e);if(s){const c=s.getElevationForLngLatZoom(e,this._helper._tileZoom);a.aV(l,l,1+c/a.by)}return this._projectSurfacePointToScreen(l)}_projectSurfacePointToScreen(e){const s=a.bz();return a.aB(s,[...e,1],this._globeViewProjMatrixNoCorrection),s[0]/=s[3],s[1]/=s[3],new a.P((.5*s[0]+.5)*this.width,(.5*-s[1]+.5)*this.height)}screenPointToMercatorCoordinate(e,s){if(s){const a=s.pointCoordinate(e);if(a)return a}return a.a5.fromLngLat(this.unprojectScreenPoint(e))}screenPointToLocation(e,s){var a;return null===(a=this.screenPointToMercatorCoordinate(e,s))||void 0===a?void 0:a.toLngLat()}isPointOnMapSurface(e,s){const a=this._cameraPosition,l=this.getRayDirectionFromPixel(e);return!!this.rayPlanetIntersection(a,l)}getRayDirectionFromPixel(e){const s=a.bz();s[0]=e.x/this.width*2-1,s[1]=-1*(e.y/this.height*2-1),s[2]=1,s[3]=1,a.aB(s,s,this._globeViewProjMatrixNoCorrectionInverted),s[0]/=s[3],s[1]/=s[3],s[2]/=s[3];const l=a.bt();l[0]=s[0]-this._cameraPosition[0],l[1]=s[1]-this._cameraPosition[1],l[2]=s[2]-this._cameraPosition[2];const c=a.bt();return a.aZ(c,l),c}isSurfacePointVisible(e){const s=this._cachedClippingPlane;return s[0]*e[0]+s[1]*e[1]+s[2]*e[2]+s[3]>=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;const s=a.bz();return a.aB(s,[...e,1],this._globeViewProjMatrixNoCorrection),s[0]/=s[3],s[1]/=s[3],s[2]/=s[3],s[0]>-1&&s[0]<1&&s[1]>-1&&s[1]<1&&s[2]>-1&&s[2]<1}rayPlanetIntersection(e,s){const l=a.a$(e,s),c=a.bt(),u=a.bt();a.aV(u,s,l),a.aY(c,e,u);const d=1-a.a$(c,c);if(d<0)return null;const f=a.a$(e,e)-1,_=-l+(l<0?1:-1)*Math.sqrt(d),y=f/_,b=_;return{tMin:Math.min(y,b),tMax:Math.max(y,b)}}unprojectScreenPoint(e){const s=this._cameraPosition,l=this.getRayDirectionFromPixel(e),c=this.rayPlanetIntersection(s,l);if(c){const e=a.bt();a.aW(e,s,[l[0]*c.tMin,l[1]*c.tMin,l[2]*c.tMin]);const u=a.bt();return a.aZ(u,e),or(u)}const u=this._cachedClippingPlane,d=u[0]*l[0]+u[1]*l[1]+u[2]*l[2],f=-a.b5(u,s)/d,_=a.bt();if(f>0)a.aW(_,s,[l[0]*f,l[1]*f,l[2]*f]);else{const e=a.bt();a.aW(e,s,[2*l[0],2*l[1],2*l[2]]);const c=a.b5(this._cachedClippingPlane,e);a.aY(_,e,[this._cachedClippingPlane[0]*c,this._cachedClippingPlane[1]*c,this._cachedClippingPlane[2]*c])}const y=function(e){const s=a.bt();return s[0]=e[0]*-e[3],s[1]=e[1]*-e[3],s[2]=e[2]*-e[3],{center:s,radius:Math.sqrt(1-e[3]*e[3])}}(u);return or(function(e,s,l){const c=a.bt();a.aY(c,l,e);const u=a.bt();return a.bu(u,e,c,s/a.b3(c)),u}(y.center,y.radius,_))}getMatrixForModel(e,s){const l=a.U.convert(e),c=1/a.by,u=a.bd();return a.bD(u,u,l.lng/180*Math.PI),a.bb(u,u,-l.lat/180*Math.PI),a.N(u,u,[0,0,1+s/a.by]),a.bb(u,u,.5*Math.PI),a.O(u,u,[c,c,c]),u}getProjectionDataForCustomLayer(e=!0){const s=this.getProjectionData({overscaledTileID:new a.a0(0,0,0,0,0),applyGlobeMatrix:e});return s.tileMercatorCoords=[0,0,1,1],s}getFastPathSimpleProjectionMatrix(e){}}class Pi{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,s,a){return this._helper.interpolatePadding(e,s,a)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,s,a=!0){this._helper.resize(e,s,a)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,s){this._helper.overrideNearFarZ(e,s)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,s){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=s,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(e){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this.defaultConstrain=(e,s)=>this.currentTransform.defaultConstrain(e,s),this.applyConstrain=(e,s)=>this._helper.applyConstrain(e,s),this._helper=new Bt({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,s)=>this.defaultConstrain(e,s)},e),this._globeness=1,this._mercatorTransform=new Nt,this._verticalPerspectiveTransform=new Ti}clone(){const e=new Pi;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this),e}apply(e){this._helper.apply(e),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const s=this._mercatorTransform.getProjectionData(e),a=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?a.mainMatrix:s.mainMatrix,clippingPlane:a.clippingPlane,tileMercatorCoords:a.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:s.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return a.bo(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return a.bo(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,s,l){const c=this._mercatorTransform.getPitchedTextCorrection(e,s,l),u=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,s,l);return a.bo(c,u,this._globeness)}projectTileCoordinates(e,s,a,l){return this.currentTransform.projectTileCoordinates(e,s,a,l)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,s){return this.currentTransform.lngLatToCameraDepth(e,s)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(e,s,a,l){return this._helper.calculateCenterFromCameraLngLatAlt(e,s,a,l)}setLocationAtPoint(e,s){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,s),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(e,s),this.apply(this._verticalPerspectiveTransform)}locationToScreenPoint(e,s){return this.currentTransform.locationToScreenPoint(e,s)}screenPointToMercatorCoordinate(e,s){return this.currentTransform.screenPointToMercatorCoordinate(e,s)}screenPointToLocation(e,s){return this.currentTransform.screenPointToLocation(e,s)}isPointOnMapSurface(e,s){return this.currentTransform.isPointOnMapSurface(e,s)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,s){return this.currentTransform.getMatrixForModel(e,s)}getProjectionDataForCustomLayer(e=!0){const s=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return s;const a=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return a.fallbackMatrix=s.mainMatrix,a}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class Mi{get useGlobeControls(){return!0}handlePanInertia(e,s){const l=hr(e,s);return Math.abs(l.lng-s.center.lng)>180&&(l.lng=s.center.lng+179.5*Math.sign(l.lng-s.center.lng)),{easingCenter:l,easingOffset:new a.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,s){const l=e.around,c=s.screenPointToLocation(l);e.bearingDelta&&s.setBearing(s.bearing+e.bearingDelta),e.pitchDelta&&s.setPitch(s.pitch+e.pitchDelta),e.rollDelta&&s.setRoll(s.roll+e.rollDelta);const u=s.zoom;e.zoomDelta&&s.setZoom(s.zoom+e.zoomDelta);const d=s.zoom-u;if(0===d)return;const f=a.bE(s.center.lng,c.lng),_=f/(Math.abs(f/180)+1),y=a.bE(s.center.lat,c.lat),b=s.getRayDirectionFromPixel(l),S=s.cameraPosition,P=-1*a.a$(S,b),M=a.bt();a.aW(M,S,[b[0]*P,b[1]*P,b[2]*P]);const C=a.b1(M)-1,D=Math.exp(.5*-Math.max(C-.3,0)),L=sr(s.worldSize,s.center.lat)/Math.min(s.width,s.height),F=a.br(L,.9,.5,1,.25),B=(1-a.al(-d))*Math.min(D,F),O=s.center.lat,V=s.zoom,N=new a.U(s.center.lng+_*B,a.ai(s.center.lat+y*B,-a.aj,a.aj));s.setLocationAtPoint(c,l);const j=s.center,G=a.br(Math.abs(f),45,85,0,1),Z=a.br(L,.75,.35,0,1),q=Math.pow(Math.max(G,Z),.25),W=a.bE(j.lng,N.lng),J=a.bE(j.lat,N.lat);s.setCenter(new a.U(j.lng+W*q,j.lat+J*q).wrap()),s.setZoom(V+cr(O,s.center.lat))}handleMapControlsPan(e,s,a){if(!e.panDelta)return;const l=s.center.lat,c=s.zoom;s.setCenter(hr(e.panDelta,s).wrap()),s.setZoom(c+cr(l,s.center.lat))}cameraForBoxAndBearing(e,s,l,c,u){const d=Ui(e,s,l,c,u),f=s.left/u.width*2-1,_=(u.width-s.right)/u.width*2-1,y=s.top/u.height*-2+1,b=(u.height-s.bottom)/u.height*-2+1,S=a.bE(l.getWest(),l.getEast())<0,P=S?l.getEast():l.getWest(),M=S?l.getWest():l.getEast(),C=Math.max(l.getNorth(),l.getSouth()),D=Math.min(l.getNorth(),l.getSouth()),L=P+.5*a.bE(P,M),F=C+.5*a.bE(C,D),B=u.clone();B.setCenter(d.center),B.setBearing(d.bearing),B.setPitch(0),B.setRoll(0),B.setZoom(d.zoom);const O=B.modelViewProjectionMatrix,V=[Qi(l.getNorthWest()),Qi(l.getNorthEast()),Qi(l.getSouthWest()),Qi(l.getSouthEast()),Qi(new a.U(M,F)),Qi(new a.U(P,F)),Qi(new a.U(L,C)),Qi(new a.U(L,D))],N=Qi(d.center);let j=Number.POSITIVE_INFINITY;for(const e of V)f<0&&(j=Mi.getLesserNonNegativeNonNull(j,Mi.solveVectorScale(e,N,O,"x",f))),_>0&&(j=Mi.getLesserNonNegativeNonNull(j,Mi.solveVectorScale(e,N,O,"x",_))),y>0&&(j=Mi.getLesserNonNegativeNonNull(j,Mi.solveVectorScale(e,N,O,"y",y))),b<0&&(j=Mi.getLesserNonNegativeNonNull(j,Mi.solveVectorScale(e,N,O,"y",b)));if(Number.isFinite(j)&&0!==j)return d.zoom=B.zoom+a.ao(j),d;Ni()}handleJumpToCenterZoom(e,s){const l=e.center.lat,c=e.applyConstrain(s.center?a.U.convert(s.center):e.center,e.zoom).center;e.setCenter(c.wrap());const u=void 0!==s.zoom?+s.zoom:e.zoom+cr(l,c.lat);e.zoom!==u&&e.setZoom(u)}handleEaseTo(e,s){const l=e.zoom,c=e.center,u=e.padding,d={roll:e.roll,pitch:e.pitch,bearing:e.bearing},f={roll:void 0===s.roll?e.roll:s.roll,pitch:void 0===s.pitch?e.pitch:s.pitch,bearing:void 0===s.bearing?e.bearing:s.bearing},_=void 0!==s.zoom,y=!e.isPaddingEqual(s.padding);let b=!1;const S=s.center?a.U.convert(s.center):c,P=e.applyConstrain(S,l).center;Oi(e,P);const M=e.clone();M.setCenter(P),M.setZoom(_?+s.zoom:l+cr(c.lat,S.lat)),M.setBearing(s.bearing);const C=new a.P(a.ai(e.centerPoint.x+s.offsetAsPoint.x,0,e.width),a.ai(e.centerPoint.y+s.offsetAsPoint.y,0,e.height));M.setLocationAtPoint(P,C);const D=(s.offset&&s.offsetAsPoint.mag())>0?M.center:P,L=_?+s.zoom:l+cr(c.lat,D.lat),F=l+cr(c.lat,0),B=L+cr(D.lat,0),O=a.bE(c.lng,D.lng),V=a.bE(c.lat,D.lat),N=a.al(B-F);return b=L!==l,{easeFunc:l=>{if(a.bi(d,f)||ji({startEulerAngles:d,endEulerAngles:f,tr:e,k:l,useSlerp:d.roll!=f.roll}),y&&e.interpolatePadding(u,s.padding,l),s.around)a.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(s.around,s.aroundPoint);else{const s=B>F?Math.min(2,N):Math.max(.5,N),a=Math.pow(s,1-l),u=dr(c,O,V,l*a);e.setCenter(u.wrap())}if(b){const s=a.F.number(F,B,l)+cr(0,e.center.lat);e.setZoom(s)}},isZooming:b,elevationCenter:D}}handleFlyTo(e,s){const l=void 0!==s.zoom,c=e.center,u=e.zoom,d=e.padding,f=!e.isPaddingEqual(s.padding),_=e.applyConstrain(a.U.convert(s.center||s.locationAtOffset),u).center,y=l?+s.zoom:e.zoom+cr(e.center.lat,_.lat),b=e.clone();b.setCenter(_),b.setZoom(y),b.setBearing(s.bearing);const S=new a.P(a.ai(e.centerPoint.x+s.offsetAsPoint.x,0,e.width),a.ai(e.centerPoint.y+s.offsetAsPoint.y,0,e.height));b.setLocationAtPoint(_,S);const P=b.center;Oi(e,P);const M=function(e,s,l){const c=Qi(s),u=Qi(l),d=a.a$(c,u),f=Math.acos(d),_=Ki(e);return f/(2*Math.PI)*_}(e,c,P),C=u+cr(c.lat,0),D=y+cr(P.lat,0),L=a.al(D-C);let F;if("number"==typeof s.minZoom){const l=+s.minZoom+cr(P.lat,0),c=Math.min(l,C,D)+cr(0,P.lat),u=e.applyConstrain(P,c).zoom+cr(P.lat,0);F=a.al(u-C)}const B=a.bE(c.lng,P.lng),O=a.bE(c.lat,P.lat);return{easeFunc:(l,u,_,b)=>{const S=dr(c,B,O,_);f&&e.interpolatePadding(d,s.padding,l);const M=1===l?P:S;e.setCenter(M.wrap());const D=C+a.ao(u);e.setZoom(1===l?y:D+cr(0,M.lat))},scaleOfZoom:L,targetCenter:P,scaleOfMinZoom:F,pixelPathLength:M}}static solveVectorScale(e,s,a,l,c){const u="x"===l?[a[0],a[4],a[8],a[12]]:[a[1],a[5],a[9],a[13]],d=[a[3],a[7],a[11],a[15]],f=e[0]*u[0]+e[1]*u[1]+e[2]*u[2],_=e[0]*d[0]+e[1]*d[1]+e[2]*d[2],y=s[0]*u[0]+s[1]*u[1]+s[2]*u[2],b=s[0]*d[0]+s[1]*d[1]+s[2]*d[2];return y+c*_===f+c*b||d[3]*(f-y)+u[3]*(b-_)+f*b==y*_?null:(y+u[3]-c*b-c*d[3])/(y-f-c*b+c*_)}static getLesserNonNegativeNonNull(e,s){return null!==s&&s>=0&&s<e?s:e}}class Ci{constructor(e){this._globe=e,this._mercatorCameraHelper=new Wt,this._verticalPerspectiveCameraHelper=new Mi}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(e,s){return this.currentHelper.handlePanInertia(e,s)}handleMapControlsRollPitchBearingZoom(e,s){return this.currentHelper.handleMapControlsRollPitchBearingZoom(e,s)}handleMapControlsPan(e,s,a){this.currentHelper.handleMapControlsPan(e,s,a)}cameraForBoxAndBearing(e,s,a,l,c){return this.currentHelper.cameraForBoxAndBearing(e,s,a,l,c)}handleJumpToCenterZoom(e,s){this.currentHelper.handleJumpToCenterZoom(e,s)}handleEaseTo(e,s){return this.currentHelper.handleEaseTo(e,s)}handleFlyTo(e,s){return this.currentHelper.handleFlyTo(e,s)}}const gr=(e,s)=>a.z(e,s&&s.filter((e=>"source.canvas"!==e.identifier))),xr=a.bI();class Si extends a.E{constructor(e,s={}){var l,c;super(),this._rtlPluginLoaded=()=>{for(const e in this.tileManagers){const s=this.tileManagers[e].getSource().type;"vector"!==s&&"geojson"!==s||this.tileManagers[e].reload()}},this.map=e,this.dispatcher=new U(ce(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",((e,s)=>this.getGlyphs(e,s))),this.dispatcher.registerMessageHandler("GI",((e,s)=>this.getImages(e,s))),this.dispatcher.registerMessageHandler("GDA",((e,s)=>this.getDashes(e,s))),this.imageManager=new w,this.imageManager.setEventedParent(this);const u=(null===(l=e._container)||void 0===l?void 0:l.lang)||"undefined"!=typeof document&&(null===(c=document.documentElement)||void 0===c?void 0:c.lang)||void 0;this.glyphManager=new I(e._requestManager,s.localIdeographFontFamily,u),this.lineAtlas=new A(256,512),this.crossTileSymbolIndex=new Mt,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",a.bJ()),ke().on(Ce,this._rtlPluginLoaded),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const s=this.tileManagers[e.sourceId];if(!s)return;const a=s.getSource();if(a&&a.vectorLayerIds)for(const e in this._layers){const s=this._layers[e];s.source===a.id&&this._validateLayer(s)}}))}_setInitialValues(){var e;this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new a.bK,this._availableImages=[],this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this.crossTileSymbolIndex=new((null===(e=this.crossTileSymbolIndex)||void 0===e?void 0:e.constructor)||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(e,s){var l,c,u;this._checkLoaded();const d=null===s?null!==(u=null===(c=null===(l=this.stylesheet.state)||void 0===l?void 0:l[e])||void 0===c?void 0:c.default)&&void 0!==u?u:null:s;if(a.bL(d,this._globalState[e]))return this;this._globalState[e]=d,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();const s=[];for(const l in e)!a.bL(this._globalState[l],e[l].default)&&(s.push(l),this._globalState[l]=e[l].default);this._applyGlobalStateChanges(s)}_applyGlobalStateChanges(e){if(0===e.length)return;const s=new Set,a={};for(const l of e){a[l]=this._globalState[l];for(const e in this._layers){const a=this._layers[e],c=a.getLayoutAffectingGlobalStateRefs(),u=a.getPaintAffectingGlobalStateRefs();if(c.has(l)&&s.add(a.source),u.has(l))for(const{name:e,value:s}of u.get(l))this._updatePaintProperty(a,e,s)}}this.dispatcher.broadcast("UGS",a);for(const e in this.tileManagers)s.has(e)&&(this._reloadSource(e),this._changed=!0)}loadURL(e,s={},l){this.fire(new a.l("dataloading",{dataType:"style"})),s.validate="boolean"!=typeof s.validate||s.validate;const c=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const u=this._loadStyleRequest;a.j(c,this._loadStyleRequest).then((e=>{this._loadStyleRequest=null,this._load(e.data,s,l)})).catch((e=>{this._loadStyleRequest=null,e&&!u.signal.aborted&&this.fire(new a.k(e))}))}loadJSON(e,s={},l){this.fire(new a.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,_.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,s.validate=!1!==s.validate,this._load(e,s,l)})).catch((()=>{}))}loadEmpty(){this.fire(new a.l("dataloading",{dataType:"style"})),this._load(xr,{validate:!1})}_load(e,s,l){var c,u;let d=s.transformStyle?s.transformStyle(l,e):e;if(!s.validate||!gr(this,a.B(d))){d=Object.assign({},d),this._loaded=!0,this.stylesheet=d;for(const e in d.sources)this.addSource(e,d.sources[e],{validate:!1});d.sprite?this._loadSprite(d.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(d.glyphs),this._createLayers(),this.light=new R(this.stylesheet.light),this._setProjectionInternal((null===(c=this.stylesheet.projection)||void 0===c?void 0:c.type)||"mercator"),this.sky=new z(this.stylesheet.sky),this.map.setTerrain(null!==(u=this.stylesheet.terrain)&&void 0!==u?u:null),this.fire(new a.l("data",{dataType:"style"})),this.fire(new a.l("style.load"))}}_createLayers(){var e,s,l;const c=a.bM(this.stylesheet.layers);this.setGlobalState(null!==(e=this.stylesheet.state)&&void 0!==e?e:null),this.dispatcher.broadcast("SL",c),this._order=c.map((e=>e.id)),this._layers={},this._serializedLayers=null;for(const e of c){const c=a.bN(e,this._globalState);if(c.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=c,a.bO(c)&&this.tileManagers[c.source]){const a=null!==(l=null===(s=e.paint)||void 0===s?void 0:s["raster-fade-duration"])&&void 0!==l?l:c.paint.get("raster-fade-duration");this.tileManagers[c.source].setRasterFadeDuration(a)}}}_loadSprite(e,s=!1,l=void 0){let c;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(e,s,l,c){return a._(this,void 0,void 0,(function*(){const u=B(e),d=l>1?"@2x":"",f={},y={};for(const{id:e,url:l}of u){const u=s.transformRequest(O(l,d,".json"),"SpriteJSON");f[e]=a.j(u,c);const _=s.transformRequest(O(l,d,".png"),"SpriteImage");y[e]=F.getImage(_,c)}return yield Promise.all([...Object.values(f),...Object.values(y)]),function(e,s){return a._(this,void 0,void 0,(function*(){const a={};for(const l in e){a[l]={};const c=_.getImageCanvasContext((yield s[l]).data),u=(yield e[l]).data;for(const e in u){const{width:s,height:d,x:f,y:_,sdf:y,pixelRatio:b,stretchX:S,stretchY:P,content:M,textFitWidth:C,textFitHeight:D}=u[e];a[l][e]={data:null,pixelRatio:b,sdf:y,stretchX:S,stretchY:P,content:M,textFitWidth:C,textFitHeight:D,spriteData:{width:s,height:d,x:f,y:_,context:c}}}}return a}))}(f,y)}))}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((e=>{if(this._spriteRequest=null,e)for(const a in e){this._spritesImagesIds[a]=[];const l=this._spritesImagesIds[a]?this._spritesImagesIds[a].filter((s=>!(s in e))):[];for(const e of l)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(const l in e[a]){const c="default"===a?l:`${a}:${l}`;this._spritesImagesIds[a].push(c),c in this.imageManager.images?this.imageManager.updateImage(c,e[a][l],!1):this.imageManager.addImage(c,e[a][l]),s&&(this._changedImages[c]=!0)}}})).catch((e=>{this._spriteRequest=null,c=e,this.fire(new a.k(c))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),s&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new a.l("data",{dataType:"style"})),l&&l(c)}))}_unloadSprite(){for(const e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new a.l("data",{dataType:"style"}))}_validateLayer(e){const s=this.tileManagers[e.source];if(!s)return;const l=e.sourceLayer;if(!l)return;const c=s.getSource();("geojson"===c.type||c.vectorLayerIds&&-1===c.vectorLayerIds.indexOf(l))&&this.fire(new a.k(new Error(`Source layer "${l}" does not exist on source "${c.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const e in this.tileManagers)if(!this.tileManagers[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(e,s=!1){const l=this._serializedAllLayers();if(!e||0===e.length)return Object.values(s?a.bP(l):l);const c=[];for(const u of e)if(l[u]){const e=s?a.bP(l[u]):l[u];c.push(e)}return c}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const s=Object.keys(this._layers);for(const a of s){const s=this._layers[a];"custom"!==s.type&&(e[a]=s.serialize())}return e}hasTransitions(){var e,s,a;if(null===(e=this.light)||void 0===e?void 0:e.hasTransition())return!0;if(null===(s=this.sky)||void 0===s?void 0:s.hasTransition())return!0;if(null===(a=this.projection)||void 0===a?void 0:a.hasTransition())return!0;for(const e in this.tileManagers)if(this.tileManagers[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const s=this._changed;if(s){const s=Object.keys(this._updatedLayers),a=Object.keys(this._removedLayers);(s.length||a.length)&&this._updateWorkerLayers(s,a);for(const e in this._updatedSources){const s=this._updatedSources[e];if("reload"===s)this._reloadSource(e);else{if("clear"!==s)throw new Error(`Invalid action ${s}`);this._clearSource(e)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const s in this._updatedPaintProps)this._layers[s].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}const l={};for(const e in this.tileManagers){const s=this.tileManagers[e];l[e]=s.used,s.used=!1}for(const s of this._order){const a=this._layers[s];a.recalculate(e,this._availableImages),!a.isHidden(e.zoom)&&a.source&&(this.tileManagers[a.source].used=!0)}for(const e in l){const s=this.tileManagers[e];!!l[e]!=!!s.used&&s.fire(new a.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,s&&this.fire(new a.l("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const s in this.tileManagers)this.tileManagers[s].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,s){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:s})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,s={}){var l;this._checkLoaded();const c=this.serialize();if(e=s.transformStyle?s.transformStyle(c,e):e,(null===(l=s.validate)||void 0===l||l)&&gr(this,a.B(e)))return!1;(e=a.bP(e)).layers=a.bM(e.layers);const u=a.bQ(c,e),d=this._getOperationsToPerform(u);if(d.unimplemented.length>0)throw new Error(`Unimplemented: ${d.unimplemented.join(", ")}.`);if(0===d.operations.length)return!1;for(const e of d.operations)e();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){const s=[],a=[];for(const l of e)switch(l.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":s.push((()=>this.addLayer.apply(this,l.args)));break;case"removeLayer":s.push((()=>this.removeLayer.apply(this,l.args)));break;case"setPaintProperty":s.push((()=>this.setPaintProperty.apply(this,l.args)));break;case"setLayoutProperty":s.push((()=>this.setLayoutProperty.apply(this,l.args)));break;case"setFilter":s.push((()=>this.setFilter.apply(this,l.args)));break;case"addSource":s.push((()=>this.addSource.apply(this,l.args)));break;case"removeSource":s.push((()=>this.removeSource.apply(this,l.args)));break;case"setLayerZoomRange":s.push((()=>this.setLayerZoomRange.apply(this,l.args)));break;case"setLight":s.push((()=>this.setLight.apply(this,l.args)));break;case"setGeoJSONSourceData":s.push((()=>this.setGeoJSONSourceData.apply(this,l.args)));break;case"setGlyphs":s.push((()=>this.setGlyphs.apply(this,l.args)));break;case"setSprite":s.push((()=>this.setSprite.apply(this,l.args)));break;case"setTerrain":s.push((()=>this.map.setTerrain.apply(this,l.args)));break;case"setSky":s.push((()=>this.setSky.apply(this,l.args)));break;case"setProjection":this.setProjection.apply(this,l.args);break;case"setGlobalState":s.push((()=>this.setGlobalState.apply(this,l.args)));break;case"setTransition":s.push((()=>{}));break;default:a.push(l.command)}return{operations:s,unimplemented:a}}addImage(e,s){if(this.getImage(e))return this.fire(new a.k(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,s),this._afterImageUpdated(e)}updateImage(e,s){this.imageManager.updateImage(e,s)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new a.k(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new a.l("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,s,l={}){if(this._checkLoaded(),void 0!==this.tileManagers[e])throw new Error(`Source "${e}" already exists.`);if(!s.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(s).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(s.type)>=0&&this._validate(a.B.source,`sources.${e}`,s,null,l))return;this.map&&this.map._collectResourceTiming&&(s.collectResourceTiming=!0);const c=this.tileManagers[e]=new Ie(e,s,this.dispatcher);c.style=this,c.setEventedParent(this,(()=>({isSourceLoaded:c.loaded(),source:c.serialize(),sourceId:e}))),c.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error("There is no source with this ID");for(const s in this._layers)if(this._layers[s].source===e)return this.fire(new a.k(new Error(`Source "${e}" cannot be removed while layer "${s}" is using it.`)));const s=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],s.fire(new a.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),s.setEventedParent(null),s.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,s){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error(`There is no source with this ID=${e}`);const a=this.tileManagers[e].getSource();if("geojson"!==a.type)throw new Error(`geojsonSource.type is ${a.type}, which is !== 'geojson`);a.setData(s),this._changed=!0}getSource(e){return this.tileManagers[e]&&this.tileManagers[e].getSource()}addLayer(e,s,l={}){this._checkLoaded();const c=e.id;if(this.getLayer(c))return void this.fire(new a.k(new Error(`Layer "${c}" already exists on this map.`)));let u;if("custom"===e.type){if(gr(this,a.bR(e)))return;u=a.bN(e,this._globalState)}else{if("source"in e&&"object"==typeof e.source&&(this.addSource(c,e.source),e=a.bP(e),e=a.e(e,{source:c})),this._validate(a.B.layer,`layers.${c}`,e,{arrayIndex:-1},l))return;u=a.bN(e,this._globalState),this._validateLayer(u),u.setEventedParent(this,{layer:{id:c}})}const d=s?this._order.indexOf(s):this._order.length;if(s&&-1===d)this.fire(new a.k(new Error(`Cannot add layer "${c}" before non-existing layer "${s}".`)));else{if(this._order.splice(d,0,c),this._layerOrderChanged=!0,this._layers[c]=u,this._removedLayers[c]&&u.source&&"custom"!==u.type){const e=this._removedLayers[c];delete this._removedLayers[c],e.type!==u.type?this._updatedSources[u.source]="clear":(this._updatedSources[u.source]="reload",this.tileManagers[u.source].pause())}this._updateLayer(u),u.onAdd&&u.onAdd(this.map)}}moveLayer(e,s){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new a.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===s)return;const l=this._order.indexOf(e);this._order.splice(l,1);const c=s?this._order.indexOf(s):this._order.length;s&&-1===c?this.fire(new a.k(new Error(`Cannot move layer "${e}" before non-existing layer "${s}".`))):(this._order.splice(c,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const s=this._layers[e];if(!s)return void this.fire(new a.k(new Error(`Cannot remove non-existing layer "${e}".`)));s.setEventedParent(null);const l=this._order.indexOf(e);this._order.splice(l,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=s,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],s.onRemove&&s.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,s,l){this._checkLoaded();const c=this.getLayer(e);c?c.minzoom===s&&c.maxzoom===l||(null!=s&&(c.minzoom=s),null!=l&&(c.maxzoom=l),this._updateLayer(c)):this.fire(new a.k(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,s,l={}){this._checkLoaded();const c=this.getLayer(e);if(c){if(!a.bL(c.filter,s))return null==s?(c.setFilter(void 0),void this._updateLayer(c)):void(this._validate(a.B.filter,`layers.${c.id}.filter`,s,null,l)||(c.setFilter(a.bP(s)),this._updateLayer(c)))}else this.fire(new a.k(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return a.bP(this.getLayer(e).filter)}setLayoutProperty(e,s,l,c={}){this._checkLoaded();const u=this.getLayer(e);u?a.bL(u.getLayoutProperty(s),l)||(u.setLayoutProperty(s,l,c),this._updateLayer(u)):this.fire(new a.k(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,s){const l=this.getLayer(e);if(l)return l.getLayoutProperty(s);this.fire(new a.k(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,s,l,c={}){this._checkLoaded();const u=this.getLayer(e);u?a.bL(u.getPaintProperty(s),l)||this._updatePaintProperty(u,s,l,c):this.fire(new a.k(new Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,s,l,c={}){e.setPaintProperty(s,l,c)&&this._updateLayer(e),a.bO(e)&&"raster-fade-duration"===s&&this.tileManagers[e.source].setRasterFadeDuration(l),this._changed=!0,this._updatedPaintProps[e.id]=!0,this._serializedLayers=null}getPaintProperty(e,s){return this.getLayer(e).getPaintProperty(s)}setFeatureState(e,s){this._checkLoaded();const l=e.source,c=e.sourceLayer,u=this.tileManagers[l];if(void 0===u)return void this.fire(new a.k(new Error(`The source '${l}' does not exist in the map's style.`)));const d=u.getSource().type;"geojson"===d&&c?this.fire(new a.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==d||c?(void 0===e.id&&this.fire(new a.k(new Error("The feature id parameter must be provided."))),u.setFeatureState(c,e.id,s)):this.fire(new a.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,s){this._checkLoaded();const l=e.source,c=this.tileManagers[l];if(void 0===c)return void this.fire(new a.k(new Error(`The source '${l}' does not exist in the map's style.`)));const u=c.getSource().type,d="vector"===u?e.sourceLayer:void 0;"vector"!==u||d?s&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new a.k(new Error("A feature id is required to remove its specific state property."))):c.removeFeatureState(d,e.id,s):this.fire(new a.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const s=e.source,l=e.sourceLayer,c=this.tileManagers[s];if(void 0!==c)return"vector"!==c.getSource().type||l?(void 0===e.id&&this.fire(new a.k(new Error("The feature id parameter must be provided."))),c.getFeatureState(l,e.id)):void this.fire(new a.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new a.k(new Error(`The source '${s}' does not exist in the map's style.`)))}getTransition(){return a.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=a.bS(this.tileManagers,(e=>e.serialize())),s=this._serializeByIds(this._order,!0),l=this.map.getTerrain()||void 0,c=this.stylesheet;return a.bT({version:c.version,name:c.name,metadata:c.metadata,light:c.light,sky:c.sky,center:c.center,zoom:c.zoom,bearing:c.bearing,pitch:c.pitch,sprite:c.sprite,glyphs:c.glyphs,transition:c.transition,projection:c.projection,sources:e,layers:s,terrain:l},(e=>void 0!==e))}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&"raster"!==this.tileManagers[e.source].getSource().type&&(this._updatedSources[e.source]="reload",this.tileManagers[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){const s=e=>"fill-extrusion"===this._layers[e].type,a={},l=[];for(let c=this._order.length-1;c>=0;c--){const u=this._order[c];if(s(u)){a[u]=c;for(const s of e){const e=s[u];if(e)for(const s of e)l.push(s)}}}l.sort(((e,s)=>s.intersectionZ-e.intersectionZ));const c=[];for(let u=this._order.length-1;u>=0;u--){const d=this._order[u];if(s(d))for(let e=l.length-1;e>=0;e--){const s=l[e].feature;if(a[s.layer.id]<u)break;c.push(s),l.pop()}else for(const s of e){const e=s[d];if(e)for(const s of e)c.push(s.feature)}}return c}queryRenderedFeatures(e,s,l){s&&s.filter&&this._validate(a.B.filter,"queryRenderedFeatures.filter",s.filter,null,s);const c={};if(s&&s.layers){if(!(Array.isArray(s.layers)||s.layers instanceof Set))return this.fire(new a.k(new Error("parameters.layers must be an Array or a Set of strings"))),[];for(const e of s.layers){const s=this._layers[e];if(!s)return this.fire(new a.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be queried for features.`))),[];c[s.source]=!0}}const u=[];s.availableImages=this._availableImages;const d=this._serializedAllLayers(),f=s.layers instanceof Set?s.layers:Array.isArray(s.layers)?new Set(s.layers):null,_=Object.assign(Object.assign({},s),{layers:f,globalState:this._globalState});for(const a in this.tileManagers)s.layers&&!c[a]||u.push(xe(this.tileManagers[a],this._layers,d,e,_,l,this.map.terrain?(e,s,a)=>this.map.terrain.getElevation(e,s,a):void 0));return this.placement&&u.push(function(e,s,a,l,c,u,d){const f={},_=u.queryRenderedSymbols(l),y=[];for(const e of Object.keys(_).map(Number))y.push(d[e]);y.sort(ve);for(const a of y){const l=a.featureIndex.lookupSymbolFeatures(_[a.bucketInstanceId],s,a.bucketIndex,a.sourceLayerIndex,{filterSpec:c.filter,globalState:c.globalState},c.layers,c.availableImages,e);for(const e in l){const s=f[e]=f[e]||[],c=l[e];c.sort(((e,s)=>{const l=a.featureSortOrder;if(l){const a=l.indexOf(e.featureIndex);return l.indexOf(s.featureIndex)-a}return s.featureIndex-e.featureIndex}));for(const e of c)s.push(e)}}return function(e,s,a){for(const l in e)for(const c of e[l])be(c,a[s[l].source]);return e}(f,e,a)}(this._layers,d,this.tileManagers,e,_,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(u)}querySourceFeatures(e,s){(null==s?void 0:s.filter)&&this._validate(a.B.filter,"querySourceFeatures.filter",s.filter,null,s);const l=this.tileManagers[e];return l?function(e,s){const a=e.getRenderableIds().map((s=>e.getTileByID(s))),l=[],c={};for(let e=0;e<a.length;e++){const u=a[e],d=u.tileID.canonical.key;c[d]||(c[d]=!0,u.querySourceFeatures(l,s))}return l}(l,s?Object.assign(Object.assign({},s),{globalState:this._globalState}):{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(e,s={}){this._checkLoaded();const l=this.light.getLight();let c=!1;for(const s in e)if(!a.bL(e[s],l[s])){c=!0;break}if(!c)return;const u={now:b(),transition:a.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,s),this.light.updateTransitions(u)}getProjection(){var e;return null===(e=this.stylesheet)||void 0===e?void 0:e.projection}setProjection(e){if(this._checkLoaded(),this.projection){if(this.projection.name===e.type)return;this.projection.destroy(),delete this.projection}this.stylesheet.projection=e,this._setProjectionInternal(e.type)}getSky(){var e;return null===(e=this.stylesheet)||void 0===e?void 0:e.sky}setSky(e,s={}){this._checkLoaded();const l=this.getSky();let c=!1;if(!e&&!l)return;if(e&&!l)c=!0;else if(!e&&l)c=!0;else for(const s in e)if(!a.bL(e[s],l[s])){c=!0;break}if(!c)return;const u={now:b(),transition:a.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=e,this.sky.setSky(e,s),this.sky.updateTransitions(u)}_setProjectionInternal(e){const s=function(e,s){const l={constrainOverride:s};if(Array.isArray(e)){const s=new si({type:e});return{projection:s,transform:new Pi(l),cameraHelper:new Ci(s)}}switch(e){case"mercator":return{projection:new At,transform:new Nt(l),cameraHelper:new Wt};case"globe":{const e=new si({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]});return{projection:e,transform:new Pi(l),cameraHelper:new Ci(e)}}case"vertical-perspective":return{projection:new ri,transform:new Ti(l),cameraHelper:new Mi};default:return a.w(`Unknown projection name: ${e}. Falling back to mercator projection.`),{projection:new At,transform:new Nt(l),cameraHelper:new Wt}}}(e,this.map.transformConstrain);this.projection=s.projection,this.map.migrateProjection(s.transform,s.cameraHelper);for(const e in this.tileManagers)this.tileManagers[e].reload()}_validate(e,s,l,c,u={}){return(!u||!1!==u.validate)&&gr(this,e.call(a.B,a.e({key:s,style:this.serialize(),value:l,styleSpec:a.u},c)))}_remove(e=!0){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null),ke().off(Ce,this._rtlPluginLoaded);for(const e in this._layers)this._layers[e].setEventedParent(null);for(const e in this.tileManagers){const s=this.tileManagers[e];s.setEventedParent(null),s.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),e&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(e)}_clearSource(e){this.tileManagers[e].clearTiles()}_reloadSource(e){this.tileManagers[e].resume(),this.tileManagers[e].reload()}_updateSources(e){for(const s in this.tileManagers)this.tileManagers[s].update(e,this.map.terrain)}_generateCollisionBoxes(){for(const e in this.tileManagers)this._reloadSource(e)}_updatePlacement(e,s,a,l,c=!1){let u=!1,d=!1;const f={};for(const s of this._order){const a=this._layers[s];if("symbol"!==a.type)continue;if(!f[a.source]){const e=this.tileManagers[a.source];f[a.source]=e.getRenderableIds(!0).map((s=>e.getTileByID(s))).sort(((e,s)=>s.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(s.tileID)?-1:1)))}const l=this.crossTileSymbolIndex.addLayer(a,f[a.source],e.center.lng);u=u||l}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((c=c||this._layerOrderChanged||0===a)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(b(),e.zoom))&&(this.pauseablePlacement=new bt(e,this.map.terrain,this._order,c,s,a,l,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,f),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(b()),d=!0),u&&this.pauseablePlacement.placement.setStale()),d||u)for(const e of this._order){const s=this._layers[e];"symbol"===s.type&&this.placement.updateLayerOpacities(s,f[s.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(b())}_releaseSymbolFadeTiles(){for(const e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}getImages(e,s){return a._(this,void 0,void 0,(function*(){const e=yield this.imageManager.getImages(s.icons);this._updateTilesForChangedImages();const a=this.tileManagers[s.source];return a&&a.setDependencies(s.tileID.key,s.type,s.icons),e}))}getGlyphs(e,s){return a._(this,void 0,void 0,(function*(){const e=yield this.glyphManager.getGlyphs(s.stacks),a=this.tileManagers[s.source];return a&&a.setDependencies(s.tileID.key,s.type,[""]),e}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,s={}){this._checkLoaded(),e&&this._validate(a.B.glyphs,"glyphs",e,null,s)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}getDashes(e,s){return a._(this,void 0,void 0,(function*(){const e={};for(const[a,l]of Object.entries(s.dashes))e[a]=this.lineAtlas.getDash(l.dasharray,l.round);return e}))}addSprite(e,s,l={},c){this._checkLoaded();const u=[{id:e,url:s}],d=[...B(this.stylesheet.sprite),...u];this._validate(a.B.sprite,"sprite",d,null,l)||(this.stylesheet.sprite=d,this._loadSprite(u,!0,c))}removeSprite(e){this._checkLoaded();const s=B(this.stylesheet.sprite);if(s.find((s=>s.id===e))){if(this._spritesImagesIds[e])for(const s of this._spritesImagesIds[e])this.imageManager.removeImage(s),this._changedImages[s]=!0;s.splice(s.findIndex((s=>s.id===e)),1),this.stylesheet.sprite=s.length>0?s:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new a.l("data",{dataType:"style"}))}else this.fire(new a.k(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return B(this.stylesheet.sprite)}setSprite(e,s={},l){this._checkLoaded(),e&&this._validate(a.B.sprite,"sprite",e,null,s)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,l):(this._unloadSprite(),l&&l(null)))}destroy(){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null);for(const e in this.tileManagers){const s=this.tileManagers[e];if(s.setEventedParent(null),s._tiles){for(const e in s._tiles)s._tiles[e].unloadVectorData();s._tiles={}}s._cache.reset(),s.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this._availableImages=[],this._spritesImagesIds={}),this.glyphManager&&this.glyphManager.destroy();for(const e in this._layers){const s=this._layers[e];s.setEventedParent(null),s.onRemove&&s.onRemove(this.map)}this._setInitialValues(),this.setEventedParent(null),this.dispatcher.unregisterMessageHandler("GG"),this.dispatcher.unregisterMessageHandler("GI"),this.dispatcher.unregisterMessageHandler("GDA"),this.dispatcher.remove(!0),this._listeners={},this._oneTimeListeners={}}}var vr=a.aO([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Di{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,s,a,l,c,u,d,f,_){this.context=e;let y=this.boundPaintVertexBuffers.length!==l.length;for(let e=0;!y&&e<l.length;e++)this.boundPaintVertexBuffers[e]!==l[e]&&(y=!0);!this.vao||this.boundProgram!==s||this.boundLayoutVertexBuffer!==a||y||this.boundIndexBuffer!==c||this.boundVertexOffset!==u||this.boundDynamicVertexBuffer!==d||this.boundDynamicVertexBuffer2!==f||this.boundDynamicVertexBuffer3!==_?this.freshBind(s,a,l,c,u,d,f,_):(e.bindVertexArray.set(this.vao),d&&d.bind(),c&&c.dynamicDraw&&c.bind(),f&&f.bind(),_&&_.bind())}freshBind(e,s,a,l,c,u,d,f){const _=e.numAttributes,y=this.context,b=y.gl;this.vao&&this.destroy(),this.vao=y.createVertexArray(),y.bindVertexArray.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=s,this.boundPaintVertexBuffers=a,this.boundIndexBuffer=l,this.boundVertexOffset=c,this.boundDynamicVertexBuffer=u,this.boundDynamicVertexBuffer2=d,this.boundDynamicVertexBuffer3=f,s.enableAttributes(b,e);for(const s of a)s.enableAttributes(b,e);u&&u.enableAttributes(b,e),d&&d.enableAttributes(b,e),f&&f.enableAttributes(b,e),s.bind(),s.setVertexAttribPointers(b,e,c);for(const s of a)s.bind(),s.setVertexAttribPointers(b,e,c);u&&(u.bind(),u.setVertexAttribPointers(b,e,c)),l&&l.bind(),d&&(d.bind(),d.setVertexAttribPointers(b,e,c)),f&&(f.bind(),f.setVertexAttribPointers(b,e,c)),y.currentNumAttributes=_}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const br=(e,s,l,c,u)=>({u_texture:0,u_ele_delta:e,u_fog_matrix:s,u_fog_color:l?l.properties.get("fog-color"):a.bj.white,u_fog_ground_blend:l?l.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:u?0:l?l.calculateFogBlendOpacity(c):0,u_horizon_color:l?l.properties.get("horizon-color"):a.bj.white,u_horizon_fog_blend:l?l.properties.get("horizon-fog-blend"):1,u_is_globe_mode:u?1:0}),wr={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function Sr(e){const s=[];for(let a=0;a<e.length;a++){if(null===e[a])continue;const l=e[a].split(" ");s.push(l.pop())}return s}class ki{constructor(e,s,l,c,u,d,f,_,y=[]){const b=e.gl;this.program=b.createProgram();const S=Sr(s.staticAttributes),P=l?l.getBinderAttributes():[],M=S.concat(P),C=zi.prelude.staticUniforms?Sr(zi.prelude.staticUniforms):[],D=f.staticUniforms?Sr(f.staticUniforms):[],L=s.staticUniforms?Sr(s.staticUniforms):[],F=l?l.getBinderUniforms():[],B=C.concat(D).concat(L).concat(F),O=[];for(const e of B)O.indexOf(e)<0&&O.push(e);const V=l?l.defines():[];$i(b)&&V.unshift("#version 300 es"),u&&V.push("#define OVERDRAW_INSPECTOR;"),d&&V.push("#define TERRAIN3D;"),_&&V.push(_),y&&V.push(...y);let N=V.concat(zi.prelude.fragmentSource,f.fragmentSource,s.fragmentSource).join("\n"),j=V.concat(zi.prelude.vertexSource,f.vertexSource,s.vertexSource).join("\n");$i(b)||(N=function(e){return e.replace(/\bin\s/g,"varying ").replace("out highp vec4 fragColor;","").replace(/fragColor/g,"gl_FragColor").replace(/texture\(/g,"texture2D(")}(N),j=function(e){return e.replace(/\bin\s/g,"attribute ").replace(/\bout\s/g,"varying ").replace(/texture\(/g,"texture2D(")}(j));const G=b.createShader(b.FRAGMENT_SHADER);if(b.isContextLost())return void(this.failedToCreate=!0);if(b.shaderSource(G,N),b.compileShader(G),!b.getShaderParameter(G,b.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${b.getShaderInfoLog(G)}`);b.attachShader(this.program,G);const Z=b.createShader(b.VERTEX_SHADER);if(b.isContextLost())return void(this.failedToCreate=!0);if(b.shaderSource(Z,j),b.compileShader(Z),!b.getShaderParameter(Z,b.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${b.getShaderInfoLog(Z)}`);b.attachShader(this.program,Z),this.attributes={};const q={};this.numAttributes=M.length;for(let e=0;e<this.numAttributes;e++)M[e]&&(b.bindAttribLocation(this.program,e,M[e]),this.attributes[M[e]]=e);if(b.linkProgram(this.program),!b.getProgramParameter(this.program,b.LINK_STATUS))throw new Error(`Program failed to link: ${b.getProgramInfoLog(this.program)}`);b.deleteShader(Z),b.deleteShader(G);for(let e=0;e<O.length;e++){const s=O[e];if(s&&!q[s]){const e=b.getUniformLocation(this.program,s);e&&(q[s]=e)}}this.fixedUniforms=c(e,q),this.terrainUniforms=((e,s)=>({u_depth:new a.bU(e,s.u_depth),u_terrain:new a.bU(e,s.u_terrain),u_terrain_dim:new a.bk(e,s.u_terrain_dim),u_terrain_matrix:new a.bW(e,s.u_terrain_matrix),u_terrain_unpack:new a.bX(e,s.u_terrain_unpack),u_terrain_exaggeration:new a.bk(e,s.u_terrain_exaggeration)}))(e,q),this.projectionUniforms=((e,s)=>({u_projection_matrix:new a.bW(e,s.u_projection_matrix),u_projection_tile_mercator_coords:new a.bX(e,s.u_projection_tile_mercator_coords),u_projection_clipping_plane:new a.bX(e,s.u_projection_clipping_plane),u_projection_transition:new a.bk(e,s.u_projection_transition),u_projection_fallback_matrix:new a.bW(e,s.u_projection_fallback_matrix)}))(e,q),this.binderUniforms=l?l.getUniforms(e,q):[]}draw(e,s,a,l,c,u,d,f,_,y,b,S,P,M,C,D,L,F,B){const O=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(a),e.setStencilMode(l),e.setColorMode(c),e.setCullFace(u),f){e.activeTexture.set(O.TEXTURE2),O.bindTexture(O.TEXTURE_2D,f.depthTexture),e.activeTexture.set(O.TEXTURE3),O.bindTexture(O.TEXTURE_2D,f.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(f[e])}if(_)for(const e in _)this.projectionUniforms[wr[e]].set(_[e]);if(d)for(const e in this.fixedUniforms)this.fixedUniforms[e].set(d[e]);D&&D.setUniforms(e,this.binderUniforms,M,{zoom:C});let V=0;switch(s){case O.LINES:V=2;break;case O.TRIANGLES:V=3;break;case O.LINE_STRIP:V=1}for(const a of P.get()){const l=a.vaos||(a.vaos={});(l[y]||(l[y]=new Di)).bind(e,this,b,D?D.getPaintVertexBuffers():[],S,a.vertexOffset,L,F,B),O.drawElements(s,a.primitiveLength*V,O.UNSIGNED_SHORT,a.primitiveOffset*V*2)}}}function Pr(e,s,l){const c=1/a.aH(l,1,s.transform.tileZoom),u=Math.pow(2,l.tileID.overscaledZ),d=l.tileSize*Math.pow(2,s.transform.tileZoom)/u,f=d*(l.tileID.canonical.x+l.tileID.wrap*u),_=d*l.tileID.canonical.y;return{u_image:0,u_texsize:l.imageAtlasTexture.size,u_scale:[c,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[f>>16,_>>16],u_pixel_coord_lower:[65535&f,65535&_]}}const Cr=(e,s,l,c)=>{const u=e.style.light,d=u.properties.get("position"),f=[d.x,d.y,d.z],_=a.b_();"viewport"===u.properties.get("anchor")&&a.b$(_,e.transform.bearingInRadians),a.c0(f,f,_);const y=e.transform.transformLightDirection(f),b=u.properties.get("color");return{u_lightpos:f,u_lightpos_globe:y,u_lightintensity:u.properties.get("intensity"),u_lightcolor:[b.r,b.g,b.b],u_vertical_gradient:+s,u_opacity:l,u_fill_translate:c}},Ar=(e,s,l,c,u,d,f)=>a.e(Cr(e,s,l,c),Pr(d,e,f),{u_height_factor:-Math.pow(2,u.overscaledZ)/f.tileSize/8}),Dr=(e,s,l,c)=>a.e(Pr(s,e,l),{u_fill_translate:c}),zr=(e,s)=>({u_world:e,u_fill_translate:s}),Rr=(e,s,l,c,u)=>a.e(Dr(e,s,l,u),{u_world:c}),Lr=(e,s,l,c,u)=>{const d=e.transform;let f,_,y=0;if("map"===l.paint.get("circle-pitch-alignment")){const e=a.aH(s,1,d.zoom);f=!0,_=[e,e],y=e/(a.a3*Math.pow(2,s.tileID.overscaledZ))*2*Math.PI*u}else f=!1,_=d.pixelsToGLUnits;return{u_camera_to_center_distance:d.cameraToCenterDistance,u_scale_with_map:+("map"===l.paint.get("circle-pitch-scale")),u_pitch_with_map:+f,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:_,u_globe_extrude_scale:y,u_translate:c}},Fr=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),Br=e=>({u_viewport_size:[e.width,e.height]}),Or=(e,s=1)=>({u_color:e,u_overlay:0,u_overlay_scale:s}),Vr=(e,s,l,c)=>{const u=a.aH(e,1,s)/(a.a3*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*c;return{u_extrude_scale:a.aH(e,1,s),u_intensity:l,u_globe_extrude_scale:u}},Ur=(e,s,l,c)=>{const u=a.M();a.c1(u,0,e.width,e.height,0,0,1);const d=e.context.gl;return{u_matrix:u,u_world:[d.drawingBufferWidth,d.drawingBufferHeight],u_image:l,u_color_ramp:c,u_opacity:s.paint.get("heatmap-opacity")}},Gr=(e,s,a)=>{const l=a.paint.get("hillshade-accent-color");let c;switch(a.paint.get("hillshade-method")){case"basic":c=4;break;case"combined":c=1;break;case"igor":c=2;break;case"multidirectional":c=3;break;default:c=0}const u=a.getIlluminationProperties();for(let s=0;s<u.directionRadians.length;s++)"viewport"===a.paint.get("hillshade-illumination-anchor")&&(u.directionRadians[s]+=e.transform.bearingInRadians);return{u_image:0,u_latrange:$r(0,s.tileID),u_exaggeration:a.paint.get("hillshade-exaggeration"),u_altitudes:u.altitudeRadians,u_azimuths:u.directionRadians,u_accent:l,u_method:c,u_highlights:u.highlightColor,u_shadows:u.shadowColor}},qr=(e,s)=>{const l=s.stride,c=a.M();return a.c1(c,0,a.a3,-a.a3,0,0,1),a.N(c,c,[0,-a.a3,0]),{u_matrix:c,u_image:1,u_dimension:[l,l],u_zoom:e.overscaledZ,u_unpack:s.getUnpackVector()}};function $r(e,s){const l=Math.pow(2,s.canonical.z),c=s.canonical.y;return[new a.a5(0,c/l).toLngLat().lat,new a.a5(0,(c+1)/l).toLngLat().lat]}const Wr=(e,s,a=0)=>({u_image:0,u_unpack:s.getUnpackVector(),u_dimension:[s.stride,s.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:a,u_opacity:e.paint.get("color-relief-opacity")}),Xr=(e,s,l,c)=>{const u=e.transform;return{u_translation:sn(e,s,l),u_ratio:c/a.aH(s,1,u.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/u.pixelsToGLUnits[0],1/u.pixelsToGLUnits[1]]}},Kr=(e,s,l,c,u)=>a.e(Xr(e,s,l,c),{u_image:0,u_image_height:u}),en=(e,s,l,c,u)=>{const d=e.transform,f=nn(s,d);return{u_translation:sn(e,s,l),u_texsize:s.imageAtlasTexture.size,u_ratio:c/a.aH(s,1,d.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[f,u.fromScale,u.toScale],u_fade:u.t,u_units_to_pixels:[1/d.pixelsToGLUnits[0],1/d.pixelsToGLUnits[1]]}},tn=(e,s,l,c,u)=>{const d=nn(s,e.transform);return a.e(Xr(e,s,l,c),{u_tileratio:d,u_crossfade_from:u.fromScale,u_crossfade_to:u.toScale,u_image:0,u_mix:u.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})},rn=(e,s,l,c,u,d)=>{const f=nn(s,e.transform);return a.e(Xr(e,s,l,c),{u_image:0,u_image_height:d,u_tileratio:f,u_crossfade_from:u.fromScale,u_crossfade_to:u.toScale,u_image_dash:1,u_mix:u.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})};function nn(e,s){return 1/a.aH(e,1,s.tileZoom)}function sn(e,s,l){return a.aI(e.transform,s,l.paint.get("line-translate"),l.paint.get("line-translate-anchor"))}const on=(e,s,a,l,c)=>{return{u_tl_parent:e,u_scale_parent:s,u_buffer_scale:1,u_fade_t:a.mix,u_opacity:a.opacity*l.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:l.paint.get("raster-brightness-min"),u_brightness_high:l.paint.get("raster-brightness-max"),u_saturation_factor:(d=l.paint.get("raster-saturation"),d>0?1-1/(1.001-d):-d),u_contrast_factor:(u=l.paint.get("raster-contrast"),u>0?1/(1-u):1+u),u_spin_weights:ln(l.paint.get("raster-hue-rotate")),u_coords_top:[c[0].x,c[0].y,c[1].x,c[1].y],u_coords_bottom:[c[3].x,c[3].y,c[2].x,c[2].y]};var u,d};function ln(e){e*=Math.PI/180;const s=Math.sin(e),a=Math.cos(e);return[(2*a+1)/3,(-Math.sqrt(3)*s-a+1)/3,(Math.sqrt(3)*s-a+1)/3]}const cn=(e,s,a,l,c,u,d,f,_,y,b,S,P)=>{const M=d.transform;return{u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:s?s.uSizeT:0,u_size:s?s.uSize:0,u_camera_to_center_distance:M.cameraToCenterDistance,u_pitch:M.pitch/360*2*Math.PI,u_rotate_symbol:+a,u_aspect_ratio:M.width/M.height,u_fade_change:d.options.fadeDuration?d.symbolFadeChange:1,u_label_plane_matrix:f,u_coord_matrix:_,u_is_text:+b,u_pitch_with_map:+l,u_is_along_line:c,u_is_variable_anchor:u,u_texsize:S,u_texture:0,u_translation:y,u_pitched_scale:P}},hn=(e,s,l,c,u,d,f,_,y,b,S,P,M,C)=>{const D=f.transform;return a.e(cn(e,s,l,c,u,d,f,_,y,b,S,P,C),{u_gamma_scale:c?Math.cos(D.pitch*Math.PI/180)*D.cameraToCenterDistance:1,u_device_pixel_ratio:f.pixelRatio,u_is_halo:1})},un=(e,s,l,c,u,d,f,_,y,b,S,P,M)=>a.e(hn(e,s,l,c,u,d,f,_,y,b,!0,S,0,M),{u_texsize_icon:P,u_texture_icon:1}),dn=(e,s)=>({u_opacity:e,u_color:s}),pn=(e,s,l,c,u)=>a.e(function(e,s,l,c){const u=l.imageManager.getPattern(e.from.toString()),d=l.imageManager.getPattern(e.to.toString()),{width:f,height:_}=l.imageManager.getPixelSize(),y=Math.pow(2,c.tileID.overscaledZ),b=c.tileSize*Math.pow(2,l.transform.tileZoom)/y,S=b*(c.tileID.canonical.x+c.tileID.wrap*y),P=b*c.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:u.tl,u_pattern_br_a:u.br,u_pattern_tl_b:d.tl,u_pattern_br_b:d.br,u_texsize:[f,_],u_mix:s.t,u_pattern_size_a:u.displaySize,u_pattern_size_b:d.displaySize,u_scale_a:s.fromScale,u_scale_b:s.toScale,u_tile_units_to_pixels:1/a.aH(c,1,l.transform.tileZoom),u_pixel_coord_upper:[S>>16,P>>16],u_pixel_coord_lower:[65535&S,65535&P]}}(l,u,s,c),{u_opacity:e}),fn=(e,s)=>{},mn={fillExtrusion:(e,s)=>({u_lightpos:new a.bY(e,s.u_lightpos),u_lightpos_globe:new a.bY(e,s.u_lightpos_globe),u_lightintensity:new a.bk(e,s.u_lightintensity),u_lightcolor:new a.bY(e,s.u_lightcolor),u_vertical_gradient:new a.bk(e,s.u_vertical_gradient),u_opacity:new a.bk(e,s.u_opacity),u_fill_translate:new a.bZ(e,s.u_fill_translate)}),fillExtrusionPattern:(e,s)=>({u_lightpos:new a.bY(e,s.u_lightpos),u_lightpos_globe:new a.bY(e,s.u_lightpos_globe),u_lightintensity:new a.bk(e,s.u_lightintensity),u_lightcolor:new a.bY(e,s.u_lightcolor),u_vertical_gradient:new a.bk(e,s.u_vertical_gradient),u_height_factor:new a.bk(e,s.u_height_factor),u_opacity:new a.bk(e,s.u_opacity),u_fill_translate:new a.bZ(e,s.u_fill_translate),u_image:new a.bU(e,s.u_image),u_texsize:new a.bZ(e,s.u_texsize),u_pixel_coord_upper:new a.bZ(e,s.u_pixel_coord_upper),u_pixel_coord_lower:new a.bZ(e,s.u_pixel_coord_lower),u_scale:new a.bY(e,s.u_scale),u_fade:new a.bk(e,s.u_fade)}),fill:(e,s)=>({u_fill_translate:new a.bZ(e,s.u_fill_translate)}),fillPattern:(e,s)=>({u_image:new a.bU(e,s.u_image),u_texsize:new a.bZ(e,s.u_texsize),u_pixel_coord_upper:new a.bZ(e,s.u_pixel_coord_upper),u_pixel_coord_lower:new a.bZ(e,s.u_pixel_coord_lower),u_scale:new a.bY(e,s.u_scale),u_fade:new a.bk(e,s.u_fade),u_fill_translate:new a.bZ(e,s.u_fill_translate)}),fillOutline:(e,s)=>({u_world:new a.bZ(e,s.u_world),u_fill_translate:new a.bZ(e,s.u_fill_translate)}),fillOutlinePattern:(e,s)=>({u_world:new a.bZ(e,s.u_world),u_image:new a.bU(e,s.u_image),u_texsize:new a.bZ(e,s.u_texsize),u_pixel_coord_upper:new a.bZ(e,s.u_pixel_coord_upper),u_pixel_coord_lower:new a.bZ(e,s.u_pixel_coord_lower),u_scale:new a.bY(e,s.u_scale),u_fade:new a.bk(e,s.u_fade),u_fill_translate:new a.bZ(e,s.u_fill_translate)}),circle:(e,s)=>({u_camera_to_center_distance:new a.bk(e,s.u_camera_to_center_distance),u_scale_with_map:new a.bU(e,s.u_scale_with_map),u_pitch_with_map:new a.bU(e,s.u_pitch_with_map),u_extrude_scale:new a.bZ(e,s.u_extrude_scale),u_device_pixel_ratio:new a.bk(e,s.u_device_pixel_ratio),u_globe_extrude_scale:new a.bk(e,s.u_globe_extrude_scale),u_translate:new a.bZ(e,s.u_translate)}),collisionBox:(e,s)=>({u_pixel_extrude_scale:new a.bZ(e,s.u_pixel_extrude_scale)}),collisionCircle:(e,s)=>({u_viewport_size:new a.bZ(e,s.u_viewport_size)}),debug:(e,s)=>({u_color:new a.bV(e,s.u_color),u_overlay:new a.bU(e,s.u_overlay),u_overlay_scale:new a.bk(e,s.u_overlay_scale)}),depth:fn,clippingMask:fn,heatmap:(e,s)=>({u_extrude_scale:new a.bk(e,s.u_extrude_scale),u_intensity:new a.bk(e,s.u_intensity),u_globe_extrude_scale:new a.bk(e,s.u_globe_extrude_scale)}),heatmapTexture:(e,s)=>({u_matrix:new a.bW(e,s.u_matrix),u_world:new a.bZ(e,s.u_world),u_image:new a.bU(e,s.u_image),u_color_ramp:new a.bU(e,s.u_color_ramp),u_opacity:new a.bk(e,s.u_opacity)}),hillshade:(e,s)=>({u_image:new a.bU(e,s.u_image),u_latrange:new a.bZ(e,s.u_latrange),u_exaggeration:new a.bk(e,s.u_exaggeration),u_altitudes:new a.c3(e,s.u_altitudes),u_azimuths:new a.c3(e,s.u_azimuths),u_accent:new a.bV(e,s.u_accent),u_method:new a.bU(e,s.u_method),u_shadows:new a.c2(e,s.u_shadows),u_highlights:new a.c2(e,s.u_highlights)}),hillshadePrepare:(e,s)=>({u_matrix:new a.bW(e,s.u_matrix),u_image:new a.bU(e,s.u_image),u_dimension:new a.bZ(e,s.u_dimension),u_zoom:new a.bk(e,s.u_zoom),u_unpack:new a.bX(e,s.u_unpack)}),colorRelief:(e,s)=>({u_image:new a.bU(e,s.u_image),u_unpack:new a.bX(e,s.u_unpack),u_dimension:new a.bZ(e,s.u_dimension),u_elevation_stops:new a.bU(e,s.u_elevation_stops),u_color_stops:new a.bU(e,s.u_color_stops),u_color_ramp_size:new a.bU(e,s.u_color_ramp_size),u_opacity:new a.bk(e,s.u_opacity)}),line:(e,s)=>({u_translation:new a.bZ(e,s.u_translation),u_ratio:new a.bk(e,s.u_ratio),u_device_pixel_ratio:new a.bk(e,s.u_device_pixel_ratio),u_units_to_pixels:new a.bZ(e,s.u_units_to_pixels)}),lineGradient:(e,s)=>({u_translation:new a.bZ(e,s.u_translation),u_ratio:new a.bk(e,s.u_ratio),u_device_pixel_ratio:new a.bk(e,s.u_device_pixel_ratio),u_units_to_pixels:new a.bZ(e,s.u_units_to_pixels),u_image:new a.bU(e,s.u_image),u_image_height:new a.bk(e,s.u_image_height)}),linePattern:(e,s)=>({u_translation:new a.bZ(e,s.u_translation),u_texsize:new a.bZ(e,s.u_texsize),u_ratio:new a.bk(e,s.u_ratio),u_device_pixel_ratio:new a.bk(e,s.u_device_pixel_ratio),u_image:new a.bU(e,s.u_image),u_units_to_pixels:new a.bZ(e,s.u_units_to_pixels),u_scale:new a.bY(e,s.u_scale),u_fade:new a.bk(e,s.u_fade)}),lineSDF:(e,s)=>({u_translation:new a.bZ(e,s.u_translation),u_ratio:new a.bk(e,s.u_ratio),u_device_pixel_ratio:new a.bk(e,s.u_device_pixel_ratio),u_units_to_pixels:new a.bZ(e,s.u_units_to_pixels),u_image:new a.bU(e,s.u_image),u_mix:new a.bk(e,s.u_mix),u_tileratio:new a.bk(e,s.u_tileratio),u_crossfade_from:new a.bk(e,s.u_crossfade_from),u_crossfade_to:new a.bk(e,s.u_crossfade_to),u_lineatlas_width:new a.bk(e,s.u_lineatlas_width),u_lineatlas_height:new a.bk(e,s.u_lineatlas_height)}),lineGradientSDF:(e,s)=>({u_translation:new a.bZ(e,s.u_translation),u_ratio:new a.bk(e,s.u_ratio),u_device_pixel_ratio:new a.bk(e,s.u_device_pixel_ratio),u_units_to_pixels:new a.bZ(e,s.u_units_to_pixels),u_image:new a.bU(e,s.u_image),u_image_height:new a.bk(e,s.u_image_height),u_tileratio:new a.bk(e,s.u_tileratio),u_crossfade_from:new a.bk(e,s.u_crossfade_from),u_crossfade_to:new a.bk(e,s.u_crossfade_to),u_image_dash:new a.bU(e,s.u_image_dash),u_mix:new a.bk(e,s.u_mix),u_lineatlas_width:new a.bk(e,s.u_lineatlas_width),u_lineatlas_height:new a.bk(e,s.u_lineatlas_height)}),raster:(e,s)=>({u_tl_parent:new a.bZ(e,s.u_tl_parent),u_scale_parent:new a.bk(e,s.u_scale_parent),u_buffer_scale:new a.bk(e,s.u_buffer_scale),u_fade_t:new a.bk(e,s.u_fade_t),u_opacity:new a.bk(e,s.u_opacity),u_image0:new a.bU(e,s.u_image0),u_image1:new a.bU(e,s.u_image1),u_brightness_low:new a.bk(e,s.u_brightness_low),u_brightness_high:new a.bk(e,s.u_brightness_high),u_saturation_factor:new a.bk(e,s.u_saturation_factor),u_contrast_factor:new a.bk(e,s.u_contrast_factor),u_spin_weights:new a.bY(e,s.u_spin_weights),u_coords_top:new a.bX(e,s.u_coords_top),u_coords_bottom:new a.bX(e,s.u_coords_bottom)}),symbolIcon:(e,s)=>({u_is_size_zoom_constant:new a.bU(e,s.u_is_size_zoom_constant),u_is_size_feature_constant:new a.bU(e,s.u_is_size_feature_constant),u_size_t:new a.bk(e,s.u_size_t),u_size:new a.bk(e,s.u_size),u_camera_to_center_distance:new a.bk(e,s.u_camera_to_center_distance),u_pitch:new a.bk(e,s.u_pitch),u_rotate_symbol:new a.bU(e,s.u_rotate_symbol),u_aspect_ratio:new a.bk(e,s.u_aspect_ratio),u_fade_change:new a.bk(e,s.u_fade_change),u_label_plane_matrix:new a.bW(e,s.u_label_plane_matrix),u_coord_matrix:new a.bW(e,s.u_coord_matrix),u_is_text:new a.bU(e,s.u_is_text),u_pitch_with_map:new a.bU(e,s.u_pitch_with_map),u_is_along_line:new a.bU(e,s.u_is_along_line),u_is_variable_anchor:new a.bU(e,s.u_is_variable_anchor),u_texsize:new a.bZ(e,s.u_texsize),u_texture:new a.bU(e,s.u_texture),u_translation:new a.bZ(e,s.u_translation),u_pitched_scale:new a.bk(e,s.u_pitched_scale)}),symbolSDF:(e,s)=>({u_is_size_zoom_constant:new a.bU(e,s.u_is_size_zoom_constant),u_is_size_feature_constant:new a.bU(e,s.u_is_size_feature_constant),u_size_t:new a.bk(e,s.u_size_t),u_size:new a.bk(e,s.u_size),u_camera_to_center_distance:new a.bk(e,s.u_camera_to_center_distance),u_pitch:new a.bk(e,s.u_pitch),u_rotate_symbol:new a.bU(e,s.u_rotate_symbol),u_aspect_ratio:new a.bk(e,s.u_aspect_ratio),u_fade_change:new a.bk(e,s.u_fade_change),u_label_plane_matrix:new a.bW(e,s.u_label_plane_matrix),u_coord_matrix:new a.bW(e,s.u_coord_matrix),u_is_text:new a.bU(e,s.u_is_text),u_pitch_with_map:new a.bU(e,s.u_pitch_with_map),u_is_along_line:new a.bU(e,s.u_is_along_line),u_is_variable_anchor:new a.bU(e,s.u_is_variable_anchor),u_texsize:new a.bZ(e,s.u_texsize),u_texture:new a.bU(e,s.u_texture),u_gamma_scale:new a.bk(e,s.u_gamma_scale),u_device_pixel_ratio:new a.bk(e,s.u_device_pixel_ratio),u_is_halo:new a.bU(e,s.u_is_halo),u_translation:new a.bZ(e,s.u_translation),u_pitched_scale:new a.bk(e,s.u_pitched_scale)}),symbolTextAndIcon:(e,s)=>({u_is_size_zoom_constant:new a.bU(e,s.u_is_size_zoom_constant),u_is_size_feature_constant:new a.bU(e,s.u_is_size_feature_constant),u_size_t:new a.bk(e,s.u_size_t),u_size:new a.bk(e,s.u_size),u_camera_to_center_distance:new a.bk(e,s.u_camera_to_center_distance),u_pitch:new a.bk(e,s.u_pitch),u_rotate_symbol:new a.bU(e,s.u_rotate_symbol),u_aspect_ratio:new a.bk(e,s.u_aspect_ratio),u_fade_change:new a.bk(e,s.u_fade_change),u_label_plane_matrix:new a.bW(e,s.u_label_plane_matrix),u_coord_matrix:new a.bW(e,s.u_coord_matrix),u_is_text:new a.bU(e,s.u_is_text),u_pitch_with_map:new a.bU(e,s.u_pitch_with_map),u_is_along_line:new a.bU(e,s.u_is_along_line),u_is_variable_anchor:new a.bU(e,s.u_is_variable_anchor),u_texsize:new a.bZ(e,s.u_texsize),u_texsize_icon:new a.bZ(e,s.u_texsize_icon),u_texture:new a.bU(e,s.u_texture),u_texture_icon:new a.bU(e,s.u_texture_icon),u_gamma_scale:new a.bk(e,s.u_gamma_scale),u_device_pixel_ratio:new a.bk(e,s.u_device_pixel_ratio),u_is_halo:new a.bU(e,s.u_is_halo),u_translation:new a.bZ(e,s.u_translation),u_pitched_scale:new a.bk(e,s.u_pitched_scale)}),background:(e,s)=>({u_opacity:new a.bk(e,s.u_opacity),u_color:new a.bV(e,s.u_color)}),backgroundPattern:(e,s)=>({u_opacity:new a.bk(e,s.u_opacity),u_image:new a.bU(e,s.u_image),u_pattern_tl_a:new a.bZ(e,s.u_pattern_tl_a),u_pattern_br_a:new a.bZ(e,s.u_pattern_br_a),u_pattern_tl_b:new a.bZ(e,s.u_pattern_tl_b),u_pattern_br_b:new a.bZ(e,s.u_pattern_br_b),u_texsize:new a.bZ(e,s.u_texsize),u_mix:new a.bk(e,s.u_mix),u_pattern_size_a:new a.bZ(e,s.u_pattern_size_a),u_pattern_size_b:new a.bZ(e,s.u_pattern_size_b),u_scale_a:new a.bk(e,s.u_scale_a),u_scale_b:new a.bk(e,s.u_scale_b),u_pixel_coord_upper:new a.bZ(e,s.u_pixel_coord_upper),u_pixel_coord_lower:new a.bZ(e,s.u_pixel_coord_lower),u_tile_units_to_pixels:new a.bk(e,s.u_tile_units_to_pixels)}),terrain:(e,s)=>({u_texture:new a.bU(e,s.u_texture),u_ele_delta:new a.bk(e,s.u_ele_delta),u_fog_matrix:new a.bW(e,s.u_fog_matrix),u_fog_color:new a.bV(e,s.u_fog_color),u_fog_ground_blend:new a.bk(e,s.u_fog_ground_blend),u_fog_ground_blend_opacity:new a.bk(e,s.u_fog_ground_blend_opacity),u_horizon_color:new a.bV(e,s.u_horizon_color),u_horizon_fog_blend:new a.bk(e,s.u_horizon_fog_blend),u_is_globe_mode:new a.bk(e,s.u_is_globe_mode)}),terrainDepth:(e,s)=>({u_ele_delta:new a.bk(e,s.u_ele_delta)}),terrainCoords:(e,s)=>({u_texture:new a.bU(e,s.u_texture),u_terrain_coords_id:new a.bk(e,s.u_terrain_coords_id),u_ele_delta:new a.bk(e,s.u_ele_delta)}),projectionErrorMeasurement:(e,s)=>({u_input:new a.bk(e,s.u_input),u_output_expected:new a.bk(e,s.u_output_expected)}),atmosphere:(e,s)=>({u_sun_pos:new a.bY(e,s.u_sun_pos),u_atmosphere_blend:new a.bk(e,s.u_atmosphere_blend),u_globe_position:new a.bY(e,s.u_globe_position),u_globe_radius:new a.bk(e,s.u_globe_radius),u_inv_proj_matrix:new a.bW(e,s.u_inv_proj_matrix)}),sky:(e,s)=>({u_sky_color:new a.bV(e,s.u_sky_color),u_horizon_color:new a.bV(e,s.u_horizon_color),u_horizon:new a.bZ(e,s.u_horizon),u_horizon_normal:new a.bZ(e,s.u_horizon_normal),u_sky_horizon_blend:new a.bk(e,s.u_sky_horizon_blend),u_sky_blend:new a.bk(e,s.u_sky_blend)})};class pa{constructor(e,s,a){this.context=e;const l=e.gl;this.buffer=l.createBuffer(),this.dynamicDraw=Boolean(a),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),l.bufferData(l.ELEMENT_ARRAY_BUFFER,s.arrayBuffer,this.dynamicDraw?l.DYNAMIC_DRAW:l.STATIC_DRAW),this.dynamicDraw||delete s.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const s=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),s.bufferSubData(s.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const _n={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class fa{constructor(e,s,a,l){this.length=s.length,this.attributes=a,this.itemSize=s.bytesPerElement,this.dynamicDraw=l,this.context=e;const c=e.gl;this.buffer=c.createBuffer(),e.bindVertexBuffer.set(this.buffer),c.bufferData(c.ARRAY_BUFFER,s.arrayBuffer,this.dynamicDraw?c.DYNAMIC_DRAW:c.STATIC_DRAW),this.dynamicDraw||delete s.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const s=this.context.gl;this.bind(),s.bufferSubData(s.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,s){for(let a=0;a<this.attributes.length;a++){const l=s.attributes[this.attributes[a].name];void 0!==l&&e.enableVertexAttribArray(l)}}setVertexAttribPointers(e,s,a){for(let l=0;l<this.attributes.length;l++){const c=this.attributes[l],u=s.attributes[c.name];void 0!==u&&e.vertexAttribPointer(u,c.components,e[_n[c.type]],!1,this.itemSize,c.offset+this.itemSize*(a||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class ga{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class va extends ga{getDefault(){return a.bj.transparent}set(e){const s=this.current;(e.r!==s.r||e.g!==s.g||e.b!==s.b||e.a!==s.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class xa extends ga{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class ba extends ga{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class ya extends ga{getDefault(){return[!0,!0,!0,!0]}set(e){const s=this.current;(e[0]!==s[0]||e[1]!==s[1]||e[2]!==s[2]||e[3]!==s[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class wa extends ga{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class Ta extends ga{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class Pa extends ga{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const s=this.current;(e.func!==s.func||e.ref!==s.ref||e.mask!==s.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}}class Ma extends ga{getDefault(){const e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){const s=this.current;(e[0]!==s[0]||e[1]!==s[1]||e[2]!==s[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}}class Ca extends ga{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const s=this.gl;e?s.enable(s.STENCIL_TEST):s.disable(s.STENCIL_TEST),this.current=e,this.dirty=!1}}class Ia extends ga{getDefault(){return[0,1]}set(e){const s=this.current;(e[0]!==s[0]||e[1]!==s[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}}class Ea extends ga{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const s=this.gl;e?s.enable(s.DEPTH_TEST):s.disable(s.DEPTH_TEST),this.current=e,this.dirty=!1}}class Sa extends ga{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class Ra extends ga{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const s=this.gl;e?s.enable(s.BLEND):s.disable(s.BLEND),this.current=e,this.dirty=!1}}class Da extends ga{getDefault(){const e=this.gl;return[e.ONE,e.ZERO]}set(e){const s=this.current;(e[0]!==s[0]||e[1]!==s[1]||this.dirty)&&(this.gl.blendFunc(e[0],e[1]),this.current=e,this.dirty=!1)}}class za extends ga{getDefault(){return a.bj.transparent}set(e){const s=this.current;(e.r!==s.r||e.g!==s.g||e.b!==s.b||e.a!==s.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class Aa extends ga{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}}class La extends ga{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const s=this.gl;e?s.enable(s.CULL_FACE):s.disable(s.CULL_FACE),this.current=e,this.dirty=!1}}class ka extends ga{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class Fa extends ga{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}class Ba extends ga{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}}class Oa extends ga{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class ja extends ga{getDefault(){const e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const s=this.current;(e[0]!==s[0]||e[1]!==s[1]||e[2]!==s[2]||e[3]!==s[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class Ua extends ga{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const s=this.gl;s.bindFramebuffer(s.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class Na extends ga{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const s=this.gl;s.bindRenderbuffer(s.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Za extends ga{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const s=this.gl;s.bindTexture(s.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class Ga extends ga{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const s=this.gl;s.bindBuffer(s.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Va extends ga{getDefault(){return null}set(e){const s=this.gl;s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Wa extends ga{getDefault(){return null}set(e){var s;if(e===this.current&&!this.dirty)return;const a=this.gl;$i(a)?a.bindVertexArray(e):null===(s=a.getExtension("OES_vertex_array_object"))||void 0===s||s.bindVertexArrayOES(e),this.current=e,this.dirty=!1}}class qa extends ga{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const s=this.gl;s.pixelStorei(s.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class $a extends ga{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const s=this.gl;s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class Ha extends ga{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const s=this.gl;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class Xa extends ga{constructor(e,s){super(e),this.context=e,this.parent=s}getDefault(){return null}}class Ka extends Xa{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const s=this.gl;s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class Ya extends Xa{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const s=this.gl;s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Qa extends Xa{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const s=this.gl;s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,e),this.current=e,this.dirty=!1}}const gn="Framebuffer is not complete";class er{constructor(e,s,a,l,c){this.context=e,this.width=s,this.height=a;const u=e.gl,d=this.framebuffer=u.createFramebuffer();if(this.colorAttachment=new Ka(e,d),l)this.depthAttachment=c?new Qa(e,d):new Ya(e,d);else if(c)throw new Error("Stencil cannot be set without depth");if(u.checkFramebufferStatus(u.FRAMEBUFFER)!==u.FRAMEBUFFER_COMPLETE)throw new Error(gn)}destroy(){const e=this.context.gl,s=this.colorAttachment.get();if(s&&e.deleteTexture(s),this.depthAttachment){const s=this.depthAttachment.get();s&&e.deleteRenderbuffer(s)}e.deleteFramebuffer(this.framebuffer)}}class tr{constructor(e){var s,a;if(this.gl=e,this.clearColor=new va(this),this.clearDepth=new xa(this),this.clearStencil=new ba(this),this.colorMask=new ya(this),this.depthMask=new wa(this),this.stencilMask=new Ta(this),this.stencilFunc=new Pa(this),this.stencilOp=new Ma(this),this.stencilTest=new Ca(this),this.depthRange=new Ia(this),this.depthTest=new Ea(this),this.depthFunc=new Sa(this),this.blend=new Ra(this),this.blendFunc=new Da(this),this.blendColor=new za(this),this.blendEquation=new Aa(this),this.cullFace=new La(this),this.cullFaceSide=new ka(this),this.frontFace=new Fa(this),this.program=new Ba(this),this.activeTexture=new Oa(this),this.viewport=new ja(this),this.bindFramebuffer=new Ua(this),this.bindRenderbuffer=new Na(this),this.bindTexture=new Za(this),this.bindVertexBuffer=new Ga(this),this.bindElementBuffer=new Va(this),this.bindVertexArray=new Wa(this),this.pixelStoreUnpack=new qa(this),this.pixelStoreUnpackPremultiplyAlpha=new $a(this),this.pixelStoreUnpackFlipY=new Ha(this),this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),$i(e)){this.HALF_FLOAT=e.HALF_FLOAT;const l=e.getExtension("EXT_color_buffer_half_float");this.RGBA16F=null!==(s=e.RGBA16F)&&void 0!==s?s:null==l?void 0:l.RGBA16F_EXT,this.RGB16F=null!==(a=e.RGB16F)&&void 0!==a?a:null==l?void 0:l.RGB16F_EXT,e.getExtension("EXT_color_buffer_float")}else{e.getExtension("EXT_color_buffer_half_float"),e.getExtension("OES_texture_half_float_linear");const s=e.getExtension("OES_texture_half_float");this.HALF_FLOAT=null==s?void 0:s.HALF_FLOAT_OES}}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.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(e,s){return new pa(this,e,s)}createVertexBuffer(e,s,a){return new fa(this,e,s,a)}createRenderbuffer(e,s,a){const l=this.gl,c=l.createRenderbuffer();return this.bindRenderbuffer.set(c),l.renderbufferStorage(l.RENDERBUFFER,e,s,a),this.bindRenderbuffer.set(null),c}createFramebuffer(e,s,a,l){return new er(this,e,s,a,l)}clear({color:e,depth:s,stencil:a}){const l=this.gl;let c=0;e&&(c|=l.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),void 0!==s&&(c|=l.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(s),this.depthMask.set(!0)),void 0!==a&&(c|=l.STENCIL_BUFFER_BIT,this.clearStencil.set(a),this.stencilMask.set(255)),l.clear(c)}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(e){a.bL(e.blendFunction,qt.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor)),this.colorMask.set(e.mask)}createVertexArray(){var e;return $i(this.gl)?this.gl.createVertexArray():null===(e=this.gl.getExtension("OES_vertex_array_object"))||void 0===e?void 0:e.createVertexArrayOES()}deleteVertexArray(e){var s;return $i(this.gl)?this.gl.deleteVertexArray(e):null===(s=this.gl.getExtension("OES_vertex_array_object"))||void 0===s?void 0:s.deleteVertexArrayOES(e)}unbindVAO(){this.bindVertexArray.set(null)}}let yn;function xn(e,s,l,c,u){const d=e.context,f=e.transform,_=d.gl,y=e.useProgram("collisionBox"),b=[];let S=0,P=0;for(let a=0;a<c.length;a++){const M=c[a],C=s.getTile(M).getBucket(l);if(!C)continue;const D=u?C.textCollisionBox:C.iconCollisionBox,L=C.collisionCircleArray;L.length>0&&(b.push({circleArray:L,circleOffset:P,coord:M}),S+=L.length/4,P=S),D&&y.draw(d,_.LINES,Xt.disabled,Yt.disabled,e.colorModeForRenderPass(),Ht.disabled,Fr(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(M),f.getProjectionData({overscaledTileID:M,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),l.id,D.layoutVertexBuffer,D.indexBuffer,D.segments,null,e.transform.zoom,null,null,D.collisionVertexBuffer)}if(!u||!b.length)return;const M=e.useProgram("collisionCircle"),C=new a.c4;C.resize(4*S),C._trim();let D=0;for(const e of b)for(let s=0;s<e.circleArray.length/4;s++){const a=4*s,l=e.circleArray[a+0],c=e.circleArray[a+1],u=e.circleArray[a+2],d=e.circleArray[a+3];C.emplace(D++,l,c,u,d,0),C.emplace(D++,l,c,u,d,1),C.emplace(D++,l,c,u,d,2),C.emplace(D++,l,c,u,d,3)}(!yn||yn.length<2*S)&&(yn=function(e){const s=2*e,l=new a.c6;l.resize(s),l._trim();for(let e=0;e<s;e++){const s=6*e;l.uint16[s+0]=4*e+0,l.uint16[s+1]=4*e+1,l.uint16[s+2]=4*e+2,l.uint16[s+3]=4*e+2,l.uint16[s+4]=4*e+3,l.uint16[s+5]=4*e+0}return l}(S));const L=d.createIndexBuffer(yn,!0),F=d.createVertexBuffer(C,a.c5.members,!0);for(const s of b){const c=Br(e.transform);M.draw(d,_.TRIANGLES,Xt.disabled,Yt.disabled,e.colorModeForRenderPass(),Ht.disabled,c,e.style.map.terrain&&e.style.map.terrain.getTerrainData(s.coord),null,l.id,F,L,a.aR.simpleSegment(0,2*s.circleOffset,s.circleArray.length,s.circleArray.length/2),null,e.transform.zoom,null,null,null)}F.destroy(),L.destroy()}const vn=a.am(new Float32Array(16));function bn(e,s,l,c,u,d){const{horizontalAlign:f,verticalAlign:_}=a.aM(e);return new a.P((-(f-.5)*s/u+c[0])*d,(-(_-.5)*l/u+c[1])*d)}function wn(e,s,l,c,u,d){const f=s.tileAnchorPoint.add(new a.P(s.translation[0],s.translation[1]));if(s.pitchWithMap){let e=c.mult(d);l||(e=e.rotate(-u));const a=f.add(e);return ht(a.x,a.y,s.pitchedLabelPlaneMatrix,s.getElevation).point}if(l){const a=vt(s.tileAnchorPoint.x+1,s.tileAnchorPoint.y,s).point.sub(e),l=Math.atan(a.y/a.x)+(a.x<0?Math.PI:0);return e.add(c.rotate(l))}return e.add(c)}function Tn(e,s,l,c,u,d,f,_,y,b,S,P){const M=e.text.placedSymbolArray,C=e.text.dynamicLayoutVertexArray,D=e.icon.dynamicLayoutVertexArray,L={};C.clear();for(let D=0;D<M.length;D++){const F=M.get(D),B=F.hidden||!F.crossTileID||e.allowVerticalPlacement&&!F.placedOrientation?null:c[F.crossTileID];if(B){const c=new a.P(F.anchorX,F.anchorY),M={getElevation:P,width:u.width,height:u.height,pitchedLabelPlaneMatrix:d,pitchWithMap:l,transform:u,tileAnchorPoint:c,translation:b,unwrappedTileID:S},D=l?Rt(c.x,c.y,M):vt(c.x,c.y,M),O=ut(u.cameraToCenterDistance,D.signedDistanceFromCamera);let V=a.au(e.textSizeData,_,F)*O/a.aG;l&&(V*=e.tilePixelRatio/f);const{width:N,height:j,anchor:G,textOffset:Z,textBoxScale:q}=B,W=bn(G,N,j,Z,q,V),J=u.getPitchedTextCorrection(c.x+b[0],c.y+b[1],S),Q=wn(D.point,M,s,W,-u.bearingInRadians,J),se=e.allowVerticalPlacement&&F.placedOrientation===a.at.vertical?Math.PI/2:0;for(let e=0;e<F.numGlyphs;e++)a.aA(C,Q,se);y&&F.associatedIconIndex>=0&&(L[F.associatedIconIndex]={shiftedAnchor:Q,angle:se})}else oi(F.numGlyphs,C)}if(y){D.clear();const s=e.icon.placedSymbolArray;for(let e=0;e<s.length;e++){const l=s.get(e);if(l.hidden)oi(l.numGlyphs,D);else{const s=L[e];if(s)for(let e=0;e<l.numGlyphs;e++)a.aA(D,s.shiftedAnchor,s.angle);else oi(l.numGlyphs,D)}}e.icon.dynamicLayoutVertexBuffer.updateData(D)}e.text.dynamicLayoutVertexBuffer.updateData(C)}function Sn(e,s,a){return a.iconsInText&&s?"symbolTextAndIcon":e?"symbolSDF":"symbolIcon"}function Pn(e,s,l,c,u,d,f,_,y,b,S,P,M){const C=e.context,D=C.gl,L=e.transform,F="map"===_,B="map"===y,O="viewport"!==_&&"point"!==l.layout.get("symbol-placement"),V=F&&!B&&!O,N=!l.layout.get("symbol-sort-key").isConstant();let j=!1;const G=e.getDepthModeForSublayer(0,Xt.ReadOnly),Z=l._unevaluatedLayout.hasValue("text-variable-anchor")||l._unevaluatedLayout.hasValue("text-variable-anchor-offset"),q=[],W=L.getCircleRadiusCorrection();for(const _ of c){const c=s.getTile(_),y=c.getBucket(l);if(!y)continue;const S=u?y.text:y.icon;if(!S||!S.segments.get().length||!S.hasVisibleVertices)continue;const P=S.programConfigurations.get(l.id),C=u||y.sdfIcons,G=u?y.textSizeData:y.iconSizeData,J=B||0!==L.pitch,Q=e.useProgram(Sn(C,u,y),P),se=a.as(G,L.zoom),oe=e.style.map.terrain&&e.style.map.terrain.getTerrainData(_);let ce,pe,fe,xe,ve=[0,0],be=null;if(u)pe=c.glyphAtlasTexture,fe=D.LINEAR,ce=c.glyphAtlasTexture.size,y.iconsInText&&(ve=c.imageAtlasTexture.size,be=c.imageAtlasTexture,xe=J||e.options.rotating||e.options.zooming||"composite"===G.kind||"camera"===G.kind?D.LINEAR:D.NEAREST);else{const s=1!==l.layout.get("icon-size").constantOr(0)||y.iconsNeedLinear;pe=c.imageAtlasTexture,fe=C||e.options.rotating||e.options.zooming||s||J?D.LINEAR:D.NEAREST,ce=c.imageAtlasTexture.size}const we=a.aH(c,1,e.transform.zoom),Te=et(F,e.transform,we),Se=a.M();a.av(Se,Te);const Me=nt(B,F,e.transform,we),Ee=a.aI(L,c,d,f),Ce=L.getProjectionData({overscaledTileID:_,applyGlobeMatrix:!M,applyTerrainMatrix:!0}),Ae=Z&&y.hasTextData(),ke="none"!==l.layout.get("icon-text-fit")&&Ae&&y.hasIconData();if(O){const s=e.style.map.terrain?(s,a)=>e.style.map.terrain.getElevation(_,s,a):null,a="map"===l.layout.get("text-rotation-alignment");pt(y,e,u,Te,Se,B,b,a,_.toUnwrapped(),L.width,L.height,Ee,s)}const Le=u&&Z||ke,Fe=O||Le?vn:B?Te:e.transform.clipSpaceToPixelsMatrix,Oe=C&&0!==l.paint.get(u?"text-halo-width":"icon-halo-width").constantOr(1);let Ve;Ve=C?y.iconsInText?un(G.kind,se,V,B,O,Le,e,Fe,Me,Ee,ce,ve,W):hn(G.kind,se,V,B,O,Le,e,Fe,Me,Ee,u,ce,0,W):cn(G.kind,se,V,B,O,Le,e,Fe,Me,Ee,u,ce,W);const Ne={program:Q,buffers:S,uniformValues:Ve,projectionData:Ce,atlasTexture:pe,atlasTextureIcon:be,atlasInterpolation:fe,atlasInterpolationIcon:xe,isSDF:C,hasHalo:Oe};if(N&&y.canOverlap){j=!0;const e=S.segments.get();for(const s of e)q.push({segments:new a.aR([s]),sortKey:s.sortKey,state:Ne,terrainData:oe})}else q.push({segments:S.segments,sortKey:0,state:Ne,terrainData:oe})}j&&q.sort(((e,s)=>e.sortKey-s.sortKey));for(const s of q){const a=s.state;if(C.activeTexture.set(D.TEXTURE0),a.atlasTexture.bind(a.atlasInterpolation,D.CLAMP_TO_EDGE),a.atlasTextureIcon&&(C.activeTexture.set(D.TEXTURE1),a.atlasTextureIcon&&a.atlasTextureIcon.bind(a.atlasInterpolationIcon,D.CLAMP_TO_EDGE)),a.isSDF){const c=a.uniformValues;a.hasHalo&&(c.u_is_halo=1,In(a.buffers,s.segments,l,e,a.program,G,S,P,c,a.projectionData,s.terrainData)),c.u_is_halo=0}In(a.buffers,s.segments,l,e,a.program,G,S,P,a.uniformValues,a.projectionData,s.terrainData)}}function In(e,s,a,l,c,u,d,f,_,y,b){const S=l.context;c.draw(S,S.gl.TRIANGLES,u,d,f,Ht.backCCW,_,b,y,a.id,e.layoutVertexBuffer,e.indexBuffer,s,a.paint,l.transform.zoom,e.programConfigurations.get(a.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function Mn(e,s,l,c,u){const d=e.context,f=d.gl,_=Yt.disabled,y=new qt([f.ONE,f.ONE],a.bj.transparent,[!0,!0,!0,!0]),b=s.getBucket(l);if(!b)return;const S=c.key;let P=l.heatmapFbos.get(S);P||(P=An(d,s.tileSize,s.tileSize),l.heatmapFbos.set(S,P)),d.bindFramebuffer.set(P.framebuffer),d.viewport.set([0,0,s.tileSize,s.tileSize]),d.clear({color:a.bj.transparent});const M=b.programConfigurations.get(l.id),C=e.useProgram("heatmap",M,!u),D=e.transform.getProjectionData({overscaledTileID:s.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),L=e.style.map.terrain.getTerrainData(c);C.draw(d,f.TRIANGLES,Xt.disabled,_,y,Ht.disabled,Vr(s,e.transform.zoom,l.paint.get("heatmap-intensity"),1),L,D,l.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,l.paint,e.transform.zoom,M)}function Cn(e,s,a,l,c){const u=e.context,d=u.gl,f=e.transform;u.setColorMode(e.colorModeForRenderPass());const _=Dn(u,s),y=a.key,b=s.heatmapFbos.get(y);if(!b)return;u.activeTexture.set(d.TEXTURE0),d.bindTexture(d.TEXTURE_2D,b.colorAttachment.get()),u.activeTexture.set(d.TEXTURE1),_.bind(d.LINEAR,d.CLAMP_TO_EDGE);const S=f.getProjectionData({overscaledTileID:a,applyTerrainMatrix:c,applyGlobeMatrix:!l});e.useProgram("heatmapTexture").draw(u,d.TRIANGLES,Xt.disabled,Yt.disabled,e.colorModeForRenderPass(),Ht.disabled,Ur(e,s,0,1),null,S,s.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,s.paint,f.zoom),b.destroy(),s.heatmapFbos.delete(y)}function An(e,s,a){var l,c;const u=e.gl,d=u.createTexture();u.bindTexture(u.TEXTURE_2D,d),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,u.LINEAR),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,u.LINEAR);const f=null!==(l=e.HALF_FLOAT)&&void 0!==l?l:u.UNSIGNED_BYTE,_=null!==(c=e.RGBA16F)&&void 0!==c?c:u.RGBA;u.texImage2D(u.TEXTURE_2D,0,_,s,a,0,u.RGBA,f,null);const y=e.createFramebuffer(s,a,!1,!1);return y.colorAttachment.set(d),y}function Dn(e,s){return s.colorRampTexture||(s.colorRampTexture=new a.T(e,s.colorRamp,e.gl.RGBA)),s.colorRampTexture}function zn(e,s,l,c,u,d,f,_){let y=256;if(u.stepInterpolant){const c=s.getSource().maxzoom,u=f.canonical.z===c?Math.ceil(1<<e.transform.maxZoom-f.canonical.z):1;y=a.ai(a.c8(d.maxLineLength/a.a3*1024*u),256,l.maxTextureSize)}return _.gradient=a.c9({expression:u.gradientExpression(),evaluationKey:"lineProgress",resolution:y,image:_.gradient||void 0,clips:d.lineClipsArray}),_.texture?_.texture.update(_.gradient):_.texture=new a.T(l,_.gradient,c.RGBA),_.version=u.gradientVersion,_.texture}function Rn(e,s,a,l,c){e.activeTexture.set(s.TEXTURE0),a.imageAtlasTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE),l.updatePaintBuffers(c)}function Ln(e,s,a,l,c,u){(c||e.lineAtlas.dirty)&&(s.activeTexture.set(a.TEXTURE0),e.lineAtlas.bind(s)),l.updatePaintBuffers(u)}function Bn(e,s,a,l,c,u,d){const f=u.gradients[c.id];let _=f.texture;c.gradientVersion!==f.version&&(_=zn(e,s,a,l,c,u,d,f)),a.activeTexture.set(l.TEXTURE0),_.bind(c.stepInterpolant?l.NEAREST:l.LINEAR,l.CLAMP_TO_EDGE)}function On(e,s,a,l,c,u,d,f,_){const y=u.gradients[c.id];let b=y.texture;c.gradientVersion!==y.version&&(b=zn(e,s,a,l,c,u,d,y)),a.activeTexture.set(l.TEXTURE0),b.bind(c.stepInterpolant?l.NEAREST:l.LINEAR,l.CLAMP_TO_EDGE),a.activeTexture.set(l.TEXTURE1),e.lineAtlas.bind(a),f.updatePaintBuffers(_)}function Vn(e,s,a,l,c){if(!a||!l||!l.imageAtlas)return;const u=l.imageAtlas.patternPositions;let d=u[a.to.toString()],f=u[a.from.toString()];if(!d&&f&&(d=f),!f&&d&&(f=d),!d||!f){const e=c.getPaintProperty(s);d=u[e],f=u[e]}d&&f&&e.setConstantPatternPositions(d,f)}function Nn(e,s,l,c,u,d,f,_){const y=e.context.gl,b="fill-pattern",S=l.paint.get(b),P=S&&S.constantOr(1),M=l.getCrossfadeParameters();let C,D,L,F,B;const O=e.transform,V=l.paint.get("fill-translate"),N=l.paint.get("fill-translate-anchor");f?(D=P&&!l.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",C=y.LINES):(D=P?"fillPattern":"fill",C=y.TRIANGLES);const j=S.constantOr(null);for(const S of c){const c=s.getTile(S);if(P&&!c.patternsLoaded())continue;const G=c.getBucket(l);if(!G)continue;const Z=G.programConfigurations.get(l.id),q=e.useProgram(D,Z),W=e.style.map.terrain&&e.style.map.terrain.getTerrainData(S);P&&(e.context.activeTexture.set(y.TEXTURE0),c.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),Z.updatePaintBuffers(M)),Vn(Z,b,j,c,l);const J=O.getProjectionData({overscaledTileID:S,applyGlobeMatrix:!_,applyTerrainMatrix:!0}),Q=a.aI(O,c,V,N);if(f){F=G.indexBuffer2,B=G.segments2;const s=[y.drawingBufferWidth,y.drawingBufferHeight];L="fillOutlinePattern"===D&&P?Rr(e,M,c,s,Q):zr(s,Q)}else F=G.indexBuffer,B=G.segments,L=P?Dr(e,M,c,Q):{u_fill_translate:Q};const se=e.stencilModeForClipping(S);q.draw(e.context,C,u,se,d,Ht.backCCW,L,W,J,l.id,G.layoutVertexBuffer,F,B,l.paint,e.transform.zoom,Z)}}function jn(e,s,l,c,u,d,f,_){const y=e.context,b=y.gl,S="fill-extrusion-pattern",P=l.paint.get(S),M=P.constantOr(1),C=l.getCrossfadeParameters(),D=l.paint.get("fill-extrusion-opacity"),L=P.constantOr(null),F=e.transform;for(const P of c){const c=s.getTile(P),B=c.getBucket(l);if(!B)continue;const O=e.style.map.terrain&&e.style.map.terrain.getTerrainData(P),V=B.programConfigurations.get(l.id),N=e.useProgram(M?"fillExtrusionPattern":"fillExtrusion",V);M&&(e.context.activeTexture.set(b.TEXTURE0),c.imageAtlasTexture.bind(b.LINEAR,b.CLAMP_TO_EDGE),V.updatePaintBuffers(C));const j=F.getProjectionData({overscaledTileID:P,applyGlobeMatrix:!_,applyTerrainMatrix:!0});Vn(V,S,L,c,l);const G=a.aI(F,c,l.paint.get("fill-extrusion-translate"),l.paint.get("fill-extrusion-translate-anchor")),Z=l.paint.get("fill-extrusion-vertical-gradient"),q=M?Ar(e,Z,D,G,P,C,c):Cr(e,Z,D,G);N.draw(y,y.gl.TRIANGLES,u,d,f,Ht.backCCW,q,O,j,l.id,B.layoutVertexBuffer,B.indexBuffer,B.segments,l.paint,e.transform.zoom,V,e.style.map.terrain&&B.centroidVertexBuffer)}}function Un(e,s,a,l,c,u,d,f,_){var y;const b=e.style.projection,S=e.context,P=e.transform,M=S.gl,C=[`#define NUM_ILLUMINATION_SOURCES ${a.paint.get("hillshade-highlight-color").values.length}`],D=e.useProgram("hillshade",null,!1,C),L=!e.options.moving;for(const C of l){const l=s.getTile(C),F=l.fbo;if(!F)continue;const B=b.getMeshFromTileID(S,C.canonical,f,!0,"raster"),O=null===(y=e.style.map.terrain)||void 0===y?void 0:y.getTerrainData(C);S.activeTexture.set(M.TEXTURE0),M.bindTexture(M.TEXTURE_2D,F.colorAttachment.get());const V=P.getProjectionData({overscaledTileID:C,aligned:L,applyGlobeMatrix:!_,applyTerrainMatrix:!0});D.draw(S,M.TRIANGLES,u,c[C.overscaledZ],d,Ht.backCCW,Gr(e,l,a),O,V,a.id,B.vertexBuffer,B.indexBuffer,B.segments)}}function Gn(e,s,l,c,u,d,f,_,y){var b;const S=e.style.projection,P=e.context,M=e.transform,C=P.gl,D=e.useProgram("colorRelief"),L=!e.options.moving;let F=!0,B=0;for(const O of c){const c=s.getTile(O),V=c.dem;if(F){const e=C.getParameter(C.MAX_TEXTURE_SIZE),{elevationTexture:s,colorTexture:a}=l.getColorRampTextures(P,e,V.getUnpackVector());P.activeTexture.set(C.TEXTURE1),s.bind(C.NEAREST,C.CLAMP_TO_EDGE),P.activeTexture.set(C.TEXTURE4),a.bind(C.LINEAR,C.CLAMP_TO_EDGE),F=!1,B=s.size[0]}if(!V||!V.data)continue;const N=V.stride,j=V.getPixels();if(P.activeTexture.set(C.TEXTURE0),P.pixelStoreUnpackPremultiplyAlpha.set(!1),c.demTexture=c.demTexture||e.getTileTexture(N),c.demTexture){const e=c.demTexture;e.update(j,{premultiply:!1}),e.bind(C.LINEAR,C.CLAMP_TO_EDGE)}else c.demTexture=new a.T(P,j,C.RGBA,{premultiply:!1}),c.demTexture.bind(C.LINEAR,C.CLAMP_TO_EDGE);const G=S.getMeshFromTileID(P,O.canonical,_,!0,"raster"),Z=null===(b=e.style.map.terrain)||void 0===b?void 0:b.getTerrainData(O),q=M.getProjectionData({overscaledTileID:O,aligned:L,applyGlobeMatrix:!y,applyTerrainMatrix:!0});D.draw(P,C.TRIANGLES,d,u[O.overscaledZ],f,Ht.backCCW,Wr(l,c.dem,B),Z,q,l.id,G.vertexBuffer,G.indexBuffer,G.segments)}}const Zn=[new a.P(0,0),new a.P(a.a3,0),new a.P(a.a3,a.a3),new a.P(0,a.a3)];function qn(e,s,a,l,c,u,d,f,_=!1,y=!1){const b=l[l.length-1].overscaledZ,S=e.context,P=S.gl,M=e.useProgram("raster"),C=e.transform,D=e.style.projection,L=e.colorModeForRenderPass(),F=!e.options.moving,B=a.paint.get("raster-opacity"),O=a.paint.get("raster-resampling"),V=a.paint.get("raster-fade-duration"),N=!!e.style.map.terrain;for(const j of l){const l=e.getDepthModeForSublayer(j.overscaledZ-b,1===B?Xt.ReadWrite:Xt.ReadOnly,P.LESS),G=s.getTile(j),Z="nearest"===O?P.NEAREST:P.LINEAR;S.activeTexture.set(P.TEXTURE0),G.texture.bind(Z,P.CLAMP_TO_EDGE,P.LINEAR_MIPMAP_NEAREST),S.activeTexture.set(P.TEXTURE1);const{parentTile:q,parentScaleBy:W,parentTopLeft:J,fadeValues:Q}=$n(G,s,V,N);G.fadeOpacity=Q.tileOpacity,q?(q.fadeOpacity=Q.parentTileOpacity,q.texture.bind(Z,P.CLAMP_TO_EDGE,P.LINEAR_MIPMAP_NEAREST)):G.texture.bind(Z,P.CLAMP_TO_EDGE,P.LINEAR_MIPMAP_NEAREST),G.texture.useMipmap&&S.extTextureFilterAnisotropic&&e.transform.pitch>20&&P.texParameterf(P.TEXTURE_2D,S.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,S.extTextureFilterAnisotropicMax);const se=e.style.map.terrain&&e.style.map.terrain.getTerrainData(j),oe=C.getProjectionData({overscaledTileID:j,aligned:F,applyGlobeMatrix:!y,applyTerrainMatrix:!0}),ce=on(J,W,Q.fadeMix,a,f),pe=D.getMeshFromTileID(S,j.canonical,u,d,"raster");M.draw(S,P.TRIANGLES,l,c?c[j.overscaledZ]:Yt.disabled,L,_?Ht.frontCCW:Ht.backCCW,ce,se,oe,a.id,pe.vertexBuffer,pe.indexBuffer,pe.segments)}}function $n(e,s,l,c){const u={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(0===l||c)return u;if(e.fadingParentID){const c=s.getLoadedTile(e.fadingParentID);if(!c)return u;const d=Math.pow(2,c.tileID.overscaledZ-e.tileID.overscaledZ),f=[e.tileID.canonical.x*d%1,e.tileID.canonical.y*d%1],_=function(e,s,l){const c=b(),u=(c-s.timeAdded)/l,d=e.fadingDirection===Fe.Incoming,f=a.ai((c-e.timeAdded)/l,0,1),_=a.ai(1-u,0,1),y=d?f:_;return{tileOpacity:y,parentTileOpacity:d?_:f,fadeMix:{opacity:1,mix:1-y}}}(e,c,l);return{parentTile:c,parentScaleBy:d,parentTopLeft:f,fadeValues:_}}if(e.selfFading){const s=function(e,s){const l=(b()-e.timeAdded)/s,c=a.ai(l,0,1);return{tileOpacity:c,fadeMix:{opacity:c,mix:0}}}(e,l);return{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:s}}return u}const Wn=new a.bj(1,0,0,1),Hn=new a.bj(0,1,0,1),Xn=new a.bj(0,0,1,1),Yn=new a.bj(1,0,1,1),Kn=new a.bj(0,1,1,1);function Jn(e,s,a,l){es(e,0,s+a/2,e.transform.width,a,l)}function Qn(e,s,a,l){es(e,s-a/2,0,a,e.transform.height,l)}function es(e,s,a,l,c,u){const d=e.context,f=d.gl;f.enable(f.SCISSOR_TEST),f.scissor(s*e.pixelRatio,a*e.pixelRatio,l*e.pixelRatio,c*e.pixelRatio),d.clear({color:u}),f.disable(f.SCISSOR_TEST)}function ts(e,s,l){const c=e.context,u=c.gl,d=e.useProgram("debug"),f=Xt.disabled,_=Yt.disabled,y=e.colorModeForRenderPass(),b="$debug",S=e.style.map.terrain&&e.style.map.terrain.getTerrainData(l);c.activeTexture.set(u.TEXTURE0);const P=s.getTileByID(l.key).latestRawTileData,M=Math.floor((P&&P.byteLength||0)/1024),C=s.getTile(l).tileSize,D=512/Math.min(C,512)*(l.overscaledZ/e.transform.zoom)*.5;let L=l.canonical.toString();l.overscaledZ!==l.canonical.z&&(L+=` => ${l.overscaledZ}`),function(e,s){e.initDebugOverlayCanvas();const a=e.debugOverlayCanvas,l=e.context.gl,c=e.debugOverlayCanvas.getContext("2d");c.clearRect(0,0,a.width,a.height),c.shadowColor="white",c.shadowBlur=2,c.lineWidth=1.5,c.strokeStyle="white",c.textBaseline="top",c.font="bold 36px Open Sans, sans-serif",c.fillText(s,5,5),c.strokeText(s,5,5),e.debugOverlayTexture.update(a),e.debugOverlayTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE)}(e,`${L} ${M}kB`);const F=e.transform.getProjectionData({overscaledTileID:l,applyGlobeMatrix:!0,applyTerrainMatrix:!0});d.draw(c,u.TRIANGLES,f,_,qt.alphaBlended,Ht.disabled,Or(a.bj.transparent,D),null,F,b,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),d.draw(c,u.LINE_STRIP,f,_,y,Ht.disabled,Or(a.bj.red),S,F,b,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function is(e,s,a,l){const{isRenderingGlobe:c}=l,u=e.context,d=u.gl,f=e.transform,_=e.colorModeForRenderPass(),y=e.getDepthModeFor3D(),b=e.useProgram("terrain");u.bindFramebuffer.set(null),u.viewport.set([0,0,e.width,e.height]);for(const l of a){const a=s.getTerrainMesh(l.tileID),S=e.renderToTexture.getTexture(l),P=s.getTerrainData(l.tileID);u.activeTexture.set(d.TEXTURE0),d.bindTexture(d.TEXTURE_2D,S.texture);const M=s.getMeshFrameDelta(f.zoom),C=f.calculateFogMatrix(l.tileID.toUnwrapped()),D=br(M,C,e.style.sky,f.pitch,c),L=f.getProjectionData({overscaledTileID:l.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});b.draw(u,d.TRIANGLES,y,Yt.disabled,_,Ht.backCCW,D,P,L,"terrain",a.vertexBuffer,a.indexBuffer,a.segments)}}function ns(e,s){if(!s.mesh){const l=new a.aQ;l.emplaceBack(-1,-1),l.emplaceBack(1,-1),l.emplaceBack(1,1),l.emplaceBack(-1,1);const c=new a.aS;c.emplaceBack(0,1,2),c.emplaceBack(0,2,3),s.mesh=new St(e.createVertexBuffer(l,Li.members),e.createIndexBuffer(c),a.aR.simpleSegment(0,0,l.length,c.length))}return s.mesh}class jr{constructor(e,s){this.context=new tr(e),this.transform=s,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:a.am(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Ie.maxUnderzooming+Ie.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Mt}resize(e,s,a){if(this.width=Math.floor(e*a),this.height=Math.floor(s*a),this.pixelRatio=a,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style._order)this.style._layers[e].resize()}setup(){const e=this.context,s=new a.aQ;s.emplaceBack(0,0),s.emplaceBack(a.a3,0),s.emplaceBack(0,a.a3),s.emplaceBack(a.a3,a.a3),this.tileExtentBuffer=e.createVertexBuffer(s,Li.members),this.tileExtentSegments=a.aR.simpleSegment(0,0,4,2);const l=new a.aQ;l.emplaceBack(0,0),l.emplaceBack(a.a3,0),l.emplaceBack(0,a.a3),l.emplaceBack(a.a3,a.a3),this.debugBuffer=e.createVertexBuffer(l,Li.members),this.debugSegments=a.aR.simpleSegment(0,0,4,5);const c=new a.cb;c.emplaceBack(0,0,0,0),c.emplaceBack(a.a3,0,a.a3,0),c.emplaceBack(0,a.a3,0,a.a3),c.emplaceBack(a.a3,a.a3,a.a3,a.a3),this.rasterBoundsBuffer=e.createVertexBuffer(c,vr.members),this.rasterBoundsSegments=a.aR.simpleSegment(0,0,4,2);const u=new a.aQ;u.emplaceBack(0,0),u.emplaceBack(a.a3,0),u.emplaceBack(0,a.a3),u.emplaceBack(a.a3,a.a3),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(u,Li.members),this.rasterBoundsSegmentsPosOnly=a.aR.simpleSegment(0,0,4,5);const d=new a.aQ;d.emplaceBack(0,0),d.emplaceBack(1,0),d.emplaceBack(0,1),d.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(d,Li.members),this.viewportSegments=a.aR.simpleSegment(0,0,4,2);const f=new a.cc;f.emplaceBack(0),f.emplaceBack(1),f.emplaceBack(3),f.emplaceBack(2),f.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(f);const _=new a.aS;_.emplaceBack(1,0,2),_.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(_);const y=this.context.gl;this.stencilClearMode=new Yt({func:y.ALWAYS,mask:0},0,255,y.ZERO,y.ZERO,y.ZERO),this.tileExtentMesh=new St(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const e=this.context,s=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const l=a.M();a.c1(l,0,this.width,this.height,0,0,1),a.O(l,l,[s.drawingBufferWidth,s.drawingBufferHeight,0]);const c={mainMatrix:l,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:l};this.useProgram("clippingMask",null,!0).draw(e,s.TRIANGLES,Xt.disabled,this.stencilClearMode,qt.disabled,Ht.disabled,null,null,c,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,s,a){if(this.currentStencilSource===e.source||!e.isTileClipped()||!s||!s.length)return;this.currentStencilSource=e.source,this.nextStencilID+s.length>256&&this.clearStencil();const l=this.context;l.setColorMode(qt.disabled),l.setDepthMode(Xt.disabled);const c={};for(const e of s)c[e.key]=this.nextStencilID++;this._renderTileMasks(c,s,a,!0),this._renderTileMasks(c,s,a,!1),this._tileClippingMaskIDs=c}_renderTileMasks(e,s,a,l){const c=this.context,u=c.gl,d=this.style.projection,f=this.transform,_=this.useProgram("clippingMask");for(const y of s){const s=e[y.key],b=this.style.map.terrain&&this.style.map.terrain.getTerrainData(y),S=d.getMeshFromTileID(this.context,y.canonical,l,!0,"stencil"),P=f.getProjectionData({overscaledTileID:y,applyGlobeMatrix:!a,applyTerrainMatrix:!0});_.draw(c,u.TRIANGLES,Xt.disabled,new Yt({func:u.ALWAYS,mask:0},s,255,u.KEEP,u.KEEP,u.REPLACE),qt.disabled,a?Ht.disabled:Ht.backCCW,null,b,P,"$clipping",S.vertexBuffer,S.indexBuffer,S.segments)}}_renderTilesDepthBuffer(){const e=this.context,s=e.gl,a=this.style.projection,l=this.transform,c=this.useProgram("depth"),u=this.getDepthModeFor3D(),d=Xe(l,{tileSize:l.tileSize});for(const f of d){const d=this.style.map.terrain&&this.style.map.terrain.getTerrainData(f),_=a.getMeshFromTileID(this.context,f.canonical,!0,!0,"raster"),y=l.getProjectionData({overscaledTileID:f,applyGlobeMatrix:!0,applyTerrainMatrix:!0});c.draw(e,s.TRIANGLES,u,Yt.disabled,qt.disabled,Ht.backCCW,null,d,y,"$clipping",_.vertexBuffer,_.indexBuffer,_.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,s=this.context.gl;return new Yt({func:s.NOTEQUAL,mask:255},e,255,s.KEEP,s.KEEP,s.REPLACE)}stencilModeForClipping(e){const s=this.context.gl;return new Yt({func:s.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,s.KEEP,s.KEEP,s.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const s=this.context.gl,a=e.sort(((e,s)=>s.overscaledZ-e.overscaledZ)),l=a[a.length-1].overscaledZ,c=a[0].overscaledZ-l+1;if(c>1){this.currentStencilSource=void 0,this.nextStencilID+c>256&&this.clearStencil();const e={};for(let a=0;a<c;a++)e[a+l]=new Yt({func:s.GEQUAL,mask:255},a+this.nextStencilID,255,s.KEEP,s.KEEP,s.REPLACE);return this.nextStencilID+=c,[e,a]}return[{[l]:Yt.disabled},a]}stencilConfigForOverlapTwoPass(e){const s=this.context.gl,a=e.sort(((e,s)=>s.overscaledZ-e.overscaledZ)),l=a[a.length-1].overscaledZ,c=a[0].overscaledZ-l+1;if(this.clearStencil(),c>1){const e={},u={};for(let a=0;a<c;a++)e[a+l]=new Yt({func:s.GREATER,mask:255},c+1+a,255,s.KEEP,s.KEEP,s.REPLACE),u[a+l]=new Yt({func:s.GREATER,mask:255},1+a,255,s.KEEP,s.KEEP,s.REPLACE);return this.nextStencilID=2*c+1,[e,u,a]}return this.nextStencilID=3,[{[l]:new Yt({func:s.GREATER,mask:255},2,255,s.KEEP,s.KEEP,s.REPLACE)},{[l]:new Yt({func:s.GREATER,mask:255},1,255,s.KEEP,s.KEEP,s.REPLACE)},a]}colorModeForRenderPass(){const e=this.context.gl;if(this._showOverdrawInspector){const s=1/8;return new qt([e.CONSTANT_COLOR,e.ONE],new a.bj(s,s,s,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?qt.unblended:qt.alphaBlended}getDepthModeForSublayer(e,s,a){if(!this.opaquePassEnabledForLayer())return Xt.disabled;const l=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new Xt(a||this.context.gl.LEQUAL,s,[l,l])}getDepthModeFor3D(){return new Xt(this.context.gl.LEQUAL,Xt.ReadWrite,this.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(e,s){var l,c;this.style=e,this.options=s,this.lineAtlas=e.lineAtlas,this.imageManager=e.imageManager,this.glyphManager=e.glyphManager,this.symbolFadeChange=e.placement.symbolFadeChange(b()),this.imageManager.beginFrame();const u=this.style._order,d=this.style.tileManagers,f={},_={},y={},S={isRenderingToTexture:!1,isRenderingGlobe:(null===(l=e.projection)||void 0===l?void 0:l.transitionState)>0};for(const e in d){const s=d[e];s.used&&s.prepare(this.context),f[e]=s.getVisibleCoordinates(!1),_[e]=f[e].slice().reverse(),y[e]=s.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let e=0;e<u.length;e++)if(this.style._layers[u[e]].is3D()){this.opaquePassCutoff=e;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const e of u){const s=this.style._layers[e];if(!s.hasOffscreenPass()||s.isHidden(this.transform.zoom))continue;const a=_[s.source];("custom"===s.type||a.length)&&this.renderLayer(this,d[s.source],s,a,S)}if(null===(c=this.style.projection)||void 0===c||c.updateGPUdependent({context:this.context,useProgram:e=>this.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:s.showOverdrawInspector?a.bj.black:a.bj.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(e,s){const a=e.context,l=a.gl,c=((e,s,a)=>{const l=Math.cos(s.rollInRadians),c=Math.sin(s.rollInRadians),u=je(s),d=s.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(s.width/2-u*c)*a,(s.height/2+u*l)*a],u_horizon_normal:[-c,l],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*s.height/2*a,u_sky_blend:d}})(s,e.style.map.transform,e.pixelRatio),u=new Xt(l.LEQUAL,Xt.ReadWrite,[0,1]),d=Yt.disabled,f=e.colorModeForRenderPass(),_=e.useProgram("sky"),y=ns(a,s);_.draw(a,l.TRIANGLES,u,d,f,Ht.disabled,c,null,void 0,"sky",y.vertexBuffer,y.indexBuffer,y.segments)}(this,this.style.sky),this._showOverdrawInspector=s.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=u.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[u[this.currentLayer]],s=d[e.source],a=f[e.source];this._renderTileClippingMasks(e,a,!1),this.renderLayer(this,s,e,a,S)}this.renderPass="translucent";let P=!1;for(this.currentLayer=0;this.currentLayer<u.length;this.currentLayer++){const e=this.style._layers[u[this.currentLayer]],s=d[e.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(e,S))continue;this.opaquePassEnabledForLayer()||P||(P=!0,S.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());const a=("symbol"===e.type?y:_)[e.source];this._renderTileClippingMasks(e,f[e.source],!!this.renderToTexture),this.renderLayer(this,s,e,a,S)}if(S.isRenderingGlobe&&function(e,s,l){const c=e.context,u=c.gl,d=e.useProgram("atmosphere"),f=new Xt(u.LEQUAL,Xt.ReadOnly,[0,1]),_=e.transform,y=function(e,s){const l=e.properties.get("position"),c=[-l.x,-l.y,-l.z],u=a.am(new Float64Array(16));return"map"===e.properties.get("anchor")&&(a.ba(u,u,s.rollInRadians),a.bb(u,u,-s.pitchInRadians),a.ba(u,u,s.bearingInRadians),a.bb(u,u,s.center.lat*Math.PI/180),a.bD(u,u,-s.center.lng*Math.PI/180)),a.ca(c,c,u),c}(l,e.transform),b=_.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),S=s.properties.get("atmosphere-blend")*b.projectionTransition;if(0===S)return;const P=sr(_.worldSize,_.center.lat),M=_.inverseProjectionMatrix,C=new Float64Array(4);C[3]=1,a.aB(C,C,_.modelViewProjectionMatrix),C[0]/=C[3],C[1]/=C[3],C[2]/=C[3],C[3]=1,a.aB(C,C,M),C[0]/=C[3],C[1]/=C[3],C[2]/=C[3],C[3]=1;const D=((e,s,a,l,c)=>({u_sun_pos:e,u_atmosphere_blend:s,u_globe_position:a,u_globe_radius:l,u_inv_proj_matrix:c}))(y,S,[C[0],C[1],C[2]],P,M),L=ns(c,s);d.draw(c,u.TRIANGLES,f,Yt.disabled,qt.alphaBlended,Ht.disabled,D,null,null,"atmosphere",L.vertexBuffer,L.indexBuffer,L.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const e=function(e,s){let a=null;const l=Object.values(e._layers).flatMap((a=>a.source&&!a.isHidden(s)?[e.tileManagers[a.source]]:[])),c=l.filter((e=>"vector"===e.getSource().type)),u=l.filter((e=>"vector"!==e.getSource().type)),d=e=>{(!a||a.getSource().maxzoom<e.getSource().maxzoom)&&(a=e)};return c.forEach((e=>d(e))),a||u.forEach((e=>d(e))),a}(this.style,this.transform.zoom);e&&function(e,s,a){for(let l=0;l<a.length;l++)ts(e,s,a[l])}(this,e,e.getVisibleCoordinates())}this.options.showPadding&&function(e){const s=e.transform.padding;Jn(e,e.transform.height-(s.top||0),3,Wn),Jn(e,s.bottom||0,3,Hn),Qn(e,s.left||0,3,Xn),Qn(e,e.transform.width-(s.right||0),3,Yn);const a=e.transform.centerPoint;!function(e,s,a,l){es(e,s-1,a-10,2,20,l),es(e,s-10,a-1,20,2,l)}(e,a.x,e.transform.height-a.y,Kn)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(e){if(!this.style||!this.style.map||!this.style.map.terrain)return;const s=this.terrainFacilitator.matrix,l=this.transform.modelViewProjectionMatrix;let c=this.terrainFacilitator.dirty;c||(c=e?!a.cd(s,l):!a.ce(s,l)),c||(c=this.style.map.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime)),c&&(a.cf(s,l),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(e,s){const l=e.context,c=l.gl,u=e.transform,d=qt.unblended,f=new Xt(c.LEQUAL,Xt.ReadWrite,[0,1]),_=s.tileManager.getRenderableTiles(),y=e.useProgram("terrainDepth");l.bindFramebuffer.set(s.getFramebuffer("depth").framebuffer),l.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),l.clear({color:a.bj.transparent,depth:1});for(const e of _){const a=s.getTerrainMesh(e.tileID),_=s.getTerrainData(e.tileID),b=u.getProjectionData({overscaledTileID:e.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),S={u_ele_delta:s.getMeshFrameDelta(u.zoom)};y.draw(l,c.TRIANGLES,f,Yt.disabled,d,Ht.backCCW,S,_,b,"terrain",a.vertexBuffer,a.indexBuffer,a.segments)}l.bindFramebuffer.set(null),l.viewport.set([0,0,e.width,e.height])}(this,this.style.map.terrain),function(e,s){const l=e.context,c=l.gl,u=e.transform,d=qt.unblended,f=new Xt(c.LEQUAL,Xt.ReadWrite,[0,1]),_=s.getCoordsTexture(),y=s.tileManager.getRenderableTiles(),b=e.useProgram("terrainCoords");l.bindFramebuffer.set(s.getFramebuffer("coords").framebuffer),l.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),l.clear({color:a.bj.transparent,depth:1}),s.coordsIndex=[];for(const e of y){const a=s.getTerrainMesh(e.tileID),y=s.getTerrainData(e.tileID);l.activeTexture.set(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,_.texture);const S={u_terrain_coords_id:(255-s.coordsIndex.length)/255,u_texture:0,u_ele_delta:s.getMeshFrameDelta(u.zoom)},P=u.getProjectionData({overscaledTileID:e.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});b.draw(l,c.TRIANGLES,f,Yt.disabled,d,Ht.backCCW,S,y,P,"terrain",a.vertexBuffer,a.indexBuffer,a.segments),s.coordsIndex.push(e.tileID.key)}l.bindFramebuffer.set(null),l.viewport.set([0,0,e.width,e.height])}(this,this.style.map.terrain))}renderLayer(e,s,l,c,u){l.isHidden(this.transform.zoom)||("background"===l.type||"custom"===l.type||(c||[]).length)&&(this.id=l.id,a.cg(l)?function(e,s,l,c,u,d){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:f}=d,_=Yt.disabled,y=e.colorModeForRenderPass();(l._unevaluatedLayout.hasValue("text-variable-anchor")||l._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(e,s,l,c,u,d,f,_,y){const b=s.transform,S=s.style.map.terrain,P="map"===u,M="map"===d;for(const u of e){const e=c.getTile(u),d=e.getBucket(l);if(!d||!d.text||!d.text.segments.get().length)continue;const C=a.as(d.textSizeData,b.zoom),D=a.aH(e,1,s.transform.zoom),L=et(P,s.transform,D),F="none"!==l.layout.get("icon-text-fit")&&d.hasIconData();if(C){const s=Math.pow(2,b.zoom-e.tileID.overscaledZ),l=S?(e,s)=>S.getElevation(u,e,s):null;Tn(d,P,M,y,b,L,s,C,F,a.aI(b,e,f,_),u.toUnwrapped(),l)}}}(c,e,l,s,l.layout.get("text-rotation-alignment"),l.layout.get("text-pitch-alignment"),l.paint.get("text-translate"),l.paint.get("text-translate-anchor"),u),0!==l.paint.get("icon-opacity").constantOr(1)&&Pn(e,s,l,c,!1,l.paint.get("icon-translate"),l.paint.get("icon-translate-anchor"),l.layout.get("icon-rotation-alignment"),l.layout.get("icon-pitch-alignment"),l.layout.get("icon-keep-upright"),_,y,f),0!==l.paint.get("text-opacity").constantOr(1)&&Pn(e,s,l,c,!0,l.paint.get("text-translate"),l.paint.get("text-translate-anchor"),l.layout.get("text-rotation-alignment"),l.layout.get("text-pitch-alignment"),l.layout.get("text-keep-upright"),_,y,f),s.map.showCollisionBoxes&&(xn(e,s,l,c,!0),xn(e,s,l,c,!1))}(e,s,l,c,this.style.placement.variableOffsets,u):a.ch(l)?function(e,s,l,c,u){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:d}=u,f=l.paint.get("circle-opacity"),_=l.paint.get("circle-stroke-width"),y=l.paint.get("circle-stroke-opacity"),b=!l.layout.get("circle-sort-key").isConstant();if(0===f.constantOr(1)&&(0===_.constantOr(1)||0===y.constantOr(1)))return;const S=e.context,P=S.gl,M=e.transform,C=e.getDepthModeForSublayer(0,Xt.ReadOnly),D=Yt.disabled,L=e.colorModeForRenderPass(),F=[],B=M.getCircleRadiusCorrection();for(let u=0;u<c.length;u++){const f=c[u],_=s.getTile(f),y=_.getBucket(l);if(!y)continue;const S=l.paint.get("circle-translate"),P=l.paint.get("circle-translate-anchor"),C=a.aI(M,_,S,P),D=y.programConfigurations.get(l.id),L=e.useProgram("circle",D),O=y.layoutVertexBuffer,V=y.indexBuffer,N=e.style.map.terrain&&e.style.map.terrain.getTerrainData(f),j={programConfiguration:D,program:L,layoutVertexBuffer:O,indexBuffer:V,uniformValues:Lr(e,_,l,C,B),terrainData:N,projectionData:M.getProjectionData({overscaledTileID:f,applyGlobeMatrix:!d,applyTerrainMatrix:!0})};if(b){const e=y.segments.get();for(const s of e)F.push({segments:new a.aR([s]),sortKey:s.sortKey,state:j})}else F.push({segments:y.segments,sortKey:0,state:j})}b&&F.sort(((e,s)=>e.sortKey-s.sortKey));for(const s of F){const{programConfiguration:a,program:c,layoutVertexBuffer:u,indexBuffer:d,uniformValues:f,terrainData:_,projectionData:y}=s.state;c.draw(S,P.TRIANGLES,C,D,L,Ht.backCCW,f,_,y,l.id,u,d,s.segments,l.paint,e.transform.zoom,a)}}(e,s,l,c,u):a.ci(l)?function(e,s,l,c,u){if(0===l.paint.get("heatmap-opacity"))return;const d=e.context,{isRenderingToTexture:f,isRenderingGlobe:_}=u;if(e.style.map.terrain){for(const a of c){const c=s.getTile(a);s.hasRenderableParent(a)||("offscreen"===e.renderPass?Mn(e,c,l,a,_):"translucent"===e.renderPass&&Cn(e,l,a,f,_))}d.viewport.set([0,0,e.width,e.height])}else"offscreen"===e.renderPass?function(e,s,l,c){const u=e.context,d=u.gl,f=e.transform,_=Yt.disabled,y=new qt([d.ONE,d.ONE],a.bj.transparent,[!0,!0,!0,!0]);(function(e,s,l){const c=e.gl;e.activeTexture.set(c.TEXTURE1),e.viewport.set([0,0,s.width/4,s.height/4]);let u=l.heatmapFbos.get(a.c7);u?(c.bindTexture(c.TEXTURE_2D,u.colorAttachment.get()),e.bindFramebuffer.set(u.framebuffer)):(u=An(e,s.width/4,s.height/4),l.heatmapFbos.set(a.c7,u))})(u,e,l),u.clear({color:a.bj.transparent});for(let a=0;a<c.length;a++){const b=c[a];if(s.hasRenderableParent(b))continue;const S=s.getTile(b),P=S.getBucket(l);if(!P)continue;const M=P.programConfigurations.get(l.id),C=e.useProgram("heatmap",M),D=f.getProjectionData({overscaledTileID:b,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),L=f.getCircleRadiusCorrection();C.draw(u,d.TRIANGLES,Xt.disabled,_,y,Ht.backCCW,Vr(S,f.zoom,l.paint.get("heatmap-intensity"),L),null,D,l.id,P.layoutVertexBuffer,P.indexBuffer,P.segments,l.paint,f.zoom,M)}u.viewport.set([0,0,e.width,e.height])}(e,s,l,c):"translucent"===e.renderPass&&function(e,s){const l=e.context,c=l.gl;l.setColorMode(e.colorModeForRenderPass());const u=s.heatmapFbos.get(a.c7);u&&(l.activeTexture.set(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,u.colorAttachment.get()),l.activeTexture.set(c.TEXTURE1),Dn(l,s).bind(c.LINEAR,c.CLAMP_TO_EDGE),e.useProgram("heatmapTexture").draw(l,c.TRIANGLES,Xt.disabled,Yt.disabled,e.colorModeForRenderPass(),Ht.disabled,Ur(e,s,0,1),null,null,s.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,s.paint,e.transform.zoom))}(e,l)}(e,s,l,c,u):a.cj(l)?function(e,s,a,l,c){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:u}=c,d=a.paint.get("line-opacity"),f=a.paint.get("line-width");if(0===d.constantOr(1)||0===f.constantOr(1))return;const _=e.getDepthModeForSublayer(0,Xt.ReadOnly),y=e.colorModeForRenderPass(),b=a.paint.get("line-dasharray"),S=b.constantOr(1),P=a.paint.get("line-pattern"),M=P.constantOr(1),C=a.paint.get("line-gradient"),D=a.getCrossfadeParameters();let L;L=M?"linePattern":S&&C?"lineGradientSDF":S?"lineSDF":C?"lineGradient":"line";const F=e.context,B=F.gl,O=e.transform;let V=!0;for(const c of l){const l=s.getTile(c);if(M&&!l.patternsLoaded())continue;const d=l.getBucket(a);if(!d)continue;const f=d.programConfigurations.get(a.id),N=e.context.program.get(),j=e.useProgram(L,f),G=V||j.program!==N,Z=e.style.map.terrain&&e.style.map.terrain.getTerrainData(c),q=P.constantOr(null),W=b&&b.constantOr(null);if(q&&l.imageAtlas){const e=l.imageAtlas,s=e.patternPositions[q.to.toString()],a=e.patternPositions[q.from.toString()];s&&a&&f.setConstantPatternPositions(s,a)}else if(W){const s="round"===a.layout.get("line-cap"),l=e.lineAtlas.getDash(W.to,s),c=e.lineAtlas.getDash(W.from,s);f.setConstantDashPositions(l,c)}const J=O.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!u,applyTerrainMatrix:!0}),Q=O.getPixelScale();let se;M?(se=en(e,l,a,Q,D),Rn(F,B,l,f,D)):S&&C?(se=rn(e,l,a,Q,D,d.lineClipsArray.length),On(e,s,F,B,a,d,c,f,D)):S?(se=tn(e,l,a,Q,D),Ln(e,F,B,f,G,D)):C?(se=Kr(e,l,a,Q,d.lineClipsArray.length),Bn(e,s,F,B,a,d,c)):se=Xr(e,l,a,Q);const oe=e.stencilModeForClipping(c);j.draw(F,B.TRIANGLES,_,oe,y,Ht.disabled,se,Z,J,a.id,d.layoutVertexBuffer,d.indexBuffer,d.segments,a.paint,e.transform.zoom,f,d.layoutVertexBuffer2),V=!1}}(e,s,l,c,u):a.ck(l)?function(e,s,l,c,u){const d=l.paint.get("fill-color"),f=l.paint.get("fill-opacity");if(0===f.constantOr(1))return;const{isRenderingToTexture:_}=u,y=e.colorModeForRenderPass(),b=l.paint.get("fill-pattern"),S=e.opaquePassEnabledForLayer()&&!b.constantOr(1)&&1===d.constantOr(a.bj.transparent).a&&1===f.constantOr(0)?"opaque":"translucent";if(e.renderPass===S){const a=e.getDepthModeForSublayer(1,"opaque"===e.renderPass?Xt.ReadWrite:Xt.ReadOnly);Nn(e,s,l,c,a,y,!1,_)}if("translucent"===e.renderPass&&l.paint.get("fill-antialias")){const a=e.getDepthModeForSublayer(l.getPaintProperty("fill-outline-color")?2:0,Xt.ReadOnly);Nn(e,s,l,c,a,y,!0,_)}}(e,s,l,c,u):a.cl(l)?function(e,s,a,l,c){const u=a.paint.get("fill-extrusion-opacity");if(0===u)return;const{isRenderingToTexture:d}=c;if("translucent"===e.renderPass){const c=new Xt(e.context.gl.LEQUAL,Xt.ReadWrite,e.depthRangeFor3D);if(1!==u||a.paint.get("fill-extrusion-pattern").constantOr(1))jn(e,s,a,l,c,Yt.disabled,qt.disabled,d),jn(e,s,a,l,c,e.stencilModeFor3D(),e.colorModeForRenderPass(),d);else{const u=e.colorModeForRenderPass();jn(e,s,a,l,c,Yt.disabled,u,d)}}}(e,s,l,c,u):a.cm(l)?function(e,s,l,c,u){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;const{isRenderingToTexture:d}=u,f=e.context,_=e.style.projection.useSubdivision,y=e.getDepthModeForSublayer(0,Xt.ReadOnly),b=e.colorModeForRenderPass();if("offscreen"===e.renderPass)!function(e,s,l,c,u,d,f){const _=e.context,y=_.gl;for(const b of l){const l=s.getTile(b),S=l.dem;if(!S||!S.data)continue;if(!l.needsHillshadePrepare)continue;const P=S.dim,M=S.stride,C=S.getPixels();if(_.activeTexture.set(y.TEXTURE1),_.pixelStoreUnpackPremultiplyAlpha.set(!1),l.demTexture=l.demTexture||e.getTileTexture(M),l.demTexture){const e=l.demTexture;e.update(C,{premultiply:!1}),e.bind(y.NEAREST,y.CLAMP_TO_EDGE)}else l.demTexture=new a.T(_,C,y.RGBA,{premultiply:!1}),l.demTexture.bind(y.NEAREST,y.CLAMP_TO_EDGE);_.activeTexture.set(y.TEXTURE0);let D=l.fbo;if(!D){const e=new a.T(_,{width:P,height:P,data:null},y.RGBA);e.bind(y.LINEAR,y.CLAMP_TO_EDGE),D=l.fbo=_.createFramebuffer(P,P,!0,!1),D.colorAttachment.set(e.texture)}_.bindFramebuffer.set(D.framebuffer),_.viewport.set([0,0,P,P]),e.useProgram("hillshadePrepare").draw(_,y.TRIANGLES,u,d,f,Ht.disabled,qr(l.tileID,S),null,null,c.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments),l.needsHillshadePrepare=!1}}(e,s,c,l,y,Yt.disabled,b),f.viewport.set([0,0,e.width,e.height]);else if("translucent"===e.renderPass)if(_){const[a,u,f]=e.stencilConfigForOverlapTwoPass(c);Un(e,s,l,f,a,y,b,!1,d),Un(e,s,l,f,u,y,b,!0,d)}else{const[a,u]=e.getStencilConfigForOverlapAndUpdateStencilID(c);Un(e,s,l,u,a,y,b,!1,d)}}(e,s,l,c,u):a.cn(l)?function(e,s,a,l,c){if("translucent"!==e.renderPass)return;if(!l.length)return;const{isRenderingToTexture:u}=c,d=e.style.projection.useSubdivision,f=e.getDepthModeForSublayer(0,Xt.ReadOnly),_=e.colorModeForRenderPass();if(d){const[c,d,y]=e.stencilConfigForOverlapTwoPass(l);Gn(e,s,a,y,c,f,_,!1,u),Gn(e,s,a,y,d,f,_,!0,u)}else{const[c,d]=e.getStencilConfigForOverlapAndUpdateStencilID(l);Gn(e,s,a,d,c,f,_,!1,u)}}(e,s,l,c,u):a.bO(l)?function(e,s,a,l,c){if("translucent"!==e.renderPass)return;if(0===a.paint.get("raster-opacity"))return;if(!l.length)return;const{isRenderingToTexture:u}=c,d=s.getSource(),f=e.style.projection.useSubdivision;if(d instanceof te)qn(e,s,a,l,null,!1,!1,d.tileCoords,d.flippedWindingOrder,u);else if(f){const[c,d,f]=e.stencilConfigForOverlapTwoPass(l);qn(e,s,a,f,c,!1,!0,Zn,!1,u),qn(e,s,a,f,d,!0,!0,Zn,!1,u)}else{const[c,d]=e.getStencilConfigForOverlapAndUpdateStencilID(l);qn(e,s,a,d,c,!1,!0,Zn,!1,u)}}(e,s,l,c,u):a.co(l)?function(e,s,a,l,c){const u=a.paint.get("background-color"),d=a.paint.get("background-opacity");if(0===d)return;const{isRenderingToTexture:f}=c,_=e.context,y=_.gl,b=e.style.projection,S=e.transform,P=S.tileSize,M=a.paint.get("background-pattern");if(e.isPatternMissing(M))return;const C=!M&&1===u.a&&1===d&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(e.renderPass!==C)return;const D=Yt.disabled,L=e.getDepthModeForSublayer(0,"opaque"===C?Xt.ReadWrite:Xt.ReadOnly),F=e.colorModeForRenderPass(),B=e.useProgram(M?"backgroundPattern":"background"),O=l||Xe(S,{tileSize:P,terrain:e.style.map.terrain});M&&(_.activeTexture.set(y.TEXTURE0),e.imageManager.bind(e.context));const V=a.getCrossfadeParameters();for(const s of O){const l=S.getProjectionData({overscaledTileID:s,applyGlobeMatrix:!f,applyTerrainMatrix:!0}),c=M?pn(d,e,M,{tileID:s,tileSize:P},V):dn(d,u),C=e.style.map.terrain&&e.style.map.terrain.getTerrainData(s),O=b.getMeshFromTileID(_,s.canonical,!1,!0,"raster");B.draw(_,y.TRIANGLES,L,D,F,Ht.backCCW,c,C,l,a.id,O.vertexBuffer,O.indexBuffer,O.segments)}}(e,0,l,c,u):a.cp(l)&&function(e,s,a,l){const{isRenderingGlobe:c}=l,u=e.context,d=a.implementation,f=e.style.projection,_=e.transform,y=_.getProjectionDataForCustomLayer(c),b={farZ:_.farZ,nearZ:_.nearZ,fov:_.fov*Math.PI/180,modelViewProjectionMatrix:_.modelViewProjectionMatrix,projectionMatrix:_.projectionMatrix,shaderData:{variantName:f.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;\nuniform mat4 u_projection_matrix;\n${f.shaderPreludeCode.vertexSource}`,define:f.shaderDefine},defaultProjectionData:y},S=d.renderingMode?d.renderingMode:"2d";if("offscreen"===e.renderPass){const s=d.prerender;s&&(e.setCustomLayerDefaults(),u.setColorMode(e.colorModeForRenderPass()),s.call(d,u.gl,b),u.setDirty(),e.setBaseState())}else if("translucent"===e.renderPass){e.setCustomLayerDefaults(),u.setColorMode(e.colorModeForRenderPass()),u.setStencilMode(Yt.disabled);const s="3d"===S?e.getDepthModeFor3D():e.getDepthModeForSublayer(0,Xt.ReadOnly);u.setDepthMode(s),d.render(u.gl,b),u.setDirty(),e.setBaseState(),u.bindFramebuffer.set(null)}}(e,0,l,u))}saveTileTexture(e){const s=this._tileTextures[e.size[0]];s?s.push(e):this._tileTextures[e.size[0]]=[e]}getTileTexture(e){const s=this._tileTextures[e];return s&&s.length>0?s.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const s=this.imageManager.getPattern(e.from.toString()),a=this.imageManager.getPattern(e.to.toString());return!s||!a}useProgram(e,s,a=!1,l=[]){this.cache=this.cache||{};const c=!!this.style.map.terrain,u=this.style.projection,d=a?zi.projectionMercator:u.shaderPreludeCode,f=a?Fi:u.shaderDefine,_=e+(s?s.cacheKey:"")+`/${a?Bi:u.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(c?"/terrain":"")+(l?`/${l.join("/")}`:"");return this.cache[_]||(this.cache[_]=new ki(this.context,zi[e],s,mn[e],this._showOverdrawInspector,c,d,f,l)),this.cache[_]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new a.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){var e,s;if(this._tileTextures){for(const e in this._tileTextures){const s=this._tileTextures[e];if(s)for(const e of s)e.destroy()}this._tileTextures={}}if(this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&(null===(e=this.tileExtentMesh.vertexBuffer)||void 0===e||e.destroy()),this.tileExtentMesh&&(null===(s=this.tileExtentMesh.indexBuffer)||void 0===s||s.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(const e in this.cache){const s=this.cache[e];s&&s.program&&this.context.gl.deleteProgram(s.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:s}=this.context.gl;return this.width!==e||this.height!==s}}function ss(s,a){let l,c=!1,u=null,d=null;const f=()=>{u=null,c&&(s.apply(d,l),u=setTimeout(f,a),c=!1)};return(...s)=>(c=!0,d=this||e,l=s,u||f(),u)}class Nr{constructor(e){this._getCurrentHash=()=>{const e=window.location.hash.replace("#","");if(this._hashName){let s;return e.split("&").map((e=>e.split("="))).forEach((e=>{e[0]===this._hashName&&(s=e)})),(s&&s[1]||"").split("/")}return e.split("/")},this._onHashChange=()=>{const e=this._getCurrentHash();if(!this._isValidHash(e))return!1;const s=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:s,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{const e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e)},this._removeHash=()=>{const e=this._getCurrentHash();if(0===e.length)return;const s=e.join("/");let a=s;a.split("&").length>0&&(a=a.split("&")[0]),this._hashName&&(a=`${this._hashName}=${s}`);let l=window.location.hash.replace(a,"");l.startsWith("#&")?l=l.slice(0,1)+l.slice(2):"#"===l&&(l="");let c=window.location.href.replace(/(#.+)?$/,l);c=c.replace("&&","&"),window.history.replaceState(window.history.state,null,c)},this._updateHash=ss(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){const s=this._map.getCenter(),a=Math.round(100*this._map.getZoom())/100,l=Math.ceil((a*Math.LN2+Math.log(512/360/.5))/Math.LN10),c=Math.pow(10,l),u=Math.round(s.lng*c)/c,d=Math.round(s.lat*c)/c,f=this._map.getBearing(),_=this._map.getPitch();let y="";if(y+=e?`/${u}/${d}/${a}`:`${a}/${d}/${u}`,(f||_)&&(y+="/"+Math.round(10*f)/10),_&&(y+=`/${Math.round(_)}`),this._hashName){const e=this._hashName;let s=!1;const a=window.location.hash.slice(1).split("&").map((a=>{const l=a.split("=")[0];return l===e?(s=!0,`${l}=${y}`):a})).filter((e=>e));return s||a.push(`${e}=${y}`),`#${a.join("&")}`}return`#${y}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new a.U(+e[2],+e[1])}catch(e){return!1}const s=+e[0],l=+(e[3]||0),c=+(e[4]||0);return s>=this._map.getMinZoom()&&s<=this._map.getMaxZoom()&&l>=-180&&l<=180&&c>=this._map.getMinPitch()&&c<=this._map.getMaxPitch()}}const os={linearity:.3,easing:a.cq(0,0,.3,1)},ls=a.e({deceleration:2500,maxSpeed:1400},os),hs=a.e({deceleration:20,maxSpeed:1400},os),us=a.e({deceleration:1e3,maxSpeed:360},os),ps=a.e({deceleration:1e3,maxSpeed:90},os),fs=a.e({deceleration:1e3,maxSpeed:360},os);class Hr{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:b(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,s=b();for(;e.length>0&&s-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const s={zoom:0,bearing:0,pitch:0,roll:0,pan:new a.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)s.zoom+=e.zoomDelta||0,s.bearing+=e.bearingDelta||0,s.pitch+=e.pitchDelta||0,s.roll+=e.rollDelta||0,e.panDelta&&s.pan._add(e.panDelta),e.around&&(s.around=e.around),e.pinchAround&&(s.pinchAround=e.pinchAround);const l=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,c={};if(s.pan.mag()){const u=_s(s.pan.mag(),l,a.e({},ls,e||{})),d=s.pan.mult(u.amount/s.pan.mag()),f=this._map.cameraHelper.handlePanInertia(d,this._map.transform);c.center=f.easingCenter,c.offset=f.easingOffset,ms(c,u)}if(s.zoom){const e=_s(s.zoom,l,hs);c.zoom=this._map.transform.zoom+e.amount,ms(c,e)}if(s.bearing){const e=_s(s.bearing,l,us);c.bearing=this._map.transform.bearing+a.ai(e.amount,-179,179),ms(c,e)}if(s.pitch){const e=_s(s.pitch,l,ps);c.pitch=this._map.transform.pitch+e.amount,ms(c,e)}if(s.roll){const e=_s(s.roll,l,fs);c.roll=this._map.transform.roll+a.ai(e.amount,-179,179),ms(c,e)}if(c.zoom||c.bearing){const e=void 0===s.pinchAround?s.around:s.pinchAround;c.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),a.e(c,{noMoveStart:!0})}}function ms(e,s){(!e.duration||e.duration<s.duration)&&(e.duration=s.duration,e.easing=s.easing)}function _s(e,s,l){const{maxSpeed:c,linearity:u,deceleration:d}=l,f=a.ai(e*u/(s/1e3),-c,c),_=Math.abs(f)/(d*u);return{easing:l.easing,duration:1e3*_,amount:f*(_/2)}}class Yr extends a.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,s,l,c={}){l=l instanceof MouseEvent?l:new MouseEvent(e,l);const u=h.mousePos(s.getCanvas(),l),d=s.unproject(u);super(e,a.e({point:u,lngLat:d,originalEvent:l},c)),this._defaultPrevented=!1,this.target=s}}class Qr extends a.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,s,l){const c="touchend"===e?l.changedTouches:l.touches,u=h.touchPos(s.getCanvasContainer(),c),d=u.map((e=>s.unproject(e))),f=u.reduce(((e,s,a,l)=>e.add(s.div(l.length))),new a.P(0,0));super(e,{points:u,point:f,lngLats:d,lngLat:s.unproject(f),originalEvent:l}),this._defaultPrevented=!1}}class Jr extends a.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,s,a){super(e,{originalEvent:a}),this._defaultPrevented=!1}}class eo{constructor(e,s){this._map=e,this._clickTolerance=s.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new Jr(e.type,this._map,e))}mousedown(e,s){return this._mousedownPos=s,this._firePreventable(new Yr(e.type,this._map,e))}mouseup(e){this._map.fire(new Yr(e.type,this._map,e))}click(e,s){this._mousedownPos&&this._mousedownPos.dist(s)>=this._clickTolerance||this._map.fire(new Yr(e.type,this._map,e))}dblclick(e){return this._firePreventable(new Yr(e.type,this._map,e))}mouseover(e){this._map.fire(new Yr(e.type,this._map,e))}mouseout(e){this._map.fire(new Yr(e.type,this._map,e))}touchstart(e){return this._firePreventable(new Qr(e.type,this._map,e))}touchmove(e){this._map.fire(new Qr(e.type,this._map,e))}touchend(e){this._map.fire(new Qr(e.type,this._map,e))}touchcancel(e){this._map.fire(new Qr(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class to{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new Yr(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Yr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new Yr(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class io{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(a.P.convert(e),this._map.terrain)}}class ao{constructor(e,s){this._map=e,this._tr=new io(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=s.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,s){this.isEnabled()&&e.shiftKey&&0===e.button&&(h.disableDrag(),this._startPos=this._lastPos=s,this._active=!0)}mousemoveWindow(e,s){if(!this._active)return;const a=s;if(this._lastPos.equals(a)||!this._box&&a.dist(this._startPos)<this._clickTolerance)return;const l=this._startPos;this._lastPos=a,this._box||(this._box=h.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",e));const c=Math.min(l.x,a.x),u=Math.max(l.x,a.x),d=Math.min(l.y,a.y),f=Math.max(l.y,a.y);h.setTransform(this._box,`translate(${c}px,${d}px)`),this._box.style.width=u-c+"px",this._box.style.height=f-d+"px"}mouseupWindow(e,s){if(!this._active)return;if(0!==e.button)return;const l=this._startPos,c=s;if(this.reset(),h.suppressClick(),l.x!==c.x||l.y!==c.y)return this._map.fire(new a.l("boxzoomend",{originalEvent:e})),{cameraAnimation:e=>e.fitScreenCoordinates(l,c,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(h.remove(this._box),this._box=null),h.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,s){return this._map.fire(new a.l(e,{originalEvent:s}))}}function gs(e,s){if(e.length!==s.length)throw new Error(`The number of touches and points are not equal - touches ${e.length}, points ${s.length}`);const a={};for(let l=0;l<e.length;l++)a[e[l].identifier]=s[l];return a}class oo{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(e,s,l){(this.centroid||l.length>this.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),l.length===this.numTouches&&(this.centroid=function(e){const s=new a.P(0,0);for(const a of e)s._add(a);return s.div(e.length)}(s),this.touches=gs(l,s)))}touchmove(e,s,a){if(this.aborted||!this.centroid)return;const l=gs(a,s);for(const e in this.touches){const s=l[e];(!s||s.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,s,a){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===a.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class so{constructor(e){this.singleTap=new oo(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,s,a){this.singleTap.touchstart(e,s,a)}touchmove(e,s,a){this.singleTap.touchmove(e,s,a)}touchend(e,s,a){const l=this.singleTap.touchend(e,s,a);if(l){const s=e.timeStamp-this.lastTime<500,a=!this.lastTap||this.lastTap.dist(l)<30;if(s&&a||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=l,this.count===this.numTaps)return this.reset(),l}}}class no{constructor(e){this._tr=new io(e),this._zoomIn=new so({numTouches:1,numTaps:2}),this._zoomOut=new so({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,s,a){this._zoomIn.touchstart(e,s,a),this._zoomOut.touchstart(e,s,a)}touchmove(e,s,a){this._zoomIn.touchmove(e,s,a),this._zoomOut.touchmove(e,s,a)}touchend(e,s,a){const l=this._zoomIn.touchend(e,s,a),c=this._zoomOut.touchend(e,s,a),u=this._tr;return l?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:s=>s.easeTo({duration:300,zoom:u.zoom+1,around:u.unproject(l)},{originalEvent:e})}):c?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:s=>s.easeTo({duration:300,zoom:u.zoom-1,around:u.unproject(c)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class lo{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){const s=this._moveFunction(...e);if(s.bearingDelta||s.pitchDelta||s.rollDelta||s.around||s.panDelta)return this._active=!0,s}dragStart(e,s){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(s)?s[0]:s,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,s){if(!this.isEnabled())return;const a=this._lastPoint;if(!a)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const l=Array.isArray(s)?s[0]:s;return!this._moved&&l.dist(a)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=l,this._move(a,l))}dragEnd(e){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(e)&&(this._moved&&h.suppressClick(),this.reset(e))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}const ys=0,xs=2,vs={[ys]:1,[xs]:2};class _o{constructor(e){this._correctEvent=e.checkCorrectEvent}startMove(e){const s=h.mouseButton(e);this._eventButton=s}endMove(e){delete this._eventButton}isValidStartEvent(e){return this._correctEvent(e)}isValidMoveEvent(e){return!function(e,s){const a=vs[s];return void 0===e.buttons||(e.buttons&a)!==a}(e,this._eventButton)}isValidEndEvent(e){return h.mouseButton(e)===this._eventButton}}class po{constructor(){this._firstTouch=void 0}_isOneFingerTouch(e){return 1===e.targetTouches.length}_isSameTouchEvent(e){return e.targetTouches[0].identifier===this._firstTouch}startMove(e){this._firstTouch=e.targetTouches[0].identifier}endMove(e){delete this._firstTouch}isValidStartEvent(e){return this._isOneFingerTouch(e)}isValidMoveEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}isValidEndEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}}class mo{constructor(e=new _o({checkCorrectEvent:()=>!0}),s=new po){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=s}_executeRelevantHandler(e,s,a){return e instanceof MouseEvent?s(e):"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?a(e):void 0}startMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.startMove(e)),(e=>this.oneFingerTouchMoveStateManager.startMove(e)))}endMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.endMove(e)),(e=>this.oneFingerTouchMoveStateManager.endMove(e)))}isValidStartEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidStartEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e)))}isValidMoveEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidMoveEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e)))}isValidEndEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidEndEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e)))}}const bs=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};class go{constructor(e,s){this._clickTolerance=e.clickTolerance||1,this._map=s,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new a.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,s,a){return this._calculateTransform(e,s,a)}touchmove(e,s,a){if(this._active){if(!this._shouldBePrevented(a.length))return e.preventDefault(),this._calculateTransform(e,s,a);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,s,a){this._calculateTransform(e,s,a),this._active&&this._shouldBePrevented(a.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,s,l){l.length>0&&(this._active=!0);const c=gs(l,s),u=new a.P(0,0),d=new a.P(0,0);let f=0;for(const e in c){const s=c[e],a=this._touches[e];a&&(u._add(s),d._add(s.sub(a)),f++,c[e]=s)}if(this._touches=c,this._shouldBePrevented(f)||!d.mag())return;const _=d.div(f);return this._sum._add(_),this._sum.mag()<this._clickTolerance?void 0:{around:u.div(f),panDelta:_}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class vo{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(e,s,a){this._firstTwoTouches||a.length<2||(this._firstTwoTouches=[a[0].identifier,a[1].identifier],this._start([s[0],s[1]]))}touchmove(e,s,a){if(!this._firstTwoTouches)return;e.preventDefault();const[l,c]=this._firstTwoTouches,u=ws(a,s,l),d=ws(a,s,c);if(!u||!d)return;const f=this._aroundCenter?null:u.add(d).div(2);return this._move([u,d],f,e)}touchend(e,s,a){if(!this._firstTwoTouches)return;const[l,c]=this._firstTwoTouches,u=ws(a,s,l),d=ws(a,s,c);u&&d||(this._active&&h.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function ws(e,s,a){for(let l=0;l<e.length;l++)if(e[l].identifier===a)return s[l]}function Ts(e,s){return Math.log(e/s)/Math.LN2}class yo extends vo{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,s){const a=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(Ts(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Ts(this._distance,a),pinchAround:s}}}function Ss(e,s){return 180*e.angleWith(s)/Math.PI}class To extends vo{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,s,a){const l=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Ss(this._vector,l),pinchAround:s}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());const s=25/(Math.PI*this._minDiameter)*360,a=Ss(e,this._startVector);return Math.abs(a)<s}}function Is(e){return Math.abs(e.y)>Math.abs(e.x)}class Mo extends vo{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,s,a){super.touchstart(e,s,a),this._currentTouchCount=a.length}_start(e){this._lastPoints=e,Is(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,s,a){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const l=e[0].sub(this._lastPoints[0]),c=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(l,c,a.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(l.y+c.y)/2*-.5}):void 0}gestureBeginsVertically(e,s,a){if(void 0!==this._valid)return this._valid;const l=e.mag()>=2,c=s.mag()>=2;if(!l&&!c)return;if(!l||!c)return void 0===this._firstMove&&(this._firstMove=a),a-this._firstMove<100&&void 0;const u=e.y>0==s.y>0;return Is(e)&&Is(s)&&u}}const Ms={panStep:100,bearingStep:15,pitchStep:10};class Io{constructor(e){this._tr=new io(e);const s=Ms;this._panStep=s.panStep,this._bearingStep=s.bearingStep,this._pitchStep=s.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let s=0,a=0,l=0,c=0,u=0;switch(e.keyCode){case 61:case 107:case 171:case 187:s=1;break;case 189:case 109:case 173:s=-1;break;case 37:e.shiftKey?a=-1:(e.preventDefault(),c=-1);break;case 39:e.shiftKey?a=1:(e.preventDefault(),c=1);break;case 38:e.shiftKey?l=1:(e.preventDefault(),u=-1);break;case 40:e.shiftKey?l=-1:(e.preventDefault(),u=1);break;default:return}return this._rotationDisabled&&(a=0,l=0),{cameraAnimation:d=>{const f=this._tr;d.easeTo({duration:300,easeId:"keyboardHandler",easing:As,zoom:s?Math.round(f.zoom)+s*(e.shiftKey?2:1):f.zoom,bearing:f.bearing+a*this._bearingStep,pitch:f.pitch+l*this._pitchStep,offset:[-c*this._panStep,-u*this._panStep],center:f.center},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function As(e){return e*(2-e)}const ks=4.000244140625,js=1/450;class Do{constructor(e,s){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)},this._map=e,this._tr=new io(e),this._triggerRenderFrame=s,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=js}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let s=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const a=b(),l=a-(this._lastWheelEventTime||0);this._lastWheelEventTime=a,0!==s&&s%ks==0?this._type="wheel":0!==s&&Math.abs(s)<4?this._type="trackpad":l>400?(this._type=null,this._lastValue=s,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(l*s)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,s+=this._lastValue)),e.shiftKey&&s&&(s/=4),this._type&&(this._lastWheelEvent=e,this._delta-=s,this._active||this._start(e)),e.preventDefault()}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const s=h.mousePos(this._map.getCanvas(),e),l=this._tr;this._aroundPoint=this._aroundCenter?l.transform.locationToScreenPoint(a.U.convert(l.center)):s,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const s=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=s),"number"==typeof this._targetZoom&&(this._targetZoom+=s)}if(0!==this._delta){const s="wheel"===this._type&&Math.abs(this._delta)>ks?this._wheelZoomRate:this._defaultZoomRate;let l=2/(1+Math.exp(-Math.abs(this._delta*s)));this._delta<0&&0!==l&&(l=1/l);const c="number"!=typeof this._targetZoom?e.scale:a.al(this._targetZoom);this._targetZoom=e.applyConstrain(e.getCameraLngLat(),a.ao(c*l)).zoom,"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const s="number"!=typeof this._targetZoom?e.zoom:this._targetZoom,l=this._startZoom,c=this._easing;let u,d=!1;if("wheel"===this._type&&l&&c){const e=b()-this._lastWheelEventTime,f=Math.min((e+5)/200,1),_=c(f);u=a.F.number(l,s,_),f<1?this._frameId||(this._frameId=!0):d=!0}else u=s,d=!0;return this._active=!0,d&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout}),200)),this._lastExpectedZoom=u,{noInertia:!0,needsRenderFrame:!d,zoomDelta:u-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let s=a.cs;if(this._prevEase){const e=this._prevEase,l=(b()-e.start)/e.duration,c=e.easing(l+.01)-e.easing(l),u=.27/Math.sqrt(c*c+1e-4)*.01,d=Math.sqrt(.0729-u*u);s=a.cq(u,d,.25,1)}return this._prevEase={start:b(),duration:e,easing:s},s}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class zo{constructor(e,s){this._clickZoom=e,this._tapZoom=s}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 Ao{constructor(e){this._tr=new io(e),this.reset()}reset(){this._active=!1}dblclick(e,s){return e.preventDefault(),{cameraAnimation:a=>{a.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(s)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Lo{constructor(){this._tap=new so({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,s,a){if(!this._swipePoint)if(this._tapTime){const l=s[0],c=e.timeStamp-this._tapTime<500,u=this._tapPoint.dist(l)<30;c&&u?a.length>0&&(this._swipePoint=l,this._swipeTouch=a[0].identifier):this.reset()}else this._tap.touchstart(e,s,a)}touchmove(e,s,a){if(this._tapTime){if(this._swipePoint){if(a[0].identifier!==this._swipeTouch)return;const l=s[0],c=l.y-this._swipePoint.y;return this._swipePoint=l,e.preventDefault(),this._active=!0,{zoomDelta:c/128}}}else this._tap.touchmove(e,s,a)}touchend(e,s,a){if(this._tapTime)this._swipePoint&&0===a.length&&this.reset();else{const l=this._tap.touchend(e,s,a);l&&(this._tapTime=e.timeStamp,this._tapPoint=l)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ko{constructor(e,s,a){this._el=e,this._mousePan=s,this._touchPan=a}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Fo{constructor(e,s,a,l){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=s,this._mousePitch=a,this._mouseRoll=l}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class Bo{constructor(e,s,a,l){this._el=e,this._touchZoom=s,this._touchRotate=a,this._tapDragZoom=l,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-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()}}class Oo{constructor(e,s){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=s,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=h.create("div","maplibregl-cooperative-gesture-screen",e);let s=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(s=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const a=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),l=document.createElement("div");l.className="maplibregl-desktop-message",l.textContent=s,this._container.appendChild(l);const c=document.createElement("div");c.className="maplibregl-mobile-message",c.textContent=a,this._container.appendChild(c),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(h.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,s){this._enabled&&(this._map.fire(new a.l("cooperativegestureprevented",{gestureType:e,originalEvent:s})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}}const Ws=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class Uo extends a.l{}function Hs(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class Zo{constructor(e,s){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`)},this.handleEvent=(e,s)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;const l="renderFrame"===e.type?void 0:e,c={needsRenderFrame:!1},u={},d={};for(const{handlerName:f,handler:_,allowed:y}of this._handlers){if(!_.isEnabled())continue;let b;if(this._blockedByActive(d,y,f))_.reset();else if(_[s||e.type]){if(a.ct(e,s||e.type)){const a=h.mousePos(this._map.getCanvas(),e);b=_[s||e.type](e,a)}else if(a.cu(e,s||e.type)){const a=this._getMapTouches(e.touches),l=h.touchPos(this._map.getCanvas(),a);b=_[s||e.type](e,l,a)}else a.cv(s||e.type)||(b=_[s||e.type](e));this.mergeHandlerResult(c,u,b,f,l),b&&b.needsRenderFrame&&this._triggerRenderFrame()}(b||_.isActive())&&(d[f]=_)}const f={};for(const e in this._previousActiveHandlers)d[e]||(f[e]=l);this._previousActiveHandlers=d,(Object.keys(f).length||Hs(c))&&(this._changes.push([c,u,f]),this._triggerRenderFrame()),(Object.keys(d).length||Hs(c))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:_}=c;_&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],_(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Hr(e),this._bearingSnap=s.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(s);const l=this._el;this._listeners=[[l,"touchstart",{passive:!0}],[l,"touchmove",{passive:!1}],[l,"touchend",void 0],[l,"touchcancel",void 0],[l,"mousedown",void 0],[l,"mousemove",void 0],[l,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[l,"mouseover",void 0],[l,"mouseout",void 0],[l,"dblclick",void 0],[l,"click",void 0],[l,"keydown",{capture:!1}],[l,"keyup",void 0],[l,"wheel",{passive:!1}],[l,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,s,a]of this._listeners)h.addEventListener(e,s,e===document?this.handleWindowEvent:this.handleEvent,a)}destroy(){for(const[e,s,a]of this._listeners)h.removeEventListener(e,s,e===document?this.handleWindowEvent:this.handleEvent,a)}_addDefaultHandlers(e){const s=this._map,l=s.getCanvasContainer();this._add("mapEvent",new eo(s,e));const c=s.boxZoom=new ao(s,e);this._add("boxZoom",c),e.interactive&&e.boxZoom&&c.enable();const u=s.cooperativeGestures=new Oo(s,e.cooperativeGestures);this._add("cooperativeGestures",u),e.cooperativeGestures&&u.enable();const d=new no(s),f=new Ao(s);s.doubleClickZoom=new zo(f,d),this._add("tapZoom",d),this._add("clickZoom",f),e.interactive&&e.doubleClickZoom&&s.doubleClickZoom.enable();const _=new Lo;this._add("tapDragZoom",_);const y=s.touchPitch=new Mo(s);this._add("touchPitch",y),e.interactive&&e.touchPitch&&s.touchPitch.enable(e.touchPitch);const b=()=>s.project(s.getCenter()),S=function({enable:e,clickTolerance:s,aroundCenter:l=!0,minPixelCenterThreshold:c=100,rotateDegreesPerPixelMoved:u=.8},d){const f=new _o({checkCorrectEvent:e=>0===h.mouseButton(e)&&e.ctrlKey||2===h.mouseButton(e)&&!e.ctrlKey});return new lo({clickTolerance:s,move:(e,s)=>{const f=d();if(l&&Math.abs(f.y-e.y)>c)return{bearingDelta:a.cr(new a.P(e.x,s.y),s,f)};let _=(s.x-e.x)*u;return l&&s.y<f.y&&(_=-_),{bearingDelta:_}},moveStateManager:f,enable:e,assignEvents:bs})}(e,b),P=function({enable:e,clickTolerance:s,pitchDegreesPerPixelMoved:a=-.5}){const l=new _o({checkCorrectEvent:e=>0===h.mouseButton(e)&&e.ctrlKey||2===h.mouseButton(e)});return new lo({clickTolerance:s,move:(e,s)=>({pitchDelta:(s.y-e.y)*a}),moveStateManager:l,enable:e,assignEvents:bs})}(e),M=function({enable:e,clickTolerance:s,rollDegreesPerPixelMoved:a=.3},l){const c=new _o({checkCorrectEvent:e=>2===h.mouseButton(e)&&e.ctrlKey});return new lo({clickTolerance:s,move:(e,s)=>{const c=l();let u=(s.x-e.x)*a;return s.y<c.y&&(u=-u),{rollDelta:u}},moveStateManager:c,enable:e,assignEvents:bs})}(e,b);s.dragRotate=new Fo(e,S,P,M),this._add("mouseRotate",S,["mousePitch"]),this._add("mousePitch",P,["mouseRotate","mouseRoll"]),this._add("mouseRoll",M,["mousePitch"]),e.interactive&&e.dragRotate&&s.dragRotate.enable();const C=function({enable:e,clickTolerance:s}){const a=new _o({checkCorrectEvent:e=>0===h.mouseButton(e)&&!e.ctrlKey});return new lo({clickTolerance:s,move:(e,s)=>({around:s,panDelta:s.sub(e)}),activateOnStart:!0,moveStateManager:a,enable:e,assignEvents:bs})}(e),D=new go(e,s);s.dragPan=new ko(l,C,D),this._add("mousePan",C),this._add("touchPan",D,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&s.dragPan.enable(e.dragPan);const L=new To,F=new yo;s.touchZoomRotate=new Bo(l,F,L,_),this._add("touchRotate",L,["touchPan","touchZoom"]),this._add("touchZoom",F,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&s.touchZoomRotate.enable(e.touchZoomRotate),this._add("blockableMapEvent",new to(s));const B=s.scrollZoom=new Do(s,(()=>this._triggerRenderFrame()));this._add("scrollZoom",B,["mousePan"]),e.interactive&&e.scrollZoom&&s.scrollZoom.enable(e.scrollZoom);const O=s.keyboard=new Io(s);this._add("keyboard",O),e.interactive&&e.keyboard&&s.keyboard.enable()}_add(e,s,a){this._handlers.push({handlerName:e,handler:s,allowed:a}),this._handlersById[e]=s}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(Ws(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,s,a){for(const l in e)if(l!==a&&(!s||s.indexOf(l)<0))return!0;return!1}_getMapTouches(e){const s=[];for(const a of e)this._el.contains(a.target)&&s.push(a);return s}mergeHandlerResult(e,s,l,c,u){if(!l)return;a.e(e,l);const d={handlerName:c,originalEvent:l.originalEvent||u};void 0!==l.zoomDelta&&(s.zoom=d),void 0!==l.panDelta&&(s.drag=d),void 0!==l.rollDelta&&(s.roll=d),void 0!==l.pitchDelta&&(s.pitch=d),void 0!==l.bearingDelta&&(s.rotate=d)}_applyChanges(){const e={},s={},l={};for(const[c,u,d]of this._changes)c.panDelta&&(e.panDelta=(e.panDelta||new a.P(0,0))._add(c.panDelta)),c.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+c.zoomDelta),c.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+c.bearingDelta),c.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+c.pitchDelta),c.rollDelta&&(e.rollDelta=(e.rollDelta||0)+c.rollDelta),void 0!==c.around&&(e.around=c.around),void 0!==c.pinchAround&&(e.pinchAround=c.pinchAround),c.noInertia&&(e.noInertia=c.noInertia),a.e(s,u),a.e(l,d);this._updateMapTransform(e,s,l),this._changes=[]}_updateMapTransform(e,s,a){const l=this._map,c=l._getTransformForUpdate(),u=l.terrain;if(!(Hs(e)||u&&this._terrainMovement))return this._fireEvents(s,a,!0);l._stop(!0);let{panDelta:d,zoomDelta:f,bearingDelta:_,pitchDelta:y,rollDelta:b,around:S,pinchAround:P}=e;void 0!==P&&(S=P),S=S||l.transform.centerPoint,u&&!c.isPointOnMapSurface(S)&&(S=c.centerPoint);const M={panDelta:d,zoomDelta:f,rollDelta:b,pitchDelta:y,bearingDelta:_,around:S};this._map.cameraHelper.useGlobeControls&&!c.isPointOnMapSurface(S)&&(S=c.centerPoint);const C=S.distSqr(c.centerPoint)<.01?c.center:c.screenPointToLocation(d?S.sub(d):S);this._handleMapControls({terrain:u,tr:c,deltasForHelper:M,preZoomAroundLoc:C,combinedEventsInProgress:s,panDelta:d}),l._applyUpdatedTransform(c),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(s,a,!0)}_handleMapControls({terrain:e,tr:s,deltasForHelper:a,preZoomAroundLoc:l,combinedEventsInProgress:c,panDelta:u}){const d=this._map.cameraHelper;if(d.handleMapControlsRollPitchBearingZoom(a,s),e)return d.useGlobeControls?(this._terrainMovement||!c.drag&&!c.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void d.handleMapControlsPan(a,s,l)):this._terrainMovement||!c.drag&&!c.zoom?void(c.drag&&this._terrainMovement&&u?s.setCenter(s.screenPointToLocation(s.centerPoint.sub(u))):d.handleMapControlsPan(a,s,l)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void d.handleMapControlsPan(a,s,l));d.handleMapControlsPan(a,s,l)}_fireEvents(e,s,l){const c=Ws(this._eventsInProgress),u=Ws(e),d={};for(const s in e){const{originalEvent:a}=e[s];this._eventsInProgress[s]||(d[`${s}start`]=a),this._eventsInProgress[s]=e[s]}!c&&u&&this._fireEvent("movestart",u.originalEvent);for(const e in d)this._fireEvent(e,d[e]);u&&this._fireEvent("move",u.originalEvent);for(const s in e){const{originalEvent:a}=e[s];this._fireEvent(s,a)}const f={};let y;for(const e in this._eventsInProgress){const{handlerName:a,originalEvent:l}=this._eventsInProgress[e];this._handlersById[a].isActive()||(delete this._eventsInProgress[e],y=s[a]||l,f[`${e}end`]=y)}for(const e in f)this._fireEvent(e,f[e]);const b=Ws(this._eventsInProgress),S=(c||u)&&!b;if(S&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e)}if(l&&S){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),s=e=>0!==e&&-this._bearingSnap<e&&e<this._bearingSnap;!e||!e.essential&&_.prefersReducedMotion?(this._map.fire(new a.l("moveend",{originalEvent:y})),s(this._map.getBearing())&&this._map.resetNorth()):(s(e.bearing||this._map.getBearing())&&(e.bearing=0),e.freezeElevation=!0,this._map.easeTo(e,{originalEvent:y})),this._updatingCamera=!1}}_fireEvent(e,s){this._map.fire(new a.l(e,s?{originalEvent:s}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((e=>{delete this._frameId,this.handleEvent(new Uo("renderFrame",{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class Go extends a.E{constructor(e,s,a){super(),this._renderFrameCallback=()=>{const e=Math.min((b()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=a.bearingSnap,this.cameraHelper=s,this.on("moveend",(()=>{delete this._requestedCameraState}))}migrateProjection(e,s){e.apply(this.transform),this.transform=e,this.cameraHelper=s}getCenter(){return new a.U(this.transform.center.lng,this.transform.center.lat)}setCenter(e,s){return this.jumpTo({center:e},s)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,s){return this.jumpTo({elevation:e},s),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,s,l){return e=a.P.convert(e).mult(-1),this.panTo(this.transform.center,a.e({offset:e},s),l)}panTo(e,s,l){return this.easeTo(a.e({center:e},s),l)}getZoom(){return this.transform.zoom}setZoom(e,s){return this.jumpTo({zoom:e},s),this}zoomTo(e,s,l){return this.easeTo(a.e({zoom:e},s),l)}zoomIn(e,s){return this.zoomTo(this.getZoom()+1,e,s),this}zoomOut(e,s){return this.zoomTo(this.getZoom()-1,e,s),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,s){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new a.l("movestart",s)).fire(new a.l("move",s)).fire(new a.l("moveend",s))),this}getBearing(){return this.transform.bearing}setBearing(e,s){return this.jumpTo({bearing:e},s),this}getPadding(){return this.transform.padding}setPadding(e,s){return this.jumpTo({padding:e},s),this}rotateTo(e,s,l){return this.easeTo(a.e({bearing:e},s),l)}resetNorth(e,s){return this.rotateTo(0,a.e({duration:1e3},e),s),this}resetNorthPitch(e,s){return this.easeTo(a.e({bearing:0,pitch:0,roll:0,duration:1e3},e),s),this}snapToNorth(e,s){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,s):this}getPitch(){return this.transform.pitch}setPitch(e,s){return this.jumpTo({pitch:e},s),this}getRoll(){return this.transform.roll}setRoll(e,s){return this.jumpTo({roll:e},s),this}cameraForBounds(e,s){e=$.convert(e).adjustAntiMeridian();const a=s&&s.bearing||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),a,s)}_cameraForBoxAndBearing(e,s,l,c){const u={top:0,bottom:0,right:0,left:0};if("number"==typeof(c=a.e({padding:u,offset:[0,0],maxZoom:this.transform.maxZoom},c)).padding){const e=c.padding;c.padding={top:e,bottom:e,right:e,left:e}}const d=a.e(u,c.padding);c.padding=d;const f=this.transform,_=new $(e,s);return this.cameraHelper.cameraForBoxAndBearing(c,d,_,l,f)}fitBounds(e,s,a){return this._fitInternal(this.cameraForBounds(e,s),s,a)}fitScreenCoordinates(e,s,l,c,u){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(a.P.convert(e)),this.transform.screenPointToLocation(a.P.convert(s)),l,c),c,u)}_fitInternal(e,s,l){return e?(delete(s=a.e(e,s)).padding,s.linear?this.easeTo(s,l):this.flyTo(s,l)):this}jumpTo(e,s){this.stop();const l=this._getTransformForUpdate();let c=!1,u=!1,d=!1;const f=l.zoom;this.cameraHelper.handleJumpToCenterZoom(l,e);const _=l.zoom!==f;return"elevation"in e&&l.elevation!==+e.elevation&&l.setElevation(+e.elevation),"bearing"in e&&l.bearing!==+e.bearing&&(c=!0,l.setBearing(+e.bearing)),"pitch"in e&&l.pitch!==+e.pitch&&(u=!0,l.setPitch(+e.pitch)),"roll"in e&&l.roll!==+e.roll&&(d=!0,l.setRoll(+e.roll)),null==e.padding||l.isPaddingEqual(e.padding)||l.setPadding(e.padding),this._applyUpdatedTransform(l),this.fire(new a.l("movestart",s)).fire(new a.l("move",s)),_&&this.fire(new a.l("zoomstart",s)).fire(new a.l("zoom",s)).fire(new a.l("zoomend",s)),c&&this.fire(new a.l("rotatestart",s)).fire(new a.l("rotate",s)).fire(new a.l("rotateend",s)),u&&this.fire(new a.l("pitchstart",s)).fire(new a.l("pitch",s)).fire(new a.l("pitchend",s)),d&&this.fire(new a.l("rollstart",s)).fire(new a.l("roll",s)).fire(new a.l("rollend",s)),this.fire(new a.l("moveend",s))}calculateCameraOptionsFromTo(e,s,l,c=0){const u=a.a5.fromLngLat(e,s),d=a.a5.fromLngLat(l,c),f=d.x-u.x,_=d.y-u.y,y=d.z-u.z,b=Math.hypot(f,_,y);if(0===b)throw new Error("Can't calculate camera options with same From and To");const S=Math.hypot(f,_),P=a.ao(this.transform.cameraToCenterDistance/b/this.transform.tileSize),M=180*Math.atan2(f,-_)/Math.PI;let C=180*Math.acos(S/b)/Math.PI;return C=y<0?90-C:90+C,{center:d.toLngLat(),elevation:c,zoom:P,pitch:C,bearing:M}}calculateCameraOptionsFromCameraLngLatAltRotation(e,s,a,l,c){const u=this.transform.calculateCenterFromCameraLngLatAlt(e,s,a,l);return{center:u.center,elevation:u.elevation,zoom:u.zoom,bearing:a,pitch:l,roll:c}}easeTo(e,s){this._stop(!1,e.easeId),(!1===(e=a.e({offset:[0,0],duration:500,easing:a.cs},e)).animate||!e.essential&&_.prefersReducedMotion)&&(e.duration=0);const l=this._getTransformForUpdate(),c=this.getBearing(),u=l.pitch,d=l.roll,f="bearing"in e?this._normalizeBearing(e.bearing,c):c,y="pitch"in e?+e.pitch:u,b="roll"in e?this._normalizeBearing(e.roll,d):d,S="padding"in e?e.padding:l.padding,P=a.P.convert(e.offset);let M,C;e.around&&(M=a.U.convert(e.around),C=l.locationToScreenPoint(M));const D={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},L=this.cameraHelper.handleEaseTo(l,{bearing:f,pitch:y,roll:b,padding:S,around:M,aroundPoint:C,offsetAsPoint:P,offset:e.offset,zoom:e.zoom,center:e.center});return this._rotating=this._rotating||c!==f,this._pitching=this._pitching||y!==u,this._rolling=this._rolling||b!==d,this._padding=!l.isPaddingEqual(S),this._zooming=this._zooming||L.isZooming,this._easeId=e.easeId,this._prepareEase(s,e.noMoveStart,D),this.terrain&&this._prepareElevation(L.elevationCenter),this._ease((a=>{L.easeFunc(a),this.terrain&&!e.freezeElevation&&this._updateElevation(a),this._applyUpdatedTransform(l),this._fireMoveEvents(s)}),(a=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(s,a)}),e),this}_prepareEase(e,s,l={}){this._moving=!0,s||l.moving||this.fire(new a.l("movestart",e)),this._zooming&&!l.zooming&&this.fire(new a.l("zoomstart",e)),this._rotating&&!l.rotating&&this.fire(new a.l("rotatestart",e)),this._pitching&&!l.pitching&&this.fire(new a.l("pitchstart",e)),this._rolling&&!l.rolling&&this.fire(new a.l("rollstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){void 0!==this._elevationStart&&void 0!==this._elevationCenter||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const s=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&s!==this._elevationTarget){const a=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(a-(s-(a*e+this._elevationStart))/(1-e)),this._elevationTarget=s}this.transform.setElevation(a.F.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};const s=e.getCameraLngLat(),a=e.getCameraAltitude(),l=this.terrain?this.terrain.getElevationForLngLatZoom(s,e.zoom):0;if(a<l){const a=this.calculateCameraOptionsFromTo(s,l,e.center,e.elevation);return{pitch:a.pitch,zoom:a.zoom}}return{}}_applyUpdatedTransform(e){const s=[];if(s.push((e=>this._elevateCameraIfInsideTerrain(e))),this.transformCameraUpdate&&s.push((e=>this.transformCameraUpdate(e))),!s.length)return;const a=e.clone();for(const e of s){const s=a.clone(),{center:l,zoom:c,roll:u,pitch:d,bearing:f,elevation:_}=e(s);l&&s.setCenter(l),void 0!==_&&s.setElevation(_),void 0!==c&&s.setZoom(c),void 0!==u&&s.setRoll(u),void 0!==d&&s.setPitch(d),void 0!==f&&s.setBearing(f),a.apply(s)}this.transform.apply(a)}_fireMoveEvents(e){this.fire(new a.l("move",e)),this._zooming&&this.fire(new a.l("zoom",e)),this._rotating&&this.fire(new a.l("rotate",e)),this._pitching&&this.fire(new a.l("pitch",e)),this._rolling&&this.fire(new a.l("roll",e))}_afterEase(e,s){if(this._easeId&&s&&this._easeId===s)return;delete this._easeId;const l=this._zooming,c=this._rotating,u=this._pitching,d=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,l&&this.fire(new a.l("zoomend",e)),c&&this.fire(new a.l("rotateend",e)),u&&this.fire(new a.l("pitchend",e)),d&&this.fire(new a.l("rollend",e)),this.fire(new a.l("moveend",e))}flyTo(e,s){if(!e.essential&&_.prefersReducedMotion){const l=a.S(e,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(l,s)}this.stop(),e=a.e({offset:[0,0],speed:1.2,curve:1.42,easing:a.cs},e);const l=this._getTransformForUpdate(),c=l.bearing,u=l.pitch,d=l.roll,f=l.padding,y="bearing"in e?this._normalizeBearing(e.bearing,c):c,b="pitch"in e?+e.pitch:u,S="roll"in e?this._normalizeBearing(e.roll,d):d,P="padding"in e?e.padding:l.padding,M=a.P.convert(e.offset);let C=l.centerPoint.add(M);const D=l.screenPointToLocation(C),L=this.cameraHelper.handleFlyTo(l,{bearing:y,pitch:b,roll:S,padding:P,locationAtOffset:D,offsetAsPoint:M,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let F=e.curve;const B=Math.max(l.width,l.height),O=B/L.scaleOfZoom,V=L.pixelPathLength;"number"==typeof L.scaleOfMinZoom&&(F=Math.sqrt(B/L.scaleOfMinZoom/V*2));const N=F*F;function j(e){const s=(O*O-B*B+(e?-1:1)*N*N*V*V)/(2*(e?O:B)*N*V);return Math.log(Math.sqrt(s*s+1)-s)}function G(e){return(Math.exp(e)-Math.exp(-e))/2}function Z(e){return(Math.exp(e)+Math.exp(-e))/2}const q=j(!1);let W=function(e){return Z(q)/Z(q+F*e)},J=function(e){return B*((Z(q)*(G(s=q+F*e)/Z(s))-G(q))/N)/V;var s},Q=(j(!0)-q)/F;if(Math.abs(V)<2e-6||!isFinite(Q)){if(Math.abs(B-O)<1e-6)return this.easeTo(e,s);const a=O<B?-1:1;Q=Math.abs(Math.log(O/B))/F,J=()=>0,W=e=>Math.exp(a*F*e)}return e.duration="duration"in e?+e.duration:1e3*Q/("screenSpeed"in e?+e.screenSpeed/F:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=c!==y,this._pitching=b!==u,this._rolling=S!==d,this._padding=!l.isPaddingEqual(P),this._prepareEase(s,!1),this.terrain&&this._prepareElevation(L.targetCenter),this._ease((_=>{const D=_*Q,F=1/W(D),B=J(D);this._rotating&&l.setBearing(a.F.number(c,y,_)),this._pitching&&l.setPitch(a.F.number(u,b,_)),this._rolling&&l.setRoll(a.F.number(d,S,_)),this._padding&&(l.interpolatePadding(f,P,_),C=l.centerPoint.add(M)),L.easeFunc(_,F,B,C),this.terrain&&!e.freezeElevation&&this._updateElevation(_),this._applyUpdatedTransform(l),this._fireMoveEvents(s)}),(()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(s)}),e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,s){var a;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,s)}return e||null===(a=this.handlers)||void 0===a||a.stop(!1),this}_ease(e,s,a){!1===a.animate||0===a.duration?(e(1),s()):(this._easeStart=b(),this._easeOptions=a,this._onEaseFrame=e,this._onEaseEnd=s,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,s){e=a.V(e,-180,180);const l=Math.abs(e-s);return Math.abs(e-360-s)<l&&(e-=360),Math.abs(e+360-s)<l&&(e+=360),e}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLatZoom(a.U.convert(e),this.transform.tileZoom):null}}const Xs={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class Wo{constructor(e=Xs){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=e=>{!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType&&"terrain"!==e.type||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=h.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=h.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=h.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){h.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,s){const a=this._map._getUIString(`AttributionControl.${s}`);e.title=a,e.setAttribute("aria-label",a)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map((e=>"string"!=typeof e?"":e))):"string"==typeof this.options.customAttribution&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}const s=this._map.style.tileManagers;for(const a in s){const l=s[a];if(l.used||l.usedForTerrain){const s=l.getSource();s.attribution&&e.indexOf(s.attribution)<0&&e.push(s.attribution)}}e=e.filter((e=>String(e).trim())),e.sort(((e,s)=>e.length-s.length)),e=e.filter(((s,a)=>{for(let l=a+1;l<e.length;l++)if(e[l].indexOf(s)>=0)return!1;return!0}));const a=e.join(" | ");a!==this._attribHTML&&(this._attribHTML=a,e.length?(this._innerContainer.innerHTML=h.sanitize(a),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class qo{constructor(e={}){this._updateCompact=()=>{const e=this._container.children;if(e.length){const s=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&s.classList.add("maplibregl-compact"):s.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=h.create("div","maplibregl-ctrl");const s=h.create("a","maplibregl-ctrl-logo");return s.target="_blank",s.rel="noopener nofollow",s.href="https://maplibre.org/",s.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),s.setAttribute("rel","noopener nofollow"),this._container.appendChild(s),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){h.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class $o{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const s=++this._id;return this._queue.push({callback:e,id:s,cancelled:!1}),s}remove(e){const s=this._currentlyRunning,a=s?this._queue.concat(s):this._queue;for(const s of a)if(s.id===e)return void(s.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const s=this._currentlyRunning=this._queue;this._queue=[];for(const a of s)if(!a.cancelled&&(a.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Ys=a.aO([{name:"a_pos3d",type:"Int16",components:3}]);class Xo extends a.E{constructor(e){super(),this._lastTilesetChange=b(),this.tileManager=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null}getSource(){return this.tileManager._source}update(e,s){this.tileManager.update(e,s),this._renderableTilesKeys=[];const l={};for(const c of Xe(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:s,calculateTileZoom:this.tileManager._source.calculateTileZoom}))l[c.key]=!0,this._renderableTilesKeys.push(c.key),this._tiles[c.key]||(c.terrainRttPosMatrix32f=new Float64Array(16),a.c1(c.terrainRttPosMatrix32f,0,a.a3,a.a3,0,0,1),this._tiles[c.key]=new de(c,this.tileSize),this._lastTilesetChange=b());for(const e in this._tiles)l[e]||delete this._tiles[e]}freeRtt(e){for(const s in this._tiles){const a=this._tiles[s];(!e||a.tileID.equals(e)||a.tileID.isChildOf(e)||e.isChildOf(a.tileID))&&(a.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((e=>this.getTileByID(e)))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,s){return s?this._getTerrainCoordsForTileRanges(e,s):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const s={};for(const l of this._renderableTilesKeys){const c=this._tiles[l].tileID,u=e.clone(),d=a.be();if(c.canonical.equals(e.canonical))a.c1(d,0,a.a3,a.a3,0,0,1);else if(c.canonical.isChildOf(e.canonical)){const s=c.canonical.z-e.canonical.z,l=c.canonical.x-(c.canonical.x>>s<<s),u=c.canonical.y-(c.canonical.y>>s<<s),f=a.a3>>s;a.c1(d,0,f,f,0,0,1),a.N(d,d,[-l*f,-u*f,0])}else{if(!e.canonical.isChildOf(c.canonical))continue;{const s=e.canonical.z-c.canonical.z,l=e.canonical.x-(e.canonical.x>>s<<s),u=e.canonical.y-(e.canonical.y>>s<<s),f=a.a3>>s;a.c1(d,0,a.a3,a.a3,0,0,1),a.N(d,d,[l*f,u*f,0]),a.O(d,d,[1/2**s,1/2**s,0])}}u.terrainRttPosMatrix32f=new Float32Array(d),s[l]=u}return s}_getTerrainCoordsForTileRanges(e,s){const l={};for(const c of this._renderableTilesKeys){const u=this._tiles[c].tileID;if(!this._isWithinTileRanges(u,s))continue;const d=e.clone(),f=a.be();if(u.canonical.z===e.canonical.z){const s=e.canonical.x-u.canonical.x,l=e.canonical.y-u.canonical.y;a.c1(f,0,a.a3,a.a3,0,0,1),a.N(f,f,[s*a.a3,l*a.a3,0])}else if(u.canonical.z>e.canonical.z){const s=u.canonical.z-e.canonical.z,l=u.canonical.x-(u.canonical.x>>s<<s),c=u.canonical.y-(u.canonical.y>>s<<s),d=e.canonical.x-(u.canonical.x>>s),_=e.canonical.y-(u.canonical.y>>s),y=a.a3>>s;a.c1(f,0,y,y,0,0,1),a.N(f,f,[-l*y+d*a.a3,-c*y+_*a.a3,0])}else{const s=e.canonical.z-u.canonical.z,l=e.canonical.x-(e.canonical.x>>s<<s),c=e.canonical.y-(e.canonical.y>>s<<s),d=(e.canonical.x>>s)-u.canonical.x,_=(e.canonical.y>>s)-u.canonical.y,y=a.a3<<s;a.c1(f,0,y,y,0,0,1),a.N(f,f,[l*a.a3+d*y,c*a.a3+_*y,0])}d.terrainRttPosMatrix32f=new Float32Array(f),l[c]=d}return l}getSourceTile(e,s){const a=this.tileManager._source;let l=e.overscaledZ-this.deltaZoom;if(l>a.maxzoom&&(l=a.maxzoom),l<a.minzoom)return null;this._sourceTileCache[e.key]||(this._sourceTileCache[e.key]=e.scaledTo(l).key);let c=this.tileManager.getTileByID(this._sourceTileCache[e.key]);if((!c||!c.dem)&&s)for(;l>=a.minzoom&&(!c||!c.dem);)c=this.tileManager.getTileByID(e.scaledTo(l--).key);return c}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,s){return s[e.canonical.z]&&e.canonical.x>=s[e.canonical.z].minTileX&&e.canonical.x<=s[e.canonical.z].maxTileX&&e.canonical.y>=s[e.canonical.z].minTileY&&e.canonical.y<=s[e.canonical.z].maxTileY}}class Ko{constructor(e,s,a){this._meshCache={},this.painter=e,this.tileManager=new Xo(s),this.options=a,this.exaggeration="number"==typeof a.exaggeration?a.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,s,l,c=a.a3){var u;if(!(s>=0&&s<c&&l>=0&&l<c))return 0;const d=this.getTerrainData(e),f=null===(u=d.tile)||void 0===u?void 0:u.dem;if(!f)return 0;const _=a.cw([],[s/c*a.a3,l/c*a.a3],d.u_terrain_matrix),y=[_[0]*f.dim,_[1]*f.dim],b=Math.floor(y[0]),S=Math.floor(y[1]),P=y[0]-b,M=y[1]-S;return f.get(b,S)*(1-P)*(1-M)+f.get(b+1,S)*P*(1-M)+f.get(b,S+1)*(1-P)*M+f.get(b+1,S+1)*P*M}getElevationForLngLatZoom(e,s){if(!a.cx(s,e.wrap()))return 0;const{tileID:l,mercatorX:c,mercatorY:u}=this._getOverscaledTileIDFromLngLatZoom(e,s);return this.getElevation(l,c%a.a3,u%a.a3,a.a3)}getElevation(e,s,l,c=a.a3){return this.getDEMElevation(e,s,l,c)*this.exaggeration}getTerrainData(e){if(!this._emptyDemTexture){const e=this.painter.context,s=new a.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new a.T(e,s,e.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new a.T(e,new a.R({width:1,height:1}),e.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=a.am([])}const s=this.tileManager.getSourceTile(e,!0);if(s&&s.dem&&(!s.demTexture||s.needsTerrainPrepare)){const e=this.painter.context;s.demTexture=this.painter.getTileTexture(s.dem.stride),s.demTexture?s.demTexture.update(s.dem.getPixels(),{premultiply:!1}):s.demTexture=new a.T(e,s.dem.getPixels(),e.gl.RGBA,{premultiply:!1}),s.demTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),s.needsTerrainPrepare=!1}const l=s&&s+s.tileID.key+e.key;if(l&&!this._demMatrixCache[l]){const l=this.tileManager.getSource().maxzoom;let c=e.canonical.z-s.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=l?c=e.canonical.z-l:a.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const u=e.canonical.x-(e.canonical.x>>c<<c),d=e.canonical.y-(e.canonical.y>>c<<c),f=a.cy(new Float64Array(16),[1/(a.a3<<c),1/(a.a3<<c),0]);a.N(f,f,[u*a.a3,d*a.a3,0]),this._demMatrixCache[e.key]={matrix:f,coord:e}}return{u_depth:2,u_terrain:3,u_terrain_dim:s&&s.dem&&s.dem.dim||1,u_terrain_matrix:l?this._demMatrixCache[e.key].matrix:this._emptyDemMatrix,u_terrain_unpack:s&&s.dem&&s.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(s&&s.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:s}}getFramebuffer(e){const s=this.painter,l=s.width/devicePixelRatio,c=s.height/devicePixelRatio;return!this._fbo||this._fbo.width===l&&this._fbo.height===c||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new a.T(s.context,{width:l,height:c,data:null},s.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(s.context.gl.NEAREST,s.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new a.T(s.context,{width:l,height:c,data:null},s.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(s.context.gl.NEAREST,s.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=s.context.createFramebuffer(l,c,!0,!1),this._fbo.depthAttachment.set(s.context.createRenderbuffer(s.context.gl.DEPTH_COMPONENT16,l,c))),this._fbo.colorAttachment.set("coords"===e?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const e=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const s=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let e=0,a=0;e<this._coordsTextureSize;e++)for(let l=0;l<this._coordsTextureSize;l++,a+=4)s[a+0]=255&l,s[a+1]=255&e,s[a+2]=l>>8<<4|e>>8,s[a+3]=0;const l=new a.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(s.buffer)),c=new a.T(e,l,e.gl.RGBA,{premultiply:!1});return c.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=c,c}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const s=new Uint8Array(4),l=this.painter.context,c=l.gl,u=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),d=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),f=Math.round(this.painter.height/devicePixelRatio);l.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),c.readPixels(u,f-d-1,1,1,c.RGBA,c.UNSIGNED_BYTE,s),l.bindFramebuffer.set(null);const _=s[0]+(s[2]>>4<<8),y=s[1]+((15&s[2])<<8),b=this.coordsIndex[255-s[3]],S=b&&this.tileManager.getTileByID(b);if(!S)return null;const P=this._coordsTextureSize,M=(1<<S.tileID.canonical.z)*P;return new a.a5((S.tileID.canonical.x*P+_)/M+S.tileID.wrap,(S.tileID.canonical.y*P+y)/M,this.getElevation(S.tileID,_,y,P))}depthAtPoint(e){const s=new Uint8Array(4),a=this.painter.context,l=a.gl;return a.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),l.readPixels(e.x,this.painter.height/devicePixelRatio-e.y-1,1,1,l.RGBA,l.UNSIGNED_BYTE,s),a.bindFramebuffer.set(null),(s[0]/16777216+s[1]/65536+s[2]/256+s[3])/256}getTerrainMesh(e){var s;const l=(null===(s=this.painter.style.projection)||void 0===s?void 0:s.transitionState)>0,c=l&&0===e.canonical.y,u=l&&e.canonical.y===(1<<e.canonical.z)-1,d=`m_${c?"n":""}_${u?"s":""}`;if(this._meshCache[d])return this._meshCache[d];const f=this.painter.context,_=new a.cz,y=new a.aS,b=this.meshSize,S=a.a3/b,P=b*b;for(let e=0;e<=b;e++)for(let s=0;s<=b;s++)_.emplaceBack(s*S,e*S,0);for(let e=0;e<P;e+=b+1)for(let s=0;s<b;s++)y.emplaceBack(s+e,b+s+e+1,b+s+e+2),y.emplaceBack(s+e,b+s+e+2,s+e+1);const M=_.length,C=M+(b+1),D=(b+1)*b,L=c?a.bl:0,F=c?0:1,B=u?a.bm:a.a3,O=u?0:1;for(let e=0;e<=b;e++)_.emplaceBack(e*S,L,F);for(let e=0;e<=b;e++)_.emplaceBack(e*S,B,O);for(let e=0;e<b;e++)y.emplaceBack(D+e,C+e,C+e+1),y.emplaceBack(D+e,C+e+1,D+e+1),y.emplaceBack(0+e,M+e+1,M+e),y.emplaceBack(0+e,0+e+1,M+e+1);const V=_.length,N=V+2*(b+1);for(const e of[0,1])for(let s=0;s<=b;s++)for(const l of[0,1])_.emplaceBack(e*a.a3,s*S,l);for(let e=0;e<2*b;e+=2)y.emplaceBack(V+e,V+e+1,V+e+3),y.emplaceBack(V+e,V+e+3,V+e+2),y.emplaceBack(N+e,N+e+3,N+e+1),y.emplaceBack(N+e,N+e+2,N+e+3);const j=new St(f.createVertexBuffer(_,Ys.members),f.createIndexBuffer(y),a.aR.simpleSegment(0,0,_.length,y.length));return this._meshCache[d]=j,j}getMeshFrameDelta(e){return 2*Math.PI*a.by/Math.pow(2,Math.max(e,0))/5}getMinTileElevationForLngLatZoom(e,s){var a;const{tileID:l}=this._getOverscaledTileIDFromLngLatZoom(e,s);return null!==(a=this.getMinMaxElevation(l).minElevation)&&void 0!==a?a:0}getMinMaxElevation(e){const s=this.getTerrainData(e).tile,a={minElevation:null,maxElevation:null};return s&&s.dem&&(a.minElevation=s.dem.min*this.exaggeration,a.maxElevation=s.dem.max*this.exaggeration),a}_getOverscaledTileIDFromLngLatZoom(e,s){const l=a.a5.fromLngLat(e.wrap()),c=(1<<s)*a.a3,u=l.x*c,d=l.y*c,f=Math.floor(u/a.a3),_=Math.floor(d/a.a3);return{tileID:new a.a0(s,0,s,f,_),mercatorX:u,mercatorY:d}}}class Yo{constructor(e,s,a){this._context=e,this._size=s,this._tileSize=a,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const e of this._objects)e.texture.destroy(),e.fbo.destroy()}_createObject(e){const s=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),l=new a.T(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return l.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),this._context.extTextureFilterAnisotropic&&this._context.gl.texParameterf(this._context.gl.TEXTURE_2D,this._context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this._context.extTextureFilterAnisotropicMax),s.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),s.colorAttachment.set(l.texture),{id:e,fbo:s,texture:l,stamp:-1,inUse:!1}}getObjectForId(e){return this._objects[e]}useObject(e){e.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter((s=>e.id!==s)),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(const e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(const e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length<this._size)&&!1===this._objects.some((e=>!e.inUse))}}const Qs={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class Jo{constructor(e,s){this.painter=e,this.terrain=s,this.pool=new Yo(e.context,30,s.tileManager.tileSize*s.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,s){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter((a=>!e._layers[a].isHidden(s))),this._coordsAscending={};for(const s in e.tileManagers){this._coordsAscending[s]={};const a=e.tileManagers[s].getVisibleCoordinates(),l=e.tileManagers[s].getSource(),c=l instanceof te?l.terrainTileRanges:null;for(const e of a){const a=this.terrain.tileManager.getTerrainCoords(e,c);for(const e in a)this._coordsAscending[s][e]||(this._coordsAscending[s][e]=[]),this._coordsAscending[s][e].push(a[e])}}this._coordsAscendingStr={};for(const s of e._order){const a=e._layers[s],l=a.source;if(Qs[a.type]&&!this._coordsAscendingStr[l]){this._coordsAscendingStr[l]={};for(const e in this._coordsAscending[l])this._coordsAscendingStr[l][e]=this._coordsAscending[l][e].map((e=>e.key)).sort().join()}}for(const e of this._renderableTiles)for(const s in this._coordsAscendingStr){const a=this._coordsAscendingStr[s][e.tileID.key];a&&a!==e.rttCoords[s]&&(e.rtt=[])}}renderLayer(e,s){if(e.isHidden(this.painter.transform.zoom))return!1;const l=Object.assign(Object.assign({},s),{isRenderingToTexture:!0}),c=e.type,u=this.painter,d=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(Qs[c]&&(this._prevType&&Qs[this._prevType]||this._stacks.push([]),this._prevType=c,this._stacks[this._stacks.length-1].push(e.id),!d))return!0;if(Qs[this._prevType]||Qs[c]&&d){this._prevType=c;const e=this._stacks.length-1,s=this._stacks[e]||[];for(const c of this._renderableTiles){if(this.pool.isFull()&&(is(this.painter,this.terrain,this._rttTiles,l),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(c),c.rtt[e]){const s=this.pool.getObjectForId(c.rtt[e].id);if(s.stamp===c.rtt[e].stamp){this.pool.useObject(s);continue}}const d=this.pool.getOrCreateFreeObject();this.pool.useObject(d),this.pool.stampObject(d),c.rtt[e]={id:d.id,stamp:d.stamp},u.context.bindFramebuffer.set(d.fbo.framebuffer),u.context.clear({color:a.bj.transparent,stencil:0}),u.currentStencilSource=void 0;for(let e=0;e<s.length;e++){const a=u.style._layers[s[e]],f=a.source?this._coordsAscending[a.source][c.tileID.key]:[c.tileID];u.context.viewport.set([0,0,d.fbo.width,d.fbo.height]),u._renderTileClippingMasks(a,f,!0),u.renderLayer(u,u.style.tileManagers[a.source],a,f,l),a.source&&(c.rttCoords[a.source]=this._coordsAscendingStr[a.source][c.tileID.key])}}return is(this.painter,this.terrain,this._rttTiles,l),this._rttTiles=[],this.pool.freeAllObjects(),Qs[c]}return!1}}const ro={"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":"MapLibre logo","Map.Title":"Map","Marker.Title":"Map marker","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","Popup.Close":"Close popup","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","GlobeControl.Enable":"Enable globe","GlobeControl.Disable":"Disable globe","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":"Use + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},co=l,uo={hash:!1,interactive:!0,bearingSnap:7,attributionControl:Xs,maplibreLogo:!1,refreshExpiredTiles:!0,canvasContextAttributes:{antialias:!1,preserveDrawingBuffer:!1,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,desynchronized:!1,contextType:void 0},scrollZoom:!0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,trackResize:!0,center:[0,0],elevation:0,zoom:0,bearing:0,pitch:0,roll:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:a.a.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,transformConstrain:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,rollEnabled:!1,reduceMotion:void 0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0,experimentalZoomLevelsToOverscale:void 0},fo={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};class rs{constructor(e,s,l=!1){this.mousedown=e=>{this.startMove(e,h.mousePos(this.element,e)),h.addEventListener(window,"mousemove",this.mousemove),h.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=e=>{this.move(e,h.mousePos(this.element,e))},this.mouseup=e=>{this._rotatePitchHandler.dragEnd(e),this.offTemp()},this.touchstart=e=>{1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=h.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),h.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),h.addEventListener(window,"touchend",this.touchend))},this.touchmove=e=>{1!==e.targetTouches.length?this.reset():(this._lastPos=h.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos))},this.touchend=e=>{0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.reset=()=>{this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=s;const c=new mo;this._rotatePitchHandler=new lo({clickTolerance:3,move:(e,c)=>{const u=s.getBoundingClientRect(),d=new a.P((u.bottom-u.top)/2,(u.right-u.left)/2);return{bearingDelta:a.cr(new a.P(e.x,c.y),c,d),pitchDelta:l?-.5*(c.y-e.y):void 0}},moveStateManager:c,enable:!0,assignEvents:()=>{}}),this.map=e,h.addEventListener(s,"mousedown",this.mousedown),h.addEventListener(s,"touchstart",this.touchstart,{passive:!1}),h.addEventListener(s,"touchcancel",this.reset)}startMove(e,s){this._rotatePitchHandler.dragStart(e,s),h.disableDrag()}move(e,s){const a=this.map,{bearingDelta:l,pitchDelta:c}=this._rotatePitchHandler.dragMove(e,s)||{};l&&a.setBearing(a.getBearing()+l),c&&a.setPitch(a.getPitch()+c)}off(){const e=this.element;h.removeEventListener(e,"mousedown",this.mousedown),h.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),h.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),h.removeEventListener(window,"touchend",this.touchend),h.removeEventListener(e,"touchcancel",this.reset),this.offTemp()}offTemp(){h.enableDrag(),h.removeEventListener(window,"mousemove",this.mousemove),h.removeEventListener(window,"mouseup",this.mouseup),h.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),h.removeEventListener(window,"touchend",this.touchend)}}let bo;function wo(e,s,l,c=!1){if(c||!l.getCoveringTilesDetailsProvider().allowWorldCopies())return null==e?void 0:e.wrap();const u=new a.U(e.lng,e.lat);if(e=new a.U(e.lng,e.lat),s){const c=new a.U(e.lng-360,e.lat),u=new a.U(e.lng+360,e.lat),d=l.locationToScreenPoint(e).distSqr(s);l.locationToScreenPoint(c).distSqr(s)<d?e=c:l.locationToScreenPoint(u).distSqr(s)<d&&(e=u)}for(;Math.abs(e.lng-l.center.lng)>180;){const s=l.locationToScreenPoint(e);if(s.x>=0&&s.y>=0&&s.x<=l.width&&s.y<=l.height)break;e.lng>l.center.lng?e.lng-=360:e.lng+=360}return e.lng!==u.lng&&l.isPointOnMapSurface(l.locationToScreenPoint(e))?e:u}const Po={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%)"};function Co(e,s,a){const l=e.classList;for(const e in Po)l.remove(`maplibregl-${a}-anchor-${e}`);l.add(`maplibregl-${a}-anchor-${s}`)}class cs extends a.E{constructor(e){if(super(),this._onKeyPress=e=>{const s=e.code,a=e.charCode||e.keyCode;"Space"!==s&&"Enter"!==s&&32!==a&&13!==a||this.togglePopup()},this._onMapClick=e=>{const s=e.originalEvent.target,a=this._element;this._popup&&(s===a||a.contains(s))&&this.togglePopup()},this._update=e=>{if(!this._map)return;const s=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!s)&&this._map.once("render",this._update),this._lngLat=wo(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let a="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?a=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(a=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let l="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?l="rotateX(0deg)":"map"===this._pitchAlignment&&(l=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&"moveend"!==e.type||(this._pos=this._pos.round()),h.setTransform(this._element,`${Po[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${l} ${a}`),_.frameAsync(new AbortController).then((()=>{this._updateOpacity(e&&"moveend"===e.type)})).catch((()=>{}))},this._onMove=e=>{if(!this._isDragging){const s=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=s}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new a.l("dragstart"))),this.fire(new a.l("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new a.l("dragend")),this._state="inactive"},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,this.setOpacity(null==e?void 0:e.opacity,null==e?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=a.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=h.create("div");const s=h.createNS("http://www.w3.org/2000/svg","svg"),l=41,c=27;s.setAttributeNS(null,"display","block"),s.setAttributeNS(null,"height",`${l}px`),s.setAttributeNS(null,"width",`${c}px`),s.setAttributeNS(null,"viewBox",`0 0 ${c} ${l}`);const u=h.createNS("http://www.w3.org/2000/svg","g");u.setAttributeNS(null,"stroke","none"),u.setAttributeNS(null,"stroke-width","1"),u.setAttributeNS(null,"fill","none"),u.setAttributeNS(null,"fill-rule","evenodd");const d=h.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"fill-rule","nonzero");const f=h.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"transform","translate(3.0, 29.0)"),f.setAttributeNS(null,"fill","#000000");const _=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const e of _){const s=h.createNS("http://www.w3.org/2000/svg","ellipse");s.setAttributeNS(null,"opacity","0.04"),s.setAttributeNS(null,"cx","10.5"),s.setAttributeNS(null,"cy","5.80029008"),s.setAttributeNS(null,"rx",e.rx),s.setAttributeNS(null,"ry",e.ry),f.appendChild(s)}const y=h.createNS("http://www.w3.org/2000/svg","g");y.setAttributeNS(null,"fill",this._color);const b=h.createNS("http://www.w3.org/2000/svg","path");b.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),y.appendChild(b);const S=h.createNS("http://www.w3.org/2000/svg","g");S.setAttributeNS(null,"opacity","0.25"),S.setAttributeNS(null,"fill","#000000");const P=h.createNS("http://www.w3.org/2000/svg","path");P.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),S.appendChild(P);const M=h.createNS("http://www.w3.org/2000/svg","g");M.setAttributeNS(null,"transform","translate(6.0, 7.0)"),M.setAttributeNS(null,"fill","#FFFFFF");const C=h.createNS("http://www.w3.org/2000/svg","g");C.setAttributeNS(null,"transform","translate(8.0, 8.0)");const D=h.createNS("http://www.w3.org/2000/svg","circle");D.setAttributeNS(null,"fill","#000000"),D.setAttributeNS(null,"opacity","0.25"),D.setAttributeNS(null,"cx","5.5"),D.setAttributeNS(null,"cy","5.5"),D.setAttributeNS(null,"r","5.4999962");const L=h.createNS("http://www.w3.org/2000/svg","circle");L.setAttributeNS(null,"fill","#FFFFFF"),L.setAttributeNS(null,"cx","5.5"),L.setAttributeNS(null,"cy","5.5"),L.setAttributeNS(null,"r","5.4999962"),C.appendChild(D),C.appendChild(L),d.appendChild(f),d.appendChild(y),d.appendChild(S),d.appendChild(M),d.appendChild(C),s.appendChild(d),s.setAttributeNS(null,"height",l*this._scale+"px"),s.setAttributeNS(null,"width",c*this._scale+"px"),this._element.appendChild(s),this._offset=a.P.convert(e&&e.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(e=>{e.preventDefault()})),this._element.addEventListener("mousedown",(e=>{e.preventDefault()})),Co(this._element,this._anchor,"marker"),e&&e.className)for(const s of e.className.split(" "))this._element.classList.add(s);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),this._element.hasAttribute("role")||this._element.setAttribute("role","button"),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),h.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=a.U.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const s=38.1,a=13.5,l=Math.abs(a)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-s],"bottom-left":[l,-1*(s-a+l)],"bottom-right":[-l,-1*(s-a+l)],left:[a,-1*(s-a)],right:[-a,-1*(s-a)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var s,l;const c=null===(s=this._map)||void 0===s?void 0:s.terrain,u=this._map.transform.isLocationOccluded(this._lngLat);if(!c||u){const e=u?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==e&&(this._element.style.opacity=e))}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null}),100)}const d=this._map,f=d.terrain.depthAtPoint(this._pos),_=d.terrain.getElevationForLngLatZoom(this._lngLat,d.transform.tileZoom);if(d.transform.lngLatToCameraDepth(this._lngLat,_)-f<.006)return void(this._element.style.opacity=this._opacity);const y=-this._offset.y/d.transform.pixelsPerMeter,b=Math.sin(d.getPitch()*Math.PI/180)*y,S=d.terrain.depthAtPoint(new a.P(this._pos.x,this._pos.y-this._offset.y)),P=d.transform.lngLatToCameraDepth(this._lngLat,_+b)-S>.006;(null===(l=this._popup)||void 0===l?void 0:l.isOpen())&&P&&this._popup.remove(),this._element.style.opacity=P?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=a.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&"auto"!==e?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,s){return(void 0===this._opacity||void 0===e&&void 0===s)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=e),void 0!==s&&(this._opacityWhenCovered=s),this._map&&this._updateOpacity(!0),this}}const Vo={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let No=0,jo=!1;const Ho={maxWidth:100,unit:"metric"};function Qo(e,s,a){const l=a&&a.maxWidth||100,c=e._container.clientHeight/2,u=e._container.clientWidth/2,d=e.unproject([u-l/2,c]),f=e.unproject([u+l/2,c]),_=Math.round(e.project(f).x-e.project(d).x),y=Math.min(l,_,e._container.clientWidth),b=d.distanceTo(f);if(a&&"imperial"===a.unit){const a=3.2808*b;a>5280?Ja(s,y,a/5280,e._getUIString("ScaleControl.Miles")):Ja(s,y,a,e._getUIString("ScaleControl.Feet"))}else a&&"nautical"===a.unit?Ja(s,y,b/1852,e._getUIString("ScaleControl.NauticalMiles")):b>=1e3?Ja(s,y,b/1e3,e._getUIString("ScaleControl.Kilometers")):Ja(s,y,b,e._getUIString("ScaleControl.Meters"))}function Ja(e,s,a,l){const c=function(e){const s=Math.pow(10,`${Math.floor(e)}`.length-1);let a=e/s;return a=a>=10?10:a>=5?5:a>=3?3:a>=2?2:a>=1?1:function(e){const s=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*s)/s}(a),s*a}(a);e.style.width=s*(c/a)+"px",e.innerHTML=`${c}&nbsp;${l}`}const el={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0},tl=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function il(e){if(e){if("number"==typeof e){const s=Math.round(Math.abs(e)/Math.SQRT2);return{center:new a.P(0,0),top:new a.P(0,e),"top-left":new a.P(s,s),"top-right":new a.P(-s,s),bottom:new a.P(0,-e),"bottom-left":new a.P(s,-s),"bottom-right":new a.P(-s,-s),left:new a.P(e,0),right:new a.P(-e,0)}}if(e instanceof a.P||Array.isArray(e)){const s=a.P.convert(e);return{center:s,top:s,"top-left":s,"top-right":s,bottom:s,"bottom-left":s,"bottom-right":s,left:s,right:s}}return{center:a.P.convert(e.center||[0,0]),top:a.P.convert(e.top||[0,0]),"top-left":a.P.convert(e["top-left"]||[0,0]),"top-right":a.P.convert(e["top-right"]||[0,0]),bottom:a.P.convert(e.bottom||[0,0]),"bottom-left":a.P.convert(e["bottom-left"]||[0,0]),"bottom-right":a.P.convert(e["bottom-right"]||[0,0]),left:a.P.convert(e.left||[0,0]),right:a.P.convert(e.right||[0,0])}}return il(new a.P(0,0))}const rl=l;s.AJAXError=a.cD,s.Event=a.l,s.Evented=a.E,s.LngLat=a.U,s.MercatorCoordinate=a.a5,s.Point=a.P,s.addProtocol=a.cE,s.config=a.a,s.removeProtocol=a.cF,s.AttributionControl=Wo,s.BoxZoomHandler=ao,s.CanvasSource=ae,s.CooperativeGesturesHandler=Oo,s.DoubleClickZoomHandler=zo,s.DragPanHandler=ko,s.DragRotateHandler=Fo,s.EdgeInsets=Lt,s.FullscreenControl=class extends a.E{constructor(e={}){super(),this._onFullscreenChange=()=>{var e;let s=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(e=null==s?void 0:s.shadowRoot)||void 0===e?void 0:e.fullscreenElement;)s=s.shadowRoot.fullscreenElement;s===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:a.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){h.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const e=this._fullscreenButton=h.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);h.create("span","maplibregl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.title=e}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new a.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new a.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},s.GeoJSONSource=ee,s.GeolocateControl=class extends a.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new a.l("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new a.l("geolocate",e)),this._finish()}},this._updateCamera=e=>{const s=new a.U(e.coords.longitude,e.coords.latitude),l=e.coords.accuracy,c=this._map.getBearing(),u=a.e({bearing:c},this.options.fitBoundsOptions),d=$.fromLngLat(s,l);this._map.fitBounds(d,u,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const s=new a.U(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(s).addTo(this._map),this._userLocationDotMarker.setLngLat(s).addTo(this._map),this._accuracy=e.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=e=>{if(this._map){if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&jo)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new a.l("error",e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=h.create("button","maplibregl-ctrl-geolocate",this._container),h.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(!1===e){a.w("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=h.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new cs({element:this._dotElement}),this._circleElement=h.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new cs({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onUpdate),this._map.on("move",this._onUpdate),this._map.on("rotate",this._onUpdate),this._map.on("pitch",this._onUpdate)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(e=>{const s=(null==e?void 0:e[0])instanceof ResizeObserverEntry;e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||s||this._map.isZooming()||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new a.l("trackuserlocationend")),this.fire(new a.l("userlocationlostfocus")))}))}},this.options=a.e({},Vo,e)}onAdd(e){return this._map=e,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return a._(this,arguments,void 0,(function*(e=!1){if(void 0!==bo&&!e)return bo;if(void 0===window.navigator.permissions)return bo=!!window.navigator.geolocation,bo;try{const e=yield window.navigator.permissions.query({name:"geolocation"});bo="denied"!==e.state}catch(e){bo=!!window.navigator.geolocation}return bo}))}().then((e=>this._finishSetupUI(e))),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),h.remove(this._container),this._map.off("zoom",this._onUpdate),this._map.off("move",this._onUpdate),this._map.off("rotate",this._onUpdate),this._map.off("pitch",this._onUpdate),this._map=void 0,No=0,jo=!1}_isOutOfMapMaxBounds(e){const s=this._map.getMaxBounds(),a=e.coords;return s&&(a.longitude<s.getWest()||a.longitude>s.getEast()||a.latitude<s.getSouth()||a.latitude>s.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":case"BACKGROUND_ERROR":case"OFF":case void 0:break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){const e=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&e))return;const s=this._map.project(e),a=this._map.unproject([s.x+100,s.y]),l=e.distanceTo(a)/100,c=2*this._accuracy/l;this._circleElement.style.width=`${c.toFixed(2)}px`,this._circleElement.style.height=`${c.toFixed(2)}px`}trigger(){if(!this._setup)return a.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new a.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":No--,jo=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new a.l("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new a.l("trackuserlocationstart")),this.fire(new a.l("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),No++,No>1?(e={maximumAge:6e5,timeout:0},jo=!0):(e=this.options.positionOptions,jo=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},s.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;const s=null===(e=this._map.getProjection())||void 0===e?void 0:e.type;this._map.setProjection("mercator"!==s&&s?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var e;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===(null===(e=this._map.getProjection())||void 0===e?void 0:e.type)?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(e){return this._map=e,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=h.create("button","maplibregl-ctrl-globe",this._container),h.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){h.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},s.Hash=Nr,s.ImageSource=te,s.KeyboardHandler=Io,s.LngLatBounds=$,s.LogoControl=qo,s.Map=class extends Go{constructor(e){var s,l;a.cA.mark(a.cB.create);const c=Object.assign(Object.assign(Object.assign({},uo),e),{canvasContextAttributes:Object.assign(Object.assign({},uo.canvasContextAttributes),e.canvasContextAttributes)});if(null!=c.minZoom&&null!=c.maxZoom&&c.minZoom>c.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=c.minPitch&&null!=c.maxPitch&&c.minPitch>c.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=c.minPitch&&c.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=c.maxPitch&&c.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const u=new Nt,d=new Wt;if(void 0!==c.minZoom&&u.setMinZoom(c.minZoom),void 0!==c.maxZoom&&u.setMaxZoom(c.maxZoom),void 0!==c.minPitch&&u.setMinPitch(c.minPitch),void 0!==c.maxPitch&&u.setMaxPitch(c.maxPitch),void 0!==c.renderWorldCopies&&u.setRenderWorldCopies(c.renderWorldCopies),null!==c.transformConstrain&&u.setConstrainOverride(c.transformConstrain),super(u,d,{bearingSnap:c.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new $o,this._controls=[],this._mapId=a.ab(),this._lostContextStyle={style:null,images:null},this._contextLost=e=>{e.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.painter.destroy();for(const e of Object.values(this.style._layers))if("custom"===e.type&&console.warn(`Custom layer with id '${e.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),e._listeners)for(const[s]of Object.entries(e._listeners))console.warn(`Custom layer with id '${e.id}' had event listeners for event '${s}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this._lostContextStyle=this._getStyleAndImages(),this.style.destroy(),this.style=null,this.fire(new a.l("webglcontextlost",{originalEvent:e}))},this._contextRestored=e=>{this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&(this.style.imageManager.images=this._lostContextStyle.images),this._setupPainter(),this.resize(),this._update(),this.fire(new a.l("webglcontextrestored",{originalEvent:e}))},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=c.interactive,this._maxTileCacheSize=c.maxTileCacheSize,this._maxTileCacheZoomLevels=c.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},c.canvasContextAttributes),this._trackResize=!0===c.trackResize,this._bearingSnap=c.bearingSnap,this._centerClampedToGround=c.centerClampedToGround,this._refreshExpiredTiles=!0===c.refreshExpiredTiles,this._fadeDuration=c.fadeDuration,this._crossSourceCollisions=!0===c.crossSourceCollisions,this._collectResourceTiming=!0===c.collectResourceTiming,this._locale=Object.assign(Object.assign({},ro),c.locale),this._clickTolerance=c.clickTolerance,this._overridePixelRatio=c.pixelRatio,this._maxCanvasSize=c.maxCanvasSize,this._zoomLevelsToOverscale=c.experimentalZoomLevelsToOverscale,this.transformCameraUpdate=c.transformCameraUpdate,this.transformConstrain=c.transformConstrain,this.cancelPendingTileRequestsWhileZooming=!0===c.cancelPendingTileRequestsWhileZooming,void 0!==c.reduceMotion&&(_.prefersReducedMotion=c.reduceMotion),this._imageQueueHandle=F.addThrottleControl((()=>this.isMoving())),this._requestManager=new v(c.transformRequest),"string"==typeof c.container){if(this._container=document.getElementById(c.container),!this._container)throw new Error(`Container '${c.container}' not found.`)}else{if(!(c.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=c.container}if(c.maxBounds&&this.setMaxBounds(c.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)})),this.once("idle",(()=>{this._idleTriggered=!0})),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let e=!1;const s=ss((e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())}),50);this._resizeObserver=new ResizeObserver((a=>{e?s(a):e=!0})),this._resizeObserver.observe(this._container)}this.handlers=new Zo(this,c),this._hash=c.hash&&new Nr("string"==typeof c.hash&&c.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:c.center,elevation:c.elevation,zoom:c.zoom,bearing:c.bearing,pitch:c.pitch,roll:c.roll}),c.bounds&&(this.resize(),this.fitBounds(c.bounds,a.e({},c.fitBoundsOptions,{duration:0}))));const f="string"==typeof c.style||!("globe"===(null===(l=null===(s=c.style)||void 0===s?void 0:s.projection)||void 0===l?void 0:l.type));this.resize(null,f),this._localIdeographFontFamily=c.localIdeographFontFamily,this._validateStyle=c.validateStyle,c.style&&this.setStyle(c.style,{localIdeographFontFamily:c.localIdeographFontFamily}),c.attributionControl&&this.addControl(new Wo("boolean"==typeof c.attributionControl?void 0:c.attributionControl)),c.maplibreLogo&&this.addControl(new qo,c.logoPosition),this.on("style.load",(()=>{if(f||this._resizeTransform(),this.transform.unmodified){const e=a.S(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e)}})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new a.l(`${e.dataType}data`,e))})),this.on("dataloading",(e=>{this.fire(new a.l(`${e.dataType}dataloading`,e))})),this.on("dataabort",(e=>{this.fire(new a.l("sourcedataabort",e))}))}_getMapId(){return this._mapId}setGlobalStateProperty(e,s){return this.style.setGlobalStateProperty(e,s),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,s){if(void 0===s&&(s=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new a.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const l=e.onAdd(this);this._controls.push(e);const c=this._controlPositions[s];return-1!==s.indexOf("bottom")?c.insertBefore(l,c.firstChild):c.appendChild(l),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new a.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const s=this._controls.indexOf(e);return s>-1&&this._controls.splice(s,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}coveringTiles(e){return Xe(this.transform,e)}calculateCameraOptionsFromTo(e,s,a,l){return null==l&&this.terrain&&(l=this.terrain.getElevationForLngLatZoom(a,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(e,s,a,l)}resize(e,s=!0){const[l,c]=this._containerDimensions(),u=this._getClampedPixelRatio(l,c);if(this._resizeCanvas(l,c,u),this.painter.resize(l,c,u),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const s=this._getClampedPixelRatio(l,c);this._resizeCanvas(l,c,s),this.painter.resize(l,c,s)}this._resizeTransform(s);const d=!this._moving;return d&&(this.stop(),this.fire(new a.l("movestart",e)).fire(new a.l("move",e))),this.fire(new a.l("resize",e)),d&&this.fire(new a.l("moveend",e)),this}_resizeTransform(e=!0){var s;const[a,l]=this._containerDimensions();this.transform.resize(a,l,e),null===(s=this._requestedCameraState)||void 0===s||s.resize(a,l,e)}_getClampedPixelRatio(e,s){const{0:a,1:l}=this._maxCanvasSize,c=this.getPixelRatio(),u=e*c,d=s*c;return Math.min(u>a?a/u:1,d>l?l/d:1)*c}getPixelRatio(){var e;return null!==(e=this._overridePixelRatio)&&void 0!==e?e:devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds($.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.setMinZoom(e),this._update(),this.getZoom()<e&&this.setZoom(e),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(e){if((e=null==e?22:e)>=this.transform.minZoom)return this.transform.setMaxZoom(e),this._update(),this.getZoom()>e&&this.setZoom(e),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.setMinPitch(e),this._update(),this.getPitch()<e&&this.setPitch(e),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(e){if((e=null==e?60:e)>180)throw new Error("maxPitch must be less than or equal to 180");if(e>=this.transform.minPitch)return this.transform.setMaxPitch(e),this._update(),this.getPitch()>e&&this.setPitch(e),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}setTransformConstrain(e){return this.transform.setConstrainOverride(e),this._update()}project(e){return this.transform.locationToScreenPoint(a.U.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(a.P.convert(e),this.terrain)}isMoving(){var e;return this._moving||(null===(e=this.handlers)||void 0===e?void 0:e.isMoving())}isZooming(){var e;return this._zooming||(null===(e=this.handlers)||void 0===e?void 0:e.isZooming())}isRotating(){var e;return this._rotating||(null===(e=this.handlers)||void 0===e?void 0:e.isRotating())}_createDelegatedListener(e,s,a){if("mouseenter"===e||"mouseover"===e){let l=!1;const c=c=>{const u=s.filter((e=>this.getLayer(e))),d=0!==u.length?this.queryRenderedFeatures(c.point,{layers:u}):[];d.length?l||(l=!0,a.call(this,new Yr(e,this,c.originalEvent,{features:d}))):l=!1};return{layers:s,listener:a,delegates:{mousemove:c,mouseout:()=>{l=!1}}}}if("mouseleave"===e||"mouseout"===e){let l=!1;const c=c=>{const u=s.filter((e=>this.getLayer(e)));(0!==u.length?this.queryRenderedFeatures(c.point,{layers:u}):[]).length?l=!0:l&&(l=!1,a.call(this,new Yr(e,this,c.originalEvent)))},u=s=>{l&&(l=!1,a.call(this,new Yr(e,this,s.originalEvent)))};return{layers:s,listener:a,delegates:{mousemove:c,mouseout:u}}}{const l=e=>{const l=s.filter((e=>this.getLayer(e))),c=0!==l.length?this.queryRenderedFeatures(e.point,{layers:l}):[];c.length&&(e.features=c,a.call(this,e),delete e.features)};return{layers:s,listener:a,delegates:{[e]:l}}}}_saveDelegatedListener(e,s){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(s)}_removeDelegatedListener(e,s,a){if(!this._delegatedListeners||!this._delegatedListeners[e])return;const l=this._delegatedListeners[e];for(let e=0;e<l.length;e++){const c=l[e];if(c.listener===a&&c.layers.length===s.length&&c.layers.every((e=>s.includes(e)))){for(const e in c.delegates)this.off(e,c.delegates[e]);return void l.splice(e,1)}}}on(e,s,a){if(void 0===a)return super.on(e,s);const l="string"==typeof s?[s]:s,c=this._createDelegatedListener(e,l,a);this._saveDelegatedListener(e,c);for(const e in c.delegates)this.on(e,c.delegates[e]);return{unsubscribe:()=>{this._removeDelegatedListener(e,l,a)}}}once(e,s,a){if(void 0===a)return super.once(e,s);const l="string"==typeof s?[s]:s,c=this._createDelegatedListener(e,l,a);for(const s in c.delegates){const u=c.delegates[s];c.delegates[s]=(...s)=>{this._removeDelegatedListener(e,l,a),u(...s)}}this._saveDelegatedListener(e,c);for(const e in c.delegates)this.once(e,c.delegates[e]);return this}off(e,s,a){return void 0===a?super.off(e,s):(this._removeDelegatedListener(e,"string"==typeof s?[s]:s,a),this)}queryRenderedFeatures(e,s){if(!this.style)return[];let l;const c=e instanceof a.P||Array.isArray(e),u=c?e:[[0,0],[this.transform.width,this.transform.height]];if(s=s||(c?{}:e)||{},u instanceof a.P||"number"==typeof u[0])l=[a.P.convert(u)];else{const e=a.P.convert(u[0]),s=a.P.convert(u[1]);l=[e,new a.P(s.x,e.y),s,new a.P(e.x,s.y),e]}return this.style.queryRenderedFeatures(l,s,this.transform)}querySourceFeatures(e,s){return this.style.querySourceFeatures(e,s)}setStyle(e,s){return!1!==(s=a.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},s)).diff&&s.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,s),this):(this._localIdeographFontFamily=s.localIdeographFontFamily,this._updateStyle(e,s))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){const s=this._locale[e];if(null==s)throw new Error(`Missing UI string '${e}'`);return s}_updateStyle(e,s){var a,l;if(s.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(e,s)));const c=this.style&&s.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new Si(this,s||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,s,c):this.style.loadJSON(e,s,c),this):(null===(l=null===(a=this.style)||void 0===a?void 0:a.projection)||void 0===l||l.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Si(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,s){if("string"==typeof e){const l=this._requestManager.transformRequest(e,"Style");a.j(l,new AbortController).then((e=>{this._updateDiff(e.data,s)})).catch((e=>{e&&this.fire(new a.k(e))}))}else"object"==typeof e&&this._updateDiff(e,s)}_updateDiff(e,s){try{this.style.setState(e,s)&&this._update(!0)}catch(l){a.w(`Unable to perform style diff: ${l.message||l.error||l}. Rebuilding the style from scratch.`),this._updateStyle(e,s)}}getStyle(){if(this.style)return this.style.serialize()}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){return this.style?this.style.loaded():a.w("There is no style added to the map.")}addSource(e,s){return this._lazyInitEmptyStyle(),this.style.addSource(e,s),this._update(!0)}isSourceLoaded(e){const s=this.style&&this.style.tileManagers[e];if(void 0!==s)return s.loaded();this.fire(new a.k(new Error(`There is no tile manager with ID '${e}'`)))}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){const s=this.style.tileManagers[e.source];if(!s)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&s.reload();for(const s in this.style._layers){const l=this.style._layers[s];"hillshade"===l.type&&l.source===e.source&&a.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),"color-relief"===l.type&&l.source===e.source&&a.w("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new Ko(this.painter,s,e),this.painter.renderToTexture=new Jo(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=s=>{var a;"style"===s.dataType?this.terrain.tileManager.freeRtt():"source"===s.dataType&&s.tile&&(s.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),"image"===(null===(a=s.source)||void 0===a?void 0:a.type)?this.terrain.tileManager.freeRtt():this.terrain.tileManager.freeRtt(s.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.tileManager.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new a.l("terrain",{terrain:e})),this}getTerrain(){var e,s;return null!==(s=null===(e=this.terrain)||void 0===e?void 0:e.options)&&void 0!==s?s:null}areTilesLoaded(){const e=this.style&&this.style.tileManagers;for(const s in e){const a=e[s]._tiles;for(const e in a){const s=a[e];if("loaded"!==s.state&&"errored"!==s.state)return!1}}return!0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}setSourceTileLodParams(e,s,a){if(a){const l=this.getSource(a);if(!l)throw new Error(`There is no source with ID "${a}", cannot set LOD parameters`);l.calculateTileZoom=$e(Math.max(1,e),Math.max(1,s))}else for(const a in this.style.tileManagers)this.style.tileManagers[a].getSource().calculateTileZoom=$e(Math.max(1,e),Math.max(1,s));return this._update(!0),this}refreshTiles(e,s){const l=this.style.tileManagers[e];if(!l)throw new Error(`There is no tile manager with ID "${e}", cannot refresh tile`);void 0===s?l.reload(!0):l.refreshTiles(s.map((e=>new a.a8(e.z,e.x,e.y))))}addImage(e,s,l={}){const{pixelRatio:c=1,sdf:u=!1,stretchX:d,stretchY:f,content:y,textFitWidth:b,textFitHeight:S}=l;if(this._lazyInitEmptyStyle(),!(s instanceof HTMLImageElement||a.b(s))){if(void 0===s.width||void 0===s.height)return this.fire(new a.k(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:l,height:_,data:P}=s,M=s;return this.style.addImage(e,{data:new a.R({width:l,height:_},new Uint8Array(P)),pixelRatio:c,stretchX:d,stretchY:f,content:y,textFitWidth:b,textFitHeight:S,sdf:u,version:0,userImage:M}),M.onAdd&&M.onAdd(this,e),this}}{const{width:l,height:P,data:M}=_.getImageData(s);this.style.addImage(e,{data:new a.R({width:l,height:P},M),pixelRatio:c,stretchX:d,stretchY:f,content:y,textFitWidth:b,textFitHeight:S,sdf:u,version:0})}}updateImage(e,s){const l=this.style.getImage(e);if(!l)return this.fire(new a.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const c=s instanceof HTMLImageElement||a.b(s)?_.getImageData(s):s,{width:u,height:d,data:f}=c;if(void 0===u||void 0===d)return this.fire(new a.k(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`")));if(u!==l.data.width||d!==l.data.height)return this.fire(new a.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const y=!(s instanceof HTMLImageElement||a.b(s));return l.data.replace(f,y),this.style.updateImage(e,l),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new a.k(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(e){return F.getImage(this._requestManager.transformRequest(e,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(e,s){return this._lazyInitEmptyStyle(),this.style.addLayer(e,s),this._update(!0)}moveLayer(e,s){return this.style.moveLayer(e,s),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,s,a){return this.style.setLayerZoomRange(e,s,a),this._update(!0)}setFilter(e,s,a={}){return this.style.setFilter(e,s,a),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,s,a,l={}){return this.style.setPaintProperty(e,s,a,l),this._update(!0)}getPaintProperty(e,s){return this.style.getPaintProperty(e,s)}setLayoutProperty(e,s,a,l={}){return this.style.setLayoutProperty(e,s,a,l),this._update(!0)}getLayoutProperty(e,s){return this.style.getLayoutProperty(e,s)}setGlyphs(e,s={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,s),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,s,a={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,s,a,(e=>{e||this._update(!0)})),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,s={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,s,(e=>{e||this._update(!0)})),this}setLight(e,s={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,s),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,s={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,s),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,s){return this.style.setFeatureState(e,s),this._update()}removeFeatureState(e,s){return this.style.removeFeatureState(e,s),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,s=0;return this._container&&(e=this._container.clientWidth||400,s=this._container.clientHeight||300),[e,s]}_setupContainer(){const e=this._container;e.classList.add("maplibregl-map");const s=this._canvasContainer=h.create("div","maplibregl-canvas-container",e);this._interactive&&s.classList.add("maplibregl-interactive"),this._canvas=h.create("canvas","maplibregl-canvas",s),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const a=this._containerDimensions(),l=this._getClampedPixelRatio(a[0],a[1]);this._resizeCanvas(a[0],a[1],l);const c=this._controlContainer=h.create("div","maplibregl-control-container",e),u=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{u[e]=h.create("div",`maplibregl-ctrl-${e} `,c)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,s,a){this._canvas.width=Math.floor(a*e),this._canvas.height=Math.floor(a*s),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${s}px`}_setupPainter(){const e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let s=null;this._canvas.addEventListener("webglcontextcreationerror",(a=>{s={requestedAttributes:e},a&&(s.statusMessage=a.statusMessage,s.type=a.type)}),{once:!0});let a=null;if(a=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext("webgl2",e)||this._canvas.getContext("webgl",e),!a){const e="Failed to initialize WebGL";throw s?(s.message=e,new Error(JSON.stringify(s))):new Error(e)}this.painter=new jr(a,this.transform),S.testSupport(a)}migrateProjection(e,s){super.migrateProjection(e,s),this.painter.transform=e,this.fire(new a.l("projectiontransition",{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_render(e){var s,l,c,u,d;const f=this._idleTriggered?this._fadeDuration:0,_=(null===(s=this.style.projection)||void 0===s?void 0:s.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let y=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,s=b();this.style.zoomHistory.update(e,s);const l=new a.G(e,{now:s,fadeDuration:f,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),c=l.crossFadingFactor();1===c&&c===this._crossFadingFactor||(y=!0,this._crossFadingFactor=c),this.style.update(l)}const S=(null===(l=this.style.projection)||void 0===l?void 0:l.transitionState)>0!==_;null===(c=this.style.projection)||void 0===c||c.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(u=this.style.projection)||void 0===u?void 0:u.transitionState,null===(d=this.style.projection)||void 0===d?void 0:d.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||S)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.tileManager.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,f,this._crossSourceCollisions,S),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:f,showPadding:this.showPadding}),this.fire(new a.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,a.cA.mark(a.cB.load),this.fire(new a.l("load"))),this.style&&(this.style.hasTransitions()||y)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const P=this._sourcesDirty||this._styleDirty||this._placementDirty;return P||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new a.l("idle")),!this._loaded||this._fullyLoaded||P||(this._fullyLoaded=!0,a.cA.mark(a.cB.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var e;this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),F.removeThrottleControl(this._imageQueueHandle),null===(e=this._resizeObserver)||void 0===e||e.disconnect();const s=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==s?void 0:s.loseContext)&&s.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),h.remove(this._canvasContainer),h.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),a.cA.clearMetrics(),this._removed=!0,this.fire(new a.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,_.frame(this._frameRequest,(e=>{a.cA.frame(e),this._frameRequest=null;try{this._render(e)}catch(e){if(!a.cC(e)&&!function(e){return e.message===gn}(e))throw e}}),(()=>{})))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get version(){return co}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},s.MapMouseEvent=Yr,s.MapTouchEvent=Qr,s.MapWheelEvent=Jr,s.Marker=cs,s.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const e=this._map.getZoom(),s=e===this._map.getMaxZoom(),a=e===this._map.getMinZoom();this._zoomInButton.disabled=s,this._zoomOutButton.disabled=a,this._zoomInButton.setAttribute("aria-disabled",s.toString()),this._zoomOutButton.setAttribute("aria-disabled",a.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(e,s)=>{const a=this._map._getUIString(`NavigationControl.${s}`);e.title=a,e.setAttribute("aria-label",a)},this.options=a.e({},fo,e),this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(e=>this._map.zoomIn({},{originalEvent:e}))),h.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(e=>this._map.zoomOut({},{originalEvent:e}))),h.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})})),this._compassIcon=h.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new rs(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){h.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(e,s){const a=h.create("button",e,this._container);return a.type="button",a.addEventListener("click",s),a}},s.Popup=class extends a.E{constructor(e){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"")},this.remove=()=>(this._content&&h.remove(this._content),this._container&&(h.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new a.l("close"))),this),this._onMouseUp=e=>{this._update(e.point)},this._onMouseMove=e=>{this._update(e.point)},this._onDrag=e=>{this._update(e.point)},this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=h.create("div","maplibregl-popup",this._map.getContainer()),this._tip=h.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const e of this.options.className.split(" "))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=wo(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!e)return;const s=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let a=this.options.anchor;const l=il(this.options.offset);if(!a){const e=this._container.offsetWidth,c=this._container.offsetHeight;let u;u=s.y+l.bottom.y<c?["top"]:s.y>this._map.transform.height-c?["bottom"]:[],s.x<e/2?u.push("left"):s.x>this._map.transform.width-e/2&&u.push("right"),a=0===u.length?"bottom":u.join("-")}let c=s.add(l[a]);this.options.subpixelPositioning||(c=c.round()),h.setTransform(this._container,`${Po[a]} translate(${c.x}px,${c.y}px)`),Co(this._container,a,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=a.e(Object.create(el),e)}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new a.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=a.U.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const s=document.createDocumentFragment(),a=document.createElement("body");let l;for(a.innerHTML=e;l=a.firstChild,l;)s.appendChild(l);return this.setDOMContent(s)}getMaxWidth(){var e;return null===(e=this._container)||void 0===e?void 0:e.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=h.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e}_createCloseButton(){this.options.closeButton&&(this._closeButton=h.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(tl);e&&e.focus()}},s.RasterDEMTileSource=Y,s.RasterTileSource=K,s.ScaleControl=class{constructor(e){this._onMove=()=>{Qo(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,Qo(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},Ho),e)}getDefaultPosition(){return"bottom-left"}onAdd(e){return this._map=e,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){h.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},s.ScrollZoomHandler=Do,s.Style=Si,s.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=e}onAdd(e){return this._map=e,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=h.create("button","maplibregl-ctrl-terrain",this._container),h.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){h.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},s.TwoFingersTouchPitchHandler=Mo,s.TwoFingersTouchRotateHandler=To,s.TwoFingersTouchZoomHandler=yo,s.TwoFingersTouchZoomRotateHandler=Bo,s.VectorTileSource=X,s.VideoSource=ie,s.addSourceType=(e,s)=>a._(void 0,void 0,void 0,(function*(){if(Ee(e))throw new Error(`A source type called "${e}" already exists.`);((e,s)=>{Me[e]=s})(e,s)})),s.clearPrewarmedResources=function(){const e=se;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(J),se=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()"))},s.createTileMesh=Hi,s.getMaxParallelImageRequests=function(){return a.a.MAX_PARALLEL_IMAGE_REQUESTS},s.getRTLTextPluginStatus=function(){return ke().getRTLTextPluginStatus()},s.getVersion=function(){return rl},s.getWorkerCount=function(){return k.workerCount},s.getWorkerUrl=function(){return a.a.WORKER_URL},s.importScriptInWorkers=function(e){return pe().broadcast("IS",e)},s.isTimeFrozen=function(){return y.isFrozen()},s.now=b,s.prewarm=function(){ce().acquire(J)},s.restoreNow=function(){y.restoreNow()},s.setMaxParallelImageRequests=function(e){a.a.MAX_PARALLEL_IMAGE_REQUESTS=e},s.setNow=function(e){y.setNow(e)},s.setRTLTextPlugin=function(e,s){return ke().setRTLTextPlugin(e,s)},s.setWorkerCount=function(e){k.workerCount=e},s.setWorkerUrl=function(e){a.a.WORKER_URL=e}}));var c=s;return c}));var a=s;export{a as default};