@maptoolkit/maps 11.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +27 -0
- package/README.md +31 -0
- package/dist/maptoolkit.css +508 -0
- package/dist/maptoolkit.d.ts +883 -0
- package/dist/maptoolkit.js +817 -0
- package/dist/maptoolkit.js.map +1 -0
- package/dist/maptoolkit.mjs +817 -0
- package/dist/maptoolkit.mjs.map +1 -0
- package/package.json +83 -0
|
@@ -0,0 +1,817 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maptoolkit Maps JS v11.0.0-beta.1
|
|
3
|
+
* Copyright (c) 2026 Maptoolkit - Toursprung GmbH
|
|
4
|
+
* @license BSD-3-Clause
|
|
5
|
+
* https://github.com/maptoolkit/maps-js/blob/main/LICENSE
|
|
6
|
+
*/(function(ke,Va){typeof exports=="object"&&typeof module<"u"?Va(exports):typeof define=="function"&&define.amd?define(["exports"],Va):(ke=typeof globalThis<"u"?globalThis:ke||self,Va(ke.maptoolkit={}))})(this,(function(ke){"use strict";function Va(Ke){return Ke&&Ke.__esModule&&Object.prototype.hasOwnProperty.call(Ke,"default")?Ke.default:Ke}var Yl={exports:{}};/**
|
|
7
|
+
* MapLibre GL JS
|
|
8
|
+
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.19.0/LICENSE.txt
|
|
9
|
+
*/var If=Yl.exports,rd;function Ef(){return rd||(rd=1,(function(Ke,re){(function(Se,Ae){Ke.exports=Ae()})(If,(function(){var Se={},Ae={};function $e(D,c,Te){if(Ae[D]=Te,D==="index"){var _t="var sharedModule = {}; ("+Ae.shared+")(sharedModule); ("+Ae.worker+")(sharedModule);",ct={};return Ae.shared(ct),Ae.index(Se,ct),typeof window<"u"&&Se.setWorkerUrl(window.URL.createObjectURL(new Blob([_t],{type:"text/javascript"}))),Se}}$e("shared",["exports"],(function(D){function c(r,e,i,s){return new(i||(i=Promise))((function(a,u){function h(y){try{g(s.next(y))}catch(x){u(x)}}function f(y){try{g(s.throw(y))}catch(x){u(x)}}function g(y){var x;y.done?a(y.value):(x=y.value,x instanceof i?x:new i((function(b){b(x)}))).then(h,f)}g((s=s.apply(r,e||[])).next())}))}function Te(r,e){this.x=r,this.y=e}function _t(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var ct,Si;typeof SuppressedError=="function"&&SuppressedError,Te.prototype={clone(){return new Te(this.x,this.y)},add(r){return this.clone()._add(r)},sub(r){return this.clone()._sub(r)},multByPoint(r){return this.clone()._multByPoint(r)},divByPoint(r){return this.clone()._divByPoint(r)},mult(r){return this.clone()._mult(r)},div(r){return this.clone()._div(r)},rotate(r){return this.clone()._rotate(r)},rotateAround(r,e){return this.clone()._rotateAround(r,e)},matMult(r){return this.clone()._matMult(r)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(r){return this.x===r.x&&this.y===r.y},dist(r){return Math.sqrt(this.distSqr(r))},distSqr(r){const e=r.x-this.x,i=r.y-this.y;return e*e+i*i},angle(){return Math.atan2(this.y,this.x)},angleTo(r){return Math.atan2(this.y-r.y,this.x-r.x)},angleWith(r){return this.angleWithSep(r.x,r.y)},angleWithSep(r,e){return Math.atan2(this.x*e-this.y*r,this.x*r+this.y*e)},_matMult(r){const e=r[2]*this.x+r[3]*this.y;return this.x=r[0]*this.x+r[1]*this.y,this.y=e,this},_add(r){return this.x+=r.x,this.y+=r.y,this},_sub(r){return this.x-=r.x,this.y-=r.y,this},_mult(r){return this.x*=r,this.y*=r,this},_div(r){return this.x/=r,this.y/=r,this},_multByPoint(r){return this.x*=r.x,this.y*=r.y,this},_divByPoint(r){return this.x/=r.x,this.y/=r.y,this},_unit(){return this._div(this.mag()),this},_perp(){const r=this.y;return this.y=this.x,this.x=-r,this},_rotate(r){const e=Math.cos(r),i=Math.sin(r),s=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=s,this},_rotateAround(r,e){const i=Math.cos(r),s=Math.sin(r),a=e.y+s*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-s*(this.y-e.y),this.y=a,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:Te},Te.convert=function(r){if(r instanceof Te)return r;if(Array.isArray(r))return new Te(+r[0],+r[1]);if(r.x!==void 0&&r.y!==void 0)return new Te(+r.x,+r.y);throw new Error("Expected [x, y] or {x, y} point format")};var dr=(function(){if(Si)return ct;function r(e,i,s,a){this.cx=3*e,this.bx=3*(s-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*i,this.by=3*(a-i)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=i,this.p2x=s,this.p2y=a}return Si=1,ct=r,r.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,i){if(i===void 0&&(i=1e-6),e<0)return 0;if(e>1)return 1;for(var s=e,a=0;a<8;a++){var u=this.sampleCurveX(s)-e;if(Math.abs(u)<i)return s;var h=this.sampleCurveDerivativeX(s);if(Math.abs(h)<1e-6)break;s-=u/h}var f=0,g=1;for(s=e,a=0;a<20&&(u=this.sampleCurveX(s),!(Math.abs(u-e)<i));a++)e>u?f=s:g=s,s=.5*(g-f)+f;return s},solve:function(e,i){return this.sampleCurveY(this.solveCurveX(e,i))}},ct})(),$t=_t(dr);let tr,He;function pe(){return tr==null&&(tr=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),tr}function pr(){if(He==null&&(He=!1,pe())){const e=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(e){for(let s=0;s<25;s++){const a=4*s;e.fillStyle=`rgb(${a},${a+1},${a+2})`,e.fillRect(s%5,Math.floor(s/5),1,1)}const i=e.getImageData(0,0,5,5).data;for(let s=0;s<100;s++)if(s%4!=3&&i[s]!==s){He=!0;break}}}return He||!1}var bt=1e-6,mt=typeof Float32Array<"u"?Float32Array:Array;function kr(){var r=new mt(9);return mt!=Float32Array&&(r[1]=0,r[2]=0,r[3]=0,r[5]=0,r[6]=0,r[7]=0),r[0]=1,r[4]=1,r[8]=1,r}function Yn(r){return r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=1,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function Ds(){var r=new mt(3);return mt!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r}function Ni(r){var e=r[0],i=r[1],s=r[2];return Math.sqrt(e*e+i*i+s*s)}function zs(r,e,i){var s=new mt(3);return s[0]=r,s[1]=e,s[2]=i,s}function wr(r,e,i){return r[0]=e[0]+i[0],r[1]=e[1]+i[1],r[2]=e[2]+i[2],r}function rn(r,e,i){return r[0]=e[0]*i,r[1]=e[1]*i,r[2]=e[2]*i,r}function xn(r,e,i){var s=e[0],a=e[1],u=e[2],h=i[0],f=i[1],g=i[2];return r[0]=a*g-u*f,r[1]=u*h-s*g,r[2]=s*f-a*h,r}var nn,Tr=Ni;function sn(r,e,i){var s=e[0],a=e[1],u=e[2],h=e[3];return r[0]=i[0]*s+i[4]*a+i[8]*u+i[12]*h,r[1]=i[1]*s+i[5]*a+i[9]*u+i[13]*h,r[2]=i[2]*s+i[6]*a+i[10]*u+i[14]*h,r[3]=i[3]*s+i[7]*a+i[11]*u+i[15]*h,r}function ks(){var r=new mt(4);return mt!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r[3]=1,r}function Kn(r,e,i,s){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:"zyx",u=Math.PI/360;e*=u,s*=u,i*=u;var h=Math.sin(e),f=Math.cos(e),g=Math.sin(i),y=Math.cos(i),x=Math.sin(s),b=Math.cos(s);switch(a){case"xyz":r[0]=h*y*b+f*g*x,r[1]=f*g*b-h*y*x,r[2]=f*y*x+h*g*b,r[3]=f*y*b-h*g*x;break;case"xzy":r[0]=h*y*b-f*g*x,r[1]=f*g*b-h*y*x,r[2]=f*y*x+h*g*b,r[3]=f*y*b+h*g*x;break;case"yxz":r[0]=h*y*b+f*g*x,r[1]=f*g*b-h*y*x,r[2]=f*y*x-h*g*b,r[3]=f*y*b+h*g*x;break;case"yzx":r[0]=h*y*b+f*g*x,r[1]=f*g*b+h*y*x,r[2]=f*y*x-h*g*b,r[3]=f*y*b-h*g*x;break;case"zxy":r[0]=h*y*b-f*g*x,r[1]=f*g*b+h*y*x,r[2]=f*y*x+h*g*b,r[3]=f*y*b-h*g*x;break;case"zyx":r[0]=h*y*b-f*g*x,r[1]=f*g*b+h*y*x,r[2]=f*y*x-h*g*b,r[3]=f*y*b+h*g*x;break;default:throw new Error("Unknown angle order "+a)}return r}function Lr(){var r=new mt(2);return mt!=Float32Array&&(r[0]=0,r[1]=0),r}function Ht(r,e){var i=new mt(2);return i[0]=r,i[1]=e,i}Ds(),nn=new mt(4),mt!=Float32Array&&(nn[0]=0,nn[1]=0,nn[2]=0,nn[3]=0),Ds(),zs(1,0,0),zs(0,1,0),ks(),ks(),kr(),Lr();const ht=8192;function bn(r,e,i){return e*(ht/(r.tileSize*Math.pow(2,i-r.tileID.overscaledZ)))}function Sr(r,e){return(r%e+e)%e}function Ls(r,e,i){return r*(1-i)+e*i}function Jn(r){if(r<=0)return 0;if(r>=1)return 1;const e=r*r,i=e*r;return 4*(r<.5?i:3*(r-e)+i-.75)}function on(r,e,i,s){const a=new $t(r,e,i,s);return u=>a.solve(u)}const Rr=on(.25,.1,.25,1);function ir(r,e,i){return Math.min(i,Math.max(e,r))}function fi(r,e,i){const s=i-e,a=((r-e)%s+s)%s+e;return a===e?i:a}function ki(r,...e){for(const i of e)for(const s in i)r[s]=i[s];return r}let Qn=1;function wn(r,e,i){const s={};for(const a in r)s[a]=e.call(this,r[a],a,r);return s}function Tn(r,e,i){const s={};for(const a in r)e.call(this,r[a],a,r)&&(s[a]=r[a]);return s}function mi(r){return Array.isArray(r)?r.map(mi):typeof r=="object"&&r?wn(r,mi):r}const zo={};function gi(r){zo[r]||(typeof console<"u"&&console.warn(r),zo[r]=!0)}function ji(r,e,i){return(i.y-r.y)*(e.x-r.x)>(e.y-r.y)*(i.x-r.x)}function Pr(r){return typeof WorkerGlobalScope<"u"&&r!==void 0&&r instanceof WorkerGlobalScope}let Mt=null;function Sn(r){return typeof ImageBitmap<"u"&&r instanceof ImageBitmap}const es="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function Pn(r,e,i,s,a){return c(this,void 0,void 0,(function*(){if(typeof VideoFrame>"u")throw new Error("VideoFrame not supported");const u=new VideoFrame(r,{timestamp:0});try{const h=u?.format;if(!h||!h.startsWith("BGR")&&!h.startsWith("RGB"))throw new Error(`Unrecognized format ${h}`);const f=h.startsWith("BGR"),g=new Uint8ClampedArray(s*a*4);if(yield u.copyTo(g,(function(y,x,b,S,P){const I=4*Math.max(-x,0),A=(Math.max(0,b)-b)*S*4+I,L=4*S,O=Math.max(0,x),G=Math.max(0,b);return{rect:{x:O,y:G,width:Math.min(y.width,x+S)-O,height:Math.min(y.height,b+P)-G},layout:[{offset:A,stride:L}]}})(r,e,i,s,a)),f)for(let y=0;y<g.length;y+=4){const x=g[y];g[y]=g[y+2],g[y+2]=x}return g}finally{u.close()}}))}let an,Mr;function ln(r,e,i,s){return r.addEventListener(e,i,s),{unsubscribe:()=>{r.removeEventListener(e,i,s)}}}function Mn(r){return r*Math.PI/180}function Fr(r){return r/Math.PI*180}const Br={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},cn={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},ts="AbortError";class Rs extends Error{constructor(e=ts){super(e instanceof Error?e.message:e),this.name=ts,e instanceof Error&&e.stack&&(this.stack=e.stack)}}function is(r){return r.name===ts}const ie={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function E(r){return ie.REGISTERED_PROTOCOLS[r.substring(0,r.indexOf("://"))]}const k="global-dispatcher";class F extends Error{constructor(e,i,s,a){super(`AJAXError: ${i} (${e}): ${s}`),this.status=e,this.statusText=i,this.url=s,this.body=a}}const $=()=>Pr(self)?self.worker&&self.worker.referrer:(window.location.protocol==="blob:"?window.parent:window).location.href,J=function(r,e){if(/:\/\//.test(r.url)&&!/^https?:|^file:/.test(r.url)){const s=E(r.url);if(s)return s(r,e);if(Pr(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:r,targetMapId:k},e)}if(!(/^file:/.test(i=r.url)||/^file:/.test($())&&!/^\w+:/.test(i))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return(function(s,a){return c(this,void 0,void 0,(function*(){const u=new Request(s.url,{method:s.method||"GET",body:s.body,credentials:s.credentials,headers:s.headers,cache:s.cache,referrer:$(),signal:a.signal});let h,f;s.type!=="json"||u.headers.has("Accept")||u.headers.set("Accept","application/json");try{h=yield fetch(u)}catch(y){throw is(y)?y:new F(0,y.message,s.url,new Blob)}if(!h.ok){const y=yield h.blob();throw new F(h.status,h.statusText,s.url,y)}f=s.type==="arrayBuffer"||s.type==="image"?h.arrayBuffer():s.type==="json"?h.json():h.text();const g=yield f;return a.signal.throwIfAborted(),{data:g,cacheControl:h.headers.get("Cache-Control"),expires:h.headers.get("Expires")}}))})(r,e);if(Pr(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:r,mustQueue:!0,targetMapId:k},e)}var i;return(function(s,a){return new Promise(((u,h)=>{var f;const g=new XMLHttpRequest;g.open(s.method||"GET",s.url,!0),s.type!=="arrayBuffer"&&s.type!=="image"||(g.responseType="arraybuffer");for(const y in s.headers)g.setRequestHeader(y,s.headers[y]);s.type==="json"&&(g.responseType="text",!((f=s.headers)===null||f===void 0)&&f.Accept||g.setRequestHeader("Accept","application/json")),g.withCredentials=s.credentials==="include",g.onerror=()=>{h(new Error(g.statusText))},g.onload=()=>{if(!a.signal.aborted)if((g.status>=200&&g.status<300||g.status===0)&&g.response!==null){let y=g.response;if(s.type==="json")try{y=JSON.parse(g.response)}catch(x){return void h(x)}u({data:y,cacheControl:g.getResponseHeader("Cache-Control"),expires:g.getResponseHeader("Expires")})}else{const y=new Blob([g.response],{type:g.getResponseHeader("Content-Type")});h(new F(g.status,g.statusText,s.url,y))}},a.signal.addEventListener("abort",(()=>{g.abort(),h(new Rs(a.signal.reason))})),g.send(s.body)}))})(r,e)};function oe(r){if(!r||r.indexOf("://")<=0||r.indexOf("data:image/")===0||r.indexOf("blob:")===0)return!0;const e=new URL(r),i=window.location;return e.protocol===i.protocol&&e.host===i.host}function le(r,e,i){i[r]&&i[r].indexOf(e)!==-1||(i[r]=i[r]||[],i[r].push(e))}function ne(r,e,i){if(i&&i[r]){const s=i[r].indexOf(e);s!==-1&&i[r].splice(s,1)}}class se{constructor(e,i={}){ki(this,i),this.type=e}}class be extends se{constructor(e,i={}){super("error",ki({error:e},i))}}class me{on(e,i){return this._listeners=this._listeners||{},le(e,i,this._listeners),{unsubscribe:()=>{this.off(e,i)}}}off(e,i){return ne(e,i,this._listeners),ne(e,i,this._oneTimeListeners),this}once(e,i){return i?(this._oneTimeListeners=this._oneTimeListeners||{},le(e,i,this._oneTimeListeners),this):new Promise((s=>this.once(e,s)))}fire(e,i){typeof e=="string"&&(e=new se(e,i||{}));const s=e.type;if(this.listens(s)){e.target=this;const a=this._listeners&&this._listeners[s]?this._listeners[s].slice():[];for(const f of a)f.call(this,e);const u=this._oneTimeListeners&&this._oneTimeListeners[s]?this._oneTimeListeners[s].slice():[];for(const f of u)ne(s,f,this._oneTimeListeners),f.call(this,e);const h=this._eventedParent;h&&(ki(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),h.fire(e))}else e instanceof be&&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,i){return this._eventedParent=e,this._eventedParentData=i,this}}var K={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number",length:2},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:"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:"filter"},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",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-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",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-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",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-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",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-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",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},filter:{type:"boolean",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},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:"expression_name",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"}},interpolation:{type:"array",value:"interpolation_name",minimum:1},interpolation_name:{type:"enum",values:{linear:{syntax:{overloads:[{parameters:[],"output-type":"interpolation"}],parameters:[]}},exponential:{syntax:{overloads:[{parameters:["base"],"output-type":"interpolation"}],parameters:[{name:"base",type:"number literal"}]}},"cubic-bezier":{syntax:{overloads:[{parameters:["x1","y1","x2","y2"],"output-type":"interpolation"}],parameters:[{name:"x1",type:"number literal"},{name:"y1",type:"number literal"},{name:"x2",type:"number literal"},{name:"y2",type:"number literal"}]}}}}};const Oe=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function We(r,e){const i={};for(const s in r)s!=="ref"&&(i[s]=r[s]);return Oe.forEach((s=>{s in e&&(i[s]=e[s])})),i}function Ue(r,e){if(Array.isArray(r)){if(!Array.isArray(e)||r.length!==e.length)return!1;for(let i=0;i<r.length;i++)if(!Ue(r[i],e[i]))return!1;return!0}if(typeof r=="object"&&r!==null&&e!==null){if(typeof e!="object"||Object.keys(r).length!==Object.keys(e).length)return!1;for(const i in r)if(!Ue(r[i],e[i]))return!1;return!0}return r===e}function Ze(r,e){r.push(e)}function qe(r,e,i){Ze(i,{command:"addSource",args:[r,e[r]]})}function et(r,e,i){Ze(e,{command:"removeSource",args:[r]}),i[r]=!0}function Nt(r,e,i,s){et(r,i,s),qe(r,e,i)}function wt(r,e,i){let s;for(s in r[i])if(Object.prototype.hasOwnProperty.call(r[i],s)&&s!=="data"&&!Ue(r[i][s],e[i][s]))return!1;for(s in e[i])if(Object.prototype.hasOwnProperty.call(e[i],s)&&s!=="data"&&!Ue(r[i][s],e[i][s]))return!1;return!0}function jt(r,e,i,s,a,u){r=r||{},e=e||{};for(const h in r)Object.prototype.hasOwnProperty.call(r,h)&&(Ue(r[h],e[h])||i.push({command:u,args:[s,h,e[h],a]}));for(const h in e)Object.prototype.hasOwnProperty.call(e,h)&&!Object.prototype.hasOwnProperty.call(r,h)&&(Ue(r[h],e[h])||i.push({command:u,args:[s,h,e[h],a]}))}function ci(r){return r.id}function Rt(r,e){return r[e.id]=e,r}class Pe{constructor(e,i,s,a){this.message=(e?`${e}: `:"")+s,a&&(this.identifier=a),i!=null&&i.__line__&&(this.line=i.__line__)}}function ut(r,...e){for(const i of e)for(const s in i)r[s]=i[s];return r}class Ct extends Error{constructor(e,i){super(i),this.message=i,this.key=e}}class Cn{constructor(e,i=[]){this.parent=e,this.bindings={};for(const[s,a]of i)this.bindings[s]=a}concat(e){return new Cn(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 Or={kind:"null"},Me={kind:"number"},Xe={kind:"string"},Ye={kind:"boolean"},rr={kind:"color"},rs={kind:"projectionDefinition"},In={kind:"object"},tt={kind:"value"},ns={kind:"collator"},ss={kind:"formatted"},ko={kind:"padding"},Fs={kind:"colorArray"},Bs={kind:"numberArray"},os={kind:"resolvedImage"},Os={kind:"variableAnchorOffsetCollection"};function Li(r,e){return{kind:"array",itemType:r,N:e}}function St(r){if(r.kind==="array"){const e=St(r.itemType);return typeof r.N=="number"?`array<${e}, ${r.N}>`:r.itemType.kind==="value"?"array":`array<${e}>`}return r.kind}const En=[Or,Me,Xe,Ye,rr,rs,ss,In,Li(tt),ko,Bs,Fs,os,Os];function un(r,e){if(e.kind==="error")return null;if(r.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!un(r.itemType,e.itemType))&&(typeof r.N!="number"||r.N===e.N))return null}else{if(r.kind===e.kind)return null;if(r.kind==="value"){for(const i of En)if(!un(i,e))return null}}return`Expected ${St(r)} but found ${St(e)} instead.`}function Lo(r,e){return e.some((i=>i.kind===r.kind))}function Vr(r,e){return e.some((i=>i==="null"?r===null:i==="array"?Array.isArray(r):i==="object"?r&&!Array.isArray(r)&&typeof r=="object":i===typeof r))}function hn(r,e){return r.kind==="array"&&e.kind==="array"?r.itemType.kind===e.itemType.kind&&typeof r.N=="number":r.kind===e.kind}const Vs=.96422,Kl=.82521,An=4/29,dn=6/29,ti=3*dn*dn,zu=dn*dn*dn,Jl=Math.PI/180,Ns=180/Math.PI;function Na(r){return(r%=360)<0&&(r+=360),r}function Ql([r,e,i,s]){let a,u;const h=Ro((.2225045*(r=ja(r))+.7168786*(e=ja(e))+.0606169*(i=ja(i)))/1);r===e&&e===i?a=u=h:(a=Ro((.4360747*r+.3850649*e+.1430804*i)/Vs),u=Ro((.0139322*r+.0971045*e+.7141733*i)/Kl));const f=116*h-16;return[f<0?0:f,500*(a-h),200*(h-u),s]}function ja(r){return r<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)}function Ro(r){return r>zu?Math.pow(r,1/3):r/ti+An}function ec([r,e,i,s]){let a=(r+16)/116,u=isNaN(e)?a:a+e/500,h=isNaN(i)?a:a-i/200;return a=1*Ua(a),u=Vs*Ua(u),h=Kl*Ua(h),[Fo(3.1338561*u-1.6168667*a-.4906146*h),Fo(-.9787684*u+1.9161415*a+.033454*h),Fo(.0719453*u-.2289914*a+1.4052427*h),s]}function Fo(r){return(r=r<=.00304?12.92*r:1.055*Math.pow(r,1/2.4)-.055)<0?0:r>1?1:r}function Ua(r){return r>dn?r*r*r:ti*(r-An)}const ku=Object.hasOwn||function(r,e){return Object.prototype.hasOwnProperty.call(r,e)};function js(r,e){return ku(r,e)?r[e]:void 0}function Bo(r){return parseInt(r.padEnd(2,r),16)/255}function tc(r,e){return as(e?r/100:r,0,1)}function as(r,e,i){return Math.min(Math.max(e,r),i)}function ic(r){return!r.some(Number.isNaN)}const rc={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 nr(r,e,i){return r+i*(e-r)}function ls(r,e,i){return r.map(((s,a)=>nr(s,e[a],i)))}class st{constructor(e,i,s,a=1,u=!0){this.r=e,this.g=i,this.b=s,this.a=a,u||(this.r*=a,this.g*=a,this.b*=a,a||this.overwriteGetter("rgb",[e,i,s,a]))}static parse(e){if(e instanceof st)return e;if(typeof e!="string")return;const i=(function(s){if((s=s.toLowerCase().trim())==="transparent")return[0,0,0,0];const a=js(rc,s);if(a){const[h,f,g]=a;return[h/255,f/255,g/255,1]}if(s.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(s)){const h=s.length<6?1:2;let f=1;return[Bo(s.slice(f,f+=h)),Bo(s.slice(f,f+=h)),Bo(s.slice(f,f+=h)),Bo(s.slice(f,f+h)||"ff")]}if(s.startsWith("rgb")){const h=s.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(h){const[f,g,y,x,b,S,P,I,A,L,O,G]=h,B=[x||" ",P||" ",L].join("");if(B===" "||B===" /"||B===",,"||B===",,,"){const V=[y,S,A].join(""),W=V==="%%%"?100:V===""?255:0;if(W){const ee=[as(+g/W,0,1),as(+b/W,0,1),as(+I/W,0,1),O?tc(+O,G):1];if(ic(ee))return ee}}return}}const u=s.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(u){const[h,f,g,y,x,b,S,P,I]=u,A=[g||" ",x||" ",S].join("");if(A===" "||A===" /"||A===",,"||A===",,,"){const L=[+f,as(+y,0,100),as(+b,0,100),P?tc(+P,I):1];if(ic(L))return(function([O,G,B,V]){function W(ee){const ae=(ee+O/30)%12,_e=G*Math.min(B,1-B);return B-_e*Math.max(-1,Math.min(ae-3,9-ae,1))}return O=Na(O),G/=100,B/=100,[W(0),W(8),W(4),V]})(L)}}})(e);return i?new st(...i,!1):void 0}get rgb(){const{r:e,g:i,b:s,a}=this,u=a||1/0;return this.overwriteGetter("rgb",[e/u,i/u,s/u,a])}get hcl(){return this.overwriteGetter("hcl",(function(e){const[i,s,a,u]=Ql(e),h=Math.sqrt(s*s+a*a);return[Math.round(1e4*h)?Na(Math.atan2(a,s)*Ns):NaN,h,i,u]})(this.rgb))}get lab(){return this.overwriteGetter("lab",Ql(this.rgb))}overwriteGetter(e,i){return Object.defineProperty(this,e,{value:i}),i}toString(){const[e,i,s,a]=this.rgb;return`rgba(${[e,i,s].map((u=>Math.round(255*u))).join(",")},${a})`}static interpolate(e,i,s,a="rgb"){switch(a){case"rgb":{const[u,h,f,g]=ls(e.rgb,i.rgb,s);return new st(u,h,f,g,!1)}case"hcl":{const[u,h,f,g]=e.hcl,[y,x,b,S]=i.hcl;let P,I;if(isNaN(u)||isNaN(y))isNaN(u)?isNaN(y)?P=NaN:(P=y,f!==1&&f!==0||(I=x)):(P=u,b!==1&&b!==0||(I=h));else{let B=y-u;y>u&&B>180?B-=360:y<u&&u-y>180&&(B+=360),P=u+s*B}const[A,L,O,G]=(function([B,V,W,ee]){return B=isNaN(B)?0:B*Jl,ec([W,Math.cos(B)*V,Math.sin(B)*V,ee])})([P,I??nr(h,x,s),nr(f,b,s),nr(g,S,s)]);return new st(A,L,O,G,!1)}case"lab":{const[u,h,f,g]=ec(ls(e.lab,i.lab,s));return new st(u,h,f,g,!1)}}}}st.black=new st(0,0,0,1),st.white=new st(1,1,1,1),st.transparent=new st(0,0,0,0),st.red=new st(1,0,0,1);class Dn{constructor(e,i,s){this.sensitivity=e?i?"variant":"case":i?"accent":"base",this.locale=s,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,i){return this.collator.compare(e,i)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const Lu=["bottom","center","top"];class Ga{constructor(e,i,s,a,u,h){this.text=e,this.image=i,this.scale=s,this.fontStack=a,this.textColor=u,this.verticalAlign=h}}class Ui{constructor(e){this.sections=e}static fromString(e){return new Ui([new Ga(e,null,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some((e=>e.text.length!==0||e.image&&e.image.name.length!==0))}static factory(e){return e instanceof Ui?e:Ui.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map((e=>e.text)).join("")}}class _i{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof _i)return e;if(typeof e=="number")return new _i([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const i of e)if(typeof i!="number")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 _i(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,i,s){return new _i(ls(e.values,i.values,s))}}class yi{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof yi)return e;if(typeof e=="number")return new yi([e]);if(Array.isArray(e)){for(const i of e)if(typeof i!="number")return;return new yi(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,i,s){return new yi(ls(e.values,i.values,s))}}class Pt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Pt)return e;if(typeof e=="string"){const s=st.parse(e);return s?new Pt([s]):void 0}if(!Array.isArray(e))return;const i=[];for(const s of e){if(typeof s!="string")return;const a=st.parse(s);if(!a)return;i.push(a)}return new Pt(i)}toString(){return JSON.stringify(this.values)}static interpolate(e,i,s,a="rgb"){const u=[];if(e.values.length!=i.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${i.values.length}), cannot interpolate.`);for(let h=0;h<e.values.length;h++)u.push(st.interpolate(e.values[h],i.values[h],s,a));return new Pt(u)}}class je extends Error{constructor(e){super(e),this.name="RuntimeError"}toJSON(){return this.message}}const cs=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class Wt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Wt)return e;if(Array.isArray(e)&&!(e.length<1)&&e.length%2==0){for(let i=0;i<e.length;i+=2){const s=e[i],a=e[i+1];if(typeof s!="string"||!cs.has(s)||!Array.isArray(a)||a.length!==2||typeof a[0]!="number"||typeof a[1]!="number")return}return new Wt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,i,s){const a=e.values,u=i.values;if(a.length!==u.length)throw new je(`Cannot interpolate values of different length. from: ${e.toString()}, to: ${i.toString()}`);const h=[];for(let f=0;f<a.length;f+=2){if(a[f]!==u[f])throw new je(`Cannot interpolate values containing mismatched anchors. from[${f}]: ${a[f]}, to[${f}]: ${u[f]}`);h.push(a[f]);const[g,y]=a[f+1],[x,b]=u[f+1];h.push([nr(g,x,s),nr(y,b,s)])}return new Wt(h)}}class Gi{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new Gi({name:e,available:!1}):null}}class Ri{constructor(e,i,s){this.from=e,this.to=i,this.transition=s}static interpolate(e,i,s){return new Ri(e,i,s)}static parse(e){return e instanceof Ri?e:Array.isArray(e)&&e.length===3&&typeof e[0]=="string"&&typeof e[1]=="string"&&typeof e[2]=="number"?new Ri(e[0],e[1],e[2]):typeof e=="object"&&typeof e.from=="string"&&typeof e.to=="string"&&typeof e.transition=="number"?new Ri(e.from,e.to,e.transition):typeof e=="string"?new Ri(e,e,1):void 0}}function Oo(r,e,i,s){return typeof r=="number"&&r>=0&&r<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof i=="number"&&i>=0&&i<=255?s===void 0||typeof s=="number"&&s>=0&&s<=1?null:`Invalid rgba value [${[r,e,i,s].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof s=="number"?[r,e,i,s]:[r,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Nr(r){if(r===null||typeof r=="string"||typeof r=="boolean"||typeof r=="number"||r instanceof Ri||r instanceof st||r instanceof Dn||r instanceof Ui||r instanceof _i||r instanceof yi||r instanceof Pt||r instanceof Wt||r instanceof Gi)return!0;if(Array.isArray(r)){for(const e of r)if(!Nr(e))return!1;return!0}if(typeof r=="object"){for(const e in r)if(!Nr(r[e]))return!1;return!0}return!1}function zt(r){if(r===null)return Or;if(typeof r=="string")return Xe;if(typeof r=="boolean")return Ye;if(typeof r=="number")return Me;if(r instanceof st)return rr;if(r instanceof Ri)return rs;if(r instanceof Dn)return ns;if(r instanceof Ui)return ss;if(r instanceof _i)return ko;if(r instanceof yi)return Bs;if(r instanceof Pt)return Fs;if(r instanceof Wt)return Os;if(r instanceof Gi)return os;if(Array.isArray(r)){const e=r.length;let i;for(const s of r){const a=zt(s);if(i){if(i===a)continue;i=tt;break}i=a}return Li(i||tt,e)}return In}function us(r){const e=typeof r;return r===null?"":e==="string"||e==="number"||e==="boolean"?String(r):r instanceof st||r instanceof Ri||r instanceof Ui||r instanceof _i||r instanceof yi||r instanceof Pt||r instanceof Wt||r instanceof Gi?r.toString():JSON.stringify(r)}class jr{constructor(e,i){this.type=e,this.value=i}static parse(e,i){if(e.length!==2)return i.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Nr(e[1]))return i.error("invalid value");const s=e[1];let a=zt(s);const u=i.expectedType;return a.kind!=="array"||a.N!==0||!u||u.kind!=="array"||typeof u.N=="number"&&u.N!==0||(a=u),new jr(a,s)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const zn={string:Xe,number:Me,boolean:Ye,object:In};class fr{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");let s,a=1;const u=e[0];if(u==="array"){let f,g;if(e.length>2){const y=e[1];if(typeof y!="string"||!(y in zn)||y==="object")return i.error('The item type argument of "array" must be one of string, number, boolean',1);f=zn[y],a++}else f=tt;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return i.error('The length argument to "array" must be a positive integer literal',2);g=e[2],a++}s=Li(f,g)}else{if(!zn[u])throw new Error(`Types doesn't contain name = ${u}`);s=zn[u]}const h=[];for(;a<e.length;a++){const f=i.parse(e[a],a,tt);if(!f)return null;h.push(f)}return new fr(s,h)}evaluate(e){for(let i=0;i<this.args.length;i++){const s=this.args[i].evaluate(e);if(!un(this.type,zt(s)))return s;if(i===this.args.length-1)throw new je(`Expected value to be of type ${St(this.type)}, but found ${St(zt(s))} instead.`)}throw new Error}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const Us={"to-boolean":Ye,"to-color":rr,"to-number":Me,"to-string":Xe};class qi{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");const s=e[0];if(!Us[s])throw new Error(`Can't parse ${s} as it is not part of the known types`);if((s==="to-boolean"||s==="to-string")&&e.length!==2)return i.error("Expected one argument.");const a=Us[s],u=[];for(let h=1;h<e.length;h++){const f=i.parse(e[h],h,tt);if(!f)return null;u.push(f)}return new qi(a,u)}evaluate(e){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(e);case"color":{let i,s;for(const a of this.args){if(i=a.evaluate(e),s=null,i instanceof st)return i;if(typeof i=="string"){const u=e.parseColor(i);if(u)return u}else if(Array.isArray(i)&&(s=i.length<3||i.length>4?`Invalid rgba value ${JSON.stringify(i)}: expected an array containing either three or four numeric values.`:Oo(i[0],i[1],i[2],i[3]),!s))return new st(i[0]/255,i[1]/255,i[2]/255,i[3])}throw new je(s||`Could not parse color from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"padding":{let i;for(const s of this.args){i=s.evaluate(e);const a=_i.parse(i);if(a)return a}throw new je(`Could not parse padding from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"numberArray":{let i;for(const s of this.args){i=s.evaluate(e);const a=yi.parse(i);if(a)return a}throw new je(`Could not parse numberArray from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"colorArray":{let i;for(const s of this.args){i=s.evaluate(e);const a=Pt.parse(i);if(a)return a}throw new je(`Could not parse colorArray from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"variableAnchorOffsetCollection":{let i;for(const s of this.args){i=s.evaluate(e);const a=Wt.parse(i);if(a)return a}throw new je(`Could not parse variableAnchorOffsetCollection from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"number":{let i=null;for(const s of this.args){if(i=s.evaluate(e),i===null)return 0;const a=Number(i);if(!isNaN(a))return a}throw new je(`Could not convert ${JSON.stringify(i)} to number.`)}case"formatted":return Ui.fromString(us(this.args[0].evaluate(e)));case"resolvedImage":return Gi.fromString(us(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return us(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const nc=["Unknown","Point","LineString","Polygon"];class qa{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?typeof this.feature.type=="number"?nc[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 i=this._parseColorCache.get(e);return i||(i=st.parse(e),this._parseColorCache.set(e,i)),i}}class Gs{constructor(e,i,s=[],a,u=new Cn,h=[]){this.registry=e,this.path=s,this.key=s.map((f=>`[${f}]`)).join(""),this.scope=u,this.errors=h,this.expectedType=a,this._isConstant=i}parse(e,i,s,a,u={}){return i?this.concat(i,s,a)._parse(e,u):this._parse(e,u)}_parse(e,i){function s(a,u,h){return h==="assert"?new fr(u,[a]):h==="coerce"?new qi(u,[a]):a}if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const a=e[0];if(typeof a!="string")return this.error(`Expression name must be a string, but found ${typeof a} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const u=this.registry[a];if(u){let h=u.parse(e,this);if(!h)return null;if(this.expectedType){const f=this.expectedType,g=h.type;if(f.kind!=="string"&&f.kind!=="number"&&f.kind!=="boolean"&&f.kind!=="object"&&f.kind!=="array"||g.kind!=="value"){if(f.kind==="projectionDefinition"&&["string","array"].includes(g.kind)||["color","formatted","resolvedImage"].includes(f.kind)&&["value","string"].includes(g.kind)||["padding","numberArray"].includes(f.kind)&&["value","number","array"].includes(g.kind)||f.kind==="colorArray"&&["value","string","array"].includes(g.kind)||f.kind==="variableAnchorOffsetCollection"&&["value","array"].includes(g.kind))h=s(h,f,i.typeAnnotation||"coerce");else if(this.checkSubtype(f,g))return null}else h=s(h,f,i.typeAnnotation||"assert")}if(!(h instanceof jr)&&h.type.kind!=="resolvedImage"&&this._isConstant(h)){const f=new qa;try{h=new jr(h.type,h.evaluate(f))}catch(g){return this.error(g.message),null}}return h}return this.error(`Unknown expression "${a}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,i,s){const a=typeof e=="number"?this.path.concat(e):this.path,u=s?this.scope.concat(s):this.scope;return new Gs(this.registry,this._isConstant,a,i||null,u,this.errors)}error(e,...i){const s=`${this.key}${i.map((a=>`[${a}]`)).join("")}`;this.errors.push(new Ct(s,e))}checkSubtype(e,i){const s=un(e,i);return s&&this.error(s),s}}class kn{constructor(e,i){this.type=i.type,this.bindings=[].concat(e),this.result=i}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const i of this.bindings)e(i[1]);e(this.result)}static parse(e,i){if(e.length<4)return i.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const s=[];for(let u=1;u<e.length-1;u+=2){const h=e[u];if(typeof h!="string")return i.error(`Expected string, but found ${typeof h} instead.`,u);if(/[^a-zA-Z0-9_]/.test(h))return i.error("Variable names must contain only alphanumeric characters or '_'.",u);const f=i.parse(e[u+1],u+1);if(!f)return null;s.push([h,f])}const a=i.parse(e[e.length-1],e.length-1,i.expectedType,s);return a?new kn(s,a):null}outputDefined(){return this.result.outputDefined()}}class yt{constructor(e,i){this.type=i.type,this.name=e,this.boundExpression=i}static parse(e,i){if(e.length!==2||typeof e[1]!="string")return i.error("'var' expression requires exactly one string literal argument.");const s=e[1];return i.scope.has(s)?new yt(s,i.scope.get(s)):i.error(`Unknown variable "${s}". Make sure "${s}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}}class qs{constructor(e,i,s){this.type=e,this.index=i,this.input=s}static parse(e,i){if(e.length!==3)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const s=i.parse(e[1],1,Me),a=i.parse(e[2],2,Li(i.expectedType||tt));return s&&a?new qs(a.type.itemType,s,a):null}evaluate(e){const i=this.index.evaluate(e),s=this.input.evaluate(e);if(i<0)throw new je(`Array index out of bounds: ${i} < 0.`);if(i>=s.length)throw new je(`Array index out of bounds: ${i} > ${s.length-1}.`);if(i!==Math.floor(i))throw new je(`Array index must be an integer, but found ${i} instead.`);return s[i]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class ot{constructor(e,i){this.type=Ye,this.needle=e,this.haystack=i}static parse(e,i){if(e.length!==3)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const s=i.parse(e[1],1,tt),a=i.parse(e[2],2,tt);return s&&a?Lo(s.type,[Ye,Xe,Me,Or,tt])?new ot(s,a):i.error(`Expected first argument to be of type boolean, string, number or null, but found ${St(s.type)} instead`):null}evaluate(e){const i=this.needle.evaluate(e),s=this.haystack.evaluate(e);if(!s)return!1;if(!Vr(i,["boolean","string","number","null"]))throw new je(`Expected first argument to be of type boolean, string, number or null, but found ${St(zt(i))} instead.`);if(!Vr(s,["string","array"]))throw new je(`Expected second argument to be of type array or string, but found ${St(zt(s))} instead.`);return s.indexOf(i)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class Qe{constructor(e,i,s){this.type=Me,this.needle=e,this.haystack=i,this.fromIndex=s}static parse(e,i){if(e.length<=2||e.length>=5)return i.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const s=i.parse(e[1],1,tt),a=i.parse(e[2],2,tt);if(!s||!a)return null;if(!Lo(s.type,[Ye,Xe,Me,Or,tt]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${St(s.type)} instead`);if(e.length===4){const u=i.parse(e[3],3,Me);return u?new Qe(s,a,u):null}return new Qe(s,a)}evaluate(e){const i=this.needle.evaluate(e),s=this.haystack.evaluate(e);if(!Vr(i,["boolean","string","number","null"]))throw new je(`Expected first argument to be of type boolean, string, number or null, but found ${St(zt(i))} instead.`);let a;if(this.fromIndex&&(a=this.fromIndex.evaluate(e)),Vr(s,["string"])){const u=s.indexOf(i,a);return u===-1?-1:[...s.slice(0,u)].length}if(Vr(s,["array"]))return s.indexOf(i,a);throw new je(`Expected second argument to be of type array or string, but found ${St(zt(s))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class Zs{constructor(e,i,s,a,u,h){this.inputType=e,this.type=i,this.input=s,this.cases=a,this.outputs=u,this.otherwise=h}static parse(e,i){if(e.length<5)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return i.error("Expected an even number of arguments.");let s,a;i.expectedType&&i.expectedType.kind!=="value"&&(a=i.expectedType);const u={},h=[];for(let y=2;y<e.length-1;y+=2){let x=e[y];const b=e[y+1];Array.isArray(x)||(x=[x]);const S=i.concat(y);if(x.length===0)return S.error("Expected at least one branch label.");for(const I of x){if(typeof I!="number"&&typeof I!="string")return S.error("Branch labels must be numbers or strings.");if(typeof I=="number"&&Math.abs(I)>Number.MAX_SAFE_INTEGER)return S.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof I=="number"&&Math.floor(I)!==I)return S.error("Numeric branch labels must be integer values.");if(s){if(S.checkSubtype(s,zt(I)))return null}else s=zt(I);if(u[String(I)]!==void 0)return S.error("Branch labels must be unique.");u[String(I)]=h.length}const P=i.parse(b,y,a);if(!P)return null;a=a||P.type,h.push(P)}const f=i.parse(e[1],1,tt);if(!f)return null;const g=i.parse(e[e.length-1],e.length-1,a);return g?f.type.kind!=="value"&&i.concat(1).checkSubtype(s,f.type)?null:new Zs(s,a,f,u,h,g):null}evaluate(e){const i=this.input.evaluate(e);return(zt(i)===this.inputType&&this.outputs[this.cases[i]]||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 at{constructor(e,i,s){this.type=e,this.branches=i,this.otherwise=s}static parse(e,i){if(e.length<4)return i.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return i.error("Expected an odd number of arguments.");let s;i.expectedType&&i.expectedType.kind!=="value"&&(s=i.expectedType);const a=[];for(let h=1;h<e.length-1;h+=2){const f=i.parse(e[h],h,Ye);if(!f)return null;const g=i.parse(e[h+1],h+1,s);if(!g)return null;a.push([f,g]),s=s||g.type}const u=i.parse(e[e.length-1],e.length-1,s);if(!u)return null;if(!s)throw new Error("Can't infer output type");return new at(s,a,u)}evaluate(e){for(const[i,s]of this.branches)if(i.evaluate(e))return s.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[i,s]of this.branches)e(i),e(s);e(this.otherwise)}outputDefined(){return this.branches.every((([e,i])=>i.outputDefined()))&&this.otherwise.outputDefined()}}class hs{constructor(e,i,s,a){this.type=e,this.input=i,this.beginIndex=s,this.endIndex=a}static parse(e,i){if(e.length<=2||e.length>=5)return i.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const s=i.parse(e[1],1,tt),a=i.parse(e[2],2,Me);if(!s||!a)return null;if(!Lo(s.type,[Li(tt),Xe,tt]))return i.error(`Expected first argument to be of type array or string, but found ${St(s.type)} instead`);if(e.length===4){const u=i.parse(e[3],3,Me);return u?new hs(s.type,s,a,u):null}return new hs(s.type,s,a)}evaluate(e){const i=this.input.evaluate(e),s=this.beginIndex.evaluate(e);let a;if(this.endIndex&&(a=this.endIndex.evaluate(e)),Vr(i,["string"]))return[...i].slice(s,a).join("");if(Vr(i,["array"]))return i.slice(s,a);throw new je(`Expected first argument to be of type array or string, but found ${St(zt(i))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function sr(r,e){const i=r.length-1;let s,a,u=0,h=i,f=0;for(;u<=h;)if(f=Math.floor((u+h)/2),s=r[f],a=r[f+1],s<=e){if(f===i||e<a)return f;u=f+1}else{if(!(s>e))throw new je("Input is not a number.");h=f-1}return 0}class Ln{constructor(e,i,s){this.type=e,this.input=i,this.labels=[],this.outputs=[];for(const[a,u]of s)this.labels.push(a),this.outputs.push(u)}static parse(e,i){if(e.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return i.error("Expected an even number of arguments.");const s=i.parse(e[1],1,Me);if(!s)return null;const a=[];let u=null;i.expectedType&&i.expectedType.kind!=="value"&&(u=i.expectedType);for(let h=1;h<e.length;h+=2){const f=h===1?-1/0:e[h],g=e[h+1],y=h,x=h+1;if(typeof f!="number")return i.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',y);if(a.length&&a[a.length-1][0]>=f)return i.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',y);const b=i.parse(g,x,u);if(!b)return null;u=u||b.type,a.push([f,b])}return new Ln(u,s,a)}evaluate(e){const i=this.labels,s=this.outputs;if(i.length===1)return s[0].evaluate(e);const a=this.input.evaluate(e);if(a<=i[0])return s[0].evaluate(e);const u=i.length;return a>=i[u-1]?s[u-1].evaluate(e):s[sr(i,a)].evaluate(e)}eachChild(e){e(this.input);for(const i of this.outputs)e(i)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function Vo(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var No,jo,sc=(function(){if(jo)return No;function r(e,i,s,a){this.cx=3*e,this.bx=3*(s-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*i,this.by=3*(a-i)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=i,this.p2x=s,this.p2y=a}return jo=1,No=r,r.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,i){if(i===void 0&&(i=1e-6),e<0)return 0;if(e>1)return 1;for(var s=e,a=0;a<8;a++){var u=this.sampleCurveX(s)-e;if(Math.abs(u)<i)return s;var h=this.sampleCurveDerivativeX(s);if(Math.abs(h)<1e-6)break;s-=u/h}var f=0,g=1;for(s=e,a=0;a<20&&(u=this.sampleCurveX(s),!(Math.abs(u-e)<i));a++)e>u?f=s:g=s,s=.5*(g-f)+f;return s},solve:function(e,i){return this.sampleCurveY(this.solveCurveX(e,i))}},No})(),Ru=Vo(sc);class Pi{constructor(e,i,s,a,u){this.type=e,this.operator=i,this.interpolation=s,this.input=a,this.labels=[],this.outputs=[];for(const[h,f]of u)this.labels.push(h),this.outputs.push(f)}static interpolationFactor(e,i,s,a){let u=0;if(e.name==="exponential")u=Uo(i,e.base,s,a);else if(e.name==="linear")u=Uo(i,1,s,a);else if(e.name==="cubic-bezier"){const h=e.controlPoints;u=new Ru(h[0],h[1],h[2],h[3]).solve(Uo(i,1,s,a))}return u}static parse(e,i){let[s,a,u,...h]=e;if(!Array.isArray(a)||a.length===0)return i.error("Expected an interpolation type expression.",1);if(a[0]==="linear")a={name:"linear"};else if(a[0]==="exponential"){const y=a[1];if(typeof y!="number")return i.error("Exponential interpolation requires a numeric base.",1,1);a={name:"exponential",base:y}}else{if(a[0]!=="cubic-bezier")return i.error(`Unknown interpolation type ${String(a[0])}`,1,0);{const y=a.slice(1);if(y.length!==4||y.some((x=>typeof x!="number"||x<0||x>1)))return i.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);a={name:"cubic-bezier",controlPoints:y}}}if(e.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return i.error("Expected an even number of arguments.");if(u=i.parse(u,2,Me),!u)return null;const f=[];let g=null;s!=="interpolate-hcl"&&s!=="interpolate-lab"||i.expectedType==Fs?i.expectedType&&i.expectedType.kind!=="value"&&(g=i.expectedType):g=rr;for(let y=0;y<h.length;y+=2){const x=h[y],b=h[y+1],S=y+3,P=y+4;if(typeof x!="number")return i.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',S);if(f.length&&f[f.length-1][0]>=x)return i.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',S);const I=i.parse(b,P,g);if(!I)return null;g=g||I.type,f.push([x,I])}return hn(g,Me)||hn(g,rs)||hn(g,rr)||hn(g,ko)||hn(g,Bs)||hn(g,Fs)||hn(g,Os)||hn(g,Li(Me))?new Pi(g,s,a,u,f):i.error(`Type ${St(g)} is not interpolatable.`)}evaluate(e){const i=this.labels,s=this.outputs;if(i.length===1)return s[0].evaluate(e);const a=this.input.evaluate(e);if(a<=i[0])return s[0].evaluate(e);const u=i.length;if(a>=i[u-1])return s[u-1].evaluate(e);const h=sr(i,a),f=Pi.interpolationFactor(this.interpolation,a,i[h],i[h+1]),g=s[h].evaluate(e),y=s[h+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return nr(g,y,f);case"color":return st.interpolate(g,y,f);case"padding":return _i.interpolate(g,y,f);case"colorArray":return Pt.interpolate(g,y,f);case"numberArray":return yi.interpolate(g,y,f);case"variableAnchorOffsetCollection":return Wt.interpolate(g,y,f);case"array":return ls(g,y,f);case"projectionDefinition":return Ri.interpolate(g,y,f)}case"interpolate-hcl":switch(this.type.kind){case"color":return st.interpolate(g,y,f,"hcl");case"colorArray":return Pt.interpolate(g,y,f,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return st.interpolate(g,y,f,"lab");case"colorArray":return Pt.interpolate(g,y,f,"lab")}}}eachChild(e){e(this.input);for(const i of this.outputs)e(i)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function Uo(r,e,i,s){const a=s-i,u=r-i;return a===0?0:e===1?u/a:(Math.pow(e,u)-1)/(Math.pow(e,a)-1)}const ui={color:st.interpolate,number:nr,padding:_i.interpolate,numberArray:yi.interpolate,colorArray:Pt.interpolate,variableAnchorOffsetCollection:Wt.interpolate,array:ls};class ii{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");let s=null;const a=i.expectedType;a&&a.kind!=="value"&&(s=a);const u=[];for(const f of e.slice(1)){const g=i.parse(f,1+u.length,s,void 0,{typeAnnotation:"omit"});if(!g)return null;s=s||g.type,u.push(g)}if(!s)throw new Error("No output type");const h=a&&u.some((f=>un(a,f.type)));return new ii(h?tt:s,u)}evaluate(e){let i,s=null,a=0;for(const u of this.args)if(a++,s=u.evaluate(e),s&&s instanceof Gi&&!s.available&&(i||(i=s.name),s=null,a===this.args.length&&(s=i)),s!==null)break;return s}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}function $s(r,e){return r==="=="||r==="!="?e.kind==="boolean"||e.kind==="string"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function Za(r,e,i,s){return s.compare(e,i)===0}function Ur(r,e,i){const s=r!=="=="&&r!=="!=";return class Cf{constructor(u,h,f){this.type=Ye,this.lhs=u,this.rhs=h,this.collator=f,this.hasUntypedArgument=u.type.kind==="value"||h.type.kind==="value"}static parse(u,h){if(u.length!==3&&u.length!==4)return h.error("Expected two or three arguments.");const f=u[0];let g=h.parse(u[1],1,tt);if(!g)return null;if(!$s(f,g.type))return h.concat(1).error(`"${f}" comparisons are not supported for type '${St(g.type)}'.`);let y=h.parse(u[2],2,tt);if(!y)return null;if(!$s(f,y.type))return h.concat(2).error(`"${f}" comparisons are not supported for type '${St(y.type)}'.`);if(g.type.kind!==y.type.kind&&g.type.kind!=="value"&&y.type.kind!=="value")return h.error(`Cannot compare types '${St(g.type)}' and '${St(y.type)}'.`);s&&(g.type.kind==="value"&&y.type.kind!=="value"?g=new fr(y.type,[g]):g.type.kind!=="value"&&y.type.kind==="value"&&(y=new fr(g.type,[y])));let x=null;if(u.length===4){if(g.type.kind!=="string"&&y.type.kind!=="string"&&g.type.kind!=="value"&&y.type.kind!=="value")return h.error("Cannot use collator to compare non-string types.");if(x=h.parse(u[3],3,ns),!x)return null}return new Cf(g,y,x)}evaluate(u){const h=this.lhs.evaluate(u),f=this.rhs.evaluate(u);if(s&&this.hasUntypedArgument){const g=zt(h),y=zt(f);if(g.kind!==y.kind||g.kind!=="string"&&g.kind!=="number")throw new je(`Expected arguments for "${r}" to be (string, string) or (number, number), but found (${g.kind}, ${y.kind}) instead.`)}if(this.collator&&!s&&this.hasUntypedArgument){const g=zt(h),y=zt(f);if(g.kind!=="string"||y.kind!=="string")return e(u,h,f)}return this.collator?i(u,h,f,this.collator.evaluate(u)):e(u,h,f)}eachChild(u){u(this.lhs),u(this.rhs),this.collator&&u(this.collator)}outputDefined(){return!0}}}const ni=Ur("==",(function(r,e,i){return e===i}),Za),oc=Ur("!=",(function(r,e,i){return e!==i}),(function(r,e,i,s){return!Za(0,e,i,s)})),$a=Ur("<",(function(r,e,i){return e<i}),(function(r,e,i,s){return s.compare(e,i)<0})),ac=Ur(">",(function(r,e,i){return e>i}),(function(r,e,i,s){return s.compare(e,i)>0})),Fu=Ur("<=",(function(r,e,i){return e<=i}),(function(r,e,i,s){return s.compare(e,i)<=0})),ds=Ur(">=",(function(r,e,i){return e>=i}),(function(r,e,i,s){return s.compare(e,i)>=0}));class Rn{constructor(e,i,s){this.type=ns,this.locale=s,this.caseSensitive=e,this.diacriticSensitive=i}static parse(e,i){if(e.length!==2)return i.error("Expected one argument.");const s=e[1];if(typeof s!="object"||Array.isArray(s))return i.error("Collator options argument must be an object.");const a=i.parse(s["case-sensitive"]!==void 0&&s["case-sensitive"],1,Ye);if(!a)return null;const u=i.parse(s["diacritic-sensitive"]!==void 0&&s["diacritic-sensitive"],1,Ye);if(!u)return null;let h=null;return s.locale&&(h=i.parse(s.locale,1,Xe),!h)?null:new Rn(a,u,h)}evaluate(e){return new Dn(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 Hs{constructor(e,i,s,a,u){this.type=Xe,this.number=e,this.locale=i,this.currency=s,this.minFractionDigits=a,this.maxFractionDigits=u}static parse(e,i){if(e.length!==3)return i.error("Expected two arguments.");const s=i.parse(e[1],1,Me);if(!s)return null;const a=e[2];if(typeof a!="object"||Array.isArray(a))return i.error("NumberFormat options argument must be an object.");let u=null;if(a.locale&&(u=i.parse(a.locale,1,Xe),!u))return null;let h=null;if(a.currency&&(h=i.parse(a.currency,1,Xe),!h))return null;let f=null;if(a["min-fraction-digits"]&&(f=i.parse(a["min-fraction-digits"],1,Me),!f))return null;let g=null;return a["max-fraction-digits"]&&(g=i.parse(a["max-fraction-digits"],1,Me),!g)?null:new Hs(s,u,h,f,g)}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 Go{constructor(e){this.type=ss,this.sections=e}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");const s=e[1];if(!Array.isArray(s)&&typeof s=="object")return i.error("First argument must be an image or text section.");const a=[];let u=!1;for(let h=1;h<=e.length-1;++h){const f=e[h];if(u&&typeof f=="object"&&!Array.isArray(f)){u=!1;let g=null;if(f["font-scale"]&&(g=i.parse(f["font-scale"],1,Me),!g))return null;let y=null;if(f["text-font"]&&(y=i.parse(f["text-font"],1,Li(Xe)),!y))return null;let x=null;if(f["text-color"]&&(x=i.parse(f["text-color"],1,rr),!x))return null;let b=null;if(f["vertical-align"]){if(typeof f["vertical-align"]=="string"&&!Lu.includes(f["vertical-align"]))return i.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${f["vertical-align"]}' instead.`);if(b=i.parse(f["vertical-align"],1,Xe),!b)return null}const S=a[a.length-1];S.scale=g,S.font=y,S.textColor=x,S.verticalAlign=b}else{const g=i.parse(e[h],1,tt);if(!g)return null;const y=g.type.kind;if(y!=="string"&&y!=="value"&&y!=="null"&&y!=="resolvedImage")return i.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");u=!0,a.push({content:g,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Go(a)}evaluate(e){return new Ui(this.sections.map((i=>{const s=i.content.evaluate(e);return zt(s)===os?new Ga("",s,null,null,null,i.verticalAlign?i.verticalAlign.evaluate(e):null):new Ga(us(s),null,i.scale?i.scale.evaluate(e):null,i.font?i.font.evaluate(e).join(","):null,i.textColor?i.textColor.evaluate(e):null,i.verticalAlign?i.verticalAlign.evaluate(e):null)})))}eachChild(e){for(const i of this.sections)e(i.content),i.scale&&e(i.scale),i.font&&e(i.font),i.textColor&&e(i.textColor),i.verticalAlign&&e(i.verticalAlign)}outputDefined(){return!1}}class qo{constructor(e){this.type=os,this.input=e}static parse(e,i){if(e.length!==2)return i.error("Expected two arguments.");const s=i.parse(e[1],1,Xe);return s?new qo(s):i.error("No image name provided.")}evaluate(e){const i=this.input.evaluate(e),s=Gi.fromString(i);return s&&e.availableImages&&(s.available=e.availableImages.indexOf(i)>-1),s}eachChild(e){e(this.input)}outputDefined(){return!1}}class ps{constructor(e){this.type=Me,this.input=e}static parse(e,i){if(e.length!==2)return i.error(`Expected 1 argument, but found ${e.length-1} instead.`);const s=i.parse(e[1],1);return s?s.type.kind!=="array"&&s.type.kind!=="string"&&s.type.kind!=="value"?i.error(`Expected argument of type string or array, but found ${St(s.type)} instead.`):new ps(s):null}evaluate(e){const i=this.input.evaluate(e);if(typeof i=="string")return[...i].length;if(Array.isArray(i))return i.length;throw new je(`Expected value to be of type string or array, but found ${St(zt(i))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const Zi=8192;function mr(r,e){const i=(180+r[0])/360,s=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+r[1]*Math.PI/360)))/360,a=Math.pow(2,e.z);return[Math.round(i*a*Zi),Math.round(s*a*Zi)]}function Zo(r,e){const i=Math.pow(2,e.z);return[(a=(r[0]/Zi+e.x)/i,360*a-180),(s=(r[1]/Zi+e.y)/i,360/Math.PI*Math.atan(Math.exp((180-360*s)*Math.PI/180))-90)];var s,a}function pn(r,e){r[0]=Math.min(r[0],e[0]),r[1]=Math.min(r[1],e[1]),r[2]=Math.max(r[2],e[0]),r[3]=Math.max(r[3],e[1])}function Ws(r,e){return!(r[0]<=e[0]||r[2]>=e[2]||r[1]<=e[1]||r[3]>=e[3])}function Ha(r,e,i){const s=r[0]-e[0],a=r[1]-e[1],u=r[0]-i[0],h=r[1]-i[1];return s*h-u*a==0&&s*u<=0&&a*h<=0}function $o(r,e,i,s){return(a=[s[0]-i[0],s[1]-i[1]])[0]*(u=[e[0]-r[0],e[1]-r[1]])[1]-a[1]*u[0]!=0&&!(!Wa(r,e,i,s)||!Wa(i,s,r,e));var a,u}function Bu(r,e,i){for(const s of i)for(let a=0;a<s.length-1;++a)if($o(r,e,s[a],s[a+1]))return!0;return!1}function fs(r,e,i=!1){let s=!1;for(const f of e)for(let g=0;g<f.length-1;g++){if(Ha(r,f[g],f[g+1]))return i;(u=f[g])[1]>(a=r)[1]!=(h=f[g+1])[1]>a[1]&&a[0]<(h[0]-u[0])*(a[1]-u[1])/(h[1]-u[1])+u[0]&&(s=!s)}var a,u,h;return s}function Ou(r,e){for(const i of e)if(fs(r,i))return!0;return!1}function Xs(r,e){for(const i of r)if(!fs(i,e))return!1;for(let i=0;i<r.length-1;++i)if(Bu(r[i],r[i+1],e))return!1;return!0}function Vu(r,e){for(const i of e)if(Xs(r,i))return!0;return!1}function Wa(r,e,i,s){const a=s[0]-i[0],u=s[1]-i[1],h=(r[0]-i[0])*u-a*(r[1]-i[1]),f=(e[0]-i[0])*u-a*(e[1]-i[1]);return h>0&&f<0||h<0&&f>0}function Ho(r,e,i){const s=[];for(let a=0;a<r.length;a++){const u=[];for(let h=0;h<r[a].length;h++){const f=mr(r[a][h],i);pn(e,f),u.push(f)}s.push(u)}return s}function lc(r,e,i){const s=[];for(let a=0;a<r.length;a++){const u=Ho(r[a],e,i);s.push(u)}return s}function Xa(r,e,i,s){if(r[0]<i[0]||r[0]>i[2]){const a=.5*s;let u=r[0]-i[0]>a?-s:i[0]-r[0]>a?s:0;u===0&&(u=r[0]-i[2]>a?-s:i[2]-r[0]>a?s:0),r[0]+=u}pn(e,r)}function cc(r,e,i,s){const a=Math.pow(2,s.z)*Zi,u=[s.x*Zi,s.y*Zi],h=[];for(const f of r)for(const g of f){const y=[g.x+u[0],g.y+u[1]];Xa(y,e,i,a),h.push(y)}return h}function uc(r,e,i,s){const a=Math.pow(2,s.z)*Zi,u=[s.x*Zi,s.y*Zi],h=[];for(const g of r){const y=[];for(const x of g){const b=[x.x+u[0],x.y+u[1]];pn(e,b),y.push(b)}h.push(y)}if(e[2]-e[0]<=a/2){(f=e)[0]=f[1]=1/0,f[2]=f[3]=-1/0;for(const g of h)for(const y of g)Xa(y,e,i,a)}var f;return h}class Fn{constructor(e,i){this.type=Ye,this.geojson=e,this.geometries=i}static parse(e,i){if(e.length!==2)return i.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Nr(e[1])){const s=e[1];if(s.type==="FeatureCollection"){const a=[];for(const u of s.features){const{type:h,coordinates:f}=u.geometry;h==="Polygon"&&a.push(f),h==="MultiPolygon"&&a.push(...f)}if(a.length)return new Fn(s,{type:"MultiPolygon",coordinates:a})}else if(s.type==="Feature"){const a=s.geometry.type;if(a==="Polygon"||a==="MultiPolygon")return new Fn(s,s.geometry)}else if(s.type==="Polygon"||s.type==="MultiPolygon")return new Fn(s,s)}return i.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return(function(i,s){const a=[1/0,1/0,-1/0,-1/0],u=[1/0,1/0,-1/0,-1/0],h=i.canonicalID();if(s.type==="Polygon"){const f=Ho(s.coordinates,u,h),g=cc(i.geometry(),a,u,h);if(!Ws(a,u))return!1;for(const y of g)if(!fs(y,f))return!1}if(s.type==="MultiPolygon"){const f=lc(s.coordinates,u,h),g=cc(i.geometry(),a,u,h);if(!Ws(a,u))return!1;for(const y of g)if(!Ou(y,f))return!1}return!0})(e,this.geometries);if(e.geometryType()==="LineString")return(function(i,s){const a=[1/0,1/0,-1/0,-1/0],u=[1/0,1/0,-1/0,-1/0],h=i.canonicalID();if(s.type==="Polygon"){const f=Ho(s.coordinates,u,h),g=uc(i.geometry(),a,u,h);if(!Ws(a,u))return!1;for(const y of g)if(!Xs(y,f))return!1}if(s.type==="MultiPolygon"){const f=lc(s.coordinates,u,h),g=uc(i.geometry(),a,u,h);if(!Ws(a,u))return!1;for(const y of g)if(!Vu(y,f))return!1}return!0})(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let hc=class{constructor(r=[],e=(i,s)=>i<s?-1:i>s?1:0){if(this.data=r,this.length=this.data.length,this.compare=e,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(r){this.data.push(r),this._up(this.length++)}pop(){if(this.length===0)return;const r=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),r}peek(){return this.data[0]}_up(r){const{data:e,compare:i}=this,s=e[r];for(;r>0;){const a=r-1>>1,u=e[a];if(i(s,u)>=0)break;e[r]=u,r=a}e[r]=s}_down(r){const{data:e,compare:i}=this,s=this.length>>1,a=e[r];for(;r<s;){let u=1+(r<<1);const h=u+1;if(h<this.length&&i(e[h],e[u])<0&&(u=h),i(e[u],a)>=0)break;e[r]=e[u],r=u}e[r]=a}};function dc(r,e,i=0,s=r.length-1,a=pc){for(;s>i;){if(s-i>600){const g=s-i+1,y=e-i+1,x=Math.log(g),b=.5*Math.exp(2*x/3),S=.5*Math.sqrt(x*b*(g-b)/g)*(y-g/2<0?-1:1);dc(r,e,Math.max(i,Math.floor(e-y*b/g+S)),Math.min(s,Math.floor(e+(g-y)*b/g+S)),a)}const u=r[e];let h=i,f=s;for(ms(r,i,e),a(r[s],u)>0&&ms(r,i,s);h<f;){for(ms(r,h,f),h++,f--;a(r[h],u)<0;)h++;for(;a(r[f],u)>0;)f--}a(r[i],u)===0?ms(r,i,f):(f++,ms(r,f,s)),f<=e&&(i=f+1),e<=f&&(s=f-1)}}function ms(r,e,i){const s=r[e];r[e]=r[i],r[i]=s}function pc(r,e){return r<e?-1:r>e?1:0}function Ys(r,e){if(r.length<=1)return[r];const i=[];let s,a;for(const u of r){const h=ju(u);h!==0&&(u.area=Math.abs(h),a===void 0&&(a=h<0),a===h<0?(s&&i.push(s),s=[u]):s.push(u))}if(s&&i.push(s),e>1)for(let u=0;u<i.length;u++)i[u].length<=e||(dc(i[u],e,1,i[u].length-1,Nu),i[u]=i[u].slice(0,e));return i}function Nu(r,e){return e.area-r.area}function ju(r){let e=0;for(let i,s,a=0,u=r.length,h=u-1;a<u;h=a++)i=r[a],s=r[h],e+=(s.x-i.x)*(i.y+s.y);return e}const fc=1/298.257223563,mc=fc*(2-fc),Ks=Math.PI/180;class Ya{constructor(e){const i=6378.137*Ks*1e3,s=Math.cos(e*Ks),a=1/(1-mc*(1-s*s)),u=Math.sqrt(a);this.kx=i*u*s,this.ky=i*u*a*(1-mc)}distance(e,i){const s=this.wrap(e[0]-i[0])*this.kx,a=(e[1]-i[1])*this.ky;return Math.sqrt(s*s+a*a)}pointOnLine(e,i){let s,a,u,h,f=1/0;for(let g=0;g<e.length-1;g++){let y=e[g][0],x=e[g][1],b=this.wrap(e[g+1][0]-y)*this.kx,S=(e[g+1][1]-x)*this.ky,P=0;b===0&&S===0||(P=(this.wrap(i[0]-y)*this.kx*b+(i[1]-x)*this.ky*S)/(b*b+S*S),P>1?(y=e[g+1][0],x=e[g+1][1]):P>0&&(y+=b/this.kx*P,x+=S/this.ky*P)),b=this.wrap(i[0]-y)*this.kx,S=(i[1]-x)*this.ky;const I=b*b+S*S;I<f&&(f=I,s=y,a=x,u=g,h=P)}return{point:[s,a],index:u,t:Math.max(0,Math.min(1,h))}}wrap(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}}function gc(r,e){return e[0]-r[0]}function Wo(r){return r[1]-r[0]+1}function Gr(r,e){return r[1]>=r[0]&&r[1]<e}function Js(r,e){if(r[0]>r[1])return[null,null];const i=Wo(r);if(e){if(i===2)return[r,null];const a=Math.floor(i/2);return[[r[0],r[0]+a],[r[0]+a,r[1]]]}if(i===1)return[r,null];const s=Math.floor(i/2)-1;return[[r[0],r[0]+s],[r[0]+s+1,r[1]]]}function Xo(r,e){if(!Gr(e,r.length))return[1/0,1/0,-1/0,-1/0];const i=[1/0,1/0,-1/0,-1/0];for(let s=e[0];s<=e[1];++s)pn(i,r[s]);return i}function Ka(r){const e=[1/0,1/0,-1/0,-1/0];for(const i of r)for(const s of i)pn(e,s);return e}function _c(r){return r[0]!==-1/0&&r[1]!==-1/0&&r[2]!==1/0&&r[3]!==1/0}function Yo(r,e,i){if(!_c(r)||!_c(e))return NaN;let s=0,a=0;return r[2]<e[0]&&(s=e[0]-r[2]),r[0]>e[2]&&(s=r[0]-e[2]),r[1]>e[3]&&(a=r[1]-e[3]),r[3]<e[1]&&(a=e[1]-r[3]),i.distance([0,0],[s,a])}function fn(r,e,i){const s=i.pointOnLine(e,r);return i.distance(r,s.point)}function Ja(r,e,i,s,a){const u=Math.min(fn(r,[i,s],a),fn(e,[i,s],a)),h=Math.min(fn(i,[r,e],a),fn(s,[r,e],a));return Math.min(u,h)}function Uu(r,e,i,s,a){if(!Gr(e,r.length)||!Gr(s,i.length))return 1/0;let u=1/0;for(let h=e[0];h<e[1];++h){const f=r[h],g=r[h+1];for(let y=s[0];y<s[1];++y){const x=i[y],b=i[y+1];if($o(f,g,x,b))return 0;u=Math.min(u,Ja(f,g,x,b,a))}}return u}function Gu(r,e,i,s,a){if(!Gr(e,r.length)||!Gr(s,i.length))return NaN;let u=1/0;for(let h=e[0];h<=e[1];++h)for(let f=s[0];f<=s[1];++f)if(u=Math.min(u,a.distance(r[h],i[f])),u===0)return u;return u}function yc(r,e,i){if(fs(r,e,!0))return 0;let s=1/0;for(const a of e){const u=a[0],h=a[a.length-1];if(u!==h&&(s=Math.min(s,fn(r,[h,u],i)),s===0))return s;const f=i.pointOnLine(a,r);if(s=Math.min(s,i.distance(r,f.point)),s===0)return s}return s}function qu(r,e,i,s){if(!Gr(e,r.length))return NaN;for(let u=e[0];u<=e[1];++u)if(fs(r[u],i,!0))return 0;let a=1/0;for(let u=e[0];u<e[1];++u){const h=r[u],f=r[u+1];for(const g of i)for(let y=0,x=g.length,b=x-1;y<x;b=y++){const S=g[b],P=g[y];if($o(h,f,S,P))return 0;a=Math.min(a,Ja(h,f,S,P,s))}}return a}function vc(r,e){for(const i of r)for(const s of i)if(fs(s,e,!0))return!0;return!1}function Zu(r,e,i,s=1/0){const a=Ka(r),u=Ka(e);if(s!==1/0&&Yo(a,u,i)>=s)return s;if(Ws(a,u)){if(vc(r,e))return 0}else if(vc(e,r))return 0;let h=1/0;for(const f of r)for(let g=0,y=f.length,x=y-1;g<y;x=g++){const b=f[x],S=f[g];for(const P of e)for(let I=0,A=P.length,L=A-1;I<A;L=I++){const O=P[L],G=P[I];if($o(b,S,O,G))return 0;h=Math.min(h,Ja(b,S,O,G,i))}}return h}function xc(r,e,i,s,a,u){if(!u)return;const h=Yo(Xo(s,u),a,i);h<e&&r.push([h,u,[0,0]])}function lt(r,e,i,s,a,u,h){if(!u||!h)return;const f=Yo(Xo(s,u),Xo(a,h),i);f<e&&r.push([f,u,h])}function Ko(r,e,i,s,a=1/0){let u=Math.min(s.distance(r[0],i[0][0]),a);if(u===0)return u;const h=new hc([[0,[0,r.length-1],[0,0]]],gc),f=Ka(i);for(;h.length>0;){const g=h.pop();if(g[0]>=u)continue;const y=g[1],x=e?50:100;if(Wo(y)<=x){if(!Gr(y,r.length))return NaN;if(e){const b=qu(r,y,i,s);if(isNaN(b)||b===0)return b;u=Math.min(u,b)}else for(let b=y[0];b<=y[1];++b){const S=yc(r[b],i,s);if(u=Math.min(u,S),u===0)return 0}}else{const b=Js(y,e);xc(h,u,s,r,f,b[0]),xc(h,u,s,r,f,b[1])}}return u}function Jo(r,e,i,s,a,u=1/0){let h=Math.min(u,a.distance(r[0],i[0]));if(h===0)return h;const f=new hc([[0,[0,r.length-1],[0,i.length-1]]],gc);for(;f.length>0;){const g=f.pop();if(g[0]>=h)continue;const y=g[1],x=g[2],b=e?50:100,S=s?50:100;if(Wo(y)<=b&&Wo(x)<=S){if(!Gr(y,r.length)&&Gr(x,i.length))return NaN;let P;if(e&&s)P=Uu(r,y,i,x,a),h=Math.min(h,P);else if(e&&!s){const I=r.slice(y[0],y[1]+1);for(let A=x[0];A<=x[1];++A)if(P=fn(i[A],I,a),h=Math.min(h,P),h===0)return h}else if(!e&&s){const I=i.slice(x[0],x[1]+1);for(let A=y[0];A<=y[1];++A)if(P=fn(r[A],I,a),h=Math.min(h,P),h===0)return h}else P=Gu(r,y,i,x,a),h=Math.min(h,P)}else{const P=Js(y,e),I=Js(x,s);lt(f,h,a,r,i,P[0],I[0]),lt(f,h,a,r,i,P[0],I[1]),lt(f,h,a,r,i,P[1],I[0]),lt(f,h,a,r,i,P[1],I[1])}}return h}function Qa(r){return r.type==="MultiPolygon"?r.coordinates.map((e=>({type:"Polygon",coordinates:e}))):r.type==="MultiLineString"?r.coordinates.map((e=>({type:"LineString",coordinates:e}))):r.type==="MultiPoint"?r.coordinates.map((e=>({type:"Point",coordinates:e}))):[r]}class Bn{constructor(e,i){this.type=Me,this.geojson=e,this.geometries=i}static parse(e,i){if(e.length!==2)return i.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Nr(e[1])){const s=e[1];if(s.type==="FeatureCollection")return new Bn(s,s.features.map((a=>Qa(a.geometry))).flat());if(s.type==="Feature")return new Bn(s,Qa(s.geometry));if("type"in s&&"coordinates"in s)return new Bn(s,Qa(s))}return i.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return(function(i,s){const a=i.geometry(),u=a.flat().map((g=>Zo([g.x,g.y],i.canonical)));if(a.length===0)return NaN;const h=new Ya(u[0][1]);let f=1/0;for(const g of s){switch(g.type){case"Point":f=Math.min(f,Jo(u,!1,[g.coordinates],!1,h,f));break;case"LineString":f=Math.min(f,Jo(u,!1,g.coordinates,!0,h,f));break;case"Polygon":f=Math.min(f,Ko(u,!1,g.coordinates,h,f))}if(f===0)return f}return f})(e,this.geometries);if(e.geometryType()==="LineString")return(function(i,s){const a=i.geometry(),u=a.flat().map((g=>Zo([g.x,g.y],i.canonical)));if(a.length===0)return NaN;const h=new Ya(u[0][1]);let f=1/0;for(const g of s){switch(g.type){case"Point":f=Math.min(f,Jo(u,!0,[g.coordinates],!1,h,f));break;case"LineString":f=Math.min(f,Jo(u,!0,g.coordinates,!0,h,f));break;case"Polygon":f=Math.min(f,Ko(u,!0,g.coordinates,h,f))}if(f===0)return f}return f})(e,this.geometries);if(e.geometryType()==="Polygon")return(function(i,s){const a=i.geometry();if(a.length===0||a[0].length===0)return NaN;const u=Ys(a,0).map((g=>g.map((y=>y.map((x=>Zo([x.x,x.y],i.canonical))))))),h=new Ya(u[0][0][0][1]);let f=1/0;for(const g of s)for(const y of u){switch(g.type){case"Point":f=Math.min(f,Ko([g.coordinates],!1,y,h,f));break;case"LineString":f=Math.min(f,Ko(g.coordinates,!0,y,h,f));break;case"Polygon":f=Math.min(f,Zu(y,g.coordinates,h,f))}if(f===0)return f}return f})(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class Qs{constructor(e){this.type=tt,this.key=e}static parse(e,i){if(e.length!==2)return i.error(`Expected 1 argument, but found ${e.length-1} instead.`);const s=e[1];return s==null?i.error("Global state property must be defined."):typeof s!="string"?i.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new Qs(s)}evaluate(e){var i;const s=(i=e.globals)===null||i===void 0?void 0:i.globalState;return s&&Object.keys(s).length!==0?js(s,this.key):null}eachChild(){}outputDefined(){return!1}}const gs={"==":ni,"!=":oc,">":ac,"<":$a,">=":ds,"<=":Fu,array:fr,at:qs,boolean:fr,case:at,coalesce:ii,collator:Rn,format:Go,image:qo,in:ot,"index-of":Qe,interpolate:Pi,"interpolate-hcl":Pi,"interpolate-lab":Pi,length:ps,let:kn,literal:jr,match:Zs,number:fr,"number-format":Hs,object:fr,slice:hs,step:Ln,string:fr,"to-boolean":qi,"to-color":qi,"to-number":qi,"to-string":qi,var:yt,within:Fn,distance:Bn,"global-state":Qs};class or{constructor(e,i,s,a){this.name=e,this.type=i,this._evaluate=s,this.args=a}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,i){const s=e[0],a=or.definitions[s];if(!a)return i.error(`Unknown expression "${s}". If you wanted a literal array, use ["literal", [...]].`,0);const u=Array.isArray(a)?a[0]:a.type,h=Array.isArray(a)?[[a[1],a[2]]]:a.overloads,f=h.filter((([y])=>!Array.isArray(y)||y.length===e.length-1));let g=null;for(const[y,x]of f){g=new Gs(i.registry,Qo,i.path,null,i.scope);const b=[];let S=!1;for(let P=1;P<e.length;P++){const I=e[P],A=Array.isArray(y)?y[P-1]:y.type,L=g.parse(I,1+b.length,A);if(!L){S=!0;break}b.push(L)}if(!S)if(Array.isArray(y)&&y.length!==b.length)g.error(`Expected ${y.length} arguments, but found ${b.length} instead.`);else{for(let P=0;P<b.length;P++){const I=Array.isArray(y)?y[P]:y.type,A=b[P];g.concat(P+1).checkSubtype(I,A.type)}if(g.errors.length===0)return new or(s,u,x,b)}}if(f.length===1)i.errors.push(...g.errors);else{const y=(f.length?f:h).map((([b])=>{return S=b,Array.isArray(S)?`(${S.map(St).join(", ")})`:`(${St(S.type)}...)`;var S})).join(" | "),x=[];for(let b=1;b<e.length;b++){const S=i.parse(e[b],1+x.length);if(!S)return null;x.push(St(S.type))}i.error(`Expected arguments of type ${y}, but found (${x.join(", ")}) instead.`)}return null}static register(e,i){or.definitions=i;for(const s in i)e[s]=or}}function bc(r,[e,i,s,a]){e=e.evaluate(r),i=i.evaluate(r),s=s.evaluate(r);const u=a?a.evaluate(r):1,h=Oo(e,i,s,u);if(h)throw new je(h);return new st(e/255,i/255,s/255,u,!1)}function wc(r,e){return r in e}function el(r,e){const i=e[r];return i===void 0?null:i}function On(r){return{type:r}}function Qo(r){if(r instanceof yt)return Qo(r.boundExpression);if(r instanceof or&&r.name==="error"||r instanceof Rn||r instanceof Fn||r instanceof Bn||r instanceof Qs)return!1;const e=r instanceof qi||r instanceof fr;let i=!0;return r.eachChild((s=>{i=e?i&&Qo(s):i&&s instanceof jr})),!!i&&ea(r)&&ta(r,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function ea(r){if(r instanceof or&&(r.name==="get"&&r.args.length===1||r.name==="feature-state"||r.name==="has"&&r.args.length===1||r.name==="properties"||r.name==="geometry-type"||r.name==="id"||/^filter-/.test(r.name))||r instanceof Fn||r instanceof Bn)return!1;let e=!0;return r.eachChild((i=>{e&&!ea(i)&&(e=!1)})),e}function eo(r){if(r instanceof or&&r.name==="feature-state")return!1;let e=!0;return r.eachChild((i=>{e&&!eo(i)&&(e=!1)})),e}function ta(r,e){if(r instanceof or&&e.indexOf(r.name)>=0)return!1;let i=!0;return r.eachChild((s=>{i&&!ta(s,e)&&(i=!1)})),i}function Tc(r){return{result:"success",value:r}}function _s(r){return{result:"error",value:r}}function ys(r){return r["property-type"]==="data-driven"||r["property-type"]==="cross-faded-data-driven"}function Sc(r){return!!r.expression&&r.expression.parameters.indexOf("zoom")>-1}function tl(r){return!!r.expression&&r.expression.interpolated}function rt(r){return r instanceof Number?"number":r instanceof String?"string":r instanceof Boolean?"boolean":Array.isArray(r)?"array":r===null?"null":typeof r}function ia(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)&&zt(r)===In}function $u(r){return r}function Pc(r,e){const i=r.stops&&typeof r.stops[0][0]=="object",s=i||!(i||r.property!==void 0),a=r.type||(tl(e)?"exponential":"interval"),u=(function(x){switch(x.type){case"color":return st.parse;case"padding":return _i.parse;case"numberArray":return yi.parse;case"colorArray":return Pt.parse;default:return null}})(e);if(u&&((r=ut({},r)).stops&&(r.stops=r.stops.map((x=>[x[0],u(x[1])]))),r.default=u(r.default?r.default:e.default)),r.colorSpace&&(h=r.colorSpace)!=="rgb"&&h!=="hcl"&&h!=="lab")throw new Error(`Unknown color space: "${r.colorSpace}"`);var h;const f=(function(x){switch(x){case"exponential":return Mc;case"interval":return Wu;case"categorical":return Hu;case"identity":return Xu;default:throw new Error(`Unknown function type "${x}"`)}})(a);let g,y;if(a==="categorical"){g=Object.create(null);for(const x of r.stops)g[x[0]]=x[1];y=typeof r.stops[0][0]}if(i){const x={},b=[];for(let I=0;I<r.stops.length;I++){const A=r.stops[I],L=A[0].zoom;x[L]===void 0&&(x[L]={zoom:L,type:r.type,property:r.property,default:r.default,stops:[]},b.push(L)),x[L].stops.push([A[0].value,A[1]])}const S=[];for(const I of b)S.push([x[I].zoom,Pc(x[I],e)]);const P={name:"linear"};return{kind:"composite",interpolationType:P,interpolationFactor:Pi.interpolationFactor.bind(void 0,P),zoomStops:S.map((I=>I[0])),evaluate:({zoom:I},A)=>Mc({stops:S,base:r.base},e,I).evaluate(I,A)}}if(s){const x=a==="exponential"?{name:"exponential",base:r.base!==void 0?r.base:1}:null;return{kind:"camera",interpolationType:x,interpolationFactor:Pi.interpolationFactor.bind(void 0,x),zoomStops:r.stops.map((b=>b[0])),evaluate:({zoom:b})=>f(r,e,b,g,y)}}return{kind:"source",evaluate(x,b){const S=b&&b.properties?b.properties[r.property]:void 0;return S===void 0?to(r.default,e.default):f(r,e,S,g,y)}}}function to(r,e,i){return r!==void 0?r:e!==void 0?e:i!==void 0?i:void 0}function Hu(r,e,i,s,a){return to(typeof i===a?s[i]:void 0,r.default,e.default)}function Wu(r,e,i){if(rt(i)!=="number")return to(r.default,e.default);const s=r.stops.length;if(s===1||i<=r.stops[0][0])return r.stops[0][1];if(i>=r.stops[s-1][0])return r.stops[s-1][1];const a=sr(r.stops.map((u=>u[0])),i);return r.stops[a][1]}function Mc(r,e,i){const s=r.base!==void 0?r.base:1;if(rt(i)!=="number")return to(r.default,e.default);const a=r.stops.length;if(a===1||i<=r.stops[0][0])return r.stops[0][1];if(i>=r.stops[a-1][0])return r.stops[a-1][1];const u=sr(r.stops.map((x=>x[0])),i),h=(function(x,b,S,P){const I=P-S,A=x-S;return I===0?0:b===1?A/I:(Math.pow(b,A)-1)/(Math.pow(b,I)-1)})(i,s,r.stops[u][0],r.stops[u+1][0]),f=r.stops[u][1],g=r.stops[u+1][1],y=ui[e.type]||$u;return typeof f.evaluate=="function"?{evaluate(...x){const b=f.evaluate.apply(void 0,x),S=g.evaluate.apply(void 0,x);if(b!==void 0&&S!==void 0)return y(b,S,h,r.colorSpace)}}:y(f,g,h,r.colorSpace)}function Xu(r,e,i){switch(e.type){case"color":i=st.parse(i);break;case"formatted":i=Ui.fromString(i.toString());break;case"resolvedImage":i=Gi.fromString(i.toString());break;case"padding":i=_i.parse(i);break;case"colorArray":i=Pt.parse(i);break;case"numberArray":i=yi.parse(i);break;default:rt(i)===e.type||e.type==="enum"&&e.values[i]||(i=void 0)}return to(i,r.default,e.default)}or.register(gs,{error:[{kind:"error"},[Xe],(r,[e])=>{throw new je(e.evaluate(r))}],typeof:[Xe,[tt],(r,[e])=>St(zt(e.evaluate(r)))],"to-rgba":[Li(Me,4),[rr],(r,[e])=>{const[i,s,a,u]=e.evaluate(r).rgb;return[255*i,255*s,255*a,u]}],rgb:[rr,[Me,Me,Me],bc],rgba:[rr,[Me,Me,Me,Me],bc],has:{type:Ye,overloads:[[[Xe],(r,[e])=>wc(e.evaluate(r),r.properties())],[[Xe,In],(r,[e,i])=>wc(e.evaluate(r),i.evaluate(r))]]},get:{type:tt,overloads:[[[Xe],(r,[e])=>el(e.evaluate(r),r.properties())],[[Xe,In],(r,[e,i])=>el(e.evaluate(r),i.evaluate(r))]]},"feature-state":[tt,[Xe],(r,[e])=>el(e.evaluate(r),r.featureState||{})],properties:[In,[],r=>r.properties()],"geometry-type":[Xe,[],r=>r.geometryType()],id:[tt,[],r=>r.id()],zoom:[Me,[],r=>r.globals.zoom],"heatmap-density":[Me,[],r=>r.globals.heatmapDensity||0],elevation:[Me,[],r=>r.globals.elevation||0],"line-progress":[Me,[],r=>r.globals.lineProgress||0],accumulated:[tt,[],r=>r.globals.accumulated===void 0?null:r.globals.accumulated],"+":[Me,On(Me),(r,e)=>{let i=0;for(const s of e)i+=s.evaluate(r);return i}],"*":[Me,On(Me),(r,e)=>{let i=1;for(const s of e)i*=s.evaluate(r);return i}],"-":{type:Me,overloads:[[[Me,Me],(r,[e,i])=>e.evaluate(r)-i.evaluate(r)],[[Me],(r,[e])=>-e.evaluate(r)]]},"/":[Me,[Me,Me],(r,[e,i])=>e.evaluate(r)/i.evaluate(r)],"%":[Me,[Me,Me],(r,[e,i])=>e.evaluate(r)%i.evaluate(r)],ln2:[Me,[],()=>Math.LN2],pi:[Me,[],()=>Math.PI],e:[Me,[],()=>Math.E],"^":[Me,[Me,Me],(r,[e,i])=>Math.pow(e.evaluate(r),i.evaluate(r))],sqrt:[Me,[Me],(r,[e])=>Math.sqrt(e.evaluate(r))],log10:[Me,[Me],(r,[e])=>Math.log(e.evaluate(r))/Math.LN10],ln:[Me,[Me],(r,[e])=>Math.log(e.evaluate(r))],log2:[Me,[Me],(r,[e])=>Math.log(e.evaluate(r))/Math.LN2],sin:[Me,[Me],(r,[e])=>Math.sin(e.evaluate(r))],cos:[Me,[Me],(r,[e])=>Math.cos(e.evaluate(r))],tan:[Me,[Me],(r,[e])=>Math.tan(e.evaluate(r))],asin:[Me,[Me],(r,[e])=>Math.asin(e.evaluate(r))],acos:[Me,[Me],(r,[e])=>Math.acos(e.evaluate(r))],atan:[Me,[Me],(r,[e])=>Math.atan(e.evaluate(r))],min:[Me,On(Me),(r,e)=>Math.min(...e.map((i=>i.evaluate(r))))],max:[Me,On(Me),(r,e)=>Math.max(...e.map((i=>i.evaluate(r))))],abs:[Me,[Me],(r,[e])=>Math.abs(e.evaluate(r))],round:[Me,[Me],(r,[e])=>{const i=e.evaluate(r);return i<0?-Math.round(-i):Math.round(i)}],floor:[Me,[Me],(r,[e])=>Math.floor(e.evaluate(r))],ceil:[Me,[Me],(r,[e])=>Math.ceil(e.evaluate(r))],"filter-==":[Ye,[Xe,tt],(r,[e,i])=>r.properties()[e.value]===i.value],"filter-id-==":[Ye,[tt],(r,[e])=>r.id()===e.value],"filter-type-==":[Ye,[Xe],(r,[e])=>r.geometryType()===e.value],"filter-<":[Ye,[Xe,tt],(r,[e,i])=>{const s=r.properties()[e.value],a=i.value;return typeof s==typeof a&&s<a}],"filter-id-<":[Ye,[tt],(r,[e])=>{const i=r.id(),s=e.value;return typeof i==typeof s&&i<s}],"filter->":[Ye,[Xe,tt],(r,[e,i])=>{const s=r.properties()[e.value],a=i.value;return typeof s==typeof a&&s>a}],"filter-id->":[Ye,[tt],(r,[e])=>{const i=r.id(),s=e.value;return typeof i==typeof s&&i>s}],"filter-<=":[Ye,[Xe,tt],(r,[e,i])=>{const s=r.properties()[e.value],a=i.value;return typeof s==typeof a&&s<=a}],"filter-id-<=":[Ye,[tt],(r,[e])=>{const i=r.id(),s=e.value;return typeof i==typeof s&&i<=s}],"filter->=":[Ye,[Xe,tt],(r,[e,i])=>{const s=r.properties()[e.value],a=i.value;return typeof s==typeof a&&s>=a}],"filter-id->=":[Ye,[tt],(r,[e])=>{const i=r.id(),s=e.value;return typeof i==typeof s&&i>=s}],"filter-has":[Ye,[tt],(r,[e])=>e.value in r.properties()],"filter-has-id":[Ye,[],r=>r.id()!==null&&r.id()!==void 0],"filter-type-in":[Ye,[Li(Xe)],(r,[e])=>e.value.indexOf(r.geometryType())>=0],"filter-id-in":[Ye,[Li(tt)],(r,[e])=>e.value.indexOf(r.id())>=0],"filter-in-small":[Ye,[Xe,Li(tt)],(r,[e,i])=>i.value.indexOf(r.properties()[e.value])>=0],"filter-in-large":[Ye,[Xe,Li(tt)],(r,[e,i])=>(function(s,a,u,h){for(;u<=h;){const f=u+h>>1;if(a[f]===s)return!0;a[f]>s?h=f-1:u=f+1}return!1})(r.properties()[e.value],i.value,0,i.value.length-1)],all:{type:Ye,overloads:[[[Ye,Ye],(r,[e,i])=>e.evaluate(r)&&i.evaluate(r)],[On(Ye),(r,e)=>{for(const i of e)if(!i.evaluate(r))return!1;return!0}]]},any:{type:Ye,overloads:[[[Ye,Ye],(r,[e,i])=>e.evaluate(r)||i.evaluate(r)],[On(Ye),(r,e)=>{for(const i of e)if(i.evaluate(r))return!0;return!1}]]},"!":[Ye,[Ye],(r,[e])=>!e.evaluate(r)],"is-supported-script":[Ye,[Xe],(r,[e])=>{const i=r.globals&&r.globals.isSupportedScript;return!i||i(e.evaluate(r))}],upcase:[Xe,[Xe],(r,[e])=>e.evaluate(r).toUpperCase()],downcase:[Xe,[Xe],(r,[e])=>e.evaluate(r).toLowerCase()],concat:[Xe,On(tt),(r,e)=>e.map((i=>us(i.evaluate(r)))).join("")],"resolved-locale":[Xe,[ns],(r,[e])=>e.evaluate(r).resolvedLocale()]});class il{constructor(e,i,s){this.expression=e,this._warningHistory={},this._evaluator=new qa,this._defaultValue=i?(function(a){if(a.type==="color"&&ia(a.default))return new st(0,0,0,0);switch(a.type){case"color":return st.parse(a.default)||null;case"padding":return _i.parse(a.default)||null;case"numberArray":return yi.parse(a.default)||null;case"colorArray":return Pt.parse(a.default)||null;case"variableAnchorOffsetCollection":return Wt.parse(a.default)||null;case"projectionDefinition":return Ri.parse(a.default)||null;default:return a.default===void 0?null:a.default}})(i):null,this._enumValues=i&&i.type==="enum"?i.values:null,this._globalState=s}evaluateWithoutErrorHandling(e,i,s,a,u,h){return this._globalState&&(e=qr(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=i,this._evaluator.featureState=s,this._evaluator.canonical=a,this._evaluator.availableImages=u||null,this._evaluator.formattedSection=h,this.expression.evaluate(this._evaluator)}evaluate(e,i,s,a,u,h){this._globalState&&(e=qr(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=i||null,this._evaluator.featureState=s||null,this._evaluator.canonical=a,this._evaluator.availableImages=u||null,this._evaluator.formattedSection=h||null;try{const f=this.expression.evaluate(this._evaluator);if(f==null||typeof f=="number"&&f!=f)return this._defaultValue;if(this._enumValues&&!(f in this._enumValues))throw new je(`Expected value to be one of ${Object.keys(this._enumValues).map((g=>JSON.stringify(g))).join(", ")}, but found ${JSON.stringify(f)} instead.`);return f}catch(f){return this._warningHistory[f.message]||(this._warningHistory[f.message]=!0,typeof console<"u"&&console.warn(f.message)),this._defaultValue}}}function ra(r){return Array.isArray(r)&&r.length>0&&typeof r[0]=="string"&&r[0]in gs}function Vn(r,e,i){const s=new Gs(gs,Qo,[],e?(function(u){const h={color:rr,string:Xe,number:Me,enum:Xe,boolean:Ye,formatted:ss,padding:ko,numberArray:Bs,colorArray:Fs,projectionDefinition:rs,resolvedImage:os,variableAnchorOffsetCollection:Os};return u.type==="array"?Li(h[u.value]||tt,u.length):h[u.type]})(e):void 0),a=s.parse(r,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return a?Tc(new il(a,e,i)):_s(s.errors)}class na{constructor(e,i,s){this.kind=e,this._styleExpression=i,this.isStateDependent=e!=="constant"&&!eo(i.expression),this.globalStateRefs=ro(i.expression),this._globalState=s}evaluateWithoutErrorHandling(e,i,s,a,u,h){return this._globalState&&(e=qr(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,i,s,a,u,h)}evaluate(e,i,s,a,u,h){return this._globalState&&(e=qr(e,this._globalState)),this._styleExpression.evaluate(e,i,s,a,u,h)}}class rl{constructor(e,i,s,a,u){this.kind=e,this.zoomStops=s,this._styleExpression=i,this.isStateDependent=e!=="camera"&&!eo(i.expression),this.globalStateRefs=ro(i.expression),this.interpolationType=a,this._globalState=u}evaluateWithoutErrorHandling(e,i,s,a,u,h){return this._globalState&&(e=qr(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,i,s,a,u,h)}evaluate(e,i,s,a,u,h){return this._globalState&&(e=qr(e,this._globalState)),this._styleExpression.evaluate(e,i,s,a,u,h)}interpolationFactor(e,i,s){return this.interpolationType?Pi.interpolationFactor(this.interpolationType,e,i,s):0}}function Cc(r,e,i){const s=Vn(r,e,i);if(s.result==="error")return s;const a=s.value.expression,u=ea(a);if(!u&&!ys(e))return _s([new Ct("","data expressions not supported")]);const h=ta(a,["zoom"]);if(!h&&!Sc(e))return _s([new Ct("","zoom expressions not supported")]);const f=sa(a);return f||h?f instanceof Ct?_s([f]):f instanceof Pi&&!tl(e)?_s([new Ct("",'"interpolate" expressions cannot be used with this property')]):Tc(f?new rl(u?"camera":"composite",s.value,f.labels,f instanceof Pi?f.interpolation:void 0,i):new na(u?"constant":"source",s.value,i)):_s([new Ct("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class io{constructor(e,i){this._parameters=e,this._specification=i,ut(this,Pc(this._parameters,this._specification))}static deserialize(e){return new io(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function sa(r){let e=null;if(r instanceof kn)e=sa(r.result);else if(r instanceof ii){for(const i of r.args)if(e=sa(i),e)break}else(r instanceof Ln||r instanceof Pi)&&r.input instanceof or&&r.input.name==="zoom"&&(e=r);return e instanceof Ct||r.eachChild((i=>{const s=sa(i);s instanceof Ct?e=s:!e&&s?e=new Ct("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&s&&e!==s&&(e=new Ct("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function ro(r,e=new Set){return r instanceof Qs&&e.add(r.key),r.eachChild((i=>{ro(i,e)})),e}function qr(r,e){const{zoom:i,heatmapDensity:s,elevation:a,lineProgress:u,isSupportedScript:h,accumulated:f}=r??{};return{zoom:i,heatmapDensity:s,elevation:a,lineProgress:u,isSupportedScript:h,accumulated:f,globalState:e}}function oa(r){if(r===!0||r===!1)return!0;if(!Array.isArray(r)||r.length===0)return!1;switch(r[0]){case"has":return r.length>=2&&r[1]!=="$id"&&r[1]!=="$type";case"in":return r.length>=3&&(typeof r[1]!="string"||Array.isArray(r[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return r.length!==3||Array.isArray(r[1])||Array.isArray(r[2]);case"any":case"all":for(const e of r.slice(1))if(!oa(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}const Yu={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function no(r,e){if(r==null)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};oa(r)||(r=aa(r));const i=Vn(r,Yu,e);if(i.result==="error")throw new Error(i.value.map((s=>`${s.key}: ${s.message}`)).join(", "));return{filter:(s,a,u)=>i.value.evaluate(s,a,{},u),needGeometry:Ic(r),getGlobalStateRefs:()=>ro(i.value.expression)}}function Ku(r,e){return r<e?-1:r>e?1:0}function Ic(r){if(!Array.isArray(r))return!1;if(r[0]==="within"||r[0]==="distance")return!0;for(let e=1;e<r.length;e++)if(Ic(r[e]))return!0;return!1}function aa(r){if(!r)return!0;const e=r[0];return r.length<=1?e!=="any":e==="=="?la(r[1],r[2],"=="):e==="!="?ca(la(r[1],r[2],"==")):e==="<"||e===">"||e==="<="||e===">="?la(r[1],r[2],e):e==="any"?(i=r.slice(1),["any"].concat(i.map(aa))):e==="all"?["all"].concat(r.slice(1).map(aa)):e==="none"?["all"].concat(r.slice(1).map(aa).map(ca)):e==="in"?nl(r[1],r.slice(2)):e==="!in"?ca(nl(r[1],r.slice(2))):e==="has"?Ec(r[1]):e!=="!has"||ca(Ec(r[1]));var i}function la(r,e,i){switch(r){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,r,e]}}function nl(r,e){if(e.length===0)return!1;switch(r){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((i=>typeof i!=typeof e[0]))?["filter-in-large",r,["literal",e.sort(Ku)]]:["filter-in-small",r,["literal",e]]}}function Ec(r){switch(r){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",r]}}function ca(r){return["!",r]}function ua(r){const e=typeof r;if(e==="number"||e==="boolean"||e==="string"||r==null)return JSON.stringify(r);if(Array.isArray(r)){let a="[";for(const u of r)a+=`${ua(u)},`;return`${a}]`}const i=Object.keys(r).sort();let s="{";for(let a=0;a<i.length;a++)s+=`${JSON.stringify(i[a])}:${ua(r[i[a]])},`;return`${s}}`}function Ac(r){let e="";for(const i of Oe)e+=`/${ua(r[i])}`;return e}function sl(r){const e=r.value;return e?[new Pe(r.key,e,"constants have been deprecated as of v8")]:[]}function Ut(r){return r instanceof Number||r instanceof String||r instanceof Boolean?r.valueOf():r}function Nn(r){if(Array.isArray(r))return r.map(Nn);if(r instanceof Object&&!(r instanceof Number||r instanceof String||r instanceof Boolean)){const e={};for(const i in r)e[i]=Nn(r[i]);return e}return Ut(r)}function $i(r){const e=r.key,i=r.value,s=r.valueSpec||{},a=r.objectElementValidators||{},u=r.style,h=r.styleSpec,f=r.validateSpec;let g=[];const y=rt(i);if(y!=="object")return[new Pe(e,i,`object expected, ${y} found`)];for(const x in i){const b=x.split(".")[0],S=js(s,b)||s["*"];let P;if(js(a,b))P=a[b];else if(js(s,b)){if(i[x]===void 0)continue;P=f}else if(a["*"])P=a["*"];else{if(!s["*"]){g.push(new Pe(e,i[x],`unknown property "${x}"`));continue}P=f}g=g.concat(P({key:(e&&`${e}.`)+x,value:i[x],valueSpec:S,style:u,styleSpec:h,object:i,objectKey:x,validateSpec:f},i))}for(const x in s)a[x]||s[x].required&&s[x].default===void 0&&i[x]===void 0&&g.push(new Pe(e,i,`missing required property "${x}"`));return g}function ol(r){const e=r.value,i=r.valueSpec,s=r.style,a=r.styleSpec,u=r.key,h=r.arrayElementValidator||r.validateSpec;if(rt(e)!=="array")return[new Pe(u,e,`array expected, ${rt(e)} found`)];if(i.length&&e.length!==i.length)return[new Pe(u,e,`array length ${i.length} expected, length ${e.length} found`)];let f={type:i.value,values:i.values};a.$version<7&&(f.function=i.function),rt(i.value)==="object"&&(f=i.value);let g=[];for(let y=0;y<e.length;y++)g=g.concat(h({array:e,arrayIndex:y,value:e[y],valueSpec:f,validateSpec:r.validateSpec,style:s,styleSpec:a,key:`${u}[${y}]`}));return g}function so(r){const e=r.key,i=r.value,s=r.valueSpec;let a=rt(i);return a==="number"&&i!=i&&(a="NaN"),a!=="number"?[new Pe(e,i,`number expected, ${a} found`)]:"minimum"in s&&i<s.minimum?[new Pe(e,i,`${i} is less than the minimum value ${s.minimum}`)]:"maximum"in s&&i>s.maximum?[new Pe(e,i,`${i} is greater than the maximum value ${s.maximum}`)]:[]}function al(r){const e=r.valueSpec,i=Ut(r.value.type);let s,a,u,h={};const f=i!=="categorical"&&r.value.property===void 0,g=!f,y=rt(r.value.stops)==="array"&&rt(r.value.stops[0])==="array"&&rt(r.value.stops[0][0])==="object",x=$i({key:r.key,value:r.value,valueSpec:r.styleSpec.function,validateSpec:r.validateSpec,style:r.style,styleSpec:r.styleSpec,objectElementValidators:{stops:function(P){if(i==="identity")return[new Pe(P.key,P.value,'identity function may not have a "stops" property')];let I=[];const A=P.value;return I=I.concat(ol({key:P.key,value:A,valueSpec:P.valueSpec,validateSpec:P.validateSpec,style:P.style,styleSpec:P.styleSpec,arrayElementValidator:b})),rt(A)==="array"&&A.length===0&&I.push(new Pe(P.key,A,"array must have at least one stop")),I},default:function(P){return P.validateSpec({key:P.key,value:P.value,valueSpec:e,validateSpec:P.validateSpec,style:P.style,styleSpec:P.styleSpec})}}});return i==="identity"&&f&&x.push(new Pe(r.key,r.value,'missing required property "property"')),i==="identity"||r.value.stops||x.push(new Pe(r.key,r.value,'missing required property "stops"')),i==="exponential"&&r.valueSpec.expression&&!tl(r.valueSpec)&&x.push(new Pe(r.key,r.value,"exponential functions not supported")),r.styleSpec.$version>=8&&(g&&!ys(r.valueSpec)?x.push(new Pe(r.key,r.value,"property functions not supported")):f&&!Sc(r.valueSpec)&&x.push(new Pe(r.key,r.value,"zoom functions not supported"))),i!=="categorical"&&!y||r.value.property!==void 0||x.push(new Pe(r.key,r.value,'"property" property is required')),x;function b(P){let I=[];const A=P.value,L=P.key;if(rt(A)!=="array")return[new Pe(L,A,`array expected, ${rt(A)} found`)];if(A.length!==2)return[new Pe(L,A,`array length 2 expected, length ${A.length} found`)];if(y){if(rt(A[0])!=="object")return[new Pe(L,A,`object expected, ${rt(A[0])} found`)];if(A[0].zoom===void 0)return[new Pe(L,A,"object stop key must have zoom")];if(A[0].value===void 0)return[new Pe(L,A,"object stop key must have value")];if(u&&u>Ut(A[0].zoom))return[new Pe(L,A[0].zoom,"stop zoom values must appear in ascending order")];Ut(A[0].zoom)!==u&&(u=Ut(A[0].zoom),a=void 0,h={}),I=I.concat($i({key:`${L}[0]`,value:A[0],valueSpec:{zoom:{}},validateSpec:P.validateSpec,style:P.style,styleSpec:P.styleSpec,objectElementValidators:{zoom:so,value:S}}))}else I=I.concat(S({key:`${L}[0]`,value:A[0],validateSpec:P.validateSpec,style:P.style,styleSpec:P.styleSpec},A));return ra(Nn(A[1]))?I.concat([new Pe(`${L}[1]`,A[1],"expressions are not allowed in function stops.")]):I.concat(P.validateSpec({key:`${L}[1]`,value:A[1],valueSpec:e,validateSpec:P.validateSpec,style:P.style,styleSpec:P.styleSpec}))}function S(P,I){const A=rt(P.value),L=Ut(P.value),O=P.value!==null?P.value:I;if(s){if(A!==s)return[new Pe(P.key,O,`${A} stop domain type must match previous stop domain type ${s}`)]}else s=A;if(A!=="number"&&A!=="string"&&A!=="boolean")return[new Pe(P.key,O,"stop domain value must be a number, string, or boolean")];if(A!=="number"&&i!=="categorical"){let G=`number expected, ${A} found`;return ys(e)&&i===void 0&&(G+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Pe(P.key,O,G)]}return i!=="categorical"||A!=="number"||isFinite(L)&&Math.floor(L)===L?i!=="categorical"&&A==="number"&&a!==void 0&&L<a?[new Pe(P.key,O,"stop domain values must appear in ascending order")]:(a=L,i==="categorical"&&L in h?[new Pe(P.key,O,"stop domain values must be unique")]:(h[L]=!0,[])):[new Pe(P.key,O,`integer expected, found ${L}`)]}}function mn(r){const e=(r.expressionContext==="property"?Cc:Vn)(Nn(r.value),r.valueSpec);if(e.result==="error")return e.value.map((s=>new Pe(`${r.key}${s.key}`,r.value,s.message)));const i=e.value.expression||e.value._styleExpression.expression;if(r.expressionContext==="property"&&r.propertyKey==="text-font"&&!i.outputDefined())return[new Pe(r.key,r.value,`Invalid data expression for "${r.propertyKey}". Output values must be contained as literals within the expression.`)];if(r.expressionContext==="property"&&r.propertyType==="layout"&&!eo(i))return[new Pe(r.key,r.value,'"feature-state" data expressions are not supported with layout properties.')];if(r.expressionContext==="filter"&&!eo(i))return[new Pe(r.key,r.value,'"feature-state" data expressions are not supported with filters.')];if(r.expressionContext&&r.expressionContext.indexOf("cluster")===0){if(!ta(i,["zoom","feature-state"]))return[new Pe(r.key,r.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(r.expressionContext==="cluster-initial"&&!ea(i))return[new Pe(r.key,r.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function oo(r){const e=r.key,i=r.value,s=rt(i);return s!=="string"?[new Pe(e,i,`color expected, ${s} found`)]:st.parse(String(i))?[]:[new Pe(e,i,`color expected, "${i}" found`)]}function jn(r){const e=r.key,i=r.value,s=r.valueSpec,a=[];return Array.isArray(s.values)?s.values.indexOf(Ut(i))===-1&&a.push(new Pe(e,i,`expected one of [${s.values.join(", ")}], ${JSON.stringify(i)} found`)):Object.keys(s.values).indexOf(Ut(i))===-1&&a.push(new Pe(e,i,`expected one of [${Object.keys(s.values).join(", ")}], ${JSON.stringify(i)} found`)),a}function ao(r){return oa(Nn(r.value))?mn(ut({},r,{expressionContext:"filter",valueSpec:{value:"boolean"}})):lo(r)}function lo(r){const e=r.value,i=r.key;if(rt(e)!=="array")return[new Pe(i,e,`array expected, ${rt(e)} found`)];const s=r.styleSpec;let a,u=[];if(e.length<1)return[new Pe(i,e,"filter array must have at least 1 element")];switch(u=u.concat(jn({key:`${i}[0]`,value:e[0],valueSpec:s.filter_operator,style:r.style,styleSpec:r.styleSpec})),Ut(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&Ut(e[1])==="$type"&&u.push(new Pe(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&u.push(new Pe(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(a=rt(e[1]),a!=="string"&&u.push(new Pe(`${i}[1]`,e[1],`string expected, ${a} found`)));for(let h=2;h<e.length;h++)a=rt(e[h]),Ut(e[1])==="$type"?u=u.concat(jn({key:`${i}[${h}]`,value:e[h],valueSpec:s.geometry_type,style:r.style,styleSpec:r.styleSpec})):a!=="string"&&a!=="number"&&a!=="boolean"&&u.push(new Pe(`${i}[${h}]`,e[h],`string, number, or boolean expected, ${a} found`));break;case"any":case"all":case"none":for(let h=1;h<e.length;h++)u=u.concat(lo({key:`${i}[${h}]`,value:e[h],style:r.style,styleSpec:r.styleSpec}));break;case"has":case"!has":a=rt(e[1]),e.length!==2?u.push(new Pe(i,e,`filter array for "${e[0]}" operator must have 2 elements`)):a!=="string"&&u.push(new Pe(`${i}[1]`,e[1],`string expected, ${a} found`))}return u}function Dc(r,e){const i=r.key,s=r.validateSpec,a=r.style,u=r.styleSpec,h=r.value,f=r.objectKey,g=u[`${e}_${r.layerType}`];if(!g)return[];const y=f.match(/^(.*)-transition$/);if(e==="paint"&&y&&g[y[1]]&&g[y[1]].transition)return s({key:i,value:h,valueSpec:u.transition,style:a,styleSpec:u});const x=r.valueSpec||g[f];if(!x)return[new Pe(i,h,`unknown property "${f}"`)];let b;if(rt(h)==="string"&&ys(x)&&!x.tokens&&(b=/^{([^}]+)}$/.exec(h)))return[new Pe(i,h,`"${f}" does not support interpolation syntax
|
|
10
|
+
Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(b[1])} }\`.`)];const S=[];return r.layerType==="symbol"&&f==="text-font"&&ia(Nn(h))&&Ut(h.type)==="identity"&&S.push(new Pe(i,h,'"text-font" does not support identity functions')),S.concat(s({key:r.key,value:h,valueSpec:x,style:a,styleSpec:u,expressionContext:"property",propertyType:e,propertyKey:f}))}function zc(r){return Dc(r,"paint")}function kc(r){return Dc(r,"layout")}function Lc(r){let e=[];const i=r.value,s=r.key,a=r.style,u=r.styleSpec;if(rt(i)!=="object")return[new Pe(s,i,`object expected, ${rt(i)} found`)];i.type||i.ref||e.push(new Pe(s,i,'either "type" or "ref" is required'));let h=Ut(i.type);const f=Ut(i.ref);if(i.id){const g=Ut(i.id);for(let y=0;y<r.arrayIndex;y++){const x=a.layers[y];Ut(x.id)===g&&e.push(new Pe(s,i.id,`duplicate layer id "${i.id}", previously used at line ${x.id.__line__}`))}}if("ref"in i){let g;["type","source","source-layer","filter","layout"].forEach((y=>{y in i&&e.push(new Pe(s,i[y],`"${y}" is prohibited for ref layers`))})),a.layers.forEach((y=>{Ut(y.id)===f&&(g=y)})),g?g.ref?e.push(new Pe(s,i.ref,"ref cannot reference another ref layer")):h=Ut(g.type):e.push(new Pe(s,i.ref,`ref layer "${f}" not found`))}else if(h!=="background")if(i.source){const g=a.sources&&a.sources[i.source],y=g&&Ut(g.type);g?y==="vector"&&h==="raster"?e.push(new Pe(s,i.source,`layer "${i.id}" requires a raster source`)):y!=="raster-dem"&&h==="hillshade"||y!=="raster-dem"&&h==="color-relief"?e.push(new Pe(s,i.source,`layer "${i.id}" requires a raster-dem source`)):y==="raster"&&h!=="raster"?e.push(new Pe(s,i.source,`layer "${i.id}" requires a vector source`)):y!=="vector"||i["source-layer"]?y==="raster-dem"&&h!=="hillshade"&&h!=="color-relief"?e.push(new Pe(s,i.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):h!=="line"||!i.paint||!i.paint["line-gradient"]||y==="geojson"&&g.lineMetrics||e.push(new Pe(s,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new Pe(s,i,`layer "${i.id}" must specify a "source-layer"`)):e.push(new Pe(s,i.source,`source "${i.source}" not found`))}else e.push(new Pe(s,i,'missing required property "source"'));return e=e.concat($i({key:s,value:i,valueSpec:u.layer,style:r.style,styleSpec:r.styleSpec,validateSpec:r.validateSpec,objectElementValidators:{"*":()=>[],type:()=>r.validateSpec({key:`${s}.type`,value:i.type,valueSpec:u.layer.type,style:r.style,styleSpec:r.styleSpec,validateSpec:r.validateSpec,object:i,objectKey:"type"}),filter:ao,layout:g=>$i({layer:i,key:g.key,value:g.value,style:g.style,styleSpec:g.styleSpec,validateSpec:g.validateSpec,objectElementValidators:{"*":y=>kc(ut({layerType:h},y))}}),paint:g=>$i({layer:i,key:g.key,value:g.value,style:g.style,styleSpec:g.styleSpec,validateSpec:g.validateSpec,objectElementValidators:{"*":y=>zc(ut({layerType:h},y))}})}})),e}function gn(r){const e=r.value,i=r.key,s=rt(e);return s!=="string"?[new Pe(i,e,`string expected, ${s} found`)]:[]}const Rc={promoteId:function({key:r,value:e}){if(rt(e)==="string")return gn({key:r,value:e});{const i=[];for(const s in e)i.push(...gn({key:`${r}.${s}`,value:e[s]}));return i}}};function ll(r){const e=r.value,i=r.key,s=r.styleSpec,a=r.style,u=r.validateSpec;if(!e.type)return[new Pe(i,e,'"type" is required')];const h=Ut(e.type);let f;switch(h){case"vector":case"raster":return f=$i({key:i,value:e,valueSpec:s[`source_${h.replace("-","_")}`],style:r.style,styleSpec:s,objectElementValidators:Rc,validateSpec:u}),f;case"raster-dem":return f=(function(g){var y;const x=(y=g.sourceName)!==null&&y!==void 0?y:"",b=g.value,S=g.styleSpec,P=S.source_raster_dem,I=g.style;let A=[];const L=rt(b);if(b===void 0)return A;if(L!=="object")return A.push(new Pe("source_raster_dem",b,`object expected, ${L} found`)),A;const O=Ut(b.encoding)==="custom",G=["redFactor","greenFactor","blueFactor","baseShift"],B=g.value.encoding?`"${g.value.encoding}"`:"Default";for(const V in b)!O&&G.includes(V)?A.push(new Pe(V,b[V],`In "${x}": "${V}" is only valid when "encoding" is set to "custom". ${B} encoding found`)):P[V]?A=A.concat(g.validateSpec({key:V,value:b[V],valueSpec:P[V],validateSpec:g.validateSpec,style:I,styleSpec:S})):A.push(new Pe(V,b[V],`unknown property "${V}"`));return A})({sourceName:i,value:e,style:r.style,styleSpec:s,validateSpec:u}),f;case"geojson":if(f=$i({key:i,value:e,valueSpec:s.source_geojson,style:a,styleSpec:s,validateSpec:u,objectElementValidators:Rc}),e.cluster)for(const g in e.clusterProperties){const[y,x]=e.clusterProperties[g],b=typeof y=="string"?[y,["accumulated"],["get",g]]:y;f.push(...mn({key:`${i}.${g}.map`,value:x,expressionContext:"cluster-map"})),f.push(...mn({key:`${i}.${g}.reduce`,value:b,expressionContext:"cluster-reduce"}))}return f;case"video":return $i({key:i,value:e,valueSpec:s.source_video,style:a,validateSpec:u,styleSpec:s});case"image":return $i({key:i,value:e,valueSpec:s.source_image,style:a,validateSpec:u,styleSpec:s});case"canvas":return[new Pe(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return jn({key:`${i}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function cl(r){const e=r.value,i=r.styleSpec,s=i.light,a=r.style;let u=[];const h=rt(e);if(e===void 0)return u;if(h!=="object")return u=u.concat([new Pe("light",e,`object expected, ${h} found`)]),u;for(const f in e){const g=f.match(/^(.*)-transition$/);u=u.concat(g&&s[g[1]]&&s[g[1]].transition?r.validateSpec({key:f,value:e[f],valueSpec:i.transition,validateSpec:r.validateSpec,style:a,styleSpec:i}):s[f]?r.validateSpec({key:f,value:e[f],valueSpec:s[f],validateSpec:r.validateSpec,style:a,styleSpec:i}):[new Pe(f,e[f],`unknown property "${f}"`)])}return u}function co(r){const e=r.value,i=r.styleSpec,s=i.sky,a=r.style,u=rt(e);if(e===void 0)return[];if(u!=="object")return[new Pe("sky",e,`object expected, ${u} found`)];let h=[];for(const f in e)h=h.concat(s[f]?r.validateSpec({key:f,value:e[f],valueSpec:s[f],style:a,styleSpec:i}):[new Pe(f,e[f],`unknown property "${f}"`)]);return h}function Fc(r){const e=r.value,i=r.styleSpec,s=i.terrain,a=r.style;let u=[];const h=rt(e);if(e===void 0)return u;if(h!=="object")return u=u.concat([new Pe("terrain",e,`object expected, ${h} found`)]),u;for(const f in e)u=u.concat(s[f]?r.validateSpec({key:f,value:e[f],valueSpec:s[f],validateSpec:r.validateSpec,style:a,styleSpec:i}):[new Pe(f,e[f],`unknown property "${f}"`)]);return u}function ul(r){let e=[];const i=r.value,s=r.key;if(Array.isArray(i)){const a=[],u=[];for(const h in i)i[h].id&&a.includes(i[h].id)&&e.push(new Pe(s,i,`all the sprites' ids must be unique, but ${i[h].id} is duplicated`)),a.push(i[h].id),i[h].url&&u.includes(i[h].url)&&e.push(new Pe(s,i,`all the sprites' URLs must be unique, but ${i[h].url} is duplicated`)),u.push(i[h].url),e=e.concat($i({key:`${s}[${h}]`,value:i[h],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:r.validateSpec}));return e}return gn({key:s,value:i})}function hl(r){return!!r&&r.constructor===Object}function Bc(r){return hl(r.value)?[]:[new Pe(r.key,r.value,`object expected, ${rt(r.value)} found`)]}const dl={"*":()=>[],array:ol,boolean:function(r){const e=r.value,i=r.key,s=rt(e);return s!=="boolean"?[new Pe(i,e,`boolean expected, ${s} found`)]:[]},number:so,color:oo,constants:sl,enum:jn,filter:ao,function:al,layer:Lc,object:$i,source:ll,light:cl,sky:co,terrain:Fc,projection:function(r){const e=r.value,i=r.styleSpec,s=i.projection,a=r.style,u=rt(e);if(e===void 0)return[];if(u!=="object")return[new Pe("projection",e,`object expected, ${u} found`)];let h=[];for(const f in e)h=h.concat(s[f]?r.validateSpec({key:f,value:e[f],valueSpec:s[f],style:a,styleSpec:i}):[new Pe(f,e[f],`unknown property "${f}"`)]);return h},projectionDefinition:function(r){const e=r.key;let i=r.value;i=i instanceof String?i.valueOf():i;const s=rt(i);return s!=="array"||(function(a){return Array.isArray(a)&&a.length===3&&typeof a[0]=="string"&&typeof a[1]=="string"&&typeof a[2]=="number"})(i)||(function(a){return!!["interpolate","step","literal"].includes(a[0])})(i)?["array","string"].includes(s)?[]:[new Pe(e,i,`projection expected, invalid type "${s}" found`)]:[new Pe(e,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:gn,formatted:function(r){return gn(r).length===0?[]:mn(r)},resolvedImage:function(r){return gn(r).length===0?[]:mn(r)},padding:function(r){const e=r.key,i=r.value;if(rt(i)==="array"){if(i.length<1||i.length>4)return[new Pe(e,i,`padding requires 1 to 4 values; ${i.length} values found`)];const s={type:"number"};let a=[];for(let u=0;u<i.length;u++)a=a.concat(r.validateSpec({key:`${e}[${u}]`,value:i[u],validateSpec:r.validateSpec,valueSpec:s}));return a}return so({key:e,value:i,valueSpec:{}})},numberArray:function(r){const e=r.key,i=r.value;if(rt(i)==="array"){const s={type:"number"};if(i.length<1)return[new Pe(e,i,"array length at least 1 expected, length 0 found")];let a=[];for(let u=0;u<i.length;u++)a=a.concat(r.validateSpec({key:`${e}[${u}]`,value:i[u],validateSpec:r.validateSpec,valueSpec:s}));return a}return so({key:e,value:i,valueSpec:{}})},colorArray:function(r){const e=r.key,i=r.value;if(rt(i)==="array"){if(i.length<1)return[new Pe(e,i,"array length at least 1 expected, length 0 found")];let s=[];for(let a=0;a<i.length;a++)s=s.concat(oo({key:`${e}[${a}]`,value:i[a]}));return s}return oo({key:e,value:i})},variableAnchorOffsetCollection:function(r){const e=r.key,i=r.value,s=rt(i),a=r.styleSpec;if(s!=="array"||i.length<1||i.length%2!=0)return[new Pe(e,i,"variableAnchorOffsetCollection requires a non-empty array of even length")];let u=[];for(let h=0;h<i.length;h+=2)u=u.concat(jn({key:`${e}[${h}]`,value:i[h],valueSpec:a.layout_symbol["text-anchor"]})),u=u.concat(ol({key:`${e}[${h+1}]`,value:i[h+1],valueSpec:{length:2,value:"number"},validateSpec:r.validateSpec,style:r.style,styleSpec:a}));return u},sprite:ul,state:Bc,fontFaces:function(r){const e=r.key,i=r.value,s=r.validateSpec,a=r.styleSpec,u=r.style;if(!hl(i))return[new Pe(e,i,`object expected, ${rt(i)} found`)];const h=[];for(const f in i){const g=i[f],y=rt(g);if(y==="string")h.push(...gn({key:`${e}.${f}`,value:g}));else if(y==="array"){const x={url:{type:"string",required:!0},"unicode-range":{type:"array",value:"string"}};for(const[b,S]of g.entries())h.push(...$i({key:`${e}.${f}[${b}]`,value:S,valueSpec:x,styleSpec:a,style:u,validateSpec:s}))}else h.push(new Pe(`${e}.${f}`,g,`string or array expected, ${y} found`))}return h}};function uo(r){const e=r.value,i=r.valueSpec,s=r.styleSpec;return r.validateSpec=uo,i.expression&&ia(Ut(e))?al(r):i.expression&&ra(Nn(e))?mn(r):i.type&&dl[i.type]?dl[i.type](r):$i(ut({},r,{valueSpec:i.type?s[i.type]:i}))}function vs(r){const e=r.value,i=r.key,s=gn(r);return s.length||(e.indexOf("{fontstack}")===-1&&s.push(new Pe(i,e,'"glyphs" url must include a "{fontstack}" token')),e.indexOf("{range}")===-1&&s.push(new Pe(i,e,'"glyphs" url must include a "{range}" token'))),s}function ar(r,e=K){let i=[];return i=i.concat(uo({key:"",value:r,valueSpec:e.$root,styleSpec:e,style:r,validateSpec:uo,objectElementValidators:{glyphs:vs,"*":()=>[]}})),r.constants&&(i=i.concat(sl({key:"constants",value:r.constants}))),Oc(i)}function gr(r){return function(e){return r(Object.assign({},e,{validateSpec:uo}))}}function Oc(r){return[].concat(r).sort(((e,i)=>e.line-i.line))}function _r(r){return function(...e){return Oc(r.apply(this,e))}}ar.source=_r(gr(ll)),ar.sprite=_r(gr(ul)),ar.glyphs=_r(gr(vs)),ar.light=_r(gr(cl)),ar.sky=_r(gr(co)),ar.terrain=_r(gr(Fc)),ar.state=_r(gr(Bc)),ar.layer=_r(gr(Lc)),ar.filter=_r(gr(ao)),ar.paintProperty=_r(gr(zc)),ar.layoutProperty=_r(gr(kc));const Ju={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"};class Qu{constructor(e,i){this._globalState=i,this.setValue(e)}evaluate(){var e;return(e=this._literalValue)!==null&&e!==void 0?e:this._compiledValue.evaluate({})}setValue(e){if(e==null||e==="visible"||e==="none")return this._literalValue=e==="none"?"none":"visible",this._compiledValue=void 0,void(this._globalStateRefs=new Set);const i=Vn(e,Ju,this._globalState);if(i.result==="error")throw this._literalValue="visible",this._compiledValue=void 0,new Error(i.value.map((s=>`${s.key}: ${s.message}`)).join(", "));this._literalValue=void 0,this._compiledValue=i.value,this._globalStateRefs=ro(i.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}}const ho=K,Cr=ar,Hi=Cr.light,po=Cr.sky,Vc=Cr.paintProperty,eh=Cr.layoutProperty;function Nc(r,e){let i=!1;if(e&&e.length)for(const s of e)r.fire(new be(new Error(s.message))),i=!0;return i}class Zr{constructor(e,i,s){const a=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const h=new Int32Array(this.arrayBuffer);e=h[0],this.d=(i=h[1])+2*(s=h[2]);for(let g=0;g<this.d*this.d;g++){const y=h[3+g],x=h[3+g+1];a.push(y===x?null:h.subarray(y,x))}const f=h[3+a.length+1];this.keys=h.subarray(h[3+a.length],f),this.bboxes=h.subarray(f),this.insert=this._insertReadonly}else{this.d=i+2*s;for(let h=0;h<this.d*this.d;h++)a.push([]);this.keys=[],this.bboxes=[]}this.n=i,this.extent=e,this.padding=s,this.scale=i/e,this.uid=0;const u=s/i*e;this.min=-u,this.max=e+u}insert(e,i,s,a,u){this._forEachCell(i,s,a,u,this._insertCell,this.uid++,void 0,void 0),this.keys.push(e),this.bboxes.push(i),this.bboxes.push(s),this.bboxes.push(a),this.bboxes.push(u)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(e,i,s,a,u,h){this.cells[u].push(h)}query(e,i,s,a,u){const h=this.min,f=this.max;if(e<=h&&i<=h&&f<=s&&f<=a&&!u)return Array.prototype.slice.call(this.keys);{const g=[];return this._forEachCell(e,i,s,a,this._queryCell,g,{},u),g}}_queryCell(e,i,s,a,u,h,f,g){const y=this.cells[u];if(y!==null){const x=this.keys,b=this.bboxes;for(let S=0;S<y.length;S++){const P=y[S];if(f[P]===void 0){const I=4*P;(g?g(b[I+0],b[I+1],b[I+2],b[I+3]):e<=b[I+2]&&i<=b[I+3]&&s>=b[I+0]&&a>=b[I+1])?(f[P]=!0,h.push(x[P])):f[P]=!1}}}}_forEachCell(e,i,s,a,u,h,f,g){const y=this._convertToCellCoord(e),x=this._convertToCellCoord(i),b=this._convertToCellCoord(s),S=this._convertToCellCoord(a);for(let P=y;P<=b;P++)for(let I=x;I<=S;I++){const A=this.d*I+P;if((!g||g(this._convertFromCellCoord(P),this._convertFromCellCoord(I),this._convertFromCellCoord(P+1),this._convertFromCellCoord(I+1)))&&u.call(this,e,i,s,a,A,h,f,g))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,i=3+this.cells.length+1+1;let s=0;for(let h=0;h<this.cells.length;h++)s+=this.cells[h].length;const a=new Int32Array(i+s+this.keys.length+this.bboxes.length);a[0]=this.extent,a[1]=this.n,a[2]=this.padding;let u=i;for(let h=0;h<e.length;h++){const f=e[h];a[3+h]=u,a.set(f,u),u+=f.length}return a[3+e.length]=u,a.set(this.keys,u),u+=this.keys.length,a[3+e.length+1]=u,a.set(this.bboxes,u),u+=this.bboxes.length,a.buffer}static serialize(e,i){const s=e.toArrayBuffer();return i&&i.push(s),{buffer:s}}static deserialize(e){return new Zr(e.buffer)}}const Ir={};function De(r,e,i={}){if(Ir[r])throw new Error(`${r} is already registered.`);Object.defineProperty(e,"_classRegistryKey",{value:r,writeable:!1}),Ir[r]={klass:e,omit:i.omit||[],shallow:i.shallow||[]}}De("Object",Object),De("Set",Set),De("TransferableGridIndex",Zr),De("Color",st),De("Error",Error),De("AJAXError",F),De("ResolvedImage",Gi),De("StylePropertyFunction",io),De("StyleExpression",il,{omit:["_evaluator"]}),De("ZoomDependentExpression",rl),De("ZoomConstantExpression",na),De("CompoundExpression",or,{omit:["_evaluate"]});for(const r in gs)gs[r]._classRegistryKey||De(`Expression_${r}`,gs[r]);function jc(r){return r&&typeof ArrayBuffer<"u"&&(r instanceof ArrayBuffer||r.constructor&&r.constructor.name==="ArrayBuffer")}function fo(r){return r.$name||r.constructor._classRegistryKey}function Uc(r){return!(function(e){if(e===null||typeof e!="object")return!1;const i=fo(e);return!(!i||i==="Object")})(r)&&(r==null||typeof r=="boolean"||typeof r=="number"||typeof r=="string"||r instanceof Boolean||r instanceof Number||r instanceof String||r instanceof Date||r instanceof RegExp||r instanceof Blob||r instanceof Error||jc(r)||Sn(r)||ArrayBuffer.isView(r)||r instanceof ImageData)}function $r(r,e){if(Uc(r))return(jc(r)||Sn(r))&&e&&e.push(r),ArrayBuffer.isView(r)&&e&&e.push(r.buffer),r instanceof ImageData&&e&&e.push(r.data.buffer),r;if(Array.isArray(r)){const u=[];for(const h of r)u.push($r(h,e));return u}if(typeof r!="object")throw new Error("can't serialize object of type "+typeof r);const i=fo(r);if(!i)throw new Error(`can't serialize object of unregistered class ${r.constructor.name}`);if(!Ir[i])throw new Error(`${i} is not registered.`);const{klass:s}=Ir[i],a=s.serialize?s.serialize(r,e):{};if(s.serialize){if(e&&a===e[e.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const u in r){if(!r.hasOwnProperty(u)||Ir[i].omit.indexOf(u)>=0)continue;const h=r[u];a[u]=Ir[i].shallow.indexOf(u)>=0?h:$r(h,e)}r instanceof Error&&(a.message=r.message)}if(a.$name)throw new Error("$name property is reserved for worker serialization logic.");return i!=="Object"&&(a.$name=i),a}function mo(r){if(Uc(r))return r;if(Array.isArray(r))return r.map(mo);if(typeof r!="object")throw new Error("can't deserialize object of type "+typeof r);const e=fo(r)||"Object";if(!Ir[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:i}=Ir[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(r);const s=Object.create(i.prototype);for(const a of Object.keys(r)){if(a==="$name")continue;const u=r[a];s[a]=Ir[e].shallow.indexOf(a)>=0?u:mo(u)}return s}class pl{constructor(){this.first=!0}update(e,i){const s=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=s,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=s,!0):(this.lastFloorZoom>s?(this.lastIntegerZoom=s+1,this.lastIntegerZoomTime=i):this.lastFloorZoom<s&&(this.lastIntegerZoom=s,this.lastIntegerZoomTime=i),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=s,!0))}}function th(r){return/[\u02EA\u02EB\u2E80-\u2FDF\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-\uDFFF]|[\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-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\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(r))}function Un(r){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]|\uD802[\uDD80-\uDD9F]|\uD805[\uDD80-\uDDFF]|\uD806[\uDE00-\uDEBF]|\uD811[\uDC00-\uDE7F]|\uD81B[\uDFE0-\uDFE4\uDFF0-\uDFF6]|[\uD81C-\uD822\uD83D\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\uDD30-\uDEFB]|\uD833[\uDEC0-\uDFCF]|\uD834[\uDC00-\uDDFF\uDEE0-\uDF7F]|\uD836[\uDC00-\uDEAF]|\uD83C[\uDC00-\uDE00\uDF00-\uDFFF]|\uD83E[\uDD00-\uDEFF]|\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(r))}function Gc(r){return/\s/u.test(String.fromCodePoint(r))}function fl(r){for(const e of r)if(Un(e.codePointAt(0)))return!0;return!1}function ha(r){for(const e of r)if(!da(e.codePointAt(0)))return!1;return!0}function qc(r){const e=r.map((i=>{try{return new RegExp(`\\p{sc=${i}}`,"u").source}catch{return null}})).filter((i=>i));return new RegExp(e.join("|"),"u")}const ml=qc(["Arab","Dupl","Mong","Ougr","Syrc"]);function da(r){return!ml.test(String.fromCodePoint(r))}function gl(r){return!(Un(r)||(e=r,/[\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]|[\uDB80-\uDBFF][\uDC00-\uDFFF]/gim.test(String.fromCodePoint(e))));var e}const Zc=qc(["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 _l(r){return Zc.test(String.fromCodePoint(r))}function $c(r,e){return!(!e&&_l(r)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(r)))}function yl(r){for(const e of r)if(_l(e.codePointAt(0)))return!0;return!1}const Hr=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(r){this.pluginStatus=r.pluginStatus,this.pluginURL=r.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(r){if(Hr.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=r.applyArabicShaping,this.processBidirectionalText=r.processBidirectionalText,this.processStyledBidirectionalText=r.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getRTLTextPluginStatus(){return this.pluginStatus}syncState(r,e){return c(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if(r.pluginStatus!=="loading")return this.setState(r),r;const i=r.pluginURL,s=new Promise((u=>{this.loadScriptResolve=u}));e(i);const a=new Promise((u=>setTimeout((()=>u()),this.TIMEOUT)));if(yield Promise.race([s,a]),this.isParsed()){const u={pluginStatus:"loaded",pluginURL:i};return this.setState(u),u}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${i}`)}))}};class vt{constructor(e,i){this.isSupportedScript=Hc,this.zoom=e,i?(this.now=i.now||0,this.fadeDuration=i.fadeDuration||0,this.zoomHistory=i.zoomHistory||new pl,this.transition=i.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new pl,this.transition={})}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,i=e-Math.floor(e),s=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:i+(1-i)*s}:{fromScale:.5,toScale:1,t:1-(1-s)*i}}}function Hc(r){return(function(e,i){for(const s of e)if(!$c(s.codePointAt(0),i))return!1;return!0})(r,Hr.getRTLTextPluginStatus()==="loaded")}const pa="-transition";class go{constructor(e,i,s){this.property=e,this.value=i,this.expression=(function(a,u,h){if(ia(a))return new io(a,u);if(ra(a)){const f=Cc(a,u,h);if(f.result==="error")throw new Error(f.value.map((g=>`${g.key}: ${g.message}`)).join(", "));return f.value}{let f=a;return u.type==="color"&&typeof a=="string"?f=st.parse(a):u.type!=="padding"||typeof a!="number"&&!Array.isArray(a)?u.type!=="numberArray"||typeof a!="number"&&!Array.isArray(a)?u.type!=="colorArray"||typeof a!="string"&&!Array.isArray(a)?u.type==="variableAnchorOffsetCollection"&&Array.isArray(a)?f=Wt.parse(a):u.type==="projectionDefinition"&&typeof a=="string"&&(f=Ri.parse(a)):f=Pt.parse(a):f=yi.parse(a):f=_i.parse(a),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>f}}})(i===void 0?e.specification.default:i,e.specification,s)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,i,s){return this.property.possiblyEvaluate(this,e,i,s)}}class vl{constructor(e,i){this.property=e,this.value=new go(e,void 0,i)}transitioned(e,i){return new bl(this.property,this.value,i,ki({},e.transition,this.transition),e.now)}untransitioned(){return new bl(this.property,this.value,null,{},0)}}class xl{constructor(e,i){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=i}getValue(e){return mi(this._values[e].value.value)}setValue(e,i){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new vl(this._values[e].property,this._globalState)),this._values[e].value=new go(this._values[e].property,i===null?void 0:mi(i),this._globalState)}getTransition(e){return mi(this._values[e].transition)}setTransition(e,i){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new vl(this._values[e].property,this._globalState)),this._values[e].transition=mi(i)||void 0}serialize(){const e={};for(const i of Object.keys(this._values)){const s=this.getValue(i);s!==void 0&&(e[i]=s);const a=this.getTransition(i);a!==void 0&&(e[`${i}${pa}`]=a)}return e}transitioned(e,i){const s=new Wc(this._properties);for(const a of Object.keys(this._values))s._values[a]=this._values[a].transitioned(e,i._values[a]);return s}untransitioned(){const e=new Wc(this._properties);for(const i of Object.keys(this._values))e._values[i]=this._values[i].untransitioned();return e}}class bl{constructor(e,i,s,a,u){this.property=e,this.value=i,this.begin=u+a.delay||0,this.end=this.begin+a.duration||0,e.specification.transition&&(a.delay||a.duration)&&(this.prior=s)}possiblyEvaluate(e,i,s){const a=e.now||0,u=this.value.possiblyEvaluate(e,i,s),h=this.prior;if(h){if(a>this.end)return this.prior=null,u;if(this.value.isDataDriven())return this.prior=null,u;if(a<this.begin)return h.possiblyEvaluate(e,i,s);{const f=(a-this.begin)/(this.end-this.begin);return this.property.interpolate(h.possiblyEvaluate(e,i,s),u,Jn(f))}}return u}}class Wc{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,i,s){const a=new _o(this._properties);for(const u of Object.keys(this._values))a._values[u]=this._values[u].possiblyEvaluate(e,i,s);return a}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class ih{constructor(e,i){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._globalState=i}hasValue(e){return this._values[e].value!==void 0}getValue(e){return mi(this._values[e].value)}setValue(e,i){this._values[e]=new go(this._values[e].property,i===null?void 0:mi(i),this._globalState)}serialize(){const e={};for(const i of Object.keys(this._values)){const s=this.getValue(i);s!==void 0&&(e[i]=s)}return e}possiblyEvaluate(e,i,s){const a=new _o(this._properties);for(const u of Object.keys(this._values))a._values[u]=this._values[u].possiblyEvaluate(e,i,s);return a}}class yr{constructor(e,i,s){this.property=e,this.value=i,this.parameters=s}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,i,s,a){return this.property.evaluate(this.value,this.parameters,e,i,s,a)}}class _o{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class Be{constructor(e){this.specification=e}possiblyEvaluate(e,i){if(e.isDataDriven())throw new Error("Value should not be data driven");return e.expression.evaluate(i)}interpolate(e,i,s){const a=ui[this.specification.type];return a?a(e,i,s):e}}class Ge{constructor(e,i){this.specification=e,this.overrides=i}possiblyEvaluate(e,i,s,a){return new yr(this,e.expression.kind==="constant"||e.expression.kind==="camera"?{kind:"constant",value:e.expression.evaluate(i,null,{},s,a)}:e.expression,i)}interpolate(e,i,s){if(e.value.kind!=="constant"||i.value.kind!=="constant")return e;if(e.value.value===void 0||i.value.value===void 0)return new yr(this,{kind:"constant",value:void 0},e.parameters);const a=ui[this.specification.type];if(a){const u=a(e.value.value,i.value.value,s);return new yr(this,{kind:"constant",value:u},e.parameters)}return e}evaluate(e,i,s,a,u,h){return e.kind==="constant"?e.value:e.evaluate(i,s,a,u,h)}}class _n extends Ge{possiblyEvaluate(e,i,s,a){if(e.value===void 0)return new yr(this,{kind:"constant",value:void 0},i);if(e.expression.kind==="constant"){const u=e.expression.evaluate(i,null,{},s,a),h=e.property.specification.type==="resolvedImage"&&typeof u!="string"?u.name:u,f=this._calculate(h,h,h,i);return new yr(this,{kind:"constant",value:f},i)}if(e.expression.kind==="camera"){const u=this._calculate(e.expression.evaluate({zoom:i.zoom-1}),e.expression.evaluate({zoom:i.zoom}),e.expression.evaluate({zoom:i.zoom+1}),i);return new yr(this,{kind:"constant",value:u},i)}return new yr(this,e.expression,i)}evaluate(e,i,s,a,u,h){if(e.kind==="source"){const f=e.evaluate(i,s,a,u,h);return this._calculate(f,f,f,i)}return e.kind==="composite"?this._calculate(e.evaluate({zoom:Math.floor(i.zoom)-1},s,a),e.evaluate({zoom:Math.floor(i.zoom)},s,a),e.evaluate({zoom:Math.floor(i.zoom)+1},s,a),i):e.value}_calculate(e,i,s,a){return a.zoom>a.zoomHistory.lastIntegerZoom?{from:e,to:i}:{from:s,to:i}}interpolate(e){return e}}class Xc{constructor(e){this.specification=e}possiblyEvaluate(e,i,s,a){if(e.value!==void 0){if(e.expression.kind==="constant"){const u=e.expression.evaluate(i,null,{},s,a);return this._calculate(u,u,u,i)}return this._calculate(e.expression.evaluate(new vt(Math.floor(i.zoom-1),i)),e.expression.evaluate(new vt(Math.floor(i.zoom),i)),e.expression.evaluate(new vt(Math.floor(i.zoom+1),i)),i)}}_calculate(e,i,s,a){return a.zoom>a.zoomHistory.lastIntegerZoom?{from:e,to:i}:{from:s,to:i}}interpolate(e){return e}}class xs{constructor(e){this.specification=e}possiblyEvaluate(e,i,s,a){return!!e.expression.evaluate(i,null,{},s,a)}interpolate(){return!1}}class Mi{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const i in e){const s=e[i];s.specification.overridable&&this.overridableProperties.push(i);const a=this.defaultPropertyValues[i]=new go(s,void 0,void 0),u=this.defaultTransitionablePropertyValues[i]=new vl(s,void 0);this.defaultTransitioningPropertyValues[i]=u.untransitioned(),this.defaultPossiblyEvaluatedValues[i]=a.possiblyEvaluate({})}}}De("DataDrivenProperty",Ge),De("DataConstantProperty",Be),De("CrossFadedDataDrivenProperty",_n),De("CrossFadedProperty",Xc),De("ColorRampProperty",xs);class vr extends me{constructor(e,i,s){if(super(),this.id=e.id,this.type=e.type,this._globalState=s,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},this._visibilityExpression=(function(a,u){return new Qu(a,u)})(this.visibility,s),e.type!=="custom"&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!=="background"&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter,this._featureFilter=no(e.filter,s)),i.layout&&(this._unevaluatedLayout=new ih(i.layout,s)),i.paint)){this._transitionablePaint=new xl(i.paint,s);for(const a in e.paint)this.setPaintProperty(a,e.paint[a],{validate:!1});for(const a in e.layout)this.setLayoutProperty(a,e.layout[a],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new _o(i.paint)}}setFilter(e){this.filter=e,this._featureFilter=no(e,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){const e=new Set;for(const i of this._visibilityExpression.getGlobalStateRefs())e.add(i);if(this._unevaluatedLayout)for(const i in this._unevaluatedLayout._values){const s=this._unevaluatedLayout._values[i];for(const a of s.getGlobalStateRefs())e.add(a)}for(const i of this._featureFilter.getGlobalStateRefs())e.add(i);return e}getPaintAffectingGlobalStateRefs(){var e;const i=new globalThis.Map;if(this._transitionablePaint)for(const s in this._transitionablePaint._values){const a=this._transitionablePaint._values[s].value;for(const u of a.getGlobalStateRefs()){const h=(e=i.get(u))!==null&&e!==void 0?e:[];h.push({name:s,value:a.value}),i.set(u,h)}}return i}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(e,i,s={}){if(i==null||!this._validate(eh,`layers.${this.id}.layout.${e}`,e,i,s))return e==="visibility"?(this.visibility=i,this._visibilityExpression.setValue(i),void this.recalculateVisibility()):void this._unevaluatedLayout.setValue(e,i)}getPaintProperty(e){return e.endsWith(pa)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,i,s={}){if(i!=null&&this._validate(Vc,`layers.${this.id}.paint.${e}`,e,i,s))return!1;if(e.endsWith(pa))return this._transitionablePaint.setTransition(e.slice(0,-11),i||void 0),!1;{const a=this._transitionablePaint._values[e],u=a.property.specification["property-type"]==="cross-faded-data-driven",h=a.value.isDataDriven(),f=a.value;this._transitionablePaint.setValue(e,i),this._handleSpecialPaintPropertyUpdate(e);const g=this._transitionablePaint._values[e].value;return g.isDataDriven()||h||u||this._handleOverridablePaintPropertyUpdate(e,f,g)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,i,s){return!1}isHidden(e=this.minzoom,i=!1){return!!(this.minzoom&&e<(i?Math.floor(this.minzoom):this.minzoom))||!!(this.maxzoom&&e>=this.maxzoom)||this._evaluatedVisibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculateVisibility(){this._evaluatedVisibility=this._visibilityExpression.evaluate()}recalculate(e,i){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,i)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,i)}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),Tn(e,((i,s)=>!(i===void 0||s==="layout"&&!Object.keys(i).length||s==="paint"&&!Object.keys(i).length)))}_validate(e,i,s,a,u={}){return(!u||u.validate!==!1)&&Nc(this,e.call(Cr,{key:i,layerType:this.type,objectKey:s,value:a,styleSpec:K,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const i=this.paint.get(e);if(i instanceof yr&&ys(i.property.specification)&&(i.value.kind==="source"||i.value.kind==="composite")&&i.value.isStateDependent)return!0}return!1}}let wl;var Yc={get paint(){return wl=wl||new Mi({"raster-opacity":new Be(K.paint_raster["raster-opacity"]),"raster-hue-rotate":new Be(K.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Be(K.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Be(K.paint_raster["raster-brightness-max"]),"raster-saturation":new Be(K.paint_raster["raster-saturation"]),"raster-contrast":new Be(K.paint_raster["raster-contrast"]),"raster-resampling":new Be(K.paint_raster["raster-resampling"]),"raster-fade-duration":new Be(K.paint_raster["raster-fade-duration"])})}};class Kc extends vr{constructor(e,i){super(e,Yc,i)}}const rh={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class yo{constructor(e,i){this._structArray=e,this._pos1=i*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class kt{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,i){return e._trim(),i&&(e.isTransferred=!0,i.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const i=Object.create(this.prototype);return i.arrayBuffer=e.arrayBuffer,i.length=e.length,i.capacity=e.arrayBuffer.byteLength/i.bytesPerElement,i._refreshViews(),i}_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 i=this.uint8;this._refreshViews(),i&&this.uint8.set(i)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Gt(r,e=1){let i=0,s=0;return{members:r.map((a=>{const u=rh[a.type].BYTES_PER_ELEMENT,h=i=Jc(i,Math.max(e,u)),f=a.components||1;return s=Math.max(s,u),i+=u*f,{name:a.name,type:a.type,components:f,offset:h}})),size:Jc(i,Math.max(s,e)),alignment:e}}function Jc(r,e){return Math.ceil(r/e)*e}class Er extends kt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i){const s=this.length;return this.resize(s+1),this.emplace(s,e,i)}emplace(e,i,s){const a=2*e;return this.int16[a+0]=i,this.int16[a+1]=s,e}}Er.prototype.bytesPerElement=4,De("StructArrayLayout2i4",Er);class fa extends kt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,i,s)}emplace(e,i,s,a){const u=3*e;return this.int16[u+0]=i,this.int16[u+1]=s,this.int16[u+2]=a,e}}fa.prototype.bytesPerElement=6,De("StructArrayLayout3i6",fa);class Tl extends kt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,s,a){const u=this.length;return this.resize(u+1),this.emplace(u,e,i,s,a)}emplace(e,i,s,a,u){const h=4*e;return this.int16[h+0]=i,this.int16[h+1]=s,this.int16[h+2]=a,this.int16[h+3]=u,e}}Tl.prototype.bytesPerElement=8,De("StructArrayLayout4i8",Tl);class Sl extends kt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,s,a,u,h){const f=this.length;return this.resize(f+1),this.emplace(f,e,i,s,a,u,h)}emplace(e,i,s,a,u,h,f){const g=6*e;return this.int16[g+0]=i,this.int16[g+1]=s,this.int16[g+2]=a,this.int16[g+3]=u,this.int16[g+4]=h,this.int16[g+5]=f,e}}Sl.prototype.bytesPerElement=12,De("StructArrayLayout2i4i12",Sl);class ma extends kt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,s,a,u,h){const f=this.length;return this.resize(f+1),this.emplace(f,e,i,s,a,u,h)}emplace(e,i,s,a,u,h,f){const g=4*e,y=8*e;return this.int16[g+0]=i,this.int16[g+1]=s,this.uint8[y+4]=a,this.uint8[y+5]=u,this.uint8[y+6]=h,this.uint8[y+7]=f,e}}ma.prototype.bytesPerElement=8,De("StructArrayLayout2i4ub8",ma);class vo extends kt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i){const s=this.length;return this.resize(s+1),this.emplace(s,e,i)}emplace(e,i,s){const a=2*e;return this.float32[a+0]=i,this.float32[a+1]=s,e}}vo.prototype.bytesPerElement=8,De("StructArrayLayout2f8",vo);class Pl extends kt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,s,a,u,h,f,g,y,x){const b=this.length;return this.resize(b+1),this.emplace(b,e,i,s,a,u,h,f,g,y,x)}emplace(e,i,s,a,u,h,f,g,y,x,b){const S=10*e;return this.uint16[S+0]=i,this.uint16[S+1]=s,this.uint16[S+2]=a,this.uint16[S+3]=u,this.uint16[S+4]=h,this.uint16[S+5]=f,this.uint16[S+6]=g,this.uint16[S+7]=y,this.uint16[S+8]=x,this.uint16[S+9]=b,e}}Pl.prototype.bytesPerElement=20,De("StructArrayLayout10ui20",Pl);class Wr extends kt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,s,a,u,h,f,g){const y=this.length;return this.resize(y+1),this.emplace(y,e,i,s,a,u,h,f,g)}emplace(e,i,s,a,u,h,f,g,y){const x=8*e;return this.uint16[x+0]=i,this.uint16[x+1]=s,this.uint16[x+2]=a,this.uint16[x+3]=u,this.uint16[x+4]=h,this.uint16[x+5]=f,this.uint16[x+6]=g,this.uint16[x+7]=y,e}}Wr.prototype.bytesPerElement=16,De("StructArrayLayout8ui16",Wr);class ga extends kt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,s,a,u,h,f,g,y,x,b,S){const P=this.length;return this.resize(P+1),this.emplace(P,e,i,s,a,u,h,f,g,y,x,b,S)}emplace(e,i,s,a,u,h,f,g,y,x,b,S,P){const I=12*e;return this.int16[I+0]=i,this.int16[I+1]=s,this.int16[I+2]=a,this.int16[I+3]=u,this.uint16[I+4]=h,this.uint16[I+5]=f,this.uint16[I+6]=g,this.uint16[I+7]=y,this.int16[I+8]=x,this.int16[I+9]=b,this.int16[I+10]=S,this.int16[I+11]=P,e}}ga.prototype.bytesPerElement=24,De("StructArrayLayout4i4ui4i24",ga);class xo extends kt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,i,s)}emplace(e,i,s,a){const u=3*e;return this.float32[u+0]=i,this.float32[u+1]=s,this.float32[u+2]=a,e}}xo.prototype.bytesPerElement=12,De("StructArrayLayout3f12",xo);class _a extends kt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.uint32[1*e+0]=i,e}}_a.prototype.bytesPerElement=4,De("StructArrayLayout1ul4",_a);class bo extends kt{_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,i,s,a,u,h,f,g,y){const x=this.length;return this.resize(x+1),this.emplace(x,e,i,s,a,u,h,f,g,y)}emplace(e,i,s,a,u,h,f,g,y,x){const b=10*e,S=5*e;return this.int16[b+0]=i,this.int16[b+1]=s,this.int16[b+2]=a,this.int16[b+3]=u,this.int16[b+4]=h,this.int16[b+5]=f,this.uint32[S+3]=g,this.uint16[b+8]=y,this.uint16[b+9]=x,e}}bo.prototype.bytesPerElement=20,De("StructArrayLayout6i1ul2ui20",bo);class Ml extends kt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,s,a,u,h){const f=this.length;return this.resize(f+1),this.emplace(f,e,i,s,a,u,h)}emplace(e,i,s,a,u,h,f){const g=6*e;return this.int16[g+0]=i,this.int16[g+1]=s,this.int16[g+2]=a,this.int16[g+3]=u,this.int16[g+4]=h,this.int16[g+5]=f,e}}Ml.prototype.bytesPerElement=12,De("StructArrayLayout2i2i2i12",Ml);class bs extends kt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,s,a,u){const h=this.length;return this.resize(h+1),this.emplace(h,e,i,s,a,u)}emplace(e,i,s,a,u,h){const f=4*e,g=8*e;return this.float32[f+0]=i,this.float32[f+1]=s,this.float32[f+2]=a,this.int16[g+6]=u,this.int16[g+7]=h,e}}bs.prototype.bytesPerElement=16,De("StructArrayLayout2f1f2i16",bs);class Gn extends kt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,s,a,u,h){const f=this.length;return this.resize(f+1),this.emplace(f,e,i,s,a,u,h)}emplace(e,i,s,a,u,h,f){const g=16*e,y=4*e,x=8*e;return this.uint8[g+0]=i,this.uint8[g+1]=s,this.float32[y+1]=a,this.float32[y+2]=u,this.int16[x+6]=h,this.int16[x+7]=f,e}}Gn.prototype.bytesPerElement=16,De("StructArrayLayout2ub2f2i16",Gn);class ya extends kt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,i,s)}emplace(e,i,s,a){const u=3*e;return this.uint16[u+0]=i,this.uint16[u+1]=s,this.uint16[u+2]=a,e}}ya.prototype.bytesPerElement=6,De("StructArrayLayout3ui6",ya);class va extends kt{_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,i,s,a,u,h,f,g,y,x,b,S,P,I,A,L,O){const G=this.length;return this.resize(G+1),this.emplace(G,e,i,s,a,u,h,f,g,y,x,b,S,P,I,A,L,O)}emplace(e,i,s,a,u,h,f,g,y,x,b,S,P,I,A,L,O,G){const B=24*e,V=12*e,W=48*e;return this.int16[B+0]=i,this.int16[B+1]=s,this.uint16[B+2]=a,this.uint16[B+3]=u,this.uint32[V+2]=h,this.uint32[V+3]=f,this.uint32[V+4]=g,this.uint16[B+10]=y,this.uint16[B+11]=x,this.uint16[B+12]=b,this.float32[V+7]=S,this.float32[V+8]=P,this.uint8[W+36]=I,this.uint8[W+37]=A,this.uint8[W+38]=L,this.uint32[V+10]=O,this.int16[B+22]=G,e}}va.prototype.bytesPerElement=48,De("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",va);class qn extends kt{_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,i,s,a,u,h,f,g,y,x,b,S,P,I,A,L,O,G,B,V,W,ee,ae,_e,ye,xe,Ee,we){const ve=this.length;return this.resize(ve+1),this.emplace(ve,e,i,s,a,u,h,f,g,y,x,b,S,P,I,A,L,O,G,B,V,W,ee,ae,_e,ye,xe,Ee,we)}emplace(e,i,s,a,u,h,f,g,y,x,b,S,P,I,A,L,O,G,B,V,W,ee,ae,_e,ye,xe,Ee,we,ve){const fe=32*e,ze=16*e;return this.int16[fe+0]=i,this.int16[fe+1]=s,this.int16[fe+2]=a,this.int16[fe+3]=u,this.int16[fe+4]=h,this.int16[fe+5]=f,this.int16[fe+6]=g,this.int16[fe+7]=y,this.uint16[fe+8]=x,this.uint16[fe+9]=b,this.uint16[fe+10]=S,this.uint16[fe+11]=P,this.uint16[fe+12]=I,this.uint16[fe+13]=A,this.uint16[fe+14]=L,this.uint16[fe+15]=O,this.uint16[fe+16]=G,this.uint16[fe+17]=B,this.uint16[fe+18]=V,this.uint16[fe+19]=W,this.uint16[fe+20]=ee,this.uint16[fe+21]=ae,this.uint16[fe+22]=_e,this.uint32[ze+12]=ye,this.float32[ze+13]=xe,this.float32[ze+14]=Ee,this.uint16[fe+30]=we,this.uint16[fe+31]=ve,e}}qn.prototype.bytesPerElement=64,De("StructArrayLayout8i15ui1ul2f2ui64",qn);class xa extends kt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.float32[1*e+0]=i,e}}xa.prototype.bytesPerElement=4,De("StructArrayLayout1f4",xa);class Cl extends kt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,i,s)}emplace(e,i,s,a){const u=3*e;return this.uint16[6*e+0]=i,this.float32[u+1]=s,this.float32[u+2]=a,e}}Cl.prototype.bytesPerElement=12,De("StructArrayLayout1ui2f12",Cl);class ba extends kt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,i,s)}emplace(e,i,s,a){const u=4*e;return this.uint32[2*e+0]=i,this.uint16[u+2]=s,this.uint16[u+3]=a,e}}ba.prototype.bytesPerElement=8,De("StructArrayLayout1ul2ui8",ba);class Il extends kt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i){const s=this.length;return this.resize(s+1),this.emplace(s,e,i)}emplace(e,i,s){const a=2*e;return this.uint16[a+0]=i,this.uint16[a+1]=s,e}}Il.prototype.bytesPerElement=4,De("StructArrayLayout2ui4",Il);class d extends kt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.uint16[1*e+0]=i,e}}d.prototype.bytesPerElement=2,De("StructArrayLayout1ui2",d);class t extends kt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,s,a){const u=this.length;return this.resize(u+1),this.emplace(u,e,i,s,a)}emplace(e,i,s,a,u){const h=4*e;return this.float32[h+0]=i,this.float32[h+1]=s,this.float32[h+2]=a,this.float32[h+3]=u,e}}t.prototype.bytesPerElement=16,De("StructArrayLayout4f16",t);class n extends yo{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 Te(this.anchorPointX,this.anchorPointY)}}n.prototype.size=20;class o extends bo{get(e){return new n(this,e)}}De("CollisionBoxArray",o);class l extends yo{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]}}l.prototype.size=48;class p extends va{get(e){return new l(this,e)}}De("PlacedSymbolArray",p);class m extends yo{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]}}m.prototype.size=64;class _ extends qn{get(e){return new m(this,e)}}De("SymbolInstanceArray",_);class v extends xa{getoffsetX(e){return this.float32[1*e+0]}}De("GlyphOffsetArray",v);class w extends fa{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}De("SymbolLineVertexArray",w);class T extends yo{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]}}T.prototype.size=12;class C extends Cl{get(e){return new T(this,e)}}De("TextAnchorOffsetArray",C);class M extends yo{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]}}M.prototype.size=8;class z extends ba{get(e){return new M(this,e)}}De("FeatureIndexArray",z);class R extends Er{}class N extends Er{}class U extends Er{}class j extends Sl{}class Z extends ma{}class X extends vo{}class q extends Pl{}class Y extends Wr{}class Q extends ga{}class H extends xo{}class te extends _a{}class de extends Ml{}class ue extends Gn{}class ce extends ya{}class he extends Il{}const Ce=Gt([{name:"a_pos",components:2,type:"Int16"}],4),{members:Ie}=Ce;class ge{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,i,s,a){const u=this.segments[this.segments.length-1];return e>ge.MAX_VERTEX_ARRAY_LENGTH&&gi(`Max vertices per segment is ${ge.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${ge.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!u||u.vertexLength+e>ge.MAX_VERTEX_ARRAY_LENGTH||u.sortKey!==a?this.createNewSegment(i,s,a):u}createNewSegment(e,i,s){const a={vertexOffset:e.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0,vaos:{}};return s!==void 0&&(a.sortKey=s),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(a),a}getOrCreateLatestSegment(e,i,s){return this.prepareSegment(0,e,i,s)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(const e of this.segments)for(const i in e.vaos)e.vaos[i].destroy()}static simpleSegment(e,i,s,a){return new ge([{vertexOffset:e,primitiveOffset:i,vertexLength:s,primitiveLength:a,vaos:{},sortKey:0}])}}function Re(r,e){return 256*(r=ir(Math.floor(r),0,255))+ir(Math.floor(e),0,255)}ge.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,De("SegmentVector",ge);const Je=Gt([{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"}]),dt=Gt([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var Tt,xt,It,pt={exports:{}},Kt={exports:{}},Et={exports:{}},hi=(function(){if(It)return pt.exports;It=1;var r=(Tt||(Tt=1,Kt.exports=function(i,s){var a,u,h,f,g,y,x,b;for(u=i.length-(a=3&i.length),h=s,g=3432918353,y=461845907,b=0;b<u;)x=255&i.charCodeAt(b)|(255&i.charCodeAt(++b))<<8|(255&i.charCodeAt(++b))<<16|(255&i.charCodeAt(++b))<<24,++b,h=27492+(65535&(f=5*(65535&(h=(h^=x=(65535&(x=(x=(65535&x)*g+(((x>>>16)*g&65535)<<16)&4294967295)<<15|x>>>17))*y+(((x>>>16)*y&65535)<<16)&4294967295)<<13|h>>>19))+((5*(h>>>16)&65535)<<16)&4294967295))+((58964+(f>>>16)&65535)<<16);switch(x=0,a){case 3:x^=(255&i.charCodeAt(b+2))<<16;case 2:x^=(255&i.charCodeAt(b+1))<<8;case 1:h^=x=(65535&(x=(x=(65535&(x^=255&i.charCodeAt(b)))*g+(((x>>>16)*g&65535)<<16)&4294967295)<<15|x>>>17))*y+(((x>>>16)*y&65535)<<16)&4294967295}return h^=i.length,h=2246822507*(65535&(h^=h>>>16))+((2246822507*(h>>>16)&65535)<<16)&4294967295,h=3266489909*(65535&(h^=h>>>13))+((3266489909*(h>>>16)&65535)<<16)&4294967295,(h^=h>>>16)>>>0}),Kt.exports),e=(xt||(xt=1,Et.exports=function(i,s){for(var a,u=i.length,h=s^u,f=0;u>=4;)a=1540483477*(65535&(a=255&i.charCodeAt(f)|(255&i.charCodeAt(++f))<<8|(255&i.charCodeAt(++f))<<16|(255&i.charCodeAt(++f))<<24))+((1540483477*(a>>>16)&65535)<<16),h=1540483477*(65535&h)+((1540483477*(h>>>16)&65535)<<16)^(a=1540483477*(65535&(a^=a>>>24))+((1540483477*(a>>>16)&65535)<<16)),u-=4,++f;switch(u){case 3:h^=(255&i.charCodeAt(f+2))<<16;case 2:h^=(255&i.charCodeAt(f+1))<<8;case 1:h=1540483477*(65535&(h^=255&i.charCodeAt(f)))+((1540483477*(h>>>16)&65535)<<16)}return h=1540483477*(65535&(h^=h>>>13))+((1540483477*(h>>>16)&65535)<<16),(h^=h>>>15)>>>0}),Et.exports);return pt.exports=r,pt.exports.murmur3=r,pt.exports.murmur2=e,pt.exports})(),Ft=_t(hi);class Bt{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,i,s,a){this.ids.push(Ci(e)),this.positions.push(i,s,a)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const i=Ci(e);let s=0,a=this.ids.length-1;for(;s<a;){const h=s+a>>1;this.ids[h]>=i?a=h:s=h+1}const u=[];for(;this.ids[s]===i;)u.push({index:this.positions[3*s],start:this.positions[3*s+1],end:this.positions[3*s+2]}),s++;return u}static serialize(e,i){const s=new Float64Array(e.ids),a=new Uint32Array(e.positions);return Xr(s,a,0,s.length-1),i&&i.push(s.buffer,a.buffer),{ids:s,positions:a}}static deserialize(e){const i=new Bt;return i.ids=e.ids,i.positions=e.positions,i.indexed=!0,i}}function Ci(r){const e=+r;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:Ft(String(r))}function Xr(r,e,i,s){for(;i<s;){const a=r[i+s>>1];let u=i-1,h=s+1;for(;;){do u++;while(r[u]<a);do h--;while(r[h]>a);if(u>=h)break;Ar(r,u,h),Ar(e,3*u,3*h),Ar(e,3*u+1,3*h+1),Ar(e,3*u+2,3*h+2)}h-i<s-h?(Xr(r,e,i,h),i=h+1):(Xr(r,e,h+1,s),s=h)}}function Ar(r,e,i){const s=r[e];r[e]=r[i],r[i]=s}De("FeaturePositionMap",Bt);class Ii{constructor(e,i){this.gl=e.gl,this.location=i}}class Yr extends Ii{constructor(e,i){super(e,i),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}}class wo extends Ii{constructor(e,i){super(e,i),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 To extends Ii{constructor(e,i){super(e,i),this.current=st.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 ws=new Float32Array(16);function Fi(r){return[Re(255*r.r,255*r.g),Re(255*r.b,255*r.a)]}class lr{constructor(e,i,s){this.value=e,this.uniformNames=i.map((a=>`u_${a}`)),this.type=s}setUniform(e,i,s){e.set(s.constantOr(this.value))}getBinding(e,i,s){return this.type==="color"?new To(e,i):new Yr(e,i)}}class Wi{constructor(e,i){this.uniformNames=i.map((s=>`u_${s}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,i){this.pixelRatioFrom=i.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=i.tlbr,this.patternTo=e.tlbr}setConstantDashPositions(e,i){this.dashTo=[0,e.y,e.height,e.width],this.dashFrom=[0,i.y,i.height,i.width]}setUniform(e,i,s,a){let u=null;a==="u_pattern_to"?u=this.patternTo:a==="u_pattern_from"?u=this.patternFrom:a==="u_dasharray_to"?u=this.dashTo:a==="u_dasharray_from"?u=this.dashFrom:a==="u_pixel_ratio_to"?u=this.pixelRatioTo:a==="u_pixel_ratio_from"&&(u=this.pixelRatioFrom),u!==null&&e.set(u)}getBinding(e,i,s){return s.startsWith("u_pattern")||s.startsWith("u_dasharray_")?new wo(e,i):new Yr(e,i)}}class Xi{constructor(e,i,s,a){this.expression=e,this.type=s,this.maxValue=0,this.paintVertexAttributes=i.map((u=>({name:`a_${u}`,type:"Float32",components:s==="color"?2:1,offset:0}))),this.paintVertexArray=new a}populatePaintArray(e,i,s){const a=this.paintVertexArray.length,u=this.expression.evaluate(new vt(0,s),i,{},s.canonical,[],s.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(a,e,u)}updatePaintArray(e,i,s,a,u){const h=this.expression.evaluate(new vt(0,u),s,a);this._setPaintValue(e,i,h)}_setPaintValue(e,i,s){if(this.type==="color"){const a=Fi(s);for(let u=e;u<i;u++)this.paintVertexArray.emplace(u,a[0],a[1])}else{for(let a=e;a<i;a++)this.paintVertexArray.emplace(a,s);this.maxValue=Math.max(this.maxValue,Math.abs(s))}}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 gt{constructor(e,i,s,a,u,h){this.expression=e,this.uniformNames=i.map((f=>`u_${f}_t`)),this.type=s,this.useIntegerZoom=a,this.zoom=u,this.maxValue=0,this.paintVertexAttributes=i.map((f=>({name:`a_${f}`,type:"Float32",components:s==="color"?4:2,offset:0}))),this.paintVertexArray=new h}populatePaintArray(e,i,s){const a=this.expression.evaluate(new vt(this.zoom,s),i,{},s.canonical,[],s.formattedSection),u=this.expression.evaluate(new vt(this.zoom+1,s),i,{},s.canonical,[],s.formattedSection),h=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(h,e,a,u)}updatePaintArray(e,i,s,a,u){const h=this.expression.evaluate(new vt(this.zoom,u),s,a),f=this.expression.evaluate(new vt(this.zoom+1,u),s,a);this._setPaintValue(e,i,h,f)}_setPaintValue(e,i,s,a){if(this.type==="color"){const u=Fi(s),h=Fi(a);for(let f=e;f<i;f++)this.paintVertexArray.emplace(f,u[0],u[1],h[0],h[1])}else{for(let u=e;u<i;u++)this.paintVertexArray.emplace(u,s,a);this.maxValue=Math.max(this.maxValue,Math.abs(s),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()}setUniform(e,i){const s=this.useIntegerZoom?Math.floor(i.zoom):i.zoom,a=ir(this.expression.interpolationFactor(s,this.zoom,this.zoom+1),0,1);e.set(a)}getBinding(e,i,s){return new Yr(e,i)}}class At{constructor(e,i,s,a,u,h){this.expression=e,this.type=i,this.useIntegerZoom=s,this.zoom=a,this.layerId=h,this.zoomInPaintVertexArray=new u,this.zoomOutPaintVertexArray=new u}populatePaintArray(e,i,s){const a=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(a,e,this.getPositionIds(i),s)}updatePaintArray(e,i,s,a,u){this._setPaintValues(e,i,this.getPositionIds(s),u)}_setPaintValues(e,i,s,a){const u=this.getPositions(a);if(!u||!s)return;const h=u[s.min],f=u[s.mid],g=u[s.max];if(h&&f&&g)for(let y=e;y<i;y++)this.emplace(this.zoomInPaintVertexArray,y,f,h),this.emplace(this.zoomOutPaintVertexArray,y,f,g)}upload(e){if(this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer){const i=this.getVertexAttributes();this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,i,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,i,this.expression.isStateDependent)}}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class Yi extends At{getPositions(e){return e.imagePositions}getPositionIds(e){return e.patterns&&e.patterns[this.layerId]}getVertexAttributes(){return Je.members}emplace(e,i,s,a){e.emplace(i,s.tlbr[0],s.tlbr[1],s.tlbr[2],s.tlbr[3],a.tlbr[0],a.tlbr[1],a.tlbr[2],a.tlbr[3],s.pixelRatio,a.pixelRatio)}}class ri extends At{getPositions(e){return e.dashPositions}getPositionIds(e){return e.dashes&&e.dashes[this.layerId]}getVertexAttributes(){return dt.members}emplace(e,i,s,a){e.emplace(i,0,s.y,s.height,s.width,0,a.y,a.height,a.width)}}class Qc{constructor(e,i,s){this.binders={},this._buffers=[];const a=[];for(const u in e.paint._values){if(!s(u))continue;const h=e.paint.get(u);if(!(h instanceof yr&&ys(h.property.specification)))continue;const f=nh(u,e.type),g=h.value,y=h.property.specification.type,x=h.property.useIntegerZoom,b=h.property.specification["property-type"],S=b==="cross-faded"||b==="cross-faded-data-driven";if(g.kind==="constant")this.binders[u]=S?new Wi(g.value,f):new lr(g.value,f,y),a.push(`/u_${u}`);else if(g.kind==="source"||S){const P=eu(u,y,"source");this.binders[u]=S?u==="line-dasharray"?new ri(g,y,x,i,P,e.id):new Yi(g,y,x,i,P,e.id):new Xi(g,f,y,P),a.push(`/a_${u}`)}else{const P=eu(u,y,"composite");this.binders[u]=new gt(g,f,y,x,i,P),a.push(`/z_${u}`)}}this.cacheKey=a.sort().join("")}getMaxValue(e){const i=this.binders[e];return i instanceof Xi||i instanceof gt?i.maxValue:0}populatePaintArrays(e,i,s){for(const a in this.binders){const u=this.binders[a];(u instanceof Xi||u instanceof gt||u instanceof At)&&u.populatePaintArray(e,i,s)}}setConstantPatternPositions(e,i){for(const s in this.binders){const a=this.binders[s];a instanceof Wi&&a.setConstantPatternPositions(e,i)}}setConstantDashPositions(e,i){for(const s in this.binders){const a=this.binders[s];a instanceof Wi&&a.setConstantDashPositions(e,i)}}updatePaintArrays(e,i,s,a,u){let h=!1;for(const f in e){const g=i.getPositions(f);for(const y of g){const x=s.feature(y.index);for(const b in this.binders){const S=this.binders[b];if((S instanceof Xi||S instanceof gt||S instanceof At)&&S.expression.isStateDependent===!0){const P=a.paint.get(b);S.expression=P.value,S.updatePaintArray(y.start,y.end,x,e[f],u),h=!0}}}}return h}defines(){const e=[];for(const i in this.binders){const s=this.binders[i];(s instanceof lr||s instanceof Wi)&&e.push(...s.uniformNames.map((a=>`#define HAS_UNIFORM_${a}`)))}return e}getBinderAttributes(){const e=[];for(const i in this.binders){const s=this.binders[i];if(s instanceof Xi||s instanceof gt)for(let a=0;a<s.paintVertexAttributes.length;a++)e.push(s.paintVertexAttributes[a].name);else if(s instanceof At){const a=s.getVertexAttributes();for(const u of a)e.push(u.name)}}return e}getBinderUniforms(){const e=[];for(const i in this.binders){const s=this.binders[i];if(s instanceof lr||s instanceof Wi||s instanceof gt)for(const a of s.uniformNames)e.push(a)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,i){const s=[];for(const a in this.binders){const u=this.binders[a];if(u instanceof lr||u instanceof Wi||u instanceof gt){for(const h of u.uniformNames)if(i[h]){const f=u.getBinding(e,i[h],h);s.push({name:h,property:a,binding:f})}}}return s}setUniforms(e,i,s,a){for(const{name:u,property:h,binding:f}of i)this.binders[h].setUniform(f,a,s.get(h),u)}updatePaintBuffers(e){this._buffers=[];for(const i in this.binders){const s=this.binders[i];if(e&&s instanceof At){const a=e.fromScale===2?s.zoomInPaintVertexBuffer:s.zoomOutPaintVertexBuffer;a&&this._buffers.push(a)}else(s instanceof Xi||s instanceof gt)&&s.paintVertexBuffer&&this._buffers.push(s.paintVertexBuffer)}}upload(e){for(const i in this.binders){const s=this.binders[i];(s instanceof Xi||s instanceof gt||s instanceof At)&&s.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const i=this.binders[e];(i instanceof Xi||i instanceof gt||i instanceof At)&&i.destroy()}}}class Zn{constructor(e,i,s=()=>!0){this.programConfigurations={};for(const a of e)this.programConfigurations[a.id]=new Qc(a,i,s);this.needsUpload=!1,this._featureMap=new Bt,this._bufferOffset=0}populatePaintArrays(e,i,s,a){for(const u in this.programConfigurations)this.programConfigurations[u].populatePaintArrays(e,i,a);i.id!==void 0&&this._featureMap.add(i.id,s,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,i,s,a){for(const u of s)this.needsUpload=this.programConfigurations[u.id].updatePaintArrays(e,this._featureMap,i,u,a)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const i in this.programConfigurations)this.programConfigurations[i].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}function nh(r,e){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"]}[r]||[r.replace(`${e}-`,"").replace(/-/g,"_")]}function eu(r,e,i){const s={color:{source:vo,composite:t},number:{source:xa,composite:vo}},a=(function(u){return{"line-pattern":{source:q,composite:q},"fill-pattern":{source:q,composite:q},"fill-extrusion-pattern":{source:q,composite:q},"line-dasharray":{source:Y,composite:Y}}[u]})(r);return a&&a[i]||s[e][i]}De("ConstantBinder",lr),De("CrossFadedConstantBinder",Wi),De("SourceExpressionBinder",Xi),De("CrossFadedPatternBinder",Yi),De("CrossFadedDasharrayBinder",ri),De("CompositeExpressionBinder",gt),De("ProgramConfiguration",Qc,{omit:["_buffers"]}),De("ProgramConfigurationSet",Zn);const El=Math.pow(2,14)-1,tu=-El-1;function Ki(r){const e=ht/r.extent,i=r.loadGeometry();for(let s=0;s<i.length;s++){const a=i[s];for(let u=0;u<a.length;u++){const h=a[u],f=Math.round(h.x*e),g=Math.round(h.y*e);h.x=ir(f,tu,El),h.y=ir(g,tu,El),(f<h.x||f>h.x+1||g<h.y||g>h.y+1)&&gi("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return i}function yn(r,e){return{type:r.type,id:r.id,properties:r.properties,geometry:e?Ki(r):[]}}const Al=-32768;function iu(r,e,i,s,a){r.emplaceBack(Al+8*e+s,Al+8*i+a)}class So{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((i=>i.id)),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new N,this.indexArray=new ce,this.segments=new ge,this.programConfigurations=new Zn(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((i=>i.isStateDependent())).map((i=>i.id))}populate(e,i,s){const a=this.layers[0],u=[];let h=null,f=!1,g=a.type==="heatmap";if(a.type==="circle"){const x=a;h=x.layout.get("circle-sort-key"),f=!h.isConstant(),g=g||x.paint.get("circle-pitch-alignment")==="map"}const y=g?i.subdivisionGranularity.circle:1;for(const{feature:x,id:b,index:S,sourceLayerIndex:P}of e){const I=this.layers[0]._featureFilter.needGeometry,A=yn(x,I);if(!this.layers[0]._featureFilter.filter(new vt(this.zoom),A,s))continue;const L=f?h.evaluate(A,{},s):void 0,O={id:b,properties:x.properties,type:x.type,sourceLayerIndex:P,index:S,geometry:I?A.geometry:Ki(x),patterns:{},sortKey:L};u.push(O)}f&&u.sort(((x,b)=>x.sortKey-b.sortKey));for(const x of u){const{geometry:b,index:S,sourceLayerIndex:P}=x,I=e[S].feature;this.addFeature(x,b,S,s,y),i.featureIndex.insert(I,b,S,P,this.index)}}update(e,i,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,i,this.stateDependentLayers,{imagePositions:s})}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ie),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,i,s,a,u=1){let h;switch(u){case 1:h=[0,7];break;case 3:h=[0,2,5,7];break;case 5:h=[0,1,3,4,6,7];break;case 7:h=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${u}; valid values are 1, 3, 5, 7.`)}const f=h.length;for(const g of i)for(const y of g){const x=y.x,b=y.y;if(x<0||x>=ht||b<0||b>=ht)continue;const S=this.segments.prepareSegment(f*f,this.layoutVertexArray,this.indexArray,e.sortKey),P=S.vertexLength;for(let I=0;I<f;I++)for(let A=0;A<f;A++)iu(this.layoutVertexArray,x,b,h[A],h[I]);for(let I=0;I<f-1;I++)for(let A=0;A<f-1;A++){const L=P+I*f+A,O=P+(I+1)*f+A;this.indexArray.emplaceBack(L,O+1,L+1),this.indexArray.emplaceBack(L,O,O+1)}S.vertexLength+=f*f,S.primitiveLength+=(f-1)*(f-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,s,{imagePositions:{},canonical:a})}}function Dl(r,e){for(let i=0;i<r.length;i++)if(wa(e,r[i]))return!0;for(let i=0;i<e.length;i++)if(wa(r,e[i]))return!0;return!!sh(r,e)}function Ts(r,e,i){return!!wa(r,e)||!!oh(e,r,i)}function pd(r,e){if(r.length===1)return md(e,r[0]);for(let i=0;i<e.length;i++){const s=e[i];for(let a=0;a<s.length;a++)if(wa(r,s[a]))return!0}for(let i=0;i<r.length;i++)if(md(e,r[i]))return!0;for(let i=0;i<e.length;i++)if(sh(r,e[i]))return!0;return!1}function ym(r,e,i){if(r.length>1){if(sh(r,e))return!0;for(let s=0;s<e.length;s++)if(oh(e[s],r,i))return!0}for(let s=0;s<r.length;s++)if(oh(r[s],e,i))return!0;return!1}function sh(r,e){if(r.length===0||e.length===0)return!1;for(let i=0;i<r.length-1;i++){const s=r[i],a=r[i+1];for(let u=0;u<e.length-1;u++)if(vm(s,a,e[u],e[u+1]))return!0}return!1}function vm(r,e,i,s){return ji(r,i,s)!==ji(e,i,s)&&ji(r,e,i)!==ji(r,e,s)}function oh(r,e,i){const s=i*i;if(e.length===1)return r.distSqr(e[0])<s;for(let a=1;a<e.length;a++)if(fd(r,e[a-1],e[a])<s)return!0;return!1}function fd(r,e,i){const s=e.distSqr(i);if(s===0)return r.distSqr(e);const a=((r.x-e.x)*(i.x-e.x)+(r.y-e.y)*(i.y-e.y))/s;return r.distSqr(a<0?e:a>1?i:i.sub(e)._mult(a)._add(e))}function md(r,e){let i,s,a,u=!1;for(let h=0;h<r.length;h++){i=r[h];for(let f=0,g=i.length-1;f<i.length;g=f++)s=i[f],a=i[g],s.y>e.y!=a.y>e.y&&e.x<(a.x-s.x)*(e.y-s.y)/(a.y-s.y)+s.x&&(u=!u)}return u}function wa(r,e){let i=!1;for(let s=0,a=r.length-1;s<r.length;a=s++){const u=r[s],h=r[a];u.y>e.y!=h.y>e.y&&e.x<(h.x-u.x)*(e.y-u.y)/(h.y-u.y)+u.x&&(i=!i)}return i}function xm(r,e,i){const s=i[0],a=i[2];if(r.x<s.x&&e.x<s.x||r.x>a.x&&e.x>a.x||r.y<s.y&&e.y<s.y||r.y>a.y&&e.y>a.y)return!1;const u=ji(r,e,i[0]);return u!==ji(r,e,i[1])||u!==ji(r,e,i[2])||u!==ji(r,e,i[3])}function Ta(r,e,i){const s=e.paint.get(r).value;return s.kind==="constant"?s.value:i.programConfigurations.get(e.id).getMaxValue(r)}function ru(r){return Math.sqrt(r[0]*r[0]+r[1]*r[1])}function nu(r,e,i,s,a){if(!e[0]&&!e[1])return r;const u=Te.convert(e)._mult(a);i==="viewport"&&u._rotate(-s);const h=[];for(let f=0;f<r.length;f++)h.push(r[f].sub(u));return h}function bm(r){const e=[];for(let i=0;i<r.length;i++){const s=r[i],a=e.at(-1);(i===0||a&&!s.equals(a))&&e.push(s)}return e}function wm({queryGeometry:r,size:e},i){return Ts(r,i,e)}function Tm({queryGeometry:r,size:e,transform:i,unwrappedTileID:s,getElevation:a},u){return Ts(r,u,e*(i.projectTileCoordinates(u.x,u.y,s,a).signedDistanceFromCamera/i.cameraToCenterDistance))}function Sm({queryGeometry:r,size:e,transform:i,unwrappedTileID:s,getElevation:a},u){const h=i.projectTileCoordinates(u.x,u.y,s,a).signedDistanceFromCamera,f=e*(i.cameraToCenterDistance/h);return Ts(r,ah(u,i,s,a),f)}function Pm({queryGeometry:r,size:e,transform:i,unwrappedTileID:s,getElevation:a},u){return Ts(r,ah(u,i,s,a),e)}function gd({queryGeometry:r,size:e,transform:i,unwrappedTileID:s,getElevation:a,pitchAlignment:u="map",pitchScale:h="map"},f){const g=u==="map"?h==="map"?wm:Tm:h==="map"?Sm:Pm,y={queryGeometry:r,size:e,transform:i,unwrappedTileID:s,getElevation:a};for(const x of f)for(const b of x)if(g(y,b))return!0;return!1}function ah(r,e,i,s){const a=e.projectTileCoordinates(r.x,r.y,i,s).point;return new Te((.5*a.x+.5)*e.width,(.5*-a.y+.5)*e.height)}let _d,yd;De("CircleBucket",So,{omit:["layers"]});var Mm={get paint(){return yd=yd||new Mi({"circle-radius":new Ge(K.paint_circle["circle-radius"]),"circle-color":new Ge(K.paint_circle["circle-color"]),"circle-blur":new Ge(K.paint_circle["circle-blur"]),"circle-opacity":new Ge(K.paint_circle["circle-opacity"]),"circle-translate":new Be(K.paint_circle["circle-translate"]),"circle-translate-anchor":new Be(K.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Be(K.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Be(K.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Ge(K.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Ge(K.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Ge(K.paint_circle["circle-stroke-opacity"])})},get layout(){return _d=_d||new Mi({"circle-sort-key":new Ge(K.layout_circle["circle-sort-key"])})}};class Cm extends vr{constructor(e,i){super(e,Mm,i)}createBucket(e){return new So(e)}queryRadius(e){const i=e;return Ta("circle-radius",this,i)+Ta("circle-stroke-width",this,i)+ru(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:e,feature:i,featureState:s,geometry:a,transform:u,pixelsToTileUnits:h,unwrappedTileID:f,getElevation:g}){const y=nu(e,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-u.bearingInRadians,h),x=this.paint.get("circle-radius").evaluate(i,s)+this.paint.get("circle-stroke-width").evaluate(i,s),b=this.paint.get("circle-pitch-scale"),S=this.paint.get("circle-pitch-alignment");let P,I;return S==="map"?(P=y,I=x*h):(P=(function(A,L,O,G){return A.map((B=>ah(B,L,O,G)))})(y,u,f,g),I=x),gd({queryGeometry:P,size:I,transform:u,unwrappedTileID:f,getElevation:g,pitchAlignment:S,pitchScale:b},a)}}class vd extends So{}let xd;De("HeatmapBucket",vd,{omit:["layers"]});var Im={get paint(){return xd=xd||new Mi({"heatmap-radius":new Ge(K.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Ge(K.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Be(K.paint_heatmap["heatmap-intensity"]),"heatmap-color":new xs(K.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Be(K.paint_heatmap["heatmap-opacity"])})}};function lh(r,{width:e,height:i},s,a){if(a){if(a instanceof Uint8ClampedArray)a=new Uint8Array(a.buffer);else if(a.length!==e*i*s)throw new RangeError(`mismatched image size. expected: ${a.length} but got: ${e*i*s}`)}else a=new Uint8Array(e*i*s);return r.width=e,r.height=i,r.data=a,r}function bd(r,{width:e,height:i},s){if(e===r.width&&i===r.height)return;const a=lh({},{width:e,height:i},s);ch(r,a,{x:0,y:0},{x:0,y:0},{width:Math.min(r.width,e),height:Math.min(r.height,i)},s),r.width=e,r.height=i,r.data=a.data}function ch(r,e,i,s,a,u){if(a.width===0||a.height===0)return e;if(a.width>r.width||a.height>r.height||i.x>r.width-a.width||i.y>r.height-a.height)throw new RangeError("out of range source coordinates for image copy");if(a.width>e.width||a.height>e.height||s.x>e.width-a.width||s.y>e.height-a.height)throw new RangeError("out of range destination coordinates for image copy");const h=r.data,f=e.data;if(h===f)throw new Error("srcData equals dstData, so image is already copied");for(let g=0;g<a.height;g++){const y=((i.y+g)*r.width+i.x)*u,x=((s.y+g)*e.width+s.x)*u;for(let b=0;b<a.width*u;b++)f[x+b]=h[y+b]}return e}class zl{constructor(e,i){lh(this,e,1,i)}resize(e){bd(this,e,1)}clone(){return new zl({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,i,s,a,u){ch(e,i,s,a,u,1)}}class Ji{constructor(e,i){lh(this,e,4,i)}resize(e){bd(this,e,4)}replace(e,i){i?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new Ji({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,i,s,a,u){ch(e,i,s,a,u,4)}setPixel(e,i,s){const a=4*(e*this.width+i);this.data[a+0]=Math.round(255*s.r/s.a),this.data[a+1]=Math.round(255*s.g/s.a),this.data[a+2]=Math.round(255*s.b/s.a),this.data[a+3]=Math.round(255*s.a)}}function wd(r){const e=new Uint8Array(r.length);for(let i=0;i<r.length;i+=4){const s=r[i+3];e[i+0]=Math.round(r[i+0]*s/255),e[i+1]=Math.round(r[i+1]*s/255),e[i+2]=Math.round(r[i+2]*s/255),e[i+3]=s}return e}function Td(r){const e={},i=r.resolution||256,s=r.clips?r.clips.length:1,a=r.image||new Ji({width:i,height:s});if(Math.log(i)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${i}`);const u=(h,f,g)=>{e[r.evaluationKey]=g;const y=r.expression.evaluate(e);a.setPixel(h/4/i,f/4,y)};if(r.clips)for(let h=0,f=0;h<s;++h,f+=4*i)for(let g=0,y=0;g<i;g++,y+=4){const x=g/(i-1),{start:b,end:S}=r.clips[h];u(f,y,b*(1-x)+S*x)}else for(let h=0,f=0;h<i;h++,f+=4)u(0,f,h/(i-1));return a}De("AlphaImage",zl),De("RGBAImage",Ji);const uh="big-fb";class Em extends vr{createBucket(e){return new vd(e)}constructor(e,i){super(e,Im,i),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){e==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Td({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(uh)&&this.heatmapFbos.delete(uh)}queryRadius(e){return Ta("heatmap-radius",this,e)}queryIntersectsFeature({queryGeometry:e,feature:i,featureState:s,geometry:a,transform:u,pixelsToTileUnits:h,unwrappedTileID:f,getElevation:g}){return gd({queryGeometry:e,size:this.paint.get("heatmap-radius").evaluate(i,s)*h,transform:u,unwrappedTileID:f,getElevation:g},a)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&!this.isHidden()}}let Sd;var Am={get paint(){return Sd=Sd||new Mi({"hillshade-illumination-direction":new Be(K.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-altitude":new Be(K.paint_hillshade["hillshade-illumination-altitude"]),"hillshade-illumination-anchor":new Be(K.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Be(K.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Be(K.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Be(K.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Be(K.paint_hillshade["hillshade-accent-color"]),"hillshade-method":new Be(K.paint_hillshade["hillshade-method"])})}};class Dm extends vr{constructor(e,i){super(e,Am,i),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let e=this.paint.get("hillshade-illumination-direction").values,i=this.paint.get("hillshade-illumination-altitude").values,s=this.paint.get("hillshade-highlight-color").values,a=this.paint.get("hillshade-shadow-color").values;const u=Math.max(e.length,i.length,s.length,a.length);e=e.concat(Array(u-e.length).fill(e.at(-1))),i=i.concat(Array(u-i.length).fill(i.at(-1))),s=s.concat(Array(u-s.length).fill(s.at(-1))),a=a.concat(Array(u-a.length).fill(a.at(-1)));const h=i.map(Mn);return{directionRadians:e.map(Mn),altitudeRadians:h,shadowColor:a,highlightColor:s}}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&!this.isHidden()}}let Pd;var zm={get paint(){return Pd=Pd||new Mi({"color-relief-opacity":new Be(K["paint_color-relief"]["color-relief-opacity"]),"color-relief-color":new xs(K["paint_color-relief"]["color-relief-color"])})}};function Md(r){return"data"in r}class hh{constructor(e,i,s,a){this.context=e,this.format=s,this.texture=e.gl.createTexture(),this._ownedHandle=this.texture,this.update(i,a)}update(e,i,s){const{width:a,height:u}=e,h=!(this.size&&this.size[0]===a&&this.size[1]===u||s),{context:f}=this,{gl:g}=f;this.useMipmap=!!(i&&i.useMipmap),g.bindTexture(g.TEXTURE_2D,this.texture),f.pixelStoreUnpackFlipY.set(!1),f.pixelStoreUnpack.set(1);const y=this.format===g.RGBA&&(!i||i.premultiply!==!1);if(h)this.size=[a,u],Md(e)?(f.pixelStoreUnpackPremultiplyAlpha.set(!1),this._uploadRawData(e,y,a,u,g)):(f.pixelStoreUnpackPremultiplyAlpha.set(y),this._uploadDomImage(e,g));else{const{x,y:b}=s||{x:0,y:0};Md(e)?(f.pixelStoreUnpackPremultiplyAlpha.set(!1),this._updateRawData(e,y,x,b,a,u,g)):(f.pixelStoreUnpackPremultiplyAlpha.set(y),this._updateDomImage(e,x,b,g))}this.useMipmap&&this.isSizePowerOfTwo()&&g.generateMipmap(g.TEXTURE_2D),f.pixelStoreUnpackFlipY.setDefault(),f.pixelStoreUnpack.setDefault(),f.pixelStoreUnpackPremultiplyAlpha.setDefault()}_uploadDomImage(e,i){i.texImage2D(i.TEXTURE_2D,0,this.format,this.format,i.UNSIGNED_BYTE,e)}_uploadRawData(e,i,s,a,u){let{data:h}=e;i&&h&&(h=wd(h)),u.texImage2D(u.TEXTURE_2D,0,this.format,s,a,0,this.format,u.UNSIGNED_BYTE,h)}_updateDomImage(e,i,s,a){a.texSubImage2D(a.TEXTURE_2D,0,i,s,a.RGBA,a.UNSIGNED_BYTE,e)}_updateRawData(e,i,s,a,u,h,f){let{data:g}=e;i&&g&&(g=wd(g)),f.texSubImage2D(f.TEXTURE_2D,0,s,a,u,h,f.RGBA,f.UNSIGNED_BYTE,g)}bind(e,i,s){const{context:a}=this,{gl:u}=a;this.texture!==this._ownedHandle&&(this.texture=this._ownedHandle),u.bindTexture(u.TEXTURE_2D,this.texture),s!==u.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(s=u.LINEAR),e!==this.filter&&(u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,e),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,s||e),this.filter=e),i!==this.wrap&&(u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,i),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,i),this.wrap=i)}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,this._ownedHandle=null}}class Cd{constructor(e,i,s,a=1,u=1,h=1,f=0){if(this.uid=e,i.height!==i.width)throw new RangeError("DEM tiles must be square");if(s&&!["mapbox","terrarium","custom"].includes(s))return void gi(`"${s}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=i.height;const g=this.dim=i.height-2;switch(this.data=new Uint32Array(i.data.buffer),s){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=a,this.greenFactor=u,this.blueFactor=h,this.baseShift=f;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let y=0;y<g;y++)this.data[this._idx(-1,y)]=this.data[this._idx(0,y)],this.data[this._idx(g,y)]=this.data[this._idx(g-1,y)],this.data[this._idx(y,-1)]=this.data[this._idx(y,0)],this.data[this._idx(y,g)]=this.data[this._idx(y,g-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(g,-1)]=this.data[this._idx(g-1,0)],this.data[this._idx(-1,g)]=this.data[this._idx(0,g-1)],this.data[this._idx(g,g)]=this.data[this._idx(g-1,g-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let y=0;y<g;y++)for(let x=0;x<g;x++){const b=this.get(y,x);b>this.max&&(this.max=b),b<this.min&&(this.min=b)}}get(e,i){const s=new Uint8Array(this.data.buffer),a=4*this._idx(e,i);return this.unpack(s[a],s[a+1],s[a+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(e,i){if(e<-1||e>=this.dim+1||i<-1||i>=this.dim+1)throw new RangeError(`Out of range source coordinates for DEM data. x: ${e}, y: ${i}, dim: ${this.dim}`);return(i+1)*this.stride+(e+1)}unpack(e,i,s){return e*this.redFactor+i*this.greenFactor+s*this.blueFactor-this.baseShift}pack(e){return Id(e,this.getUnpackVector())}getPixels(){return new Ji({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,i,s){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let a=i*this.dim,u=i*this.dim+this.dim,h=s*this.dim,f=s*this.dim+this.dim;switch(i){case-1:a=u-1;break;case 1:u=a+1}switch(s){case-1:h=f-1;break;case 1:f=h+1}const g=-i*this.dim,y=-s*this.dim;for(let x=h;x<f;x++)for(let b=a;b<u;b++)this.data[this._idx(b,x)]=e.data[this._idx(b+g,x+y)]}}function Id(r,e){const i=e[0],s=e[1],a=e[2],u=e[3],h=Math.min(i,s,a),f=Math.round((r+u)/h);return{r:Math.floor(f*h/i)%256,g:Math.floor(f*h/s)%256,b:Math.floor(f*h/a)%256}}De("DEMData",Cd);class km extends vr{constructor(e,i){super(e,zm,i)}_createColorRamp(e){const i={elevationStops:[],colorStops:[]},s=this._transitionablePaint._values["color-relief-color"].value.expression;if(s instanceof na&&s._styleExpression.expression instanceof Pi){this.colorRampExpression=s;const h=s._styleExpression.expression;i.elevationStops=h.labels,i.colorStops=[];for(const f of i.elevationStops)i.colorStops.push(h.evaluate({globals:{elevation:f}}))}if(i.elevationStops.length<1&&(i.elevationStops=[0],i.colorStops=[st.transparent]),i.elevationStops.length<2&&(i.elevationStops.push(i.elevationStops[0]+1),i.colorStops.push(i.colorStops[0])),i.elevationStops.length<=e)return i;const a={elevationStops:[],colorStops:[]},u=(i.elevationStops.length-1)/(e-1);for(let h=0;h<i.elevationStops.length-.5;h+=u)a.elevationStops.push(i.elevationStops[Math.round(h)]),a.colorStops.push(i.colorStops[Math.round(h)]);return gi(`Too many colors in specification of ${this.id} color-relief layer, may not render properly. Max possible colors: ${e}, provided: ${i.elevationStops.length}`),a}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values["color-relief-color"].value.expression}getColorRampTextures(e,i,s){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;const a=this._createColorRamp(i),u=new Ji({width:a.colorStops.length,height:1}),h=new Ji({width:a.colorStops.length,height:1});for(let f=0;f<a.elevationStops.length;f++){const g=Id(a.elevationStops[f],s);h.setPixel(0,f,new st(g.r/255,g.g/255,g.b/255,1)),u.setPixel(0,f,a.colorStops[f])}return this.colorRampTextures={elevationTexture:new hh(e,h,e.gl.RGBA),colorTexture:new hh(e,u,e.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return!this.isHidden()&&!!this.colorRampTextures}}const Lm=Gt([{name:"a_pos",components:2,type:"Int16"}],4),{members:Rm}=Lm;function su(r,e,i){const s=i.patternDependencies;let a=!1;for(const u of e){const h=u.paint.get(`${r}-pattern`);h.isConstant()||(a=!0);const f=h.constantOr(null);f&&(a=!0,s[f.to]=!0,s[f.from]=!0)}return a}function dh(r,e,i,s,a){const{zoom:u}=s,h=a.patternDependencies;for(const f of e){const g=f.paint.get(`${r}-pattern`).value;if(g.kind!=="constant"){let y=g.evaluate({zoom:u-1},i,{},a.availableImages),x=g.evaluate({zoom:u},i,{},a.availableImages),b=g.evaluate({zoom:u+1},i,{},a.availableImages);y=y&&y.name?y.name:y,x=x&&x.name?x.name:x,b=b&&b.name?b.name:b,h[y]=!0,h[x]=!0,h[b]=!0,i.patterns[f.id]={min:y,mid:x,max:b}}}return i}function Ed(r,e,i,s,a){let u;if(a===(function(h,f,g,y){let x=0;for(let b=f,S=g-y;b<g;b+=y)x+=(h[S]-h[b])*(h[b+1]+h[S+1]),S=b;return x})(r,e,i,s)>0)for(let h=e;h<i;h+=s)u=kd(h/s|0,r[h],r[h+1],u);else for(let h=i-s;h>=e;h-=s)u=kd(h/s|0,r[h],r[h+1],u);return u&&Sa(u,u.next)&&(Fl(u),u=u.next),u}function Po(r,e){if(!r)return r;e||(e=r);let i,s=r;do if(i=!1,s.steiner||!Sa(s,s.next)&&Xt(s.prev,s,s.next)!==0)s=s.next;else{if(Fl(s),s=e=s.prev,s===s.next)break;i=!0}while(i||s!==e);return e}function kl(r,e,i,s,a,u,h){if(!r)return;!h&&u&&(function(g,y,x,b){let S=g;do S.z===0&&(S.z=ph(S.x,S.y,y,x,b)),S.prevZ=S.prev,S.nextZ=S.next,S=S.next;while(S!==g);S.prevZ.nextZ=null,S.prevZ=null,(function(P){let I,A=1;do{let L,O=P;P=null;let G=null;for(I=0;O;){I++;let B=O,V=0;for(let ee=0;ee<A&&(V++,B=B.nextZ,B);ee++);let W=A;for(;V>0||W>0&&B;)V!==0&&(W===0||!B||O.z<=B.z)?(L=O,O=O.nextZ,V--):(L=B,B=B.nextZ,W--),G?G.nextZ=L:P=L,L.prevZ=G,G=L;O=B}G.nextZ=null,A*=2}while(I>1)})(S)})(r,s,a,u);let f=r;for(;r.prev!==r.next;){const g=r.prev,y=r.next;if(u?Bm(r,s,a,u):Fm(r))e.push(g.i,r.i,y.i),Fl(r),r=y.next,f=y.next;else if((r=y)===f){h?h===1?kl(r=Om(Po(r),e),e,i,s,a,u,2):h===2&&Vm(r,e,i,s,a,u):kl(Po(r),e,i,s,a,u,1);break}}}function Fm(r){const e=r.prev,i=r,s=r.next;if(Xt(e,i,s)>=0)return!1;const a=e.x,u=i.x,h=s.x,f=e.y,g=i.y,y=s.y,x=Math.min(a,u,h),b=Math.min(f,g,y),S=Math.max(a,u,h),P=Math.max(f,g,y);let I=s.next;for(;I!==e;){if(I.x>=x&&I.x<=S&&I.y>=b&&I.y<=P&&Ll(a,f,u,g,h,y,I.x,I.y)&&Xt(I.prev,I,I.next)>=0)return!1;I=I.next}return!0}function Bm(r,e,i,s){const a=r.prev,u=r,h=r.next;if(Xt(a,u,h)>=0)return!1;const f=a.x,g=u.x,y=h.x,x=a.y,b=u.y,S=h.y,P=Math.min(f,g,y),I=Math.min(x,b,S),A=Math.max(f,g,y),L=Math.max(x,b,S),O=ph(P,I,e,i,s),G=ph(A,L,e,i,s);let B=r.prevZ,V=r.nextZ;for(;B&&B.z>=O&&V&&V.z<=G;){if(B.x>=P&&B.x<=A&&B.y>=I&&B.y<=L&&B!==a&&B!==h&&Ll(f,x,g,b,y,S,B.x,B.y)&&Xt(B.prev,B,B.next)>=0||(B=B.prevZ,V.x>=P&&V.x<=A&&V.y>=I&&V.y<=L&&V!==a&&V!==h&&Ll(f,x,g,b,y,S,V.x,V.y)&&Xt(V.prev,V,V.next)>=0))return!1;V=V.nextZ}for(;B&&B.z>=O;){if(B.x>=P&&B.x<=A&&B.y>=I&&B.y<=L&&B!==a&&B!==h&&Ll(f,x,g,b,y,S,B.x,B.y)&&Xt(B.prev,B,B.next)>=0)return!1;B=B.prevZ}for(;V&&V.z<=G;){if(V.x>=P&&V.x<=A&&V.y>=I&&V.y<=L&&V!==a&&V!==h&&Ll(f,x,g,b,y,S,V.x,V.y)&&Xt(V.prev,V,V.next)>=0)return!1;V=V.nextZ}return!0}function Om(r,e){let i=r;do{const s=i.prev,a=i.next.next;!Sa(s,a)&&Dd(s,i,i.next,a)&&Rl(s,a)&&Rl(a,s)&&(e.push(s.i,i.i,a.i),Fl(i),Fl(i.next),i=r=a),i=i.next}while(i!==r);return Po(i)}function Vm(r,e,i,s,a,u){let h=r;do{let f=h.next.next;for(;f!==h.prev;){if(h.i!==f.i&&qm(h,f)){let g=zd(h,f);return h=Po(h,h.next),g=Po(g,g.next),kl(h,e,i,s,a,u,0),void kl(g,e,i,s,a,u,0)}f=f.next}h=h.next}while(h!==r)}function Nm(r,e){let i=r.x-e.x;return i===0&&(i=r.y-e.y,i===0)&&(i=(r.next.y-r.y)/(r.next.x-r.x)-(e.next.y-e.y)/(e.next.x-e.x)),i}function jm(r,e){const i=(function(a,u){let h=u;const f=a.x,g=a.y;let y,x=-1/0;if(Sa(a,h))return h;do{if(Sa(a,h.next))return h.next;if(g<=h.y&&g>=h.next.y&&h.next.y!==h.y){const A=h.x+(g-h.y)*(h.next.x-h.x)/(h.next.y-h.y);if(A<=f&&A>x&&(x=A,y=h.x<h.next.x?h:h.next,A===f))return y}h=h.next}while(h!==u);if(!y)return null;const b=y,S=y.x,P=y.y;let I=1/0;h=y;do{if(f>=h.x&&h.x>=S&&f!==h.x&&Ad(g<P?f:x,g,S,P,g<P?x:f,g,h.x,h.y)){const A=Math.abs(g-h.y)/(f-h.x);Rl(h,a)&&(A<I||A===I&&(h.x>y.x||h.x===y.x&&Um(y,h)))&&(y=h,I=A)}h=h.next}while(h!==b);return y})(r,e);if(!i)return e;const s=zd(i,r);return Po(s,s.next),Po(i,i.next)}function Um(r,e){return Xt(r.prev,r,e.prev)<0&&Xt(e.next,r,r.next)<0}function ph(r,e,i,s,a){return(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=(r-i)*a|0)|r<<8))|r<<4))|r<<2))|r<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-s)*a|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Gm(r){let e=r,i=r;do(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next;while(e!==r);return i}function Ad(r,e,i,s,a,u,h,f){return(a-h)*(e-f)>=(r-h)*(u-f)&&(r-h)*(s-f)>=(i-h)*(e-f)&&(i-h)*(u-f)>=(a-h)*(s-f)}function Ll(r,e,i,s,a,u,h,f){return!(r===h&&e===f)&&Ad(r,e,i,s,a,u,h,f)}function qm(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!(function(i,s){let a=i;do{if(a.i!==i.i&&a.next.i!==i.i&&a.i!==s.i&&a.next.i!==s.i&&Dd(a,a.next,i,s))return!0;a=a.next}while(a!==i);return!1})(r,e)&&(Rl(r,e)&&Rl(e,r)&&(function(i,s){let a=i,u=!1;const h=(i.x+s.x)/2,f=(i.y+s.y)/2;do a.y>f!=a.next.y>f&&a.next.y!==a.y&&h<(a.next.x-a.x)*(f-a.y)/(a.next.y-a.y)+a.x&&(u=!u),a=a.next;while(a!==i);return u})(r,e)&&(Xt(r.prev,r,e.prev)||Xt(r,e.prev,e))||Sa(r,e)&&Xt(r.prev,r,r.next)>0&&Xt(e.prev,e,e.next)>0)}function Xt(r,e,i){return(e.y-r.y)*(i.x-e.x)-(e.x-r.x)*(i.y-e.y)}function Sa(r,e){return r.x===e.x&&r.y===e.y}function Dd(r,e,i,s){const a=au(Xt(r,e,i)),u=au(Xt(r,e,s)),h=au(Xt(i,s,r)),f=au(Xt(i,s,e));return a!==u&&h!==f||!(a!==0||!ou(r,i,e))||!(u!==0||!ou(r,s,e))||!(h!==0||!ou(i,r,s))||!(f!==0||!ou(i,e,s))}function ou(r,e,i){return e.x<=Math.max(r.x,i.x)&&e.x>=Math.min(r.x,i.x)&&e.y<=Math.max(r.y,i.y)&&e.y>=Math.min(r.y,i.y)}function au(r){return r>0?1:r<0?-1:0}function Rl(r,e){return Xt(r.prev,r,r.next)<0?Xt(r,e,r.next)>=0&&Xt(r,r.prev,e)>=0:Xt(r,e,r.prev)<0||Xt(r,r.next,e)<0}function zd(r,e){const i=fh(r.i,r.x,r.y),s=fh(e.i,e.x,e.y),a=r.next,u=e.prev;return r.next=e,e.prev=r,i.next=a,a.prev=i,s.next=i,i.prev=s,u.next=s,s.prev=u,s}function kd(r,e,i,s){const a=fh(r,e,i);return s?(a.next=s.next,a.prev=s,s.next.prev=a,s.next=a):(a.prev=a,a.next=a),a}function Fl(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function fh(r,e,i){return{i:r,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class Pa{constructor(e,i){if(i>e)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=i}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<<e)),this._minGranularity,1)}}class lu{constructor(e){this.fill=e.fill,this.line=e.line,this.tile=e.tile,this.stencil=e.stencil,this.circle=e.circle}}lu.noSubdivision=new lu({fill:new Pa(0,0),line:new Pa(0,0),tile:new Pa(0,0),stencil:new Pa(0,0),circle:1}),De("SubdivisionGranularityExpression",Pa),De("SubdivisionGranularitySetting",lu);const Ma=-32768,Bl=32767;class Zm{constructor(e,i){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=e,this._granularityCellSize=ht/e,this._canonical=i}_getKey(e,i){return(e+=32768)<<16|i+32768}_vertexToIndex(e,i){if(e<-32768||i<-32768||e>32767||i>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const s=0|Math.round(e),a=0|Math.round(i),u=this._getKey(s,a);if(this._vertexDictionary.has(u))return this._vertexDictionary.get(u);const h=this._vertexBuffer.length/2;return this._vertexDictionary.set(u,h),this._vertexBuffer.push(s,a),h}_subdivideTrianglesScanline(e){if(this._granularity<2)return(function(a,u){const h=[];for(let f=0;f<u.length;f+=3){const g=u[f],y=u[f+1],x=u[f+2],b=a[2*g],S=a[2*g+1];(a[2*y]-b)*(a[2*x+1]-S)-(a[2*y+1]-S)*(a[2*x]-b)>0?(h.push(g),h.push(x),h.push(y)):(h.push(g),h.push(y),h.push(x))}return h})(this._vertexBuffer,e);const i=[],s=e.length;for(let a=0;a<s;a+=3){const u=[e[a+0],e[a+1],e[a+2]],h=[this._vertexBuffer[2*e[a+0]+0],this._vertexBuffer[2*e[a+0]+1],this._vertexBuffer[2*e[a+1]+0],this._vertexBuffer[2*e[a+1]+1],this._vertexBuffer[2*e[a+2]+0],this._vertexBuffer[2*e[a+2]+1]];let f=1/0,g=1/0,y=-1/0,x=-1/0;for(let A=0;A<3;A++){const L=h[2*A],O=h[2*A+1];f=Math.min(f,L),y=Math.max(y,L),g=Math.min(g,O),x=Math.max(x,O)}if(f===y||g===x)continue;const b=Math.floor(f/this._granularityCellSize),S=Math.ceil(y/this._granularityCellSize),P=Math.floor(g/this._granularityCellSize),I=Math.ceil(x/this._granularityCellSize);if(b!==S||P!==I)for(let A=P;A<I;A++){const L=this._scanlineGenerateVertexRingForCellRow(A,h,u);$m(this._vertexBuffer,L,i)}else i.push(...u)}return i}_scanlineGenerateVertexRingForCellRow(e,i,s){const a=e*this._granularityCellSize,u=a+this._granularityCellSize,h=[];for(let f=0;f<3;f++){const g=i[2*f],y=i[2*f+1],x=i[2*(f+1)%6],b=i[(2*(f+1)+1)%6],S=i[2*(f+2)%6],P=i[(2*(f+2)+1)%6],I=x-g,A=b-y,L=I===0,O=A===0,G=(a-y)/A,B=(u-y)/A,V=Math.min(G,B),W=Math.max(G,B);if(!O&&(V>=1||W<=0)||O&&(y<a||y>u)){b>=a&&b<=u&&h.push(s[(f+1)%3]);continue}!O&&V>0&&h.push(this._vertexToIndex(g+I*V,y+A*V));const ee=g+I*Math.max(V,0),ae=g+I*Math.min(W,1);L||this._generateIntraEdgeVertices(h,g,y,x,b,ee,ae),!O&&W<1&&h.push(this._vertexToIndex(g+I*W,y+A*W)),(O||b>=a&&b<=u)&&h.push(s[(f+1)%3]),!O&&(b<=a||b>=u)&&this._generateInterEdgeVertices(h,g,y,x,b,S,P,ae,a,u)}return h}_generateIntraEdgeVertices(e,i,s,a,u,h,f){const g=a-i,y=u-s,x=y===0,b=x?Math.min(i,a):Math.min(h,f),S=x?Math.max(i,a):Math.max(h,f),P=Math.floor(b/this._granularityCellSize)+1,I=Math.ceil(S/this._granularityCellSize)-1;if(x?i<a:h<f)for(let A=P;A<=I;A++){const L=A*this._granularityCellSize;e.push(this._vertexToIndex(L,s+y*(L-i)/g))}else for(let A=I;A>=P;A--){const L=A*this._granularityCellSize;e.push(this._vertexToIndex(L,s+y*(L-i)/g))}}_generateInterEdgeVertices(e,i,s,a,u,h,f,g,y,x){const b=u-s,S=h-a,P=f-u,I=(y-u)/P,A=(x-u)/P,L=Math.min(I,A),O=Math.max(I,A),G=a+S*L;let B=Math.floor(Math.min(G,g)/this._granularityCellSize)+1,V=Math.ceil(Math.max(G,g)/this._granularityCellSize)-1,W=g<G;const ee=P===0;if(ee&&(f===y||f===x))return;if(ee||L>=1||O<=0){const _e=s-f,ye=h+(i-h)*Math.min((y-f)/_e,(x-f)/_e);B=Math.floor(Math.min(ye,g)/this._granularityCellSize)+1,V=Math.ceil(Math.max(ye,g)/this._granularityCellSize)-1,W=g<ye}const ae=b>0?x:y;if(W)for(let _e=B;_e<=V;_e++)e.push(this._vertexToIndex(_e*this._granularityCellSize,ae));else for(let _e=V;_e>=B;_e--)e.push(this._vertexToIndex(_e*this._granularityCellSize,ae))}_generateOutline(e){const i=[];for(const s of e){const a=Mo(s,this._granularity,!0),u=this._pointArrayToIndices(a),h=[];for(let f=1;f<u.length;f++)h.push(u[f-1]),h.push(u[f]);i.push(h)}return i}_handlePoles(e){let i=!1,s=!1;this._canonical&&(this._canonical.y===0&&(i=!0),this._canonical.y===(1<<this._canonical.z)-1&&(s=!0)),(i||s)&&this._fillPoles(e,i,s)}_ensureNoPoleVertices(){const e=this._vertexBuffer;for(let i=0;i<e.length;i+=2){const s=e[i+1];s===Ma&&(e[i+1]=-32767),s===Bl&&(e[i+1]=32766)}}_generatePoleQuad(e,i,s,a,u,h){a>u!=(h===Ma)?(e.push(i),e.push(s),e.push(this._vertexToIndex(a,h)),e.push(s),e.push(this._vertexToIndex(u,h)),e.push(this._vertexToIndex(a,h))):(e.push(s),e.push(i),e.push(this._vertexToIndex(a,h)),e.push(this._vertexToIndex(u,h)),e.push(s),e.push(this._vertexToIndex(a,h)))}_fillPoles(e,i,s){const a=this._vertexBuffer,u=ht,h=e.length;for(let f=2;f<h;f+=3){const g=e[f-2],y=e[f-1],x=e[f],b=a[2*g],S=a[2*g+1],P=a[2*y],I=a[2*y+1],A=a[2*x],L=a[2*x+1];i&&(S===0&&I===0&&this._generatePoleQuad(e,g,y,b,P,Ma),I===0&&L===0&&this._generatePoleQuad(e,y,x,P,A,Ma),L===0&&S===0&&this._generatePoleQuad(e,x,g,A,b,Ma)),s&&(S===u&&I===u&&this._generatePoleQuad(e,g,y,b,P,Bl),I===u&&L===u&&this._generatePoleQuad(e,y,x,P,A,Bl),L===u&&S===u&&this._generatePoleQuad(e,x,g,A,b,Bl))}}_initializeVertices(e){for(let i=0;i<e.length;i+=2)this._vertexToIndex(e[i],e[i+1])}subdividePolygonInternal(e,i){if(this._used)throw new Error("Subdivision: multiple use not allowed.");this._used=!0;const{flattened:s,holeIndices:a}=(function(f){const g=[],y=[];for(const x of f)if(x.length!==0){x!==f[0]&&g.push(y.length/2);for(let b=0;b<x.length;b++)y.push(x[b].x),y.push(x[b].y)}return{flattened:y,holeIndices:g}})(e);let u;this._initializeVertices(s);try{const f=(function(y,x,b=2){const S=x&&x.length,P=S?x[0]*b:y.length;let I=Ed(y,0,P,b,!0);const A=[];if(!I||I.next===I.prev)return A;let L,O,G;if(S&&(I=(function(B,V,W,ee){const ae=[];for(let _e=0,ye=V.length;_e<ye;_e++){const xe=Ed(B,V[_e]*ee,_e<ye-1?V[_e+1]*ee:B.length,ee,!1);xe===xe.next&&(xe.steiner=!0),ae.push(Gm(xe))}ae.sort(Nm);for(let _e=0;_e<ae.length;_e++)W=jm(ae[_e],W);return W})(y,x,I,b)),y.length>80*b){L=y[0],O=y[1];let B=L,V=O;for(let W=b;W<P;W+=b){const ee=y[W],ae=y[W+1];ee<L&&(L=ee),ae<O&&(O=ae),ee>B&&(B=ee),ae>V&&(V=ae)}G=Math.max(B-L,V-O),G=G!==0?32767/G:0}return kl(I,A,b,L,O,G,0),A})(s,a),g=this._convertIndices(s,f);u=this._subdivideTrianglesScanline(g)}catch(f){console.error(f)}let h=[];return i&&(h=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(u),{verticesFlattened:this._vertexBuffer,indicesTriangles:u,indicesLineList:h}}_convertIndices(e,i){const s=[];for(let a=0;a<i.length;a++)s.push(this._vertexToIndex(e[2*i[a]],e[2*i[a]+1]));return s}_pointArrayToIndices(e){const i=[];for(let s=0;s<e.length;s++){const a=e[s];i.push(this._vertexToIndex(a.x,a.y))}return i}}function Ld(r,e,i,s=!0){return new Zm(i,e).subdividePolygonInternal(r,s)}function Mo(r,e,i=!1){if(!r||r.length<1)return[];if(r.length<2)return[];const s=r[0],a=r[r.length-1],u=i&&(s.x!==a.x||s.y!==a.y);if(e<2)return u?[...r,r[0]]:[...r];const h=Math.floor(ht/e),f=[];f.push(new Te(r[0].x,r[0].y));const g=r.length,y=u?g:g-1;for(let x=0;x<y;x++){const b=r[x],S=x<g-1?r[x+1]:r[0],P=b.x,I=b.y,A=S.x,L=S.y,O=P!==A,G=I!==L;if(!O&&!G)continue;const B=A-P,V=L-I,W=Math.abs(B),ee=Math.abs(V);let ae=P,_e=I;for(;;){const xe=B>0?(Math.floor(ae/h)+1)*h:(Math.ceil(ae/h)-1)*h,Ee=V>0?(Math.floor(_e/h)+1)*h:(Math.ceil(_e/h)-1)*h,we=Math.abs(ae-xe),ve=Math.abs(_e-Ee),fe=Math.abs(ae-A),ze=Math.abs(_e-L),Le=O?we/W:Number.POSITIVE_INFINITY,Ve=G?ve/ee:Number.POSITIVE_INFINITY;if((fe<=we||!O)&&(ze<=ve||!G))break;if(Le<Ve&&O||!G){ae=xe,_e+=V*Le;const Fe=new Te(ae,Math.round(_e));f[f.length-1].x===Fe.x&&f[f.length-1].y===Fe.y||f.push(Fe)}else{ae+=B*Ve,_e=Ee;const Fe=new Te(Math.round(ae),_e);f[f.length-1].x===Fe.x&&f[f.length-1].y===Fe.y||f.push(Fe)}}const ye=new Te(A,L);f[f.length-1].x===ye.x&&f[f.length-1].y===ye.y||f.push(ye)}return f}function $m(r,e,i){if(e.length===0)throw new Error("Subdivision vertex ring is empty.");let s=0,a=r[2*e[0]];for(let g=1;g<e.length;g++){const y=r[2*e[g]];y<a&&(a=y,s=g)}const u=e.length;let h=s,f=(h+1)%u;for(;;){const g=h-1>=0?h-1:u-1,y=(f+1)%u,x=r[2*e[g]],b=r[2*e[y]],S=r[2*e[h]],P=r[2*e[h]+1],I=r[2*e[f]+1];let A=!1;if(x<b)A=!0;else if(x>b)A=!1;else{const L=I-P,O=-(r[2*e[f]]-S),G=P<I?1:-1;((x-S)*L+(r[2*e[g]+1]-P)*O)*G>((b-S)*L+(r[2*e[y]+1]-P)*O)*G&&(A=!0)}if(A){const L=e[g],O=e[h],G=e[f];L!==O&&L!==G&&O!==G&&i.push(G,O,L),h--,h<0&&(h=u-1)}else{const L=e[y],O=e[h],G=e[f];L!==O&&L!==G&&O!==G&&i.push(G,O,L),f++,f>=u&&(f=0)}if(g===y)break}}function Rd(r,e,i,s,a,u,h,f,g){const y=a.length/2,x=h&&f&&g;if(y<ge.MAX_VERTEX_ARRAY_LENGTH){const b=e.prepareSegment(y,i,s),S=b.vertexLength;for(let A=0;A<u.length;A+=3)s.emplaceBack(S+u[A],S+u[A+1],S+u[A+2]);let P,I;b.vertexLength+=y,b.primitiveLength+=u.length/3,x&&(I=h.prepareSegment(y,i,f),P=I.vertexLength,I.vertexLength+=y);for(let A=0;A<a.length;A+=2)r(a[A],a[A+1]);if(x)for(let A=0;A<g.length;A++){const L=g[A];for(let O=1;O<L.length;O+=2)f.emplaceBack(P+L[O-1],P+L[O]);I.primitiveLength+=L.length/2}}else(function(b,S,P,I,A,L){const O=[];for(let ee=0;ee<I.length/2;ee++)O.push(-1);const G={count:0};let B=0,V=b.getOrCreateLatestSegment(S,P),W=V.vertexLength;for(let ee=2;ee<A.length;ee+=3){const ae=A[ee-2],_e=A[ee-1],ye=A[ee];let xe=O[ae]<B,Ee=O[_e]<B,we=O[ye]<B;V.vertexLength+((xe?1:0)+(Ee?1:0)+(we?1:0))>ge.MAX_VERTEX_ARRAY_LENGTH&&(V=b.createNewSegment(S,P),B=G.count,xe=!0,Ee=!0,we=!0,W=0);const ve=Ol(O,I,L,G,ae,xe,V),fe=Ol(O,I,L,G,_e,Ee,V),ze=Ol(O,I,L,G,ye,we,V);P.emplaceBack(W+ve-B,W+fe-B,W+ze-B),V.primitiveLength++}})(e,i,s,a,u,r),x&&(function(b,S,P,I,A,L){const O=[];for(let ee=0;ee<I.length/2;ee++)O.push(-1);const G={count:0};let B=0,V=b.getOrCreateLatestSegment(S,P),W=V.vertexLength;for(let ee=0;ee<A.length;ee++){const ae=A[ee];for(let _e=1;_e<A[ee].length;_e+=2){const ye=ae[_e-1],xe=ae[_e];let Ee=O[ye]<B,we=O[xe]<B;V.vertexLength+((Ee?1:0)+(we?1:0))>ge.MAX_VERTEX_ARRAY_LENGTH&&(V=b.createNewSegment(S,P),B=G.count,Ee=!0,we=!0,W=0);const ve=Ol(O,I,L,G,ye,Ee,V),fe=Ol(O,I,L,G,xe,we,V);P.emplaceBack(W+ve-B,W+fe-B),V.primitiveLength++}}})(h,i,f,a,g,r),e.forceNewSegmentOnNextPrepare(),h?.forceNewSegmentOnNextPrepare()}function Ol(r,e,i,s,a,u,h){if(u){const f=s.count;return i(e[2*a],e[2*a+1]),r[a]=s.count,s.count++,h.vertexLength++,f}return r[a]}class mh{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((i=>i.id)),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new U,this.indexArray=new ce,this.indexArray2=new he,this.programConfigurations=new Zn(e.layers,e.zoom),this.segments=new ge,this.segments2=new ge,this.stateDependentLayerIds=this.layers.filter((i=>i.isStateDependent())).map((i=>i.id))}populate(e,i,s){this.hasDependencies=su("fill",this.layers,i);const a=this.layers[0].layout.get("fill-sort-key"),u=!a.isConstant(),h=[];for(const{feature:f,id:g,index:y,sourceLayerIndex:x}of e){const b=this.layers[0]._featureFilter.needGeometry,S=yn(f,b);if(!this.layers[0]._featureFilter.filter(new vt(this.zoom),S,s))continue;const P=u?a.evaluate(S,{},s,i.availableImages):void 0,I={id:g,properties:f.properties,type:f.type,sourceLayerIndex:x,index:y,geometry:b?S.geometry:Ki(f),patterns:{},sortKey:P};h.push(I)}u&&h.sort(((f,g)=>f.sortKey-g.sortKey));for(const f of h){const{geometry:g,index:y,sourceLayerIndex:x}=f;if(this.hasDependencies){const b=dh("fill",this.layers,f,{zoom:this.zoom},i);this.patternFeatures.push(b)}else this.addFeature(f,g,y,s,{},i.subdivisionGranularity);i.featureIndex.insert(e[y].feature,g,y,x,this.index)}}update(e,i,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,i,this.stateDependentLayers,{imagePositions:s})}addFeatures(e,i,s){for(const a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,i,s,e.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Rm),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,i,s,a,u,h){for(const f of Ys(i,500)){const g=Ld(f,a,h.fill.getGranularityForZoomLevel(a.z)),y=this.layoutVertexArray;Rd(((x,b)=>{y.emplaceBack(x,b)}),this.segments,this.layoutVertexArray,this.indexArray,g.verticesFlattened,g.indicesTriangles,this.segments2,this.indexArray2,g.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,s,{imagePositions:u,canonical:a})}}let Fd,Bd;De("FillBucket",mh,{omit:["layers","patternFeatures"]});var Hm={get paint(){return Bd=Bd||new Mi({"fill-antialias":new Be(K.paint_fill["fill-antialias"]),"fill-opacity":new Ge(K.paint_fill["fill-opacity"]),"fill-color":new Ge(K.paint_fill["fill-color"]),"fill-outline-color":new Ge(K.paint_fill["fill-outline-color"]),"fill-translate":new Be(K.paint_fill["fill-translate"]),"fill-translate-anchor":new Be(K.paint_fill["fill-translate-anchor"]),"fill-pattern":new _n(K.paint_fill["fill-pattern"])})},get layout(){return Fd=Fd||new Mi({"fill-sort-key":new Ge(K.layout_fill["fill-sort-key"])})}};class Wm extends vr{constructor(e,i){super(e,Hm,i)}recalculate(e,i){super.recalculate(e,i);const s=this.paint._values["fill-outline-color"];s.value.kind==="constant"&&s.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new mh(e)}queryRadius(){return ru(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:i,transform:s,pixelsToTileUnits:a}){return pd(nu(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-s.bearingInRadians,a),i)}isTileClipped(){return!0}}const Xm=Gt([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Ym=Gt([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Km}=Xm;class Vl{constructor(e,i,s,a,u){this.properties={},this.extent=s,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=a,this._values=u,e.readFields(Jm,this,i)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const i=e.readVarint()+e.pos,s=[];let a,u=1,h=0,f=0,g=0;for(;e.pos<i;){if(h<=0){const y=e.readVarint();u=7&y,h=y>>3}if(h--,u===1||u===2)f+=e.readSVarint(),g+=e.readSVarint(),u===1&&(a&&s.push(a),a=[]),a&&a.push(new Te(f,g));else{if(u!==7)throw new Error(`unknown command ${u}`);a&&a.push(a[0].clone())}}return a&&s.push(a),s}bbox(){const e=this._pbf;e.pos=this._geometry;const i=e.readVarint()+e.pos;let s=1,a=0,u=0,h=0,f=1/0,g=-1/0,y=1/0,x=-1/0;for(;e.pos<i;){if(a<=0){const b=e.readVarint();s=7&b,a=b>>3}if(a--,s===1||s===2)u+=e.readSVarint(),h+=e.readSVarint(),u<f&&(f=u),u>g&&(g=u),h<y&&(y=h),h>x&&(x=h);else if(s!==7)throw new Error(`unknown command ${s}`)}return[f,y,g,x]}toGeoJSON(e,i,s){const a=this.extent*Math.pow(2,s),u=this.extent*e,h=this.extent*i,f=this.loadGeometry();function g(S){return[360*(S.x+u)/a-180,360/Math.PI*Math.atan(Math.exp((1-2*(S.y+h)/a)*Math.PI))-90]}function y(S){return S.map(g)}let x;if(this.type===1){const S=[];for(const I of f)S.push(I[0]);const P=y(S);x=S.length===1?{type:"Point",coordinates:P[0]}:{type:"MultiPoint",coordinates:P}}else if(this.type===2){const S=f.map(y);x=S.length===1?{type:"LineString",coordinates:S[0]}:{type:"MultiLineString",coordinates:S}}else{if(this.type!==3)throw new Error("unknown feature type");{const S=Od(f),P=[];for(const I of S)P.push(I.map(y));x=P.length===1?{type:"Polygon",coordinates:P[0]}:{type:"MultiPolygon",coordinates:P}}}const b={type:"Feature",geometry:x,properties:this.properties};return this.id!=null&&(b.id=this.id),b}}function Jm(r,e,i){r===1?e.id=i.readVarint():r===2?(function(s,a){const u=s.readVarint()+s.pos;for(;s.pos<u;){const h=a._keys[s.readVarint()],f=a._values[s.readVarint()];a.properties[h]=f}})(i,e):r===3?e.type=i.readVarint():r===4&&(e._geometry=i.pos)}function Od(r){const e=r.length;if(e<=1)return[r];const i=[];let s,a;for(let u=0;u<e;u++){const h=Qm(r[u]);h!==0&&(a===void 0&&(a=h<0),a===h<0?(s&&i.push(s),s=[r[u]]):s&&s.push(r[u]))}return s&&i.push(s),i}function Qm(r){let e=0;for(let i,s,a=0,u=r.length,h=u-1;a<u;h=a++)i=r[a],s=r[h],e+=(s.x-i.x)*(i.y+s.y);return e}Vl.types=["Unknown","Point","LineString","Polygon"];class eg{constructor(e,i){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(tg,this,i),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 i=this._pbf.readVarint()+this._pbf.pos;return new Vl(this._pbf,i,this.extent,this._keys,this._values)}}function tg(r,e,i){r===15?e.version=i.readVarint():r===1?e.name=i.readString():r===5?e.extent=i.readVarint():r===2?e._features.push(i.pos):r===3?e._keys.push(i.readString()):r===4&&e._values.push((function(s){let a=null;const u=s.readVarint()+s.pos;for(;s.pos<u;){const h=s.readVarint()>>3;a=h===1?s.readString():h===2?s.readFloat():h===3?s.readDouble():h===4?s.readVarint64():h===5?s.readVarint():h===6?s.readSVarint():h===7?s.readBoolean():null}if(a==null)throw new Error("unknown feature value");return a})(i))}class Vd{constructor(e,i){this.layers=e.readFields(ig,{},i)}}function ig(r,e,i){if(r===3){const s=new eg(i,i.readVarint()+i.pos);s.length&&(e[s.name]=s)}}const gh=Math.pow(2,13);function Nl(r,e,i,s,a,u,h,f){r.emplaceBack(e,i,2*Math.floor(s*gh)+h,a*gh*2,u*gh*2,Math.round(f))}class _h{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((i=>i.id)),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new j,this.centroidVertexArray=new R,this.indexArray=new ce,this.programConfigurations=new Zn(e.layers,e.zoom),this.segments=new ge,this.stateDependentLayerIds=this.layers.filter((i=>i.isStateDependent())).map((i=>i.id))}populate(e,i,s){this.features=[],this.hasDependencies=su("fill-extrusion",this.layers,i);for(const{feature:a,id:u,index:h,sourceLayerIndex:f}of e){const g=this.layers[0]._featureFilter.needGeometry,y=yn(a,g);if(!this.layers[0]._featureFilter.filter(new vt(this.zoom),y,s))continue;const x={id:u,sourceLayerIndex:f,index:h,geometry:g?y.geometry:Ki(a),properties:a.properties,type:a.type,patterns:{}};this.hasDependencies?this.features.push(dh("fill-extrusion",this.layers,x,{zoom:this.zoom},i)):this.addFeature(x,x.geometry,h,s,{},i.subdivisionGranularity),i.featureIndex.insert(a,x.geometry,h,f,this.index,!0)}}addFeatures(e,i,s){for(const a of this.features){const{geometry:u}=a;this.addFeature(a,u,a.index,i,s,e.subdivisionGranularity)}}update(e,i,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,i,this.stateDependentLayers,{imagePositions:s})}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Km),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Ym.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,i,s,a,u,h){for(const f of Ys(i,500)){const g={x:0,y:0,sampleCount:0},y=this.layoutVertexArray.length;this.processPolygon(g,a,e,f,h);const x=this.layoutVertexArray.length-y,b=Math.floor(g.x/g.sampleCount),S=Math.floor(g.y/g.sampleCount);for(let P=0;P<x;P++)this.centroidVertexArray.emplaceBack(b,S)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,s,{imagePositions:u,canonical:a})}processPolygon(e,i,s,a,u){if(a.length<1||Nd(a[0]))return;for(const b of a)b.length!==0&&rg(e,b);const h={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},f=u.fill.getGranularityForZoomLevel(i.z),g=Vl.types[s.type]==="Polygon";for(const b of a){if(b.length===0||Nd(b))continue;const S=Mo(b,f,g);this._generateSideFaces(S,h)}if(!g)return;const y=Ld(a,i,f,!1),x=this.layoutVertexArray;Rd(((b,S)=>{Nl(x,b,S,0,0,1,1,0)}),this.segments,this.layoutVertexArray,this.indexArray,y.verticesFlattened,y.indicesTriangles)}_generateSideFaces(e,i){let s=0;for(let a=1;a<e.length;a++){const u=e[a],h=e[a-1];if(ng(u,h))continue;i.segment.vertexLength+4>ge.MAX_VERTEX_ARRAY_LENGTH&&(i.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const f=u.sub(h)._perp()._unit(),g=h.dist(u);s+g>32768&&(s=0),Nl(this.layoutVertexArray,u.x,u.y,f.x,f.y,0,0,s),Nl(this.layoutVertexArray,u.x,u.y,f.x,f.y,0,1,s),s+=g,Nl(this.layoutVertexArray,h.x,h.y,f.x,f.y,0,0,s),Nl(this.layoutVertexArray,h.x,h.y,f.x,f.y,0,1,s);const y=i.segment.vertexLength;this.indexArray.emplaceBack(y,y+2,y+1),this.indexArray.emplaceBack(y+1,y+2,y+3),i.segment.vertexLength+=4,i.segment.primitiveLength+=2}}}function rg(r,e){for(let i=0;i<e.length;i++){const s=e[i];i===e.length-1&&e[0].x===s.x&&e[0].y===s.y||(r.x+=s.x,r.y+=s.y,r.sampleCount++)}}function ng(r,e){return r.x===e.x&&(r.x<0||r.x>ht)||r.y===e.y&&(r.y<0||r.y>ht)}function Nd(r){return r.every((e=>e.x<0))||r.every((e=>e.x>ht))||r.every((e=>e.y<0))||r.every((e=>e.y>ht))}let jd;De("FillExtrusionBucket",_h,{omit:["layers","features"]});var sg={get paint(){return jd=jd||new Mi({"fill-extrusion-opacity":new Be(K["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Ge(K["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Be(K["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Be(K["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new _n(K["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Ge(K["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Ge(K["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Be(K["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class og extends vr{constructor(e,i){super(e,sg,i)}createBucket(e){return new _h(e)}queryRadius(){return ru(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:i,featureState:s,geometry:a,transform:u,pixelsToTileUnits:h,pixelPosMatrix:f}){const g=nu(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-u.bearingInRadians,h),y=this.paint.get("fill-extrusion-height").evaluate(i,s),x=this.paint.get("fill-extrusion-base").evaluate(i,s),b=(function(P,I){const A=[];for(const L of P){const O=[L.x,L.y,0,1];sn(O,O,I),A.push(new Te(O[0]/O[3],O[1]/O[3]))}return A})(g,f),S=(function(P,I,A,L){const O=[],G=[],B=L[8]*I,V=L[9]*I,W=L[10]*I,ee=L[11]*I,ae=L[8]*A,_e=L[9]*A,ye=L[10]*A,xe=L[11]*A;for(const Ee of P){const we=[],ve=[];for(const fe of Ee){const ze=fe.x,Le=fe.y,Ve=L[0]*ze+L[4]*Le+L[12],Fe=L[1]*ze+L[5]*Le+L[13],it=L[2]*ze+L[6]*Le+L[14],Dt=L[3]*ze+L[7]*Le+L[15],Jt=it+W,bi=Dt+ee,Dr=Ve+ae,Vi=Fe+_e,di=it+ye,wi=Dt+xe,Zt=new Te((Ve+B)/bi,(Fe+V)/bi);Zt.z=Jt/bi,we.push(Zt);const pi=new Te(Dr/wi,Vi/wi);pi.z=di/wi,ve.push(pi)}O.push(we),G.push(ve)}return[O,G]})(a,x,y,f);return(function(P,I,A){let L=1/0;pd(A,I)&&(L=Ud(A,I[0]));for(let O=0;O<I.length;O++){const G=I[O],B=P[O];for(let V=0;V<G.length-1;V++){const W=G[V],ee=[W,G[V+1],B[V+1],B[V],W];Dl(A,ee)&&(L=Math.min(L,Ud(A,ee)))}}return L!==1/0&&L})(S[0],S[1],b)}}function jl(r,e){return r.x*e.x+r.y*e.y}function Ud(r,e){if(r.length===1){let i=0;const s=e[i++];let a;for(;!a||s.equals(a);)if(a=e[i++],!a)return 1/0;for(;i<e.length;i++){const u=e[i],h=r[0],f=a.sub(s),g=u.sub(s),y=h.sub(s),x=jl(f,f),b=jl(f,g),S=jl(g,g),P=jl(y,f),I=jl(y,g),A=x*S-b*b,L=(S*P-b*I)/A,O=(x*I-b*P)/A,G=s.z*(1-L-O)+a.z*L+u.z*O;if(isFinite(G))return G}return 1/0}{let i=1/0;for(const s of e)i=Math.min(i,s.z);return i}}const ag=Gt([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:lg}=ag,cg=Gt([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:ug}=cg,hg=Math.cos(Math.PI/180*37.5),Gd=Math.pow(2,14)/.5;class yh{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((i=>i.id)),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((i=>{this.gradients[i.id]={}})),this.layoutVertexArray=new Z,this.layoutVertexArray2=new X,this.indexArray=new ce,this.programConfigurations=new Zn(e.layers,e.zoom),this.segments=new ge,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((i=>i.isStateDependent())).map((i=>i.id))}populate(e,i,s){this.hasDependencies=su("line",this.layers,i)||this.hasLineDasharray(this.layers);const a=this.layers[0].layout.get("line-sort-key"),u=!a.isConstant(),h=[];for(const{feature:f,id:g,index:y,sourceLayerIndex:x}of e){const b=this.layers[0]._featureFilter.needGeometry,S=yn(f,b);if(!this.layers[0]._featureFilter.filter(new vt(this.zoom),S,s))continue;const P=u?a.evaluate(S,{},s):void 0,I={id:g,properties:f.properties,type:f.type,sourceLayerIndex:x,index:y,geometry:b?S.geometry:Ki(f),patterns:{},dashes:{},sortKey:P};h.push(I)}u&&h.sort(((f,g)=>f.sortKey-g.sortKey));for(const f of h){const{geometry:g,index:y,sourceLayerIndex:x}=f;this.hasDependencies?(su("line",this.layers,i)?dh("line",this.layers,f,{zoom:this.zoom},i):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,f,this.zoom,i),this.patternFeatures.push(f)):this.addFeature(f,g,y,s,{},{},i.subdivisionGranularity),i.featureIndex.insert(e[y].feature,g,y,x,this.index)}}update(e,i,s,a){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,i,this.stateDependentLayers,{imagePositions:s,dashPositions:a})}addFeatures(e,i,s,a){for(const u of this.patternFeatures)this.addFeature(u,u.geometry,u.index,i,s,a,e.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,ug)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,lg),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,i,s,a,u,h,f){const g=this.layers[0].layout,y=g.get("line-join").evaluate(e,{}),x=g.get("line-cap"),b=g.get("line-miter-limit"),S=g.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const P of i)this.addLine(P,e,y,x,b,S,a,f);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,s,{imagePositions:u,dashPositions:h,canonical:a})}addLine(e,i,s,a,u,h,f,g){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=Mo(e,f?g.line.getGranularityForZoomLevel(f.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let B=0;B<e.length-1;B++)this.totalDistance+=e[B].dist(e[B+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const y=Vl.types[i.type]==="Polygon";let x=e.length;for(;x>=2&&e[x-1].equals(e[x-2]);)x--;let b=0;for(;b<x-1&&e[b].equals(e[b+1]);)b++;if(x<(y?3:2))return;s==="bevel"&&(u=1.05);const S=this.overscaling<=16?122880/(512*this.overscaling):0,P=this.segments.prepareSegment(10*x,this.layoutVertexArray,this.indexArray);let I,A,L,O,G;this.e1=this.e2=-1,y&&(I=e[x-2],G=e[b].sub(I)._unit()._perp());for(let B=b;B<x;B++){if(L=B===x-1?y?e[b+1]:void 0:e[B+1],L&&e[B].equals(L))continue;G&&(O=G),I&&(A=I),I=e[B],G=L?L.sub(I)._unit()._perp():O,O=O||G;let V=O.add(G);V.x===0&&V.y===0||V._unit();const W=O.x*G.x+O.y*G.y,ee=V.x*G.x+V.y*G.y,ae=ee!==0?1/ee:1/0,_e=2*Math.sqrt(2-2*ee),ye=ee<hg&&A&&L,xe=O.x*G.y-O.y*G.x>0;if(ye&&B>b){const ve=I.dist(A);if(ve>2*S){const fe=I.sub(I.sub(A)._mult(S/ve)._round());this.updateDistance(A,fe),this.addCurrentVertex(fe,O,0,0,P),A=fe}}const Ee=A&&L;let we=Ee?s:y?"butt":a;if(Ee&&we==="round"&&(ae<h?we="miter":ae<=2&&(we="fakeround")),we==="miter"&&ae>u&&(we="bevel"),we==="bevel"&&(ae>2&&(we="flipbevel"),ae<u&&(we="miter")),A&&this.updateDistance(A,I),we==="miter")V._mult(ae),this.addCurrentVertex(I,V,0,0,P);else if(we==="flipbevel"){if(ae>100)V=G.mult(-1);else{const ve=ae*O.add(G).mag()/O.sub(G).mag();V._perp()._mult(ve*(xe?-1:1))}this.addCurrentVertex(I,V,0,0,P),this.addCurrentVertex(I,V.mult(-1),0,0,P)}else if(we==="bevel"||we==="fakeround"){const ve=-Math.sqrt(ae*ae-1),fe=xe?ve:0,ze=xe?0:ve;if(A&&this.addCurrentVertex(I,O,fe,ze,P),we==="fakeround"){const Le=Math.round(180*_e/Math.PI/20);for(let Ve=1;Ve<Le;Ve++){let Fe=Ve/Le;if(Fe!==.5){const Dt=Fe-.5;Fe+=Fe*Dt*(Fe-1)*((1.0904+W*(W*(3.55645-1.43519*W)-3.2452))*Dt*Dt+(.848013+W*(.215638*W-1.06021)))}const it=G.sub(O)._mult(Fe)._add(O)._unit()._mult(xe?-1:1);this.addHalfVertex(I,it.x,it.y,!1,xe,0,P)}}L&&this.addCurrentVertex(I,G,-fe,-ze,P)}else if(we==="butt")this.addCurrentVertex(I,V,0,0,P);else if(we==="square"){const ve=A?1:-1;this.addCurrentVertex(I,V,ve,ve,P)}else we==="round"&&(A&&(this.addCurrentVertex(I,O,0,0,P),this.addCurrentVertex(I,O,1,1,P,!0)),L&&(this.addCurrentVertex(I,G,-1,-1,P,!0),this.addCurrentVertex(I,G,0,0,P)));if(ye&&B<x-1){const ve=I.dist(L);if(ve>2*S){const fe=I.add(L.sub(I)._mult(S/ve)._round());this.updateDistance(I,fe),this.addCurrentVertex(fe,G,0,0,P),I=fe}}}}addCurrentVertex(e,i,s,a,u,h=!1){const f=i.y*a-i.x,g=-i.y-i.x*a;this.addHalfVertex(e,i.x+i.y*s,i.y-i.x*s,h,!1,s,u),this.addHalfVertex(e,f,g,h,!0,-a,u),this.distance>Gd/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,i,s,a,u,h))}addHalfVertex({x:e,y:i},s,a,u,h,f,g){const y=.5*(this.lineClips?this.scaledDistance*(Gd-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(u?1:0),(i<<1)+(h?1:0),Math.round(63*s)+128,Math.round(63*a)+128,1+(f===0?0:f<0?-1:1)|(63&y)<<2,y>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const x=g.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,x,this.e2),g.primitiveLength++),h?this.e2=x:this.e1=x}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,i){this.distance+=e.dist(i),this.updateScaledDistance()}hasLineDasharray(e){for(const i of e){const s=i.paint.get("line-dasharray");if(s&&!s.isConstant())return!0}return!1}addLineDashDependencies(e,i,s,a){for(const u of e){const h=u.paint.get("line-dasharray");if(!h||h.value.kind==="constant")continue;const f=u.layout.get("line-cap")==="round",g={dasharray:h.value.evaluate({zoom:s-1},i,{}),round:f},y={dasharray:h.value.evaluate({zoom:s},i,{}),round:f},x={dasharray:h.value.evaluate({zoom:s+1},i,{}),round:f},b=`${g.dasharray.join(",")},${g.round}`,S=`${y.dasharray.join(",")},${y.round}`,P=`${x.dasharray.join(",")},${x.round}`;a.dashDependencies[b]=g,a.dashDependencies[S]=y,a.dashDependencies[P]=x,i.dashes[u.id]={min:b,mid:S,max:P}}}}let qd,Zd;De("LineBucket",yh,{omit:["layers","patternFeatures"]});var $d={get paint(){return Zd=Zd||new Mi({"line-opacity":new Ge(K.paint_line["line-opacity"]),"line-color":new Ge(K.paint_line["line-color"]),"line-translate":new Be(K.paint_line["line-translate"]),"line-translate-anchor":new Be(K.paint_line["line-translate-anchor"]),"line-width":new Ge(K.paint_line["line-width"]),"line-gap-width":new Ge(K.paint_line["line-gap-width"]),"line-offset":new Ge(K.paint_line["line-offset"]),"line-blur":new Ge(K.paint_line["line-blur"]),"line-dasharray":new _n(K.paint_line["line-dasharray"]),"line-pattern":new _n(K.paint_line["line-pattern"]),"line-gradient":new xs(K.paint_line["line-gradient"])})},get layout(){return qd=qd||new Mi({"line-cap":new Be(K.layout_line["line-cap"]),"line-join":new Ge(K.layout_line["line-join"]),"line-miter-limit":new Be(K.layout_line["line-miter-limit"]),"line-round-limit":new Be(K.layout_line["line-round-limit"]),"line-sort-key":new Ge(K.layout_line["line-sort-key"])})}};class dg extends Ge{possiblyEvaluate(e,i){return i=new vt(Math.floor(i.zoom),{now:i.now,fadeDuration:i.fadeDuration,zoomHistory:i.zoomHistory,transition:i.transition}),super.possiblyEvaluate(e,i)}evaluate(e,i,s,a){return i=ki({},i,{zoom:Math.floor(i.zoom)}),super.evaluate(e,i,s,a)}}let cu;class pg extends vr{constructor(e,i){super(e,$d,i),this.gradientVersion=0,cu||(cu=new dg($d.paint.properties["line-width"].specification),cu.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if(e==="line-gradient"){const i=this.gradientExpression();this.stepInterpolant=!!(function(s){return s._styleExpression!==void 0})(i)&&i._styleExpression.expression instanceof Ln,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,i){super.recalculate(e,i),this.paint._values["line-floorwidth"]=cu.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new yh(e)}queryRadius(e){const i=e,s=Hd(Ta("line-width",this,i),Ta("line-gap-width",this,i)),a=Ta("line-offset",this,i);return s/2+Math.abs(a)+ru(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:i,featureState:s,geometry:a,transform:u,pixelsToTileUnits:h}){const f=nu(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-u.bearingInRadians,h),g=h/2*Hd(this.paint.get("line-width").evaluate(i,s),this.paint.get("line-gap-width").evaluate(i,s)),y=this.paint.get("line-offset").evaluate(i,s);return y&&(a=(function(x,b){const S=[];for(let P=0;P<x.length;P++){const I=bm(x[P]),A=[];for(let L=0;L<I.length;L++){const O=I[L],G=I[L-1],B=I[L+1],V=L===0?new Te(0,0):O.sub(G)._unit()._perp(),W=L===I.length-1?new Te(0,0):B.sub(O)._unit()._perp(),ee=V._add(W)._unit(),ae=ee.x*W.x+ee.y*W.y;ae!==0&&ee._mult(1/ae),A.push(ee._mult(b)._add(O))}S.push(A)}return S})(a,y*h)),(function(x,b,S){for(let P=0;P<b.length;P++){const I=b[P];if(x.length>=3){for(let A=0;A<I.length;A++)if(wa(x,I[A]))return!0}if(ym(x,I,S))return!0}return!1})(f,a,g)}isTileClipped(){return!0}}function Hd(r,e){return e>0?e+2*r:r}const fg=Gt([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),mg=Gt([{name:"a_projected_pos",components:3,type:"Float32"}],4);Gt([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const gg=Gt([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Gt([{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 Wd=Gt([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),_g=Gt([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function yg(r,e,i){return r.sections.forEach((s=>{s.text=(function(a,u,h){const f=u.layout.get("text-transform").evaluate(h,{});return f==="uppercase"?a=a.toLocaleUpperCase():f==="lowercase"&&(a=a.toLocaleLowerCase()),Hr.applyArabicShaping&&(a=Hr.applyArabicShaping(a)),a})(s.text,e,i)})),r}Gt([{name:"triangle",components:3,type:"Uint16"}]),Gt([{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"}]),Gt([{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"}]),Gt([{type:"Float32",name:"offsetX"}]),Gt([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Gt([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);var si=24;const Ul={"!":"\uFE15","#":"\uFF03",$:"\uFF04","%":"\uFF05","&":"\uFF06","(":"\uFE35",")":"\uFE36","*":"\uFF0A","+":"\uFF0B",",":"\uFE10","-":"\uFE32",".":"\u30FB","/":"\uFF0F",":":"\uFE13",";":"\uFE14","<":"\uFE3F","=":"\uFF1D",">":"\uFE40","?":"\uFE16","@":"\uFF20","[":"\uFE47","\\":"\uFF3C","]":"\uFE48","^":"\uFF3E",_:"\uFE33","`":"\uFF40","{":"\uFE37","|":"\u2015","}":"\uFE38","~":"\uFF5E","\xA2":"\uFFE0","\xA3":"\uFFE1","\xA5":"\uFFE5","\xA6":"\uFFE4","\xAC":"\uFFE2","\xAF":"\uFFE3","\u2013":"\uFE32","\u2014":"\uFE31","\u2018":"\uFE43","\u2019":"\uFE44","\u201C":"\uFE41","\u201D":"\uFE42","\u2026":"\uFE19","\u22EF":"\uFE19","\u2027":"\u30FB","\u20A9":"\uFFE6","\u3001":"\uFE11","\u3002":"\uFE12","\u3008":"\uFE3F","\u3009":"\uFE40","\u300A":"\uFE3D","\u300B":"\uFE3E","\u300C":"\uFE41","\u300D":"\uFE42","\u300E":"\uFE43","\u300F":"\uFE44","\u3010":"\uFE3B","\u3011":"\uFE3C","\u3014":"\uFE39","\u3015":"\uFE3A","\u3016":"\uFE17","\u3017":"\uFE18","\uFF01":"\uFE15","\uFF08":"\uFE35","\uFF09":"\uFE36","\uFF0C":"\uFE10","\uFF0D":"\uFE32","\uFF0E":"\u30FB","\uFF1A":"\uFE13","\uFF1B":"\uFE14","\uFF1C":"\uFE3F","\uFF1E":"\uFE40","\uFF1F":"\uFE16","\uFF3B":"\uFE47","\uFF3D":"\uFE48","\uFF3F":"\uFE33","\uFF5B":"\uFE37","\uFF5C":"\u2015","\uFF5D":"\uFE38","\uFF5F":"\uFE35","\uFF60":"\uFE36","\uFF61":"\uFE12","\uFF62":"\uFE41","\uFF63":"\uFE42"},vg={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},xg={40:!0};function Xd(r,e,i,s,a,u){if("fontStack"in e){const h=i[e.fontStack],f=h&&h[r];return f?f.metrics.advance*e.scale+a:0}{const h=s[e.imageName];return h?h.displaySize[0]*e.scale*si/u+a:0}}function Yd(r,e,i,s){const a=Math.pow(r-e,2);return s?r<e?a/2:2*a:a+Math.abs(i)*i}function bg(r,e,i){let s=0;return r===10&&(s-=1e4),i&&(s+=150),r!==40&&r!==65288||(s+=50),e!==41&&e!==65289||(s+=50),s}function Kd(r,e,i,s,a,u){let h=null,f=Yd(e,i,a,u);for(const g of s){const y=Yd(e-g.x,i,a,u)+g.badness;y<=f&&(h=g,f=y)}return{index:r,x:e,priorBreak:h,badness:f}}function Jd(r){return r?Jd(r.priorBreak).concat(r.index):[]}class Ca{constructor(e="",i=[],s=[]){this.text=e,this.sections=i,this.sectionIndex=s,this.imageSectionID=null}static fromFeature(e,i){const s=new Ca;for(let a=0;a<e.sections.length;a++){const u=e.sections[a];u.image?s.addImageSection(u):s.addTextSection(u,i)}return s}length(){return[...this.text].length}getSection(e){return this.sections[this.sectionIndex[e]]}getSectionIndex(e){return this.sectionIndex[e]}verticalizePunctuation(){this.text=(function(e){let i="",s={premature:!0,value:void 0};const a=e[Symbol.iterator]();let u=a.next();const h=e[Symbol.iterator]();h.next();let f=h.next();for(;!u.done;)i+=!f.done&&gl(f.value.codePointAt(0))&&!Ul[f.value]||!s.premature&&gl(s.value.codePointAt(0))&&!Ul[s.value]||!Ul[u.value]?u.value:Ul[u.value],s={value:u.value,premature:!1},u=a.next(),f=h.next();return i})(this.text)}hasZeroWidthSpaces(){return this.text.includes("\u200B")}trim(){const e=this.text.match(/^\s*/),i=e?e[0].length:0,s=this.text.match(/\S\s*$/),a=s?s[0].length-1:0;this.text=this.text.substring(i,this.text.length-a),this.sectionIndex=this.sectionIndex.slice(i,this.sectionIndex.length-a)}substring(e,i){const s=[...this.text].slice(e,i).join(""),a=this.sectionIndex.slice(e,i);return new Ca(s,this.sections,a)}toCodeUnitIndex(e){return[...this.text].slice(0,e).join("").length}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((e,i)=>Math.max(e,this.sections[i].scale)),0)}getMaxImageSize(e){let i=0,s=0;for(let a=0;a<this.length();a++){const u=this.getSection(a);if("imageName"in u){const h=e[u.imageName];if(!h)continue;const f=h.displaySize;i=Math.max(i,f[0]),s=Math.max(s,f[1])}}return{maxImageWidth:i,maxImageHeight:s}}addTextSection(e,i){this.text+=e.text,this.sections.push({scale:e.scale||1,verticalAlign:e.verticalAlign||"bottom",fontStack:e.fontStack||i});const s=this.sections.length-1;this.sectionIndex.push(...[...e.text].map((()=>s)))}addImageSection(e){const i=e.image?e.image.name:"";if(i.length===0)return void gi("Can't add FormattedSection with an empty image.");const s=this.getNextImageSectionCharCode();s?(this.text+=String.fromCharCode(s),this.sections.push({scale:1,verticalAlign:e.verticalAlign||"bottom",imageName:i}),this.sectionIndex.push(this.sections.length-1)):gi("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(e,i,s,a,u){const h=[],f=this.determineAverageLineWidth(e,i,s,a,u),g=this.hasZeroWidthSpaces();let y=0,x=0;const b=this.text[Symbol.iterator]();let S=b.next();const P=this.text[Symbol.iterator]();P.next();let I=P.next();const A=this.text[Symbol.iterator]();A.next(),A.next();let L=A.next();for(;!S.done;){const O=this.getSection(x),G=S.value.codePointAt(0);if(Gc(G)||(y+=Xd(G,O,s,a,e,u)),!I.done){const B=th(G),V=I.value.codePointAt(0);(vg[G]||B||"imageName"in O||!L.done&&xg[V])&&h.push(Kd(x+1,y,f,h,bg(G,V,B&&g),!1))}x++,S=b.next(),I=P.next(),L=A.next()}return Jd(Kd(this.length(),y,f,h,0,!0))}determineAverageLineWidth(e,i,s,a,u){let h=0,f=0;for(const g of this.text){const y=this.getSection(f);h+=Xd(g.codePointAt(0),y,s,a,e,u),f++}return h/Math.max(1,Math.ceil(h/i))}}const vh=4294967296,Qd=1/vh,ep=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");class uu{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,i,s=this.length){for(;this.pos<s;){const a=this.readVarint(),u=a>>3,h=this.pos;this.type=7&a,e(u,i,this),this.pos===h&&this.skip(a)}return i}readMessage(e,i){return this.readFields(e,i,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)*vh;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*vh;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 i=this.buf;let s,a;return a=i[this.pos++],s=127&a,a<128?s:(a=i[this.pos++],s|=(127&a)<<7,a<128?s:(a=i[this.pos++],s|=(127&a)<<14,a<128?s:(a=i[this.pos++],s|=(127&a)<<21,a<128?s:(a=i[this.pos],s|=(15&a)<<28,(function(u,h,f){const g=f.buf;let y,x;if(x=g[f.pos++],y=(112&x)>>4,x<128||(x=g[f.pos++],y|=(127&x)<<3,x<128)||(x=g[f.pos++],y|=(127&x)<<10,x<128)||(x=g[f.pos++],y|=(127&x)<<17,x<128)||(x=g[f.pos++],y|=(127&x)<<24,x<128)||(x=g[f.pos++],y|=(1&x)<<31,x<128))return Ia(u,y,h);throw new Error("Expected varint not more than 10 bytes")})(s,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return!!this.readVarint()}readString(){const e=this.readVarint()+this.pos,i=this.pos;return this.pos=e,e-i>=12&&ep?ep.decode(this.buf.subarray(i,e)):(function(s,a,u){let h="",f=a;for(;f<u;){const g=s[f];let y,x,b,S=null,P=g>239?4:g>223?3:g>191?2:1;if(f+P>u)break;P===1?g<128&&(S=g):P===2?(y=s[f+1],(192&y)==128&&(S=(31&g)<<6|63&y,S<=127&&(S=null))):P===3?(y=s[f+1],x=s[f+2],(192&y)==128&&(192&x)==128&&(S=(15&g)<<12|(63&y)<<6|63&x,(S<=2047||S>=55296&&S<=57343)&&(S=null))):P===4&&(y=s[f+1],x=s[f+2],b=s[f+3],(192&y)==128&&(192&x)==128&&(192&b)==128&&(S=(15&g)<<18|(63&y)<<12|(63&x)<<6|63&b,(S<=65535||S>=1114112)&&(S=null))),S===null?(S=65533,P=1):S>65535&&(S-=65536,h+=String.fromCharCode(S>>>10&1023|55296),S=56320|1023&S),h+=String.fromCharCode(S),f+=P}return h})(this.buf,i,e)}readBytes(){const e=this.readVarint()+this.pos,i=this.buf.subarray(this.pos,e);return this.pos=e,i}readPackedVarint(e=[],i){const s=this.readPackedEnd();for(;this.pos<s;)e.push(this.readVarint(i));return e}readPackedSVarint(e=[]){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readSVarint());return e}readPackedBoolean(e=[]){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readBoolean());return e}readPackedFloat(e=[]){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readFloat());return e}readPackedDouble(e=[]){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readDouble());return e}readPackedFixed32(e=[]){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readFixed32());return e}readPackedSFixed32(e=[]){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readSFixed32());return e}readPackedFixed64(e=[]){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readFixed64());return e}readPackedSFixed64(e=[]){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readSFixed64());return e}readPackedEnd(){return this.type===2?this.readVarint()+this.pos:this.pos+1}skip(e){const i=7&e;if(i===0)for(;this.buf[this.pos++]>127;);else if(i===2)this.pos=this.readVarint()+this.pos;else if(i===5)this.pos+=4;else{if(i!==1)throw new Error(`Unimplemented type: ${i}`);this.pos+=8}}writeTag(e,i){this.writeVarint(e<<3|i)}realloc(e){let i=this.length||16;for(;i<this.pos+e;)i*=2;if(i!==this.length){const s=new Uint8Array(i);s.set(this.buf),this.buf=s,this.dataView=new DataView(s.buffer),this.length=i}}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*Qd),!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*Qd),!0),this.pos+=8}writeVarint(e){(e=+e||0)>268435455||e<0?(function(i,s){let a,u;if(i>=0?(a=i%4294967296|0,u=i/4294967296|0):(a=~(-i%4294967296),u=~(-i/4294967296),4294967295^a?a=a+1|0:(a=0,u=u+1|0)),i>=18446744073709552e3||i<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");s.realloc(10),(function(h,f,g){g.buf[g.pos++]=127&h|128,h>>>=7,g.buf[g.pos++]=127&h|128,h>>>=7,g.buf[g.pos++]=127&h|128,h>>>=7,g.buf[g.pos++]=127&h|128,g.buf[g.pos]=127&(h>>>=7)})(a,0,s),(function(h,f){const g=(7&h)<<4;f.buf[f.pos++]|=g|((h>>>=3)?128:0),h&&(f.buf[f.pos++]=127&h|((h>>>=7)?128:0),h&&(f.buf[f.pos++]=127&h|((h>>>=7)?128:0),h&&(f.buf[f.pos++]=127&h|((h>>>=7)?128:0),h&&(f.buf[f.pos++]=127&h|((h>>>=7)?128:0),h&&(f.buf[f.pos++]=127&h)))))})(u,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 i=this.pos;this.pos=(function(a,u,h){for(let f,g,y=0;y<u.length;y++){if(f=u.charCodeAt(y),f>55295&&f<57344){if(!g){f>56319||y+1===u.length?(a[h++]=239,a[h++]=191,a[h++]=189):g=f;continue}if(f<56320){a[h++]=239,a[h++]=191,a[h++]=189,g=f;continue}f=g-55296<<10|f-56320|65536,g=null}else g&&(a[h++]=239,a[h++]=191,a[h++]=189,g=null);f<128?a[h++]=f:(f<2048?a[h++]=f>>6|192:(f<65536?a[h++]=f>>12|224:(a[h++]=f>>18|240,a[h++]=f>>12&63|128),a[h++]=f>>6&63|128),a[h++]=63&f|128)}return h})(this.buf,e,this.pos);const s=this.pos-i;s>=128&&tp(i,s,this),this.pos=i-1,this.writeVarint(s),this.pos+=s}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 i=e.length;this.writeVarint(i),this.realloc(i);for(let s=0;s<i;s++)this.buf[this.pos++]=e[s]}writeRawMessage(e,i){this.pos++;const s=this.pos;e(i,this);const a=this.pos-s;a>=128&&tp(s,a,this),this.pos=s-1,this.writeVarint(a),this.pos+=a}writeMessage(e,i,s){this.writeTag(e,2),this.writeRawMessage(i,s)}writePackedVarint(e,i){i.length&&this.writeMessage(e,wg,i)}writePackedSVarint(e,i){i.length&&this.writeMessage(e,Tg,i)}writePackedBoolean(e,i){i.length&&this.writeMessage(e,Mg,i)}writePackedFloat(e,i){i.length&&this.writeMessage(e,Sg,i)}writePackedDouble(e,i){i.length&&this.writeMessage(e,Pg,i)}writePackedFixed32(e,i){i.length&&this.writeMessage(e,Cg,i)}writePackedSFixed32(e,i){i.length&&this.writeMessage(e,Ig,i)}writePackedFixed64(e,i){i.length&&this.writeMessage(e,Eg,i)}writePackedSFixed64(e,i){i.length&&this.writeMessage(e,Ag,i)}writeBytesField(e,i){this.writeTag(e,2),this.writeBytes(i)}writeFixed32Field(e,i){this.writeTag(e,5),this.writeFixed32(i)}writeSFixed32Field(e,i){this.writeTag(e,5),this.writeSFixed32(i)}writeFixed64Field(e,i){this.writeTag(e,1),this.writeFixed64(i)}writeSFixed64Field(e,i){this.writeTag(e,1),this.writeSFixed64(i)}writeVarintField(e,i){this.writeTag(e,0),this.writeVarint(i)}writeSVarintField(e,i){this.writeTag(e,0),this.writeSVarint(i)}writeStringField(e,i){this.writeTag(e,2),this.writeString(i)}writeFloatField(e,i){this.writeTag(e,5),this.writeFloat(i)}writeDoubleField(e,i){this.writeTag(e,1),this.writeDouble(i)}writeBooleanField(e,i){this.writeVarintField(e,+i)}}function Ia(r,e,i){return i?4294967296*e+(r>>>0):4294967296*(e>>>0)+(r>>>0)}function tp(r,e,i){const s=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(s);for(let a=i.pos-1;a>=r;a--)i.buf[a+s]=i.buf[a]}function wg(r,e){for(let i=0;i<r.length;i++)e.writeVarint(r[i])}function Tg(r,e){for(let i=0;i<r.length;i++)e.writeSVarint(r[i])}function Sg(r,e){for(let i=0;i<r.length;i++)e.writeFloat(r[i])}function Pg(r,e){for(let i=0;i<r.length;i++)e.writeDouble(r[i])}function Mg(r,e){for(let i=0;i<r.length;i++)e.writeBoolean(r[i])}function Cg(r,e){for(let i=0;i<r.length;i++)e.writeFixed32(r[i])}function Ig(r,e){for(let i=0;i<r.length;i++)e.writeSFixed32(r[i])}function Eg(r,e){for(let i=0;i<r.length;i++)e.writeFixed64(r[i])}function Ag(r,e){for(let i=0;i<r.length;i++)e.writeSFixed64(r[i])}function Dg(r,e,i){r===1&&i.readMessage(zg,e)}function zg(r,e,i){if(r===3){const{id:s,bitmap:a,width:u,height:h,left:f,top:g,advance:y}=i.readMessage(kg,{});e.push({id:s,bitmap:new zl({width:u+6,height:h+6},a),metrics:{width:u,height:h,left:f,top:g,advance:y}})}}function kg(r,e,i){r===1?e.id=i.readVarint():r===2?e.bitmap=i.readBytes():r===3?e.width=i.readVarint():r===4?e.height=i.readVarint():r===5?e.left=i.readSVarint():r===6?e.top=i.readSVarint():r===7&&(e.advance=i.readVarint())}function ip(r){let e=0,i=0;for(const h of r)e+=h.w*h.h,i=Math.max(i,h.w);r.sort(((h,f)=>f.h-h.h));const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let a=0,u=0;for(const h of r)for(let f=s.length-1;f>=0;f--){const g=s[f];if(!(h.w>g.w||h.h>g.h)){if(h.x=g.x,h.y=g.y,u=Math.max(u,h.y+h.h),a=Math.max(a,h.x+h.w),h.w===g.w&&h.h===g.h){const y=s.pop();y&&f<s.length&&(s[f]=y)}else h.h===g.h?(g.x+=h.w,g.w-=h.w):h.w===g.w?(g.y+=h.h,g.h-=h.h):(s.push({x:g.x+h.w,y:g.y,w:g.w-h.w,h:h.h}),g.y+=h.h,g.h-=h.h);break}}return{w:a,h:u,fill:e/(a*u)||0}}class xh{constructor(e,{pixelRatio:i,version:s,stretchX:a,stretchY:u,content:h,textFitWidth:f,textFitHeight:g}){this.paddedRect=e,this.pixelRatio=i,this.stretchX=a,this.stretchY=u,this.content=h,this.version=s,this.textFitWidth=f,this.textFitHeight=g}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 rp{constructor(e,i){const s={},a={};this.haveRenderCallbacks=[];const u=[];this.addImages(e,s,u),this.addImages(i,a,u);const{w:h,h:f}=ip(u),g=new Ji({width:h||1,height:f||1});for(const y in e){const x=e[y],b=s[y].paddedRect;Ji.copy(x.data,g,{x:0,y:0},{x:b.x+1,y:b.y+1},x.data)}for(const y in i){const x=i[y],b=a[y].paddedRect,S=b.x+1,P=b.y+1,I=x.data.width,A=x.data.height;Ji.copy(x.data,g,{x:0,y:0},{x:S,y:P},x.data),Ji.copy(x.data,g,{x:0,y:A-1},{x:S,y:P-1},{width:I,height:1}),Ji.copy(x.data,g,{x:0,y:0},{x:S,y:P+A},{width:I,height:1}),Ji.copy(x.data,g,{x:I-1,y:0},{x:S-1,y:P},{width:1,height:A}),Ji.copy(x.data,g,{x:0,y:0},{x:S+I,y:P},{width:1,height:A})}this.image=g,this.iconPositions=s,this.patternPositions=a}addImages(e,i,s){for(const a in e){const u=e[a],h={x:0,y:0,w:u.data.width+2,h:u.data.height+2};s.push(h),i[a]=new xh(h,u),u.hasRenderCallback&&this.haveRenderCallbacks.push(a)}}patchUpdatedImages(e,i){e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const s in e.updatedImages)this.patchUpdatedImage(this.iconPositions[s],e.getImage(s),i),this.patchUpdatedImage(this.patternPositions[s],e.getImage(s),i)}patchUpdatedImage(e,i,s){if(!e||!i||e.version===i.version)return;e.version=i.version;const[a,u]=e.tl;s.update(i.data,void 0,{x:a,y:u})}}var Ss;function hu(r,e,i,s,a,u,h,f,g,y,x,b,S,P,I){const A=Ca.fromFeature(r,a);let L;b===D.az.vertical&&A.verticalizePunctuation();let O=A.determineLineBreaks(y,u,e,s,P);const{processBidirectionalText:G,processStyledBidirectionalText:B}=Hr;if(G&&A.sections.length===1){L=[],O=O.map((ae=>A.toCodeUnitIndex(ae)));const ee=G(A.toString(),O);for(const ae of ee){const _e=[...ae].map((()=>0));L.push(new Ca(ae,A.sections,_e))}}else if(B){L=[],O=O.map((ye=>A.toCodeUnitIndex(ye)));let ee=0;const ae=[];for(const ye of A.text)ae.push(...Array(ye.length).fill(A.sectionIndex[ee])),ee++;const _e=B(A.text,ae,O);for(const ye of _e){const xe=[];let Ee="";for(const we of ye[0])xe.push(ye[1][Ee.length]),Ee+=we;L.push(new Ca(ye[0],A.sections,xe))}}else L=(function(ee,ae){const _e=[];let ye=0;for(const xe of ae)_e.push(ee.substring(ye,xe)),ye=xe;return ye<ee.length()&&_e.push(ee.substring(ye,ee.length())),_e})(A,O);const V=[],W={positionedLines:V,text:A.toString(),top:x[1],bottom:x[1],left:x[0],right:x[0],writingMode:b,iconsInText:!1,verticalizable:!1};return(function(ee,ae,_e,ye,xe,Ee,we,ve,fe,ze,Le,Ve){let Fe=0,it=0,Dt=0,Jt=0;const bi=ve==="right"?1:ve==="left"?0:.5,Dr=si/Ve;let Vi=0;for(const Zt of xe){Zt.trim();const pi=Zt.getMaxScale(),Ai={positionedGlyphs:[],lineOffset:0};ee.positionedLines[Vi]=Ai;const Di=Ai.positionedGlyphs;let Qi=0;if(!Zt.length()){it+=Ee,++Vi;continue}const Ti=Lg(ye,Zt,Dr);let er=0;for(const ai of Zt.text){const Lt=Zt.getSection(er),Qt=ai.codePointAt(0),Vt=Rg(fe,Le,Qt),li={glyph:Qt,imageName:null,x:Fe,y:it+-17,vertical:Vt,scale:1,fontStack:"",sectionIndex:Zt.getSectionIndex(er),metrics:null,rect:null};let Hn;if("fontStack"in Lt){if(Hn=Fg(Lt,Qt,Vt,Ti,ae,_e),!Hn)continue;li.fontStack=Lt.fontStack}else{if(ee.iconsInText=!0,Lt.scale*=Dr,Hn=Bg(Lt,Vt,pi,Ti,ye),!Hn)continue;Qi=Math.max(Qi,Hn.imageOffset),li.imageName=Lt.imageName}const{rect:Qr,metrics:Xl,baselineOffset:As}=Hn;li.y+=As,li.scale=Lt.scale,li.metrics=Xl,li.rect=Qr,Di.push(li),Vt?(ee.verticalizable=!0,Fe+=("imageName"in Lt?Xl.advance:si)*Lt.scale+ze):Fe+=Xl.advance*Lt.scale+ze,er++}Di.length!==0&&(Dt=Math.max(Fe-ze,Dt),Og(Di,0,Di.length-1,bi)),Fe=0,Ai.lineOffset=Math.max(Qi,(pi-1)*si);const zr=Ee*pi+Qi;it+=zr,Jt=Math.max(zr,Jt),++Vi}const{horizontalAlign:di,verticalAlign:wi}=bh(we);(function(Zt,pi,Ai,Di,Qi,Ti,er,zr,ai){const Lt=(pi-Ai)*Qi;let Qt=0;Qt=Ti!==er?-zr*Di- -17:-Di*ai*er+.5*er;for(const Vt of Zt)for(const li of Vt.positionedGlyphs)li.x+=Lt,li.y+=Qt})(ee.positionedLines,bi,di,wi,Dt,Jt,Ee,it,xe.length),ee.top+=-wi*it,ee.bottom=ee.top+it,ee.left+=-di*Dt,ee.right=ee.left+Dt})(W,e,i,s,L,h,f,g,b,y,S,I),!(function(ee){for(const ae of ee)if(ae.positionedGlyphs.length!==0)return!1;return!0})(V)&&W}function bh(r){let e=.5,i=.5;switch(r){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(r){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:e,verticalAlign:i}}function Lg(r,e,i){const s=e.getMaxScale()*si,{maxImageWidth:a,maxImageHeight:u}=e.getMaxImageSize(r),h=Math.max(s,u*i);return{verticalLineContentWidth:Math.max(s,a*i),horizontalLineContentHeight:h}}function np(r){switch(r){case"top":return 0;case"center":return .5;default:return 1}}function Rg(r,e,i){return!(r===D.az.horizontal||!e&&!Un(i)||e&&(Gc(i)||(s=i,/\p{sc=Arab}/u.test(String.fromCodePoint(s)))));var s}function Fg(r,e,i,s,a,u){const h=u[r.fontStack],f=(function(y,x,b,S){if(y&&y.rect)return y;const P=x[b.fontStack],I=P&&P[S];return I?{rect:null,metrics:I.metrics}:null})(h&&h[e],a,r,e);if(f===null)return null;let g;if(i)g=s.verticalLineContentWidth-r.scale*si;else{const y=np(r.verticalAlign);g=(s.horizontalLineContentHeight-r.scale*si)*y}return{rect:f.rect,metrics:f.metrics,baselineOffset:g}}function Bg(r,e,i,s,a){const u=a[r.imageName];if(!u)return null;const h=u.paddedRect,f=u.displaySize,g={width:f[0],height:f[1],left:1,top:-3,advance:e?f[1]:f[0]};let y;if(e)y=s.verticalLineContentWidth-f[1]*r.scale;else{const x=np(r.verticalAlign);y=(s.horizontalLineContentHeight-f[1]*r.scale)*x}return{rect:h,metrics:g,baselineOffset:y,imageOffset:(e?f[0]:f[1])*r.scale-si*i}}function Og(r,e,i,s){if(s===0)return;const a=r[i],u=(r[i].x+a.metrics.advance*a.scale)*s;for(let h=e;h<=i;h++)r[h].x-=u}function Vg(r,e,i){const{horizontalAlign:s,verticalAlign:a}=bh(i),u=e[0]-r.displaySize[0]*s,h=e[1]-r.displaySize[1]*a;return{image:r,top:h,bottom:h+r.displaySize[1],left:u,right:u+r.displaySize[0]}}function sp(r){var e,i;let s=r.left,a=r.top,u=r.right-s,h=r.bottom-a;const f=(e=r.image.textFitWidth)!==null&&e!==void 0?e:"stretchOrShrink",g=(i=r.image.textFitHeight)!==null&&i!==void 0?i:"stretchOrShrink",y=(r.image.content[2]-r.image.content[0])/(r.image.content[3]-r.image.content[1]);if(g==="proportional"){if(f==="stretchOnly"&&u/h<y||f==="proportional"){const x=Math.ceil(h*y);s*=x/u,u=x}}else if(f==="proportional"&&g==="stretchOnly"&&y!==0&&u/h>y){const x=Math.ceil(u/y);a*=x/h,h=x}return{x1:s,y1:a,x2:s+u,y2:a+h}}function op(r,e,i,s,a,u){const h=r.image;let f;if(h.content){const L=h.content,O=h.pixelRatio||1;f=[L[0]/O,L[1]/O,h.displaySize[0]-L[2]/O,h.displaySize[1]-L[3]/O]}const g=e.left*u,y=e.right*u;let x,b,S,P;i==="width"||i==="both"?(P=a[0]+g-s[3],b=a[0]+y+s[1]):(P=a[0]+(g+y-h.displaySize[0])/2,b=P+h.displaySize[0]);const I=e.top*u,A=e.bottom*u;return i==="height"||i==="both"?(x=a[1]+I-s[0],S=a[1]+A+s[2]):(x=a[1]+(I+A-h.displaySize[1])/2,S=x+h.displaySize[1]),{image:h,top:x,right:b,bottom:S,left:P,collisionPadding:f}}De("ImagePosition",xh),De("ImageAtlas",rp),D.az=void 0,(Ss=D.az||(D.az={}))[Ss.none=0]="none",Ss[Ss.horizontal=1]="horizontal",Ss[Ss.vertical=2]="vertical",Ss[Ss.horizontalOnly=3]="horizontalOnly";const $n=128,Ps=32640;function ap(r,e){const{expression:i}=e;if(i.kind==="constant")return{kind:"constant",layoutSize:i.evaluate(new vt(r+1))};if(i.kind==="source")return{kind:"source"};{const{zoomStops:s,interpolationType:a}=i;let u=0;for(;u<s.length&&s[u]<=r;)u++;u=Math.max(0,u-1);let h=u;for(;h<s.length&&s[h]<r+1;)h++;h=Math.min(s.length-1,h);const f=s[u],g=s[h];return i.kind==="composite"?{kind:"composite",minZoom:f,maxZoom:g,interpolationType:a}:{kind:"camera",minZoom:f,maxZoom:g,minSize:i.evaluate(new vt(f)),maxSize:i.evaluate(new vt(g)),interpolationType:a}}}function wh(r,e,i){let s="never";const a=r.get(e);return a?s=a:r.get(i)&&(s="always"),s}const Ng=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function du(r,e,i,s,a,u,h,f,g,y,x,b,S){const P=f?Math.min(Ps,Math.round(f[0])):0,I=f?Math.min(Ps,Math.round(f[1])):0;r.emplaceBack(e,i,Math.round(32*s),Math.round(32*a),u,h,(P<<1)+(g?1:0),I,16*y,16*x,256*b,256*S)}function Th(r,e,i){r.emplaceBack(e.x,e.y,i),r.emplaceBack(e.x,e.y,i),r.emplaceBack(e.x,e.y,i),r.emplaceBack(e.x,e.y,i)}function jg(r){for(const e of r.sections)if(yl(e.text))return!0;return!1}class Sh{constructor(e){this.layoutVertexArray=new Q,this.indexArray=new ce,this.programConfigurations=e,this.segments=new ge,this.dynamicLayoutVertexArray=new H,this.opacityVertexArray=new te,this.hasVisibleVertices=!1,this.placedSymbolArray=new p}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(e,i,s,a){this.isEmpty()||(s&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,fg.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,i),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,mg.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,Ng,!0),this.opacityVertexBuffer.itemSize=1),(s||a)&&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())}}De("SymbolBuffers",Sh);class Ph{constructor(e,i,s){this.layoutVertexArray=new e,this.layoutAttributes=i,this.indexArray=new s,this.segments=new ge,this.collisionVertexArray=new ue}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,gg.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}De("CollisionBuffers",Ph);class Ea{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((h=>h.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=ap(this.zoom,i["text-size"]),this.iconSizeData=ap(this.zoom,i["icon-size"]);const s=this.layers[0].layout,a=s.get("symbol-sort-key"),u=s.get("symbol-z-order");this.canOverlap=wh(s,"text-overlap","text-allow-overlap")!=="never"||wh(s,"icon-overlap","icon-allow-overlap")!=="never"||s.get("text-ignore-placement")||s.get("icon-ignore-placement"),this.sortFeaturesByKey=u!=="viewport-y"&&!a.isConstant(),this.sortFeaturesByY=(u==="viewport-y"||u==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,s.get("symbol-placement")==="point"&&(this.writingModes=s.get("text-writing-mode").map((h=>D.az[h]))),this.stateDependentLayerIds=this.layers.filter((h=>h.isStateDependent())).map((h=>h.id)),this.sourceID=e.sourceID}createArrays(){this.text=new Sh(new Zn(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new Sh(new Zn(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new v,this.lineVertexArray=new w,this.symbolInstances=new _,this.textAnchorOffsets=new C}calculateGlyphDependencies(e,i,s,a,u){for(const h of e)if(i[h.codePointAt(0)]=!0,(s||a)&&u){const f=Ul[h];f&&(i[f.codePointAt(0)]=!0)}}populate(e,i,s){const a=this.layers[0],u=a.layout,h=u.get("text-font"),f=u.get("text-field"),g=u.get("icon-image"),y=(f.value.kind!=="constant"||f.value.value instanceof Ui&&!f.value.value.isEmpty()||f.value.value.toString().length>0)&&(h.value.kind!=="constant"||h.value.value.length>0),x=g.value.kind!=="constant"||!!g.value.value||Object.keys(g.parameters).length>0,b=u.get("symbol-sort-key");if(this.features=[],!y&&!x)return;const S=i.iconDependencies,P=i.glyphDependencies,I=i.availableImages,A=new vt(this.zoom);for(const{feature:L,id:O,index:G,sourceLayerIndex:B}of e){const V=a._featureFilter.needGeometry,W=yn(L,V);if(!a._featureFilter.filter(A,W,s))continue;let ee,ae;if(V||(W.geometry=Ki(L)),y){const ye=a.getValueAndResolveTokens("text-field",W,s,I),xe=Ui.factory(ye),Ee=this.hasRTLText=this.hasRTLText||jg(xe);(!Ee||Hr.getRTLTextPluginStatus()==="unavailable"||Ee&&Hr.isParsed())&&(ee=yg(xe,a,W))}if(x){const ye=a.getValueAndResolveTokens("icon-image",W,s,I);ae=ye instanceof Gi?ye:Gi.fromString(ye)}if(!ee&&!ae)continue;const _e=this.sortFeaturesByKey?b.evaluate(W,{},s):void 0;if(this.features.push({id:O,text:ee,icon:ae,index:G,sourceLayerIndex:B,geometry:W.geometry,properties:L.properties,type:Vl.types[L.type],sortKey:_e}),ae&&(S[ae.name]=!0),ee){const ye=h.evaluate(W,{},s).join(","),xe=u.get("text-rotation-alignment")!=="viewport"&&u.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(D.az.vertical)>=0;for(const Ee of ee.sections)if(Ee.image)S[Ee.image.name]=!0;else{const we=fl(ee.toString()),ve=Ee.fontStack||ye,fe=P[ve]=P[ve]||{};this.calculateGlyphDependencies(Ee.text,fe,xe,this.allowVerticalPlacement,we)}}}u.get("symbol-placement")==="line"&&(this.features=(function(L){const O={},G={},B=[];let V=0;function W(ye){B.push(L[ye]),V++}function ee(ye,xe,Ee){const we=G[ye];return delete G[ye],G[xe]=we,B[we].geometry[0].pop(),B[we].geometry[0]=B[we].geometry[0].concat(Ee[0]),we}function ae(ye,xe,Ee){const we=O[xe];return delete O[xe],O[ye]=we,B[we].geometry[0].shift(),B[we].geometry[0]=Ee[0].concat(B[we].geometry[0]),we}function _e(ye,xe,Ee){const we=Ee?xe[0][xe[0].length-1]:xe[0][0];return`${ye}:${we.x}:${we.y}`}for(let ye=0;ye<L.length;ye++){const xe=L[ye],Ee=xe.geometry,we=xe.text?xe.text.toString():null;if(!we){W(ye);continue}const ve=_e(we,Ee),fe=_e(we,Ee,!0);if(ve in G&&fe in O&&G[ve]!==O[fe]){const ze=ae(ve,fe,Ee),Le=ee(ve,fe,B[ze].geometry);delete O[ve],delete G[fe],G[_e(we,B[Le].geometry,!0)]=Le,B[ze].geometry=null}else ve in G?ee(ve,fe,Ee):fe in O?ae(ve,fe,Ee):(W(ye),O[ve]=V-1,G[fe]=V-1)}return B.filter((ye=>ye.geometry))})(this.features)),this.sortFeaturesByKey&&this.features.sort(((L,O)=>L.sortKey-O.sortKey))}update(e,i,s){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,i,this.layers,{imagePositions:s}),this.icon.programConfigurations.updatePaintArrays(e,i,this.layers,{imagePositions:s}))}isEmpty(){return this.symbolInstances.length===0&&!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,i){const s=this.lineVertexArray.length;if(e.segment!==void 0){let a=e.dist(i[e.segment+1]),u=e.dist(i[e.segment]);const h={};for(let f=e.segment+1;f<i.length;f++)h[f]={x:i[f].x,y:i[f].y,tileUnitDistanceFromAnchor:a},f<i.length-1&&(a+=i[f+1].dist(i[f]));for(let f=e.segment||0;f>=0;f--)h[f]={x:i[f].x,y:i[f].y,tileUnitDistanceFromAnchor:u},f>0&&(u+=i[f-1].dist(i[f]));for(let f=0;f<i.length;f++){const g=h[f];this.lineVertexArray.emplaceBack(g.x,g.y,g.tileUnitDistanceFromAnchor)}}return{lineStartIndex:s,lineLength:this.lineVertexArray.length-s}}addSymbols(e,i,s,a,u,h,f,g,y,x,b,S){const P=e.indexArray,I=e.layoutVertexArray,A=e.segments.prepareSegment(4*i.length,I,P,this.canOverlap?h.sortKey:void 0),L=this.glyphOffsetArray.length,O=A.vertexLength,G=this.allowVerticalPlacement&&f===D.az.vertical?Math.PI/2:0,B=h.text&&h.text.sections;for(let V=0;V<i.length;V++){const{tl:W,tr:ee,bl:ae,br:_e,tex:ye,pixelOffsetTL:xe,pixelOffsetBR:Ee,minFontScaleX:we,minFontScaleY:ve,glyphOffset:fe,isSDF:ze,sectionIndex:Le}=i[V],Ve=A.vertexLength,Fe=fe[1];du(I,g.x,g.y,W.x,Fe+W.y,ye.x,ye.y,s,ze,xe.x,xe.y,we,ve),du(I,g.x,g.y,ee.x,Fe+ee.y,ye.x+ye.w,ye.y,s,ze,Ee.x,xe.y,we,ve),du(I,g.x,g.y,ae.x,Fe+ae.y,ye.x,ye.y+ye.h,s,ze,xe.x,Ee.y,we,ve),du(I,g.x,g.y,_e.x,Fe+_e.y,ye.x+ye.w,ye.y+ye.h,s,ze,Ee.x,Ee.y,we,ve),Th(e.dynamicLayoutVertexArray,g,G),P.emplaceBack(Ve,Ve+2,Ve+1),P.emplaceBack(Ve+1,Ve+2,Ve+3),A.vertexLength+=4,A.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(fe[0]),V!==i.length-1&&Le===i[V+1].sectionIndex||e.programConfigurations.populatePaintArrays(I.length,h,h.index,{imagePositions:{},canonical:S,formattedSection:B&&B[Le]})}e.placedSymbolArray.emplaceBack(g.x,g.y,L,this.glyphOffsetArray.length-L,O,y,x,g.segment,s?s[0]:0,s?s[1]:0,a[0],a[1],f,0,!1,0,b)}_addCollisionDebugVertex(e,i,s,a,u,h){return i.emplaceBack(0,0),e.emplaceBack(s.x,s.y,a,u,Math.round(h.x),Math.round(h.y))}addCollisionDebugVertices(e,i,s,a,u,h,f){const g=u.segments.prepareSegment(4,u.layoutVertexArray,u.indexArray),y=g.vertexLength,x=u.layoutVertexArray,b=u.collisionVertexArray,S=f.anchorX,P=f.anchorY;this._addCollisionDebugVertex(x,b,h,S,P,new Te(e,i)),this._addCollisionDebugVertex(x,b,h,S,P,new Te(s,i)),this._addCollisionDebugVertex(x,b,h,S,P,new Te(s,a)),this._addCollisionDebugVertex(x,b,h,S,P,new Te(e,a)),g.vertexLength+=4;const I=u.indexArray;I.emplaceBack(y,y+1),I.emplaceBack(y+1,y+2),I.emplaceBack(y+2,y+3),I.emplaceBack(y+3,y),g.primitiveLength+=4}addDebugCollisionBoxes(e,i,s,a){for(let u=e;u<i;u++){const h=this.collisionBoxArray.get(u);this.addCollisionDebugVertices(h.x1,h.y1,h.x2,h.y2,a?this.textCollisionBox:this.iconCollisionBox,h.anchorPoint,s)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Ph(de,Wd.members,he),this.iconCollisionBox=new Ph(de,Wd.members,he);for(let e=0;e<this.symbolInstances.length;e++){const i=this.symbolInstances.get(e);this.addDebugCollisionBoxes(i.textBoxStartIndex,i.textBoxEndIndex,i,!0),this.addDebugCollisionBoxes(i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i,!0),this.addDebugCollisionBoxes(i.iconBoxStartIndex,i.iconBoxEndIndex,i,!1),this.addDebugCollisionBoxes(i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex,i,!1)}}_deserializeCollisionBoxesForSymbol(e,i,s,a,u,h,f,g,y){const x={};for(let b=i;b<s;b++){const S=e.get(b);x.textBox={x1:S.x1,y1:S.y1,x2:S.x2,y2:S.y2,anchorPointX:S.anchorPointX,anchorPointY:S.anchorPointY},x.textFeatureIndex=S.featureIndex;break}for(let b=a;b<u;b++){const S=e.get(b);x.verticalTextBox={x1:S.x1,y1:S.y1,x2:S.x2,y2:S.y2,anchorPointX:S.anchorPointX,anchorPointY:S.anchorPointY},x.verticalTextFeatureIndex=S.featureIndex;break}for(let b=h;b<f;b++){const S=e.get(b);x.iconBox={x1:S.x1,y1:S.y1,x2:S.x2,y2:S.y2,anchorPointX:S.anchorPointX,anchorPointY:S.anchorPointY},x.iconFeatureIndex=S.featureIndex;break}for(let b=g;b<y;b++){const S=e.get(b);x.verticalIconBox={x1:S.x1,y1:S.y1,x2:S.x2,y2:S.y2,anchorPointX:S.anchorPointX,anchorPointY:S.anchorPointY},x.verticalIconFeatureIndex=S.featureIndex;break}return x}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let i=0;i<this.symbolInstances.length;i++){const s=this.symbolInstances.get(i);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,s.textBoxStartIndex,s.textBoxEndIndex,s.verticalTextBoxStartIndex,s.verticalTextBoxEndIndex,s.iconBoxStartIndex,s.iconBoxEndIndex,s.verticalIconBoxStartIndex,s.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,i){const s=e.placedSymbolArray.get(i),a=s.vertexStartIndex+4*s.numGlyphs;for(let u=s.vertexStartIndex;u<a;u+=4)e.indexArray.emplaceBack(u,u+2,u+1),e.indexArray.emplaceBack(u+1,u+2,u+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const i=Math.sin(e),s=Math.cos(e),a=[],u=[],h=[];for(let f=0;f<this.symbolInstances.length;++f){h.push(f);const g=this.symbolInstances.get(f);a.push(0|Math.round(i*g.anchorX+s*g.anchorY)),u.push(g.featureIndex)}return h.sort(((f,g)=>a[f]-a[g]||u[g]-u[f])),h}addToSortKeyRanges(e,i){const s=this.sortKeyRanges[this.sortKeyRanges.length-1];s&&s.sortKey===i?s.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:i,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 i of this.symbolInstanceIndexes){const s=this.symbolInstances.get(i);this.featureSortOrder.push(s.featureIndex),[s.rightJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.leftJustifiedTextSymbolIndex].forEach(((a,u,h)=>{a>=0&&h.indexOf(a)===u&&this.addIndicesForPlacedSymbol(this.text,a)})),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 lp,cp;De("SymbolBucket",Ea,{omit:["layers","collisionBoxArray","features","compareText"]}),Ea.MAX_GLYPHS=65535,Ea.addDynamicAttributes=Th;var Mh={get paint(){return cp=cp||new Mi({"icon-opacity":new Ge(K.paint_symbol["icon-opacity"]),"icon-color":new Ge(K.paint_symbol["icon-color"]),"icon-halo-color":new Ge(K.paint_symbol["icon-halo-color"]),"icon-halo-width":new Ge(K.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Ge(K.paint_symbol["icon-halo-blur"]),"icon-translate":new Be(K.paint_symbol["icon-translate"]),"icon-translate-anchor":new Be(K.paint_symbol["icon-translate-anchor"]),"text-opacity":new Ge(K.paint_symbol["text-opacity"]),"text-color":new Ge(K.paint_symbol["text-color"],{runtimeType:rr,getOverride:r=>r.textColor,hasOverride:r=>!!r.textColor}),"text-halo-color":new Ge(K.paint_symbol["text-halo-color"]),"text-halo-width":new Ge(K.paint_symbol["text-halo-width"]),"text-halo-blur":new Ge(K.paint_symbol["text-halo-blur"]),"text-translate":new Be(K.paint_symbol["text-translate"]),"text-translate-anchor":new Be(K.paint_symbol["text-translate-anchor"])})},get layout(){return lp=lp||new Mi({"symbol-placement":new Be(K.layout_symbol["symbol-placement"]),"symbol-spacing":new Be(K.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Be(K.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Ge(K.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Be(K.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Be(K.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Be(K.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Be(K.layout_symbol["icon-ignore-placement"]),"icon-optional":new Be(K.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Be(K.layout_symbol["icon-rotation-alignment"]),"icon-size":new Ge(K.layout_symbol["icon-size"]),"icon-text-fit":new Be(K.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Be(K.layout_symbol["icon-text-fit-padding"]),"icon-image":new Ge(K.layout_symbol["icon-image"]),"icon-rotate":new Ge(K.layout_symbol["icon-rotate"]),"icon-padding":new Ge(K.layout_symbol["icon-padding"]),"icon-keep-upright":new Be(K.layout_symbol["icon-keep-upright"]),"icon-offset":new Ge(K.layout_symbol["icon-offset"]),"icon-anchor":new Ge(K.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Be(K.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Be(K.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Be(K.layout_symbol["text-rotation-alignment"]),"text-field":new Ge(K.layout_symbol["text-field"]),"text-font":new Ge(K.layout_symbol["text-font"]),"text-size":new Ge(K.layout_symbol["text-size"]),"text-max-width":new Ge(K.layout_symbol["text-max-width"]),"text-line-height":new Be(K.layout_symbol["text-line-height"]),"text-letter-spacing":new Ge(K.layout_symbol["text-letter-spacing"]),"text-justify":new Ge(K.layout_symbol["text-justify"]),"text-radial-offset":new Ge(K.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Be(K.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Ge(K.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Ge(K.layout_symbol["text-anchor"]),"text-max-angle":new Be(K.layout_symbol["text-max-angle"]),"text-writing-mode":new Be(K.layout_symbol["text-writing-mode"]),"text-rotate":new Ge(K.layout_symbol["text-rotate"]),"text-padding":new Be(K.layout_symbol["text-padding"]),"text-keep-upright":new Be(K.layout_symbol["text-keep-upright"]),"text-transform":new Ge(K.layout_symbol["text-transform"]),"text-offset":new Ge(K.layout_symbol["text-offset"]),"text-allow-overlap":new Be(K.layout_symbol["text-allow-overlap"]),"text-overlap":new Be(K.layout_symbol["text-overlap"]),"text-ignore-placement":new Be(K.layout_symbol["text-ignore-placement"]),"text-optional":new Be(K.layout_symbol["text-optional"])})}};class up{constructor(e){if(e.property.overrides===void 0)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:Or,this.defaultValue=e}evaluate(e){if(e.formattedSection){const i=this.defaultValue.property.overrides;if(i&&i.hasOverride(e.formattedSection))return i.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}}De("FormatSectionOverride",up,{omit:["defaultValue"]});class pu extends vr{constructor(e,i){super(e,Mh,i)}recalculate(e,i){if(super.recalculate(e,i),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")==="map"?"map":"viewport"),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),this.layout.get("symbol-placement")==="point"){const s=this.layout.get("text-writing-mode");if(s){const a=[];for(const u of s)a.indexOf(u)<0&&a.push(u);this.layout._values["text-writing-mode"]=a}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,i,s,a){const u=this.layout.get(e).evaluate(i,{},s,a),h=this._unevaluatedLayout._values[e];return h.isDataDriven()||ra(h.value)||!u?u:(function(f,g){return g.replace(/{([^{}]+)}/g,((y,x)=>f&&x in f?String(f[x]):""))})(i.properties,u)}createBucket(e){return new Ea(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of Mh.paint.overridableProperties){if(!pu.hasPaintOverride(this.layout,e))continue;const i=this.paint.get(e),s=new up(i),a=new il(s,i.property.specification);let u=null;u=i.value.kind==="constant"||i.value.kind==="source"?new na("source",a):new rl("composite",a,i.value.zoomStops),this.paint._values[e]=new yr(i.property,u,i.parameters)}}_handleOverridablePaintPropertyUpdate(e,i,s){return!(!this.layout||i.isDataDriven()||s.isDataDriven())&&pu.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,i){const s=e.get("text-field"),a=Mh.paint.properties[i];let u=!1;const h=f=>{for(const g of f)if(a.overrides&&a.overrides.hasOverride(g))return void(u=!0)};if(s.value.kind==="constant"&&s.value.value instanceof Ui)h(s.value.value.sections);else if(s.value.kind==="source"||s.value.kind==="composite"){const f=y=>{u||(y instanceof jr&&zt(y.value)===ss?h(y.value.sections):y instanceof Go?h(y.sections):y.eachChild(f))},g=s.value;g._styleExpression&&f(g._styleExpression.expression)}return u}}let hp;var Ug={get paint(){return hp=hp||new Mi({"background-color":new Be(K.paint_background["background-color"]),"background-pattern":new Xc(K.paint_background["background-pattern"]),"background-opacity":new Be(K.paint_background["background-opacity"])})}};class Gg extends vr{constructor(e,i){super(e,Ug,i)}}class qg extends vr{constructor(e,i){super(e,{},i),this.onAdd=s=>{this.implementation.onAdd&&this.implementation.onAdd(s,s.painter.context.gl)},this.onRemove=s=>{this.implementation.onRemove&&this.implementation.onRemove(s,s.painter.context.gl)},this.implementation=e}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class Zg{constructor(e){this._methodToThrottle=e,this._triggered=!1,typeof MessageChannel<"u"&&(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 $g={once:!0},Ch=63710088e-1;class Ms{constructor(e,i){if(isNaN(e)||isNaN(i))throw new Error(`Invalid LngLat object: (${e}, ${i})`);if(this.lng=+e,this.lat=+i,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Ms(fi(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const i=Math.PI/180,s=this.lat*i,a=e.lat*i,u=Math.sin(s)*Math.sin(a)+Math.cos(s)*Math.cos(a)*Math.cos((e.lng-this.lng)*i);return Ch*Math.acos(Math.min(u,1))}static convert(e){if(e instanceof Ms)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new Ms(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new Ms(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 dp=2*Math.PI*Ch;function pp(r){return dp*Math.cos(r*Math.PI/180)}function fp(r){return(180+r)/360}function mp(r){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+r*Math.PI/360)))/360}function gp(r,e){return r/pp(e)}function _p(r){return 360*r-180}function fu(r){return 360/Math.PI*Math.atan(Math.exp((180-360*r)*Math.PI/180))-90}function yp(r,e){return r*pp(fu(e))}class Gl{constructor(e,i,s=0){this.x=+e,this.y=+i,this.z=+s}static fromLngLat(e,i=0){const s=Ms.convert(e);return new Gl(fp(s.lng),mp(s.lat),gp(i,s.lat))}toLngLat(){return new Ms(_p(this.x),fu(this.y))}toAltitude(){return yp(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/dp*(e=fu(this.y),1/Math.cos(e*Math.PI/180));var e}}function vp(r,e,i){var s=2*Math.PI*6378137/256/Math.pow(2,i);return[r*s-2*Math.PI*6378137/2,e*s-2*Math.PI*6378137/2]}class Ih{constructor(e,i,s){if(!(function(a,u,h){return!(a<0||a>25||h<0||h>=Math.pow(2,a)||u<0||u>=Math.pow(2,a))})(e,i,s))throw new Error(`x=${i}, y=${s}, 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=i,this.y=s,this.key=Aa(0,e,e,i,s)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,i,s){const a=(h=this.y,f=this.z,g=vp(256*(u=this.x),256*(h=Math.pow(2,f)-h-1),f),y=vp(256*(u+1),256*(h+1),f),g[0]+","+g[1]+","+y[0]+","+y[1]);var u,h,f,g,y;const x=(function(b,S,P){let I,A="";for(let L=b;L>0;L--)I=1<<L-1,A+=(S&I?1:0)+(P&I?2:0);return A})(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(s==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,i>1?"@2x":"").replace(/{quadkey}/g,x).replace(/{bbox-epsg-3857}/g,a)}isChildOf(e){const i=this.z-e.z;return i>0&&e.x===this.x>>i&&e.y===this.y>>i}getTilePoint(e){const i=Math.pow(2,this.z);return new Te((e.x*i-this.x)*ht,(e.y*i-this.y)*ht)}toString(){return`${this.z}/${this.x}/${this.y}`}}class xp{constructor(e,i){this.wrap=e,this.canonical=i,this.key=Aa(e,i.z,i.z,i.x,i.y)}}class cr{constructor(e,i,s,a,u){if(this.terrainRttPosMatrix32f=null,e<s)throw new Error(`overscaledZ should be >= z; overscaledZ = ${e}; z = ${s}`);this.overscaledZ=e,this.wrap=i,this.canonical=new Ih(s,+a,+u),this.key=Aa(i,e,s,a,u)}clone(){return new cr(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 i=this.canonical.z-e;return e>this.canonical.z?new cr(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new cr(e,this.wrap,e,this.canonical.x>>i,this.canonical.y>>i)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,i){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?Aa(this.wrap*+i,e,this.canonical.z,this.canonical.x,this.canonical.y):Aa(this.wrap*+i,e,e,this.canonical.x>>s,this.canonical.y>>s)}isChildOf(e){if(e.wrap!==this.wrap||this.overscaledZ-e.overscaledZ<=0)return!1;if(e.overscaledZ===0)return this.overscaledZ>0;const i=this.canonical.z-e.canonical.z;return!(i<0)&&e.canonical.x===this.canonical.x>>i&&e.canonical.y===this.canonical.y>>i}children(e){if(this.overscaledZ>=e)return[new cr(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const i=this.canonical.z+1,s=2*this.canonical.x,a=2*this.canonical.y;return[new cr(i,this.wrap,i,s,a),new cr(i,this.wrap,i,s+1,a),new cr(i,this.wrap,i,s,a+1),new cr(i,this.wrap,i,s+1,a+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 cr(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new cr(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 xp(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(e){return this.canonical.getTilePoint(new Gl(e.x-this.wrap,e.y))}normalizeCoordinates(e,i,s=8192){if(e>=0&&e<s&&i>=0&&i<s)return{tileID:this,x:e,y:i};const a=Math.floor(e/s),u=Math.floor(i/s),h=e-a*s,f=i-u*s,g=this.canonical.z,y=1<<g,x=this.canonical.y+u;if(x<0||x>=y)return null;let b=this.canonical.x+a,S=this.wrap;return b<0?(S-=Math.ceil(-b/y),b=(b%y+y)%y):b>=y&&(S+=Math.floor(b/y),b%=y),{tileID:new cr(this.overscaledZ,S,g,b,x),x:h,y:f}}}function Aa(r,e,i,s,a){(r*=2)<0&&(r=-1*r-1);const u=1<<i;return(u*u*r+u*a+s).toString(36)+i.toString(36)+e.toString(36)}function Eh(r,e){return e?r.properties[e]:r.id}function Hg(r,e){const i={id:r.id};if(e.removeAllProperties&&(delete r.removeProperties,delete r.addOrUpdateProperties,delete e.removeProperties),e.removeProperties)for(const s of e.removeProperties){const a=r.addOrUpdateProperties.findIndex((u=>u.key===s));a>-1&&r.addOrUpdateProperties.splice(a,1)}return(r.removeAllProperties||e.removeAllProperties)&&(i.removeAllProperties=!0),(r.removeProperties||e.removeProperties)&&(i.removeProperties=[...r.removeProperties||[],...e.removeProperties||[]]),(r.addOrUpdateProperties||e.addOrUpdateProperties)&&(i.addOrUpdateProperties=[...r.addOrUpdateProperties||[],...e.addOrUpdateProperties||[]]),(r.newGeometry||e.newGeometry)&&(i.newGeometry=e.newGeometry||r.newGeometry),i}function bp(r){var e,i;if(!r)return{};const s={};return s.removeAll=r.removeAll,s.remove=new Set(r.remove||[]),s.add=new Map((e=r.add)===null||e===void 0?void 0:e.map((a=>[a.id,a]))),s.update=new Map((i=r.update)===null||i===void 0?void 0:i.map((a=>[a.id,a]))),s}De("CanonicalTileID",Ih),De("OverscaledTileID",cr,{omit:["terrainRttPosMatrix32f"]});class Co{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 i=new Co;return i.extend(e(new Te(this.minX,this.minY))),i.extend(e(new Te(this.maxX,this.minY))),i.extend(e(new Te(this.minX,this.maxY))),i.extend(e(new Te(this.maxX,this.maxY))),i}static fromPoints(e){const i=new Co;for(const s of e)i.extend(s);return i}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 wp{constructor(e){this._stringToNumber={},this._numberToString=[];for(let i=0;i<e.length;i++){const s=e[i];this._stringToNumber[s]=i,this._numberToString[i]=s}}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 Tp{constructor(e,i,s,a,u){this.type="Feature",this._vectorTileFeature=e,this._x=s,this._y=a,this._z=i,this.properties=e.properties,this.id=u}projectPoint(e,i,s,a){return[360*(e.x+i)/a-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+s)/a)*Math.PI))-90]}projectLine(e,i,s,a){return e.map((u=>this.projectPoint(u,i,s,a)))}get geometry(){if(this._geometry)return this._geometry;const e=this._vectorTileFeature,i=e.extent*Math.pow(2,this._z),s=e.extent*this._x,a=e.extent*this._y,u=e.loadGeometry();switch(e.type){case 1:{const h=[];for(const g of u)h.push(g[0]);const f=this.projectLine(h,s,a,i);this._geometry=h.length===1?{type:"Point",coordinates:f[0]}:{type:"MultiPoint",coordinates:f};break}case 2:{const h=u.map((f=>this.projectLine(f,s,a,i)));this._geometry=h.length===1?{type:"LineString",coordinates:h[0]}:{type:"MultiLineString",coordinates:h};break}case 3:{const h=Od(u),f=[];for(const g of h)f.push(g.map((y=>this.projectLine(y,s,a,i))));this._geometry=f.length===1?{type:"Polygon",coordinates:f[0]}:{type:"MultiPolygon",coordinates:f};break}default:throw new Error(`unknown feature type: ${e.type}`)}return this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const i in this)i!=="_geometry"&&i!=="_vectorTileFeature"&&i!=="_x"&&i!=="_y"&&i!=="_z"&&(e[i]=this[i]);return e}}class Da{_name;dataBuffer;nullabilityBuffer;_size;constructor(e,i,s){this._name=e,this.dataBuffer=i,typeof s=="number"?this._size=s:(this.nullabilityBuffer=s,this._size=s.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 mu extends Da{}class Ah extends mu{getValueFromBuffer(e){return this.dataBuffer[e]}}class Dh extends mu{getValueFromBuffer(e){return this.dataBuffer[e]}}class Sp extends Da{delta;constructor(e,i,s,a){super(e,i,a),this.delta=s}}class zh extends Sp{constructor(e,i,s,a){super(e,Int32Array.of(i),s,a)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}}class kh extends Da{constructor(e,i,s){super(e,Int32Array.of(i),s)}getValueFromBuffer(e){return this.dataBuffer[0]}}class Wg{_name;_geometryVector;_idVector;_propertyVectors;_extent;propertyVectorsMap;constructor(e,i,s,a,u=4096){this._name=e,this._geometryVector=i,this._idVector=s,this._propertyVectors=a,this._extent=u}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((i=>[i.name,i])))),this.propertyVectorsMap.get(e)}*[Symbol.iterator](){const e=this.geometryVector[Symbol.iterator]();let i=0;for(;i<this.numFeatures;){let s;this.idVector&&(s=this.containsMaxSaveIntegerValues(this.idVector)?Number(this.idVector.getValue(i)):this.idVector.getValue(i));const a=e?.next().value,u={};for(const h of this.propertyVectors){if(!h)continue;const f=h.name,g=h.getValue(i);g!==null&&(u[f]=g)}i++,yield{id:s,geometry:a,properties:u}}}get numFeatures(){return this.geometryVector.numGeometries}get extent(){return this._extent}getFeatures(){const e=[],i=this.geometryVector.getGeometries();for(let s=0;s<this.numFeatures;s++){let a;this.idVector&&(a=this.containsMaxSaveIntegerValues(this.idVector)?Number(this.idVector.getValue(s)):this.idVector.getValue(s));const u={coordinates:i[s],type:this.geometryVector.geometryType(s)},h={};for(const f of this.propertyVectors){if(!f)continue;const g=f.name,y=f.getValue(s);y!==null&&(h[g]=y)}e.push({id:a,geometry:u,properties:h})}return e}containsMaxSaveIntegerValues(e){return e instanceof Ah||e instanceof kh&&e instanceof zh||e instanceof Dh}}class Xg{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 ft,Cs,vi,Kr,Io,ur,qt,oi,Pp,xr;function Ei(r,e,i){const s=new Int32Array(i);let a=0,u=e.get();for(let h=0;h<s.length;h++){let f=r[u++],g=127&f;f<128||(f=r[u++],g|=(127&f)<<7,f<128||(f=r[u++],g|=(127&f)<<14,f<128||(f=r[u++],g|=(127&f)<<21,f<128||(f=r[u++],g|=(15&f)<<28)))),s[a++]=g}return e.set(u),s}function Lh(r,e,i){const s=new BigInt64Array(i);for(let a=0;a<s.length;a++)s[a]=Yg(r,e);return s}function Yg(r,e){let i=0n,s=0,a=e.get();for(;a<r.length;){const u=r[a++];if(i|=BigInt(127&u)<<BigInt(s),!(128&u))break;if(s+=7,s>=64)throw new Error("Varint too long")}return e.set(a),i}function Kg(r,e){let i,s;return s=r[e.get()],e.increment(),i=127&s,s<128?i:(s=r[e.get()],e.increment(),i|=(127&s)<<7,s<128?i:(s=r[e.get()],e.increment(),i|=(127&s)<<14,s<128?i:(s=r[e.get()],e.increment(),i|=(127&s)<<21,s<128?i:(s=r[e.get()],i|=(15&s)<<28,(function(a,u,h){let f,g;if(g=u[h.get()],h.increment(),f=(112&g)>>4,g<128||(g=u[h.get()],h.increment(),f|=(127&g)<<3,g<128)||(g=u[h.get()],h.increment(),f|=(127&g)<<10,g<128)||(g=u[h.get()],h.increment(),f|=(127&g)<<17,g<128)||(g=u[h.get()],h.increment(),f|=(127&g)<<24,g<128)||(g=u[h.get()],h.increment(),f|=(1&g)<<31,g<128))return 4294967296*f+(a>>>0);throw new Error("Expected varint not more than 10 bytes")})(i,r,e)))))}function Ot(r){return r>>>1^-(1&r)}function hr(r){return r>>1n^-(1n&r)}function za(r){return r%2==1?(r+1)/-2:r/2}function Mp(r,e,i){if(i===void 0){i=0;for(let u=0;u<e;u++)i+=r[u]}const s=new Int32Array(i);let a=0;for(let u=0;u<e;u++){const h=r[u];s.fill(r[u+e],a,a+h),a+=h}return s}function Cp(r,e,i){if(i===void 0){i=0;for(let u=0;u<e;u++)i+=Number(r[u])}const s=new BigInt64Array(i);let a=0;for(let u=0;u<e;u++){const h=Number(r[u]);s.fill(r[u+e],a,a+h),a+=h}return s}function Ip(r,e,i){const s=new Float64Array(i);let a=0;for(let u=0;u<e;u++){const h=r[u];s.fill(r[u+e],a,a+h),a+=h}return s}function Ep(r){const e=r.length/4*4;let i=1;if(e>=4)for(let s=r[0];i<e-4;i+=4)s=r[i]+=s,s=r[i+1]+=s,s=r[i+2]+=s,s=r[i+3]+=s;for(;i!=r.length;)r[i]+=r[i-1],++i}(function(r){r.NONE="NONE",r.DELTA="DELTA",r.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",r.RLE="RLE",r.MORTON="MORTON",r.PDE="PDE"})(ft||(ft={})),(function(r){r.NONE="NONE",r.FAST_PFOR="FAST_PFOR",r.VARINT="VARINT",r.ALP="ALP"})(Cs||(Cs={})),(function(r){r.PRESENT="PRESENT",r.DATA="DATA",r.OFFSET="OFFSET",r.LENGTH="LENGTH"})(vi||(vi={}));class Rh{_dictionaryType;_offsetType;_lengthType;constructor(e,i,s){this._dictionaryType=e,this._offsetType=i,this._lengthType=s}get dictionaryType(){return this._dictionaryType}get offsetType(){return this._offsetType}get lengthType(){return this._lengthType}}function Bi(r,e){const i=(function(s,a){const u=s[a.get()],h=Object.values(vi)[u>>4];let f=null;switch(h){case vi.DATA:f=new Rh(Object.values(Kr)[15&u]);break;case vi.OFFSET:f=new Rh(null,Object.values(Io)[15&u]);break;case vi.LENGTH:f=new Rh(null,null,Object.values(ur)[15&u])}a.increment();const g=s[a.get()],y=Object.values(ft)[g>>5],x=Object.values(ft)[g>>2&7],b=Object.values(Cs)[3&g];a.increment();const S=Ei(s,a,2),P=S[0];return{physicalStreamType:h,logicalStreamType:f,logicalLevelTechnique1:y,logicalLevelTechnique2:x,physicalLevelTechnique:b,numValues:P,byteLength:S[1],decompressedCount:P}})(r,e);return i.logicalLevelTechnique1===ft.MORTON?(function(s,a,u){const h=Ei(a,u,2);return{physicalStreamType:s.physicalStreamType,logicalStreamType:s.logicalStreamType,logicalLevelTechnique1:s.logicalLevelTechnique1,logicalLevelTechnique2:s.logicalLevelTechnique2,physicalLevelTechnique:s.physicalLevelTechnique,numValues:s.numValues,byteLength:s.byteLength,decompressedCount:s.decompressedCount,numBits:h[0],coordinateShift:h[1]}})(i,r,e):ft.RLE!==i.logicalLevelTechnique1&&ft.RLE!==i.logicalLevelTechnique2||Cs.NONE===i.physicalLevelTechnique?i:(function(s,a,u){const h=Ei(a,u,2);return{physicalStreamType:s.physicalStreamType,logicalStreamType:s.logicalStreamType,logicalLevelTechnique1:s.logicalLevelTechnique1,logicalLevelTechnique2:s.logicalLevelTechnique2,physicalLevelTechnique:s.physicalLevelTechnique,numValues:s.numValues,byteLength:s.byteLength,decompressedCount:h[1],runs:h[0],numRleValues:h[1]}})(i,r,e)}(function(r){r.NONE="NONE",r.SINGLE="SINGLE",r.SHARED="SHARED",r.VERTEX="VERTEX",r.MORTON="MORTON",r.FSST="FSST"})(Kr||(Kr={})),(function(r){r.VERTEX="VERTEX",r.INDEX="INDEX",r.STRING="STRING",r.KEY="KEY"})(Io||(Io={})),(function(r){r.VAR_BINARY="VAR_BINARY",r.GEOMETRIES="GEOMETRIES",r.PARTS="PARTS",r.RINGS="RINGS",r.TRIANGLES="TRIANGLES",r.SYMBOL="SYMBOL",r.DICTIONARY="DICTIONARY"})(ur||(ur={})),(function(r){r[r.FLAT=0]="FLAT",r[r.CONST=1]="CONST",r[r.SEQUENCE=2]="SEQUENCE",r[r.DICTIONARY=3]="DICTIONARY",r[r.FSST_DICTIONARY=4]="FSST_DICTIONARY"})(qt||(qt={}));class Jr{values;_size;constructor(e,i){this.values=e,this._size=i}get(e){const i=Math.floor(e/8);return(this.values[i]>>e%8&1)==1}set(e,i){const s=Math.floor(e/8);this.values[s]=this.values[s]|(i?1:0)<<e%8}getInt(e){const i=Math.floor(e/8);return this.values[i]>>e%8&1}size(){return this._size}getBuffer(){return this.values}}function gu(r,e,i){if(!e)return r;const s=e.size(),a=new r.constructor(s);let u=0;for(let h=0;h<s;h++)a[h]=e.get(h)?r[u++]:i;return a}function Oi(r,e,i,s,a,u){return(function(h,f,g,y,x){switch(f.logicalLevelTechnique1){case ft.DELTA:if(f.logicalLevelTechnique2===ft.RLE){const b=f;if(!x)return(function(S,P,I){const A=new Int32Array(I);let L=0,O=0;for(let G=0;G<P;G++){const B=S[G],V=Ot(S[G+P]);for(let W=0;W<B;W++)O+=V,A[L++]=O}return A})(h,b.runs,b.numRleValues);h=Mp(h,b.runs,b.numRleValues)}(function(b){b[0]=Ot(b[0]);const S=b.length/4*4;let P=1;if(S>=4)for(;P<S-4;P+=4){const I=b[P+1],A=b[P+2],L=b[P+3];b[P]=Ot(b[P])+b[P-1],b[P+1]=Ot(I)+b[P],b[P+2]=Ot(A)+b[P+1],b[P+3]=Ot(L)+b[P+2]}for(;P!=b.length;++P)b[P]=Ot(b[P])+b[P-1]})(h);break;case ft.RLE:h=(function(b,S,P){return P?(function(I,A,L){if(L===void 0){L=0;for(let B=0;B<A;B++)L+=I[B]}const O=new Int32Array(L);let G=0;for(let B=0;B<A;B++){const V=I[B];let W=I[B+A];W=Ot(W),O.fill(W,G,G+V),G+=V}return O})(b,S.runs,S.numRleValues):Mp(b,S.runs,S.numRleValues)})(h,f,g);break;case ft.MORTON:Ep(h);break;case ft.COMPONENTWISE_DELTA:(function(b){if(b.length<2)return;b[0]=Ot(b[0]),b[1]=Ot(b[1]);const S=b.length/4*4;let P=2;if(S>=4)for(;P<S-4;P+=4){const I=b[P+1],A=b[P+2],L=b[P+3];b[P]=Ot(b[P])+b[P-2],b[P+1]=Ot(I)+b[P-1],b[P+2]=Ot(A)+b[P],b[P+3]=Ot(L)+b[P+1]}for(;P!=b.length;P+=2)b[P]=Ot(b[P])+b[P-2],b[P+1]=Ot(b[P+1])+b[P-1]})(h);break;case ft.NONE:g&&(function(b){for(let S=0;S<b.length;S++)b[S]=Ot(b[S])})(h);break;default:throw new Error(`The specified Logical level technique is not supported: ${f.logicalLevelTechnique1}`)}return x?gu(h,x,0):h})(_u(r,e,i),i,s,0,u)}function Is(r,e,i){return(function(s,a){if(a.logicalLevelTechnique1===ft.DELTA&&a.logicalLevelTechnique2===ft.NONE)return(function(u){const h=new Int32Array(u.length+1);h[0]=0,h[1]=Ot(u[0]);let f=h[1];for(let g=2;g!=h.length;++g)f+=Ot(u[g-1]),h[g]=h[g-1]+f;return new Uint32Array(h)})(s);if(a.logicalLevelTechnique1===ft.RLE&&a.logicalLevelTechnique2===ft.NONE)return(function(u,h,f){const g=new Int32Array(f+1);g[0]=0;let y=1,x=g[0];for(let b=0;b<h;b++){const S=u[b],P=u[b+h];for(let I=y;I<y+S;I++)g[I]=P+x,x=g[I];y+=S}return new Uint32Array(g)})(s,a.runs,a.numRleValues);if(a.logicalLevelTechnique1===ft.NONE&&a.logicalLevelTechnique2===ft.NONE){(function(h){let f=0;for(let g=0;g<h.length;g++)h[g]+=f,f=h[g]})(s);const u=new Uint32Array(a.numValues+1);return u[0]=0,u.set(s,1),u}if(a.logicalLevelTechnique1===ft.DELTA&&a.logicalLevelTechnique2===ft.RLE){const u=(function(h,f,g){const y=new Int32Array(g+1);y[0]=0;let x=1,b=y[0];for(let S=0;S<f;S++){const P=h[S];let I=h[S+f];I=Ot(I);for(let A=x;A<x+P;A++)y[A]=I+b,b=y[A];x+=P}return new Uint32Array(y)})(s,a.runs,a.numRleValues);return Ep(u),u}throw new Error("Only delta encoding is supported for transforming length to offset streams yet.")})(_u(r,e,i),i)}function _u(r,e,i){const s=i.physicalLevelTechnique;if(s===Cs.FAST_PFOR)return(function(){throw new Error("FastPFor is not implemented yet.")})();if(s===Cs.VARINT)return Ei(r,e,i.numValues);if(s===Cs.NONE){const a=e.get();e.add(i.byteLength);const u=r.subarray(a,e.get());return new Int32Array(u)}throw new Error("Specified physicalLevelTechnique is not supported (yet).")}function Fh(r,e,i,s){const a=_u(r,e,i);if(a.length===1){const u=a[0];return s?Ot(u):u}return s?(function(u){return Ot(u[1])})(a):(function(u){return u[1]})(a)}function Ap(r,e,i){return(function(s){if(s.length==2){const a=Ot(s[1]);return[a,a]}return[Ot(s[2]),Ot(s[3])]})(_u(r,e,i))}function Dp(r,e,i){return(function(s){if(s.length==2){const a=hr(s[1]);return[a,a]}return[hr(s[2]),hr(s[3])]})(Lh(r,e,i.numValues))}function zp(r,e,i,s,a){return(function(u,h,f,g){switch(h.logicalLevelTechnique1){case ft.DELTA:if(h.logicalLevelTechnique2===ft.RLE){const y=h;if(!g)return(function(x,b,S){const P=new BigInt64Array(S);let I=0,A=0n;for(let L=0;L<b;L++){const O=Number(x[L]),G=hr(x[L+b]);for(let B=0;B<O;B++)A+=G,P[I++]=A}return P})(u,y.runs,y.numRleValues);u=Cp(u,y.runs,y.numRleValues)}(function(y){y[0]=hr(y[0]);const x=y.length/4*4;let b=1;if(x>=4)for(;b<x-4;b+=4){const S=y[b+1],P=y[b+2],I=y[b+3];y[b]=hr(y[b])+y[b-1],y[b+1]=hr(S)+y[b],y[b+2]=hr(P)+y[b+1],y[b+3]=hr(I)+y[b+2]}for(;b!=y.length;++b)y[b]=hr(y[b])+y[b-1]})(u);break;case ft.RLE:u=(function(y,x,b){return b?(function(S,P,I){if(I===void 0){I=0;for(let O=0;O<P;O++)I+=Number(S[O])}const A=new BigInt64Array(I);let L=0;for(let O=0;O<P;O++){const G=Number(S[O]);let B=S[O+P];B=hr(B),A.fill(B,L,L+G),L+=G}return A})(y,x.runs,x.numRleValues):Cp(y,x.runs,x.numRleValues)})(u,h,f);break;case ft.NONE:f&&(function(y){for(let x=0;x<y.length;x++)y[x]=hr(y[x])})(u);break;default:throw new Error(`The specified Logical level technique is not supported: ${h.logicalLevelTechnique1}`)}return g?gu(u,g,0n):u})(Lh(r,e,i.numValues),i,s,a)}function kp(r,e,i,s){const a=Lh(r,e,i.numValues);if(a.length===1){const u=a[0];return s?hr(u):u}return s?(function(u){return hr(u[1])})(a):(function(u){return u[1]})(a)}function yu(r,e,i,s){const a=r.logicalLevelTechnique1;if(a===ft.RLE)return r.runs===1?qt.CONST:qt.FLAT;if(a!==ft.DELTA||r.logicalLevelTechnique2!==ft.RLE)return r.numValues===1?qt.CONST:qt.FLAT;const u=e instanceof Jr?e.size():e;if(r.numRleValues!==u)return qt.FLAT;if(r.runs===1)return qt.SEQUENCE;if(r.runs!==2)return r.numValues===1?qt.CONST:qt.FLAT;const h=s.get();let f;if(r.physicalLevelTechnique===Cs.VARINT)f=Ei(i,s,4);else{const g=s.get();f=new Int32Array(i.buffer,i.byteOffset+g,4)}return s.set(h),f[2]===2&&f[3]===2?qt.SEQUENCE:r.numValues===1?qt.CONST:qt.FLAT}class Lp extends mu{getValueFromBuffer(e){return this.dataBuffer[e]}}class Rp extends Sp{constructor(e,i,s,a){super(e,BigInt64Array.of(i),s,a)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}}class ka{_geometryOffsets;_partOffsets;_ringOffsets;constructor(e,i,s){this._geometryOffsets=e,this._partOffsets=i,this._ringOffsets=s}get geometryOffsets(){return this._geometryOffsets}get partOffsets(){return this._partOffsets}get ringOffsets(){return this._ringOffsets}}function Bh(r,e,i){return{x:Fp(r,e)-i,y:Fp(r>>1,e)-i}}function Fp(r,e){let i=0;for(let s=0;s<e;s++)i|=(r&1<<2*s)>>s;return i}(function(r){r[r.POINT=0]="POINT",r[r.LINESTRING=1]="LINESTRING",r[r.POLYGON=2]="POLYGON",r[r.MULTIPOINT=3]="MULTIPOINT",r[r.MULTILINESTRING=4]="MULTILINESTRING",r[r.MULTIPOLYGON=5]="MULTIPOLYGON"})(oi||(oi={})),(function(r){r[r.POINT=0]="POINT",r[r.LINESTRING=1]="LINESTRING",r[r.POLYGON=2]="POLYGON"})(Pp||(Pp={})),(function(r){r[r.MORTON=0]="MORTON",r[r.VEC_2=1]="VEC_2",r[r.VEC_3=2]="VEC_3"})(xr||(xr={}));class Jg{createPoint(e){return[[e]]}createMultiPoint(e){return e.map((i=>[i]))}createLineString(e){return[e]}createMultiLineString(e){return e}createPolygon(e,i){return[e].concat(i)}createMultiPolygon(e){return e.flat()}}function Bp(r){const e=new Array(r.numGeometries);let i=1,s=1,a=1,u=0;const h=new Jg;let f=0,g=0;const y=r.mortonSettings,x=r.topologyVector,b=x.geometryOffsets,S=x.partOffsets,P=x.ringOffsets,I=r.vertexOffsets,A=r.containsPolygonGeometry(),L=r.vertexBuffer;for(let O=0;O<r.numGeometries;O++){const G=r.geometryType(O);if(G===oi.POINT){if(I&&I.length!==0)if(r.vertexBufferType===xr.VEC_2){const B=2*I[g++],V=new Te(L[B],L[B+1]);e[u++]=h.createPoint(V)}else{const B=Bh(L[I[g++]],y.numBits,y.coordinateShift),V=new Te(B.x,B.y);e[u++]=h.createPoint(V)}else{const B=new Te(L[f++],L[f++]);e[u++]=h.createPoint(B)}b&&a++,S&&i++,P&&s++}else if(G===oi.MULTIPOINT){const B=b[a]-b[a-1];a++;const V=new Array(B);if(I&&I.length!==0){for(let W=0;W<B;W++){const ee=2*I[g++];V[W]=new Te(L[ee],L[ee+1])}e[u++]=h.createMultiPoint(V)}else{for(let W=0;W<B;W++){const ee=L[f++],ae=L[f++];V[W]=new Te(ee,ae)}e[u++]=h.createMultiPoint(V)}}else if(G===oi.LINESTRING){let B,V=0;A?(V=P[s]-P[s-1],s++):V=S[i]-S[i-1],i++,I&&I.length!==0?(B=r.vertexBufferType===xr.VEC_2?Vh(L,I,g,V,!1):Nh(L,I,g,V,!1,y),g+=V):(B=Oh(L,f,V,!1),f+=2*V),e[u++]=h.createLineString(B),b&&a++}else if(G===oi.POLYGON){const B=S[i]-S[i-1];i++;const V=new Array(B-1);let W=P[s]-P[s-1];if(s++,I&&I.length!==0){const ee=r.vertexBufferType===xr.VEC_2?xu(L,I,g,W):bu(L,I,g,W,0,y);g+=W;for(let ae=0;ae<V.length;ae++)W=P[s]-P[s-1],s++,V[ae]=r.vertexBufferType===xr.VEC_2?xu(L,I,g,W):bu(L,I,g,W,0,y),g+=W;e[u++]=h.createPolygon(ee,V)}else{const ee=vu(L,f,W);f+=2*W;for(let ae=0;ae<V.length;ae++)W=P[s]-P[s-1],s++,V[ae]=vu(L,f,W),f+=2*W;e[u++]=h.createPolygon(ee,V)}b&&a++}else if(G===oi.MULTILINESTRING){const B=b[a]-b[a-1];a++;const V=new Array(B);if(I&&I.length!==0){for(let W=0;W<B;W++){let ee=0;A?(ee=P[s]-P[s-1],s++):ee=S[i]-S[i-1],i++;const ae=r.vertexBufferType===xr.VEC_2?Vh(L,I,g,ee,!1):Nh(L,I,g,ee,!1,y);V[W]=ae,g+=ee}e[u++]=h.createMultiLineString(V)}else{for(let W=0;W<B;W++){let ee=0;A?(ee=P[s]-P[s-1],s++):ee=S[i]-S[i-1],i++,V[W]=Oh(L,f,ee,!1),f+=2*ee}e[u++]=h.createMultiLineString(V)}}else{if(G!==oi.MULTIPOLYGON)throw new Error("The specified geometry type is currently not supported.");{const B=b[a]-b[a-1];a++;const V=new Array(B);let W=0;if(I&&I.length!==0){for(let ee=0;ee<B;ee++){const ae=S[i]-S[i-1];i++;const _e=new Array(ae-1);W=P[s]-P[s-1],s++;const ye=r.vertexBufferType===xr.VEC_2?xu(L,I,g,W):bu(L,I,g,W,0,y);g+=W;for(let xe=0;xe<_e.length;xe++)W=P[s]-P[s-1],s++,_e[xe]=r.vertexBufferType===xr.VEC_2?xu(L,I,g,W):bu(L,I,g,W,0,y),g+=W;V[ee]=h.createPolygon(ye,_e)}e[u++]=h.createMultiPolygon(V)}else{for(let ee=0;ee<B;ee++){const ae=S[i]-S[i-1];i++;const _e=new Array(ae-1);W=P[s]-P[s-1],s++;const ye=vu(L,f,W);f+=2*W;for(let xe=0;xe<_e.length;xe++){const Ee=P[s]-P[s-1];s++,_e[xe]=vu(L,f,Ee),f+=2*Ee}V[ee]=h.createPolygon(ye,_e)}e[u++]=h.createMultiPolygon(V)}}}}return e}function vu(r,e,i){return Oh(r,e,i,!0)}function xu(r,e,i,s){return Vh(r,e,i,s,!0)}function bu(r,e,i,s,a,u){return Nh(r,e,i,s,!0,u)}function Oh(r,e,i,s){const a=new Array(s?i+1:i);for(let u=0;u<2*i;u+=2)a[u/2]=new Te(r[e+u],r[e+u+1]);return s&&(a[a.length-1]=a[0]),a}function Vh(r,e,i,s,a){const u=new Array(a?s+1:s);for(let h=0;h<2*s;h+=2){const f=2*e[i+h/2];u[h/2]=new Te(r[f],r[f+1])}return a&&(u[u.length-1]=u[0]),u}function Nh(r,e,i,s,a,u){const h=new Array(a?s+1:s);for(let f=0;f<s;f++){const g=Bh(r[e[i+f]],u.numBits,u.coordinateShift);h[f]=new Te(g.x,g.y)}return a&&(h[h.length-1]=h[0]),h}class Op{_vertexBufferType;_topologyVector;_vertexOffsets;_vertexBuffer;_mortonSettings;constructor(e,i,s,a,u){this._vertexBufferType=e,this._topologyVector=i,this._vertexOffsets=s,this._vertexBuffer=a,this._mortonSettings=u}get vertexBufferType(){return this._vertexBufferType}get topologyVector(){return this._topologyVector}get vertexOffsets(){return this._vertexOffsets}get vertexBuffer(){return this._vertexBuffer}*[Symbol.iterator](){const e=Bp(this);let i=0;for(;i<this.numGeometries;)yield{coordinates:e[i],type:this.geometryType(i)},i++}getSimpleEncodedVertex(e){const i=this.vertexOffsets?2*this.vertexOffsets[e]:2*e;return[this.vertexBuffer[i],this.vertexBuffer[i+1]]}getVertex(e){if(this.vertexOffsets&&this.mortonSettings){const s=Bh(this.vertexBuffer[this.vertexOffsets[e]],this.mortonSettings.numBits,this.mortonSettings.coordinateShift);return[s.x,s.y]}const i=this.vertexOffsets?2*this.vertexOffsets[e]:2*e;return[this.vertexBuffer[i],this.vertexBuffer[i+1]]}getGeometries(){return Bp(this)}get mortonSettings(){return this._mortonSettings}}class Vp extends Op{_numGeometries;_geometryType;constructor(e,i,s,a,u,h,f){super(s,a,u,h,f),this._numGeometries=e,this._geometryType=i}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===oi.POLYGON||this._geometryType===oi.MULTIPOLYGON}containsSingleGeometryType(){return!0}}class Np extends Op{_geometryTypes;constructor(e,i,s,a,u,h){super(e,s,a,u,h),this._geometryTypes=i}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)===oi.POLYGON||this.geometryType(e)===oi.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}}class jp{_triangleOffsets;_indexBuffer;_vertexBuffer;_topologyVector;constructor(e,i,s,a){this._triangleOffsets=e,this._indexBuffer=i,this._vertexBuffer=s,this._topologyVector=a}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),i=this._topologyVector,s=i.partOffsets,a=i.ringOffsets,u=i.geometryOffsets;let h=0,f=1,g=1,y=1;for(let x=0;x<this.numGeometries;x++)switch(this.geometryType(x)){case oi.POLYGON:{const b=s[f]-s[f-1];f++;const S=[];for(let P=0;P<b;P++){const I=a[g]-a[g-1];g++;const A=[];for(let L=0;L<I;L++){const O=this._vertexBuffer[h++],G=this._vertexBuffer[h++];A.push(new Te(O,G))}A.length>0&&A.push(A[0]),S.push(A)}e[x]=S,u&&y++}break;case oi.MULTIPOLYGON:{const b=u[y]-u[y-1];y++;const S=[];for(let P=0;P<b;P++){const I=s[f]-s[f-1];f++;for(let A=0;A<I;A++){const L=a[g]-a[g-1];g++;const O=[];for(let G=0;G<L;G++){const B=this._vertexBuffer[h++],V=this._vertexBuffer[h++];O.push(new Te(B,V))}O.length>0&&O.push(O[0]),S.push(O)}}e[x]=S}}return e}[Symbol.iterator](){return null}}function Up(r,e,i,s,a,u){return new Qg(r,e,i,s,a,u)}class Qg extends jp{_numGeometries;_geometryType;constructor(e,i,s,a,u,h){super(s,a,u,h),this._numGeometries=e,this._geometryType=i}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}}function Gp(r,e,i,s,a){return new e_(r,e,i,s,a)}class e_ extends jp{_geometryTypes;constructor(e,i,s,a,u){super(i,s,a,u),this._geometryTypes=e}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}}function t_(r,e,i,s,a){const u=Bi(r,i);let h=null,f=null,g=null,y=null;if(yu(u,s,r,i)===qt.CONST){const G=Fh(r,i,u,!1);let B=null,V=null,W=null,ee=null;for(let ae=0;ae<e-1;ae++){const _e=Bi(r,i);switch(_e.physicalStreamType){case vi.LENGTH:switch(_e.logicalStreamType.lengthType){case ur.GEOMETRIES:B=Is(r,i,_e);break;case ur.PARTS:V=Is(r,i,_e);break;case ur.RINGS:W=Is(r,i,_e);break;case ur.TRIANGLES:ee=Is(r,i,_e)}break;case vi.OFFSET:switch(_e.logicalStreamType.offsetType){case Io.VERTEX:h=Oi(r,i,_e,!1);break;case Io.INDEX:y=Oi(r,i,_e,!1)}break;case vi.DATA:Kr.VERTEX===_e.logicalStreamType.dictionaryType?f=Oi(r,i,_e,!0):(g={numBits:_e.numBits,coordinateShift:_e.coordinateShift},f=Oi(r,i,_e,!1))}}return y!==null?B!=null||V!=null?Up(s,G,ee,y,f,new ka(B,V,W)):Up(s,G,ee,y,f):g===null?(function(ae,_e,ye,xe,Ee){return new Vp(ae,_e,xr.VEC_2,ye,xe,Ee)})(s,G,new ka(B,V,W),h,f):(function(ae,_e,ye,xe,Ee,we){return new Vp(ae,_e,xr.MORTON,ye,xe,Ee,we)})(s,G,new ka(B,V,W),h,f,g)}const x=Oi(r,i,u,!1);let b=null,S=null,P=null,I=null;for(let G=0;G<e-1;G++){const B=Bi(r,i);switch(B.physicalStreamType){case vi.LENGTH:switch(B.logicalStreamType.lengthType){case ur.GEOMETRIES:b=Oi(r,i,B,!1);break;case ur.PARTS:S=Oi(r,i,B,!1);break;case ur.RINGS:P=Oi(r,i,B,!1);break;case ur.TRIANGLES:I=Is(r,i,B)}break;case vi.OFFSET:switch(B.logicalStreamType.offsetType){case Io.VERTEX:h=Oi(r,i,B,!1);break;case Io.INDEX:y=Oi(r,i,B,!1)}break;case vi.DATA:Kr.VERTEX===B.logicalStreamType.dictionaryType?f=Oi(r,i,B,!0):(g={numBits:B.numBits,coordinateShift:B.coordinateShift},f=Oi(r,i,B,!1))}}let A=null,L=null,O=null;return b!==null?(A=jh(x,b,2),S!==null&&P!==null?(L=qp(x,A,S,!1),O=(function(G,B,V,W){const ee=new Uint32Array(V[V.length-1]+1);let ae=0;ee[0]=ae;let _e=1,ye=1,xe=0;for(let Ee=0;Ee<G.length;Ee++){const we=G[Ee],ve=B[Ee+1]-B[Ee];if(we!==0&&we!==3)for(let fe=0;fe<ve;fe++){const ze=V[_e]-V[_e-1];_e++;for(let Le=0;Le<ze;Le++)ae=ee[ye++]=ae+W[xe++]}else for(let fe=0;fe<ve;fe++)ee[ye++]=++ae,_e++}return ee})(x,A,L,P)):S!==null&&(L=(function(G,B,V){const W=new Uint32Array(B[B.length-1]+1);let ee=0;W[0]=ee;let ae=1,_e=0;for(let ye=0;ye<G.length;ye++){const xe=G[ye],Ee=B[ye+1]-B[ye];if(xe===4||xe===1)for(let we=0;we<Ee;we++)ee=W[ae++]=ee+V[_e++];else for(let we=0;we<Ee;we++)W[ae++]=++ee}return W})(x,A,S))):S!==null&&P!==null?(L=jh(x,S,1),O=qp(x,L,P,!0)):S!==null&&(L=jh(x,S,0)),y!==null&&L===null?Gp(x,I,y,f):y!==null?Gp(x,I,y,f,new ka(A,L,O)):g===null?(function(G,B,V,W){return new Np(xr.VEC_2,G,B,V,W)})(x,new ka(A,L,O),h,f):(function(G,B,V,W,ee){return new Np(xr.MORTON,G,B,V,W,ee)})(x,new ka(A,L,O),h,f,g)}function jh(r,e,i){const s=new Uint32Array(r.length+1);let a=0;s[0]=a;let u=0;for(let h=0;h<r.length;h++)a=s[h+1]=a+(r[h]>i?e[u++]:1);return s}function qp(r,e,i,s){const a=new Uint32Array(e[e.length-1]+1);let u=0;a[0]=u;let h=1,f=0;for(let g=0;g<r.length;g++){const y=r[g],x=e[g+1]-e[g];if(y===5||y===2||s&&(y===4||y===1))for(let b=0;b<x;b++)u=a[h++]=u+i[f++];else for(let b=0;b<x;b++)a[h++]=++u}return a}class i_ extends Da{dataVector;constructor(e,i,s){super(e,i.getBuffer(),s),this.dataVector=i}getValueFromBuffer(e){return this.dataVector.get(e)}}class r_ extends mu{getValueFromBuffer(e){return this.dataBuffer[e]}}class Zp extends Da{constructor(e,i,s){super(e,BigInt64Array.of(i),s)}getValueFromBuffer(e){return this.dataBuffer[0]}}function ql(r,e,i,s,a){const u=(function(h,f,g,y){const x=new Uint8Array(f);let b=0;const S=y.get()+g;for(;b<f&&!(y.get()>=S);){const P=h[y.increment()];if(P<=127){const I=P+3,A=h[y.increment()],L=Math.min(b+I,f);x.fill(A,b,L),b=L}else{const I=256-P;for(let A=0;A<I&&b<f;A++)x[b++]=h[y.increment()]}}return y.set(S),x})(r,Math.ceil(e/8),i,s);return a?(function(h,f,g){if(!g)return h;const y=g.size(),x=new Jr(h,f),b=new Jr(new Uint8Array(Math.ceil(y/8)),y);let S=0;for(let P=0;P<y;P++){const I=!!g.get(P)&&x.get(S++);b.set(P,I)}return b.getBuffer()})(u,e,a):u}const n_=new TextDecoder;function Uh(r,e,i){return i-e>=12?n_.decode(r.subarray(e,i)):(function(s,a,u){let h="",f=a;for(;f<u;){const g=s[f];let y,x,b,S=null,P=g>239?4:g>223?3:g>191?2:1;if(f+P>u)break;P===1?g<128&&(S=g):P===2?(y=s[f+1],(192&y)==128&&(S=(31&g)<<6|63&y,S<=127&&(S=null))):P===3?(y=s[f+1],x=s[f+2],(192&y)==128&&(192&x)==128&&(S=(15&g)<<12|(63&y)<<6|63&x,(S<=2047||S>=55296&&S<=57343)&&(S=null))):P===4&&(y=s[f+1],x=s[f+2],b=s[f+3],(192&y)==128&&(192&x)==128&&(192&b)==128&&(S=(15&g)<<18|(63&y)<<12|(63&x)<<6|63&b,(S<=65535||S>=1114112)&&(S=null))),S===null?(S=65533,P=1):S>65535&&(S-=65536,h+=String.fromCharCode(S>>>10&1023|55296),S=56320|1023&S),h+=String.fromCharCode(S),f+=P}return h})(r,e,i)}class Gh extends Da{offsetBuffer;constructor(e,i,s,a){super(e,s,a),this.offsetBuffer=i}}class $p extends Gh{textEncoder;constructor(e,i,s,a){super(e,i,s,a??i.length-1),this.textEncoder=new TextEncoder}getValueFromBuffer(e){return Uh(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}}class La extends Gh{indexBuffer;textEncoder;constructor(e,i,s,a,u){super(e,s,a,u??i.length),this.indexBuffer=i,this.indexBuffer=i,this.textEncoder=new TextEncoder}getValueFromBuffer(e){const i=this.indexBuffer[e];return Uh(this.dataBuffer,this.offsetBuffer[i],this.offsetBuffer[i+1])}}class Hp extends Gh{indexBuffer;symbolOffsetBuffer;symbolTableBuffer;textEncoder;symbolLengthBuffer;lengthBuffer;decodedDictionary;constructor(e,i,s,a,u,h,f){super(e,s,a,f),this.indexBuffer=i,this.symbolOffsetBuffer=u,this.symbolTableBuffer=h,this.textEncoder=new TextEncoder}getValueFromBuffer(e){this.decodedDictionary==null&&(this.symbolLengthBuffer==null&&(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer),this.lengthBuffer=this.offsetToLengthBuffer(this.offsetBuffer)),this.decodedDictionary=(function(s,a,u){const h=[],f=new Array(a.length).fill(0);for(let g=1;g<a.length;g++)f[g]=f[g-1]+a[g-1];for(let g=0;g<u.length;g++)if(u[g]===255)h.push(u[++g]);else{const y=a[u[g]],x=f[u[g]];for(let b=0;b<y;b++)h.push(s[x+b])}return new Uint8Array(h)})(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer));const i=this.indexBuffer[e];return Uh(this.decodedDictionary,this.offsetBuffer[i],this.offsetBuffer[i+1])}offsetToLengthBuffer(e){const i=new Uint32Array(e.length-1);let s=e[0];for(let a=1;a<e.length;a++){const u=e[a];i[a-1]=u-s,s=u}return i}}function s_(r,e,i,s,a,u){return i.type==="scalarType"?(function(h,f,g,y,x,b){let S=null,P=0;if(h===0)return null;if(b.nullable){const A=Bi(f,g);P=A.numValues;const L=g.get(),O=ql(f,P,A.byteLength,g);g.set(L+A.byteLength),S=new Jr(O,A.numValues)}const I=S??y;switch(x.physicalType){case 4:case 3:return(function(A,L,O,G,B){const V=Bi(A,L),W=yu(V,B,A,L),ee=G.physicalType===3;if(W===qt.FLAT){const ae=Oi(A,L,V,ee,0,Zl(B)?B:void 0);return new Ah(O.name,ae,B)}if(W===qt.SEQUENCE){const ae=Ap(A,L,V);return new zh(O.name,ae[0],ae[1],V.numRleValues)}{const ae=Fh(A,L,V,ee);return new kh(O.name,ae,B)}})(f,g,b,x,I);case 9:return(function(A,L,O,G,B){let V=null,W=null,ee=null,ae=null,_e=null,ye=null,xe=null,Ee=null;for(let we=0;we<G;we++){const ve=Bi(L,O);if(ve.byteLength!==0)switch(ve.physicalStreamType){case vi.PRESENT:{const fe=ql(L,ve.numValues,ve.byteLength,O);ye=new Jr(fe,ve.numValues);break}case vi.OFFSET:W=Oi(L,O,ve,!1,0,B!=null||ye!=null?B??ye:void 0);break;case vi.LENGTH:{const fe=Is(L,O,ve);ur.DICTIONARY===ve.logicalStreamType.lengthType?V=fe:ur.SYMBOL===ve.logicalStreamType.lengthType?ae=fe:xe=fe;break}case vi.DATA:{const fe=L.subarray(O.get(),O.get()+ve.byteLength);O.add(ve.byteLength);const ze=ve.logicalStreamType.dictionaryType;Kr.FSST===ze?_e=fe:Kr.SINGLE===ze||Kr.SHARED===ze?ee=fe:Kr.NONE===ze&&(Ee=fe);break}}}return(function(we,ve,fe,ze,Le,Ve,Fe){return ve?new Hp(we,fe,ze,Le,Ve,ve,Fe):null})(A,_e,W,V,ee,ae,B??ye)??(function(we,ve,fe,ze,Le){return ve?Le?new La(we,fe,ze,ve,Le):new La(we,fe,ze,ve):null})(A,ee,W,V,B??ye)??(function(we,ve,fe,ze,Le){if(!ve||!fe)return null;if(ze)return Le?new La(we,ze,ve,fe,Le):new La(we,ze,ve,fe);if(Le&&Le.size()!==ve.length-1){const Ve=new Int32Array(Le.size());let Fe=0;for(let it=0;it<Le.size();it++)Ve[it]=Le.get(it)?Fe++:0;return new La(we,Ve,ve,fe,Le)}return Le?new $p(we,ve,fe,Le):new $p(we,ve,fe)})(A,xe,Ee,W,B??ye)})(b.name,f,g,b.nullable?h-1:h,S);case 0:return(function(A,L,O,G,B){const V=Bi(A,L),W=V.numValues,ee=L.get(),ae=Zl(B)?B:void 0,_e=ql(A,W,V.byteLength,L,ae);L.set(ee+V.byteLength);const ye=new Jr(_e,W);return new i_(O.name,ye,B)})(f,g,b,0,I);case 6:case 5:return(function(A,L,O,G,B){const V=Bi(A,L),W=yu(V,G,A,L),ee=B.physicalType===5;if(W===qt.FLAT){const ae=zp(A,L,V,ee,Zl(G)?G:void 0);return new Lp(O.name,ae,G)}if(W===qt.SEQUENCE){const ae=Dp(A,L,V);return new Rp(O.name,ae[0],ae[1],V.numRleValues)}{const ae=kp(A,L,V,ee);return new Zp(O.name,ae,G)}})(f,g,b,I,x);case 7:return(function(A,L,O,G){const B=Bi(A,L),V=Zl(G)?G:void 0,W=(function(ee,ae,_e,ye){const xe=ae.get(),Ee=xe+_e*Float32Array.BYTES_PER_ELEMENT,we=new Uint8Array(ee.subarray(xe,Ee)).buffer,ve=new Float32Array(we);return ae.set(Ee),ye?gu(ve,ye,0):ve})(A,L,B.numValues,V);return new r_(O.name,W,G)})(f,g,b,I);case 8:return(function(A,L,O,G){const B=Bi(A,L),V=Zl(G)?G:void 0,W=(function(ee,ae,_e,ye){const xe=ae.get(),Ee=xe+_e*Float64Array.BYTES_PER_ELEMENT,we=new Uint8Array(ee.subarray(xe,Ee)).buffer,ve=new Float64Array(we);return ae.set(Ee),ye?gu(ve,ye,0):ve})(A,L,B.numValues,V);return new Dh(O.name,W,G)})(f,g,b,I);default:throw new Error(`The specified data type for the field is currently not supported: ${x}`)}})(s,r,e,a,i.scalarType,i):s===0?null:(function(h,f,g,y){let x=null,b=null,S=null,P=null,I=!1;for(;!I;){const G=Bi(h,f);switch(G.physicalStreamType){case vi.LENGTH:ur.DICTIONARY===G.logicalStreamType.lengthType?x=Is(h,f,G):S=Is(h,f,G);break;case vi.DATA:Kr.SINGLE===G.logicalStreamType.dictionaryType||Kr.SHARED===G.logicalStreamType.dictionaryType?(b=h.subarray(f.get(),f.get()+G.byteLength),I=!0):P=h.subarray(f.get(),f.get()+G.byteLength),f.add(G.byteLength)}}const A=g.complexType.children,L=[];let O=0;for(const G of A){const B=Ei(h,f,1)[0];if(B==0)continue;const V=G.name?`${g.name}${G.name}`:g.name;if(B!==2||G.type!=="scalarField"||G.scalarField.physicalType!==9)throw new Error("Currently only optional string fields are implemented for a struct.");const W=Bi(h,f),ee=ql(h,W.numValues,W.byteLength,f),ae=Bi(h,f),_e=Oi(h,f,ae,!1,0,ae.decompressedCount!==y?new Jr(ee,W.numValues):void 0);L[O++]=P?new Hp(V,_e,x,b,S,P,new Jr(ee,W.numValues)):new La(V,_e,x,b,new Jr(ee,W.numValues))}return L})(r,e,i,a)}function Zl(r){return r instanceof Jr}function Wp(r){switch(r){case 0:case 1:case 2:case 3:{const e={};e.nullable=!!(1&r),e.columnScope=0;const i={};return i.physicalType=r>1?6:4,i.type="physicalType",e.scalarType=i,e.type="scalarType",e}case 4:{const e={nullable:!1,columnScope:0},i={type:"physicalType",physicalType:0};return e.type="complexType",e.complexType=i,e}case 30:{const e={nullable:!1,columnScope:0},i={type:"physicalType",physicalType:1};return e.type="complexType",e.complexType=i,e}default:return(function(e){let i=null;switch(e){case 10:case 11:i=0;break;case 12:case 13:i=1;break;case 14:case 15:i=2;break;case 16:case 17:i=3;break;case 18:case 19:i=4;break;case 20:case 21:i=5;break;case 22:case 23:i=6;break;case 24:case 25:i=7;break;case 26:case 27:i=8;break;case 28:case 29:i=9;break;default:return null}const s={};s.nullable=!!(1&e),s.columnScope=0;const a={type:"physicalType"};return a.physicalType=i,s.type="scalarType",s.scalarType=a,s})(r)}}function Xp(r){return r>=10}function Yp(r){return r===30}function o_(r){if(r.name==="id")return!1;if(r.type==="scalarType"){const e=r.scalarType;if(e.type==="physicalType")switch(e.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(e.type==="logicalType")return!1}else if(r.type==="complexType"){const e=r.complexType;if(e.type==="physicalType")switch(e.physicalType){case 0:case 1:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",r),!1}const a_=new TextDecoder;function qh(r,e){const i=Ei(r,e,1)[0];if(i===0)return"";const s=e.get(),a=r.subarray(s,s+i);return e.add(i),a_.decode(a)}function Kp(r,e){const i=Ei(r,e,1)[0]>>>0;if(i<10||i>30)throw new Error(`Unsupported field type code ${i}. Supported: 10-29(scalars), 30(STRUCT)`);const s=Wp(i);if(Xp(i)&&(s.name=qh(r,e)),Yp(i)){const a=Ei(r,e,1)[0]>>>0;s.complexType.children=new Array(a);for(let u=0;u<a;u++)s.complexType.children[u]=Kp(r,e)}return(function(a){return{name:a.name,nullable:a.nullable,scalarField:a.scalarType,complexField:a.complexType,type:a.type==="scalarType"?"scalarField":"complexField"}})(s)}function l_(r,e){const i=Ei(r,e,1)[0]>>>0,s=Wp(i);if(!s)throw new Error(`Unsupported column type code ${i}. Supported: 0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT)`);if(Xp(i)?s.name=qh(r,e):i>=0&&i<=3?s.name="id":i===4&&(s.name="geometry"),Yp(i)){const a=Ei(r,e,1)[0]>>>0,u=s.complexType;u.children=new Array(a);for(let h=0;h<a;h++)u.children[h]=Kp(r,e)}return s}function c_(r,e){const i={featureTables:[]},s={};s.name=qh(r,e);const a=Ei(r,e,1)[0]>>>0,u=Ei(r,e,1)[0]>>>0;s.columns=new Array(u);for(let h=0;h<u;h++)s.columns[h]=l_(r,e);return i.featureTables.push(s),[i,a]}function u_(r,e,i,s,a,u,h=!1){const f=e.scalarType.physicalType,g=yu(a,u,r,i);if(f===4)switch(g){case qt.FLAT:{const y=Oi(r,i,a,!1);return new Ah(s,y,u)}case qt.SEQUENCE:{const y=Ap(r,i,a);return new zh(s,y[0],y[1],a.numRleValues)}case qt.CONST:{const y=Fh(r,i,a,!1);return new kh(s,y,u)}}else switch(g){case qt.FLAT:{if(h){const x=(function(b,S,P){const I=(function(A,L,O){const G=new Float64Array(O);for(let B=0;B<O;B++)G[B]=Kg(A,L);return G})(b,S,P.numValues);return(function(A,L){switch(L.logicalLevelTechnique1){case ft.DELTA:return L.logicalLevelTechnique2===ft.RLE&&(A=Ip(A,L.runs,L.numRleValues)),(function(O){O[0]=za(O[0]);const G=O.length/4*4;let B=1;if(G>=4)for(;B<G-4;B+=4){const V=O[B+1],W=O[B+2],ee=O[B+3];O[B]=za(O[B])+O[B-1],O[B+1]=za(V)+O[B],O[B+2]=za(W)+O[B+1],O[B+3]=za(ee)+O[B+2]}for(;B!=O.length;++B)O[B]=za(O[B])+O[B-1]})(A),A;case ft.RLE:return(function(O,G){return Ip(O,G.runs,G.numRleValues)})(A,L);case ft.NONE:return A;default:throw new Error(`The specified Logical level technique is not supported: ${L.logicalLevelTechnique1}`)}})(I,P)})(r,i,a);return new Dh(s,x,u)}const y=zp(r,i,a,!1);return new Lp(s,y,u)}case qt.SEQUENCE:{const y=Dp(r,i,a);return new Rp(s,y[0],y[1],a.numRleValues)}case qt.CONST:{const y=kp(r,i,a,!1);return new Zp(s,y,u)}}throw new Error("Vector type not supported for id column.")}class h_{constructor(e,i){var s;switch(this._featureData=e,this.properties=this._featureData.properties||{},(s=this._featureData.geometry)===null||s===void 0?void 0:s.type){case oi.POINT:case oi.MULTIPOINT:this.type=1;break;case oi.LINESTRING:case oi.MULTILINESTRING:this.type=2;break;case oi.POLYGON:case oi.MULTIPOLYGON:this.type=3;break;default:this.type=0}this.extent=i,this.id=Number(this._featureData.id)}loadGeometry(){const e=[];for(const i of this._featureData.geometry.coordinates){const s=[];for(const a of i)s.push(new Te(a.x,a.y));e.push(s)}return e}}class d_{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 h_(this.features[e],this.extent)}}class Jp{constructor(e){this.layers={};const i=(function(s,a,u=!0){const h=new Xg(0),f=[];for(;h.get()<s.length;){const g=Ei(s,h,1)[0]>>>0,y=h.get()+g;if(y>s.length)throw new Error(`Block overruns tile: ${y} > ${s.length}`);if(Ei(s,h,1)[0]>>>0!=1){h.set(y);continue}const x=c_(s,h),b=x[1],S=x[0].featureTables[0];let P=null,I=null;const A=[];let L=0;for(const G of S.columns){const B=G.name;if(B==="id"){let V=null;if(G.nullable){const ee=Bi(s,h),ae=h.get(),_e=ql(s,ee.numValues,ee.byteLength,h);h.set(ae+ee.byteLength),V=new Jr(_e,ee.numValues)}const W=Bi(s,h);L=W.decompressedCount,P=u_(s,G,h,B,W,V??L,u)}else if(B==="geometry"){const V=Ei(s,h,1)[0];if(L===0){const W=h.get();L=Bi(s,h).decompressedCount,h.set(W)}I=t_(s,V,h,L)}else{const V=o_(G)?Ei(s,h,1)[0]:1;if(V===0)continue;const W=s_(s,h,G,V,L);if(W)if(Array.isArray(W))for(const ee of W)A.push(ee);else A.push(W)}}const O=new Wg(S.name,I,P,A,b);f.push(O),h.set(y)}return f})(new Uint8Array(e));this.layers=i.reduce(((s,a)=>Object.assign(Object.assign({},s),{[a.name]:new d_(a)})),{})}}class p_{constructor(e,i){this.feature=e,this.type=e.type,this.properties=e.tags?e.tags:{},this.extent=i,"id"in e&&(typeof e.id=="string"?this.id=parseInt(e.id,10):typeof e.id!="number"||isNaN(e.id)||(this.id=e.id))}loadGeometry(){const e=[],i=this.feature.type===1?[this.feature.geometry]:this.feature.geometry;for(const s of i){const a=[];for(const u of s)a.push(new Te(u[0],u[1]));e.push(a)}return e}}const $l="_geojsonTileLayer";function f_(r,e){e.writeVarintField(15,r.version||1),e.writeStringField(1,r.name||""),e.writeVarintField(5,r.extent||4096);const i={keys:[],values:[],keycache:{},valuecache:{}};for(let u=0;u<r.length;u++)i.feature=r.feature(u),e.writeMessage(2,m_,i);const s=i.keys;for(const u of s)e.writeStringField(3,u);const a=i.values;for(const u of a)e.writeMessage(4,y_,u)}function m_(r,e){if(!r.feature)return;const i=r.feature;i.id!==void 0&&e.writeVarintField(1,i.id),e.writeMessage(2,g_,r),e.writeVarintField(3,i.type),e.writeMessage(4,__,i)}function g_(r,e){for(const i in r.feature?.properties){let s=r.feature.properties[i],a=r.keycache[i];if(s==null)continue;a===void 0&&(r.keys.push(i),a=r.keys.length-1,r.keycache[i]=a),e.writeVarint(a),typeof s!="string"&&typeof s!="boolean"&&typeof s!="number"&&(s=JSON.stringify(s));const u=typeof s+":"+s;let h=r.valuecache[u];h===void 0&&(r.values.push(s),h=r.values.length-1,r.valuecache[u]=h),e.writeVarint(h)}}function Zh(r,e){return(e<<3)+(7&r)}function Qp(r){return r<<1^r>>31}function __(r,e){const i=r.loadGeometry(),s=r.type;let a=0,u=0;for(const h of i){let f=1;s===1&&(f=h.length),e.writeVarint(Zh(1,f));const g=s===3?h.length-1:h.length;for(let y=0;y<g;y++){y===1&&s!==1&&e.writeVarint(Zh(2,g-1));const x=h[y].x-a,b=h[y].y-u;e.writeVarint(Qp(x)),e.writeVarint(Qp(b)),a+=x,u+=b}r.type===3&&e.writeVarint(Zh(7,1))}}function y_(r,e){const i=typeof r;i==="string"?e.writeStringField(1,r):i==="boolean"?e.writeBooleanField(7,r):i==="number"&&(r%1!=0?e.writeDoubleField(3,r):r<0?e.writeSVarintField(6,r):e.writeVarintField(5,r))}class ef{constructor(e,i){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new Zr(ht,16,0),this.grid3D=new Zr(ht,16,0),this.featureIndexArray=new z,this.promoteId=i}insert(e,i,s,a,u,h){const f=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(s,a,u);const g=h?this.grid3D:this.grid;for(let y=0;y<i.length;y++){const x=i[y],b=[1/0,1/0,-1/0,-1/0];for(let S=0;S<x.length;S++){const P=x[S];b[0]=Math.min(b[0],P.x),b[1]=Math.min(b[1],P.y),b[2]=Math.max(b[2],P.x),b[3]=Math.max(b[3],P.y)}b[0]<ht&&b[1]<ht&&b[2]>=0&&b[3]>=0&&g.insert(f,b[0],b[1],b[2],b[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=this.encoding!=="mlt"?new Vd(new uu(this.rawTileData)).layers:new Jp(this.rawTileData).layers,this.sourceLayerCoder=new wp(this.vtLayers?Object.keys(this.vtLayers).sort():[$l])),this.vtLayers}query(e,i,s,a){this.loadVTLayers();const u=e.params,h=ht/e.tileSize/e.scale,f=no(u.filter,u.globalState),g=e.queryGeometry,y=e.queryPadding*h,x=Co.fromPoints(g),b=this.grid.query(x.minX-y,x.minY-y,x.maxX+y,x.maxY+y),S=Co.fromPoints(e.cameraQueryGeometry).expandBy(y),P=this.grid3D.query(S.minX,S.minY,S.maxX,S.maxY,((L,O,G,B)=>(function(V,W,ee,ae,_e){for(const xe of V)if(W<=xe.x&&ee<=xe.y&&ae>=xe.x&&_e>=xe.y)return!0;const ye=[new Te(W,ee),new Te(W,_e),new Te(ae,_e),new Te(ae,ee)];if(V.length>2){for(const xe of ye)if(wa(V,xe))return!0}for(let xe=0;xe<V.length-1;xe++)if(xm(V[xe],V[xe+1],ye))return!0;return!1})(e.cameraQueryGeometry,L-y,O-y,G+y,B+y)));for(const L of P)b.push(L);b.sort(v_);const I={};let A;for(let L=0;L<b.length;L++){const O=b[L];if(O===A)continue;A=O;const G=this.featureIndexArray.get(O);let B=null;this.loadMatchingFeature(I,G.bucketIndex,G.sourceLayerIndex,G.featureIndex,f,u.layers,u.availableImages,i,s,a,((V,W,ee)=>(B||(B=Ki(V)),W.queryIntersectsFeature({queryGeometry:g,feature:V,featureState:ee,geometry:B,zoom:this.z,transform:e.transform,pixelsToTileUnits:h,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation}))))}return I}loadMatchingFeature(e,i,s,a,u,h,f,g,y,x,b){const S=this.bucketLayerIDs[i];if(h&&!S.some((L=>h.has(L))))return;const P=this.sourceLayerCoder.decode(s),I=this.vtLayers[P].feature(a);if(u.needGeometry){const L=yn(I,!0);if(!u.filter(new vt(this.tileID.overscaledZ),L,this.tileID.canonical))return}else if(!u.filter(new vt(this.tileID.overscaledZ),I))return;const A=this.getId(I,P);for(let L=0;L<S.length;L++){const O=S[L];if(h&&!h.has(O))continue;const G=g[O];if(!G)continue;let B={};A&&x&&(B=x.getState(G.sourceLayer||$l,A));const V=ki({},y[O]);V.paint=tf(V.paint,G.paint,I,B,f),V.layout=tf(V.layout,G.layout,I,B,f);const W=!b||b(I,G,B);if(!W)continue;const ee=new Tp(I,this.z,this.x,this.y,A);ee.layer=V;let ae=e[O];ae===void 0&&(ae=e[O]=[]),ae.push({featureIndex:a,feature:ee,intersectionZ:W})}}lookupSymbolFeatures(e,i,s,a,u,h,f,g){const y={};this.loadVTLayers();const x=no(u.filterSpec,u.globalState);for(const b of e)this.loadMatchingFeature(y,s,a,b,x,h,f,g,i);return y}hasLayer(e){for(const i of this.bucketLayerIDs)for(const s of i)if(e===s)return!0;return!1}getId(e,i){var s;let a=e.id;return this.promoteId&&(a=e.properties[typeof this.promoteId=="string"?this.promoteId:this.promoteId[i]],typeof a=="boolean"&&(a=Number(a)),a===void 0&&(!((s=e.properties)===null||s===void 0)&&s.cluster)&&this.promoteId&&(a=Number(e.properties.cluster_id))),a}}function tf(r,e,i,s,a){return wn(r,((u,h)=>{const f=e instanceof _o?e.get(h):null;return f&&f.evaluate?f.evaluate(i,s,a):f}))}function v_(r,e){return e-r}function rf(r,e,i,s,a){const u=[];for(let h=0;h<r.length;h++){const f=r[h];let g;for(let y=0;y<f.length-1;y++){let x=f[y],b=f[y+1];x.x<e&&b.x<e||(x.x<e?x=new Te(e,x.y+(e-x.x)/(b.x-x.x)*(b.y-x.y))._round():b.x<e&&(b=new Te(e,x.y+(e-x.x)/(b.x-x.x)*(b.y-x.y))._round()),x.y<i&&b.y<i||(x.y<i?x=new Te(x.x+(i-x.y)/(b.y-x.y)*(b.x-x.x),i)._round():b.y<i&&(b=new Te(x.x+(i-x.y)/(b.y-x.y)*(b.x-x.x),i)._round()),x.x>=s&&b.x>=s||(x.x>=s?x=new Te(s,x.y+(s-x.x)/(b.x-x.x)*(b.y-x.y))._round():b.x>=s&&(b=new Te(s,x.y+(s-x.x)/(b.x-x.x)*(b.y-x.y))._round()),x.y>=a&&b.y>=a||(x.y>=a?x=new Te(x.x+(a-x.y)/(b.y-x.y)*(b.x-x.x),a)._round():b.y>=a&&(b=new Te(x.x+(a-x.y)/(b.y-x.y)*(b.x-x.x),a)._round()),g&&x.equals(g[g.length-1])||(g=[x],u.push(g)),g.push(b)))))}}return u}function nf(r,e,i,s,a){switch(e){case 1:return(function(u,h,f,g){const y=[];for(const x of u)for(const b of x){const S=g===0?b.x:b.y;S>=h&&S<=f&&y.push([b])}return y})(r,i,s,a);case 2:return sf(r,i,s,a,!1);case 3:return sf(r,i,s,a,!0)}return[]}function x_(r,e,i,s,a){const u=s===0?b_:w_;let h=[];const f=[];for(let x=0;x<r.length-1;x++){const b=r[x],S=r[x+1],P=s===0?b.x:b.y,I=s===0?S.x:S.y;let A=!1;P<e?I>e&&h.push(u(b,S,e)):P>i?I<i&&h.push(u(b,S,i)):h.push(b),I<e&&P>=e&&(h.push(u(b,S,e)),A=!0),I>i&&P<=i&&(h.push(u(b,S,i)),A=!0),!a&&A&&(f.push(h),h=[])}const g=r.length-1,y=s===0?r[g].x:r[g].y;return y>=e&&y<=i&&h.push(r[g]),a&&h.length>0&&!h[0].equals(h[h.length-1])&&h.push(new Te(h[0].x,h[0].y)),h.length>0&&f.push(h),f}function sf(r,e,i,s,a){const u=[];for(const h of r){const f=x_(h,e,i,s,a);f.length>0&&u.push(...f)}return u}function b_(r,e,i){return new Te(i,r.y+(i-r.x)/(e.x-r.x)*(e.y-r.y))}function w_(r,e,i){return new Te(r.x+(i-r.y)/(e.y-r.y)*(e.x-r.x),i)}De("FeatureIndex",ef,{omit:["rawTileData","sourceLayerCoder"]});class Es extends Te{constructor(e,i,s,a){super(e,i),this.angle=s,a!==void 0&&(this.segment=a)}clone(){return new Es(this.x,this.y,this.angle,this.segment)}}function of(r,e,i,s,a){if(e.segment===void 0||i===0)return!0;let u=e,h=e.segment+1,f=0;for(;f>-i/2;){if(h--,h<0)return!1;f-=r[h].dist(u),u=r[h]}f+=r[h].dist(r[h+1]),h++;const g=[];let y=0;for(;f<i/2;){const x=r[h],b=r[h+1];if(!b)return!1;let S=r[h-1].angleTo(x)-x.angleTo(b);for(S=Math.abs((S+3*Math.PI)%(2*Math.PI)-Math.PI),g.push({distance:f,angleDelta:S}),y+=S;f-g[0].distance>s;)y-=g.shift().angleDelta;if(y>a)return!1;h++,f+=x.dist(b)}return!0}function af(r){let e=0;for(let i=0;i<r.length-1;i++)e+=r[i].dist(r[i+1]);return e}function lf(r,e,i){return r?.6*e*i:0}function cf(r,e){return Math.max(r?r.right-r.left:0,e?e.right-e.left:0)}function T_(r,e,i,s,a,u){const h=lf(i,a,u),f=cf(i,s)*u;let g=0;const y=af(r)/2;for(let x=0;x<r.length-1;x++){const b=r[x],S=r[x+1],P=b.dist(S);if(g+P>y){const I=(y-g)/P,A=ui.number(b.x,S.x,I),L=ui.number(b.y,S.y,I),O=new Es(A,L,S.angleTo(b),x);return O._round(),!h||of(r,O,f,h,e)?O:void 0}g+=P}}function S_(r,e,i,s,a,u,h,f,g){const y=lf(s,u,h),x=cf(s,a),b=x*h,S=r[0].x===0||r[0].x===g||r[0].y===0||r[0].y===g;return e-b<e/4&&(e=b+e/4),uf(r,S?e/2*f%e:(x/2+2*u)*h*f%e,e,y,i,b,S,!1,g)}function uf(r,e,i,s,a,u,h,f,g){const y=u/2,x=af(r);let b=0,S=e-i,P=[];for(let I=0;I<r.length-1;I++){const A=r[I],L=r[I+1],O=A.dist(L),G=L.angleTo(A);for(;S+i<b+O;){S+=i;const B=(S-b)/O,V=ui.number(A.x,L.x,B),W=ui.number(A.y,L.y,B);if(V>=0&&V<g&&W>=0&&W<g&&S-y>=0&&S+y<=x){const ee=new Es(V,W,G,I);ee._round(),s&&!of(r,ee,u,s,a)||P.push(ee)}}b+=O}return f||P.length||h||(P=uf(r,b/2,i,s,a,u,h,!0,g)),P}function hf(r,e,i,s){const a=[],u=r.image,h=u.pixelRatio,f=u.paddedRect.w-2,g=u.paddedRect.h-2;let y={x1:r.left,y1:r.top,x2:r.right,y2:r.bottom};const x=u.stretchX||[[0,f]],b=u.stretchY||[[0,g]],S=(fe,ze)=>fe+ze[1]-ze[0],P=x.reduce(S,0),I=b.reduce(S,0),A=f-P,L=g-I;let O=0,G=P,B=0,V=I,W=0,ee=A,ae=0,_e=L;if(u.content&&s){const fe=u.content,ze=fe[2]-fe[0],Le=fe[3]-fe[1];(u.textFitWidth||u.textFitHeight)&&(y=sp(r)),O=wu(x,0,fe[0]),B=wu(b,0,fe[1]),G=wu(x,fe[0],fe[2]),V=wu(b,fe[1],fe[3]),W=fe[0]-O,ae=fe[1]-B,ee=ze-G,_e=Le-V}const ye=y.x1,xe=y.y1,Ee=y.x2-ye,we=y.y2-xe,ve=(fe,ze,Le,Ve)=>{const Fe=Tu(fe.stretch-O,G,Ee,ye),it=Su(fe.fixed-W,ee,fe.stretch,P),Dt=Tu(ze.stretch-B,V,we,xe),Jt=Su(ze.fixed-ae,_e,ze.stretch,I),bi=Tu(Le.stretch-O,G,Ee,ye),Dr=Su(Le.fixed-W,ee,Le.stretch,P),Vi=Tu(Ve.stretch-B,V,we,xe),di=Su(Ve.fixed-ae,_e,Ve.stretch,I),wi=new Te(Fe,Dt),Zt=new Te(bi,Dt),pi=new Te(bi,Vi),Ai=new Te(Fe,Vi),Di=new Te(it/h,Jt/h),Qi=new Te(Dr/h,di/h),Ti=e*Math.PI/180;if(Ti){const ai=Math.sin(Ti),Lt=Math.cos(Ti),Qt=[Lt,-ai,ai,Lt];wi._matMult(Qt),Zt._matMult(Qt),Ai._matMult(Qt),pi._matMult(Qt)}const er=fe.stretch+fe.fixed,zr=ze.stretch+ze.fixed;return{tl:wi,tr:Zt,bl:Ai,br:pi,tex:{x:u.paddedRect.x+1+er,y:u.paddedRect.y+1+zr,w:Le.stretch+Le.fixed-er,h:Ve.stretch+Ve.fixed-zr},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Di,pixelOffsetBR:Qi,minFontScaleX:ee/h/Ee,minFontScaleY:_e/h/we,isSDF:i}};if(s&&(u.stretchX||u.stretchY)){const fe=df(x,A,P),ze=df(b,L,I);for(let Le=0;Le<fe.length-1;Le++){const Ve=fe[Le],Fe=fe[Le+1];for(let it=0;it<ze.length-1;it++)a.push(ve(Ve,ze[it],Fe,ze[it+1]))}}else a.push(ve({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:f+1},{fixed:0,stretch:g+1}));return a}function wu(r,e,i){let s=0;for(const a of r)s+=Math.max(e,Math.min(i,a[1]))-Math.max(e,Math.min(i,a[0]));return s}function df(r,e,i){const s=[{fixed:-1,stretch:0}];for(const[a,u]of r){const h=s[s.length-1];s.push({fixed:a-h.stretch,stretch:h.stretch}),s.push({fixed:a-h.stretch,stretch:h.stretch+(u-a)})}return s.push({fixed:e+1,stretch:i}),s}function Tu(r,e,i,s){return r/e*i+s}function Su(r,e,i,s){return r-e*i/s}De("Anchor",Es);class Pu{constructor(e,i,s,a,u,h,f,g,y,x){var b;if(this.boxStartIndex=e.length,y){let S=h.top,P=h.bottom;const I=h.collisionPadding;I&&(S-=I[1],P+=I[3]);let A=P-S;A>0&&(A=Math.max(10,A),this.circleDiameter=A)}else{const S=!((b=h.image)===null||b===void 0)&&b.content&&(h.image.textFitWidth||h.image.textFitHeight)?sp(h):{x1:h.left,y1:h.top,x2:h.right,y2:h.bottom};S.y1=S.y1*f-g[0],S.y2=S.y2*f+g[2],S.x1=S.x1*f-g[3],S.x2=S.x2*f+g[1];const P=h.collisionPadding;if(P&&(S.x1-=P[0]*f,S.y1-=P[1]*f,S.x2+=P[2]*f,S.y2+=P[3]*f),x){const I=new Te(S.x1,S.y1),A=new Te(S.x2,S.y1),L=new Te(S.x1,S.y2),O=new Te(S.x2,S.y2),G=x*Math.PI/180;I._rotate(G),A._rotate(G),L._rotate(G),O._rotate(G),S.x1=Math.min(I.x,A.x,L.x,O.x),S.x2=Math.max(I.x,A.x,L.x,O.x),S.y1=Math.min(I.y,A.y,L.y,O.y),S.y2=Math.max(I.y,A.y,L.y,O.y)}e.emplaceBack(i.x,i.y,S.x1,S.y1,S.x2,S.y2,s,a,u)}this.boxEndIndex=e.length}}class P_{constructor(e=[],i=(s,a)=>s<a?-1:s>a?1:0){if(this.data=e,this.length=this.data.length,this.compare=i,this.length>0)for(let s=(this.length>>1)-1;s>=0;s--)this._down(s)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;const e=this.data[0],i=this.data.pop();return--this.length>0&&(this.data[0]=i,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:i,compare:s}=this,a=i[e];for(;e>0;){const u=e-1>>1,h=i[u];if(s(a,h)>=0)break;i[e]=h,e=u}i[e]=a}_down(e){const{data:i,compare:s}=this,a=this.length>>1,u=i[e];for(;e<a;){let h=1+(e<<1);const f=h+1;if(f<this.length&&s(i[f],i[h])<0&&(h=f),s(i[h],u)>=0)break;i[e]=i[h],e=h}i[e]=u}}function M_(r,e=1,i=!1){const s=Co.fromPoints(r[0]),a=Math.min(s.width(),s.height());let u=a/2;const h=new P_([],C_),{minX:f,minY:g,maxX:y,maxY:x}=s;if(a===0)return new Te(f,g);for(let P=f;P<y;P+=a)for(let I=g;I<x;I+=a)h.push(new Ra(P+u,I+u,u,r));let b=(function(P){let I=0,A=0,L=0;const O=P[0];for(let G=0,B=O.length,V=B-1;G<B;V=G++){const W=O[G],ee=O[V],ae=W.x*ee.y-ee.x*W.y;A+=(W.x+ee.x)*ae,L+=(W.y+ee.y)*ae,I+=3*ae}return new Ra(A/I,L/I,0,P)})(r),S=h.length;for(;h.length;){const P=h.pop();(P.d>b.d||!b.d)&&(b=P,i&&console.log("found best %d after %d probes",Math.round(1e4*P.d)/1e4,S)),P.max-b.d<=e||(u=P.h/2,h.push(new Ra(P.p.x-u,P.p.y-u,u,r)),h.push(new Ra(P.p.x+u,P.p.y-u,u,r)),h.push(new Ra(P.p.x-u,P.p.y+u,u,r)),h.push(new Ra(P.p.x+u,P.p.y+u,u,r)),S+=4)}return i&&(console.log(`num probes: ${S}`),console.log(`best distance: ${b.d}`)),b.p}function C_(r,e){return e.max-r.max}function Ra(r,e,i,s){this.p=new Te(r,e),this.h=i,this.d=(function(a,u){let h=!1,f=1/0;for(let g=0;g<u.length;g++){const y=u[g];for(let x=0,b=y.length,S=b-1;x<b;S=x++){const P=y[x],I=y[S];P.y>a.y!=I.y>a.y&&a.x<(I.x-P.x)*(a.y-P.y)/(I.y-P.y)+P.x&&(h=!h),f=Math.min(f,fd(a,P,I))}}return(h?1:-1)*Math.sqrt(f)})(this.p,s),this.max=this.d+this.h*Math.SQRT2}var xi;D.aP=void 0,(xi=D.aP||(D.aP={}))[xi.center=1]="center",xi[xi.left=2]="left",xi[xi.right=3]="right",xi[xi.top=4]="top",xi[xi.bottom=5]="bottom",xi[xi["top-left"]=6]="top-left",xi[xi["top-right"]=7]="top-right",xi[xi["bottom-left"]=8]="bottom-left",xi[xi["bottom-right"]=9]="bottom-right";const $h=Number.POSITIVE_INFINITY;function pf(r,e){return e[1]!==$h?(function(i,s,a){let u=0,h=0;switch(s=Math.abs(s),a=Math.abs(a),i){case"top-right":case"top-left":case"top":h=a-7;break;case"bottom-right":case"bottom-left":case"bottom":h=7-a}switch(i){case"top-right":case"bottom-right":case"right":u=-s;break;case"top-left":case"bottom-left":case"left":u=s}return[u,h]})(r,e[0],e[1]):(function(i,s){let a=0,u=0;s<0&&(s=0);const h=s/Math.SQRT2;switch(i){case"top-right":case"top-left":u=h-7;break;case"bottom-right":case"bottom-left":u=7-h;break;case"bottom":u=7-s;break;case"top":u=s-7}switch(i){case"top-right":case"bottom-right":a=-h;break;case"top-left":case"bottom-left":a=h;break;case"left":a=s;break;case"right":a=-s}return[a,u]})(r,e[0])}function ff(r,e,i){var s;const a=r.layout,u=(s=a.get("text-variable-anchor-offset"))===null||s===void 0?void 0:s.evaluate(e,{},i);if(u){const f=u.values,g=[];for(let y=0;y<f.length;y+=2){const x=g[y]=f[y],b=f[y+1].map((S=>S*si));x.startsWith("top")?b[1]-=7:x.startsWith("bottom")&&(b[1]+=7),g[y+1]=b}return new Wt(g)}const h=a.get("text-variable-anchor");if(h){let f;f=r._unevaluatedLayout.getValue("text-radial-offset")!==void 0?[a.get("text-radial-offset").evaluate(e,{},i)*si,$h]:a.get("text-offset").evaluate(e,{},i).map((y=>y*si));const g=[];for(const y of h)g.push(y,pf(y,f));return new Wt(g)}return null}function Hh(r){switch(r){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function I_(r,e,i,s,a,u,h,f,g,y,x,b){let S=u.textMaxSize.evaluate(e,{});S===void 0&&(S=h);const P=r.layers[0].layout,I=P.get("icon-offset").evaluate(e,{},x),A=gf(i.horizontal),L=h/24,O=r.tilePixelRatio*L,G=r.tilePixelRatio*S/24,B=r.tilePixelRatio*f,V=r.tilePixelRatio*P.get("symbol-spacing"),W=P.get("text-padding")*r.tilePixelRatio,ee=(function(Le,Ve,Fe,it=1){const Dt=Le.get("icon-padding").evaluate(Ve,{},Fe),Jt=Dt&&Dt.values;return[Jt[0]*it,Jt[1]*it,Jt[2]*it,Jt[3]*it]})(P,e,x,r.tilePixelRatio),ae=P.get("text-max-angle")/180*Math.PI,_e=P.get("text-rotation-alignment")!=="viewport"&&P.get("symbol-placement")!=="point",ye=P.get("icon-rotation-alignment")==="map"&&P.get("symbol-placement")!=="point",xe=P.get("symbol-placement"),Ee=V/2,we=P.get("icon-text-fit");let ve;s&&we!=="none"&&(r.allowVerticalPlacement&&i.vertical&&(ve=op(s,i.vertical,we,P.get("icon-text-fit-padding"),I,L)),A&&(s=op(s,A,we,P.get("icon-text-fit-padding"),I,L)));const fe=x?b.line.getGranularityForZoomLevel(x.z):1,ze=(Le,Ve)=>{Ve.x<0||Ve.x>=ht||Ve.y<0||Ve.y>=ht||(function(Fe,it,Dt,Jt,bi,Dr,Vi,di,wi,Zt,pi,Ai,Di,Qi,Ti,er,zr,ai,Lt,Qt,Vt,li,Hn,Qr,Xl){const As=Fe.addToLineVertexArray(it,Dt);let Eo,Fa,Ba,Oa,xf=0,bf=0,wf=0,Tf=0,td=-1,id=-1;const Wn={};let Sf=Ft("");if(Fe.allowVerticalPlacement&&Jt.vertical){const zi=di.layout.get("text-rotate").evaluate(Vt,{},Qr)+90;Ba=new Pu(wi,it,Zt,pi,Ai,Jt.vertical,Di,Qi,Ti,zi),Vi&&(Oa=new Pu(wi,it,Zt,pi,Ai,Vi,zr,ai,Ti,zi))}if(bi){const zi=di.layout.get("icon-rotate").evaluate(Vt,{}),br=di.layout.get("icon-text-fit")!=="none",Ao=hf(bi,zi,Hn,br),tn=Vi?hf(Vi,zi,Hn,br):void 0;Fa=new Pu(wi,it,Zt,pi,Ai,bi,zr,ai,!1,zi),xf=4*Ao.length;const Do=Fe.iconSizeData;let vn=null;Do.kind==="source"?(vn=[$n*di.layout.get("icon-size").evaluate(Vt,{})],vn[0]>Ps&&gi(`${Fe.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):Do.kind==="composite"&&(vn=[$n*li.compositeIconSizes[0].evaluate(Vt,{},Qr),$n*li.compositeIconSizes[1].evaluate(Vt,{},Qr)],(vn[0]>Ps||vn[1]>Ps)&&gi(`${Fe.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),Fe.addSymbols(Fe.icon,Ao,vn,Qt,Lt,Vt,D.az.none,it,As.lineStartIndex,As.lineLength,-1,Qr),td=Fe.icon.placedSymbolArray.length-1,tn&&(bf=4*tn.length,Fe.addSymbols(Fe.icon,tn,vn,Qt,Lt,Vt,D.az.vertical,it,As.lineStartIndex,As.lineLength,-1,Qr),id=Fe.icon.placedSymbolArray.length-1)}const Pf=Object.keys(Jt.horizontal);for(const zi of Pf){const br=Jt.horizontal[zi];if(!Eo){Sf=Ft(br.text);const tn=di.layout.get("text-rotate").evaluate(Vt,{},Qr);Eo=new Pu(wi,it,Zt,pi,Ai,br,Di,Qi,Ti,tn)}const Ao=br.positionedLines.length===1;if(wf+=mf(Fe,it,br,Dr,di,Ti,Vt,er,As,Jt.vertical?D.az.horizontal:D.az.horizontalOnly,Ao?Pf:[zi],Wn,td,li,Qr),Ao)break}Jt.vertical&&(Tf+=mf(Fe,it,Jt.vertical,Dr,di,Ti,Vt,er,As,D.az.vertical,["vertical"],Wn,id,li,Qr));const D_=Eo?Eo.boxStartIndex:Fe.collisionBoxArray.length,z_=Eo?Eo.boxEndIndex:Fe.collisionBoxArray.length,k_=Ba?Ba.boxStartIndex:Fe.collisionBoxArray.length,L_=Ba?Ba.boxEndIndex:Fe.collisionBoxArray.length,R_=Fa?Fa.boxStartIndex:Fe.collisionBoxArray.length,F_=Fa?Fa.boxEndIndex:Fe.collisionBoxArray.length,B_=Oa?Oa.boxStartIndex:Fe.collisionBoxArray.length,O_=Oa?Oa.boxEndIndex:Fe.collisionBoxArray.length;let en=-1;const Cu=(zi,br)=>zi&&zi.circleDiameter?Math.max(zi.circleDiameter,br):br;en=Cu(Eo,en),en=Cu(Ba,en),en=Cu(Fa,en),en=Cu(Oa,en);const Mf=en>-1?1:0;Mf&&(en*=Xl/si),Fe.glyphOffsetArray.length>=Ea.MAX_GLYPHS&&gi("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),Vt.sortKey!==void 0&&Fe.addToSortKeyRanges(Fe.symbolInstances.length,Vt.sortKey);const V_=ff(di,Vt,Qr),[N_,j_]=(function(zi,br){const Ao=zi.length,tn=br?.values;if(tn?.length>0)for(let Do=0;Do<tn.length;Do+=2){const vn=tn[Do+1];zi.emplaceBack(D.aP[tn[Do]],vn[0],vn[1])}return[Ao,zi.length]})(Fe.textAnchorOffsets,V_);Fe.symbolInstances.emplaceBack(it.x,it.y,Wn.right>=0?Wn.right:-1,Wn.center>=0?Wn.center:-1,Wn.left>=0?Wn.left:-1,Wn.vertical||-1,td,id,Sf,D_,z_,k_,L_,R_,F_,B_,O_,Zt,wf,Tf,xf,bf,Mf,0,Di,en,N_,j_)})(r,Ve,Le,i,s,a,ve,r.layers[0],r.collisionBoxArray,e.index,e.sourceLayerIndex,r.index,O,[W,W,W,W],_e,g,B,ee,ye,I,e,u,y,x,h)};if(xe==="line")for(const Le of rf(e.geometry,0,0,ht,ht)){const Ve=Mo(Le,fe),Fe=S_(Ve,V,ae,i.vertical||A,s,24,G,r.overscaling,ht);for(const it of Fe)A&&E_(r,A.text,Ee,it)||ze(Ve,it)}else if(xe==="line-center"){for(const Le of e.geometry)if(Le.length>1){const Ve=Mo(Le,fe),Fe=T_(Ve,ae,i.vertical||A,s,24,G);Fe&&ze(Ve,Fe)}}else if(e.type==="Polygon")for(const Le of Ys(e.geometry,0)){const Ve=M_(Le,16);ze(Mo(Le[0],fe,!0),new Es(Ve.x,Ve.y,0))}else if(e.type==="LineString")for(const Le of e.geometry){const Ve=Mo(Le,fe);ze(Ve,new Es(Ve[0].x,Ve[0].y,0))}else if(e.type==="Point")for(const Le of e.geometry)for(const Ve of Le)ze([Ve],new Es(Ve.x,Ve.y,0))}function mf(r,e,i,s,a,u,h,f,g,y,x,b,S,P,I){const A=(function(G,B,V,W,ee,ae,_e,ye){const xe=W.layout.get("text-rotate").evaluate(ae,{})*Math.PI/180,Ee=[];for(const we of B.positionedLines)for(const ve of we.positionedGlyphs){if(!ve.rect)continue;const fe=ve.rect||{};let ze=4,Le=!0,Ve=1,Fe=0;const it=(ee||ye)&&ve.vertical,Dt=ve.metrics.advance*ve.scale/2;if(ye&&B.verticalizable&&(Fe=we.lineOffset/2-(ve.imageName?-(si-ve.metrics.width*ve.scale)/2:(ve.scale-1)*si)),ve.imageName){const ai=_e[ve.imageName];Le=ai.sdf,Ve=ai.pixelRatio,ze=1/Ve}const Jt=ee?[ve.x+Dt,ve.y]:[0,0];let bi=ee?[0,0]:[ve.x+Dt+V[0],ve.y+V[1]-Fe],Dr=[0,0];it&&(Dr=bi,bi=[0,0]);const Vi=ve.metrics.isDoubleResolution?2:1,di=(ve.metrics.left-ze)*ve.scale-Dt+bi[0],wi=(-ve.metrics.top-ze)*ve.scale+bi[1],Zt=di+fe.w/Vi*ve.scale/Ve,pi=wi+fe.h/Vi*ve.scale/Ve,Ai=new Te(di,wi),Di=new Te(Zt,wi),Qi=new Te(di,pi),Ti=new Te(Zt,pi);if(it){const ai=new Te(-Dt,Dt- -17),Lt=-Math.PI/2,Qt=12-Dt,Vt=new Te(22-Qt,-(ve.imageName?Qt:0)),li=new Te(...Dr);Ai._rotateAround(Lt,ai)._add(Vt)._add(li),Di._rotateAround(Lt,ai)._add(Vt)._add(li),Qi._rotateAround(Lt,ai)._add(Vt)._add(li),Ti._rotateAround(Lt,ai)._add(Vt)._add(li)}if(xe){const ai=Math.sin(xe),Lt=Math.cos(xe),Qt=[Lt,-ai,ai,Lt];Ai._matMult(Qt),Di._matMult(Qt),Qi._matMult(Qt),Ti._matMult(Qt)}const er=new Te(0,0),zr=new Te(0,0);Ee.push({tl:Ai,tr:Di,bl:Qi,br:Ti,tex:fe,writingMode:B.writingMode,glyphOffset:Jt,sectionIndex:ve.sectionIndex,isSDF:Le,pixelOffsetTL:er,pixelOffsetBR:zr,minFontScaleX:0,minFontScaleY:0})}return Ee})(0,i,f,a,u,h,s,r.allowVerticalPlacement),L=r.textSizeData;let O=null;L.kind==="source"?(O=[$n*a.layout.get("text-size").evaluate(h,{})],O[0]>Ps&&gi(`${r.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):L.kind==="composite"&&(O=[$n*P.compositeTextSizes[0].evaluate(h,{},I),$n*P.compositeTextSizes[1].evaluate(h,{},I)],(O[0]>Ps||O[1]>Ps)&&gi(`${r.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),r.addSymbols(r.text,A,O,f,u,h,y,e,g.lineStartIndex,g.lineLength,S,I);for(const G of x)b[G]=r.text.placedSymbolArray.length-1;return 4*A.length}function gf(r){for(const e in r)return r[e];return null}function E_(r,e,i,s){const a=r.compareText;if(e in a){const u=a[e];for(let h=u.length-1;h>=0;h--)if(s.dist(u[h])<i)return!0}else a[e]=[];return a[e].push(s),!1}const _f=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Wh{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[i,s]=new Uint8Array(e,0,2);if(i!==219)throw new Error("Data does not appear to be in a KDBush format.");const a=s>>4;if(a!==1)throw new Error(`Got v${a} data when expected v1.`);const u=_f[15&s];if(!u)throw new Error("Unrecognized array type.");const[h]=new Uint16Array(e,2,1),[f]=new Uint32Array(e,4,1);return new Wh(f,h,u,e)}constructor(e,i=64,s=Float64Array,a){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+i,2),65535),this.ArrayType=s,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const u=_f.indexOf(this.ArrayType),h=2*e*this.ArrayType.BYTES_PER_ELEMENT,f=e*this.IndexArrayType.BYTES_PER_ELEMENT,g=(8-f%8)%8;if(u<0)throw new Error(`Unexpected typed array class: ${s}.`);a&&a instanceof ArrayBuffer?(this.data=a,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+f+g,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+h+f+g),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+f+g,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+u]),new Uint16Array(this.data,2,1)[0]=i,new Uint32Array(this.data,4,1)[0]=e)}add(e,i){const s=this._pos>>1;return this.ids[s]=s,this.coords[this._pos++]=e,this.coords[this._pos++]=i,s}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return Xh(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,i,s,a){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:u,coords:h,nodeSize:f}=this,g=[0,u.length-1,0],y=[];for(;g.length;){const x=g.pop()||0,b=g.pop()||0,S=g.pop()||0;if(b-S<=f){for(let L=S;L<=b;L++){const O=h[2*L],G=h[2*L+1];O>=e&&O<=s&&G>=i&&G<=a&&y.push(u[L])}continue}const P=S+b>>1,I=h[2*P],A=h[2*P+1];I>=e&&I<=s&&A>=i&&A<=a&&y.push(u[P]),(x===0?e<=I:i<=A)&&(g.push(S),g.push(P-1),g.push(1-x)),(x===0?s>=I:a>=A)&&(g.push(P+1),g.push(b),g.push(1-x))}return y}within(e,i,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:a,coords:u,nodeSize:h}=this,f=[0,a.length-1,0],g=[],y=s*s;for(;f.length;){const x=f.pop()||0,b=f.pop()||0,S=f.pop()||0;if(b-S<=h){for(let L=S;L<=b;L++)vf(u[2*L],u[2*L+1],e,i)<=y&&g.push(a[L]);continue}const P=S+b>>1,I=u[2*P],A=u[2*P+1];vf(I,A,e,i)<=y&&g.push(a[P]),(x===0?e-s<=I:i-s<=A)&&(f.push(S),f.push(P-1),f.push(1-x)),(x===0?e+s>=I:i+s>=A)&&(f.push(P+1),f.push(b),f.push(1-x))}return g}}function Xh(r,e,i,s,a,u){if(a-s<=i)return;const h=s+a>>1;yf(r,e,h,s,a,u),Xh(r,e,i,s,h-1,1-u),Xh(r,e,i,h+1,a,1-u)}function yf(r,e,i,s,a,u){for(;a>s;){if(a-s>600){const y=a-s+1,x=i-s+1,b=Math.log(y),S=.5*Math.exp(2*b/3),P=.5*Math.sqrt(b*S*(y-S)/y)*(x-y/2<0?-1:1);yf(r,e,i,Math.max(s,Math.floor(i-x*S/y+P)),Math.min(a,Math.floor(i+(y-x)*S/y+P)),u)}const h=e[2*i+u];let f=s,g=a;for(Hl(r,e,s,i),e[2*a+u]>h&&Hl(r,e,s,a);f<g;){for(Hl(r,e,f,g),f++,g--;e[2*f+u]<h;)f++;for(;e[2*g+u]>h;)g--}e[2*s+u]===h?Hl(r,e,s,g):(g++,Hl(r,e,g,a)),g<=i&&(s=g+1),i<=g&&(a=g-1)}}function Hl(r,e,i,s){Yh(r,i,s),Yh(e,2*i,2*s),Yh(e,2*i+1,2*s+1)}function Yh(r,e,i){const s=r[e];r[e]=r[i],r[i]=s}function vf(r,e,i,s){const a=r-i,u=e-s;return a*a+u*u}var Kh;D.cI=void 0,(Kh=D.cI||(D.cI={})).create="create",Kh.load="load",Kh.fullLoad="fullLoad";let Mu=null,Wl=[];const Jh=1e3/60,Qh="loadTime",ed="fullLoadTime",A_={mark(r){performance.mark(r)},recordStartOfFrameAt(r){Mu!=null&&Wl.push(r-Mu),Mu=r},resetRuntimeMetrics(){Mu=null,Wl=[]},clearInitializationMetrics(){performance.clearMeasures(Qh),performance.clearMeasures(ed);for(const r in D.cI)performance.clearMarks(D.cI[r])},remove(){this.resetRuntimeMetrics(),this.clearInitializationMetrics()},getPerformanceMetrics(){performance.measure(Qh,D.cI.create,D.cI.load),performance.measure(ed,D.cI.create,D.cI.fullLoad);const r=performance.getEntriesByName(Qh)[0].duration,e=performance.getEntriesByName(ed)[0].duration,i=Wl.length;return{loadTimeMs:r,fullLoadTimeMs:e,averageFramesPerSecond:1/(Wl.reduce(((s,a)=>s+a),0)/i/1e3),virtualDroppedFramesCount:Wl.filter((s=>s>Jh)).reduce(((s,a)=>s+(a-Jh)/Jh),0),totalFramesCount:i}}};D.$=pe,D.A=mt,D.B=Nc,D.C=Cr,D.D=Be,D.E=me,D.F=function([r,e,i]){return e+=90,e*=Math.PI/180,i*=Math.PI/180,{x:r*Math.cos(e)*Math.sin(i),y:r*Math.sin(e)*Math.sin(i),z:r*Math.cos(i)}},D.G=ui,D.H=vt,D.I=xh,D.J=po,D.K=function(r){if(Mt==null){const e=r.navigator?r.navigator.userAgent:null;Mt=!!r.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Mt},D.L=class{constructor(r,e){this.target=r,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Zg((()=>this.process())),this.subscription=ln(this.target,"message",(i=>this.receive(i)),!1),this.globalScope=Pr(self)?r:window}registerMessageHandler(r,e){this.messageHandlers[r]=e}unregisterMessageHandler(r){delete this.messageHandlers[r]}sendAsync(r,e){return new Promise(((i,s)=>{const a=Math.round(1e18*Math.random()).toString(36).substring(0,10),u=e?ln(e.signal,"abort",(()=>{u?.unsubscribe(),delete this.resolveRejects[a];const g={id:a,type:"<cancel>",origin:location.origin,targetMapId:r.targetMapId,sourceMapId:this.mapId};this.target.postMessage(g)}),$g):null;this.resolveRejects[a]={resolve:g=>{u?.unsubscribe(),i(g)},reject:g=>{u?.unsubscribe(),s(g)}};const h=[],f=Object.assign(Object.assign({},r),{id:a,sourceMapId:this.mapId,origin:location.origin,data:$r(r.data,h)});this.target.postMessage(f,{transfer:h})}))}receive(r){const e=r.data,i=e.id;if(!(e.origin!=="file://"&&location.origin!=="file://"&&e.origin!=="resource://android"&&location.origin!=="resource://android"&&e.origin!==location.origin||e.targetMapId&&this.mapId!==e.targetMapId)){if(e.type==="<cancel>"){delete this.tasks[i];const s=this.abortControllers[i];return delete this.abortControllers[i],void(s&&s.abort())}if(Pr(self)||e.mustQueue)return this.tasks[i]=e,this.taskQueue.push(i),void this.invoker.trigger();this.processTask(i,e)}}process(){if(this.taskQueue.length===0)return;const r=this.taskQueue.shift(),e=this.tasks[r];delete this.tasks[r],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(r,e)}processTask(r,e){return c(this,void 0,void 0,(function*(){if(e.type==="<response>"){const a=this.resolveRejects[r];return delete this.resolveRejects[r],a?void(e.error?a.reject(mo(e.error)):a.resolve(mo(e.data))):void 0}if(!this.messageHandlers[e.type])return void this.completeTask(r,new Error(`Could not find a registered handler for ${e.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const i=mo(e.data),s=new AbortController;this.abortControllers[r]=s;try{const a=yield this.messageHandlers[e.type](e.sourceMapId,i,s);this.completeTask(r,null,a)}catch(a){this.completeTask(r,a)}}))}completeTask(r,e,i){const s=[];delete this.abortControllers[r];const a={id:r,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:e?$r(e):null,data:$r(i,s)};this.target.postMessage(a,{transfer:s})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},D.M=k,D.N=function(){var r=new mt(16);return mt!=Float32Array&&(r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=0,r[12]=0,r[13]=0,r[14]=0),r[0]=1,r[5]=1,r[10]=1,r[15]=1,r},D.O=function(r,e,i){var s,a,u,h,f,g,y,x,b,S,P,I,A=i[0],L=i[1],O=i[2];return e===r?(r[12]=e[0]*A+e[4]*L+e[8]*O+e[12],r[13]=e[1]*A+e[5]*L+e[9]*O+e[13],r[14]=e[2]*A+e[6]*L+e[10]*O+e[14],r[15]=e[3]*A+e[7]*L+e[11]*O+e[15]):(a=e[1],u=e[2],h=e[3],f=e[4],g=e[5],y=e[6],x=e[7],b=e[8],S=e[9],P=e[10],I=e[11],r[0]=s=e[0],r[1]=a,r[2]=u,r[3]=h,r[4]=f,r[5]=g,r[6]=y,r[7]=x,r[8]=b,r[9]=S,r[10]=P,r[11]=I,r[12]=s*A+f*L+b*O+e[12],r[13]=a*A+g*L+S*O+e[13],r[14]=u*A+y*L+P*O+e[14],r[15]=h*A+x*L+I*O+e[15]),r},D.P=Te,D.Q=function(r,e,i){var s=i[0],a=i[1],u=i[2];return r[0]=e[0]*s,r[1]=e[1]*s,r[2]=e[2]*s,r[3]=e[3]*s,r[4]=e[4]*a,r[5]=e[5]*a,r[6]=e[6]*a,r[7]=e[7]*a,r[8]=e[8]*u,r[9]=e[9]*u,r[10]=e[10]*u,r[11]=e[11]*u,r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15],r},D.R=Ji,D.S=function(r,e,i){var s=e[0],a=e[1],u=e[2],h=e[3],f=e[4],g=e[5],y=e[6],x=e[7],b=e[8],S=e[9],P=e[10],I=e[11],A=e[12],L=e[13],O=e[14],G=e[15],B=i[0],V=i[1],W=i[2],ee=i[3];return r[0]=B*s+V*f+W*b+ee*A,r[1]=B*a+V*g+W*S+ee*L,r[2]=B*u+V*y+W*P+ee*O,r[3]=B*h+V*x+W*I+ee*G,r[4]=(B=i[4])*s+(V=i[5])*f+(W=i[6])*b+(ee=i[7])*A,r[5]=B*a+V*g+W*S+ee*L,r[6]=B*u+V*y+W*P+ee*O,r[7]=B*h+V*x+W*I+ee*G,r[8]=(B=i[8])*s+(V=i[9])*f+(W=i[10])*b+(ee=i[11])*A,r[9]=B*a+V*g+W*S+ee*L,r[10]=B*u+V*y+W*P+ee*O,r[11]=B*h+V*x+W*I+ee*G,r[12]=(B=i[12])*s+(V=i[13])*f+(W=i[14])*b+(ee=i[15])*A,r[13]=B*a+V*g+W*S+ee*L,r[14]=B*u+V*y+W*P+ee*O,r[15]=B*h+V*x+W*I+ee*G,r},D.T=hh,D.U=function(r,e){const i={};for(let s=0;s<e.length;s++){const a=e[s];a in r&&(i[a]=r[a])}return i},D.V=Ms,D.W=fi,D.X=mp,D.Y=fp,D.Z=is,D._=c,D.a=Rs,D.a$=rn,D.a0=pr,D.a1=Pn,D.a2=cr,D.a3=_p,D.a4=fu,D.a5=ht,D.a6=function(r,e,i){if(!r)return e||{};if(!e)return r||{};const s=bp(r),a=bp(e);(function(h,f){f.removeAll&&(h.add.clear(),h.update.clear(),h.remove.clear(),f.remove.clear());for(const g of f.remove)h.add.delete(g),h.update.delete(g);for(const[g,y]of f.update){const x=h.update.get(g);x&&(f.update.set(g,Hg(x,y)),h.update.delete(g))}})(s,a);const u={};if((s.removeAll||a.removeAll)&&(u.removeAll=!0),u.remove=new Set([...s.remove,...a.remove]),u.add=new Map([...s.add,...a.add]),u.update=new Map([...s.update,...a.update]),u.remove.size&&u.add.size)for(const h of u.add.keys())u.remove.delete(h);return(function(h){const f={};return h.removeAll&&(f.removeAll=h.removeAll),h.remove&&(f.remove=Array.from(h.remove)),h.add&&(f.add=Array.from(h.add.values())),h.update&&(f.update=Array.from(h.update.values())),f})(u)},D.a7=function(r,e){const i=new Map;if(r==null||r.type==null)return i;if(r.type==="Feature"){const s=Eh(r,e);return s==null?void 0:(i.set(s,r),i)}if(r.type==="FeatureCollection"){const s=new Set;for(const a of r.features){const u=Eh(a,e);if(u==null||s.has(u))return;s.add(u),i.set(u,a)}return i}},D.a8=function(r,e,i){var s,a;const u=[];if(e.removeAll)r.clear();else if(e.remove)for(const h of e.remove){const f=r.get(h);f&&(u.push(f.geometry),r.delete(h))}if(e.add)for(const h of e.add){const f=Eh(h,i);if(f==null)continue;const g=r.get(f);g&&u.push(g.geometry),u.push(h.geometry),r.set(f,h)}if(e.update)for(const h of e.update){const f=r.get(h.id);if(!f)continue;const g=!!h.newGeometry,y=h.removeAllProperties||((s=h.removeProperties)===null||s===void 0?void 0:s.length)>0||((a=h.addOrUpdateProperties)===null||a===void 0?void 0:a.length)>0;if(!g&&!y)continue;u.push(f.geometry);const x=Object.assign({},f);if(r.set(h.id,x),g&&(u.push(h.newGeometry),x.geometry=h.newGeometry),y){if(x.properties=h.removeAllProperties?{}:Object.assign({},x.properties||{}),h.removeProperties)for(const b of h.removeProperties)delete x.properties[b];if(h.addOrUpdateProperties)for(const{key:b,value:S}of h.addOrUpdateProperties)x.properties[b]=S}}return u},D.a9=Gl,D.aA=function(r,{uSize:e,uSizeT:i},{lowerSize:s,upperSize:a}){return r.kind==="source"?s/$n:r.kind==="composite"?ui.number(s/$n,a/$n,i):e},D.aB=function(r,e){var i=e[0],s=e[1],a=e[2],u=e[3],h=e[4],f=e[5],g=e[6],y=e[7],x=e[8],b=e[9],S=e[10],P=e[11],I=e[12],A=e[13],L=e[14],O=e[15],G=i*f-s*h,B=i*g-a*h,V=i*y-u*h,W=s*g-a*f,ee=s*y-u*f,ae=a*y-u*g,_e=x*A-b*I,ye=x*L-S*I,xe=x*O-P*I,Ee=b*L-S*A,we=b*O-P*A,ve=S*O-P*L,fe=G*ve-B*we+V*Ee+W*xe-ee*ye+ae*_e;return fe?(r[0]=(f*ve-g*we+y*Ee)*(fe=1/fe),r[1]=(a*we-s*ve-u*Ee)*fe,r[2]=(A*ae-L*ee+O*W)*fe,r[3]=(S*ee-b*ae-P*W)*fe,r[4]=(g*xe-h*ve-y*ye)*fe,r[5]=(i*ve-a*xe+u*ye)*fe,r[6]=(L*V-I*ae-O*B)*fe,r[7]=(x*ae-S*V+P*B)*fe,r[8]=(h*we-f*xe+y*_e)*fe,r[9]=(s*xe-i*we-u*_e)*fe,r[10]=(I*ee-A*V+O*G)*fe,r[11]=(b*V-x*ee-P*G)*fe,r[12]=(f*ye-h*Ee-g*_e)*fe,r[13]=(i*Ee-s*ye+a*_e)*fe,r[14]=(A*B-I*W-L*G)*fe,r[15]=(x*W-b*B+S*G)*fe,r):null},D.aC=Lr,D.aD=function(r){var e=r[0],i=r[1];return Math.sqrt(e*e+i*i)},D.aE=function(r){return r[0]=0,r[1]=0,r},D.aF=function(r,e,i){return r[0]=e[0]*i,r[1]=e[1]*i,r},D.aG=Th,D.aH=sn,D.aI=function(r,e,i,s){const a=e.y-r.y,u=e.x-r.x,h=s.y-i.y,f=s.x-i.x,g=h*u-f*a;if(g===0)return null;const y=(f*(r.y-i.y)-h*(r.x-i.x))/g;return new Te(r.x+y*u,r.y+y*a)},D.aJ=rf,D.aK=Dl,D.aL=function(r){let e=1/0,i=1/0,s=-1/0,a=-1/0;for(const u of r)e=Math.min(e,u.x),i=Math.min(i,u.y),s=Math.max(s,u.x),a=Math.max(a,u.y);return[e,i,s,a]},D.aM=si,D.aN=bn,D.aO=function(r,e,i,s,a=!1){if(!i[0]&&!i[1])return[0,0];const u=a?s==="map"?-r.bearingInRadians:0:s==="viewport"?r.bearingInRadians:0;if(u){const h=Math.sin(u),f=Math.cos(u);i=[i[0]*f-i[1]*h,i[0]*h+i[1]*f]}return[a?i[0]:bn(e,i[0],r.zoom),a?i[1]:bn(e,i[1],r.zoom)]},D.aQ=wh,D.aR=Hh,D.aS=bh,D.aT=Wh,D.aU=Gt,D.aV=lu,D.aW=R,D.aX=ge,D.aY=ce,D.aZ=Fr,D.a_=yp,D.aa=Co,D.ab=25,D.ac=Ih,D.ad=r=>{const e=window.document.createElement("video");return e.muted=!0,new Promise((i=>{e.onloadstart=()=>{i(e)};for(const s of r){const a=window.document.createElement("source");oe(s)||(e.crossOrigin="Anonymous"),a.src=s,e.appendChild(a)}}))},D.ae=Pe,D.af=function(){return Qn++},D.ag=o,D.ah=Ea,D.ai=$l,D.aj=no,D.ak=yn,D.al=Tp,D.am=function(r){const e={};if(r.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((i,s,a,u)=>{const h=a||u;return e[s]=!h||h.toLowerCase(),""})),e["max-age"]){const i=parseInt(e["max-age"],10);isNaN(i)?delete e["max-age"]:e["max-age"]=i}return e},D.an=ir,D.ao=85.051129,D.ap=Mn,D.aq=function(r){return Math.pow(2,r)},D.ar=Yn,D.as=gp,D.at=function(r){return Math.log(r)/Math.LN2},D.au=function(r){var e=r[0],i=r[1];return e*e+i*i},D.av=function(r){if(!r.length)return new Set;const e=Math.max(...r.map((g=>g.canonical.z)));let i=1/0,s=-1/0,a=1/0,u=-1/0;const h=[];for(const g of r){const{x:y,y:x,z:b}=g.canonical,S=Math.pow(2,e-b),P=y*S,I=x*S;h.push({id:g,x:P,y:I}),P<i&&(i=P),P>s&&(s=P),I<a&&(a=I),I>u&&(u=I)}const f=new Set;for(const g of h)g.x!==i&&g.x!==s&&g.y!==a&&g.y!==u||f.add(g.id);return f},D.aw=function(r,e){const i=Math.abs(2*r.wrap)-+(r.wrap<0),s=Math.abs(2*e.wrap)-+(e.wrap<0);return r.overscaledZ-e.overscaledZ||s-i||e.canonical.y-r.canonical.y||e.canonical.x-r.canonical.x},D.ax=class{constructor(r,e){this.max=r,this.onRemove=e,this.reset()}reset(){for(const r in this.data)for(const e of this.data[r])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(r,e,i){const s=r.wrapped().key;this.data[s]===void 0&&(this.data[s]=[]);const a={value:e,timeout:void 0};if(i!==void 0&&(a.timeout=setTimeout((()=>{this.remove(r,a)}),i)),this.data[s].push(a),this.order.push(s),this.order.length>this.max){const u=this._getAndRemoveByKey(this.order[0]);u&&this.onRemove(u)}return this}has(r){return r.wrapped().key in this.data}getAndRemove(r){return this.has(r)?this._getAndRemoveByKey(r.wrapped().key):null}_getAndRemoveByKey(r){const e=this.data[r].shift();return e.timeout&&clearTimeout(e.timeout),this.data[r].length===0&&delete this.data[r],this.order.splice(this.order.indexOf(r),1),e.value}getByKey(r){const e=this.data[r];return e?e[0].value:null}get(r){return this.has(r)?this.data[r.wrapped().key][0].value:null}remove(r,e){if(!this.has(r))return this;const i=r.wrapped().key,s=e===void 0?0:this.data[i].indexOf(e),a=this.data[i][s];return this.data[i].splice(s,1),a.timeout&&clearTimeout(a.timeout),this.data[i].length===0&&delete this.data[i],this.onRemove(a.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(r){for(this.max=r;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(r){const e=[];for(const i in this.data)for(const s of this.data[i])r(s.value)||e.push(s);for(const i of e)this.remove(i.value.tileID,i)}},D.ay=function(r,e){let i=0,s=0;if(r.kind==="constant")s=r.layoutSize;else if(r.kind!=="source"){const{interpolationType:a,minZoom:u,maxZoom:h}=r,f=a?ir(Pi.interpolationFactor(a,e,u,h),0,1):0;r.kind==="camera"?s=ui.number(r.minSize,r.maxSize,f):i=f}return{uSizeT:i,uSize:s}},D.b=Sn,D.b$=To,D.b0=wr,D.b1=function(r){var e=new mt(3);return e[0]=r[0],e[1]=r[1],e[2]=r[2],e},D.b2=function(r,e,i){return r[0]=e[0]-i[0],r[1]=e[1]-i[1],r[2]=e[2]-i[2],r},D.b3=function(r,e){var i=e[0],s=e[1],a=e[2],u=i*i+s*s+a*a;return u>0&&(u=1/Math.sqrt(u)),r[0]=e[0]*u,r[1]=e[1]*u,r[2]=e[2]*u,r},D.b4=xn,D.b5=function(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]},D.b6=function(r,e,i){return r[0]=e[0]*i[0],r[1]=e[1]*i[1],r[2]=e[2]*i[2],r[3]=e[3]*i[3],r},D.b7=Ni,D.b8=function(r,e,i){const s=e[0]*i[0]+e[1]*i[1]+e[2]*i[2];return s===0?null:(-(r[0]*i[0]+r[1]*i[1]+r[2]*i[2])-i[3])/s},D.b9=Tr,D.bA=function(){return new Float64Array(3)},D.bB=Kn,D.bC=function(r,e,i){var s=i[0],a=i[1],u=i[2],h=i[3],f=e[0],g=e[1],y=e[2],x=a*y-u*g,b=u*f-s*y,S=s*g-a*f;return r[0]=f+h*(x+=x)+a*(S+=S)-u*(b+=b),r[1]=g+h*b+u*x-s*S,r[2]=y+h*S+s*b-a*x,r},D.bD=function(r,e,i){const s=(a=[r[0],r[1],r[2],e[0],e[1],e[2],i[0],i[1],i[2]])[0]*((x=a[8])*(h=a[4])-(f=a[5])*(y=a[7]))+a[1]*(-x*(u=a[3])+f*(g=a[6]))+a[2]*(y*u-h*g);var a,u,h,f,g,y,x;if(s===0)return null;const b=xn([],[e[0],e[1],e[2]],[i[0],i[1],i[2]]),S=xn([],[i[0],i[1],i[2]],[r[0],r[1],r[2]]),P=xn([],[r[0],r[1],r[2]],[e[0],e[1],e[2]]),I=rn([],b,-r[3]);return wr(I,I,rn([],S,-e[3])),wr(I,I,rn([],P,-i[3])),rn(I,I,1/s),I},D.bE=Ch,D.bF=function(){return new Float64Array(4)},D.bG=function(r,e,i,s){var a=[],u=[];return a[0]=e[0]-i[0],a[1]=e[1]-i[1],a[2]=e[2]-i[2],u[0]=a[0]*Math.cos(s)-a[1]*Math.sin(s),u[1]=a[0]*Math.sin(s)+a[1]*Math.cos(s),u[2]=a[2],r[0]=u[0]+i[0],r[1]=u[1]+i[1],r[2]=u[2]+i[2],r},D.bH=function(r,e,i,s){var a=[],u=[];return a[0]=e[0]-i[0],a[1]=e[1]-i[1],a[2]=e[2]-i[2],u[0]=a[0],u[1]=a[1]*Math.cos(s)-a[2]*Math.sin(s),u[2]=a[1]*Math.sin(s)+a[2]*Math.cos(s),r[0]=u[0]+i[0],r[1]=u[1]+i[1],r[2]=u[2]+i[2],r},D.bI=function(r,e,i,s){var a=[],u=[];return a[0]=e[0]-i[0],a[1]=e[1]-i[1],a[2]=e[2]-i[2],u[0]=a[2]*Math.sin(s)+a[0]*Math.cos(s),u[1]=a[1],u[2]=a[2]*Math.cos(s)-a[0]*Math.sin(s),r[0]=u[0]+i[0],r[1]=u[1]+i[1],r[2]=u[2]+i[2],r},D.bJ=function(r,e,i){var s=Math.sin(i),a=Math.cos(i),u=e[0],h=e[1],f=e[2],g=e[3],y=e[8],x=e[9],b=e[10],S=e[11];return e!==r&&(r[4]=e[4],r[5]=e[5],r[6]=e[6],r[7]=e[7],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15]),r[0]=u*a-y*s,r[1]=h*a-x*s,r[2]=f*a-b*s,r[3]=g*a-S*s,r[8]=u*s+y*a,r[9]=h*s+x*a,r[10]=f*s+b*a,r[11]=g*s+S*a,r},D.bK=function(r,e){const i=Sr(r,360),s=Sr(e,360),a=s-i,u=s>i?a-360:a+360;return Math.abs(a)<Math.abs(u)?a:u},D.bL=function(r){return r[0]=0,r[1]=0,r[2]=0,r},D.bM=function(r,e,i,s){const a=Math.sqrt(r*r+e*e),u=Math.sqrt(i*i+s*s);r/=a,e/=a,i/=u,s/=u;const h=Math.acos(r*i+e*s);return-e*i+r*s>0?h:-h},D.bN=function(r,e){const i=Sr(r,2*Math.PI),s=Sr(e,2*Math.PI);return Math.min(Math.abs(i-s),Math.abs(i-s+2*Math.PI),Math.abs(i-s-2*Math.PI))},D.bO=function(){const r={},e=K.$version;for(const i in K.$root){const s=K.$root[i];if(s.required){let a=null;a=i==="version"?e:s.type==="array"?[]:{},a!=null&&(r[i]=a)}}return r},D.bP=$,D.bQ=pl,D.bR=function r(e,i){if(Array.isArray(e)){if(!Array.isArray(i)||e.length!==i.length)return!1;for(let s=0;s<e.length;s++)if(!r(e[s],i[s]))return!1;return!0}if(typeof e=="object"&&e!==null&&i!==null){if(typeof i!="object"||Object.keys(e).length!==Object.keys(i).length)return!1;for(const s in e)if(!r(e[s],i[s]))return!1;return!0}return e===i},D.bS=function(r){r=r.slice();const e=Object.create(null);for(let i=0;i<r.length;i++)e[r[i].id]=r[i];for(let i=0;i<r.length;i++)"ref"in r[i]&&(r[i]=We(r[i],e[r[i].ref]));return r},D.bT=function(r,e){if(r.type==="custom")return new qg(r,e);switch(r.type){case"background":return new Gg(r,e);case"circle":return new Cm(r,e);case"color-relief":return new km(r,e);case"fill":return new Wm(r,e);case"fill-extrusion":return new og(r,e);case"heatmap":return new Em(r,e);case"hillshade":return new Dm(r,e);case"line":return new pg(r,e);case"raster":return new Kc(r,e);case"symbol":return new pu(r,e)}},D.bU=r=>r.type==="raster",D.bV=mi,D.bW=function(r,e){if(!r)return[{command:"setStyle",args:[e]}];let i=[];try{if(!Ue(r.version,e.version))return[{command:"setStyle",args:[e]}];Ue(r.center,e.center)||i.push({command:"setCenter",args:[e.center]}),Ue(r.state,e.state)||i.push({command:"setGlobalState",args:[e.state]}),Ue(r.centerAltitude,e.centerAltitude)||i.push({command:"setCenterAltitude",args:[e.centerAltitude]}),Ue(r.zoom,e.zoom)||i.push({command:"setZoom",args:[e.zoom]}),Ue(r.bearing,e.bearing)||i.push({command:"setBearing",args:[e.bearing]}),Ue(r.pitch,e.pitch)||i.push({command:"setPitch",args:[e.pitch]}),Ue(r.roll,e.roll)||i.push({command:"setRoll",args:[e.roll]}),Ue(r.sprite,e.sprite)||i.push({command:"setSprite",args:[e.sprite]}),Ue(r.glyphs,e.glyphs)||i.push({command:"setGlyphs",args:[e.glyphs]}),Ue(r.transition,e.transition)||i.push({command:"setTransition",args:[e.transition]}),Ue(r.light,e.light)||i.push({command:"setLight",args:[e.light]}),Ue(r.terrain,e.terrain)||i.push({command:"setTerrain",args:[e.terrain]}),Ue(r.sky,e.sky)||i.push({command:"setSky",args:[e.sky]}),Ue(r.projection,e.projection)||i.push({command:"setProjection",args:[e.projection]});const s={},a=[];(function(h,f,g,y){let x;for(x in f=f||{},h=h||{})Object.prototype.hasOwnProperty.call(h,x)&&(Object.prototype.hasOwnProperty.call(f,x)||et(x,g,y));for(x in f)Object.prototype.hasOwnProperty.call(f,x)&&(Object.prototype.hasOwnProperty.call(h,x)?Ue(h[x],f[x])||(h[x].type==="geojson"&&f[x].type==="geojson"&&wt(h,f,x)?Ze(g,{command:"setGeoJSONSourceData",args:[x,f[x].data]}):Nt(x,f,g,y)):qe(x,f,g))})(r.sources,e.sources,a,s);const u=[];r.layers&&r.layers.forEach((h=>{"source"in h&&s[h.source]?i.push({command:"removeLayer",args:[h.id]}):u.push(h)})),i=i.concat(a),(function(h,f,g){f=f||[];const y=(h=h||[]).map(ci),x=f.map(ci),b=h.reduce(Rt,{}),S=f.reduce(Rt,{}),P=y.slice(),I=Object.create(null);let A,L,O,G,B;for(let V=0,W=0;V<y.length;V++)A=y[V],Object.prototype.hasOwnProperty.call(S,A)?W++:(Ze(g,{command:"removeLayer",args:[A]}),P.splice(P.indexOf(A,W),1));for(let V=0,W=0;V<x.length;V++)A=x[x.length-1-V],P[P.length-1-V]!==A&&(Object.prototype.hasOwnProperty.call(b,A)?(Ze(g,{command:"removeLayer",args:[A]}),P.splice(P.lastIndexOf(A,P.length-W),1)):W++,G=P[P.length-V],Ze(g,{command:"addLayer",args:[S[A],G]}),P.splice(P.length-V,0,A),I[A]=!0);for(let V=0;V<x.length;V++)if(A=x[V],L=b[A],O=S[A],!I[A]&&!Ue(L,O))if(Ue(L.source,O.source)&&Ue(L["source-layer"],O["source-layer"])&&Ue(L.type,O.type)){for(B in jt(L.layout,O.layout,g,A,null,"setLayoutProperty"),jt(L.paint,O.paint,g,A,null,"setPaintProperty"),Ue(L.filter,O.filter)||Ze(g,{command:"setFilter",args:[A,O.filter]}),Ue(L.minzoom,O.minzoom)&&Ue(L.maxzoom,O.maxzoom)||Ze(g,{command:"setLayerZoomRange",args:[A,O.minzoom,O.maxzoom]}),L)Object.prototype.hasOwnProperty.call(L,B)&&B!=="layout"&&B!=="paint"&&B!=="filter"&&B!=="metadata"&&B!=="minzoom"&&B!=="maxzoom"&&(B.indexOf("paint.")===0?jt(L[B],O[B],g,A,B.slice(6),"setPaintProperty"):Ue(L[B],O[B])||Ze(g,{command:"setLayerProperty",args:[A,B,O[B]]}));for(B in O)Object.prototype.hasOwnProperty.call(O,B)&&!Object.prototype.hasOwnProperty.call(L,B)&&B!=="layout"&&B!=="paint"&&B!=="filter"&&B!=="metadata"&&B!=="minzoom"&&B!=="maxzoom"&&(B.indexOf("paint.")===0?jt(L[B],O[B],g,A,B.slice(6),"setPaintProperty"):Ue(L[B],O[B])||Ze(g,{command:"setLayerProperty",args:[A,B,O[B]]}))}else Ze(g,{command:"removeLayer",args:[A]}),G=P[P.lastIndexOf(A)+1],Ze(g,{command:"addLayer",args:[O,G]})})(u,e.layers,i)}catch(s){console.warn("Unable to compute style diff:",s),i=[{command:"setStyle",args:[e]}]}return i},D.bX=function(r){const e=[],i=r.id;return i===void 0&&e.push({message:`layers.${i}: missing required property "id"`}),r.render===void 0&&e.push({message:`layers.${i}: missing required method "render"`}),r.renderingMode&&r.renderingMode!=="2d"&&r.renderingMode!=="3d"&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},D.bY=wn,D.bZ=Tn,D.b_=class extends Ii{constructor(r,e){super(r,e),this.current=0}set(r){this.current!==r&&(this.current=r,this.gl.uniform1i(this.location,r))}},D.ba=function(r,e,i){return r[0]=e[0]*i,r[1]=e[1]*i,r[2]=e[2]*i,r[3]=e[3]*i,r},D.bb=function(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]+r[3]},D.bc=xp,D.bd=Aa,D.be=function(r,e,i,s,a){var u=1/Math.tan(e/2);if(r[0]=u/i,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=u,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=-1,r[12]=0,r[13]=0,r[15]=0,a!=null&&a!==1/0){var h=1/(s-a);r[10]=(a+s)*h,r[14]=2*a*s*h}else r[10]=-1,r[14]=-2*s;return r},D.bf=function(r){var e=new mt(16);return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],e},D.bg=function(r,e,i){var s=Math.sin(i),a=Math.cos(i),u=e[0],h=e[1],f=e[2],g=e[3],y=e[4],x=e[5],b=e[6],S=e[7];return e!==r&&(r[8]=e[8],r[9]=e[9],r[10]=e[10],r[11]=e[11],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15]),r[0]=u*a+y*s,r[1]=h*a+x*s,r[2]=f*a+b*s,r[3]=g*a+S*s,r[4]=y*a-u*s,r[5]=x*a-h*s,r[6]=b*a-f*s,r[7]=S*a-g*s,r},D.bh=function(r,e,i){var s=Math.sin(i),a=Math.cos(i),u=e[4],h=e[5],f=e[6],g=e[7],y=e[8],x=e[9],b=e[10],S=e[11];return e!==r&&(r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15]),r[4]=u*a+y*s,r[5]=h*a+x*s,r[6]=f*a+b*s,r[7]=g*a+S*s,r[8]=y*a-u*s,r[9]=x*a-h*s,r[10]=b*a-f*s,r[11]=S*a-g*s,r},D.bi=function(){const r=new Float32Array(16);return Yn(r),r},D.bj=function(){const r=new Float64Array(16);return Yn(r),r},D.bk=function(){return new Float64Array(16)},D.bl=function(r,e,i){const s=new Float64Array(4);return Kn(s,r,e-90,i),s},D.bm=function(r,e,i,s){var a,u,h,f,g,y=e[0],x=e[1],b=e[2],S=e[3],P=i[0],I=i[1],A=i[2],L=i[3];return(u=y*P+x*I+b*A+S*L)<0&&(u=-u,P=-P,I=-I,A=-A,L=-L),1-u>bt?(a=Math.acos(u),h=Math.sin(a),f=Math.sin((1-s)*a)/h,g=Math.sin(s*a)/h):(f=1-s,g=s),r[0]=f*y+g*P,r[1]=f*x+g*I,r[2]=f*b+g*A,r[3]=f*S+g*L,r},D.bn=function(r){const e=new Float64Array(9);var i,s,a,u,h,f,g,y,x,b,S,P,I,A,L,O,G,B;b=(a=(s=r)[0])*(g=a+a),S=(u=s[1])*g,I=(h=s[2])*g,A=h*(y=u+u),O=(f=s[3])*g,G=f*y,B=f*(x=h+h),(i=e)[0]=1-(P=u*y)-(L=h*x),i[3]=S-B,i[6]=I+G,i[1]=S+B,i[4]=1-b-L,i[7]=A-O,i[2]=I-G,i[5]=A+O,i[8]=1-b-P;const V=Fr(-Math.asin(ir(e[2],-1,1)));let W,ee;return Math.hypot(e[5],e[8])<.001?(W=0,ee=-Fr(Math.atan2(e[3],e[4]))):(W=Fr(e[5]===0&&e[8]===0?0:Math.atan2(e[5],e[8])),ee=Fr(e[1]===0&&e[0]===0?0:Math.atan2(e[1],e[0]))),{roll:W,pitch:V+90,bearing:ee}},D.bo=function(r,e){return r.roll==e.roll&&r.pitch==e.pitch&&r.bearing==e.bearing},D.bp=st,D.bq=Yr,D.br=Ma,D.bs=Bl,D.bt=Pa,D.bu=Ls,D.bv=Jn,D.bw=Ri,D.bx=function(r,e,i,s,a){return Ls(s,a,ir((r-e)/(i-e),0,1))},D.by=function(r,e,i,s){return r[0]=e[0]+i[0]*s,r[1]=e[1]+i[1]*s,r[2]=e[2]+i[2]*s,r},D.bz=Sr,D.c=ie,D.c$=class{constructor(r){this.start=`${r}#start`,this.end=`${r}#end`,this.measure=r,performance.mark(this.start)}finish(){performance.mark(this.end);let r=performance.getEntriesByName(this.measure);return r.length===0&&(performance.measure(this.measure,this.start,this.end),r=performance.getEntriesByName(this.measure),performance.clearMarks(this.start),performance.clearMarks(this.end),performance.clearMeasures(this.measure)),r}},D.c0=class extends Ii{constructor(r,e){super(r,e),this.current=ws}set(r){if(r[12]!==this.current[12]||r[0]!==this.current[0])return this.current=r,void this.gl.uniformMatrix4fv(this.location,!1,r);for(let e=1;e<16;e++)if(r[e]!==this.current[e]){this.current=r,this.gl.uniformMatrix4fv(this.location,!1,r);break}}},D.c1=wo,D.c2=class extends Ii{constructor(r,e){super(r,e),this.current=[0,0,0]}set(r){r[0]===this.current[0]&&r[1]===this.current[1]&&r[2]===this.current[2]||(this.current=r,this.gl.uniform3f(this.location,r[0],r[1],r[2]))}},D.c3=class extends Ii{constructor(r,e){super(r,e),this.current=[0,0]}set(r){r[0]===this.current[0]&&r[1]===this.current[1]||(this.current=r,this.gl.uniform2f(this.location,r[0],r[1]))}},D.c4=kr,D.c5=function(r,e){var i=Math.sin(e),s=Math.cos(e);return r[0]=s,r[1]=i,r[2]=0,r[3]=-i,r[4]=s,r[5]=0,r[6]=0,r[7]=0,r[8]=1,r},D.c6=function(r,e,i){var s=e[0],a=e[1],u=e[2];return r[0]=s*i[0]+a*i[3]+u*i[6],r[1]=s*i[1]+a*i[4]+u*i[7],r[2]=s*i[2]+a*i[5]+u*i[8],r},D.c7=function(r,e,i,s,a,u,h){var f=1/(e-i),g=1/(s-a),y=1/(u-h);return r[0]=-2*f,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=-2*g,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=2*y,r[11]=0,r[12]=(e+i)*f,r[13]=(a+s)*g,r[14]=(h+u)*y,r[15]=1,r},D.c8=class extends Ii{constructor(r,e){super(r,e),this.current=new Array}set(r){if(r!=this.current){this.current=r;const e=new Float32Array(4*r.length);for(let i=0;i<r.length;i++)e[4*i]=r[i].r,e[4*i+1]=r[i].g,e[4*i+2]=r[i].b,e[4*i+3]=r[i].a;this.gl.uniform4fv(this.location,e)}}},D.c9=class extends Ii{constructor(r,e){super(r,e),this.current=new Array}set(r){if(r!=this.current){this.current=r;const e=new Float32Array(r);this.gl.uniform1fv(this.location,e)}}},D.cA=function(r,e){var i;if(!cn[e])return!1;const s=r?.target,a=((i=s?.ownerDocument)===null||i===void 0?void 0:i.defaultView)||window;return r instanceof a.MouseEvent||r instanceof a.WheelEvent},D.cB=function(r,e){return Br[e]&&"touches"in r},D.cC=function(r){return Br[r]||cn[r]},D.cD=function(r,e,i){var s=e[0],a=e[1];return r[0]=i[0]*s+i[4]*a+i[12],r[1]=i[1]*s+i[5]*a+i[13],r},D.cE=function(r,e){const{x:i,y:s}=Gl.fromLngLat(e);return!(r<0||r>25||s<0||s>=1||i<0||i>=1)},D.cF=function(r,e){return r[0]=e[0],r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=e[1],r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=e[2],r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r},D.cG=class extends fa{},D.cH=A_,D.cJ=F,D.cK=function(r,e){ie.REGISTERED_PROTOCOLS[r]=e},D.cL=function(r){delete ie.REGISTERED_PROTOCOLS[r]},D.cM=function(r,e){const i={};for(let a=0;a<r.length;a++){const u=e&&e[r[a].id]||Ac(r[a]);e&&(e[r[a].id]=u);let h=i[u];h||(h=i[u]=[]),h.push(r[a])}const s=[];for(const a in i)s.push(i[a]);return s},D.cN=De,D.cO=wp,D.cP=ef,D.cQ=rp,D.cR=function(r){var e;r.bucket.createArrays(),r.bucket.tilePixelRatio=ht/(512*r.bucket.overscaling),r.bucket.compareText={},r.bucket.iconsNeedLinear=!1;const i=r.bucket.layers[0],s=i.layout,a=i._unevaluatedLayout._values,u={layoutIconSize:a["icon-size"].possiblyEvaluate(new vt(r.bucket.zoom+1),r.canonical),layoutTextSize:a["text-size"].possiblyEvaluate(new vt(r.bucket.zoom+1),r.canonical),textMaxSize:a["text-size"].possiblyEvaluate(new vt(18))};if(r.bucket.textSizeData.kind==="composite"){const{minZoom:x,maxZoom:b}=r.bucket.textSizeData;u.compositeTextSizes=[a["text-size"].possiblyEvaluate(new vt(x),r.canonical),a["text-size"].possiblyEvaluate(new vt(b),r.canonical)]}if(r.bucket.iconSizeData.kind==="composite"){const{minZoom:x,maxZoom:b}=r.bucket.iconSizeData;u.compositeIconSizes=[a["icon-size"].possiblyEvaluate(new vt(x),r.canonical),a["icon-size"].possiblyEvaluate(new vt(b),r.canonical)]}const h=s.get("text-line-height")*si,f=s.get("text-rotation-alignment")!=="viewport"&&s.get("symbol-placement")!=="point",g=s.get("text-keep-upright"),y=s.get("text-size");for(const x of r.bucket.features){const b=s.get("text-font").evaluate(x,{},r.canonical).join(","),S=y.evaluate(x,{},r.canonical),P=u.layoutTextSize.evaluate(x,{},r.canonical),I=u.layoutIconSize.evaluate(x,{},r.canonical),A={horizontal:{},vertical:void 0},L=x.text;let O,G=[0,0];if(L){const W=L.toString(),ee=s.get("text-letter-spacing").evaluate(x,{},r.canonical)*si,ae=ha(W)?ee:0,_e=s.get("text-anchor").evaluate(x,{},r.canonical),ye=ff(i,x,r.canonical);if(!ye){const ve=s.get("text-radial-offset").evaluate(x,{},r.canonical);G=ve?pf(_e,[ve*si,$h]):s.get("text-offset").evaluate(x,{},r.canonical).map((fe=>fe*si))}let xe=f?"center":s.get("text-justify").evaluate(x,{},r.canonical);const Ee=s.get("symbol-placement")==="point"?s.get("text-max-width").evaluate(x,{},r.canonical)*si:1/0,we=()=>{r.bucket.allowVerticalPlacement&&fl(W)&&(A.vertical=hu(L,r.glyphMap,r.glyphPositions,r.imagePositions,b,Ee,h,_e,"left",ae,G,D.az.vertical,!0,P,S))};if(!f&&ye){const ve=new Set;if(xe==="auto")for(let ze=0;ze<ye.values.length;ze+=2)ve.add(Hh(ye.values[ze]));else ve.add(xe);let fe=!1;for(const ze of ve)if(!A.horizontal[ze])if(fe)A.horizontal[ze]=A.horizontal[0];else{const Le=hu(L,r.glyphMap,r.glyphPositions,r.imagePositions,b,Ee,h,"center",ze,ae,G,D.az.horizontal,!1,P,S);Le&&(A.horizontal[ze]=Le,fe=Le.positionedLines.length===1)}we()}else{xe==="auto"&&(xe=Hh(_e));const ve=hu(L,r.glyphMap,r.glyphPositions,r.imagePositions,b,Ee,h,_e,xe,ae,G,D.az.horizontal,!1,P,S);ve&&(A.horizontal[xe]=ve),we(),fl(W)&&f&&g&&(A.vertical=hu(L,r.glyphMap,r.glyphPositions,r.imagePositions,b,Ee,h,_e,xe,ae,G,D.az.vertical,!1,P,S))}}let B=!1;if(x.icon&&x.icon.name){const W=r.imageMap[x.icon.name];W&&(O=Vg(r.imagePositions[x.icon.name],s.get("icon-offset").evaluate(x,{},r.canonical),s.get("icon-anchor").evaluate(x,{},r.canonical)),B=!!W.sdf,r.bucket.sdfIcons===void 0?r.bucket.sdfIcons=B:r.bucket.sdfIcons!==B&&gi("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(W.pixelRatio!==r.bucket.pixelRatio||s.get("icon-rotate").constantOr(1)!==0)&&(r.bucket.iconsNeedLinear=!0))}const V=gf(A.horizontal)||A.vertical;(e=r.bucket).iconsInText||(e.iconsInText=!!V&&V.iconsInText),(V||O)&&I_(r.bucket,x,A,O,r.imageMap,u,P,I,G,B,r.canonical,r.subdivisionGranularity)}r.showCollisionBoxes&&r.bucket.generateCollisionDebugBuffers()},D.cS=mh,D.cT=_h,D.cU=yh,D.cV=function(r){const e=new uu;return(function(i,s){for(const a in i.layers)s.writeMessage(3,f_,i.layers[a])})(r,e),e.finish()},D.cW=function(r,e,i,s,a,u){let h=nf(r,e,i,a,0);return h=nf(h,e,s,u,1),h},D.cX=class{constructor(r){this.maxEntries=r,this.map=new Map}get(r){const e=this.map.get(r);return e!==void 0&&(this.map.delete(r),this.map.set(r,e)),e}set(r,e){if(this.map.has(r))this.map.delete(r);else if(this.map.size>=this.maxEntries){const i=this.map.keys().next().value;this.map.delete(i)}this.map.set(r,e)}clear(){this.map.clear()}},D.cY=Vd,D.cZ=uu,D.c_=Jp,D.ca=class extends bs{},D.cb=_g,D.cc=class extends ya{},D.cd=uh,D.ce=function(r){return r<=1?1:Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))},D.cf=Td,D.cg=function(r,e,i){var s=e[0],a=e[1],u=e[2],h=i[3]*s+i[7]*a+i[11]*u+i[15];return r[0]=(i[0]*s+i[4]*a+i[8]*u+i[12])/(h=h||1),r[1]=(i[1]*s+i[5]*a+i[9]*u+i[13])/h,r[2]=(i[2]*s+i[6]*a+i[10]*u+i[14])/h,r},D.ch=class extends Tl{},D.ci=class extends d{},D.cj=function(r,e){return r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]&&r[3]===e[3]&&r[4]===e[4]&&r[5]===e[5]&&r[6]===e[6]&&r[7]===e[7]&&r[8]===e[8]&&r[9]===e[9]&&r[10]===e[10]&&r[11]===e[11]&&r[12]===e[12]&&r[13]===e[13]&&r[14]===e[14]&&r[15]===e[15]},D.ck=function(r,e){var i=r[0],s=r[1],a=r[2],u=r[3],h=r[4],f=r[5],g=r[6],y=r[7],x=r[8],b=r[9],S=r[10],P=r[11],I=r[12],A=r[13],L=r[14],O=r[15],G=e[0],B=e[1],V=e[2],W=e[3],ee=e[4],ae=e[5],_e=e[6],ye=e[7],xe=e[8],Ee=e[9],we=e[10],ve=e[11],fe=e[12],ze=e[13],Le=e[14],Ve=e[15];return Math.abs(i-G)<=bt*Math.max(1,Math.abs(i),Math.abs(G))&&Math.abs(s-B)<=bt*Math.max(1,Math.abs(s),Math.abs(B))&&Math.abs(a-V)<=bt*Math.max(1,Math.abs(a),Math.abs(V))&&Math.abs(u-W)<=bt*Math.max(1,Math.abs(u),Math.abs(W))&&Math.abs(h-ee)<=bt*Math.max(1,Math.abs(h),Math.abs(ee))&&Math.abs(f-ae)<=bt*Math.max(1,Math.abs(f),Math.abs(ae))&&Math.abs(g-_e)<=bt*Math.max(1,Math.abs(g),Math.abs(_e))&&Math.abs(y-ye)<=bt*Math.max(1,Math.abs(y),Math.abs(ye))&&Math.abs(x-xe)<=bt*Math.max(1,Math.abs(x),Math.abs(xe))&&Math.abs(b-Ee)<=bt*Math.max(1,Math.abs(b),Math.abs(Ee))&&Math.abs(S-we)<=bt*Math.max(1,Math.abs(S),Math.abs(we))&&Math.abs(P-ve)<=bt*Math.max(1,Math.abs(P),Math.abs(ve))&&Math.abs(I-fe)<=bt*Math.max(1,Math.abs(I),Math.abs(fe))&&Math.abs(A-ze)<=bt*Math.max(1,Math.abs(A),Math.abs(ze))&&Math.abs(L-Le)<=bt*Math.max(1,Math.abs(L),Math.abs(Le))&&Math.abs(O-Ve)<=bt*Math.max(1,Math.abs(O),Math.abs(Ve))},D.cl=function(r,e){return r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[4]=e[4],r[5]=e[5],r[6]=e[6],r[7]=e[7],r[8]=e[8],r[9]=e[9],r[10]=e[10],r[11]=e[11],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15],r},D.cm=r=>r.type==="symbol",D.cn=r=>r.type==="circle",D.co=r=>r.type==="heatmap",D.cp=r=>r.type==="line",D.cq=r=>r.type==="fill",D.cr=r=>r.type==="fill-extrusion",D.cs=r=>r.type==="hillshade",D.ct=r=>r.type==="color-relief",D.cu=r=>r.type==="background",D.cv=r=>r.type==="custom",D.cw=on,D.cx=function(r,e,i){if(e<=0)return r;const s=1/e;return i===void 0||Math.abs(i)<1e-10?Math.round(r*s)/s:(i>0?Math.ceil(r*s-1e-9):Math.floor(r*s+1e-10))/s},D.cy=function(r,e,i){const s=Ht(e.x-i.x,e.y-i.y),a=Ht(r.x-i.x,r.y-i.y);var u,h;return Fr(Math.atan2(s[0]*a[1]-s[1]*a[0],(u=s)[0]*(h=a)[0]+u[1]*h[1]))},D.cz=Rr,D.d=oe,D.d0=function(r,e,i,s,a){return c(this,void 0,void 0,(function*(){if(pr())try{return yield Pn(r,e,i,s,a)}catch{}return(function(u,h,f,g,y){const x=u.width,b=u.height;an&&Mr||(an=new OffscreenCanvas(x,b),Mr=an.getContext("2d",{willReadFrequently:!0})),an.width=x,an.height=b,Mr.drawImage(u,0,0,x,b);const S=Mr.getImageData(h,f,g,y);return Mr.clearRect(0,0,x,b),S.data})(r,e,i,s,a)}))},D.d1=Cd,D.d2=_t,D.d3=class{constructor(r,e){this.layers={[$l]:this},this.name=$l,this.version=e?e.version:1,this.extent=e?e.extent:4096,this.length=r.length,this.features=r}feature(r){return new p_(this.features[r],this.extent)}},D.d4=Vn,D.d5=Hr,D.e=ki,D.f=r=>c(void 0,void 0,void 0,(function*(){if(r.byteLength===0)return createImageBitmap(new ImageData(1,1));const e=new Blob([new Uint8Array(r)],{type:"image/png"});try{return createImageBitmap(e)}catch(i){throw new Error(`Could not load image because of ${i.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),D.g=E,D.h=r=>new Promise(((e,i)=>{const s=new Image;s.onload=()=>{e(s),URL.revokeObjectURL(s.src),s.onload=null,window.requestAnimationFrame((()=>{s.src=es}))},s.onerror=()=>i(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const a=new Blob([new Uint8Array(r)],{type:"image/png"});s.src=r.byteLength?URL.createObjectURL(a):es})),D.i=Pr,D.j=(r,e)=>J(ki(r,{type:"json"}),e),D.k=be,D.l=se,D.m=J,D.n=(r,e)=>J(ki(r,{type:"arrayBuffer"}),e),D.o=function(r){return new uu(r).readFields(Dg,[])},D.p=ip,D.q=function(r){return/[\u02EA\u02EB\u1100-\u11FF\u2E80-\u2FDF\u3000-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\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-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\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(r))},D.r=zl,D.s=ln,D.t=Mi,D.u=K,D.v=ho,D.w=gi,D.x=xl,D.y=Hi,D.z=pa})),$e("worker",["./shared"],(function(D){class c{constructor(E,k){this.keyCache={},E&&this.replace(E,k)}replace(E,k){this._layerConfigs={},this._layers={},this.update(E,[],k)}update(E,k,F){for(const J of E){this._layerConfigs[J.id]=J;const oe=this._layers[J.id]=D.bT(J,F);oe._featureFilter=D.aj(oe.filter,F),this.keyCache[J.id]&&delete this.keyCache[J.id]}for(const J of k)delete this.keyCache[J],delete this._layerConfigs[J],delete this._layers[J];this.familiesBySource={};const $=D.cM(Object.values(this._layerConfigs),this.keyCache);for(const J of $){const oe=J.map((K=>this._layers[K.id])),le=oe[0];if(le.isHidden())continue;const ne=le.source||"";let se=this.familiesBySource[ne];se||(se=this.familiesBySource[ne]={});const be=le.sourceLayer||D.ai;let me=se[be];me||(me=se[be]=[]),me.push(oe)}}}class Te{constructor(E){const k={},F=[];for(const le in E){const ne=E[le],se=k[le]={};for(const be in ne){const me=ne[+be];if(!me||me.bitmap.width===0||me.bitmap.height===0)continue;const K={x:0,y:0,w:me.bitmap.width+2,h:me.bitmap.height+2};F.push(K),se[be]={rect:K,metrics:me.metrics}}}const{w:$,h:J}=D.p(F),oe=new D.r({width:$||1,height:J||1});for(const le in E){const ne=E[le];for(const se in ne){const be=ne[+se];if(!be||be.bitmap.width===0||be.bitmap.height===0)continue;const me=k[le][se].rect;D.r.copy(be.bitmap,oe,{x:0,y:0},{x:me.x+1,y:me.y+1},be.bitmap)}}this.image=oe,this.positions=k}}D.cN("GlyphAtlas",Te);class _t{constructor(E){this.tileID=new D.a2(E.tileID.overscaledZ,E.tileID.wrap,E.tileID.canonical.z,E.tileID.canonical.x,E.tileID.canonical.y),this.uid=E.uid,this.zoom=E.zoom,this.pixelRatio=E.pixelRatio,this.tileSize=E.tileSize,this.source=E.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=E.showCollisionBoxes,this.collectResourceTiming=!!E.collectResourceTiming,this.returnDependencies=!!E.returnDependencies,this.promoteId=E.promoteId,this.inFlightDependencies=[]}parse(E,k,F,$,J){return D._(this,void 0,void 0,(function*(){this.status="parsing",this.data=E,this.collisionBoxArray=new D.ag;const oe=new D.cO(Object.keys(E.layers).sort()),le=new D.cP(this.tileID,this.promoteId);le.bucketLayerIDs=[];const ne={},se={featureIndex:le,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:F,subdivisionGranularity:J},be=k.familiesBySource[this.source];for(const ut in be){const Ct=E.layers[ut];if(!Ct)continue;Ct.version===1&&D.w(`Vector tile source "${this.source}" layer "${ut}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const Cn=oe.encode(ut),Or=[];for(let Me=0;Me<Ct.length;Me++){const Xe=Ct.feature(Me),Ye=le.getId(Xe,ut);Or.push({feature:Xe,id:Ye,index:Me,sourceLayerIndex:Cn})}for(const Me of be[ut]){const Xe=Me[0];Xe.source!==this.source&&D.w(`layer.source = ${Xe.source} does not equal this.source = ${this.source}`),Xe.isHidden(this.zoom,!0)||(ct(Me,this.zoom,F),(ne[Xe.id]=Xe.createBucket({index:le.bucketLayerIDs.length,layers:Me,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Cn,sourceID:this.source})).populate(Or,se,this.tileID.canonical),le.bucketLayerIDs.push(Me.map((Ye=>Ye.id))))}}const me=D.bY(se.glyphDependencies,(ut=>Object.keys(ut).map(Number)));this.inFlightDependencies.forEach((ut=>ut?.abort())),this.inFlightDependencies=[];let K=Promise.resolve({});if(Object.keys(me).length){const ut=new AbortController;this.inFlightDependencies.push(ut),K=$.sendAsync({type:"GG",data:{stacks:me,source:this.source,tileID:this.tileID,type:"glyphs"}},ut)}const Oe=Object.keys(se.iconDependencies);let We=Promise.resolve({});if(Oe.length){const ut=new AbortController;this.inFlightDependencies.push(ut),We=$.sendAsync({type:"GI",data:{icons:Oe,source:this.source,tileID:this.tileID,type:"icons"}},ut)}const Ue=Object.keys(se.patternDependencies);let Ze=Promise.resolve({});if(Ue.length){const ut=new AbortController;this.inFlightDependencies.push(ut),Ze=$.sendAsync({type:"GI",data:{icons:Ue,source:this.source,tileID:this.tileID,type:"patterns"}},ut)}const qe=se.dashDependencies;let et=Promise.resolve({});if(Object.keys(qe).length){const ut=new AbortController;this.inFlightDependencies.push(ut),et=$.sendAsync({type:"GDA",data:{dashes:qe}},ut)}const[Nt,wt,jt,ci]=yield Promise.all([K,We,Ze,et]),Rt=new Te(Nt),Pe=new D.cQ(wt,jt);for(const ut in ne){const Ct=ne[ut];Ct instanceof D.ah?(ct(Ct.layers,this.zoom,F),D.cR({bucket:Ct,glyphMap:Nt,glyphPositions:Rt.positions,imageMap:wt,imagePositions:Pe.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:se.subdivisionGranularity})):Ct.hasDependencies&&(Ct instanceof D.cS||Ct instanceof D.cT||Ct instanceof D.cU)&&(ct(Ct.layers,this.zoom,F),Ct.addFeatures(se,this.tileID.canonical,Pe.patternPositions,ci))}return this.status="done",{buckets:Object.values(ne).filter((ut=>!ut.isEmpty())),featureIndex:le,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Rt.image,imageAtlas:Pe,dashPositions:ci,glyphMap:this.returnDependencies?Nt:null,iconMap:this.returnDependencies?wt:null,glyphPositions:this.returnDependencies?Rt.positions:null}}))}}function ct(ie,E,k){const F=new D.H(E);for(const $ of ie)$.recalculate(F,k)}class Si{constructor(){this.loading={},this.loaded={},this.parsing={}}startLoading(E,k){this.loading[E]=k}finishLoading(E){delete this.loading[E]}abort(E){const k=this.loading[E];k?.abort&&(k.abort.abort(),delete this.loading[E])}setParsing(E,k){this.parsing[E]=k}consumeParsing(E){const k=this.parsing[E];if(k)return delete this.parsing[E],k}clearParsing(E){delete this.parsing[E]}markLoaded(E,k){this.loaded[E]=k}getLoaded(E){const k=this.loaded[E];if(k)return k}removeLoaded(E){delete this.loaded[E]}clearLoaded(){this.loaded={}}}class dr{constructor(E,k,F,$,J){this.type=E,this.properties=F||{},this.extent=J,this.pointsArray=k,this.id=$}loadGeometry(){return this.pointsArray.map((E=>E.map((k=>new D.P(k.x,k.y)))))}}class $t{constructor(E,k,F){this.version=2,this._myFeatures=E,this.name=k,this.length=E.length,this.extent=F}feature(E){return this._myFeatures[E]}}class tr{constructor(){this.layers={}}addLayer(E){this.layers[E.name]=E}}function He(ie){let E=D.cV(ie);return E.byteOffset===0&&E.byteLength===E.buffer.byteLength||(E=new Uint8Array(E)),{vectorTile:ie,rawData:E.buffer}}function pe(ie,E,k){const{extent:F}=ie,$=Math.pow(2,k.z-E.z),J=(k.x-E.x*$)*F,oe=(k.y-E.y*$)*F,le=[];for(let ne=0;ne<ie.length;ne++){const se=ie.feature(ne);let be=se.loadGeometry();for(const K of be)for(const Oe of K)Oe.x=Oe.x*$-J,Oe.y=Oe.y*$-oe;const me=128;be=D.cW(be,se.type,-me,-me,F+me,F+me),be.length!==0&&le.push(new dr(se.type,be,se.properties,se.id,F))}return new $t(le,ie.name,F)}class pr{constructor(E,k,F){this.actor=E,this.layerIndex=k,this.availableImages=F,this.tileState=new Si,this.overzoomedTileResultCache=new D.cX(1e3)}loadVectorTile(E,k){return D._(this,void 0,void 0,(function*(){const F=yield D.n(E.request,k);try{return{vectorTile:E.encoding!=="mlt"?new D.cY(new D.cZ(F.data)):new D.c_(F.data),rawData:F.data,cacheControl:F.cacheControl,expires:F.expires}}catch($){const J=new Uint8Array(F.data);let oe=`Unable to parse the tile at ${E.request.url}, `;throw oe+=J[0]===31&&J[1]===139?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${$.message}`,new Error(oe)}}))}loadTile(E){return D._(this,void 0,void 0,(function*(){const{uid:k,overzoomParameters:F}=E;F&&(E.request=F.overzoomRequest);const $=this._startRequestTiming(E),J=new _t(E);this.tileState.startLoading(k,J);const oe=new AbortController;J.abort=oe;try{const le=yield this.loadVectorTile(E,oe);if(this.tileState.finishLoading(k),!le)return null;let{vectorTile:ne,rawData:se}=le;F&&({vectorTile:ne,rawData:se}=this._getOverzoomTile(E,le.vectorTile));const be=this._getExpiryData(le),me=this._finishRequestTiming($);J.vectorTile=ne,this.tileState.markLoaded(k,J);const K={rawData:se,cacheControl:be,resourceTiming:me};this.tileState.setParsing(k,K);try{return yield this._parseWorkerTile(J,E,K)}finally{this.tileState.clearParsing(k)}}catch(le){throw this.tileState.finishLoading(k),J.status="done",this.tileState.markLoaded(k,J),le}}))}_parseWorkerTile(E,k,F){return D._(this,void 0,void 0,(function*(){let $=yield E.parse(E.vectorTile,this.layerIndex,this.availableImages,this.actor,k.subdivisionGranularity);if(F){const{rawData:J,cacheControl:oe,resourceTiming:le}=F;$=D.e({rawTileData:J.slice(0),encoding:k.encoding},$,oe,le)}return $}))}_getExpiryData(E){const{expires:k,cacheControl:F}=E,$={};return k&&($.expires=k),F&&($.cacheControl=F),$}_startRequestTiming(E){var k;if(!((k=E.request)===null||k===void 0)&&k.collectResourceTiming)return new D.c$(E.request.url)}_finishRequestTiming(E){const k=E?.finish();return k?{resourceTiming:JSON.parse(JSON.stringify(k))}:{}}_getOverzoomTile(E,k){const{tileID:F,source:$,overzoomParameters:J}=E,{maxZoomTileID:oe}=J,le=`${oe.key}_${F.key}`,ne=this.overzoomedTileResultCache.get(le);if(ne)return ne;const se=new tr,be=this.layerIndex.familiesBySource[$];for(const K in be){const Oe=k.layers[K];if(!Oe)continue;const We=pe(Oe,oe,F.canonical);We.length>0&&se.addLayer(We)}const me=He(se);return this.overzoomedTileResultCache.set(le,me),me}reloadTile(E){return D._(this,void 0,void 0,(function*(){const k=E.uid,F=this.tileState.getLoaded(k);if(!F)throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");if(F.showCollisionBoxes=E.showCollisionBoxes,F.status==="parsing"){const $=this.tileState.consumeParsing(k);return yield this._parseWorkerTile(F,E,$)}if(F.status==="done"&&F.vectorTile)return yield this._parseWorkerTile(F,E)}))}abortTile(E){return D._(this,void 0,void 0,(function*(){this.tileState.abort(E.uid)}))}removeTile(E){return D._(this,void 0,void 0,(function*(){this.tileState.removeLoaded(E.uid)}))}}class bt{constructor(){this.loaded={}}loadTile(E){return D._(this,void 0,void 0,(function*(){const{uid:k,encoding:F,rawImageData:$,redFactor:J,greenFactor:oe,blueFactor:le,baseShift:ne}=E,se=$.width+2,be=$.height+2,me=D.b($)?new D.R({width:se,height:be},yield D.d0($,-1,-1,se,be)):$,K=new D.d1(k,me,F,J,oe,le,ne);return this.loaded=this.loaded||{},this.loaded[k]=K,K}))}removeTile(E){const k=this.loaded,F=E.uid;k&&k[F]&&delete k[F]}}var mt,kr,Yn=(function(){if(kr)return mt;function ie(k,F){if(k.length!==0){E(k[0],F);for(var $=1;$<k.length;$++)E(k[$],!F)}}function E(k,F){for(var $=0,J=0,oe=0,le=k.length,ne=le-1;oe<le;ne=oe++){var se=(k[oe][0]-k[ne][0])*(k[ne][1]+k[oe][1]),be=$+se;J+=Math.abs($)>=Math.abs(se)?$-be+se:se-be+$,$=be}$+J>=0!=!!F&&k.reverse()}return kr=1,mt=function k(F,$){var J,oe=F&&F.type;if(oe==="FeatureCollection")for(J=0;J<F.features.length;J++)k(F.features[J],$);else if(oe==="GeometryCollection")for(J=0;J<F.geometries.length;J++)k(F.geometries[J],$);else if(oe==="Feature")k(F.geometry,$);else if(oe==="Polygon")ie(F.coordinates,$);else if(oe==="MultiPolygon")for(J=0;J<F.coordinates.length;J++)ie(F.coordinates[J],$);return F}})(),Ds=D.d2(Yn);const Ni={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:ie=>ie},zs=Math.fround||(wr=new Float32Array(1),ie=>(wr[0]=+ie,wr[0]));var wr;class rn{constructor(E){this.options=Object.assign(Object.create(Ni),E),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(E){const{log:k,minZoom:F,maxZoom:$}=this.options;k&&console.time("total time");const J=`prepare ${E.length} points`;k&&console.time(J),this.points=E;const oe=[];for(let ne=0;ne<E.length;ne++){const se=E[ne];if(!se.geometry)continue;const[be,me]=se.geometry.coordinates,K=zs(Tr(be)),Oe=zs(sn(me));oe.push(K,Oe,1/0,ne,-1,1),this.options.reduce&&oe.push(0)}let le=this.trees[$+1]=this._createTree(oe);k&&console.timeEnd(J);for(let ne=$;ne>=F;ne--){const se=+Date.now();le=this.trees[ne]=this._createTree(this._cluster(le,ne)),k&&console.log("z%d: %d clusters in %dms",ne,le.numItems,+Date.now()-se)}return k&&console.timeEnd("total time"),this}getClusters(E,k){let F=((E[0]+180)%360+360)%360-180;const $=Math.max(-90,Math.min(90,E[1]));let J=E[2]===180?180:((E[2]+180)%360+360)%360-180;const oe=Math.max(-90,Math.min(90,E[3]));if(E[2]-E[0]>=360)F=-180,J=180;else if(F>J){const me=this.getClusters([F,$,180,oe],k),K=this.getClusters([-180,$,J,oe],k);return me.concat(K)}const le=this.trees[this._limitZoom(k)],ne=le.range(Tr(F),sn(oe),Tr(J),sn($)),se=le.data,be=[];for(const me of ne){const K=this.stride*me;be.push(se[K+5]>1?xn(se,K,this.clusterProps):this.points[se[K+3]])}return be}getChildren(E){const k=this._getOriginId(E),F=this._getOriginZoom(E),$="No cluster with the specified id.",J=this.trees[F];if(!J)throw new Error($);const oe=J.data;if(k*this.stride>=oe.length)throw new Error($);const le=this.options.radius/(this.options.extent*Math.pow(2,F-1)),ne=J.within(oe[k*this.stride],oe[k*this.stride+1],le),se=[];for(const be of ne){const me=be*this.stride;oe[me+4]===E&&se.push(oe[me+5]>1?xn(oe,me,this.clusterProps):this.points[oe[me+3]])}if(se.length===0)throw new Error($);return se}getLeaves(E,k,F){const $=[];return this._appendLeaves($,E,k=k||10,F=F||0,0),$}getTile(E,k,F){const $=this.trees[this._limitZoom(E)],J=Math.pow(2,E),{extent:oe,radius:le}=this.options,ne=le/oe,se=(F-ne)/J,be=(F+1+ne)/J,me={features:[]};return this._addTileFeatures($.range((k-ne)/J,se,(k+1+ne)/J,be),$.data,k,F,J,me),k===0&&this._addTileFeatures($.range(1-ne/J,se,1,be),$.data,J,F,J,me),k===J-1&&this._addTileFeatures($.range(0,se,ne/J,be),$.data,-1,F,J,me),me.features.length?me:null}getClusterExpansionZoom(E){let k=this._getOriginZoom(E)-1;for(;k<=this.options.maxZoom;){const F=this.getChildren(E);if(k++,F.length!==1)break;E=F[0].properties.cluster_id}return k}_appendLeaves(E,k,F,$,J){const oe=this.getChildren(k);for(const le of oe){const ne=le.properties;if(ne&&ne.cluster?J+ne.point_count<=$?J+=ne.point_count:J=this._appendLeaves(E,ne.cluster_id,F,$,J):J<$?J++:E.push(le),E.length===F)break}return J}_createTree(E){const k=new D.aT(E.length/this.stride|0,this.options.nodeSize,Float32Array);for(let F=0;F<E.length;F+=this.stride)k.add(E[F],E[F+1]);return k.finish(),k.data=E,k}_addTileFeatures(E,k,F,$,J,oe){for(const le of E){const ne=le*this.stride,se=k[ne+5]>1;let be,me,K;if(se)be=nn(k,ne,this.clusterProps),me=k[ne],K=k[ne+1];else{const Ue=this.points[k[ne+3]];be=Ue.properties;const[Ze,qe]=Ue.geometry.coordinates;me=Tr(Ze),K=sn(qe)}const Oe={type:1,geometry:[[Math.round(this.options.extent*(me*J-F)),Math.round(this.options.extent*(K*J-$))]],tags:be};let We;We=se||this.options.generateId?k[ne+3]:this.points[k[ne+3]].id,We!==void 0&&(Oe.id=We),oe.features.push(Oe)}}_limitZoom(E){return Math.max(this.options.minZoom,Math.min(Math.floor(+E),this.options.maxZoom+1))}_cluster(E,k){const{radius:F,extent:$,reduce:J,minPoints:oe}=this.options,le=F/($*Math.pow(2,k)),ne=E.data,se=[],be=this.stride;for(let me=0;me<ne.length;me+=be){if(ne[me+2]<=k)continue;ne[me+2]=k;const K=ne[me],Oe=ne[me+1],We=E.within(ne[me],ne[me+1],le),Ue=ne[me+5];let Ze=Ue;for(const qe of We){const et=qe*be;ne[et+2]>k&&(Ze+=ne[et+5])}if(Ze>Ue&&Ze>=oe){let qe,et=K*Ue,Nt=Oe*Ue,wt=-1;const jt=(me/be<<5)+(k+1)+this.points.length;for(const ci of We){const Rt=ci*be;if(ne[Rt+2]<=k)continue;ne[Rt+2]=k;const Pe=ne[Rt+5];et+=ne[Rt]*Pe,Nt+=ne[Rt+1]*Pe,ne[Rt+4]=jt,J&&(qe||(qe=this._map(ne,me,!0),wt=this.clusterProps.length,this.clusterProps.push(qe)),J(qe,this._map(ne,Rt)))}ne[me+4]=jt,se.push(et/Ze,Nt/Ze,1/0,jt,-1,Ze),J&&se.push(wt)}else{for(let qe=0;qe<be;qe++)se.push(ne[me+qe]);if(Ze>1)for(const qe of We){const et=qe*be;if(!(ne[et+2]<=k)){ne[et+2]=k;for(let Nt=0;Nt<be;Nt++)se.push(ne[et+Nt])}}}}return se}_getOriginId(E){return E-this.points.length>>5}_getOriginZoom(E){return(E-this.points.length)%32}_map(E,k,F){if(E[k+5]>1){const oe=this.clusterProps[E[k+6]];return F?Object.assign({},oe):oe}const $=this.points[E[k+3]].properties,J=this.options.map($);return F&&J===$?Object.assign({},J):J}}function xn(ie,E,k){return{type:"Feature",id:ie[E+3],properties:nn(ie,E,k),geometry:{type:"Point",coordinates:[(F=ie[E],360*(F-.5)),ks(ie[E+1])]}};var F}function nn(ie,E,k){const F=ie[E+5],$=F>=1e4?`${Math.round(F/1e3)}k`:F>=1e3?Math.round(F/100)/10+"k":F,J=ie[E+6],oe=J===-1?{}:Object.assign({},k[J]);return Object.assign(oe,{cluster:!0,cluster_id:ie[E+3],point_count:F,point_count_abbreviated:$})}function Tr(ie){return ie/360+.5}function sn(ie){const E=Math.sin(ie*Math.PI/180),k=.5-.25*Math.log((1+E)/(1-E))/Math.PI;return k<0?0:k>1?1:k}function ks(ie){const E=(180-360*ie)*Math.PI/180;return 360*Math.atan(Math.exp(E))/Math.PI-90}function Kn(ie,E,k,F){let $=F;const J=E+(k-E>>1);let oe,le=k-E;const ne=ie[E],se=ie[E+1],be=ie[k],me=ie[k+1];for(let K=E+3;K<k;K+=3){const Oe=Lr(ie[K],ie[K+1],ne,se,be,me);if(Oe>$)oe=K,$=Oe;else if(Oe===$){const We=Math.abs(K-J);We<le&&(oe=K,le=We)}}$>F&&(oe-E>3&&Kn(ie,E,oe,F),ie[oe+2]=$,k-oe>3&&Kn(ie,oe,k,F))}function Lr(ie,E,k,F,$,J){let oe=$-k,le=J-F;if(oe!==0||le!==0){const ne=((ie-k)*oe+(E-F)*le)/(oe*oe+le*le);ne>1?(k=$,F=J):ne>0&&(k+=oe*ne,F+=le*ne)}return oe=ie-k,le=E-F,oe*oe+le*le}function Ht(ie,E,k,F){const $={type:E,geom:k},J={id:ie??null,type:$.type,geometry:$.geom,tags:F,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};switch($.type){case"Point":case"MultiPoint":case"LineString":ht(J,$.geom);break;case"Polygon":ht(J,$.geom[0]);break;case"MultiLineString":for(const oe of $.geom)ht(J,oe);break;case"MultiPolygon":for(const oe of $.geom)ht(J,oe[0])}return J}function ht(ie,E){for(let k=0;k<E.length;k+=3)ie.minX=Math.min(ie.minX,E[k]),ie.minY=Math.min(ie.minY,E[k+1]),ie.maxX=Math.max(ie.maxX,E[k]),ie.maxY=Math.max(ie.maxY,E[k+1])}function bn(ie,E){const k=[];switch(ie.type){case"FeatureCollection":for(let F=0;F<ie.features.length;F++)Sr(k,ie.features[F],E,F);break;case"Feature":Sr(k,ie,E);break;default:Sr(k,{geometry:ie,properties:void 0},E)}return k}function Sr(ie,E,k,F){if(!E.geometry)return;if(E.geometry.type==="GeometryCollection"){for(const le of E.geometry.geometries)Sr(ie,{id:E.id,geometry:le,properties:E.properties},k,F);return}if(!E.geometry.coordinates?.length)return;const J=Math.pow(k.tolerance/((1<<k.maxZoom)*k.extent),2);let oe=E.id;switch(k.promoteId?oe=E.properties?.[k.promoteId]:k.generateId&&(oe=F||0),E.geometry.type){case"Point":{const le=[];return Ls(E.geometry.coordinates,le),void ie.push(Ht(oe,E.geometry.type,le,E.properties))}case"MultiPoint":{const le=[];for(const ne of E.geometry.coordinates)Ls(ne,le);return void ie.push(Ht(oe,E.geometry.type,le,E.properties))}case"LineString":{const le=[];return Jn(E.geometry.coordinates,le,J,!1),void ie.push(Ht(oe,E.geometry.type,le,E.properties))}case"MultiLineString":{if(k.lineMetrics){for(const ne of E.geometry.coordinates){const se=[];Jn(ne,se,J,!1),ie.push(Ht(oe,"LineString",se,E.properties))}return}const le=[];return on(E.geometry.coordinates,le,J,!1),void ie.push(Ht(oe,E.geometry.type,le,E.properties))}case"Polygon":{const le=[];return on(E.geometry.coordinates,le,J,!0),void ie.push(Ht(oe,E.geometry.type,le,E.properties))}case"MultiPolygon":{const le=[];for(const ne of E.geometry.coordinates){const se=[];on(ne,se,J,!0),le.push(se)}return void ie.push(Ht(oe,E.geometry.type,le,E.properties))}default:throw new Error("Input data is not a valid GeoJSON object.")}}function Ls(ie,E){E.push(Rr(ie[0]),ir(ie[1]),0)}function Jn(ie,E,k,F){let $,J,oe=0;for(let ne=0;ne<ie.length;ne++){const se=Rr(ie[ne][0]),be=ir(ie[ne][1]);E.push(se,be,0),ne>0&&(oe+=F?($*be-se*J)/2:Math.sqrt(Math.pow(se-$,2)+Math.pow(be-J,2))),$=se,J=be}const le=E.length-3;E[2]=1,k>0&&Kn(E,0,le,k),E[le+2]=1,E.size=Math.abs(oe),E.start=0,E.end=E.size}function on(ie,E,k,F){for(let $=0;$<ie.length;$++){const J=[];Jn(ie[$],J,k,F),E.push(J)}}function Rr(ie){return ie/360+.5}function ir(ie){const E=Math.sin(ie*Math.PI/180),k=.5-.25*Math.log((1+E)/(1-E))/Math.PI;return k<0?0:k>1?1:k}function fi(ie,E,k,F,$,J,oe,le){if(F/=E,J>=(k/=E)&&oe<F)return ie;if(oe<k||J>=F)return null;const ne=[];for(const se of ie){const be=$===0?se.minX:se.minY,me=$===0?se.maxX:se.maxY;if(be>=k&&me<F)ne.push(se);else if(!(me<k||be>=F))switch(se.type){case"Point":case"MultiPoint":{const K=[];if(ki(se.geometry,K,k,F,$),!K.length)continue;ne.push(Ht(se.id,K.length===3?"Point":"MultiPoint",K,se.tags));continue}case"LineString":{const K=[];if(Qn(se.geometry,K,k,F,$,!1,le.lineMetrics),!K.length)continue;if(le.lineMetrics){for(const Oe of K)ne.push(Ht(se.id,se.type,Oe,se.tags));continue}if(K.length>1){ne.push(Ht(se.id,"MultiLineString",K,se.tags));continue}ne.push(Ht(se.id,se.type,K[0],se.tags));continue}case"MultiLineString":{const K=[];if(Tn(se.geometry,K,k,F,$,!1),!K.length)continue;if(K.length===1){ne.push(Ht(se.id,"LineString",K[0],se.tags));continue}ne.push(Ht(se.id,se.type,K,se.tags));continue}case"Polygon":{const K=[];if(Tn(se.geometry,K,k,F,$,!0),!K.length)continue;ne.push(Ht(se.id,se.type,K,se.tags));continue}case"MultiPolygon":{const K=[];for(const Oe of se.geometry){const We=[];Tn(Oe,We,k,F,$,!0),We.length&&K.push(We)}if(!K.length)continue;ne.push(Ht(se.id,se.type,K,se.tags));continue}}}return ne.length?ne:null}function ki(ie,E,k,F,$){for(let J=0;J<ie.length;J+=3){const oe=ie[J+$];oe>=k&&oe<=F&&mi(E,ie[J],ie[J+1],ie[J+2])}}function Qn(ie,E,k,F,$,J,oe){let le=wn(ie);const ne=$===0?zo:gi;let se,be,me=ie.start;for(let Ze=0;Ze<ie.length-3;Ze+=3){const qe=ie[Ze],et=ie[Ze+1],Nt=ie[Ze+2],wt=ie[Ze+3],jt=ie[Ze+4],ci=$===0?qe:et,Rt=$===0?wt:jt;let Pe=!1;oe&&(se=Math.sqrt(Math.pow(qe-wt,2)+Math.pow(et-jt,2))),ci<k?Rt>k&&(be=ne(le,qe,et,wt,jt,k),oe&&(le.start=me+se*be)):ci>F?Rt<F&&(be=ne(le,qe,et,wt,jt,F),oe&&(le.start=me+se*be)):mi(le,qe,et,Nt),Rt<k&&ci>=k&&(be=ne(le,qe,et,wt,jt,k),Pe=!0),Rt>F&&ci<=F&&(be=ne(le,qe,et,wt,jt,F),Pe=!0),!J&&Pe&&(oe&&(le.end=me+se*be),E.push(le),le=wn(ie)),oe&&(me+=se)}let K=ie.length-3;const Oe=ie[K],We=ie[K+1],Ue=$===0?Oe:We;Ue>=k&&Ue<=F&&mi(le,Oe,We,ie[K+2]),K=le.length-3,J&&K>=3&&(le[K]!==le[0]||le[K+1]!==le[1])&&mi(le,le[0],le[1],le[2]),le.length&&E.push(le)}function wn(ie){const E=[];return E.size=ie.size,E.start=ie.start,E.end=ie.end,E}function Tn(ie,E,k,F,$,J){for(const oe of ie)Qn(oe,E,k,F,$,J,!1)}function mi(ie,E,k,F){ie.push(E,k,F)}function zo(ie,E,k,F,$,J){const oe=(J-E)/(F-E);return mi(ie,J,k+($-k)*oe,1),oe}function gi(ie,E,k,F,$,J){const oe=(J-k)/($-k);return mi(ie,E+(F-E)*oe,J,1),oe}function ji(ie,E){const k=E.buffer/E.extent;let F=ie;const $=fi(ie,1,-1-k,k,0,-1,2,E),J=fi(ie,1,1-k,2+k,0,-1,2,E);return($||J)&&(F=fi(ie,1,-k,1+k,0,-1,2,E)||[],$&&(F=Pr($,1).concat(F)),J&&(F=F.concat(Pr(J,-1)))),F}function Pr(ie,E){const k=[];for(const F of ie)switch(F.type){case"Point":case"MultiPoint":case"LineString":{const $=Mt(F.geometry,E);k.push(Ht(F.id,F.type,$,F.tags));continue}case"MultiLineString":case"Polygon":{const $=[];for(const J of F.geometry)$.push(Mt(J,E));k.push(Ht(F.id,F.type,$,F.tags));continue}case"MultiPolygon":{const $=[];for(const J of F.geometry){const oe=[];for(const le of J)oe.push(Mt(le,E));$.push(oe)}k.push(Ht(F.id,F.type,$,F.tags));continue}}return k}function Mt(ie,E){const k=[];k.size=ie.size,ie.start!==void 0&&(k.start=ie.start,k.end=ie.end);for(let F=0;F<ie.length;F+=3)k.push(ie[F]+E,ie[F+1],ie[F+2]);return k}function Sn(ie,E){if(ie.transformed)return ie;const k=1<<ie.z,F=ie.x,$=ie.y;for(const J of ie.features){if(J.type===1){const le=[];for(let ne=0;ne<J.geometry.length;ne+=2)le.push(es(J.geometry[ne],J.geometry[ne+1],E,k,F,$));J.geometry=le;continue}const oe=[];for(const le of J.geometry){const ne=[];for(let se=0;se<le.length;se+=2)ne.push(es(le[se],le[se+1],E,k,F,$));oe.push(ne)}J.geometry=oe}return ie.transformed=!0,ie}function es(ie,E,k,F,$,J){return[Math.round(k*(ie*F-$)),Math.round(k*(E*F-J))]}function Pn(ie,E,k,F,$){const J=E===$.maxZoom?0:$.tolerance/((1<<E)*$.extent),oe={features:[],numPoints:0,numSimplified:0,numFeatures:ie.length,source:null,x:k,y:F,z:E,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const le of ie)an(oe,le,J,$);return oe}function an(ie,E,k,F){ie.minX=Math.min(ie.minX,E.minX),ie.minY=Math.min(ie.minY,E.minY),ie.maxX=Math.max(ie.maxX,E.maxX),ie.maxY=Math.max(ie.maxY,E.maxY);let $,J=E.tags||null;switch(E.type){case"Point":case"MultiPoint":{const oe=[];for(let le=0;le<E.geometry.length;le+=3)oe.push(E.geometry[le],E.geometry[le+1]),ie.numPoints++,ie.numSimplified++;if(!oe.length)return;$={type:1,tags:J,geometry:oe};break}case"LineString":{const oe=[];if(Mr(oe,E.geometry,ie,k,!1,!1),!oe.length)return;if(F.lineMetrics){J={};for(const le in E.tags)J[le]=E.tags[le];J.mapbox_clip_start=E.geometry.start/E.geometry.size,J.mapbox_clip_end=E.geometry.end/E.geometry.size}$={type:2,tags:J,geometry:oe};break}case"MultiLineString":case"Polygon":{const oe=[];for(let le=0;le<E.geometry.length;le++)Mr(oe,E.geometry[le],ie,k,E.type==="Polygon",le===0);if(!oe.length)return;$={type:E.type==="Polygon"?3:2,tags:J,geometry:oe};break}case"MultiPolygon":{const oe=[];for(let le=0;le<E.geometry.length;le++){const ne=E.geometry[le];for(let se=0;se<ne.length;se++)Mr(oe,ne[se],ie,k,!0,se===0)}if(!oe.length)return;$={type:3,tags:J,geometry:oe};break}}E.id!==null&&($.id=E.id),ie.features.push($)}function Mr(ie,E,k,F,$,J){const oe=F*F;if(F>0&&E.size<($?oe:F))return void(k.numPoints+=E.length/3);const le=[];for(let ne=0;ne<E.length;ne+=3)(F===0||E[ne+2]>oe)&&(k.numSimplified++,le.push(E[ne],E[ne+1])),k.numPoints++;$&&(function(ne,se){let be=0;for(let me=0,K=ne.length,Oe=K-2;me<K;Oe=me,me+=2)be+=(ne[me]-ne[Oe])*(ne[me+1]+ne[Oe+1]);if(be>0===se)for(let me=0,K=ne.length;me<K/2;me+=2){const Oe=ne[me],We=ne[me+1];ne[me]=ne[K-2-me],ne[me+1]=ne[K-1-me],ne[K-2-me]=Oe,ne[K-1-me]=We}})(le,J),ie.push(le)}function ln(ie,E,k){const F=!!E.newGeometry,$=E.removeAllProperties||E.removeProperties?.length>0||E.addOrUpdateProperties?.length>0;if(F){let J=bn({type:"FeatureCollection",features:[{type:"Feature",id:ie.id,geometry:E.newGeometry,properties:$?Mn(ie.tags,E):ie.tags}]},k);return J=ji(J,k),J[0]}if($){const J={...ie};return J.tags=Mn(J.tags,E),J}return null}function Mn(ie,E){if(E.removeAllProperties)return{};const k={...ie||{}};if(E.removeProperties)for(const F of E.removeProperties)delete k[F];if(E.addOrUpdateProperties)for(const{key:F,value:$}of E.addOrUpdateProperties)k[F]=$;return k}const Fr={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,updateable:!1,debug:0};class Br{options;tiles;tileCoords;stats={};total=0;source;constructor(E,k){const F=(k=this.options=Object.assign({},Fr,k)).debug;if(F&&console.time("preprocess data"),k.maxZoom<0||k.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(k.promoteId&&k.generateId)throw new Error("promoteId and generateId cannot be used together.");let $=bn(E,k);this.tiles={},this.tileCoords=[],F&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",k.indexMaxZoom,k.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),$=ji($,k),$.length&&this.splitTile($,0,0,0),k.updateable&&(this.source=$),F&&($.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,k,F,$,J,oe,le){const ne=[E,k,F,$],se=this.options,be=se.debug;for(;ne.length;){$=ne.pop(),F=ne.pop(),k=ne.pop(),E=ne.pop();const me=1<<k,K=cn(k,F,$);let Oe=this.tiles[K];if(!Oe&&(be>1&&console.time("creation"),Oe=this.tiles[K]=Pn(E,k,F,$,se),this.tileCoords.push({z:k,x:F,y:$,id:K}),be)){be>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",k,F,$,Oe.numFeatures,Oe.numPoints,Oe.numSimplified),console.timeEnd("creation"));const Pe=`z${k}`;this.stats[Pe]=(this.stats[Pe]||0)+1,this.total++}if(Oe.source=E,J==null){if(k===se.indexMaxZoom||Oe.numPoints<=se.indexMaxPoints)continue}else{if(k===se.maxZoom||k===J)continue;if(J!=null){const Pe=J-k;if(F!==oe>>Pe||$!==le>>Pe)continue}}if(Oe.source=null,!E.length)continue;be>1&&console.time("clipping");const We=.5*se.buffer/se.extent,Ue=.5-We,Ze=.5+We,qe=1+We;let et=null,Nt=null,wt=null,jt=null;const ci=fi(E,me,F-We,F+Ze,0,Oe.minX,Oe.maxX,se),Rt=fi(E,me,F+Ue,F+qe,0,Oe.minX,Oe.maxX,se);ci&&(et=fi(ci,me,$-We,$+Ze,1,Oe.minY,Oe.maxY,se),Nt=fi(ci,me,$+Ue,$+qe,1,Oe.minY,Oe.maxY,se)),Rt&&(wt=fi(Rt,me,$-We,$+Ze,1,Oe.minY,Oe.maxY,se),jt=fi(Rt,me,$+Ue,$+qe,1,Oe.minY,Oe.maxY,se)),be>1&&console.timeEnd("clipping"),ne.push(et||[],k+1,2*F,2*$),ne.push(Nt||[],k+1,2*F,2*$+1),ne.push(wt||[],k+1,2*F+1,2*$),ne.push(jt||[],k+1,2*F+1,2*$+1)}}getTile(E,k,F){E=+E,k=+k,F=+F;const $=this.options,{extent:J,debug:oe}=$;if(E<0||E>24)return null;const le=1<<E,ne=cn(E,k=k+le&le-1,F);if(this.tiles[ne])return Sn(this.tiles[ne],J);oe>1&&console.log("drilling down to z%d-%d-%d",E,k,F);let se,be=E,me=k,K=F;for(;!se&&be>0;)be--,me>>=1,K>>=1,se=this.tiles[cn(be,me,K)];return se?.source?(oe>1&&(console.log("found parent tile z%d-%d-%d",be,me,K),console.time("drilling down")),this.splitTile(se.source,be,me,K,E,k,F),oe>1&&console.timeEnd("drilling down"),this.tiles[ne]?Sn(this.tiles[ne],J):null):null}invalidateTiles(E){const k=this.options,{debug:F}=k;let $=1/0,J=-1/0,oe=1/0,le=-1/0;for(const be of E)$=Math.min($,be.minX),J=Math.max(J,be.maxX),oe=Math.min(oe,be.minY),le=Math.max(le,be.maxY);const ne=k.buffer/k.extent,se=new Set;for(const be in this.tiles){const me=this.tiles[be],K=1<<me.z,Oe=(me.x-ne)/K,We=(me.x+1+ne)/K,Ue=(me.y-ne)/K,Ze=(me.y+1+ne)/K;if(J<Oe||$>=We||le<Ue||oe>=Ze)continue;let qe=!1;for(const et of E)if(et.maxX>=Oe&&et.minX<We&&et.maxY>=Ue&&et.minY<Ze){qe=!0;break}if(qe){if(F){F>1&&console.log("invalidate tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",me.z,me.x,me.y,me.numFeatures,me.numPoints,me.numSimplified);const et=`z${me.z}`;this.stats[et]=(this.stats[et]||0)-1,this.total--}delete this.tiles[be],se.add(be)}}se.size&&(this.tileCoords=this.tileCoords.filter((be=>!se.has(be.id))))}updateData(E){const k=this.options,F=k.debug;if(!k.updateable)throw new Error("to update tile geojson `updateable` option must be set to true");const{affected:$,source:J}=(function(me,K,Oe){const We=(function(Ze){return Ze?{removeAll:Ze.removeAll,remove:new Set(Ze.remove||[]),add:new Map(Ze.add?.map((qe=>[qe.id,qe]))),update:new Map(Ze.update?.map((qe=>[qe.id,qe])))}:{remove:new Set,add:new Map,update:new Map}})(K);let Ue=[];if(We.removeAll&&(Ue=me,me=[]),We.remove.size||We.add.size){const Ze=[];for(const qe of me){const{id:et}=qe;(We.remove.has(et)||We.add.has(et))&&Ze.push(qe)}if(Ze.length){Ue.push(...Ze);const qe=new Set(Ze.map((et=>et.id)));me=me.filter((et=>!qe.has(et.id)))}if(We.add.size){let qe=bn({type:"FeatureCollection",features:Array.from(We.add.values())},Oe);qe=ji(qe,Oe),Ue.push(...qe),me.push(...qe)}}if(We.update.size)for(const[Ze,qe]of We.update){const et=me.findIndex((jt=>jt.id===Ze));if(et===-1)continue;const Nt=me[et],wt=ln(Nt,qe,Oe);wt&&(Ue.push(Nt,wt),me[et]=wt)}return{affected:Ue,source:me}})(this.source,E,k);if(!$.length)return;this.source=J,F>1&&(console.log("invalidating tiles"),console.time("invalidating")),this.invalidateTiles($),F>1&&console.timeEnd("invalidating");const[oe,le,ne]=[0,0,0],se=Pn(this.source,oe,le,ne,this.options);se.source=this.source;const be=cn(oe,le,ne);if(this.tiles[be]=se,this.tileCoords.push({z:oe,x:le,y:ne,id:be}),F){const me=`z${oe}`;this.stats[me]=(this.stats[me]||0)+1,this.total++}}}function cn(ie,E,k){return 32*((1<<ie)*k+E)+ie}class ts{constructor(E,k,F,$=Rs){this._dataUpdateable=new Map,this.actor=E,this.layerIndex=k,this.availableImages=F,this.tileState=new Si,this._createGeoJSONIndex=$}loadVectorTile(E){if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");const{z:k,x:F,y:$}=E.tileID.canonical,J=this._geoJSONIndex.getTile(k,F,$);return J?He(new D.d3(J.features,{version:2,extent:D.a5})):null}loadTile(E){return D._(this,void 0,void 0,(function*(){const{uid:k}=E,F=new _t(E);F.abort=new AbortController;try{const $=this.loadVectorTile(E);if(!$)return null;const{vectorTile:J,rawData:oe}=$;F.vectorTile=J,this.tileState.markLoaded(k,F);const le={rawData:oe};this.tileState.setParsing(k,le);try{return yield this._parseWorkerTile(F,E,le)}finally{this.tileState.clearParsing(k)}}catch($){throw F.status="done",this.tileState.markLoaded(k,F),$}}))}_reloadLoadedTile(E){return D._(this,void 0,void 0,(function*(){const k=E.uid,F=this.tileState.getLoaded(k);if(!F)throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");if(F.showCollisionBoxes=E.showCollisionBoxes,F.status==="parsing"){const $=this.tileState.consumeParsing(k);return yield this._parseWorkerTile(F,E,$)}if(F.status==="done"&&F.vectorTile)return yield this._parseWorkerTile(F,E)}))}_parseWorkerTile(E,k,F){return D._(this,void 0,void 0,(function*(){let $=yield E.parse(E.vectorTile,this.layerIndex,this.availableImages,this.actor,k.subdivisionGranularity);if(F){const{rawData:J}=F;$=D.e({rawTileData:J.slice(0)},$)}return $}))}abortTile(E){return D._(this,void 0,void 0,(function*(){this.tileState.abort(E.uid)}))}removeTile(E){return D._(this,void 0,void 0,(function*(){this.tileState.removeLoaded(E.uid)}))}loadData(E){return D._(this,void 0,void 0,(function*(){var k;(k=this._pendingRequest)===null||k===void 0||k.abort();const F=this._startRequestTiming(E);this._pendingRequest=new AbortController;try{(!this._pendingData||E.request||E.data||E.dataDiff)&&(this._pendingData=this.loadAndProcessGeoJSON(E,this._pendingRequest));const $=yield this._pendingData;this._geoJSONIndex=this._createGeoJSONIndex($,E),this.tileState.clearLoaded();const J={};return E.request&&(J.data=$),this._finishRequestTiming(F,E,J),J}catch($){if(delete this._pendingRequest,D.Z($))return{abandoned:!0};throw $}}))}_startRequestTiming(E){var k;if(!((k=E.request)===null||k===void 0)&&k.collectResourceTiming)return new D.c$(E.request.url)}_finishRequestTiming(E,k,F){const $=E?.finish();$&&(F.resourceTiming={[k.source]:JSON.parse(JSON.stringify($))})}getData(){return D._(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(E){return this.tileState.getLoaded(E.uid)?this._reloadLoadedTile(E):this.loadTile(E)}loadAndProcessGeoJSON(E,k){return D._(this,void 0,void 0,(function*(){let F;if(E.request?F=yield this.loadGeoJSONFromUrl(E.request,E.promoteId,k):E.data?F=this._loadGeoJSONFromObject(E.data,E.promoteId):E.dataDiff&&(F=this._loadGeoJSONFromDiff(E.dataDiff,E.promoteId,E.source)),delete this._pendingRequest,typeof F!="object")throw new Error(`Input data given to '${E.source}' is not a valid GeoJSON object.`);return Ds(F,!0),E.filter&&(F=this._filterGeoJSON(F,E.filter)),F}))}loadGeoJSONFromUrl(E,k,F){return D._(this,void 0,void 0,(function*(){const $=yield D.j(E,F);return this._dataUpdateable=D.a7($.data,k),$.data}))}_loadGeoJSONFromObject(E,k){return this._dataUpdateable=D.a7(E,k),E}_loadGeoJSONFromDiff(E,k,F){if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${F}`);D.a8(this._dataUpdateable,E,k);const $=Array.from(this._dataUpdateable.values());return this._toFeatureCollection($)}_filterGeoJSON(E,k){const F=D.d4(k,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(F.result==="error")throw new Error(F.value.map((J=>`${J.key}: ${J.message}`)).join(", "));const $=E.features.filter((J=>F.value.evaluate({zoom:0},J)));return this._toFeatureCollection($)}_toFeatureCollection(E){return{type:"FeatureCollection",features:E}}removeSource(E){return D._(this,void 0,void 0,(function*(){var k;(k=this._pendingRequest)===null||k===void 0||k.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 Rs(ie,E){return E.cluster?new rn((function({superclusterOptions:k,clusterProperties:F}){if(!F||!k)return k;const $={},J={},oe={accumulated:null,zoom:0},le={properties:null},ne=Object.keys(F);for(const se of ne){const[be,me]=F[se],K=D.d4(me),Oe=D.d4(typeof be=="string"?[be,["accumulated"],["get",se]]:be);$[se]=K.value,J[se]=Oe.value}return k.map=se=>{le.properties=se;const be={};for(const me of ne)be[me]=$[me].evaluate(oe,le);return be},k.reduce=(se,be)=>{le.properties=be;for(const me of ne)oe.accumulated=se[me],se[me]=J[me].evaluate(oe,le)},k})(E)).load(ie.features):(function(k,F){return new Br(k,F)})(ie,E.geojsonVtOptions)}class is{constructor(E){this.self=E,this.actor=new D.L(E),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(k,F)=>{if(this.externalWorkerSourceTypes[k])throw new Error(`Worker source with name "${k}" already registered.`);this.externalWorkerSourceTypes[k]=F},this.self.addProtocol=D.cK,this.self.removeProtocol=D.cL,this.self.registerRTLTextPlugin=k=>{D.d5.setMethods(k)},this.actor.registerMessageHandler("LDT",((k,F)=>this._getDEMWorkerSource(k,F.source).loadTile(F))),this.actor.registerMessageHandler("RDT",((k,F)=>D._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(k,F.source).removeTile(F)})))),this.actor.registerMessageHandler("GCEZ",((k,F)=>D._(this,void 0,void 0,(function*(){return this._getWorkerSource(k,F.type,F.source).getClusterExpansionZoom(F)})))),this.actor.registerMessageHandler("GCC",((k,F)=>D._(this,void 0,void 0,(function*(){return this._getWorkerSource(k,F.type,F.source).getClusterChildren(F)})))),this.actor.registerMessageHandler("GCL",((k,F)=>D._(this,void 0,void 0,(function*(){return this._getWorkerSource(k,F.type,F.source).getClusterLeaves(F)})))),this.actor.registerMessageHandler("LD",((k,F)=>this._getWorkerSource(k,F.type,F.source).loadData(F))),this.actor.registerMessageHandler("GD",((k,F)=>this._getWorkerSource(k,F.type,F.source).getData())),this.actor.registerMessageHandler("LT",((k,F)=>this._getWorkerSource(k,F.type,F.source).loadTile(F))),this.actor.registerMessageHandler("RT",((k,F)=>this._getWorkerSource(k,F.type,F.source).reloadTile(F))),this.actor.registerMessageHandler("AT",((k,F)=>this._getWorkerSource(k,F.type,F.source).abortTile(F))),this.actor.registerMessageHandler("RMT",((k,F)=>this._getWorkerSource(k,F.type,F.source).removeTile(F))),this.actor.registerMessageHandler("RS",((k,F)=>D._(this,void 0,void 0,(function*(){if(!this.workerSources[k]||!this.workerSources[k][F.type]||!this.workerSources[k][F.type][F.source])return;const $=this.workerSources[k][F.type][F.source];delete this.workerSources[k][F.type][F.source],$.removeSource!==void 0&&$.removeSource(F)})))),this.actor.registerMessageHandler("RM",(k=>D._(this,void 0,void 0,(function*(){delete this.layerIndexes[k],delete this.availableImages[k],delete this.workerSources[k],delete this.demWorkerSources[k],this.globalStates.delete(k)})))),this.actor.registerMessageHandler("SR",((k,F)=>D._(this,void 0,void 0,(function*(){this.referrer=F})))),this.actor.registerMessageHandler("SRPS",((k,F)=>this._syncRTLPluginState(k,F))),this.actor.registerMessageHandler("IS",((k,F)=>D._(this,void 0,void 0,(function*(){this.self.importScripts(F)})))),this.actor.registerMessageHandler("SI",((k,F)=>this._setImages(k,F))),this.actor.registerMessageHandler("UL",((k,F)=>D._(this,void 0,void 0,(function*(){this._getLayerIndex(k).update(F.layers,F.removedIds,this._getGlobalState(k))})))),this.actor.registerMessageHandler("UGS",((k,F)=>D._(this,void 0,void 0,(function*(){const $=this._getGlobalState(k);for(const J in F)$[J]=F[J]})))),this.actor.registerMessageHandler("SL",((k,F)=>D._(this,void 0,void 0,(function*(){this._getLayerIndex(k).replace(F,this._getGlobalState(k))}))))}_getGlobalState(E){let k=this.globalStates.get(E);return k||(k={},this.globalStates.set(E,k)),k}_setImages(E,k){return D._(this,void 0,void 0,(function*(){this.availableImages[E]=k;for(const F in this.workerSources[E]){const $=this.workerSources[E][F];for(const J in $)$[J].availableImages=k}}))}_syncRTLPluginState(E,k){return D._(this,void 0,void 0,(function*(){return yield D.d5.syncState(k,this.self.importScripts)}))}_getAvailableImages(E){let k=this.availableImages[E];return k||(k=[]),k}_getLayerIndex(E){let k=this.layerIndexes[E];return k||(k=this.layerIndexes[E]=new c),k}_getWorkerSource(E,k,F){if(this.workerSources[E]||(this.workerSources[E]={}),this.workerSources[E][k]||(this.workerSources[E][k]={}),!this.workerSources[E][k][F]){const $={sendAsync:(J,oe)=>(J.targetMapId=E,this.actor.sendAsync(J,oe))};switch(k){case"vector":this.workerSources[E][k][F]=new pr($,this._getLayerIndex(E),this._getAvailableImages(E));break;case"geojson":this.workerSources[E][k][F]=new ts($,this._getLayerIndex(E),this._getAvailableImages(E));break;default:this.workerSources[E][k][F]=new this.externalWorkerSourceTypes[k]($,this._getLayerIndex(E),this._getAvailableImages(E))}}return this.workerSources[E][k][F]}_getDEMWorkerSource(E,k){return this.demWorkerSources[E]||(this.demWorkerSources[E]={}),this.demWorkerSources[E][k]||(this.demWorkerSources[E][k]=new bt),this.demWorkerSources[E][k]}}return D.i(self)&&(self.worker=new is(self)),is})),$e("index",["exports","./shared"],(function(D,c){var Te="5.19.0";function _t(){var d=new c.A(4);return c.A!=Float32Array&&(d[1]=0,d[2]=0),d[0]=1,d[3]=1,d}let ct,Si,dr;const $t={frame(d,t,n,o){const l=o||window,p=l.requestAnimationFrame((_=>{m(),t(_)})),{unsubscribe:m}=c.s(d.signal,"abort",(()=>{m(),l.cancelAnimationFrame(p),n(new c.a(d.signal.reason))}),!1)},frameAsync(d,t){return new Promise(((n,o)=>{this.frame(d,n,o,t)}))},getImageData(d,t=0){return this.getImageCanvasContext(d).getImageData(-t,-t,d.width+2*t,d.height+2*t)},getImageCanvasContext(d){const t=window.document.createElement("canvas"),n=t.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("failed to create canvas 2d context");return t.width=d.width,t.height=d.height,n.drawImage(d,0,0,d.width,d.height),n},resolveURL:d=>(ct||(ct=document.createElement("a")),ct.href=d,ct.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return dr!==void 0?dr:!!matchMedia&&(Si==null&&(Si=matchMedia("(prefers-reduced-motion: reduce)")),Si.matches)},set prefersReducedMotion(d){dr=d}},tr=new class{constructor(){this._realTime=typeof performance<"u"&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),this._frozenAt=null}getCurrentTime(){return this._frozenAt!==null?this._frozenAt:this._realTime()}setNow(d){this._frozenAt=d}restoreNow(){this._frozenAt=null}isFrozen(){return this._frozenAt!==null}};function He(){return tr.getCurrentTime()}class pe{static testProp(t){if(!pe.docStyle)return t[0];for(let n=0;n<t.length;n++)if(t[n]in pe.docStyle)return t[n];return t[0]}static create(t,n,o){const l=window.document.createElement(t);return n!==void 0&&(l.className=n),o&&o.appendChild(l),l}static createNS(t,n){return window.document.createElementNS(t,n)}static disableDrag(){pe.docStyle&&pe.selectProp&&(pe.userSelect=pe.docStyle[pe.selectProp],pe.docStyle[pe.selectProp]="none")}static enableDrag(){pe.docStyle&&pe.selectProp&&(pe.docStyle[pe.selectProp]=pe.userSelect)}static setTransform(t,n){t.style[pe.transformProp]=n}static addEventListener(t,n,o,l={}){t.addEventListener(n,o,"passive"in l?l:l.capture)}static removeEventListener(t,n,o,l={}){t.removeEventListener(n,o,"passive"in l?l:l.capture)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",pe.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",pe.suppressClickInternal,!0),window.setTimeout((()=>{window.removeEventListener("click",pe.suppressClickInternal,!0)}),0)}static getScale(t){const n=t.getBoundingClientRect();return{x:n.width/t.offsetWidth||1,y:n.height/t.offsetHeight||1,boundingClientRect:n}}static getPoint(t,n,o){const l=n.boundingClientRect;return new c.P((o.clientX-l.left)/n.x-t.clientLeft,(o.clientY-l.top)/n.y-t.clientTop)}static mousePos(t,n){const o=pe.getScale(t);return pe.getPoint(t,o,n)}static touchPos(t,n){const o=[],l=pe.getScale(t);for(let p=0;p<n.length;p++)o.push(pe.getPoint(t,l,n[p]));return o}static mouseButton(t){return t.button}static remove(t){t.parentNode&&t.parentNode.removeChild(t)}static sanitize(t){const n=new DOMParser().parseFromString(t,"text/html").body||document.createElement("body"),o=n.querySelectorAll("script");for(const l of o)l.remove();return pe.clean(n),n.innerHTML}static isPossiblyDangerous(t,n){const o=n.replace(/\s+/g,"").toLowerCase();return!(!["src","href","xlink:href"].includes(t)||!o.includes("javascript:")&&!o.includes("data:"))||!!t.startsWith("on")||void 0}static clean(t){const n=t.children;for(const o of n)pe.removeAttributes(o),pe.clean(o)}static removeAttributes(t){for(const{name:n,value:o}of t.attributes)pe.isPossiblyDangerous(n,o)&&t.removeAttribute(n)}}pe.docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style,pe.selectProp=pe.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),pe.transformProp=pe.testProp(["transform","WebkitTransform"]);const pr={supported:!1,testSupport:function(d){!kr&&mt&&(Yn?Ds(d):bt=d)}};let bt,mt,kr=!1,Yn=!1;function Ds(d){const t=d.createTexture();d.bindTexture(d.TEXTURE_2D,t);try{if(d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,mt),d.isContextLost())return;pr.supported=!0}catch{}d.deleteTexture(t),kr=!0}var Ni;typeof document<"u"&&(mt=document.createElement("img"),mt.onload=()=>{bt&&Ds(bt),bt=null,Yn=!0},mt.onerror=()=>{kr=!0,bt=null},mt.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),(function(d){let t,n,o,l;d.resetRequestQueue=()=>{t=[],n=0,o=0,l={}},d.addThrottleControl=v=>{const w=o++;return l[w]=v,w},d.removeThrottleControl=v=>{delete l[v],m()},d.getImage=(v,w,T=!0)=>new Promise(((C,M)=>{pr.supported&&(v.headers||(v.headers={}),v.headers.accept="image/webp,*/*"),c.e(v,{type:"image"}),t.push({abortController:w,requestParameters:v,supportImageRefresh:T,state:"queued",onError:z=>{M(z)},onSuccess:z=>{C(z)}}),m()}));const p=v=>c._(this,void 0,void 0,(function*(){v.state="running";const{requestParameters:w,supportImageRefresh:T,onError:C,onSuccess:M,abortController:z}=v,R=T===!1&&!c.i(self)&&!c.g(w.url)&&(!w.headers||Object.keys(w.headers).reduce(((j,Z)=>j&&Z==="accept"),!0));n++;const N=R?_(w,z):c.m(w,z);try{const j=yield N;delete v.abortController,v.state="completed",j.data instanceof HTMLImageElement||c.b(j.data)?M(j):j.data&&M({data:yield(U=j.data,typeof createImageBitmap=="function"?c.f(U):c.h(U)),cacheControl:j.cacheControl,expires:j.expires})}catch(j){delete v.abortController,C(j)}finally{n--,m()}var U})),m=()=>{const v=(()=>{for(const w of Object.keys(l))if(l[w]())return!0;return!1})()?c.c.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:c.c.MAX_PARALLEL_IMAGE_REQUESTS;for(let w=n;w<v&&t.length>0;w++){const T=t.shift();T.abortController.signal.aborted?w--:p(T)}},_=(v,w)=>new Promise(((T,C)=>{const M=new Image,z=v.url,R=v.credentials;R&&R==="include"?M.crossOrigin="use-credentials":(R&&R==="same-origin"||!c.d(z))&&(M.crossOrigin="anonymous"),w.signal.addEventListener("abort",(()=>{M.src="",C(new c.a(w.signal.reason))})),M.fetchPriority="high",M.onload=()=>{M.onerror=M.onload=null,T({data:M})},M.onerror=()=>{M.onerror=M.onload=null,w.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."))},M.src=z}))})(Ni||(Ni={})),Ni.resetRequestQueue();class zs{constructor(t){this._transformRequestFn=t??null}transformRequest(t,n){return this._transformRequestFn&&this._transformRequestFn(t,n)||{url:t}}setTransformRequest(t){this._transformRequestFn=t}}function wr(d){const t=[];if(typeof d=="string")t.push({id:"default",url:d});else if(d&&d.length>0){const n=[];for(const{id:o,url:l}of d){const p=`${o}${l}`;n.indexOf(p)===-1&&(n.push(p),t.push({id:o,url:l}))}}return t}function rn(d,t,n){try{const o=new URL(d);return o.pathname+=`${t}${n}`,o.toString()}catch{throw new Error(`Invalid sprite URL "${d}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function xn(d){const{userImage:t}=d;return!!(t&&t.render&&t.render())&&(d.data.replace(new Uint8Array(t.data.buffer)),!0)}class nn extends c.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new c.R({width:1,height:1}),this.dirty=!0}destroy(){this.atlasTexture&&(this.atlasTexture.destroy(),this.atlasTexture=null);for(const t of Object.keys(this.images))this.removeImage(t);this.patterns={},this.atlasImage=new c.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:n,promiseResolve:o}of this.requestors)o(this._getImagesForIds(n));this.requestors=[]}}getImage(t){const n=this.images[t];if(n&&!n.data&&n.spriteData){const o=n.spriteData;n.data=new c.R({width:o.width,height:o.height},o.context.getImageData(o.x,o.y,o.width,o.height).data),n.spriteData=null}return n}addImage(t,n){if(this.images[t])throw new Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,n)&&(this.images[t]=n)}_validate(t,n){let o=!0;const l=n.data||n.spriteData;return this._validateStretch(n.stretchX,l&&l.width)||(this.fire(new c.k(new Error(`Image "${t}" has invalid "stretchX" value`))),o=!1),this._validateStretch(n.stretchY,l&&l.height)||(this.fire(new c.k(new Error(`Image "${t}" has invalid "stretchY" value`))),o=!1),this._validateContent(n.content,n)||(this.fire(new c.k(new Error(`Image "${t}" has invalid "content" value`))),o=!1),o}_validateStretch(t,n){if(!t)return!0;let o=0;for(const l of t){if(l[0]<o||l[1]<l[0]||n<l[1])return!1;o=l[1]}return!0}_validateContent(t,n){if(!t)return!0;if(t.length!==4)return!1;const o=n.spriteData,l=o&&o.width||n.data.width,p=o&&o.height||n.data.height;return!(t[0]<0||l<t[0]||t[1]<0||p<t[1]||t[2]<0||l<t[2]||t[3]<0||p<t[3]||t[2]<t[0]||t[3]<t[1])}updateImage(t,n,o=!0){const l=this.getImage(t);if(o&&(l.data.width!==n.data.width||l.data.height!==n.data.height))throw new Error(`size mismatch between old image (${l.data.width}x${l.data.height}) and new image (${n.data.width}x${n.data.height}).`);n.version=l.version+1,this.images[t]=n,this.updatedImages[t]=!0}removeImage(t){const n=this.images[t];delete this.images[t],delete this.patterns[t],n.userImage&&n.userImage.onRemove&&n.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(t){return new Promise(((n,o)=>{let l=!0;if(!this.isLoaded())for(const p of t)this.images[p]||(l=!1);this.isLoaded()||l?n(this._getImagesForIds(t)):this.requestors.push({ids:t,promiseResolve:n})}))}_getImagesForIds(t){const n={};for(const o of t){let l=this.getImage(o);l||(this.fire(new c.l("styleimagemissing",{id:o})),l=this.getImage(o)),l?n[o]={data:l.data.clone(),pixelRatio:l.pixelRatio,sdf:l.sdf,version:l.version,stretchX:l.stretchX,stretchY:l.stretchY,content:l.content,textFitWidth:l.textFitWidth,textFitHeight:l.textFitHeight,hasRenderCallback:!!(l.userImage&&l.userImage.render)}:c.w(`Image "${o}" 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 n}getPixelSize(){const{width:t,height:n}=this.atlasImage;return{width:t,height:n}}getPattern(t){const n=this.patterns[t],o=this.getImage(t);if(!o)return null;if(n&&n.position.version===o.version)return n.position;if(n)n.position.version=o.version;else{const l={w:o.data.width+2,h:o.data.height+2,x:0,y:0},p=new c.I(l,o);this.patterns[t]={bin:l,position:p}}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){const n=t.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new c.T(t,this.atlasImage,n.RGBA),this.atlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(){const t=[];for(const p in this.patterns)t.push(this.patterns[p].bin);const{w:n,h:o}=c.p(t),l=this.atlasImage;l.resize({width:n||1,height:o||1});for(const p in this.patterns){const{bin:m}=this.patterns[p],_=m.x+1,v=m.y+1,w=this.getImage(p).data,T=w.width,C=w.height;c.R.copy(w,l,{x:0,y:0},{x:_,y:v},{width:T,height:C}),c.R.copy(w,l,{x:0,y:C-1},{x:_,y:v-1},{width:T,height:1}),c.R.copy(w,l,{x:0,y:0},{x:_,y:v+C},{width:T,height:1}),c.R.copy(w,l,{x:T-1,y:0},{x:_-1,y:v},{width:1,height:C}),c.R.copy(w,l,{x:0,y:0},{x:_+T,y:v},{width:1,height:C})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(const n of t){if(this.callbackDispatchedThisFrame[n])continue;this.callbackDispatchedThisFrame[n]=!0;const o=this.getImage(n);o||c.w(`Image with ID: "${n}" was not found`),xn(o)&&this.updateImage(n,o)}}cloneImages(){const t={};for(const n in this.images){const o=this.images[n];t[n]=Object.assign(Object.assign({},o),{data:o.data?o.data.clone():null})}return t}}const Tr=1e20;function sn(d,t,n,o,l,p,m,_,v){for(let w=t;w<t+o;w++)ks(d,n*p+w,p,l,m,_,v);for(let w=n;w<n+l;w++)ks(d,w*p+t,1,o,m,_,v)}function ks(d,t,n,o,l,p,m){p[0]=0,m[0]=-Tr,m[1]=Tr,l[0]=d[t];for(let _=1,v=0,w=0;_<o;_++){l[_]=d[t+_*n];const T=_*_;do{const C=p[v];w=(l[_]-l[C]+T-C*C)/(_-C)/2}while(w<=m[v]&&--v>-1);v++,p[v]=_,m[v]=w,m[v+1]=Tr}for(let _=0,v=0;_<o;_++){for(;m[v+1]<_;)v++;const w=p[v],T=_-w;d[t+_*n]=l[w]+T*T}}const Kn=c.v.layout_symbol["text-font"].default.join(",");class Lr{constructor(t,n,o){this.requestManager=t,this.localIdeographFontFamily=n,this.entries={},this.lang=o}setURL(t){this.url=t}getGlyphs(t){return c._(this,void 0,void 0,(function*(){const n=[];for(const p in t)for(const m of t[p])n.push(this._getAndCacheGlyphsPromise(p,m));const o=yield Promise.all(n),l={};for(const{stack:p,id:m,glyph:_}of o)l[p]||(l[p]={}),l[p][m]=_&&{id:_.id,bitmap:_.bitmap.clone(),metrics:_.metrics};return l}))}_getAndCacheGlyphsPromise(t,n){return c._(this,void 0,void 0,(function*(){let o=this.entries[t];o||(o=this.entries[t]={glyphs:{},requests:{},ranges:{}});let l=o.glyphs[n];return l!==void 0?{stack:t,id:n,glyph:l}:!this.url||this._charUsesLocalIdeographFontFamily(n)?(l=o.glyphs[n]=this._drawGlyph(o,t,n),{stack:t,id:n,glyph:l}):yield this._downloadAndCacheRangePromise(t,n)}))}_downloadAndCacheRangePromise(t,n){return c._(this,void 0,void 0,(function*(){const o=this.entries[t],l=Math.floor(n/256);if(o.ranges[l])return{stack:t,id:n,glyph:null};if(!o.requests[l]){const p=Lr.loadGlyphRange(t,l,this.url,this.requestManager);o.requests[l]=p}try{const p=yield o.requests[l];for(const m in p)o.glyphs[+m]=p[+m];return o.ranges[l]=!0,{stack:t,id:n,glyph:p[n]||null}}catch(p){const m=o.glyphs[n]=this._drawGlyph(o,t,n);return this._warnOnMissingGlyphRange(m,l,n,p),{stack:t,id:n,glyph:m}}}))}_warnOnMissingGlyphRange(t,n,o,l){const p=256*n,m=p+255,_=o.toString(16).padStart(4,"0").toUpperCase();c.w(`Unable to load glyph range ${n}, ${p}-${m}. Rendering codepoint U+${_} locally instead. ${l}`)}_charUsesLocalIdeographFontFamily(t){return!!this.localIdeographFontFamily&&c.q(t)}_drawGlyph(t,n,o){const l=n===Kn&&this.localIdeographFontFamily!==""&&this._charUsesLocalIdeographFontFamily(o),p=l?"ideographTinySDF":"tinySDF";t[p]||(t[p]=this._createTinySDF(l?this.localIdeographFontFamily:n));const m=t[p].draw(String.fromCodePoint(o)),_=/^\p{gc=Cf}+$/u.test(String.fromCodePoint(o));return{id:o,bitmap:new c.r({width:m.width||60,height:m.height||60},m.data),metrics:{width:_?0:m.glyphWidth/2||24,height:m.glyphHeight/2||24,left:m.glyphLeft/2+.5||0,top:m.glyphTop/2-27.5||-8,advance:_?0:m.glyphAdvance/2||24,isDoubleResolution:!0}}}_createTinySDF(t){const n=t?t.split(","):[];n.push("sans-serif");const o=n.map((l=>/[-\w]+/.test(l)?l:`'${CSS.escape(l)}'`)).join(",");return new Lr.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:o,fontWeight:this._fontWeight(n[0]),fontStyle:this._fontStyle(n[0]),lang:this.lang})}_fontStyle(t){return/italic/i.test(t)?"italic":/oblique/i.test(t)?"oblique":"normal"}_fontWeight(t){const n={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 o;for(const[l,p]of Object.entries(n))new RegExp(`\\b${l}\\b`,"i").test(t)&&(o=`${p}`);return o}destroy(){for(const t in this.entries){const n=this.entries[t];n.tinySDF&&(n.tinySDF=null),n.ideographTinySDF&&(n.ideographTinySDF=null),n.glyphs={},n.requests={},n.ranges={}}this.entries={}}}Lr.loadGlyphRange=function(d,t,n,o){return c._(this,void 0,void 0,(function*(){const l=256*t,p=l+255,m=o.transformRequest(n.replace("{fontstack}",d).replace("{range}",`${l}-${p}`),"Glyphs"),_=yield c.n(m,new AbortController);if(!_||!_.data)throw new Error(`Could not load glyph range. range: ${t}, ${l}-${p}`);const v={};for(const w of c.o(_.data))v[w.id]=w;return v}))},Lr.TinySDF=class{constructor({fontSize:d=24,buffer:t=3,radius:n=8,cutoff:o=.25,fontFamily:l="sans-serif",fontWeight:p="normal",fontStyle:m="normal",lang:_=null}={}){this.buffer=t,this.cutoff=o,this.radius=n,this.lang=_;const v=this.size=d+4*t,w=this._createCanvas(v),T=this.ctx=w.getContext("2d",{willReadFrequently:!0});T.font=`${m} ${p} ${d}px ${l}`,T.textBaseline="alphabetic",T.textAlign="left",T.fillStyle="black",this.gridOuter=new Float64Array(v*v),this.gridInner=new Float64Array(v*v),this.f=new Float64Array(v),this.z=new Float64Array(v+1),this.v=new Uint16Array(v)}_createCanvas(d){const t=document.createElement("canvas");return t.width=t.height=d,t}draw(d){const{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:o,actualBoundingBoxLeft:l,actualBoundingBoxRight:p}=this.ctx.measureText(d),m=Math.ceil(n),_=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(p-l))),v=Math.min(this.size-this.buffer,m+Math.ceil(o)),w=_+2*this.buffer,T=v+2*this.buffer,C=Math.max(w*T,0),M=new Uint8ClampedArray(C),z={data:M,width:w,height:T,glyphWidth:_,glyphHeight:v,glyphTop:m,glyphLeft:0,glyphAdvance:t};if(_===0||v===0)return z;const{ctx:R,buffer:N,gridInner:U,gridOuter:j}=this;this.lang&&(R.lang=this.lang),R.clearRect(N,N,_,v),R.fillText(d,N,N+m);const Z=R.getImageData(N,N,_,v);j.fill(Tr,0,C),U.fill(0,0,C);for(let X=0;X<v;X++)for(let q=0;q<_;q++){const Y=Z.data[4*(X*_+q)+3]/255;if(Y===0)continue;const Q=(X+N)*w+q+N;if(Y===1)j[Q]=0,U[Q]=Tr;else{const H=.5-Y;j[Q]=H>0?H*H:0,U[Q]=H<0?H*H:0}}sn(j,0,0,w,T,w,this.f,this.v,this.z),sn(U,N,N,_,v,w,this.f,this.v,this.z);for(let X=0;X<C;X++){const q=Math.sqrt(j[X])-Math.sqrt(U[X]);M[X]=Math.round(255-255*(q/this.radius+this.cutoff))}return z}};class Ht{constructor(){this.specification=c.u.light.position}possiblyEvaluate(t,n){return c.F(t.expression.evaluate(n))}interpolate(t,n,o){return{x:c.G.number(t.x,n.x,o),y:c.G.number(t.y,n.y,o),z:c.G.number(t.z,n.z,o)}}}let ht;class bn extends c.E{constructor(t){super(),ht=ht||new c.t({anchor:new c.D(c.u.light.anchor),position:new Ht,color:new c.D(c.u.light.color),intensity:new c.D(c.u.light.intensity)}),this._transitionable=new c.x(ht,void 0),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,n={}){if(!this._validate(c.y,t,n))for(const o in t){const l=t[o];o.endsWith(c.z)?this._transitionable.setTransition(o.slice(0,-c.z.length),l):this._transitionable.setValue(o,l)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,n,o){return(!o||o.validate!==!1)&&c.B(this,t.call(c.C,{value:n,style:{glyphs:!0,sprite:!0},styleSpec:c.u}))}}const Sr=new c.t({"sky-color":new c.D(c.u.sky["sky-color"]),"horizon-color":new c.D(c.u.sky["horizon-color"]),"fog-color":new c.D(c.u.sky["fog-color"]),"fog-ground-blend":new c.D(c.u.sky["fog-ground-blend"]),"horizon-fog-blend":new c.D(c.u.sky["horizon-fog-blend"]),"sky-horizon-blend":new c.D(c.u.sky["sky-horizon-blend"]),"atmosphere-blend":new c.D(c.u.sky["atmosphere-blend"])});class Ls extends c.E{constructor(t){super(),this._transitionable=new c.x(Sr,void 0),this.setSky(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new c.H(0))}setSky(t,n={}){if(!this._validate(c.J,t,n)){t||(t={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0});for(const o in t){const l=t[o];o.endsWith(c.z)?this._transitionable.setTransition(o.slice(0,-c.z.length),l):this._transitionable.setValue(o,l)}}}getSky(){return this._transitionable.serialize()}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,n,o={}){return o?.validate!==!1&&c.B(this,t.call(c.C,c.e({value:n,style:{glyphs:!0,sprite:!0},styleSpec:c.u})))}calculateFogBlendOpacity(t){return t<60?0:t<70?(t-60)/10:1}}class Jn{constructor(t,n){this.width=t,this.height=n,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(t,n){const o=t.join(",")+String(n);return this.dashEntry[o]||(this.dashEntry[o]=this.addDash(t,n)),this.dashEntry[o]}getDashRanges(t,n,o){const l=[];let p=t.length%2==1?-t[t.length-1]*o:0,m=t[0]*o,_=!0;l.push({left:p,right:m,isDash:_,zeroLength:t[0]===0});let v=t[0];for(let w=1;w<t.length;w++){_=!_;const T=t[w];p=v*o,v+=T,m=v*o,l.push({left:p,right:m,isDash:_,zeroLength:T===0})}return l}addRoundDash(t,n,o){const l=n/2;for(let p=-o;p<=o;p++){const m=this.width*(this.nextRow+o+p);let _=0,v=t[_];for(let w=0;w<this.width;w++){w/v.right>1&&(v=t[++_]);const T=Math.abs(w-v.left),C=Math.abs(w-v.right),M=Math.min(T,C);let z;const R=p/o*(l+1);if(v.isDash){const N=l-Math.abs(R);z=Math.sqrt(M*M+N*N)}else z=l-Math.sqrt(M*M+R*R);this.data[m+w]=Math.max(0,Math.min(255,z+128))}}}addRegularDash(t){for(let _=t.length-1;_>=0;--_){const v=t[_],w=t[_+1];v.zeroLength?t.splice(_,1):w&&w.isDash===v.isDash&&(w.left=v.left,t.splice(_,1))}const n=t[0],o=t[t.length-1];n.isDash===o.isDash&&(n.left=o.left-this.width,o.right=n.right+this.width);const l=this.width*this.nextRow;let p=0,m=t[p];for(let _=0;_<this.width;_++){_/m.right>1&&(m=t[++p]);const v=Math.abs(_-m.left),w=Math.abs(_-m.right),T=Math.min(v,w);this.data[l+_]=Math.max(0,Math.min(255,(m.isDash?T:-T)+128))}}addDash(t,n){const o=n?7:0,l=2*o+1;if(this.nextRow+l>this.height)return c.w("LineAtlas out of space"),null;let p=0;for(let _=0;_<t.length;_++)p+=t[_];if(p!==0){const _=this.width/p,v=this.getDashRanges(t,this.width,_);n?this.addRoundDash(v,_,o):this.addRegularDash(v)}const m={y:this.nextRow+o,height:2*o,width:p};return this.nextRow+=l,this.dirty=!0,m}bind(t){const n=t.gl;this.texture?(n.bindTexture(n.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,n.texSubImage2D(n.TEXTURE_2D,0,0,0,this.width,this.height,n.ALPHA,n.UNSIGNED_BYTE,this.data))):(this.texture=n.createTexture(),n.bindTexture(n.TEXTURE_2D,this.texture),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texImage2D(n.TEXTURE_2D,0,n.ALPHA,this.width,this.height,0,n.ALPHA,n.UNSIGNED_BYTE,this.data))}}const on="maplibre_preloaded_worker_pool";class Rr{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<Rr.workerCount;)this.workers.push(new Worker(c.c.WORKER_URL));return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],this.numActive()===0&&(this.workers.forEach((n=>{n.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[on]}numActive(){return Object.keys(this.active).length}}const ir=Math.floor($t.hardwareConcurrency/2);let fi,ki;function Qn(){return fi||(fi=new Rr),fi}Rr.workerCount=c.K(globalThis)?Math.max(Math.min(ir,3),1):1;class wn{constructor(t,n){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=n;const o=this.workerPool.acquire(n);for(let l=0;l<o.length;l++){const p=new c.L(o[l],n);p.name=`Worker ${l}`,this.actors.push(p)}if(!this.actors.length)throw new Error("No actors found")}broadcast(t,n){const o=[];for(const l of this.actors)o.push(l.sendAsync({type:t,data:n}));return Promise.all(o)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(t=!0){this.actors.forEach((n=>{n.remove()})),this.actors=[],t&&this.workerPool.release(this.id)}registerMessageHandler(t,n){for(const o of this.actors)o.registerMessageHandler(t,n)}unregisterMessageHandler(t){for(const n of this.actors)n.unregisterMessageHandler(t)}}function Tn(){return ki||(ki=new wn(Qn(),c.M),ki.registerMessageHandler("GR",((d,t,n)=>c.m(t,n)))),ki}function mi(d,t){const n=c.N();return c.O(n,n,[1,1,0]),c.Q(n,n,[.5*d.width,.5*d.height,1]),d.calculatePosMatrix?c.S(n,n,d.calculatePosMatrix(t.toUnwrapped())):n}function zo(d,t,n,o,l,p,m){var _;const v=(function(M,z,R){if(M)for(const N of M){const U=z[N];if(U&&U.source===R&&U.type==="fill-extrusion")return!0}else for(const N in z){const U=z[N];if(U.source===R&&U.type==="fill-extrusion")return!0}return!1})((_=l?.layers)!==null&&_!==void 0?_:null,t,d.id),w=p.maxPitchScaleFactor(),T=d.tilesIn(o,w,v);T.sort(gi);const C=[];for(const M of T)C.push({wrappedTileID:M.tileID.wrapped().key,queryResults:M.tile.queryRenderedFeatures(t,n,d.getState(),M.queryGeometry,M.cameraQueryGeometry,M.scale,l,p,w,mi(p,M.tileID),m?(z,R)=>m(M.tileID,z,R):void 0)});return(function(M,z){for(const R in M)for(const N of M[R])ji(N,z);return M})((function(M){const z={},R={};for(const N of M){const U=N.queryResults,j=N.wrappedTileID,Z=R[j]=R[j]||{};for(const X in U){const q=U[X],Y=Z[X]=Z[X]||{},Q=z[X]=z[X]||[];for(const H of q)Y[H.featureIndex]||(Y[H.featureIndex]=!0,Q.push(H))}}return z})(C),d)}function gi(d,t){const n=d.tileID,o=t.tileID;return n.overscaledZ-o.overscaledZ||n.canonical.y-o.canonical.y||n.wrap-o.wrap||n.canonical.x-o.canonical.x}function ji(d,t){const n=d.feature,o=t.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=o}function Pr(d,t,n,o){return c._(this,void 0,void 0,(function*(){let l=d;if(d.url?l=(yield c.j(t.transformRequest(d.url,"Source"),n)).data:yield $t.frameAsync(n,o),!l)return null;const p=c.U(c.e(l,d),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in l&&l.vector_layers&&(p.vectorLayerIds=l.vector_layers.map((m=>m.id))),p}))}class Mt{constructor(t,n){t&&(n?this.setSouthWest(t).setNorthEast(n):Array.isArray(t)&&(t.length===4?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1])))}setNorthEast(t){return this._ne=t instanceof c.V?new c.V(t.lng,t.lat):c.V.convert(t),this}setSouthWest(t){return this._sw=t instanceof c.V?new c.V(t.lng,t.lat):c.V.convert(t),this}extend(t){const n=this._sw,o=this._ne;let l,p;if(t instanceof c.V)l=t,p=t;else{if(!(t instanceof Mt))return Array.isArray(t)?t.length===4||t.every(Array.isArray)?this.extend(Mt.convert(t)):this.extend(c.V.convert(t)):t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(c.V.convert(t)):this;if(l=t._sw,p=t._ne,!l||!p)return this}return n||o?(n.lng=Math.min(l.lng,n.lng),n.lat=Math.min(l.lat,n.lat),o.lng=Math.max(p.lng,o.lng),o.lat=Math.max(p.lat,o.lat)):(this._sw=new c.V(l.lng,l.lat),this._ne=new c.V(p.lng,p.lat)),this}getCenter(){return new c.V((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 c.V(this.getWest(),this.getNorth())}getSouthEast(){return new c.V(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:n,lat:o}=c.V.convert(t);let l=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(l=this._sw.lng>=n&&n>=this._ne.lng),this._sw.lat<=o&&o<=this._ne.lat&&l}intersects(t){if(!((t=Mt.convert(t)).getNorth()>=this.getSouth()&&t.getSouth()<=this.getNorth()))return!1;const n=Math.abs(this.getEast()-this.getWest()),o=Math.abs(t.getEast()-t.getWest());if(n>=360||o>=360)return!0;const l=c.W(this.getWest(),-180,180),p=c.W(this.getEast(),-180,180),m=c.W(t.getWest(),-180,180),_=c.W(t.getEast(),-180,180),v=l>p,w=m>_;return!(!v||!w)||(v?_>=l||m<=p:w?p>=m||l<=_:m<=p&&_>=l)}static convert(t){return t instanceof Mt?t:t&&new Mt(t)}static fromLngLat(t,n=0){const o=360*n/40075017,l=o/Math.cos(Math.PI/180*t.lat);return new Mt(new c.V(t.lng-l,t.lat-o),new c.V(t.lng+l,t.lat+o))}adjustAntiMeridian(){const t=new c.V(this._sw.lng,this._sw.lat),n=new c.V(this._ne.lng,this._ne.lat);return new Mt(t,t.lng>n.lng?new c.V(n.lng+360,n.lat):n)}}class Sn{constructor(t,n,o){this.bounds=Mt.convert(this.validateBounds(t)),this.minzoom=n||0,this.maxzoom=o||24}validateBounds(t){return Array.isArray(t)&&t.length===4?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(t){const n=Math.pow(2,t.z),o=Math.floor(c.Y(this.bounds.getWest())*n),l=Math.floor(c.X(this.bounds.getNorth())*n),p=Math.ceil(c.Y(this.bounds.getEast())*n),m=Math.ceil(c.X(this.bounds.getSouth())*n);return t.x>=o&&t.x<p&&t.y>=l&&t.y<m}}class es extends c.E{constructor(t,n,o,l){if(super(),this.id=t,this.dispatcher=o,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,c.e(this,c.U(n,["url","scheme","tileSize","promoteId","encoding"])),this._options=c.e({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(l)}load(){return c._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new c.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const t=yield Pr(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,this.map.style.tileManagers[this.id].clearTiles(),t&&(c.e(this,t),t.bounds&&(this.tileBounds=new Sn(t.bounds,this.minzoom,this.maxzoom)),this.fire(new c.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new c.l("data",{dataType:"source",sourceDataType:"content"})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,c.Z(t)||this.fire(new c.k(t))}}))}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.abort(),t(),this.load()}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return c.e({},this._options)}loadTile(t){return c._(this,void 0,void 0,(function*(){const n=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),o={request:this.map._requestManager.transformRequest(n,"Tile"),uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.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(t)};o.request.collectResourceTiming=this._collectResourceTiming;let l="RT";if(t.actor&&t.state!=="expired"){if(t.state==="loading")return new Promise(((p,m)=>{t.reloadPromise={resolve:p,reject:m}}))}else t.actor=this.dispatcher.getActor(),l="LT";t.abortController=new AbortController;try{const p=yield t.actor.sendAsync({type:l,data:o},t.abortController);if(delete t.abortController,t.aborted)return;this._afterTileLoadWorkerResponse(t,p)}catch(p){if(delete t.abortController,t.aborted)return;if(p&&p.status!==404)throw p;this._afterTileLoadWorkerResponse(t,null)}}))}_getOverzoomParameters(t){if(t.tileID.canonical.z<=this.maxzoom||this.map._zoomLevelsToOverscale===void 0)return;const n=t.tileID.scaledTo(this.maxzoom).canonical,o=n.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:n,overzoomRequest:this.map._requestManager.transformRequest(o,"Tile")}}_afterTileLoadWorkerResponse(t,n){if(n&&n.resourceTiming&&(t.resourceTiming=n.resourceTiming),n&&this.map._refreshExpiredTiles&&t.setExpiryData(n),t.loadVectorData(n,this.map.painter),t.reloadPromise){const o=t.reloadPromise;t.reloadPromise=null,this.loadTile(t).then(o.resolve).catch(o.reject)}}abortTile(t){return c._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.actor&&(yield t.actor.sendAsync({type:"AT",data:{uid:t.uid,type:this.type,source:this.id}}))}))}unloadTile(t){return c._(this,void 0,void 0,(function*(){t.unloadVectorData(),t.actor&&(yield t.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}}))}))}hasTransition(){return!1}}class Pn extends c.E{constructor(t,n,o,l){super(),this.id=t,this.dispatcher=o,this.setEventedParent(l),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=c.e({type:"raster"},n),c.e(this,c.U(n,["url","scheme","tileSize"]))}load(){return c._(this,arguments,void 0,(function*(t=!1){this._loaded=!1,this.fire(new c.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const n=yield Pr(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,n&&(c.e(this,n),n.bounds&&(this.tileBounds=new Sn(n.bounds,this.minzoom,this.maxzoom)),this.fire(new c.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new c.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:t})))}catch(n){this._tileJSONRequest=null,this._loaded=!0,c.Z(n)||this.fire(new c.k(n))}}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(t){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),t(),this.load(!0)}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}serialize(){return c.e({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t){return c._(this,void 0,void 0,(function*(){const n=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);t.abortController=new AbortController;try{const o=yield Ni.getImage(this.map._requestManager.transformRequest(n,"Tile"),t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(o&&o.data){this.map._refreshExpiredTiles&&(o.cacheControl||o.expires)&&t.setExpiryData({cacheControl:o.cacheControl,expires:o.expires});const l=this.map.painter.context,p=l.gl,m=o.data;t.texture=this.map.painter.getTileTexture(m.width),t.texture?t.texture.update(m,{useMipmap:!0}):(t.texture=new c.T(l,m,p.RGBA,{useMipmap:!0}),t.texture.bind(p.LINEAR,p.CLAMP_TO_EDGE,p.LINEAR_MIPMAP_NEAREST)),t.state="loaded"}}catch(o){if(delete t.abortController,t.aborted)t.state="unloaded";else if(o)throw t.state="errored",o}}))}abortTile(t){return c._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController)}))}unloadTile(t){return c._(this,void 0,void 0,(function*(){t.texture&&this.map.painter.saveTileTexture(t.texture)}))}hasTransition(){return!1}}class an extends Pn{constructor(t,n,o,l){super(t,n,o,l),this.type="raster-dem",this.maxzoom=22,this._options=c.e({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox",this.redFactor=n.redFactor,this.greenFactor=n.greenFactor,this.blueFactor=n.blueFactor,this.baseShift=n.baseShift}loadTile(t){return c._(this,void 0,void 0,(function*(){const n=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),o=this.map._requestManager.transformRequest(n,"Tile");t.neighboringTiles=this._getNeighboringTiles(t.tileID),t.abortController=new AbortController;try{const l=yield Ni.getImage(o,t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(l&&l.data){const p=l.data;this.map._refreshExpiredTiles&&(l.cacheControl||l.expires)&&t.setExpiryData({cacheControl:l.cacheControl,expires:l.expires});const m=c.b(p)&&c.$()?p:yield this.readImageNow(p),_={type:this.type,uid:t.uid,source:this.id,rawImageData:m,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!t.actor||t.state==="expired"){t.actor=this.dispatcher.getActor();const v=yield t.actor.sendAsync({type:"LDT",data:_});t.dem=v,t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.state="loaded"}}}catch(l){if(delete t.abortController,t.aborted)t.state="unloaded";else if(l)throw t.state="errored",l}}))}readImageNow(t){return c._(this,void 0,void 0,(function*(){if(typeof VideoFrame<"u"&&c.a0()){const n=t.width+2,o=t.height+2;try{return new c.R({width:n,height:o},yield c.a1(t,-1,-1,n,o))}catch{}}return $t.getImageData(t,1)}))}_getNeighboringTiles(t){const n=t.canonical,o=Math.pow(2,n.z),l=(n.x-1+o)%o,p=n.x===0?t.wrap-1:t.wrap,m=(n.x+1+o)%o,_=n.x+1===o?t.wrap+1:t.wrap,v={};return v[new c.a2(t.overscaledZ,p,n.z,l,n.y).key]={backfilled:!1},v[new c.a2(t.overscaledZ,_,n.z,m,n.y).key]={backfilled:!1},n.y>0&&(v[new c.a2(t.overscaledZ,p,n.z,l,n.y-1).key]={backfilled:!1},v[new c.a2(t.overscaledZ,t.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},v[new c.a2(t.overscaledZ,_,n.z,m,n.y-1).key]={backfilled:!1}),n.y+1<o&&(v[new c.a2(t.overscaledZ,p,n.z,l,n.y+1).key]={backfilled:!1},v[new c.a2(t.overscaledZ,t.wrap,n.z,n.x,n.y+1).key]={backfilled:!1},v[new c.a2(t.overscaledZ,_,n.z,m,n.y+1).key]={backfilled:!1}),v}unloadTile(t){return c._(this,void 0,void 0,(function*(){t.demTexture&&this.map.painter.saveTileTexture(t.demTexture),t.fbo&&(t.fbo.destroy(),delete t.fbo),t.dem&&delete t.dem,delete t.neighboringTiles,t.state="unloaded",t.actor&&(yield t.actor.sendAsync({type:"RDT",data:{type:this.type,uid:t.uid,source:this.id}}))}))}}function Mr(d){return d&&d.length!==0?typeof d[0]=="number"?[d]:d.flatMap((t=>Mr(t))):[]}function ln(d){return d.type==="GeometryCollection"?d.geometries.flatMap((t=>ln(t))):Mr(d.coordinates)}function Mn(d){const t=new Mt;let n;switch(d.type){case"FeatureCollection":n=d.features.flatMap((o=>ln(o.geometry)));break;case"Feature":n=ln(d.geometry);break;default:n=ln(d)}if(n.length===0)return t;for(let o=0;o<n.length;o++){const[l,p]=n[o];t.extend([l,p])}return t}class Fr extends c.E{constructor(t,n,o,l){super(),this.id=t,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:n.data},this.actor=o.getActor(),this.setEventedParent(l),this._data=typeof n.data=="string"?{url:n.data}:{geojson:n.data},this._options=c.e({},n),this._collectResourceTiming=n.collectResourceTiming,n.maxzoom!==void 0&&(this.maxzoom=n.maxzoom),n.type&&(this.type=n.type),n.attribution&&(this.attribution=n.attribution),this.promoteId=n.promoteId,n.clusterMaxZoom!==void 0&&this.maxzoom<=n.clusterMaxZoom&&c.w(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${n.clusterMaxZoom}".`),this.workerOptions=c.e({source:this.id,cluster:n.cluster||!1,geojsonVtOptions:{buffer:this._pixelsToTileUnits(n.buffer!==void 0?n.buffer:128),tolerance:this._pixelsToTileUnits(n.tolerance!==void 0?n.tolerance:.375),extent:c.a5,maxZoom:this.maxzoom,lineMetrics:n.lineMetrics||!1,generateId:n.generateId||!1},superclusterOptions:{maxZoom:this._getClusterMaxZoom(n.clusterMaxZoom),minPoints:Math.max(2,n.clusterMinPoints||2),extent:c.a5,radius:this._pixelsToTileUnits(n.clusterRadius||50),log:!1,generateId:n.generateId||!1},clusterProperties:n.clusterProperties,filter:n.filter},n.workerOptions),typeof this.promoteId=="string"&&(this.workerOptions.promoteId=this.promoteId)}_hasPendingWorkerUpdate(){return this._pendingWorkerUpdate.data!==void 0||this._pendingWorkerUpdate.diff!==void 0||this._pendingWorkerUpdate.optionsChanged}_pixelsToTileUnits(t){return t*(c.a5/this.tileSize)}_getClusterMaxZoom(t){const n=t?Math.round(t):this.maxzoom-1;return Number.isInteger(t)||t===void 0||c.w(`Integer expected for option 'clusterMaxZoom': provided value "${t}" rounded to "${n}"`),n}load(){return c._(this,void 0,void 0,(function*(){yield this._updateWorkerData()}))}onAdd(t){this.map=t,this.load()}setData(t,n){this._data=typeof t=="string"?{url:t}:{geojson:t},this._pendingWorkerUpdate={data:t};const o=this._updateWorkerData();return n?o:this}updateData(t,n){this._pendingWorkerUpdate.diff=c.a6(this._pendingWorkerUpdate.diff,t);const o=this._updateWorkerData();return n?o:this}getData(){return c._(this,void 0,void 0,(function*(){const t=c.e({type:this.type},this.workerOptions);return this.actor.sendAsync({type:"GD",data:t})}))}getBounds(){return c._(this,void 0,void 0,(function*(){return Mn(yield this.getData())}))}setClusterOptions(t){return this.workerOptions.cluster=t.cluster,t.clusterRadius!==void 0&&(this.workerOptions.superclusterOptions.radius=this._pixelsToTileUnits(t.clusterRadius)),t.clusterMaxZoom!==void 0&&(this.workerOptions.superclusterOptions.maxZoom=this._getClusterMaxZoom(t.clusterMaxZoom)),this._pendingWorkerUpdate.optionsChanged=!0,this._updateWorkerData(),this}getClusterExpansionZoom(t){return this.actor.sendAsync({type:"GCEZ",data:{type:this.type,clusterId:t,source:this.id}})}getClusterChildren(t){return this.actor.sendAsync({type:"GCC",data:{type:this.type,clusterId:t,source:this.id}})}getClusterLeaves(t,n,o){return this.actor.sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:t,limit:n,offset:o}})}_updateWorkerData(){return c._(this,void 0,void 0,(function*(){if(this._isUpdatingWorker)return;if(!this._hasPendingWorkerUpdate())return void c.w(`No pending worker updates for GeoJSONSource ${this.id}.`);const{data:t,diff:n}=this._pendingWorkerUpdate,o=this._getLoadGeoJSONParameters(t,n);t!==void 0?this._pendingWorkerUpdate.data=void 0:n&&(this._pendingWorkerUpdate.diff=void 0),this._pendingWorkerUpdate.optionsChanged=void 0,yield this._dispatchWorkerUpdate(o)}))}_getLoadGeoJSONParameters(t,n){const o=c.e({type:this.type},this.workerOptions);return typeof t=="string"?(o.request=this.map._requestManager.transformRequest($t.resolveURL(t),"Source"),o.request.collectResourceTiming=this._collectResourceTiming,o):t!==void 0?(o.data=t,o):(n&&(o.dataDiff=n),o)}_dispatchWorkerUpdate(t){return c._(this,void 0,void 0,(function*(){this._isUpdatingWorker=!0,this.fire(new c.l("dataloading",{dataType:"source"}));try{const n=yield this.actor.sendAsync({type:"LD",data:t});if(this._isUpdatingWorker=!1,this._removed||n.abandoned)return void this.fire(new c.l("dataabort",{dataType:"source"}));n.data&&(this._data={geojson:n.data});const o=this._applyDiffToSource(t.dataDiff),l=this._getShouldReloadTileOptions(o),p={dataType:"source"};this._applyResourceTiming(p,n),this.fire(new c.l("data",Object.assign(Object.assign({},p),{sourceDataType:"metadata"}))),this.fire(new c.l("data",Object.assign(Object.assign({},p),{sourceDataType:"content",shouldReloadTileOptions:l})))}catch(n){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new c.l("dataabort",{dataType:"source"}));this.fire(new c.k(n))}finally{this._hasPendingWorkerUpdate()&&this._updateWorkerData()}}))}_applyResourceTiming(t,n){var o;if(!this._collectResourceTiming)return;const l=(o=n.resourceTiming)===null||o===void 0?void 0:o[this.id];if(!l)return;const p=l.slice(0);p?.length&&c.e(t,{resourceTiming:p})}_applyDiffToSource(t){if(!t)return;const n=typeof this.promoteId=="string"?this.promoteId:void 0;if(!this._data.url&&!this._data.updateable){const l=c.a7(this._data.geojson,n);if(!l)throw new Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:l}}if(!this._data.updateable)return;const o=c.a8(this._data.updateable,t,n);return t.removeAll||this._options.cluster?void 0:o}_getShouldReloadTileOptions(t){if(t)return{affectedBounds:t.filter(Boolean).map((n=>Mn(n)))}}shouldReloadTile(t,{affectedBounds:n}){if(t.state==="loading")return!0;if(t.state==="unloaded")return!1;const{buffer:o,extent:l}=this.workerOptions.geojsonVtOptions,p=(function({x:m,y:_,z:v},w=0){const T=c.a3((m-w)/Math.pow(2,v)),C=c.a4((_+1+w)/Math.pow(2,v)),M=c.a3((m+1+w)/Math.pow(2,v)),z=c.a4((_-w)/Math.pow(2,v));return new Mt([T,C],[M,z])})(t.tileID.canonical,o/l);for(const m of n)if(p.intersects(m))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}loadTile(t){return c._(this,void 0,void 0,(function*(){const n=t.actor?"RT":"LT";t.actor=this.actor;const o={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.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};t.abortController=new AbortController;const l=yield this.actor.sendAsync({type:n,data:o},t.abortController);delete t.abortController,t.unloadVectorData(),t.aborted||t.loadVectorData(l,this.map.painter,n==="RT")}))}abortTile(t){return c._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.aborted=!0}))}unloadTile(t){return c._(this,void 0,void 0,(function*(){t.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:t.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 c.e({},this._options,{type:this.type,data:this._data.updateable?{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}:this._data.url||this._data.geojson})}hasTransition(){return!1}}class Br extends c.E{constructor(t,n,o,l){super(),this.flippedWindingOrder=!1,this.id=t,this.dispatcher=o,this.coordinates=n.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(l),this.options=n}load(t){return c._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new c.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const n=yield Ni.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,n&&n.data&&(this.image=n.data,t&&(this.coordinates=t),this._finishLoading())}catch(n){this._request=null,this._loaded=!0,c.Z(n)||this.fire(new c.k(n))}}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=t.url,this.load(t.coordinates).finally((()=>{this.texture=null})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new c.l("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(t){this.coordinates=t;const n=t.map(c.a9.fromLngLat);var o;return this.tileID=(function(l){const p=c.aa.fromPoints(l),m=p.width(),_=p.height(),v=Math.max(m,_),w=Math.max(0,Math.floor(-Math.log(v)/Math.LN2)),T=Math.pow(2,w);return new c.ac(w,Math.floor((p.minX+p.maxX)/2*T),Math.floor((p.minY+p.maxY)/2*T))})(n),this.terrainTileRanges=this._getOverlappingTileRanges(n),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=n.map((l=>this.tileID.getTilePoint(l)._round())),this.flippedWindingOrder=((o=this.tileCoords)[1].x-o[0].x)*(o[2].y-o[0].y)-(o[1].y-o[0].y)*(o[2].x-o[0].x)<0,this.fire(new c.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const t=this.map.painter.context,n=t.gl;this.texture||(this.texture=new c.T(t,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let o=!1;for(const l in this.tiles){const p=this.tiles[l];p.state!=="loaded"&&(p.state="loaded",p.texture=this.texture,o=!0)}o&&this.fire(new c.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(t){return c._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={}):t.state="errored"}))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(t){const{minX:n,minY:o,maxX:l,maxY:p}=c.aa.fromPoints(t),m={};for(let _=0;_<=c.ab;_++){const v=Math.pow(2,_),w=Math.floor(n*v),T=Math.floor(o*v),C=Math.floor(l*v),M=Math.floor(p*v),z=(w%v+v)%v,R=C%v,N=Math.floor(w/v),U=Math.floor(C/v);m[_]={minWrap:N,maxWrap:U,minTileXWrapped:z,maxTileXWrapped:R,minTileY:T,maxTileY:M}}return m}}class cn extends Br{constructor(t,n,o,l){super(t,n,o,l),this.roundZoom=!0,this.type="video",this.options=n}load(){return c._(this,void 0,void 0,(function*(){this._loaded=!1;const t=this.options;this.urls=[];for(const n of t.urls)this.urls.push(this.map._requestManager.transformRequest(n,"Source").url);try{const n=yield c.ad(this.urls);if(this._loaded=!0,!n)return;this.video=n,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading()}catch(n){this.fire(new c.k(n))}}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const n=this.video.seekable;t<n.start(0)||t>n.end(0)?this.fire(new c.k(new c.ae(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const t=this.map.painter.context,n=t.gl;this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new c.T(t,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let o=!1;for(const l in this.tiles){const p=this.tiles[l];p.state!=="loaded"&&(p.state="loaded",p.texture=this.texture,o=!0)}o&&this.fire(new c.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 ts extends Br{constructor(t,n,o,l){super(t,n,o,l),n.coordinates?Array.isArray(n.coordinates)&&n.coordinates.length===4&&!n.coordinates.some((p=>!Array.isArray(p)||p.length!==2||p.some((m=>typeof m!="number"))))||this.fire(new c.k(new c.ae(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new c.k(new c.ae(`sources.${t}`,null,'missing required property "coordinates"'))),n.animate&&typeof n.animate!="boolean"&&this.fire(new c.k(new c.ae(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),n.canvas?typeof n.canvas=="string"||n.canvas instanceof HTMLCanvasElement||this.fire(new c.k(new c.ae(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new c.k(new c.ae(`sources.${t}`,null,'missing required property "canvas"'))),this.options=n,this.animate=n.animate===void 0||n.animate}load(){return c._(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 c.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(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const n=this.map.painter.context,o=n.gl;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new c.T(n,this.canvas,o.RGBA,{premultiply:!0}),this.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE));let l=!1;for(const p in this.tiles){const m=this.tiles[p];m.state!=="loaded"&&(m.state="loaded",m.texture=this.texture,l=!0)}l&&this.fire(new c.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 t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}}const Rs={},is=d=>{switch(d){case"geojson":return Fr;case"image":return Br;case"raster":return Pn;case"raster-dem":return an;case"vector":return es;case"video":return cn;case"canvas":return ts}return Rs[d]},ie="RTLPluginLoaded";class E extends c.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=Tn()}_syncState(t){return this.status=t,this.dispatcher.broadcast("SRPS",{pluginStatus:t,pluginURL:this.url}).catch((n=>{throw this.status="error",n}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(t){return c._(this,arguments,void 0,(function*(n,o=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=$t.resolveURL(n),!this.url)throw new Error(`requested url ${n} is invalid`);if(this.status==="unavailable"){if(!o)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if(this.status==="requested")return this._requestImport()}))}_requestImport(){return c._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new c.l(ie))}))}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}}let k=null;function F(){return k||(k=new E),k}var $,J;(function(d){d[d.Base=0]="Base",d[d.Parent=1]="Parent"})($||($={})),(function(d){d[d.Departing=0]="Departing",d[d.Incoming=1]="Incoming"})(J||(J={}));class oe{constructor(t,n){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=t,this.uid=c.af(),this.uses=0,this.tileSize=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttFingerprint={},this.expiredRequestCount=0,this.state="loading"}isRenderable(t){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(t||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:t,fadingDirection:n,fadingParentID:o,fadeEndTime:l}){this.resetFadeLogic(),this.fadingRole=t,this.fadingDirection=n,this.fadingParentID=o,this.fadeEndTime=l}setSelfFadeLogic(t){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=t}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=He(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}clearTextures(t){this.demTexture&&t.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(t,n,o){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestFeatureIndex.rawTileData=t.rawTileData,this.latestFeatureIndex.encoding=t.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=(function(l,p){const m={};if(!p)return m;for(const _ of l){const v=_.layerIds.map((w=>p.getLayer(w))).filter(Boolean);if(v.length!==0){_.layers=v,_.stateDependentLayerIds&&(_.stateDependentLayers=_.stateDependentLayerIds.map((w=>v.filter((T=>T.id===w))[0])));for(const w of v)m[w.id]=_}}return m})(t.buckets,n?.style),this.hasSymbolBuckets=!1;for(const l in this.buckets){const p=this.buckets[l];if(p instanceof c.ah){if(this.hasSymbolBuckets=!0,!o)break;p.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const l in this.buckets){const p=this.buckets[l];if(p instanceof c.ah&&p.hasRTLText){this.hasRTLText=!0,F().lazyLoad();break}}this.queryPadding=0;for(const l in this.buckets){const p=this.buckets[l];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(l).queryRadius(p))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),this.dashPositions=t.dashPositions}else this.collisionBoxArray=new c.ag}unloadVectorData(){for(const t in this.buckets)this.buckets[t].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(t){return this.buckets[t.id]}upload(t){for(const o in this.buckets){const l=this.buckets[o];l.uploadPending()&&l.upload(t)}const n=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new c.T(t,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new c.T(t,this.glyphAtlasImage,n.ALPHA),this.glyphAtlasImage=null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,n,o,l,p,m,_,v,w,T,C){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:l,cameraQueryGeometry:p,scale:m,tileSize:this.tileSize,pixelPosMatrix:T,transform:v,params:_,queryPadding:this.queryPadding*w,getElevation:C},t,n,o):{}}querySourceFeatures(t,n){const o=this.latestFeatureIndex;if(!o||!o.rawTileData)return;const l=o.loadVTLayers(),p=n&&n.sourceLayer?n.sourceLayer:"",m=l[c.ai]||l[p];if(!m)return;const _=c.aj(n?.filter,n?.globalState),{z:v,x:w,y:T}=this.tileID.canonical,C={z:v,x:w,y:T};for(let M=0;M<m.length;M++){const z=m.feature(M);if(_.needGeometry){const U=c.ak(z,!0);if(!_.filter(new c.H(this.tileID.overscaledZ),U,this.tileID.canonical))continue}else if(!_.filter(new c.H(this.tileID.overscaledZ),z))continue;const R=o.getId(z,p),N=new c.al(z,v,w,T,R);N.tile=C,t.push(N)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const n=this.expirationTime;if(t.cacheControl){const o=c.am(t.cacheControl);o["max-age"]&&(this.expirationTime=Date.now()+1e3*o["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const o=Date.now();let l=!1;if(this.expirationTime>o)l=!1;else if(n)if(this.expirationTime<n)l=!0;else{const p=this.expirationTime-n;p?this.expirationTime=o+Math.max(p,3e4):l=!0}else l=!0;l?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),Math.pow(2,31)-1)}setFeatureState(t,n){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||Object.keys(t).length===0)return;const o=this.latestFeatureIndex.loadVTLayers();for(const l in this.buckets){if(!n.style.hasLayer(l))continue;const p=this.buckets[l],m=p.layers[0].sourceLayer||c.ai,_=o[m],v=t[m];if(!_||!v||Object.keys(v).length===0)continue;p.update(v,_,this.imageAtlas&&this.imageAtlas.patternPositions||{},this.dashPositions||{});const w=n&&n.style&&n.style.getLayer(l);w&&(this.queryPadding=Math.max(this.queryPadding,w.queryRadius(p)))}}holdingForSymbolFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<He()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(t){this.symbolFadeHoldUntil=He()+t}setDependencies(t,n){const o={};for(const l of n)o[l]=!0;this.dependencies[t]=o}hasDependency(t,n){for(const o of t){const l=this.dependencies[o];if(l){for(const p of n)if(l[p])return!0}}return!1}}class le{constructor(){this.state={},this.stateChanges={},this.deletedStates={},this.revision=0}updateState(t,n,o){const l=String(n);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][l]=this.stateChanges[t][l]||{},c.e(this.stateChanges[t][l],o),this.deletedStates[t]===null){this.deletedStates[t]={};for(const p in this.state[t])p!==l&&(this.deletedStates[t][p]=null)}else if(this.deletedStates[t]&&this.deletedStates[t][l]===null){this.deletedStates[t][l]={};for(const p in this.state[t][l])o[p]||(this.deletedStates[t][l][p]=null)}else for(const p in o)this.deletedStates[t]&&this.deletedStates[t][l]&&this.deletedStates[t][l][p]===null&&delete this.deletedStates[t][l][p]}removeFeatureState(t,n,o){if(this.deletedStates[t]===null)return;const l=String(n);if(this.deletedStates[t]=this.deletedStates[t]||{},o&&n!==void 0)this.deletedStates[t][l]!==null&&(this.deletedStates[t][l]=this.deletedStates[t][l]||{},this.deletedStates[t][l][o]=null);else if(n!==void 0)if(this.stateChanges[t]&&this.stateChanges[t][l])for(o in this.deletedStates[t][l]={},this.stateChanges[t][l])this.deletedStates[t][l][o]=null;else this.deletedStates[t][l]=null;else this.deletedStates[t]=null}getState(t,n){const o=String(n),l=c.e({},(this.state[t]||{})[o],(this.stateChanges[t]||{})[o]);if(this.deletedStates[t]===null)return{};if(this.deletedStates[t]){const p=this.deletedStates[t][n];if(p===null)return{};for(const m in p)delete l[m]}return l}initializeTileState(t,n){t.setFeatureState(this.state,n)}coalesceChanges(t,n){const o={};for(const l in this.stateChanges){this.state[l]=this.state[l]||{};const p={};for(const m in this.stateChanges[l])this.state[l][m]||(this.state[l][m]={}),c.e(this.state[l][m],this.stateChanges[l][m]),p[m]=this.state[l][m];o[l]=p}for(const l in this.deletedStates){this.state[l]=this.state[l]||{};const p={};if(this.deletedStates[l]===null)for(const m in this.state[l])p[m]={},this.state[l][m]={};else for(const m in this.deletedStates[l]){if(this.deletedStates[l][m]===null)this.state[l][m]={};else for(const _ of Object.keys(this.deletedStates[l][m]))delete this.state[l][m][_];p[m]=this.state[l][m]}o[l]=o[l]||{},c.e(o[l],p)}this.stateChanges={},this.deletedStates={},Object.keys(o).length!==0&&(this.revision++,t.setFeatureState(o,n))}}const ne=89.25;function se(d,t){const n=c.an(t.lat,-c.ao,c.ao);return new c.P(c.Y(t.lng)*d,c.X(n)*d)}function be(d,t){return new c.a9(t.x/d,t.y/d).toLngLat()}function me(d){return d.cameraToCenterDistance*Math.min(.85*Math.tan(c.ap(90-d.pitch)),Math.tan(c.ap(ne-d.pitch)))}function K(d,t){const n=d.canonical,o=t/c.aq(n.z),l=n.x+Math.pow(2,n.z)*d.wrap,p=c.ar(new Float64Array(16));return c.O(p,p,[l*o,n.y*o,0]),c.Q(p,p,[o/c.a5,o/c.a5,1]),p}function Oe(d,t,n,o,l){const p=c.a9.fromLngLat(d,t),m=l*c.as(1,d.lat),{x:_,y:v,z:w}=We(n,o);return new c.a9(p.x+m*-_,p.y+m*-v,p.z+m*-w)}function We(d,t){const n=c.ap(d),o=c.ap(t),l=Math.cos(-n),p=Math.sin(n);return{x:p*Math.sin(o),y:-p*Math.cos(o),z:l}}function Ue(d,t,n){const o=t.intersectsFrustum(d);if(!n||o===0)return o;const l=t.intersectsPlane(n);return l===0?0:o===2&&l===2?2:1}function Ze(d,t,n){let o=0;const l=(n-t)/10;for(let p=0;p<10;p++)o+=l*Math.pow(Math.cos(t+(p+.5)/10*(n-t)),d);return o}function qe(d,t){return function(n,o,l,p,m){const _=2*((d-1)/c.at(Math.cos(c.ap(ne-m))/Math.cos(c.ap(ne)))-1),v=Math.acos(l/p),w=2*Ze(_-1,0,c.ap(m/2)),T=Math.min(c.ap(ne),v+c.ap(m/2)),C=Ze(_-1,Math.min(T,v-c.ap(m/2)),T),M=Math.atan(o/l),z=Math.hypot(o,l);let R=n;return R+=c.at(p/z/Math.max(.5,Math.cos(c.ap(m/2)))),R+=_*c.at(Math.cos(M))/2,R-=c.at(Math.max(1,C/w/t))/2,R}}const et=qe(9.314,3);function Nt(d,t){const n=(t.roundZoom?Math.round:Math.floor)(d.zoom+c.at(d.tileSize/t.tileSize));return Math.max(0,n)}function wt(d,t){const n=d.getCameraFrustum(),o=d.getClippingPlane(),l=d.screenPointToMercatorCoordinate(d.getCameraPoint()),p=c.a9.fromLngLat(d.center,d.elevation);l.z=p.z+Math.cos(d.pitchInRadians)*d.cameraToCenterDistance/d.worldSize;const m=d.getCoveringTilesDetailsProvider(),_=m.allowVariableZoom(d,t),v=Nt(d,t),w=t.minzoom||0,T=t.maxzoom!==void 0?t.maxzoom:d.maxZoom,C=Math.min(Math.max(0,v),T),M=Math.pow(2,C),z=[M*l.x,M*l.y,0],R=[M*p.x,M*p.y,0],N=Math.hypot(p.x-l.x,p.y-l.y),U=Math.abs(p.z-l.z),j=Math.hypot(N,U),Z=Y=>({zoom:0,x:0,y:0,wrap:Y,fullyVisible:!1}),X=[],q=[];if(d.renderWorldCopies&&m.allowWorldCopies())for(let Y=1;Y<=3;Y++)X.push(Z(-Y)),X.push(Z(Y));for(X.push(Z(0));X.length>0;){const Y=X.pop(),Q=Y.x,H=Y.y;let te=Y.fullyVisible;const de={x:Q,y:H,z:Y.zoom},ue=m.getTileBoundingVolume(de,Y.wrap,d.elevation,t);if(!te){const Ie=Ue(n,ue,o);if(Ie===0)continue;te=Ie===2}const ce=m.distanceToTile2d(l.x,l.y,de,ue);let he=v;_&&(he=(t.calculateTileZoom||et)(d.zoom+c.at(d.tileSize/t.tileSize),ce,U,j,d.fov)),he=(t.roundZoom?Math.round:Math.floor)(he),he=Math.max(0,he);const Ce=Math.min(he,T);if(Y.wrap=m.getWrap(p,de,Y.wrap),Y.zoom>=Ce){if(Y.zoom<w)continue;const Ie=C-Y.zoom,ge=z[0]-.5-(Q<<Ie),Re=z[1]-.5-(H<<Ie),Je=t.reparseOverscaled?Math.max(Y.zoom,he):Y.zoom;q.push({tileID:new c.a2(Y.zoom===T?Je:Y.zoom,Y.wrap,Y.zoom,Q,H),distanceSq:c.au([R[0]-.5-Q,R[1]-.5-H]),tileDistanceToCamera:Math.sqrt(ge*ge+Re*Re)})}else for(let Ie=0;Ie<4;Ie++)X.push({zoom:Y.zoom+1,x:(Q<<1)+Ie%2,y:(H<<1)+(Ie>>1),wrap:Y.wrap,fullyVisible:te})}return q.sort(((Y,Q)=>Y.distanceSq-Q.distanceSq)).map((Y=>Y.tileID))}const jt=c.aa.fromPoints([new c.P(0,0),new c.P(c.a5,c.a5)]);function ci(d){return d==="raster"||d==="image"||d==="video"}function Rt(d,t,n,o,l,p,m){if(!t.hasData())return!1;const{tileID:_,fadingRole:v,fadingDirection:w,fadingParentID:T}=t;if(v===$.Base&&w===J.Incoming&&T)return n[T.key]=T,!0;const C=Math.max(_.overscaledZ-l,p);for(let M=_.overscaledZ-1;M>=C;M--){const z=_.scaledTo(M),R=d.getLoadedTile(z);if(R)return t.setCrossFadeLogic({fadingRole:$.Base,fadingDirection:J.Incoming,fadingParentID:R.tileID,fadeEndTime:o+m}),R.setCrossFadeLogic({fadingRole:$.Parent,fadingDirection:J.Departing,fadeEndTime:o+m}),n[z.key]=z,!0}return!1}function Pe(d,t,n,o,l,p){if(!t.hasData())return!1;const m=t.tileID.children(l);let _=ut(d,t,m,n,o,l,p);if(_)return!0;for(const v of m)ut(d,t,v.children(l),n,o,l,p)&&(_=!0);return _}function ut(d,t,n,o,l,p,m){if(n[0].overscaledZ>=p)return!1;let _=!1;for(const v of n){const w=d.getLoadedTile(v);if(!w)continue;const{fadingRole:T,fadingDirection:C,fadingParentID:M}=w;T===$.Base&&C===J.Departing&&M||(w.setCrossFadeLogic({fadingRole:$.Base,fadingDirection:J.Departing,fadingParentID:t.tileID,fadeEndTime:l+m}),t.setCrossFadeLogic({fadingRole:$.Parent,fadingDirection:J.Incoming,fadeEndTime:l+m})),o[v.key]=v,_=!0}return _}function Ct(d,t,n,o){const l=d.tileID;return!!d.selfFading||!d.hasData()&&!!t.has(l)&&(d.setSelfFadeLogic(n+o),!0)}function Cn(d,t){var n;d.needsHillshadePrepare=!0,d.needsTerrainPrepare=!0;let o=t.tileID.canonical.x-d.tileID.canonical.x;const l=t.tileID.canonical.y-d.tileID.canonical.y,p=Math.pow(2,d.tileID.canonical.z),m=t.tileID.key;o===0&&l===0||Math.abs(l)>1||(Math.abs(o)>1&&(Math.abs(o+p)===1?o+=p:Math.abs(o-p)===1&&(o-=p)),t.dem&&d.dem&&(d.dem.backfillBorder(t.dem,o,l),!((n=d.neighboringTiles)===null||n===void 0)&&n[m]&&(d.neighboringTiles[m].backfilled=!0)))}class Or{constructor(){this._tiles={}}handleWrapJump(t){const n={};for(const o in this._tiles){const l=this._tiles[o];l.tileID=l.tileID.unwrapTo(l.tileID.wrap+t),n[l.tileID.key]=l}this._tiles=n}setFeatureState(t,n){for(const o in this._tiles)this._tiles[o].setFeatureState(t,n)}getAllTiles(){return Object.values(this._tiles)}getAllIds(t=!1){return t?Object.values(this._tiles).map((n=>n.tileID)).sort(c.aw).map((n=>n.key)):Object.keys(this._tiles)}getTileById(t){return this._tiles[t]}setTile(t,n){this._tiles[t]=n}deleteTileById(t){delete this._tiles[t]}getLoadedTile(t){const n=this.getTileById(t.key);return n?.hasData()?n:null}isIdRenderable(t,n=!1){var o;return(o=this.getTileById(t))===null||o===void 0?void 0:o.isRenderable(n)}getRenderableIds(t=0,n){const o=[];for(const l of this.getAllIds())this.isIdRenderable(l,n)&&o.push(this.getTileById(l));return n?o.sort(((l,p)=>{const m=l.tileID,_=p.tileID,v=new c.P(m.canonical.x,m.canonical.y)._rotate(-t),w=new c.P(_.canonical.x,_.canonical.y)._rotate(-t);return m.overscaledZ-_.overscaledZ||w.y-v.y||w.x-v.x})).map((l=>l.tileID.key)):o.map((l=>l.tileID)).sort(c.aw).map((l=>l.key))}}class Me extends c.E{constructor(t,n,o){super(),this.id=t,this.dispatcher=o,this.on("data",(l=>this._dataHandler(l))),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=((l,p,m,_)=>{const v=new(is(p.type))(l,p,m,_);if(v.id!==l)throw new Error(`Expected Source id to be ${l} instead of ${v.id}`);return v})(t,n,o,this),this._inViewTiles=new Or,this._outOfViewCache=new c.ax(0,(l=>this._unloadTile(l))),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new le,this._didEmitContent=!1,this._updated=!1}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(t)}onRemove(t){for(const n of this._inViewTiles.getAllTiles())n.unloadVectorData();this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(t),this._inViewTiles=new Or}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if(!(this.used===void 0&&this.usedForTerrain===void 0||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const t of this._inViewTiles.getAllTiles())if(t.state!=="loaded"&&t.state!=="errored")return!1;return!0}getSource(){return this._source}getState(){return this._state}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(t,n,o){return c._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(t),this._tileLoaded(t,n,o)}catch(l){t.state="errored",l.status!==404?this._source.fire(new c.k(l,{tile:t})):this.update(this.transform,this.terrain)}}))}_unloadTile(t){this._source.unloadTile&&this._source.unloadTile(t)}_abortTile(t){this._source.abortTile&&this._source.abortTile(t),this._source.fire(new c.l("dataabort",{tile:t,coord:t.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.map?this.map.painter:null);for(const n of this._inViewTiles.getAllTiles())n.upload(t),n.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(t){var n;return this._inViewTiles.getRenderableIds((n=this.transform)===null||n===void 0?void 0:n.bearingInRadians,t)}hasRenderableParent(t){const n=t.overscaledZ-1;if(n>=this._source.minzoom){const o=this.getLoadedTile(t.scaledTo(n));if(o)return this._inViewTiles.isIdRenderable(o.tileID.key)}return!1}reload(t,n=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._outOfViewCache.reset();for(const o of this._inViewTiles.getAllIds()){const l=this._inViewTiles.getTileById(o);n&&!this._source.shouldReloadTile(l,n)||(t?this._reloadTile(o,"expired"):l.state!=="errored"&&this._reloadTile(o,"reloading"))}}}_reloadTile(t,n){return c._(this,void 0,void 0,(function*(){const o=this._inViewTiles.getTileById(t);o&&(o.state!=="loading"&&(o.state=n),yield this._loadTile(o,t,n))}))}_tileLoaded(t,n,o){t.timeAdded=He(),t.selfFading&&(t.fadeEndTime=t.timeAdded+this._rasterFadeDuration),o==="expired"&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(n,t),this.getSource().type==="raster-dem"&&t.dem&&(function(l,p){var m,_;const v=p.getRenderableIds();for(const w of v){if(!l.neighboringTiles||!l.neighboringTiles[w])continue;const T=p.getTileById(w);l.neighboringTiles[w].backfilled||Cn(l,T),!((_=(m=T.neighboringTiles)===null||m===void 0?void 0:m[l.tileID.key])===null||_===void 0)&&_.backfilled||Cn(T,l)}})(t,this._inViewTiles),this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new c.l("data",{dataType:"source",tile:t,coord:t.tileID}))}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._inViewTiles.getTileById(t)}_retainLoadedChildren(t,n){const o=this._getLoadedDescendents(n),l=new Set;for(const p of n){const m=o[p.key];if(!m?.length){l.add(p);continue}const _=p.overscaledZ+Me.maxOverzooming,v=m.filter((C=>C.tileID.overscaledZ<=_));if(!v.length){l.add(p);continue}const w=Math.min(...v.map((C=>C.tileID.overscaledZ))),T=v.filter((C=>C.tileID.overscaledZ===w)).map((C=>C.tileID));for(const C of T)t[C.key]=C;this._areDescendentsComplete(T,w,p.overscaledZ)||l.add(p)}return l}_getLoadedDescendents(t){var n;const o={};for(const l of this._inViewTiles.getAllTiles().filter((p=>p.hasData())))for(const p of t)l.tileID.isChildOf(p)&&(o[n=p.key]||(o[n]=[])).push(l);return o}_areDescendentsComplete(t,n,o){return t.length===1&&t[0].isOverscaled()?t[0].overscaledZ===n:Math.pow(4,n-o)===t.length}getLoadedTile(t){return this._inViewTiles.getLoadedTile(t)}updateCacheSize(t){const n=Math.ceil(t.width/this._source.tileSize)+1,o=Math.ceil(t.height/this._source.tileSize)+1,l=Math.floor(n*o*(this._maxTileCacheZoomLevels===null?c.c.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),p=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,l):l;this._outOfViewCache.setMaxSize(p)}handleWrapJump(t){const n=Math.round((t-(this._prevLng===void 0?t:this._prevLng))/360);this._prevLng=t,n&&(this._inViewTiles.handleWrapJump(n),this._resetTileReloadTimers())}update(t,n){if(!this._sourceLoaded||this._paused)return;let o;this.transform=t,this.terrain=n,this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?o=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((v=>new c.a2(v.canonical.z,v.wrap,v.canonical.z,v.canonical.x,v.canonical.y))):(o=wt(t,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.type==="vector"&&this.map._zoomLevelsToOverscale!==void 0?t.maxZoom-this.map._zoomLevelsToOverscale:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:n,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(o=o.filter((v=>this._source.hasTile(v))))):o=[],this.usedForTerrain&&(o=this._addTerrainIdealTiles(o));const l=o.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,l&&this.fire(new c.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const p=Nt(t,this._source),m=this._updateRetainedTiles(o,p),_=ci(this._source.type);_&&this._rasterFadeDuration>0&&!n&&(function(v,w,T,C,M,z,R){const N=He(),U=c.av(w);for(const j of w){const Z=v.getTileById(j.key);Z.fadingDirection!==J.Departing&&Z.fadeOpacity!==0||Z.resetFadeLogic(),Rt(v,Z,T,N,C,M,R)||Pe(v,Z,T,N,z,R)||Ct(Z,U,N,R)||Z.resetFadeLogic()}})(this._inViewTiles,o,m,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),_?this._cleanUpRasterTiles(m):this._cleanUpVectorTiles(m)}_cleanUpRasterTiles(t){for(const n of this._inViewTiles.getAllIds())t[n]||this._removeTile(n)}_cleanUpVectorTiles(t){for(const n of this._inViewTiles.getAllIds()){const o=this._inViewTiles.getTileById(n);t[n]?o.clearSymbolFadeHold():o.hasSymbolBuckets?o.holdingForSymbolFade()?o.symbolFadeFinished()&&this._removeTile(n):o.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(n)}}_addTerrainIdealTiles(t){const n=[];for(const o of t)if(o.canonical.z>this._source.minzoom){const l=o.scaledTo(o.canonical.z-1);n.push(l);const p=o.scaledTo(Math.max(this._source.minzoom,Math.min(o.canonical.z,5)));n.push(p)}return t.concat(n)}releaseSymbolFadeTiles(){for(const t of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(t).holdingForSymbolFade()&&this._removeTile(t)}_updateRetainedTiles(t,n){var o;const l=new Set;for(const w of t)this._addTile(w).hasData()||l.add(w);const p=t.reduce(((w,T)=>(w[T.key]=T,w)),{}),m=this._retainLoadedChildren(p,l),_={},v=Math.max(n-Me.maxUnderzooming,this._source.minzoom);for(const w of m){let T=this._inViewTiles.getTileById(w.key),C=T?.wasRequested();for(let M=w.overscaledZ-1;M>=v;--M){const z=w.scaledTo(M);if(_[z.key])break;if(_[z.key]=!0,T=this.getTile(z),!T&&C&&(T=this._addTile(z)),T){const R=T.hasData();if((R||!(!((o=this.map)===null||o===void 0)&&o.cancelPendingTileRequestsWhileZooming)||C)&&(p[z.key]=z),C=T.wasRequested(),R)break}}}return p}_addTile(t){let n=this._inViewTiles.getTileById(t.key);if(n)return n;n=this._outOfViewCache.getAndRemove(t),n&&(n.resetFadeLogic(),this._setTileReloadTimer(t.key,n),n.tileID=t,this._state.initializeTileState(n,this.map?this.map.painter:null));const o=n;return n||(n=new oe(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(n,t.key,n.state)),n.uses++,this._inViewTiles.setTile(t.key,n),o||this._source.fire(new c.l("dataloading",{tile:n,coord:n.tileID,dataType:"source"})),n}_setTileReloadTimer(t,n){this._clearTileReloadTimer(t);const o=n.getExpiryTimeout();o&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),o))}_clearTileReloadTimer(t){const n=this._timers[t];n&&(clearTimeout(n),delete this._timers[t])}_resetTileReloadTimers(){for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t of this._inViewTiles.getAllIds()){const n=this._inViewTiles.getTileById(t);this._setTileReloadTimer(t,n)}}refreshTiles(t){for(const n of this._inViewTiles.getAllIds()){const o=this._inViewTiles.getTileById(n);(this._inViewTiles.isIdRenderable(n)||o.state=="errored")&&t.some((l=>l.equals(o.tileID.canonical)))&&this._reloadTile(n,"expired")}}_removeTile(t){const n=this._inViewTiles.getTileById(t);n&&(n.uses--,this._inViewTiles.deleteTileById(t),this._clearTileReloadTimer(t),n.uses>0||(n.hasData()&&n.state!=="reloading"?this._outOfViewCache.add(n.tileID,n,n.getExpiryTimeout()):(n.aborted=!0,this._abortTile(n),this._unloadTile(n))))}_dataHandler(t){t.dataType==="source"&&(t.sourceDataType!=="metadata"?t.sourceDataType==="content"&&this._sourceLoaded&&!this._paused&&(this.reload(t.sourceDataChanged,t.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0):this._sourceLoaded=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t of this._inViewTiles.getAllIds())this._removeTile(t);this._outOfViewCache.reset()}tilesIn(t,n,o){const l=[],p=this.transform;if(!p)return l;const m=p.getCoveringTilesDetailsProvider().allowWorldCopies(),_=o?p.getCameraQueryGeometry(t):t,v=z=>p.screenPointToMercatorCoordinate(z,this.terrain),w=this.transformBbox(t,v,!m),T=this.transformBbox(_,v,!m),C=this.getIds(),M=c.aa.fromPoints(T);for(let z=0;z<C.length;z++){const R=this._inViewTiles.getTileById(C[z]);if(R.holdingForSymbolFade())continue;const N=m?[R.tileID]:[R.tileID.unwrapTo(-1),R.tileID.unwrapTo(0)],U=Math.pow(2,p.zoom-R.tileID.overscaledZ),j=n*R.queryPadding*c.a5/R.tileSize/U;for(const Z of N){const X=M.map((q=>Z.getTilePoint(new c.a9(q.x,q.y))));if(X.expandBy(j),X.intersects(jt)){const q=w.map((Q=>Z.getTilePoint(Q))),Y=T.map((Q=>Z.getTilePoint(Q)));l.push({tile:R,tileID:m?Z:Z.unwrapTo(0),queryGeometry:q,cameraQueryGeometry:Y,scale:U})}}}return l}transformBbox(t,n,o){let l=t.map(n);if(o){const p=c.aa.fromPoints(t);p.shrinkBy(.001*Math.min(p.width(),p.height()));const m=p.map(n);c.aa.fromPoints(l).covers(m)||(l=l.map((_=>_.x>.5?new c.a9(_.x-1,_.y,_.z):_)))}return l}getVisibleCoordinates(t){const n=this.getRenderableIds(t).map((o=>this._inViewTiles.getTileById(o).tileID));return this.transform&&this.transform.populateCache(n),n}hasTransition(){return!!this._source.hasTransition()||!(!ci(this._source.type)||!(function(t,n){if(n<=0)return!1;const o=He();for(const l of t.getAllTiles())if(l.fadeEndTime>=o)return!0;return!1})(this._inViewTiles,this._rasterFadeDuration))}setRasterFadeDuration(t){this._rasterFadeDuration=t}setFeatureState(t,n,o){this._state.updateState(t=t||c.ai,n,o)}removeFeatureState(t,n,o){this._state.removeFeatureState(t=t||c.ai,n,o)}getFeatureState(t,n){return this._state.getState(t=t||c.ai,n)}setDependencies(t,n,o){const l=this._inViewTiles.getTileById(t);l&&l.setDependencies(n,o)}reloadTilesForDependencies(t,n){for(const o of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(o).hasDependency(t,n)&&this._reloadTile(o,"reloading");this._outOfViewCache.filter((o=>!o.hasDependency(t,n)))}areTilesLoaded(){for(const t of this._inViewTiles.getAllTiles())if(t.state!=="loaded"&&t.state!=="errored")return!1;return!0}}Me.maxUnderzooming=10,Me.maxOverzooming=3;class Xe{constructor(t,n){this.reset(t,n)}reset(t,n){this.points=t||[],this._distances=[0];for(let o=1;o<this.points.length;o++)this._distances[o]=this._distances[o-1]+this.points[o].dist(this.points[o-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(n||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(this.points.length===1)return this.points[0];t=c.an(t,0,1);let n=1,o=this._distances[n];const l=t*this.paddedLength+this.padding;for(;o<l&&n<this._distances.length;)o=this._distances[++n];const p=n-1,m=this._distances[p],_=o-m,v=_>0?(l-m)/_:0;return this.points[p].mult(1-v).add(this.points[n].mult(v))}}function Ye(d,t){let n=!0;return d==="always"||d!=="never"&&t!=="never"||(n=!1),n}class rr{constructor(t,n,o){const l=this.boxCells=[],p=this.circleCells=[];this.xCellCount=Math.ceil(t/o),this.yCellCount=Math.ceil(n/o);for(let m=0;m<this.xCellCount*this.yCellCount;m++)l.push([]),p.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=t,this.height=n,this.xScale=this.xCellCount/t,this.yScale=this.yCellCount/n,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(t,n,o,l,p){this._forEachCell(n,o,l,p,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(n),this.bboxes.push(o),this.bboxes.push(l),this.bboxes.push(p)}insertCircle(t,n,o,l){this._forEachCell(n-l,o-l,n+l,o+l,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(n),this.circles.push(o),this.circles.push(l)}_insertBoxCell(t,n,o,l,p,m){this.boxCells[p].push(m)}_insertCircleCell(t,n,o,l,p,m){this.circleCells[p].push(m)}_query(t,n,o,l,p,m,_){if(o<0||t>this.width||l<0||n>this.height)return[];const v=[];if(t<=0&&n<=0&&this.width<=o&&this.height<=l){if(p)return[{key:null,x1:t,y1:n,x2:o,y2:l}];for(let w=0;w<this.boxKeys.length;w++)v.push({key:this.boxKeys[w],x1:this.bboxes[4*w],y1:this.bboxes[4*w+1],x2:this.bboxes[4*w+2],y2:this.bboxes[4*w+3]});for(let w=0;w<this.circleKeys.length;w++){const T=this.circles[3*w],C=this.circles[3*w+1],M=this.circles[3*w+2];v.push({key:this.circleKeys[w],x1:T-M,y1:C-M,x2:T+M,y2:C+M})}}else this._forEachCell(t,n,o,l,this._queryCell,v,{hitTest:p,overlapMode:m,seenUids:{box:{},circle:{}}},_);return v}query(t,n,o,l){return this._query(t,n,o,l,!1,null)}hitTest(t,n,o,l,p,m){return this._query(t,n,o,l,!0,p,m).length>0}hitTestCircle(t,n,o,l,p){const m=t-o,_=t+o,v=n-o,w=n+o;if(_<0||m>this.width||w<0||v>this.height)return!1;const T=[];return this._forEachCell(m,v,_,w,this._queryCellCircle,T,{hitTest:!0,overlapMode:l,circle:{x:t,y:n,radius:o},seenUids:{box:{},circle:{}}},p),T.length>0}_queryCell(t,n,o,l,p,m,_,v){const{seenUids:w,hitTest:T,overlapMode:C}=_,M=this.boxCells[p];if(M!==null){const R=this.bboxes;for(const N of M)if(!w.box[N]){w.box[N]=!0;const U=4*N,j=this.boxKeys[N];if(t<=R[U+2]&&n<=R[U+3]&&o>=R[U+0]&&l>=R[U+1]&&(!v||v(j))&&(!T||!Ye(C,j.overlapMode))&&(m.push({key:j,x1:R[U],y1:R[U+1],x2:R[U+2],y2:R[U+3]}),T))return!0}}const z=this.circleCells[p];if(z!==null){const R=this.circles;for(const N of z)if(!w.circle[N]){w.circle[N]=!0;const U=3*N,j=this.circleKeys[N];if(this._circleAndRectCollide(R[U],R[U+1],R[U+2],t,n,o,l)&&(!v||v(j))&&(!T||!Ye(C,j.overlapMode))){const Z=R[U],X=R[U+1],q=R[U+2];if(m.push({key:j,x1:Z-q,y1:X-q,x2:Z+q,y2:X+q}),T)return!0}}}return!1}_queryCellCircle(t,n,o,l,p,m,_,v){const{circle:w,seenUids:T,overlapMode:C}=_,M=this.boxCells[p];if(M!==null){const R=this.bboxes;for(const N of M)if(!T.box[N]){T.box[N]=!0;const U=4*N,j=this.boxKeys[N];if(this._circleAndRectCollide(w.x,w.y,w.radius,R[U+0],R[U+1],R[U+2],R[U+3])&&(!v||v(j))&&!Ye(C,j.overlapMode))return m.push(!0),!0}}const z=this.circleCells[p];if(z!==null){const R=this.circles;for(const N of z)if(!T.circle[N]){T.circle[N]=!0;const U=3*N,j=this.circleKeys[N];if(this._circlesCollide(R[U],R[U+1],R[U+2],w.x,w.y,w.radius)&&(!v||v(j))&&!Ye(C,j.overlapMode))return m.push(!0),!0}}}_forEachCell(t,n,o,l,p,m,_,v){const w=this._convertToXCellCoord(t),T=this._convertToYCellCoord(n),C=this._convertToXCellCoord(o),M=this._convertToYCellCoord(l);for(let z=w;z<=C;z++)for(let R=T;R<=M;R++)if(p.call(this,t,n,o,l,this.xCellCount*R+z,m,_,v))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,n,o,l,p,m){const _=l-t,v=p-n,w=o+m;return w*w>_*_+v*v}_circleAndRectCollide(t,n,o,l,p,m,_){const v=(m-l)/2,w=Math.abs(t-(l+v));if(w>v+o)return!1;const T=(_-p)/2,C=Math.abs(n-(p+T));if(C>T+o)return!1;if(w<=v||C<=T)return!0;const M=w-v,z=C-T;return M*M+z*z<=o*o}}function rs(d,t,n){const o=c.N();if(!d){const{vecSouth:C,vecEast:M}=tt(t),z=_t();z[0]=M[0],z[1]=M[1],z[2]=C[0],z[3]=C[1],l=z,(T=(m=(p=z)[0])*(w=p[3])-(v=p[2])*(_=p[1]))&&(l[0]=w*(T=1/T),l[1]=-_*T,l[2]=-v*T,l[3]=m*T),o[0]=z[0],o[1]=z[1],o[4]=z[2],o[5]=z[3]}var l,p,m,_,v,w,T;return c.Q(o,o,[1/n,1/n,1]),o}function In(d,t,n,o){if(d){const l=c.N();if(!t){const{vecSouth:p,vecEast:m}=tt(n);l[0]=m[0],l[1]=m[1],l[4]=p[0],l[5]=p[1]}return c.Q(l,l,[o,o,1]),l}return n.pixelsToClipSpaceMatrix}function tt(d){const t=Math.cos(d.rollInRadians),n=Math.sin(d.rollInRadians),o=Math.cos(d.pitchInRadians),l=Math.cos(d.bearingInRadians),p=Math.sin(d.bearingInRadians),m=c.aC();m[0]=-l*o*n-p*t,m[1]=-p*o*n+l*t;const _=c.aD(m);_<1e-9?c.aE(m):c.aF(m,m,1/_);const v=c.aC();v[0]=l*o*t-p*n,v[1]=p*o*t+l*n;const w=c.aD(v);return w<1e-9?c.aE(v):c.aF(v,v,1/w),{vecEast:v,vecSouth:m}}function ns(d,t,n,o){let l;o?(l=[d,t,o(d,t),1],c.aH(l,l,n)):(l=[d,t,0,1],dn(l,l,n));const p=l[3];return{point:new c.P(l[0]/p,l[1]/p),signedDistanceFromCamera:p,isOccluded:!1}}function ss(d,t){return .5+d/t*.5}function ko(d,t){return d.x>=-t[0]&&d.x<=t[0]&&d.y>=-t[1]&&d.y<=t[1]}function Fs(d,t,n,o,l,p,m,_,v,w,T,C,M){const z=n?d.textSizeData:d.iconSizeData,R=c.ay(z,t.transform.zoom),N=[256/t.width*2+1,256/t.height*2+1],U=n?d.text.dynamicLayoutVertexArray:d.icon.dynamicLayoutVertexArray;U.clear();const j=d.lineVertexArray,Z=n?d.text.placedSymbolArray:d.icon.placedSymbolArray,X=t.transform.width/t.transform.height;let q=!1;for(let Y=0;Y<Z.length;Y++){const Q=Z.get(Y);if(Q.hidden||Q.writingMode===c.az.vertical&&!q){An(Q.numGlyphs,U);continue}q=!1;const H=new c.P(Q.anchorX,Q.anchorY),te={getElevation:M,pitchedLabelPlaneMatrix:o,lineVertexArray:j,pitchWithMap:p,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:t.transform,tileAnchorPoint:H,unwrappedTileID:v,width:w,height:T,translation:C},de=Lo(Q.anchorX,Q.anchorY,te);if(!ko(de.point,N)){An(Q.numGlyphs,U);continue}const ue=ss(t.transform.cameraToCenterDistance,de.signedDistanceFromCamera),ce=c.aA(z,R,Q),he=p?ce*t.transform.getPitchedTextCorrection(Q.anchorX,Q.anchorY,v)/ue:ce*ue,Ce=Os({projectionContext:te,pitchedLabelPlaneMatrixInverse:l,symbol:Q,fontSize:he,flip:!1,keepUpright:m,glyphOffsetArray:d.glyphOffsetArray,dynamicLayoutVertexArray:U,aspectRatio:X,rotateToLine:_});q=Ce.useVertical,(Ce.notEnoughRoom||q||Ce.needsFlipping&&Os({projectionContext:te,pitchedLabelPlaneMatrixInverse:l,symbol:Q,fontSize:he,flip:!0,keepUpright:m,glyphOffsetArray:d.glyphOffsetArray,dynamicLayoutVertexArray:U,aspectRatio:X,rotateToLine:_}).notEnoughRoom)&&An(Q.numGlyphs,U)}n?d.text.dynamicLayoutVertexBuffer.updateData(U):d.icon.dynamicLayoutVertexBuffer.updateData(U)}function Bs(d,t,n,o,l,p,m,_){const v=p.glyphStartIndex+p.numGlyphs,w=p.lineStartIndex,T=p.lineStartIndex+p.lineLength,C=t.getoffsetX(p.glyphStartIndex),M=t.getoffsetX(v-1),z=Vs(d*C,n,o,l,p.segment,w,T,_,m);if(!z)return null;const R=Vs(d*M,n,o,l,p.segment,w,T,_,m);return R?_.projectionCache.anyProjectionOccluded?null:{first:z,last:R}:null}function os(d,t,n,o){return d===c.az.horizontal&&Math.abs(n.y-t.y)>Math.abs(n.x-t.x)*o?{useVertical:!0}:(d===c.az.vertical?t.y<n.y:t.x>n.x)?{needsFlipping:!0}:null}function Os(d){const{projectionContext:t,pitchedLabelPlaneMatrixInverse:n,symbol:o,fontSize:l,flip:p,keepUpright:m,glyphOffsetArray:_,dynamicLayoutVertexArray:v,aspectRatio:w,rotateToLine:T}=d,C=l/24,M=o.lineOffsetX*C,z=o.lineOffsetY*C;let R;if(o.numGlyphs>1){const N=o.glyphStartIndex+o.numGlyphs,U=o.lineStartIndex,j=o.lineStartIndex+o.lineLength,Z=Bs(C,_,M,z,p,o,T,t);if(!Z)return{notEnoughRoom:!0};const X=un(Z.first.point.x,Z.first.point.y,t,n),q=un(Z.last.point.x,Z.last.point.y,t,n);if(m&&!p){const Y=os(o.writingMode,X,q,w);if(Y)return Y}R=[Z.first];for(let Y=o.glyphStartIndex+1;Y<N-1;Y++){const Q=Vs(C*_.getoffsetX(Y),M,z,p,o.segment,U,j,t,T);if(!Q)return{notEnoughRoom:!0};R.push(Q)}R.push(Z.last)}else{if(m&&!p){const U=En(t.tileAnchorPoint.x,t.tileAnchorPoint.y,t).point,j=o.lineStartIndex+o.segment+1,Z=new c.P(t.lineVertexArray.getx(j),t.lineVertexArray.gety(j)),X=En(Z.x,Z.y,t),q=X.signedDistanceFromCamera>0?X.point:Li(t.tileAnchorPoint,Z,U,1,t),Y=un(U.x,U.y,t,n),Q=un(q.x,q.y,t,n),H=os(o.writingMode,Y,Q,w);if(H)return H}const N=Vs(C*_.getoffsetX(o.glyphStartIndex),M,z,p,o.segment,o.lineStartIndex,o.lineStartIndex+o.lineLength,t,T);if(!N||t.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};R=[N]}for(const N of R)c.aG(v,N.point,N.angle);return{}}function Li(d,t,n,o,l){const p=d.add(d.sub(t)._unit()),m=En(p.x,p.y,l).point,_=n.sub(m);return n.add(_._mult(o/_.mag()))}function St(d,t,n){const o=t.projectionCache;if(o.projections[d])return o.projections[d];const l=new c.P(t.lineVertexArray.getx(d),t.lineVertexArray.gety(d)),p=En(l.x,l.y,t);if(p.signedDistanceFromCamera>0)return o.projections[d]=p.point,o.anyProjectionOccluded=o.anyProjectionOccluded||p.isOccluded,p.point;const m=d-n.direction;return Li(n.distanceFromAnchor===0?t.tileAnchorPoint:new c.P(t.lineVertexArray.getx(m),t.lineVertexArray.gety(m)),l,n.previousVertex,n.absOffsetX-n.distanceFromAnchor+1,t)}function En(d,t,n){const o=d+n.translation[0],l=t+n.translation[1];let p;return n.pitchWithMap?(p=ns(o,l,n.pitchedLabelPlaneMatrix,n.getElevation),p.isOccluded=!1):(p=n.transform.projectTileCoordinates(o,l,n.unwrappedTileID,n.getElevation),p.point.x=(.5*p.point.x+.5)*n.width,p.point.y=(.5*-p.point.y+.5)*n.height),p}function un(d,t,n,o){if(n.pitchWithMap){const l=[d,t,0,1];return c.aH(l,l,o),n.transform.projectTileCoordinates(l[0]/l[3],l[1]/l[3],n.unwrappedTileID,n.getElevation).point}return{x:d/n.width*2-1,y:1-t/n.height*2}}function Lo(d,t,n){return n.transform.projectTileCoordinates(d,t,n.unwrappedTileID,n.getElevation)}function Vr(d,t,n){return d._unit()._perp()._mult(t*n)}function hn(d,t,n,o,l,p,m,_,v){if(_.projectionCache.offsets[d])return _.projectionCache.offsets[d];const w=n.add(t);if(d+v.direction<o||d+v.direction>=l)return _.projectionCache.offsets[d]=w,w;const T=St(d+v.direction,_,v),C=Vr(T.sub(n),m,v.direction),M=n.add(C),z=T.add(C);return _.projectionCache.offsets[d]=c.aI(p,w,M,z)||w,_.projectionCache.offsets[d]}function Vs(d,t,n,o,l,p,m,_,v){const w=o?d-t:d+t;let T=w>0?1:-1,C=0;o&&(T*=-1,C=Math.PI),T<0&&(C+=Math.PI);let M,z=T>0?p+l:p+l+1;_.projectionCache.cachedAnchorPoint?M=_.projectionCache.cachedAnchorPoint:(M=En(_.tileAnchorPoint.x,_.tileAnchorPoint.y,_).point,_.projectionCache.cachedAnchorPoint=M);let R,N,U=M,j=M,Z=0,X=0;const q=Math.abs(w),Y=[];let Q;for(;Z+X<=q;){if(z+=T,z<p||z>=m)return null;Z+=X,j=U,N=R;const de={absOffsetX:q,direction:T,distanceFromAnchor:Z,previousVertex:j};if(U=St(z,_,de),n===0)Y.push(j),Q=U.sub(j);else{let ue;const ce=U.sub(j);ue=ce.mag()===0?Vr(St(z+T,_,de).sub(U),n,T):Vr(ce,n,T),N||(N=j.add(ue)),R=hn(z,ue,U,p,m,N,n,_,de),Y.push(N),Q=R.sub(N)}X=Q.mag()}const H=Q._mult((q-Z)/X)._add(N||j),te=C+Math.atan2(U.y-j.y,U.x-j.x);return Y.push(H),{point:H,angle:v?te:0,path:Y}}const Kl=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function An(d,t){for(let n=0;n<d;n++){const o=t.length;t.resize(o+4),t.float32.set(Kl,3*o)}}function dn(d,t,n){const o=t[0],l=t[1];return d[0]=n[0]*o+n[4]*l+n[12],d[1]=n[1]*o+n[5]*l+n[13],d[3]=n[3]*o+n[7]*l+n[15],d}const ti=100;class zu{constructor(t,n=new rr(t.width+200,t.height+200,25),o=new rr(t.width+200,t.height+200,25)){this.transform=t,this.grid=n,this.ignoredGrid=o,this.pitchFactor=Math.cos(t.pitch*Math.PI/180)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+ti,this.screenBottomBoundary=t.height+ti,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(t,n,o,l,p,m,_,v,w,T,C,M){const z=this.projectAndGetPerspectiveRatio(t.anchorPointX+v[0],t.anchorPointY+v[1],p,T,M),R=o*z.perspectiveRatio;let N;if(m||_)N=this._projectCollisionBox(t,R,l,p,m,_,v,z,T,C,M);else{const Q=z.x+(C?C.x*R:0),H=z.y+(C?C.y*R:0);N={allPointsOccluded:!1,box:[Q+t.x1*R,H+t.y1*R,Q+t.x2*R,H+t.y2*R]}}const[U,j,Z,X]=N.box,q=m?N.allPointsOccluded:z.isOccluded;let Y=q;return Y||(Y=z.perspectiveRatio<this.perspectiveRatioCutoff),Y||(Y=!this.isInsideGrid(U,j,Z,X)),Y||n!=="always"&&this.grid.hitTest(U,j,Z,X,n,w)?{box:[U,j,Z,X],placeable:!1,offscreen:!1,occluded:q}:{box:[U,j,Z,X],placeable:!0,offscreen:this.isOffscreen(U,j,Z,X),occluded:q}}placeCollisionCircles(t,n,o,l,p,m,_,v,w,T,C,M,z,R){const N=[],U=new c.P(n.anchorX,n.anchorY),j=this.getPerspectiveRatio(U.x,U.y,m,R),Z=(w?p*this.transform.getPitchedTextCorrection(n.anchorX,n.anchorY,m)/j:p*j)/c.aM,X={getElevation:R,pitchedLabelPlaneMatrix:_,lineVertexArray:o,pitchWithMap:w,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:U,unwrappedTileID:m,width:this.transform.width,height:this.transform.height,translation:z},q=Bs(Z,l,n.lineOffsetX*Z,n.lineOffsetY*Z,!1,n,!1,X);let Y=!1,Q=!1,H=!0;if(q){const te=.5*C*j+M,de=new c.P(-100,-100),ue=new c.P(this.screenRightBoundary,this.screenBottomBoundary),ce=new Xe,he=q.first,Ce=q.last;let Ie=[];for(let Je=he.path.length-1;Je>=1;Je--)Ie.push(he.path[Je]);for(let Je=1;Je<Ce.path.length;Je++)Ie.push(Ce.path[Je]);const ge=2.5*te;if(w){const Je=this.projectPathToScreenSpace(Ie,X);Ie=Je.some((dt=>dt.signedDistanceFromCamera<=0))?[]:Je.map((dt=>dt.point))}let Re=[];if(Ie.length>0){const Je=Ie[0].clone(),dt=Ie[0].clone();for(let Tt=1;Tt<Ie.length;Tt++)Je.x=Math.min(Je.x,Ie[Tt].x),Je.y=Math.min(Je.y,Ie[Tt].y),dt.x=Math.max(dt.x,Ie[Tt].x),dt.y=Math.max(dt.y,Ie[Tt].y);Re=Je.x>=de.x&&dt.x<=ue.x&&Je.y>=de.y&&dt.y<=ue.y?[Ie]:dt.x<de.x||Je.x>ue.x||dt.y<de.y||Je.y>ue.y?[]:c.aJ([Ie],de.x,de.y,ue.x,ue.y)}for(const Je of Re){ce.reset(Je,.25*te);let dt=0;dt=ce.length<=.5*te?1:Math.ceil(ce.paddedLength/ge)+1;for(let Tt=0;Tt<dt;Tt++){const xt=Tt/Math.max(dt-1,1),It=ce.lerp(xt),pt=It.x+ti,Kt=It.y+ti;N.push(pt,Kt,te,0);const Et=pt-te,hi=Kt-te,Ft=pt+te,Bt=Kt+te;if(H=H&&this.isOffscreen(Et,hi,Ft,Bt),Q=Q||this.isInsideGrid(Et,hi,Ft,Bt),t!=="always"&&this.grid.hitTestCircle(pt,Kt,te,t,T)&&(Y=!0,!v))return{circles:[],offscreen:!1,collisionDetected:Y}}}}return{circles:!v&&Y||!Q||j<this.perspectiveRatioCutoff?[]:N,offscreen:H,collisionDetected:Y}}projectPathToScreenSpace(t,n){const o=(function(l,p){const m=c.N();return c.aB(m,p.pitchedLabelPlaneMatrix),l.map((_=>{const v=ns(_.x,_.y,m,p.getElevation),w=p.transform.projectTileCoordinates(v.point.x,v.point.y,p.unwrappedTileID,p.getElevation);return w.point.x=(.5*w.point.x+.5)*p.width,w.point.y=(.5*-w.point.y+.5)*p.height,w}))})(t,n);return(function(l){let p=0,m=0,_=0,v=0;for(let w=0;w<l.length;w++)l[w].isOccluded?(_=w+1,v=0):(v++,v>m&&(m=v,p=_));return l.slice(p,p+m)})(o)}queryRenderedSymbols(t){if(t.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const n=[],o=new c.aa;for(const C of t){const M=new c.P(C.x+ti,C.y+ti);o.extend(M),n.push(M)}const{minX:l,minY:p,maxX:m,maxY:_}=o,v=this.grid.query(l,p,m,_).concat(this.ignoredGrid.query(l,p,m,_)),w={},T={};for(const C of v){const M=C.key;if(w[M.bucketInstanceId]===void 0&&(w[M.bucketInstanceId]={}),w[M.bucketInstanceId][M.featureIndex])continue;const z=[new c.P(C.x1,C.y1),new c.P(C.x2,C.y1),new c.P(C.x2,C.y2),new c.P(C.x1,C.y2)];c.aK(n,z)&&(w[M.bucketInstanceId][M.featureIndex]=!0,T[M.bucketInstanceId]===void 0&&(T[M.bucketInstanceId]=[]),T[M.bucketInstanceId].push(M.featureIndex))}return T}insertCollisionBox(t,n,o,l,p,m){(o?this.ignoredGrid:this.grid).insert({bucketInstanceId:l,featureIndex:p,collisionGroupID:m,overlapMode:n},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,n,o,l,p,m){const _=o?this.ignoredGrid:this.grid,v={bucketInstanceId:l,featureIndex:p,collisionGroupID:m,overlapMode:n};for(let w=0;w<t.length;w+=4)_.insertCircle(v,t[w],t[w+1],t[w+2])}projectAndGetPerspectiveRatio(t,n,o,l,p){if(p){let m;l?(m=[t,n,l(t,n),1],c.aH(m,m,p)):(m=[t,n,0,1],dn(m,m,p));const _=m[3];return{x:(m[0]/_+1)/2*this.transform.width+ti,y:(-m[1]/_+1)/2*this.transform.height+ti,perspectiveRatio:.5+this.transform.cameraToCenterDistance/_*.5,isOccluded:!1,signedDistanceFromCamera:_}}{const m=this.transform.projectTileCoordinates(t,n,o,l);return{x:(m.point.x+1)/2*this.transform.width+ti,y:(1-m.point.y)/2*this.transform.height+ti,perspectiveRatio:.5+this.transform.cameraToCenterDistance/m.signedDistanceFromCamera*.5,isOccluded:m.isOccluded,signedDistanceFromCamera:m.signedDistanceFromCamera}}}getPerspectiveRatio(t,n,o,l){const p=this.transform.projectTileCoordinates(t,n,o,l);return .5+this.transform.cameraToCenterDistance/p.signedDistanceFromCamera*.5}isOffscreen(t,n,o,l){return o<ti||t>=this.screenRightBoundary||l<ti||n>this.screenBottomBoundary}isInsideGrid(t,n,o,l){return o>=0&&t<this.gridRightBoundary&&l>=0&&n<this.gridBottomBoundary}getViewportMatrix(){const t=c.ar([]);return c.O(t,t,[-100,-100,0]),t}_projectCollisionBox(t,n,o,l,p,m,_,v,w,T,C){let M=1,z=0,R=0,N=1;const U=t.anchorPointX+_[0],j=t.anchorPointY+_[1];if(m&&!p){const Ie=this.projectAndGetPerspectiveRatio(U+1,j,l,w,C),ge=Ie.x-v.x,Re=Math.atan((Ie.y-v.y)/ge)+(ge<0?Math.PI:0),Je=Math.sin(Re),dt=Math.cos(Re);M=dt,z=Je,R=-Je,N=dt}else if(!m&&p){const Ie=tt(this.transform);M=Ie.vecEast[0],z=Ie.vecEast[1],R=Ie.vecSouth[0],N=Ie.vecSouth[1]}let Z=v.x,X=v.y,q=n;p&&(Z=U,X=j,q=Math.pow(2,-(this.transform.zoom-o.overscaledZ)),q*=this.transform.getPitchedTextCorrection(U,j,l),T||(q*=c.an(.5+v.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))),T&&(Z+=M*T.x*q+R*T.y*q,X+=z*T.x*q+N*T.y*q);const Y=t.x1*q,Q=t.x2*q,H=(Y+Q)/2,te=t.y1*q,de=t.y2*q,ue=(te+de)/2,ce=[{offsetX:Y,offsetY:te},{offsetX:H,offsetY:te},{offsetX:Q,offsetY:te},{offsetX:Q,offsetY:ue},{offsetX:Q,offsetY:de},{offsetX:H,offsetY:de},{offsetX:Y,offsetY:de},{offsetX:Y,offsetY:ue}];let he=[];for(const{offsetX:Ie,offsetY:ge}of ce)he.push(new c.P(Z+M*Ie+R*ge,X+z*Ie+N*ge));let Ce=!1;if(p){const Ie=he.map((ge=>this.projectAndGetPerspectiveRatio(ge.x,ge.y,l,w,C)));Ce=Ie.some((ge=>!ge.isOccluded)),he=Ie.map((ge=>new c.P(ge.x,ge.y)))}else Ce=!0;return{box:c.aL(he),allPointsOccluded:!Ce}}}class Jl{constructor(t,n,o,l){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?n:-n))):l&&o?1:0,this.placed=o}isHidden(){return this.opacity===0&&!this.placed}}class Ns{constructor(t,n,o,l,p){this.text=new Jl(t?t.text:null,n,o,p),this.icon=new Jl(t?t.icon:null,n,l,p)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Na{constructor(t,n,o){this.text=t,this.icon=n,this.skipFade=o}}class Ql{constructor(t,n,o,l,p){this.bucketInstanceId=t,this.featureIndex=n,this.sourceLayerIndex=o,this.bucketIndex=l,this.tileID=p}}class ja{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){const n=++this.maxGroupID;this.collisionGroups[t]={ID:n,predicate:o=>o.collisionGroupID===n}}return this.collisionGroups[t]}}function Ro(d,t,n,o,l){const{horizontalAlign:p,verticalAlign:m}=c.aS(d);return new c.P(-(p-.5)*t+o[0]*l,-(m-.5)*n+o[1]*l)}class ec{constructor(t,n,o,l,p){this.transform=t.clone(),this.terrain=n,this.collisionIndex=new zu(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=o,this.retainedQueryData={},this.collisionGroups=new ja(l),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=p,p&&(p.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(t){const n=this.terrain;return n?(o,l)=>n.getElevation(t,o,l):null}getBucketParts(t,n,o,l){const p=o.getBucket(n),m=o.latestFeatureIndex;if(!p||!m||n.id!==p.layerIds[0])return;const _=o.collisionBoxArray,v=p.layers[0].layout,w=p.layers[0].paint,T=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),C=o.tileSize/c.a5,M=o.tileID.toUnwrapped(),z=v.get("text-rotation-alignment")==="map",R=c.aN(o,1,this.transform.zoom),N=c.aO(this.collisionIndex.transform,o,w.get("text-translate"),w.get("text-translate-anchor")),U=c.aO(this.collisionIndex.transform,o,w.get("icon-translate"),w.get("icon-translate-anchor")),j=rs(z,this.transform,R);this.retainedQueryData[p.bucketInstanceId]=new Ql(p.bucketInstanceId,m,p.sourceLayerIndex,p.index,o.tileID);const Z={bucket:p,layout:v,translationText:N,translationIcon:U,unwrappedTileID:M,pitchedLabelPlaneMatrix:j,scale:T,textPixelRatio:C,holdingForFade:o.holdingForSymbolFade(),collisionBoxArray:_,partiallyEvaluatedTextSize:c.ay(p.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(p.sourceID)};if(l)for(const X of p.sortKeyRanges){const{sortKey:q,symbolInstanceStart:Y,symbolInstanceEnd:Q}=X;t.push({sortKey:q,symbolInstanceStart:Y,symbolInstanceEnd:Q,parameters:Z})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:p.symbolInstances.length,parameters:Z})}attemptAnchorPlacement(t,n,o,l,p,m,_,v,w,T,C,M,z,R,N,U,j,Z,X,q){const Y=c.aP[t.textAnchor],Q=[t.textOffset0,t.textOffset1],H=Ro(Y,o,l,Q,p),te=this.collisionIndex.placeCollisionBox(n,M,v,w,T,_,m,U,C.predicate,X,H,q);if((!Z||this.collisionIndex.placeCollisionBox(Z,M,v,w,T,_,m,j,C.predicate,X,H,q).placeable)&&te.placeable){let de;if(this.prevPlacement&&this.prevPlacement.variableOffsets[z.crossTileID]&&this.prevPlacement.placements[z.crossTileID]&&this.prevPlacement.placements[z.crossTileID].text&&(de=this.prevPlacement.variableOffsets[z.crossTileID].anchor),z.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[z.crossTileID]={textOffset:Q,width:o,height:l,anchor:Y,textBoxScale:p,prevAnchor:de},this.markUsedJustification(R,Y,z,N),R.allowVerticalPlacement&&(this.markUsedOrientation(R,N,z),this.placedOrientations[z.crossTileID]=N),{shift:H,placedGlyphBoxes:te}}}placeLayerBucketPart(t,n,o){const{bucket:l,layout:p,translationText:m,translationIcon:_,unwrappedTileID:v,pitchedLabelPlaneMatrix:w,textPixelRatio:T,holdingForFade:C,collisionBoxArray:M,partiallyEvaluatedTextSize:z,collisionGroup:R}=t.parameters,N=p.get("text-optional"),U=p.get("icon-optional"),j=c.aQ(p,"text-overlap","text-allow-overlap"),Z=j==="always",X=c.aQ(p,"icon-overlap","icon-allow-overlap"),q=X==="always",Y=p.get("text-rotation-alignment")==="map",Q=p.get("text-pitch-alignment")==="map",H=p.get("icon-text-fit")!=="none",te=p.get("symbol-z-order")==="viewport-y",de=Z&&(q||!l.hasIconData()||U),ue=q&&(Z||!l.hasTextData()||N);!l.collisionArrays&&M&&l.deserializeCollisionBoxes(M);const ce=this.retainedQueryData[l.bucketInstanceId].tileID,he=this._getTerrainElevationFunc(ce),Ce=this.transform.getFastPathSimpleProjectionMatrix(ce),Ie=(ge,Re,Je)=>{var dt,Tt;if(n[ge.crossTileID])return;if(C)return void(this.placements[ge.crossTileID]=new Na(!1,!1,!1));let xt=!1,It=!1,pt=!0,Kt=null,Et={box:null,placeable:!1,offscreen:null,occluded:!1},hi={placeable:!1},Ft=null,Bt=null,Ci=null,Xr=0,Ar=0,Ii=0;Re.textFeatureIndex?Xr=Re.textFeatureIndex:ge.useRuntimeCollisionCircles&&(Xr=ge.featureIndex),Re.verticalTextFeatureIndex&&(Ar=Re.verticalTextFeatureIndex);const Yr=Re.textBox;if(Yr){const Fi=gt=>{let At=c.az.horizontal;if(l.allowVerticalPlacement&&!gt&&this.prevPlacement){const Yi=this.prevPlacement.placedOrientations[ge.crossTileID];Yi&&(this.placedOrientations[ge.crossTileID]=Yi,At=Yi,this.markUsedOrientation(l,At,ge))}return At},lr=(gt,At)=>{if(l.allowVerticalPlacement&&ge.numVerticalGlyphVertices>0&&Re.verticalTextBox){for(const Yi of l.writingModes)if(Yi===c.az.vertical?(Et=At(),hi=Et):Et=gt(),Et&&Et.placeable)break}else Et=gt()},Wi=ge.textAnchorOffsetStartIndex,Xi=ge.textAnchorOffsetEndIndex;if(Xi===Wi){const gt=(At,Yi)=>{const ri=this.collisionIndex.placeCollisionBox(At,j,T,ce,v,Q,Y,m,R.predicate,he,void 0,Ce);return ri&&ri.placeable&&(this.markUsedOrientation(l,Yi,ge),this.placedOrientations[ge.crossTileID]=Yi),ri};lr((()=>gt(Yr,c.az.horizontal)),(()=>{const At=Re.verticalTextBox;return l.allowVerticalPlacement&&ge.numVerticalGlyphVertices>0&&At?gt(At,c.az.vertical):{box:null,offscreen:null}})),Fi(Et&&Et.placeable)}else{let gt=c.aP[(Tt=(dt=this.prevPlacement)===null||dt===void 0?void 0:dt.variableOffsets[ge.crossTileID])===null||Tt===void 0?void 0:Tt.anchor];const At=(ri,Qc,Zn)=>{const nh=ri.x2-ri.x1,eu=ri.y2-ri.y1,El=ge.textBoxScale,tu=H&&X==="never"?Qc:null;let Ki=null,yn=j==="never"?1:2,Al="never";gt&&yn++;for(let iu=0;iu<yn;iu++){for(let So=Wi;So<Xi;So++){const Dl=l.textAnchorOffsets.get(So);if(gt&&Dl.textAnchor!==gt)continue;const Ts=this.attemptAnchorPlacement(Dl,ri,nh,eu,El,Y,Q,T,ce,v,R,Al,ge,l,Zn,m,_,tu,he);if(Ts&&(Ki=Ts.placedGlyphBoxes,Ki&&Ki.placeable))return xt=!0,Kt=Ts.shift,Ki}gt?gt=null:Al=j}return o&&!Ki&&(Ki={box:this.collisionIndex.placeCollisionBox(Yr,"always",T,ce,v,Q,Y,m,R.predicate,he,void 0,Ce).box,offscreen:!1,placeable:!1,occluded:!1}),Ki};lr((()=>At(Yr,Re.iconBox,c.az.horizontal)),(()=>{const ri=Re.verticalTextBox;return l.allowVerticalPlacement&&(!Et||!Et.placeable)&&ge.numVerticalGlyphVertices>0&&ri?At(ri,Re.verticalIconBox,c.az.vertical):{box:null,occluded:!0,offscreen:null}})),Et&&(xt=Et.placeable,pt=Et.offscreen);const Yi=Fi(Et&&Et.placeable);if(!xt&&this.prevPlacement){const ri=this.prevPlacement.variableOffsets[ge.crossTileID];ri&&(this.variableOffsets[ge.crossTileID]=ri,this.markUsedJustification(l,ri.anchor,ge,Yi))}}}if(Ft=Et,xt=Ft&&Ft.placeable,pt=Ft&&Ft.offscreen,ge.useRuntimeCollisionCircles&&ge.centerJustifiedTextSymbolIndex>=0){const Fi=l.text.placedSymbolArray.get(ge.centerJustifiedTextSymbolIndex),lr=c.aA(l.textSizeData,z,Fi),Wi=p.get("text-padding");Bt=this.collisionIndex.placeCollisionCircles(j,Fi,l.lineVertexArray,l.glyphOffsetArray,lr,v,w,o,Q,R.predicate,ge.collisionCircleDiameter,Wi,m,he),Bt.circles.length&&Bt.collisionDetected&&!o&&c.w("Collisions detected, but collision boxes are not shown"),xt=Z||Bt.circles.length>0&&!Bt.collisionDetected,pt=pt&&Bt.offscreen}if(Re.iconFeatureIndex&&(Ii=Re.iconFeatureIndex),Re.iconBox){const Fi=lr=>this.collisionIndex.placeCollisionBox(lr,X,T,ce,v,Q,Y,_,R.predicate,he,H&&Kt?Kt:void 0,Ce);hi&&hi.placeable&&Re.verticalIconBox?(Ci=Fi(Re.verticalIconBox),It=Ci.placeable):(Ci=Fi(Re.iconBox),It=Ci.placeable),pt=pt&&Ci.offscreen}const wo=N||ge.numHorizontalGlyphVertices===0&&ge.numVerticalGlyphVertices===0,To=U||ge.numIconVertices===0;wo||To?To?wo||(It=It&&xt):xt=It&&xt:It=xt=It&&xt;const ws=It&&Ci.placeable;if(xt&&Ft.placeable&&this.collisionIndex.insertCollisionBox(Ft.box,j,p.get("text-ignore-placement"),l.bucketInstanceId,hi&&hi.placeable&&Ar?Ar:Xr,R.ID),ws&&this.collisionIndex.insertCollisionBox(Ci.box,X,p.get("icon-ignore-placement"),l.bucketInstanceId,Ii,R.ID),Bt&&xt&&this.collisionIndex.insertCollisionCircles(Bt.circles,j,p.get("text-ignore-placement"),l.bucketInstanceId,Xr,R.ID),o&&this.storeCollisionData(l.bucketInstanceId,Je,Re,Ft,Ci,Bt),ge.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");if(l.bucketInstanceId===0)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[ge.crossTileID]=new Na((xt||de)&&!Ft?.occluded,(It||ue)&&!Ci?.occluded,pt||l.justReloaded),n[ge.crossTileID]=!0};if(te){if(t.symbolInstanceStart!==0)throw new Error("bucket.bucketInstanceId should be 0");const ge=l.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let Re=ge.length-1;Re>=0;--Re){const Je=ge[Re];Ie(l.symbolInstances.get(Je),l.collisionArrays[Je],Je)}}else for(let ge=t.symbolInstanceStart;ge<t.symbolInstanceEnd;ge++)Ie(l.symbolInstances.get(ge),l.collisionArrays[ge],ge);l.justReloaded=!1}storeCollisionData(t,n,o,l,p,m){if(o.textBox||o.iconBox){let _,v;this.collisionBoxArrays.has(t)?_=this.collisionBoxArrays.get(t):(_=new Map,this.collisionBoxArrays.set(t,_)),_.has(n)?v=_.get(n):(v={text:null,icon:null},_.set(n,v)),o.textBox&&(v.text=l.box),o.iconBox&&(v.icon=p.box)}if(m){let _=this.collisionCircleArrays[t];_===void 0&&(_=this.collisionCircleArrays[t]=[]);for(let v=0;v<m.circles.length;v+=4)_.push(m.circles[v+0]-ti),_.push(m.circles[v+1]-ti),_.push(m.circles[v+2]),_.push(m.collisionDetected?1:0)}}markUsedJustification(t,n,o,l){let p;p=l===c.az.vertical?o.verticalPlacedTextSymbolIndex:{left:o.leftJustifiedTextSymbolIndex,center:o.centerJustifiedTextSymbolIndex,right:o.rightJustifiedTextSymbolIndex}[c.aR(n)];const m=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex,o.verticalPlacedTextSymbolIndex];for(const _ of m)_>=0&&(t.text.placedSymbolArray.get(_).crossTileID=p>=0&&_!==p?0:o.crossTileID)}markUsedOrientation(t,n,o){const l=n===c.az.horizontal||n===c.az.horizontalOnly?n:0,p=n===c.az.vertical?n:0,m=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex];for(const _ of m)t.text.placedSymbolArray.get(_).placedOrientation=l;o.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).placedOrientation=p)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const n=this.prevPlacement;let o=!1;this.prevZoomAdjustment=n?n.zoomAdjustment(this.transform.zoom):0;const l=n?n.symbolFadeChange(t):1,p=n?n.opacities:{},m=n?n.variableOffsets:{},_=n?n.placedOrientations:{};for(const v in this.placements){const w=this.placements[v],T=p[v];T?(this.opacities[v]=new Ns(T,l,w.text,w.icon),o=o||w.text!==T.text.placed||w.icon!==T.icon.placed):(this.opacities[v]=new Ns(null,l,w.text,w.icon,w.skipFade),o=o||w.text||w.icon)}for(const v in p){const w=p[v];if(!this.opacities[v]){const T=new Ns(w,l,!1,!1);T.isHidden()||(this.opacities[v]=T,o=o||w.text.placed||w.icon.placed)}}for(const v in m)this.variableOffsets[v]||!this.opacities[v]||this.opacities[v].isHidden()||(this.variableOffsets[v]=m[v]);for(const v in _)this.placedOrientations[v]||!this.opacities[v]||this.opacities[v].isHidden()||(this.placedOrientations[v]=_[v]);if(n&&n.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");o?this.lastPlacementChangeTime=t:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=n?n.lastPlacementChangeTime:t)}updateLayerOpacities(t,n){const o={};for(const l of n){const p=l.getBucket(t);p&&l.latestFeatureIndex&&t.id===p.layerIds[0]&&this.updateBucketOpacities(p,l.tileID,o,l.collisionBoxArray)}}updateBucketOpacities(t,n,o,l){t.hasTextData()&&(t.text.opacityVertexArray.clear(),t.text.hasVisibleVertices=!1),t.hasIconData()&&(t.icon.opacityVertexArray.clear(),t.icon.hasVisibleVertices=!1),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const p=t.layers[0],m=p.layout,_=new Ns(null,0,!1,!1,!0),v=m.get("text-allow-overlap"),w=m.get("icon-allow-overlap"),T=p._unevaluatedLayout.hasValue("text-variable-anchor")||p._unevaluatedLayout.hasValue("text-variable-anchor-offset"),C=m.get("text-rotation-alignment")==="map",M=m.get("text-pitch-alignment")==="map",z=m.get("icon-text-fit")!=="none",R=new Ns(null,0,v&&(w||!t.hasIconData()||m.get("icon-optional")),w&&(v||!t.hasTextData()||m.get("text-optional")),!0);!t.collisionArrays&&l&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(l);const N=(j,Z,X)=>{for(let q=0;q<Z/4;q++)j.opacityVertexArray.emplaceBack(X);j.hasVisibleVertices=j.hasVisibleVertices||X!==nr},U=this.collisionBoxArrays.get(t.bucketInstanceId);for(let j=0;j<t.symbolInstances.length;j++){const Z=t.symbolInstances.get(j),{numHorizontalGlyphVertices:X,numVerticalGlyphVertices:q,crossTileID:Y}=Z;let Q=this.opacities[Y];o[Y]?Q=_:Q||(Q=R,this.opacities[Y]=Q),o[Y]=!0;const H=Z.numIconVertices>0,te=this.placedOrientations[Z.crossTileID],de=te===c.az.vertical,ue=te===c.az.horizontal||te===c.az.horizontalOnly;if(X>0||q>0){const he=rc(Q.text);N(t.text,X,de?nr:he),N(t.text,q,ue?nr:he);const Ce=Q.text.isHidden();[Z.rightJustifiedTextSymbolIndex,Z.centerJustifiedTextSymbolIndex,Z.leftJustifiedTextSymbolIndex].forEach((Re=>{Re>=0&&(t.text.placedSymbolArray.get(Re).hidden=Ce||de?1:0)})),Z.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(Z.verticalPlacedTextSymbolIndex).hidden=Ce||ue?1:0);const Ie=this.variableOffsets[Z.crossTileID];Ie&&this.markUsedJustification(t,Ie.anchor,Z,te);const ge=this.placedOrientations[Z.crossTileID];ge&&(this.markUsedJustification(t,"left",Z,ge),this.markUsedOrientation(t,ge,Z))}if(H){const he=rc(Q.icon),Ce=!(z&&Z.verticalPlacedIconSymbolIndex&&de);Z.placedIconSymbolIndex>=0&&(N(t.icon,Z.numIconVertices,Ce?he:nr),t.icon.placedSymbolArray.get(Z.placedIconSymbolIndex).hidden=Q.icon.isHidden()),Z.verticalPlacedIconSymbolIndex>=0&&(N(t.icon,Z.numVerticalIconVertices,Ce?nr:he),t.icon.placedSymbolArray.get(Z.verticalPlacedIconSymbolIndex).hidden=Q.icon.isHidden())}const ce=U&&U.has(j)?U.get(j):{text:null,icon:null};if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const he=t.collisionArrays[j];if(he){let Ce=new c.P(0,0);if(he.textBox||he.verticalTextBox){let Ie=!0;if(T){const ge=this.variableOffsets[Y];ge?(Ce=Ro(ge.anchor,ge.width,ge.height,ge.textOffset,ge.textBoxScale),C&&Ce._rotate(M?-this.transform.bearingInRadians:this.transform.bearingInRadians)):Ie=!1}if(he.textBox||he.verticalTextBox){let ge;he.textBox&&(ge=de),he.verticalTextBox&&(ge=ue),Fo(t.textCollisionBox.collisionVertexArray,Q.text.placed,!Ie||ge,ce.text,Ce.x,Ce.y)}}if(he.iconBox||he.verticalIconBox){const Ie=!!(!ue&&he.verticalIconBox);let ge;he.iconBox&&(ge=Ie),he.verticalIconBox&&(ge=!Ie),Fo(t.iconCollisionBox.collisionVertexArray,Q.icon.placed,ge,ce.icon,z?Ce.x:0,z?Ce.y:0)}}}}if(t.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.text.opacityVertexArray.length!==t.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${t.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${t.text.layoutVertexArray.length}) / 4`);if(t.icon.opacityVertexArray.length!==t.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${t.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${t.icon.layoutVertexArray.length}) / 4`);t.bucketInstanceId in this.collisionCircleArrays&&(t.collisionCircleArray=this.collisionCircleArrays[t.bucketInstanceId],delete this.collisionCircleArrays[t.bucketInstanceId])}symbolFadeChange(t){return this.fadeDuration===0?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(t,n){const o=this.zoomAtLastRecencyCheck===n?1-this.zoomAdjustment(n):1;return this.zoomAtLastRecencyCheck=n,this.commitTime+this.fadeDuration*o>t}setStale(){this.stale=!0}}function Fo(d,t,n,o,l,p){o&&o.length!==0||(o=[0,0,0,0]);const m=o[0]-ti,_=o[1]-ti,v=o[2]-ti,w=o[3]-ti;d.emplaceBack(t?1:0,n?1:0,l||0,p||0,m,_),d.emplaceBack(t?1:0,n?1:0,l||0,p||0,v,_),d.emplaceBack(t?1:0,n?1:0,l||0,p||0,v,w),d.emplaceBack(t?1:0,n?1:0,l||0,p||0,m,w)}const Ua=Math.pow(2,25),ku=Math.pow(2,24),js=Math.pow(2,17),Bo=Math.pow(2,16),tc=Math.pow(2,9),as=Math.pow(2,8),ic=Math.pow(2,1);function rc(d){if(d.opacity===0&&!d.placed)return 0;if(d.opacity===1&&d.placed)return 4294967295;const t=d.placed?1:0,n=Math.floor(127*d.opacity);return n*Ua+t*ku+n*js+t*Bo+n*tc+t*as+n*ic+t}const nr=0;class ls{constructor(t){this._sortAcrossTiles=t.layout.get("symbol-z-order")!=="viewport-y"&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,n,o,l,p){const m=this._bucketParts;for(;this._currentTileIndex<t.length;)if(n.getBucketParts(m,l,t[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,p())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,m.sort(((_,v)=>_.sortKey-v.sortKey)));this._currentPartIndex<m.length;)if(n.placeLayerBucketPart(m[this._currentPartIndex],this._seenCrossTileIDs,o),this._currentPartIndex++,p())return!0;return!1}}class st{constructor(t,n,o,l,p,m,_,v){this.placement=new ec(t,n,m,_,v),this._currentPlacementIndex=o.length-1,this._forceFullPlacement=l,this._showCollisionBoxes=p,this._done=!1}isDone(){return this._done}continuePlacement(t,n,o){const l=He(),p=()=>!this._forceFullPlacement&&He()-l>2;for(;this._currentPlacementIndex>=0;){const m=n[t[this._currentPlacementIndex]],_=this.placement.collisionIndex.transform.zoom;if(m.type==="symbol"&&(!m.minzoom||m.minzoom<=_)&&(!m.maxzoom||m.maxzoom>_)){if(this._inProgressLayer||(this._inProgressLayer=new ls(m)),this._inProgressLayer.continuePlacement(o[m.source],this.placement,this._showCollisionBoxes,m,p))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const Dn=512/c.a5/2;class Lu{constructor(t,n,o){this.tileID=t,this.bucketInstanceId=o,this._symbolsByKey={};const l=new Map;for(let p=0;p<n.length;p++){const m=n.get(p),_=m.key,v=l.get(_);v?v.push(m):l.set(_,[m])}for(const[p,m]of l){const _={positions:m.map((v=>({x:Math.floor(v.anchorX*Dn),y:Math.floor(v.anchorY*Dn)}))),crossTileIDs:m.map((v=>v.crossTileID))};if(_.positions.length>128){const v=new c.aT(_.positions.length,16,Uint16Array);for(const{x:w,y:T}of _.positions)v.add(w,T);v.finish(),delete _.positions,_.index=v}this._symbolsByKey[p]=_}}getScaledCoordinates(t,n){const{x:o,y:l,z:p}=this.tileID.canonical,{x:m,y:_,z:v}=n.canonical,w=Dn/Math.pow(2,v-p),T=(_*c.a5+t.anchorY)*w,C=l*c.a5*Dn;return{x:Math.floor((m*c.a5+t.anchorX)*w-o*c.a5*Dn),y:Math.floor(T-C)}}findMatches(t,n,o){const l=this.tileID.canonical.z<n.canonical.z?1:Math.pow(2,this.tileID.canonical.z-n.canonical.z);for(let p=0;p<t.length;p++){const m=t.get(p);if(m.crossTileID)continue;const _=this._symbolsByKey[m.key];if(!_)continue;const v=this.getScaledCoordinates(m,n);if(_.index){const w=_.index.range(v.x-l,v.y-l,v.x+l,v.y+l).sort();for(const T of w){const C=_.crossTileIDs[T];if(!o[C]){o[C]=!0,m.crossTileID=C;break}}}else if(_.positions)for(let w=0;w<_.positions.length;w++){const T=_.positions[w],C=_.crossTileIDs[w];if(Math.abs(T.x-v.x)<=l&&Math.abs(T.y-v.y)<=l&&!o[C]){o[C]=!0,m.crossTileID=C;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map((({crossTileIDs:t})=>t))}}class Ga{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Ui{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const n=Math.round((t-this.lng)/360);if(n!==0)for(const o in this.indexes){const l=this.indexes[o],p={};for(const m in l){const _=l[m];_.tileID=_.tileID.unwrapTo(_.tileID.wrap+n),p[_.tileID.key]=_}this.indexes[o]=p}this.lng=t}addBucket(t,n,o){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===n.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let p=0;p<n.symbolInstances.length;p++)n.symbolInstances.get(p).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||(this.usedCrossTileIDs[t.overscaledZ]={});const l=this.usedCrossTileIDs[t.overscaledZ];for(const p in this.indexes){const m=this.indexes[p];if(Number(p)>t.overscaledZ)for(const _ in m){const v=m[_];v.tileID.isChildOf(t)&&v.findMatches(n.symbolInstances,t,l)}else{const _=m[t.scaledTo(Number(p)).key];_&&_.findMatches(n.symbolInstances,t,l)}}for(let p=0;p<n.symbolInstances.length;p++){const m=n.symbolInstances.get(p);m.crossTileID||(m.crossTileID=o.generate(),l[m.crossTileID]=!0)}return this.indexes[t.overscaledZ]===void 0&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new Lu(t,n.symbolInstances,n.bucketInstanceId),!0}removeBucketCrossTileIDs(t,n){for(const o of n.getCrossTileIDsLists())for(const l of o)delete this.usedCrossTileIDs[t][l]}removeStaleBuckets(t){let n=!1;for(const o in this.indexes){const l=this.indexes[o];for(const p in l)t[l[p].bucketInstanceId]||(this.removeBucketCrossTileIDs(o,l[p]),delete l[p],n=!0)}return n}}class _i{constructor(){this.layerIndexes={},this.crossTileIDs=new Ga,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,n,o){let l=this.layerIndexes[t.id];l===void 0&&(l=this.layerIndexes[t.id]=new Ui);let p=!1;const m={};l.handleWrapJump(o);for(const _ of n){const v=_.getBucket(t);v&&t.id===v.layerIds[0]&&(v.bucketInstanceId||(v.bucketInstanceId=++this.maxBucketInstanceId),l.addBucket(_.tileID,v,this.crossTileIDs)&&(p=!0),m[v.bucketInstanceId]=!0)}return l.removeStaleBuckets(m)&&(p=!0),p}pruneUnusedLayers(t){const n={};t.forEach((o=>{n[o]=!0}));for(const o in this.layerIndexes)n[o]||delete this.layerIndexes[o]}}var yi="void main() {fragColor=vec4(1.0);}";const Pt={prelude:je(`#ifdef GL_ES
|
|
11
|
+
precision mediump float;
|
|
12
|
+
#else
|
|
13
|
+
#if !defined(lowp)
|
|
14
|
+
#define lowp
|
|
15
|
+
#endif
|
|
16
|
+
#if !defined(mediump)
|
|
17
|
+
#define mediump
|
|
18
|
+
#endif
|
|
19
|
+
#if !defined(highp)
|
|
20
|
+
#define highp
|
|
21
|
+
#endif
|
|
22
|
+
#endif
|
|
23
|
+
out highp vec4 fragColor;`,`#ifdef GL_ES
|
|
24
|
+
precision highp float;
|
|
25
|
+
#else
|
|
26
|
+
#if !defined(lowp)
|
|
27
|
+
#define lowp
|
|
28
|
+
#endif
|
|
29
|
+
#if !defined(mediump)
|
|
30
|
+
#define mediump
|
|
31
|
+
#endif
|
|
32
|
+
#if !defined(highp)
|
|
33
|
+
#define highp
|
|
34
|
+
#endif
|
|
35
|
+
#endif
|
|
36
|
+
vec2 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
|
|
37
|
+
);}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
|
|
38
|
+
);}
|
|
39
|
+
#ifdef TERRAIN3D
|
|
40
|
+
uniform 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;
|
|
41
|
+
#endif
|
|
42
|
+
const 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) {
|
|
43
|
+
#ifdef TERRAIN3D
|
|
44
|
+
highp 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));
|
|
45
|
+
#else
|
|
46
|
+
return 1.0;
|
|
47
|
+
#endif
|
|
48
|
+
}float calculate_visibility(vec4 pos) {
|
|
49
|
+
#ifdef TERRAIN3D
|
|
50
|
+
vec3 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;
|
|
51
|
+
#else
|
|
52
|
+
return 1.0;
|
|
53
|
+
#endif
|
|
54
|
+
}float ele(vec2 pos) {
|
|
55
|
+
#ifdef TERRAIN3D
|
|
56
|
+
vec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;
|
|
57
|
+
#else
|
|
58
|
+
return 0.0;
|
|
59
|
+
#endif
|
|
60
|
+
}float get_elevation(vec2 pos) {
|
|
61
|
+
#ifdef TERRAIN3D
|
|
62
|
+
#ifdef GLOBE
|
|
63
|
+
if ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}
|
|
64
|
+
#endif
|
|
65
|
+
vec2 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;
|
|
66
|
+
#else
|
|
67
|
+
return 0.0;
|
|
68
|
+
#endif
|
|
69
|
+
}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;`),projectionMercator:je("","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:je("",`#define GLOBE_RADIUS 6371008.8
|
|
70
|
+
uniform 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
|
|
71
|
+
);}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);
|
|
72
|
+
if (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
|
|
73
|
+
);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:je(`uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;
|
|
74
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
75
|
+
fragColor=vec4(1.0);
|
|
76
|
+
#endif
|
|
77
|
+
}`,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:je(`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;
|
|
78
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
79
|
+
fragColor=vec4(1.0);
|
|
80
|
+
#endif
|
|
81
|
+
}`,"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:je(`in vec3 v_data;in float v_visibility;
|
|
82
|
+
#pragma mapbox: define highp vec4 color
|
|
83
|
+
#pragma mapbox: define mediump float radius
|
|
84
|
+
#pragma mapbox: define lowp float blur
|
|
85
|
+
#pragma mapbox: define lowp float opacity
|
|
86
|
+
#pragma mapbox: define highp vec4 stroke_color
|
|
87
|
+
#pragma mapbox: define mediump float stroke_width
|
|
88
|
+
#pragma mapbox: define lowp float stroke_opacity
|
|
89
|
+
void main() {
|
|
90
|
+
#pragma mapbox: initialize highp vec4 color
|
|
91
|
+
#pragma mapbox: initialize mediump float radius
|
|
92
|
+
#pragma mapbox: initialize lowp float blur
|
|
93
|
+
#pragma mapbox: initialize lowp float opacity
|
|
94
|
+
#pragma mapbox: initialize highp vec4 stroke_color
|
|
95
|
+
#pragma mapbox: initialize mediump float stroke_width
|
|
96
|
+
#pragma mapbox: initialize lowp float stroke_opacity
|
|
97
|
+
vec2 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;}
|
|
98
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
99
|
+
fragColor=vec4(1.0);
|
|
100
|
+
#endif
|
|
101
|
+
}`,`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;
|
|
102
|
+
#pragma mapbox: define highp vec4 color
|
|
103
|
+
#pragma mapbox: define mediump float radius
|
|
104
|
+
#pragma mapbox: define lowp float blur
|
|
105
|
+
#pragma mapbox: define lowp float opacity
|
|
106
|
+
#pragma mapbox: define highp vec4 stroke_color
|
|
107
|
+
#pragma mapbox: define mediump float stroke_width
|
|
108
|
+
#pragma mapbox: define lowp float stroke_opacity
|
|
109
|
+
void main(void) {
|
|
110
|
+
#pragma mapbox: initialize highp vec4 color
|
|
111
|
+
#pragma mapbox: initialize mediump float radius
|
|
112
|
+
#pragma mapbox: initialize lowp float blur
|
|
113
|
+
#pragma mapbox: initialize lowp float opacity
|
|
114
|
+
#pragma mapbox: initialize highp vec4 stroke_color
|
|
115
|
+
#pragma mapbox: initialize mediump float stroke_width
|
|
116
|
+
#pragma mapbox: initialize lowp float stroke_opacity
|
|
117
|
+
vec2 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) {
|
|
118
|
+
#ifdef GLOBE
|
|
119
|
+
vec3 center_vector=projectToSphere(circle_center);
|
|
120
|
+
#endif
|
|
121
|
+
float 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 {
|
|
122
|
+
#ifdef GLOBE
|
|
123
|
+
vec4 projected_center=interpolateProjection(circle_center,center_vector,ele);
|
|
124
|
+
#else
|
|
125
|
+
vec4 projected_center=projectTileWithElevation(circle_center,ele);
|
|
126
|
+
#endif
|
|
127
|
+
corner_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);}
|
|
128
|
+
#ifdef GLOBE
|
|
129
|
+
vec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);
|
|
130
|
+
#else
|
|
131
|
+
gl_Position=projectTileWithElevation(corner_position,ele);
|
|
132
|
+
#endif
|
|
133
|
+
} 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:je(yi,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:je(`uniform highp float u_intensity;in vec2 v_extrude;
|
|
134
|
+
#pragma mapbox: define highp float weight
|
|
135
|
+
#define GAUSS_COEF 0.3989422804014327
|
|
136
|
+
void main() {
|
|
137
|
+
#pragma mapbox: initialize highp float weight
|
|
138
|
+
float 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);
|
|
139
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
140
|
+
fragColor=vec4(1.0);
|
|
141
|
+
#endif
|
|
142
|
+
}`,`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;
|
|
143
|
+
#pragma mapbox: define highp float weight
|
|
144
|
+
#pragma mapbox: define mediump float radius
|
|
145
|
+
const highp float ZERO=1.0/255.0/16.0;
|
|
146
|
+
#define GAUSS_COEF 0.3989422804014327
|
|
147
|
+
void main(void) {
|
|
148
|
+
#pragma mapbox: initialize highp float weight
|
|
149
|
+
#pragma mapbox: initialize mediump float radius
|
|
150
|
+
vec2 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);
|
|
151
|
+
#ifdef GLOBE
|
|
152
|
+
vec2 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);
|
|
153
|
+
#else
|
|
154
|
+
gl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));
|
|
155
|
+
#endif
|
|
156
|
+
}`),heatmapTexture:je(`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;
|
|
157
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
158
|
+
fragColor=vec4(0.0);
|
|
159
|
+
#endif
|
|
160
|
+
}`,"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:je("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:je("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:je(`#ifdef GL_ES
|
|
161
|
+
precision highp float;
|
|
162
|
+
#endif
|
|
163
|
+
uniform 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
|
|
164
|
+
{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));
|
|
165
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
166
|
+
fragColor=vec4(1.0);
|
|
167
|
+
#endif
|
|
168
|
+
}`,"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:je("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:je(yi,`in vec2 a_pos;void main() {
|
|
169
|
+
#ifdef GLOBE
|
|
170
|
+
gl_Position=projectTileFor3D(a_pos,0.0);
|
|
171
|
+
#else
|
|
172
|
+
gl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);
|
|
173
|
+
#endif
|
|
174
|
+
}`),fill:je(`#pragma mapbox: define highp vec4 color
|
|
175
|
+
#pragma mapbox: define lowp float opacity
|
|
176
|
+
void main() {
|
|
177
|
+
#pragma mapbox: initialize highp vec4 color
|
|
178
|
+
#pragma mapbox: initialize lowp float opacity
|
|
179
|
+
fragColor=color*opacity;
|
|
180
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
181
|
+
fragColor=vec4(1.0);
|
|
182
|
+
#endif
|
|
183
|
+
}`,`uniform vec2 u_fill_translate;in vec2 a_pos;
|
|
184
|
+
#pragma mapbox: define highp vec4 color
|
|
185
|
+
#pragma mapbox: define lowp float opacity
|
|
186
|
+
void main() {
|
|
187
|
+
#pragma mapbox: initialize highp vec4 color
|
|
188
|
+
#pragma mapbox: initialize lowp float opacity
|
|
189
|
+
gl_Position=projectTile(a_pos+u_fill_translate,a_pos);}`),fillOutline:je(`in vec2 v_pos;
|
|
190
|
+
#ifdef GLOBE
|
|
191
|
+
in float v_depth;
|
|
192
|
+
#endif
|
|
193
|
+
#pragma mapbox: define highp vec4 outline_color
|
|
194
|
+
#pragma mapbox: define lowp float opacity
|
|
195
|
+
void main() {
|
|
196
|
+
#pragma mapbox: initialize highp vec4 outline_color
|
|
197
|
+
#pragma mapbox: initialize lowp float opacity
|
|
198
|
+
float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);
|
|
199
|
+
#ifdef GLOBE
|
|
200
|
+
if (v_depth > 1.0) {discard;}
|
|
201
|
+
#endif
|
|
202
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
203
|
+
fragColor=vec4(1.0);
|
|
204
|
+
#endif
|
|
205
|
+
}`,`uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;
|
|
206
|
+
#ifdef GLOBE
|
|
207
|
+
out float v_depth;
|
|
208
|
+
#endif
|
|
209
|
+
#pragma mapbox: define highp vec4 outline_color
|
|
210
|
+
#pragma mapbox: define lowp float opacity
|
|
211
|
+
void main() {
|
|
212
|
+
#pragma mapbox: initialize highp vec4 outline_color
|
|
213
|
+
#pragma mapbox: initialize lowp float opacity
|
|
214
|
+
gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
|
|
215
|
+
#ifdef GLOBE
|
|
216
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
217
|
+
#endif
|
|
218
|
+
}`),fillOutlinePattern:je(`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;
|
|
219
|
+
#ifdef GLOBE
|
|
220
|
+
in float v_depth;
|
|
221
|
+
#endif
|
|
222
|
+
#pragma mapbox: define lowp float opacity
|
|
223
|
+
#pragma mapbox: define lowp vec4 pattern_from
|
|
224
|
+
#pragma mapbox: define lowp vec4 pattern_to
|
|
225
|
+
void main() {
|
|
226
|
+
#pragma mapbox: initialize lowp float opacity
|
|
227
|
+
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
228
|
+
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
229
|
+
vec2 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;
|
|
230
|
+
#ifdef GLOBE
|
|
231
|
+
if (v_depth > 1.0) {discard;}
|
|
232
|
+
#endif
|
|
233
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
234
|
+
fragColor=vec4(1.0);
|
|
235
|
+
#endif
|
|
236
|
+
}`,`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;
|
|
237
|
+
#ifdef GLOBE
|
|
238
|
+
out float v_depth;
|
|
239
|
+
#endif
|
|
240
|
+
#pragma mapbox: define lowp float opacity
|
|
241
|
+
#pragma mapbox: define lowp vec4 pattern_from
|
|
242
|
+
#pragma mapbox: define lowp vec4 pattern_to
|
|
243
|
+
#pragma mapbox: define lowp float pixel_ratio_from
|
|
244
|
+
#pragma mapbox: define lowp float pixel_ratio_to
|
|
245
|
+
void main() {
|
|
246
|
+
#pragma mapbox: initialize lowp float opacity
|
|
247
|
+
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
248
|
+
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
249
|
+
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
250
|
+
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
251
|
+
vec2 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;
|
|
252
|
+
#ifdef GLOBE
|
|
253
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
254
|
+
#endif
|
|
255
|
+
}`),fillPattern:je(`#ifdef GL_ES
|
|
256
|
+
precision highp float;
|
|
257
|
+
#endif
|
|
258
|
+
uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;
|
|
259
|
+
#pragma mapbox: define lowp float opacity
|
|
260
|
+
#pragma mapbox: define lowp vec4 pattern_from
|
|
261
|
+
#pragma mapbox: define lowp vec4 pattern_to
|
|
262
|
+
void main() {
|
|
263
|
+
#pragma mapbox: initialize lowp float opacity
|
|
264
|
+
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
265
|
+
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
266
|
+
vec2 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;
|
|
267
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
268
|
+
fragColor=vec4(1.0);
|
|
269
|
+
#endif
|
|
270
|
+
}`,`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;
|
|
271
|
+
#pragma mapbox: define lowp float opacity
|
|
272
|
+
#pragma mapbox: define lowp vec4 pattern_from
|
|
273
|
+
#pragma mapbox: define lowp vec4 pattern_to
|
|
274
|
+
#pragma mapbox: define lowp float pixel_ratio_from
|
|
275
|
+
#pragma mapbox: define lowp float pixel_ratio_to
|
|
276
|
+
void main() {
|
|
277
|
+
#pragma mapbox: initialize lowp float opacity
|
|
278
|
+
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
279
|
+
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
280
|
+
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
281
|
+
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
282
|
+
vec2 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:je(`in vec4 v_color;void main() {fragColor=v_color;
|
|
283
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
284
|
+
fragColor=vec4(1.0);
|
|
285
|
+
#endif
|
|
286
|
+
}`,`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;
|
|
287
|
+
#ifdef TERRAIN3D
|
|
288
|
+
in vec2 a_centroid;
|
|
289
|
+
#endif
|
|
290
|
+
out vec4 v_color;
|
|
291
|
+
#pragma mapbox: define highp float base
|
|
292
|
+
#pragma mapbox: define highp float height
|
|
293
|
+
#pragma mapbox: define highp vec4 color
|
|
294
|
+
void main() {
|
|
295
|
+
#pragma mapbox: initialize highp float base
|
|
296
|
+
#pragma mapbox: initialize highp float height
|
|
297
|
+
#pragma mapbox: initialize highp vec4 color
|
|
298
|
+
vec3 normal=a_normal_ed.xyz;
|
|
299
|
+
#ifdef TERRAIN3D
|
|
300
|
+
float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
|
|
301
|
+
#else
|
|
302
|
+
float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
|
|
303
|
+
#endif
|
|
304
|
+
base=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;
|
|
305
|
+
#ifdef GLOBE
|
|
306
|
+
vec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);
|
|
307
|
+
#else
|
|
308
|
+
gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);
|
|
309
|
+
#endif
|
|
310
|
+
float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);
|
|
311
|
+
#ifdef GLOBE
|
|
312
|
+
mat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);
|
|
313
|
+
#endif
|
|
314
|
+
directional=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:je(`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;
|
|
315
|
+
#pragma mapbox: define lowp float base
|
|
316
|
+
#pragma mapbox: define lowp float height
|
|
317
|
+
#pragma mapbox: define lowp vec4 pattern_from
|
|
318
|
+
#pragma mapbox: define lowp vec4 pattern_to
|
|
319
|
+
#pragma mapbox: define lowp float pixel_ratio_from
|
|
320
|
+
#pragma mapbox: define lowp float pixel_ratio_to
|
|
321
|
+
void main() {
|
|
322
|
+
#pragma mapbox: initialize lowp float base
|
|
323
|
+
#pragma mapbox: initialize lowp float height
|
|
324
|
+
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
325
|
+
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
326
|
+
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
327
|
+
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
328
|
+
vec2 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;
|
|
329
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
330
|
+
fragColor=vec4(1.0);
|
|
331
|
+
#endif
|
|
332
|
+
}`,`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;
|
|
333
|
+
#ifdef TERRAIN3D
|
|
334
|
+
in vec2 a_centroid;
|
|
335
|
+
#endif
|
|
336
|
+
#ifdef GLOBE
|
|
337
|
+
out vec3 v_sphere_pos;
|
|
338
|
+
#endif
|
|
339
|
+
out vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;
|
|
340
|
+
#pragma mapbox: define lowp float base
|
|
341
|
+
#pragma mapbox: define lowp float height
|
|
342
|
+
#pragma mapbox: define lowp vec4 pattern_from
|
|
343
|
+
#pragma mapbox: define lowp vec4 pattern_to
|
|
344
|
+
#pragma mapbox: define lowp float pixel_ratio_from
|
|
345
|
+
#pragma mapbox: define lowp float pixel_ratio_to
|
|
346
|
+
void main() {
|
|
347
|
+
#pragma mapbox: initialize lowp float base
|
|
348
|
+
#pragma mapbox: initialize lowp float height
|
|
349
|
+
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
350
|
+
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
351
|
+
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
352
|
+
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
353
|
+
vec2 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;
|
|
354
|
+
#ifdef TERRAIN3D
|
|
355
|
+
float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
|
|
356
|
+
#else
|
|
357
|
+
float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
|
|
358
|
+
#endif
|
|
359
|
+
base=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;
|
|
360
|
+
#ifdef GLOBE
|
|
361
|
+
vec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);
|
|
362
|
+
#else
|
|
363
|
+
gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);
|
|
364
|
+
#endif
|
|
365
|
+
vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0
|
|
366
|
+
? a_pos
|
|
367
|
+
: 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:je(`#ifdef GL_ES
|
|
368
|
+
precision highp float;
|
|
369
|
+
#endif
|
|
370
|
+
uniform 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);
|
|
371
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
372
|
+
fragColor=vec4(1.0);
|
|
373
|
+
#endif
|
|
374
|
+
}`,"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:je(`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];
|
|
375
|
+
#define PI 3.141592653589793
|
|
376
|
+
#define STANDARD 0
|
|
377
|
+
#define COMBINED 1
|
|
378
|
+
#define IGOR 2
|
|
379
|
+
#define MULTIDIRECTIONAL 3
|
|
380
|
+
#define BASIC 4
|
|
381
|
+
float 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
|
|
382
|
+
{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
|
|
383
|
+
{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);}
|
|
384
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
385
|
+
fragColor=vec4(1.0);
|
|
386
|
+
#endif
|
|
387
|
+
}`,"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:je(`uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;
|
|
388
|
+
#ifdef GLOBE
|
|
389
|
+
in float v_depth;
|
|
390
|
+
#endif
|
|
391
|
+
#pragma mapbox: define highp vec4 color
|
|
392
|
+
#pragma mapbox: define lowp float blur
|
|
393
|
+
#pragma mapbox: define lowp float opacity
|
|
394
|
+
void main() {
|
|
395
|
+
#pragma mapbox: initialize highp vec4 color
|
|
396
|
+
#pragma mapbox: initialize lowp float blur
|
|
397
|
+
#pragma mapbox: initialize lowp float opacity
|
|
398
|
+
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);fragColor=color*(alpha*opacity);
|
|
399
|
+
#ifdef GLOBE
|
|
400
|
+
if (v_depth > 1.0) {discard;}
|
|
401
|
+
#endif
|
|
402
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
403
|
+
fragColor=vec4(1.0);
|
|
404
|
+
#endif
|
|
405
|
+
}`,`
|
|
406
|
+
#define scale 0.015873016
|
|
407
|
+
in 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;
|
|
408
|
+
#ifdef GLOBE
|
|
409
|
+
out float v_depth;
|
|
410
|
+
#endif
|
|
411
|
+
#pragma mapbox: define highp vec4 color
|
|
412
|
+
#pragma mapbox: define lowp float blur
|
|
413
|
+
#pragma mapbox: define lowp float opacity
|
|
414
|
+
#pragma mapbox: define mediump float gapwidth
|
|
415
|
+
#pragma mapbox: define lowp float offset
|
|
416
|
+
#pragma mapbox: define mediump float width
|
|
417
|
+
void main() {
|
|
418
|
+
#pragma mapbox: initialize highp vec4 color
|
|
419
|
+
#pragma mapbox: initialize lowp float blur
|
|
420
|
+
#pragma mapbox: initialize lowp float opacity
|
|
421
|
+
#pragma mapbox: initialize mediump float gapwidth
|
|
422
|
+
#pragma mapbox: initialize lowp float offset
|
|
423
|
+
#pragma mapbox: initialize mediump float width
|
|
424
|
+
float 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;
|
|
425
|
+
#ifdef GLOBE
|
|
426
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
427
|
+
#endif
|
|
428
|
+
#ifdef TERRAIN3D
|
|
429
|
+
v_gamma_scale=1.0;
|
|
430
|
+
#else
|
|
431
|
+
float 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;
|
|
432
|
+
#endif
|
|
433
|
+
v_width2=vec2(outset,inset);}`),lineGradient:je(`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;
|
|
434
|
+
#ifdef GLOBE
|
|
435
|
+
in float v_depth;
|
|
436
|
+
#endif
|
|
437
|
+
#pragma mapbox: define lowp float blur
|
|
438
|
+
#pragma mapbox: define lowp float opacity
|
|
439
|
+
void main() {
|
|
440
|
+
#pragma mapbox: initialize lowp float blur
|
|
441
|
+
#pragma mapbox: initialize lowp float opacity
|
|
442
|
+
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);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);
|
|
443
|
+
#ifdef GLOBE
|
|
444
|
+
if (v_depth > 1.0) {discard;}
|
|
445
|
+
#endif
|
|
446
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
447
|
+
fragColor=vec4(1.0);
|
|
448
|
+
#endif
|
|
449
|
+
}`,`
|
|
450
|
+
#define scale 0.015873016
|
|
451
|
+
in 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;
|
|
452
|
+
#ifdef GLOBE
|
|
453
|
+
out float v_depth;
|
|
454
|
+
#endif
|
|
455
|
+
#pragma mapbox: define lowp float blur
|
|
456
|
+
#pragma mapbox: define lowp float opacity
|
|
457
|
+
#pragma mapbox: define mediump float gapwidth
|
|
458
|
+
#pragma mapbox: define lowp float offset
|
|
459
|
+
#pragma mapbox: define mediump float width
|
|
460
|
+
void main() {
|
|
461
|
+
#pragma mapbox: initialize lowp float blur
|
|
462
|
+
#pragma mapbox: initialize lowp float opacity
|
|
463
|
+
#pragma mapbox: initialize mediump float gapwidth
|
|
464
|
+
#pragma mapbox: initialize lowp float offset
|
|
465
|
+
#pragma mapbox: initialize mediump float width
|
|
466
|
+
float 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;
|
|
467
|
+
#ifdef GLOBE
|
|
468
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
469
|
+
#endif
|
|
470
|
+
#ifdef TERRAIN3D
|
|
471
|
+
v_gamma_scale=1.0;
|
|
472
|
+
#else
|
|
473
|
+
float 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;
|
|
474
|
+
#endif
|
|
475
|
+
v_width2=vec2(outset,inset);}`),linePattern:je(`#ifdef GL_ES
|
|
476
|
+
precision highp float;
|
|
477
|
+
#endif
|
|
478
|
+
uniform 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;
|
|
479
|
+
#ifdef GLOBE
|
|
480
|
+
in float v_depth;
|
|
481
|
+
#endif
|
|
482
|
+
#pragma mapbox: define lowp vec4 pattern_from
|
|
483
|
+
#pragma mapbox: define lowp vec4 pattern_to
|
|
484
|
+
#pragma mapbox: define lowp float pixel_ratio_from
|
|
485
|
+
#pragma mapbox: define lowp float pixel_ratio_to
|
|
486
|
+
#pragma mapbox: define lowp float blur
|
|
487
|
+
#pragma mapbox: define lowp float opacity
|
|
488
|
+
void main() {
|
|
489
|
+
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
490
|
+
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
491
|
+
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
492
|
+
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
493
|
+
#pragma mapbox: initialize lowp float blur
|
|
494
|
+
#pragma mapbox: initialize lowp float opacity
|
|
495
|
+
vec2 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;
|
|
496
|
+
#ifdef GLOBE
|
|
497
|
+
if (v_depth > 1.0) {discard;}
|
|
498
|
+
#endif
|
|
499
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
500
|
+
fragColor=vec4(1.0);
|
|
501
|
+
#endif
|
|
502
|
+
}`,`
|
|
503
|
+
#define scale 0.015873016
|
|
504
|
+
#define LINE_DISTANCE_SCALE 2.0
|
|
505
|
+
in 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;
|
|
506
|
+
#ifdef GLOBE
|
|
507
|
+
out float v_depth;
|
|
508
|
+
#endif
|
|
509
|
+
#pragma mapbox: define lowp float blur
|
|
510
|
+
#pragma mapbox: define lowp float opacity
|
|
511
|
+
#pragma mapbox: define lowp float offset
|
|
512
|
+
#pragma mapbox: define mediump float gapwidth
|
|
513
|
+
#pragma mapbox: define mediump float width
|
|
514
|
+
#pragma mapbox: define lowp float floorwidth
|
|
515
|
+
#pragma mapbox: define lowp vec4 pattern_from
|
|
516
|
+
#pragma mapbox: define lowp vec4 pattern_to
|
|
517
|
+
#pragma mapbox: define lowp float pixel_ratio_from
|
|
518
|
+
#pragma mapbox: define lowp float pixel_ratio_to
|
|
519
|
+
void main() {
|
|
520
|
+
#pragma mapbox: initialize lowp float blur
|
|
521
|
+
#pragma mapbox: initialize lowp float opacity
|
|
522
|
+
#pragma mapbox: initialize lowp float offset
|
|
523
|
+
#pragma mapbox: initialize mediump float gapwidth
|
|
524
|
+
#pragma mapbox: initialize mediump float width
|
|
525
|
+
#pragma mapbox: initialize lowp float floorwidth
|
|
526
|
+
#pragma mapbox: initialize mediump vec4 pattern_from
|
|
527
|
+
#pragma mapbox: initialize mediump vec4 pattern_to
|
|
528
|
+
#pragma mapbox: initialize lowp float pixel_ratio_from
|
|
529
|
+
#pragma mapbox: initialize lowp float pixel_ratio_to
|
|
530
|
+
float 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;
|
|
531
|
+
#ifdef GLOBE
|
|
532
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
533
|
+
#endif
|
|
534
|
+
#ifdef TERRAIN3D
|
|
535
|
+
v_gamma_scale=1.0;
|
|
536
|
+
#else
|
|
537
|
+
float 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;
|
|
538
|
+
#endif
|
|
539
|
+
v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:je(`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;
|
|
540
|
+
#ifdef GLOBE
|
|
541
|
+
in float v_depth;
|
|
542
|
+
#endif
|
|
543
|
+
#pragma mapbox: define highp vec4 color
|
|
544
|
+
#pragma mapbox: define lowp float blur
|
|
545
|
+
#pragma mapbox: define lowp float opacity
|
|
546
|
+
#pragma mapbox: define mediump float width
|
|
547
|
+
#pragma mapbox: define lowp float floorwidth
|
|
548
|
+
#pragma mapbox: define mediump vec4 dasharray_from
|
|
549
|
+
#pragma mapbox: define mediump vec4 dasharray_to
|
|
550
|
+
void main() {
|
|
551
|
+
#pragma mapbox: initialize highp vec4 color
|
|
552
|
+
#pragma mapbox: initialize lowp float blur
|
|
553
|
+
#pragma mapbox: initialize lowp float opacity
|
|
554
|
+
#pragma mapbox: initialize mediump float width
|
|
555
|
+
#pragma mapbox: initialize lowp float floorwidth
|
|
556
|
+
#pragma mapbox: initialize mediump vec4 dasharray_from
|
|
557
|
+
#pragma mapbox: initialize mediump vec4 dasharray_to
|
|
558
|
+
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 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);
|
|
559
|
+
#ifdef GLOBE
|
|
560
|
+
if (v_depth > 1.0) {discard;}
|
|
561
|
+
#endif
|
|
562
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
563
|
+
fragColor=vec4(1.0);
|
|
564
|
+
#endif
|
|
565
|
+
}`,`
|
|
566
|
+
#define scale 0.015873016
|
|
567
|
+
#define LINE_DISTANCE_SCALE 2.0
|
|
568
|
+
in 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;
|
|
569
|
+
#ifdef GLOBE
|
|
570
|
+
out float v_depth;
|
|
571
|
+
#endif
|
|
572
|
+
#pragma mapbox: define highp vec4 color
|
|
573
|
+
#pragma mapbox: define lowp float blur
|
|
574
|
+
#pragma mapbox: define lowp float opacity
|
|
575
|
+
#pragma mapbox: define mediump float gapwidth
|
|
576
|
+
#pragma mapbox: define lowp float offset
|
|
577
|
+
#pragma mapbox: define mediump float width
|
|
578
|
+
#pragma mapbox: define lowp float floorwidth
|
|
579
|
+
#pragma mapbox: define mediump vec4 dasharray_from
|
|
580
|
+
#pragma mapbox: define mediump vec4 dasharray_to
|
|
581
|
+
void main() {
|
|
582
|
+
#pragma mapbox: initialize highp vec4 color
|
|
583
|
+
#pragma mapbox: initialize lowp float blur
|
|
584
|
+
#pragma mapbox: initialize lowp float opacity
|
|
585
|
+
#pragma mapbox: initialize mediump float gapwidth
|
|
586
|
+
#pragma mapbox: initialize lowp float offset
|
|
587
|
+
#pragma mapbox: initialize mediump float width
|
|
588
|
+
#pragma mapbox: initialize lowp float floorwidth
|
|
589
|
+
#pragma mapbox: initialize mediump vec4 dasharray_from
|
|
590
|
+
#pragma mapbox: initialize mediump vec4 dasharray_to
|
|
591
|
+
float 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;
|
|
592
|
+
#ifdef GLOBE
|
|
593
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
594
|
+
#endif
|
|
595
|
+
#ifdef TERRAIN3D
|
|
596
|
+
v_gamma_scale=1.0;
|
|
597
|
+
#else
|
|
598
|
+
float 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;
|
|
599
|
+
#endif
|
|
600
|
+
float 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:je(`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;
|
|
601
|
+
#ifdef GLOBE
|
|
602
|
+
in float v_depth;
|
|
603
|
+
#endif
|
|
604
|
+
#pragma mapbox: define lowp float blur
|
|
605
|
+
#pragma mapbox: define lowp float opacity
|
|
606
|
+
#pragma mapbox: define mediump float width
|
|
607
|
+
#pragma mapbox: define lowp float floorwidth
|
|
608
|
+
#pragma mapbox: define mediump vec4 dasharray_from
|
|
609
|
+
#pragma mapbox: define mediump vec4 dasharray_to
|
|
610
|
+
void main() {
|
|
611
|
+
#pragma mapbox: initialize lowp float blur
|
|
612
|
+
#pragma mapbox: initialize lowp float opacity
|
|
613
|
+
#pragma mapbox: initialize mediump float width
|
|
614
|
+
#pragma mapbox: initialize lowp float floorwidth
|
|
615
|
+
#pragma mapbox: initialize mediump vec4 dasharray_from
|
|
616
|
+
#pragma mapbox: initialize mediump vec4 dasharray_to
|
|
617
|
+
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);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);
|
|
618
|
+
#ifdef GLOBE
|
|
619
|
+
if (v_depth > 1.0) {discard;}
|
|
620
|
+
#endif
|
|
621
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
622
|
+
fragColor=vec4(1.0);
|
|
623
|
+
#endif
|
|
624
|
+
}`,`
|
|
625
|
+
#define scale 0.015873016
|
|
626
|
+
#define LINE_DISTANCE_SCALE 2.0
|
|
627
|
+
in 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;
|
|
628
|
+
#ifdef GLOBE
|
|
629
|
+
out float v_depth;
|
|
630
|
+
#endif
|
|
631
|
+
#pragma mapbox: define lowp float blur
|
|
632
|
+
#pragma mapbox: define lowp float opacity
|
|
633
|
+
#pragma mapbox: define mediump float gapwidth
|
|
634
|
+
#pragma mapbox: define lowp float offset
|
|
635
|
+
#pragma mapbox: define mediump float width
|
|
636
|
+
#pragma mapbox: define lowp float floorwidth
|
|
637
|
+
#pragma mapbox: define mediump vec4 dasharray_from
|
|
638
|
+
#pragma mapbox: define mediump vec4 dasharray_to
|
|
639
|
+
void main() {
|
|
640
|
+
#pragma mapbox: initialize lowp float blur
|
|
641
|
+
#pragma mapbox: initialize lowp float opacity
|
|
642
|
+
#pragma mapbox: initialize mediump float gapwidth
|
|
643
|
+
#pragma mapbox: initialize lowp float offset
|
|
644
|
+
#pragma mapbox: initialize mediump float width
|
|
645
|
+
#pragma mapbox: initialize lowp float floorwidth
|
|
646
|
+
#pragma mapbox: initialize mediump vec4 dasharray_from
|
|
647
|
+
#pragma mapbox: initialize mediump vec4 dasharray_to
|
|
648
|
+
float 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;
|
|
649
|
+
#ifdef GLOBE
|
|
650
|
+
v_depth=gl_Position.z/gl_Position.w;
|
|
651
|
+
#endif
|
|
652
|
+
#ifdef TERRAIN3D
|
|
653
|
+
v_gamma_scale=1.0;
|
|
654
|
+
#else
|
|
655
|
+
float 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;
|
|
656
|
+
#endif
|
|
657
|
+
float 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:je(`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);
|
|
658
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
659
|
+
fragColor=vec4(1.0);
|
|
660
|
+
#endif
|
|
661
|
+
}`,`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;
|
|
662
|
+
#ifdef GLOBE
|
|
663
|
+
if (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}
|
|
664
|
+
#endif
|
|
665
|
+
v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}`),symbolIcon:je(`uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity;
|
|
666
|
+
#pragma mapbox: define lowp float opacity
|
|
667
|
+
void main() {
|
|
668
|
+
#pragma mapbox: initialize lowp float opacity
|
|
669
|
+
lowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha;
|
|
670
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
671
|
+
fragColor=vec4(1.0);
|
|
672
|
+
#endif
|
|
673
|
+
}`,`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;
|
|
674
|
+
#pragma mapbox: define lowp float opacity
|
|
675
|
+
void main() {
|
|
676
|
+
#pragma mapbox: initialize lowp float opacity
|
|
677
|
+
vec2 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 ?
|
|
678
|
+
camera_to_anchor_distance/u_camera_to_center_distance :
|
|
679
|
+
u_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;
|
|
680
|
+
#ifdef GLOBE
|
|
681
|
+
if(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);}
|
|
682
|
+
#endif
|
|
683
|
+
vec4 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:je(`#define SDF_PX 8.0
|
|
684
|
+
uniform 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;
|
|
685
|
+
#pragma mapbox: define highp vec4 fill_color
|
|
686
|
+
#pragma mapbox: define highp vec4 halo_color
|
|
687
|
+
#pragma mapbox: define lowp float opacity
|
|
688
|
+
#pragma mapbox: define lowp float halo_width
|
|
689
|
+
#pragma mapbox: define lowp float halo_blur
|
|
690
|
+
void main() {
|
|
691
|
+
#pragma mapbox: initialize highp vec4 fill_color
|
|
692
|
+
#pragma mapbox: initialize highp vec4 halo_color
|
|
693
|
+
#pragma mapbox: initialize lowp float opacity
|
|
694
|
+
#pragma mapbox: initialize lowp float halo_width
|
|
695
|
+
#pragma mapbox: initialize lowp float halo_blur
|
|
696
|
+
float 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);
|
|
697
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
698
|
+
fragColor=vec4(1.0);
|
|
699
|
+
#endif
|
|
700
|
+
}`,`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;
|
|
701
|
+
#pragma mapbox: define highp vec4 fill_color
|
|
702
|
+
#pragma mapbox: define highp vec4 halo_color
|
|
703
|
+
#pragma mapbox: define lowp float opacity
|
|
704
|
+
#pragma mapbox: define lowp float halo_width
|
|
705
|
+
#pragma mapbox: define lowp float halo_blur
|
|
706
|
+
void main() {
|
|
707
|
+
#pragma mapbox: initialize highp vec4 fill_color
|
|
708
|
+
#pragma mapbox: initialize highp vec4 halo_color
|
|
709
|
+
#pragma mapbox: initialize lowp float opacity
|
|
710
|
+
#pragma mapbox: initialize lowp float halo_width
|
|
711
|
+
#pragma mapbox: initialize lowp float halo_blur
|
|
712
|
+
vec2 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/16.0;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 ?
|
|
713
|
+
camera_to_anchor_distance/u_camera_to_center_distance :
|
|
714
|
+
u_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;
|
|
715
|
+
#ifdef GLOBE
|
|
716
|
+
if(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);}
|
|
717
|
+
#endif
|
|
718
|
+
vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,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:je(`#define SDF_PX 8.0
|
|
719
|
+
#define SDF 1.0
|
|
720
|
+
#define ICON 0.0
|
|
721
|
+
uniform 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;
|
|
722
|
+
#pragma mapbox: define highp vec4 fill_color
|
|
723
|
+
#pragma mapbox: define highp vec4 halo_color
|
|
724
|
+
#pragma mapbox: define lowp float opacity
|
|
725
|
+
#pragma mapbox: define lowp float halo_width
|
|
726
|
+
#pragma mapbox: define lowp float halo_blur
|
|
727
|
+
void main() {
|
|
728
|
+
#pragma mapbox: initialize highp vec4 fill_color
|
|
729
|
+
#pragma mapbox: initialize highp vec4 halo_color
|
|
730
|
+
#pragma mapbox: initialize lowp float opacity
|
|
731
|
+
#pragma mapbox: initialize lowp float halo_width
|
|
732
|
+
#pragma mapbox: initialize lowp float halo_blur
|
|
733
|
+
float 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;
|
|
734
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
735
|
+
fragColor=vec4(1.0);
|
|
736
|
+
#endif
|
|
737
|
+
return;}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);
|
|
738
|
+
#ifdef OVERDRAW_INSPECTOR
|
|
739
|
+
fragColor=vec4(1.0);
|
|
740
|
+
#endif
|
|
741
|
+
}`,`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;
|
|
742
|
+
#pragma mapbox: define highp vec4 fill_color
|
|
743
|
+
#pragma mapbox: define highp vec4 halo_color
|
|
744
|
+
#pragma mapbox: define lowp float opacity
|
|
745
|
+
#pragma mapbox: define lowp float halo_width
|
|
746
|
+
#pragma mapbox: define lowp float halo_blur
|
|
747
|
+
void main() {
|
|
748
|
+
#pragma mapbox: initialize highp vec4 fill_color
|
|
749
|
+
#pragma mapbox: initialize highp vec4 halo_color
|
|
750
|
+
#pragma mapbox: initialize lowp float opacity
|
|
751
|
+
#pragma mapbox: initialize lowp float halo_width
|
|
752
|
+
#pragma mapbox: initialize lowp float halo_blur
|
|
753
|
+
vec2 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 ?
|
|
754
|
+
camera_to_anchor_distance/u_camera_to_center_distance :
|
|
755
|
+
u_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;
|
|
756
|
+
#ifdef GLOBE
|
|
757
|
+
if(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);}
|
|
758
|
+
#endif
|
|
759
|
+
vec4 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:je("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:je("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:je("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:je("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:je(`#ifdef GL_ES
|
|
760
|
+
precision highp float;
|
|
761
|
+
#endif
|
|
762
|
+
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
|
|
763
|
+
);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:je("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 je(d,t){const n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,o=t.match(/in ([\w]+) ([\w]+)/g),l=d.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),p=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),m=p?p.concat(l):l,_={};return{fragmentSource:d=d.replace(n,((v,w,T,C,M)=>(_[M]=!0,w==="define"?`
|
|
764
|
+
#ifndef HAS_UNIFORM_u_${M}
|
|
765
|
+
in ${T} ${C} ${M};
|
|
766
|
+
#else
|
|
767
|
+
uniform ${T} ${C} u_${M};
|
|
768
|
+
#endif
|
|
769
|
+
`:`
|
|
770
|
+
#ifdef HAS_UNIFORM_u_${M}
|
|
771
|
+
${T} ${C} ${M} = u_${M};
|
|
772
|
+
#endif
|
|
773
|
+
`))),vertexSource:t=t.replace(n,((v,w,T,C,M)=>{const z=C==="float"?"vec2":"vec4",R=M.match(/color/)?"color":z;return _[M]?w==="define"?`
|
|
774
|
+
#ifndef HAS_UNIFORM_u_${M}
|
|
775
|
+
uniform lowp float u_${M}_t;
|
|
776
|
+
in ${T} ${z} a_${M};
|
|
777
|
+
out ${T} ${C} ${M};
|
|
778
|
+
#else
|
|
779
|
+
uniform ${T} ${C} u_${M};
|
|
780
|
+
#endif
|
|
781
|
+
`:R==="vec4"?`
|
|
782
|
+
#ifndef HAS_UNIFORM_u_${M}
|
|
783
|
+
${M} = a_${M};
|
|
784
|
+
#else
|
|
785
|
+
${T} ${C} ${M} = u_${M};
|
|
786
|
+
#endif
|
|
787
|
+
`:`
|
|
788
|
+
#ifndef HAS_UNIFORM_u_${M}
|
|
789
|
+
${M} = unpack_mix_${R}(a_${M}, u_${M}_t);
|
|
790
|
+
#else
|
|
791
|
+
${T} ${C} ${M} = u_${M};
|
|
792
|
+
#endif
|
|
793
|
+
`:w==="define"?`
|
|
794
|
+
#ifndef HAS_UNIFORM_u_${M}
|
|
795
|
+
uniform lowp float u_${M}_t;
|
|
796
|
+
in ${T} ${z} a_${M};
|
|
797
|
+
#else
|
|
798
|
+
uniform ${T} ${C} u_${M};
|
|
799
|
+
#endif
|
|
800
|
+
`:R==="vec4"?`
|
|
801
|
+
#ifndef HAS_UNIFORM_u_${M}
|
|
802
|
+
${T} ${C} ${M} = a_${M};
|
|
803
|
+
#else
|
|
804
|
+
${T} ${C} ${M} = u_${M};
|
|
805
|
+
#endif
|
|
806
|
+
`:`
|
|
807
|
+
#ifndef HAS_UNIFORM_u_${M}
|
|
808
|
+
${T} ${C} ${M} = unpack_mix_${R}(a_${M}, u_${M}_t);
|
|
809
|
+
#else
|
|
810
|
+
${T} ${C} ${M} = u_${M};
|
|
811
|
+
#endif
|
|
812
|
+
`})),staticAttributes:o,staticUniforms:m}}class cs{constructor(t,n,o){this.vertexBuffer=t,this.indexBuffer=n,this.segments=o}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Wt=c.aU([{name:"a_pos",type:"Int16",components:2}]);const Gi="#define PROJECTION_MERCATOR",Ri="mercator";class Oo{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return Ri}get shaderDefine(){return Gi}get shaderPreludeCode(){return Pt.projectionMercator}get vertexShaderPreludeCode(){return Pt.projectionMercator.vertexSource}get subdivisionGranularity(){return c.aV.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(t){}getMeshFromTileID(t,n,o,l,p){if(this._cachedMesh)return this._cachedMesh;const m=new c.aW;m.emplaceBack(0,0),m.emplaceBack(c.a5,0),m.emplaceBack(0,c.a5),m.emplaceBack(c.a5,c.a5);const _=t.createVertexBuffer(m,Wt.members),v=c.aX.simpleSegment(0,0,4,2),w=new c.aY;w.emplaceBack(1,0,2),w.emplaceBack(1,2,3);const T=t.createIndexBuffer(w);return this._cachedMesh=new cs(_,T,v),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(t){}}class Nr{constructor(t=0,n=0,o=0,l=0){if(isNaN(t)||t<0||isNaN(n)||n<0||isNaN(o)||o<0||isNaN(l)||l<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=n,this.left=o,this.right=l}interpolate(t,n,o){return n.top!=null&&t.top!=null&&(this.top=c.G.number(t.top,n.top,o)),n.bottom!=null&&t.bottom!=null&&(this.bottom=c.G.number(t.bottom,n.bottom,o)),n.left!=null&&t.left!=null&&(this.left=c.G.number(t.left,n.left,o)),n.right!=null&&t.right!=null&&(this.right=c.G.number(t.right,n.right,o)),this}getCenter(t,n){const o=c.an((this.left+t-this.right)/2,0,t),l=c.an((this.top+n-this.bottom)/2,0,n);return new c.P(o,l)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Nr(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function zt(d,t){if(!d.renderWorldCopies||d.lngRange)return;const n=t.lng-d.center.lng;t.lng+=n>180?-360:n<-180?360:0}function us(d){return Math.max(0,Math.floor(d))}class jr{constructor(t,n){var o;this.applyConstrain=(l,p)=>this._constrainOverride!==null?this._constrainOverride(l,p):this._callbacks.defaultConstrain(l,p),this._callbacks=t,this._tileSize=512,this._renderWorldCopies=n?.renderWorldCopies===void 0||!!n?.renderWorldCopies,this._minZoom=n?.minZoom||0,this._maxZoom=n?.maxZoom||22,this._minPitch=n?.minPitch==null?0:n?.minPitch,this._maxPitch=n?.maxPitch==null?60:n?.maxPitch,this._constrainOverride=(o=n?.constrainOverride)!==null&&o!==void 0?o:null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new c.V(0,0),this._elevation=0,this._zoom=0,this._tileZoom=us(this._zoom),this._scale=c.aq(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Nr,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(t,n,o){this._constrainOverride=t.constrainOverride,this._latRange=t.latRange,this._lngRange=t.lngRange,this._width=t.width,this._height=t.height,this._center=t.center,this._elevation=t.elevation,this._minElevationForCurrentTile=t.minElevationForCurrentTile,this._zoom=t.zoom,this._tileZoom=us(this._zoom),this._scale=c.aq(this._zoom),this._bearingInRadians=t.bearingInRadians,this._fovInRadians=t.fovInRadians,this._pitchInRadians=t.pitchInRadians,this._rollInRadians=t.rollInRadians,this._unmodified=t.unmodified,this._edgeInsets=new Nr(t.padding.top,t.padding.bottom,t.padding.left,t.padding.right),this._minZoom=t.minZoom,this._maxZoom=t.maxZoom,this._minPitch=t.minPitch,this._maxPitch=t.maxPitch,this._renderWorldCopies=t.renderWorldCopies,this._cameraToCenterDistance=t.cameraToCenterDistance,this._nearZ=t.nearZ,this._farZ=t.farZ,this._autoCalculateNearFarZ=!o&&t.autoCalculateNearFarZ,n&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(t){this._minElevationForCurrentTile=t}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(t){this._minZoom!==t&&(this._minZoom=t,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(t){this._minPitch!==t&&(this._minPitch=t,this.setPitch(Math.max(this.pitch,t)))}get maxPitch(){return this._maxPitch}setMaxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.setPitch(Math.min(this.pitch,t)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(t){t===void 0?t=!0:t===null&&(t=!1),this._renderWorldCopies=t}get constrainOverride(){return this._constrainOverride}setConstrainOverride(t){t===void 0&&(t=null),this._constrainOverride!==t&&(this._constrainOverride=t,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 c.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(t){const n=c.W(t,-180,180)*Math.PI/180;var o,l,p,m,_,v,w,T,C;this._bearingInRadians!==n&&(this._unmodified=!1,this._bearingInRadians=n,this._calcMatrices(),this._rotationMatrix=_t(),o=this._rotationMatrix,p=-this._bearingInRadians,m=(l=this._rotationMatrix)[0],_=l[1],v=l[2],w=l[3],T=Math.sin(p),C=Math.cos(p),o[0]=m*C+v*T,o[1]=_*C+w*T,o[2]=m*-T+v*C,o[3]=_*-T+w*C)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(t){const n=c.an(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==n&&(this._unmodified=!1,this._pitchInRadians=n,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(t){const n=t/180*Math.PI;this._rollInRadians!==n&&(this._unmodified=!1,this._rollInRadians=n,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return c.aZ(this._fovInRadians)}setFov(t){t=c.an(t,.1,150),this.fov!==t&&(this._unmodified=!1,this._fovInRadians=c.ap(t),this._calcMatrices())}get zoom(){return this._zoom}setZoom(t){const n=this.applyConstrain(this._center,t).zoom;this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this._tileZoom=Math.max(0,Math.floor(n)),this._scale=c.aq(n),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(t){t!==this._elevation&&(this._elevation=t,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,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(t,n){this._autoCalculateNearFarZ=!1,this._nearZ=t,this._farZ=n,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,n,o){this._unmodified=!1,this._edgeInsets.interpolate(t,n,o),this.constrainInternal(),this._calcMatrices()}resize(t,n,o=!0){this._width=t,this._height=n,o&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return this._latRange&&this._latRange.length===2&&this._lngRange&&this._lngRange.length===2?new Mt([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(t){t?(this._lngRange=[t.getWest(),t.getEast()],this._latRange=[t.getSouth(),t.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-c.ao,c.ao])}getCameraQueryGeometry(t,n){if(n.length===1)return[n[0],t];{const{minX:o,minY:l,maxX:p,maxY:m}=c.aa.fromPoints(n).extend(t);return[new c.P(o,l),new c.P(p,l),new c.P(p,m),new c.P(o,m),new c.P(o,l)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const t=this._unmodified,{center:n,zoom:o}=this.applyConstrain(this.center,this.zoom);this.setCenter(n),this.setZoom(o),this._unmodified=t,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let t=c.ar(new Float64Array(16));c.Q(t,t,[this._width/2,-this._height/2,1]),c.O(t,t,[1,-1,0]),this._clipSpaceToPixelsMatrix=t,t=c.ar(new Float64Array(16)),c.Q(t,t,[1,-1,1]),c.O(t,t,[-1,-1,0]),c.Q(t,t,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=t,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(t,n,o,l){const p=o!==void 0?o:this.bearing,m=l=l!==void 0?l:this.pitch,{distanceToCenter:_,clampedElevation:v}=this._distanceToCenterFromAltElevationPitch(n,this.elevation,m),{x:w,y:T}=We(m,p),C=c.a9.fromLngLat(t,n);let M,z,R=c.a_(1,C.y),N=0;do{if(N+=1,N>10)break;z=_/R,M=new c.a9(C.x+w*z,C.y+T*z),R=1/M.meterInMercatorCoordinateUnits()}while(Math.abs(_-z*R)>1e-12);return{center:M.toLngLat(),elevation:v,zoom:c.at(this.height/2/Math.tan(this.fovInRadians/2)/z/this.tileSize)}}recalculateZoomAndCenter(t){if(this.elevation-t==0)return;const n=1/this.worldSize,o=c.as(1,this.center.lat)*this.worldSize,l=c.a9.fromLngLat(this.center,this.elevation),p=l.x/n,m=l.y/n,_=l.z/n,v=this.pitch,w=this.bearing,{x:T,y:C,z:M}=We(v,w),z=this.cameraToCenterDistance,R=p+z*-T,N=m+z*-C,U=_+z*M,{distanceToCenter:j,clampedElevation:Z}=this._distanceToCenterFromAltElevationPitch(U/o,t,v),X=j*o,q=new c.a9((R+T*X)*n,(N+C*X)*n,0).toLngLat(),Y=c.as(1,q.lat),Q=c.at(this.height/2/Math.tan(this.fovInRadians/2)/j/Y/this.tileSize);this._elevation=Z,this._center=q,this.setZoom(Q)}_distanceToCenterFromAltElevationPitch(t,n,o){const l=-Math.cos(c.ap(o)),p=t-n;let m,_=n;return l*p>=0||Math.abs(l)<.1?(m=1e4,_=t+m*l):m=-p/l,{distanceToCenter:m,clampedElevation:_}}getCameraPoint(){const t=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new c.P(t*Math.sin(this.rollInRadians),t*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const t=c.as(1,this.center.lat)*this.worldSize;return Oe(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/t).toLngLat()}getMercatorTileCoordinates(t){if(!t)return[0,0,1,1];const n=t.canonical.z>=0?1<<t.canonical.z:Math.pow(2,t.canonical.z);return[t.canonical.x/n,t.canonical.y/n,1/n/c.a5,1/n/c.a5]}}class zn{constructor(t,n){this.min=t,this.max=n,this.center=c.a$([],c.b0([],this.min,this.max),.5)}quadrant(t){const n=[t%2==0,t<2],o=c.b1(this.min),l=c.b1(this.max);for(let p=0;p<n.length;p++)o[p]=n[p]?this.min[p]:this.center[p],l[p]=n[p]?this.center[p]:this.max[p];return l[2]=this.max[2],new zn(o,l)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}intersectsFrustum(t){let n=!0;for(let o=0;o<t.planes.length;o++){const l=this.intersectsPlane(t.planes[o]);if(l===0)return 0;l===1&&(n=!1)}return n?2:t.aabb.min[0]>this.max[0]||t.aabb.min[1]>this.max[1]||t.aabb.min[2]>this.max[2]||t.aabb.max[0]<this.min[0]||t.aabb.max[1]<this.min[1]||t.aabb.max[2]<this.min[2]?0:1}intersectsPlane(t){let n=t[3],o=t[3];for(let l=0;l<3;l++)t[l]>0?(n+=t[l]*this.min[l],o+=t[l]*this.max[l]):(o+=t[l]*this.min[l],n+=t[l]*this.max[l]);return n>=0?2:o<0?0:1}}class fr{distanceToTile2d(t,n,o,l){const p=l.distanceX([t,n]),m=l.distanceY([t,n]);return Math.hypot(p,m)}getWrap(t,n,o){return o}getTileBoundingVolume(t,n,o,l){var p,m;let _=0,v=0;if(l?.terrain){const T=new c.a2(t.z,n,t.z,t.x,t.y),C=l.terrain.getMinMaxElevation(T);_=(p=C.minElevation)!==null&&p!==void 0?p:Math.min(0,o),v=(m=C.maxElevation)!==null&&m!==void 0?m:Math.max(0,o)}const w=1<<t.z;return new zn([n+t.x/w,t.y/w,_],[n+(t.x+1)/w,(t.y+1)/w,v])}allowVariableZoom(t,n){const o=t.fov*(Math.abs(Math.cos(t.rollInRadians))*t.height+Math.abs(Math.sin(t.rollInRadians))*t.width)/t.height,l=c.an(78.5-o/2,0,60);return!!n.terrain||t.pitch>l}allowWorldCopies(){return!0}prepareNextFrame(){}}class Us{constructor(t,n,o){this.points=t,this.planes=n,this.aabb=o}static fromInvProjectionMatrix(t,n=1,o=0,l,p){const m=p?[[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]],_=Math.pow(2,o),v=[[-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((M=>(function(z,R,N,U){const j=c.aH([],z,R),Z=1/j[3]/N*U;return c.b6(j,j,[Z,Z,1/j[3],Z])})(M,t,n,_)));l&&(function(M,z,R,N){const U=N?4:0,j=N?0:4;let Z=0;const X=[],q=[];for(let H=0;H<4;H++){const te=c.b2([],M[H+j],M[H+U]),de=c.b7(te);c.a$(te,te,1/de),X.push(de),q.push(te)}for(let H=0;H<4;H++){const te=c.b8(M[H+U],q[H],R);Z=te!==null&&te>=0?Math.max(Z,te):Math.max(Z,X[H])}const Y=(function(H,te){const de=c.b2([],H[te[0]],H[te[1]]),ue=c.b2([],H[te[2]],H[te[1]]),ce=[0,0,0,0];return c.b3(ce,c.b4([],de,ue)),ce[3]=-c.b5(ce,H[te[0]]),ce})(M,z),Q=(function(H,te){const de=c.b9(H),ue=c.ba([],H,1/de),ce=c.b2([],te,c.a$([],ue,c.b5(te,ue))),he=c.b9(ce);if(he>0){const Ce=Math.sqrt(1-ue[3]*ue[3]),Ie=c.a$([],ue,-ue[3]),ge=c.b0([],Ie,c.a$([],ce,Ce/he));return c.bb(te,ge)}return null})(R,Y);if(Q!==null){const H=Q/c.b5(q[0],Y);Z=Math.min(Z,H)}for(let H=0;H<4;H++){const te=Math.min(Z,X[H]);M[H+j]=[M[H+U][0]+q[H][0]*te,M[H+U][1]+q[H][1]*te,M[H+U][2]+q[H][2]*te,1]}})(v,m[0],l,p);const w=m.map((M=>{const z=c.b2([],v[M[0]],v[M[1]]),R=c.b2([],v[M[2]],v[M[1]]),N=c.b3([],c.b4([],z,R)),U=-c.b5(N,v[M[1]]);return N.concat(U)})),T=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],C=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const M of v)for(let z=0;z<3;z++)T[z]=Math.min(T[z],M[z]),C[z]=Math.max(C[z],M[z]);return new Us(v,w,new zn(T,C))}}class qi{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(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,n,o){return this._helper.interpolatePadding(t,n,o)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,n,o=!0){this._helper.resize(t,n,o)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,n){this._helper.overrideNearFarZ(t,n)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}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(t,n){}constructor(t){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(n,o)=>{o=c.an(+o,this.minZoom,this.maxZoom);const l={center:new c.V(n.lng,n.lat),zoom:o};let p=this._helper._lngRange;if(!this._helper._renderWorldCopies&&p===null){const q=179.9999999999;p=[-q,q]}const m=this.tileSize*c.aq(l.zoom);let _=0,v=m,w=0,T=m,C=0,M=0;const{x:z,y:R}=this.size;if(this._helper._latRange){const q=this._helper._latRange;_=c.X(q[1])*m,v=c.X(q[0])*m,v-_<R&&(C=R/(v-_))}p&&(w=c.W(c.Y(p[0])*m,0,m),T=c.W(c.Y(p[1])*m,0,m),T<w&&(T+=m),T-w<z&&(M=z/(T-w)));const{x:N,y:U}=se(m,n);let j,Z;const X=Math.max(M||0,C||0);if(X){const q=new c.P(M?(T+w)/2:N,C?(v+_)/2:U);return l.center=be(m,q).wrap(),l.zoom+=c.at(X),l}if(this._helper._latRange){const q=R/2;U-q<_&&(Z=_+q),U+q>v&&(Z=v-q)}if(p){const q=(w+T)/2;let Y=N;this._helper._renderWorldCopies&&(Y=c.W(N,q-m/2,q+m/2));const Q=z/2;Y-Q<w&&(j=w+Q),Y+Q>T&&(j=T-Q)}if(j!==void 0||Z!==void 0){const q=new c.P(j??N,Z??U);l.center=be(m,q).wrap()}return l},this.applyConstrain=(n,o)=>this._helper.applyConstrain(n,o),this._helper=new jr({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(n,o)=>this.defaultConstrain(n,o)},t),this._coveringTilesDetailsProvider=new fr}clone(){const t=new qi;return t.apply(this,!1),t}apply(t,n,o){this._helper.apply(t,n,o)}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(t){const n=[new c.bc(0,t)];if(this._helper._renderWorldCopies){const o=this.screenPointToMercatorCoordinate(new c.P(0,0)),l=this.screenPointToMercatorCoordinate(new c.P(this._helper._width,0)),p=this.screenPointToMercatorCoordinate(new c.P(this._helper._width,this._helper._height)),m=this.screenPointToMercatorCoordinate(new c.P(0,this._helper._height)),_=Math.floor(Math.min(o.x,l.x,p.x,m.x)),v=Math.floor(Math.max(o.x,l.x,p.x,m.x)),w=1;for(let T=_-w;T<=v+w;T++)T!==0&&n.push(new c.bc(T,t))}return n}getCameraFrustum(){return Us.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){const n=this.screenPointToLocation(this.centerPoint,t),o=t?t.getElevationForLngLatZoom(n,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(o)}setLocationAtPoint(t,n){const o=c.as(this.elevation,this.center.lat),l=this.screenPointToMercatorCoordinateAtZ(n,o),p=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,o),m=c.a9.fromLngLat(t),_=new c.a9(m.x-(l.x-p.x),m.y-(l.y-p.y));this.setCenter(_?.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(t,n){return n?this.coordinatePoint(c.a9.fromLngLat(t),n.getElevationForLngLat(t,this),this._pixelMatrix3D):this.coordinatePoint(c.a9.fromLngLat(t))}screenPointToLocation(t,n){var o;return(o=this.screenPointToMercatorCoordinate(t,n))===null||o===void 0?void 0:o.toLngLat()}screenPointToMercatorCoordinate(t,n){if(n){const o=n.pointCoordinate(t);if(o!=null)return o}return this.screenPointToMercatorCoordinateAtZ(t)}screenPointToMercatorCoordinateAtZ(t,n){const o=n||0,l=[t.x,t.y,0,1],p=[t.x,t.y,1,1];c.aH(l,l,this._pixelMatrixInverse),c.aH(p,p,this._pixelMatrixInverse);const m=l[3],_=p[3],v=l[1]/m,w=p[1]/_,T=l[2]/m,C=p[2]/_,M=T===C?0:(o-T)/(C-T);return new c.a9(c.G.number(l[0]/m,p[0]/_,M)/this.worldSize,c.G.number(v,w,M)/this.worldSize,o)}coordinatePoint(t,n=0,o=this._pixelMatrix){const l=[t.x*this.worldSize,t.y*this.worldSize,n,1];return c.aH(l,l,o),new c.P(l[0]/l[3],l[1]/l[3])}getBounds(){const t=Math.max(0,this._helper._height/2-me(this));return new Mt().extend(this.screenPointToLocation(new c.P(0,t))).extend(this.screenPointToLocation(new c.P(this._helper._width,t))).extend(this.screenPointToLocation(new c.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new c.P(0,this._helper._height)))}isPointOnMapSurface(t,n){return n?n.pointCoordinate(t)!=null:t.y>this.height/2-me(this)}calculatePosMatrix(t,n=!1,o){var l;const p=(l=t.key)!==null&&l!==void 0?l:c.bd(t.wrap,t.canonical.z,t.canonical.z,t.canonical.x,t.canonical.y),m=n?this._alignedPosMatrixCache:this._posMatrixCache;if(m.has(p)){const w=m.get(p);return o?w.f32:w.f64}const _=K(t,this.worldSize);c.S(_,n?this._alignedProjMatrix:this._viewProjMatrix,_);const v={f64:_,f32:new Float32Array(_)};return m.set(p,v),o?v.f32:v.f64}calculateFogMatrix(t){const n=t.key,o=this._fogMatrixCacheF32;if(o.has(n))return o.get(n);const l=K(t,this.worldSize);return c.S(l,this._fogMatrix,l),o.set(n,new Float32Array(l)),o.get(n)}calculateCenterFromCameraLngLatAlt(t,n,o,l){return this._helper.calculateCenterFromCameraLngLatAlt(t,n,o,l)}_calculateNearFarZIfNeeded(t,n,o){if(!this._helper.autoCalculateNearFarZ)return;const l=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),p=t-l*this._helper._pixelPerMeter/Math.cos(n),m=l<0?p:t,_=Math.PI/2+this.pitchInRadians,v=c.ap(this.fov)*(Math.abs(Math.cos(c.ap(this.roll)))*this.height+Math.abs(Math.sin(c.ap(this.roll)))*this.width)/this.height*(.5+o.y/this.height),w=Math.sin(v)*m/Math.sin(c.an(Math.PI-_-v,.01,Math.PI-.01)),T=me(this),C=Math.atan(T/this._helper.cameraToCenterDistance),M=c.ap(.75),z=C>M?2*C*(.5+o.y/(2*T)):M,R=Math.sin(z)*m/Math.sin(c.an(Math.PI-_-z,.01,Math.PI-.01)),N=Math.min(w,R);this._helper._farZ=1.01*(Math.cos(Math.PI/2-n)*N+m),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const t=this.centerOffset,n=se(this.worldSize,this.center),o=n.x,l=n.y;this._helper._pixelPerMeter=c.as(1,this.center.lat)*this.worldSize;const p=c.ap(Math.min(this.pitch,ne)),m=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(p));let _;this._calculateNearFarZIfNeeded(m,p,t),_=new Float64Array(16),c.be(_,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),c.aB(this._invProjMatrix,_),_[8]=2*-t.x/this._helper._width,_[9]=2*t.y/this._helper._height,this._projectionMatrix=c.bf(_),c.Q(_,_,[1,-1,1]),c.O(_,_,[0,0,-this._helper.cameraToCenterDistance]),c.bg(_,_,-this.rollInRadians),c.bh(_,_,this.pitchInRadians),c.bg(_,_,-this.bearingInRadians),c.O(_,_,[-o,-l,0]),this._mercatorMatrix=c.Q([],_,[this.worldSize,this.worldSize,this.worldSize]),c.Q(_,_,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=c.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,_),c.O(_,_,[0,0,-this.elevation]),this._viewProjMatrix=_,this._invViewProjMatrix=c.aB([],_);const v=[0,0,-1,1];c.aH(v,v,this._invViewProjMatrix),this._cameraPosition=[v[0]/v[3],v[1]/v[3],v[2]/v[3]],this._fogMatrix=new Float64Array(16),c.be(this._fogMatrix,this.fovInRadians,this.width/this.height,m,this._helper._farZ),this._fogMatrix[8]=2*-t.x/this.width,this._fogMatrix[9]=2*t.y/this.height,c.Q(this._fogMatrix,this._fogMatrix,[1,-1,1]),c.O(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),c.bg(this._fogMatrix,this._fogMatrix,-this.rollInRadians),c.bh(this._fogMatrix,this._fogMatrix,this.pitchInRadians),c.bg(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),c.O(this._fogMatrix,this._fogMatrix,[-o,-l,0]),c.Q(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),c.O(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=c.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,_);const w=this._helper._width%2/2,T=this._helper._height%2/2,C=Math.cos(this.bearingInRadians),M=Math.sin(-this.bearingInRadians),z=o-Math.round(o)+C*w+M*T,R=l-Math.round(l)+C*T+M*w,N=new Float64Array(_);if(c.O(N,N,[z>.5?z-1:z,R>.5?R-1:R,0]),this._alignedProjMatrix=N,_=c.aB(new Float64Array(16),this._pixelMatrix),!_)throw new Error("failed to invert matrix");this._pixelMatrixInverse=_,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const t=this.screenPointToMercatorCoordinate(new c.P(0,0)),n=[t.x*this.worldSize,t.y*this.worldSize,0,1];return c.aH(n,n,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const t=c.as(1,this.center.lat)*this.worldSize;return Oe(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/t).toLngLat()}lngLatToCameraDepth(t,n){const o=c.a9.fromLngLat(t),l=[o.x*this.worldSize,o.y*this.worldSize,n,1];return c.aH(l,l,this._viewProjMatrix),l[2]/l[3]}getProjectionData(t){const{overscaledTileID:n,aligned:o,applyTerrainMatrix:l}=t,p=this._helper.getMercatorTileCoordinates(n),m=n?this.calculatePosMatrix(n,o,!0):null;let _;return _=n&&n.terrainRttPosMatrix32f&&l?n.terrainRttPosMatrix32f:m||c.bi(),{mainMatrix:_,tileMercatorCoords:p,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:_}}isLocationOccluded(t){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(t,n,o){return 1}transformLightDirection(t){return c.b1(t)}getRayDirectionFromPixel(t){throw new Error("Not implemented.")}projectTileCoordinates(t,n,o,l){const p=this.calculatePosMatrix(o);let m;l?(m=[t,n,l(t,n),1],c.aH(m,m,p)):(m=[t,n,0,1],dn(m,m,p));const _=m[3];return{point:new c.P(m[0]/_,m[1]/_),signedDistanceFromCamera:_,isOccluded:!1}}populateCache(t){for(const n of t)this.calculatePosMatrix(n)}getMatrixForModel(t,n){const o=c.a9.fromLngLat(t,n),l=o.meterInMercatorCoordinateUnits(),p=c.bj();return c.O(p,p,[o.x,o.y,o.z]),c.bg(p,p,Math.PI),c.bh(p,p,Math.PI/2),c.Q(p,p,[-l,l,l]),p}getProjectionDataForCustomLayer(t=!0){const n=new c.a2(0,0,0,0,0),o=this.getProjectionData({overscaledTileID:n,applyGlobeMatrix:t}),l=K(n,this.worldSize);c.S(l,this._viewProjMatrix,l),o.tileMercatorCoords=[0,0,1,1];const p=[c.a5,c.a5,this.worldSize/this._helper.pixelsPerMeter],m=c.bk();return c.Q(m,l,p),o.fallbackMatrix=m,o.mainMatrix=m,o}getFastPathSimpleProjectionMatrix(t){return this.calculatePosMatrix(t)}}function nc(){c.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function qa(d){if(d.useSlerp)if(d.k<1){const t=c.bl(d.startEulerAngles.roll,d.startEulerAngles.pitch,d.startEulerAngles.bearing),n=c.bl(d.endEulerAngles.roll,d.endEulerAngles.pitch,d.endEulerAngles.bearing),o=new Float64Array(4);c.bm(o,t,n,d.k);const l=c.bn(o);d.tr.setRoll(l.roll),d.tr.setPitch(l.pitch),d.tr.setBearing(l.bearing)}else d.tr.setRoll(d.endEulerAngles.roll),d.tr.setPitch(d.endEulerAngles.pitch),d.tr.setBearing(d.endEulerAngles.bearing);else d.tr.setRoll(c.G.number(d.startEulerAngles.roll,d.endEulerAngles.roll,d.k)),d.tr.setPitch(c.G.number(d.startEulerAngles.pitch,d.endEulerAngles.pitch,d.k)),d.tr.setBearing(c.G.number(d.startEulerAngles.bearing,d.endEulerAngles.bearing,d.k))}function Gs(d,t,n,o,l){const p=l.padding,m=se(l.worldSize,n.getNorthWest()),_=se(l.worldSize,n.getNorthEast()),v=se(l.worldSize,n.getSouthEast()),w=se(l.worldSize,n.getSouthWest()),T=c.ap(-o),C=m.rotate(T),M=_.rotate(T),z=v.rotate(T),R=w.rotate(T),N=new c.P(Math.max(C.x,M.x,R.x,z.x),Math.max(C.y,M.y,R.y,z.y)),U=new c.P(Math.min(C.x,M.x,R.x,z.x),Math.min(C.y,M.y,R.y,z.y)),j=N.sub(U),Z=(l.width-(p.left+p.right+t.left+t.right))/j.x,X=(l.height-(p.top+p.bottom+t.top+t.bottom))/j.y;if(X<0||Z<0)return void nc();const q=Math.min(c.at(l.scale*Math.min(Z,X)),d.maxZoom),Y=c.P.convert(d.offset),Q=new c.P((t.left-t.right)/2,(t.top-t.bottom)/2).rotate(c.ap(o)),H=Y.add(Q).mult(l.scale/c.aq(q));return{center:be(l.worldSize,m.add(v).div(2).sub(H)),zoom:q,bearing:o}}class kn{get useGlobeControls(){return!1}handlePanInertia(t,n){const o=t.mag(),l=Math.abs(me(n));return{easingOffset:t.mult(Math.min(.75*l/o,1)),easingCenter:n.center}}handleMapControlsRollPitchBearingZoom(t,n){t.bearingDelta&&n.setBearing(n.bearing+t.bearingDelta),t.pitchDelta&&n.setPitch(n.pitch+t.pitchDelta),t.rollDelta&&n.setRoll(n.roll+t.rollDelta),t.zoomDelta&&n.setZoom(n.zoom+t.zoomDelta)}handleMapControlsPan(t,n,o){t.around.distSqr(n.centerPoint)<.01||n.setLocationAtPoint(o,t.around)}cameraForBoxAndBearing(t,n,o,l,p){return Gs(t,n,o,l,p)}handleJumpToCenterZoom(t,n){t.zoom!==(n.zoom!==void 0?+n.zoom:t.zoom)&&t.setZoom(+n.zoom),n.center!==void 0&&t.setCenter(c.V.convert(n.center))}handleEaseTo(t,n){const o=t.zoom,l=t.padding,p={roll:t.roll,pitch:t.pitch,bearing:t.bearing},m={roll:n.roll===void 0?t.roll:n.roll,pitch:n.pitch===void 0?t.pitch:n.pitch,bearing:n.bearing===void 0?t.bearing:n.bearing},_=n.zoom!==void 0,v=!t.isPaddingEqual(n.padding);let w=!1;const T=_?+n.zoom:t.zoom;let C=t.centerPoint.add(n.offsetAsPoint);const M=t.screenPointToLocation(C),{center:z,zoom:R}=t.applyConstrain(c.V.convert(n.center||M),T??o);zt(t,z);const N=se(t.worldSize,M),U=se(t.worldSize,z).sub(N),j=c.aq(R-o);return w=R!==o,{easeFunc:Z=>{if(w&&t.setZoom(c.G.number(o,R,Z)),c.bo(p,m)||qa({startEulerAngles:p,endEulerAngles:m,tr:t,k:Z,useSlerp:p.roll!=m.roll}),v&&(t.interpolatePadding(l,n.padding,Z),C=t.centerPoint.add(n.offsetAsPoint)),n.around)t.setLocationAtPoint(n.around,n.aroundPoint);else{const X=c.aq(t.zoom-o),q=R>o?Math.min(2,j):Math.max(.5,j),Y=Math.pow(q,1-Z),Q=be(t.worldSize,N.add(U.mult(Z*Y)).mult(X));t.setLocationAtPoint(t.renderWorldCopies?Q.wrap():Q,C)}},isZooming:w,elevationCenter:z}}handleFlyTo(t,n){const o=n.zoom!==void 0,l=t.zoom,p=t.applyConstrain(c.V.convert(n.center||n.locationAtOffset),o?+n.zoom:l),m=p.center,_=p.zoom;zt(t,m);const v=se(t.worldSize,n.locationAtOffset),w=se(t.worldSize,m).sub(v),T=w.mag(),C=c.aq(_-l);let M;if(n.minZoom!==void 0){const z=Math.min(+n.minZoom,l,_),R=t.applyConstrain(m,z).zoom;M=c.aq(R-l)}return{easeFunc:(z,R,N,U)=>{t.setZoom(z===1?_:l+c.at(R));const j=z===1?m:be(t.worldSize,v.add(w.mult(N)).mult(R));t.setLocationAtPoint(t.renderWorldCopies?j.wrap():j,U)},scaleOfZoom:C,targetCenter:m,scaleOfMinZoom:M,pixelPathLength:T}}}class yt{constructor(t,n,o){this.blendFunction=t,this.blendColor=n,this.mask=o}}yt.Replace=[1,0],yt.disabled=new yt(yt.Replace,c.bp.transparent,[!1,!1,!1,!1]),yt.unblended=new yt(yt.Replace,c.bp.transparent,[!0,!0,!0,!0]),yt.alphaBlended=new yt([1,771],c.bp.transparent,[!0,!0,!0,!0]);const qs=2305;class ot{constructor(t,n,o){this.enable=t,this.mode=n,this.frontFace=o}}ot.disabled=new ot(!1,1029,qs),ot.backCCW=new ot(!0,1029,qs),ot.frontCCW=new ot(!0,1028,qs);class Qe{constructor(t,n,o){this.func=t,this.mask=n,this.range=o}}Qe.ReadOnly=!1,Qe.ReadWrite=!0,Qe.disabled=new Qe(519,Qe.ReadOnly,[0,1]);const Zs=7680;class at{constructor(t,n,o,l,p,m){this.test=t,this.ref=n,this.mask=o,this.fail=l,this.depthFail=p,this.pass=m}}at.disabled=new at({func:519,mask:0},0,0,Zs,Zs,Zs);const hs=new WeakMap;function sr(d){var t;if(hs.has(d))return hs.get(d);{const n=(t=d.getParameter(d.VERSION))===null||t===void 0?void 0:t.startsWith("WebGL 2.0");return hs.set(d,n),n}}class Ln{get awaitingQuery(){return!!this._readbackQueue}constructor(t){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=t;const n=t.context,o=n.gl;this._texFormat=o.RGBA,this._texType=o.UNSIGNED_BYTE;const l=new c.aW;l.emplaceBack(-1,-1),l.emplaceBack(2,-1),l.emplaceBack(-1,2);const p=new c.aY;p.emplaceBack(0,1,2),this._fullscreenTriangle=new cs(n.createVertexBuffer(l,Wt.members),n.createIndexBuffer(p),c.aX.simpleSegment(0,0,l.length,p.length)),this._resultBuffer=new Uint8Array(4),n.activeTexture.set(o.TEXTURE1);const m=o.createTexture();o.bindTexture(o.TEXTURE_2D,m),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.NEAREST),o.texImage2D(o.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=n.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(m),sr(o)&&(this._pbo=o.createBuffer(),o.bindBuffer(o.PIXEL_PACK_BUFFER,this._pbo),o.bufferData(o.PIXEL_PACK_BUFFER,4,o.STREAM_READ),o.bindBuffer(o.PIXEL_PACK_BUFFER,null))}destroy(){const t=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),t.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(t,n){const o=this._updateCount;return this._readbackQueue?o>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():o>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(t,n),this._updateCount++,this._measuredError}_bindFramebuffer(){const t=this._cachedRenderContext.context,n=t.gl;t.activeTexture.set(n.TEXTURE1),n.bindTexture(n.TEXTURE_2D,this._fbo.colorAttachment.get()),t.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(t,n){const o=this._cachedRenderContext.context,l=o.gl;if(this._bindFramebuffer(),o.viewport.set([0,0,this._texWidth,this._texHeight]),o.clear({color:c.bp.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(o,l.TRIANGLES,Qe.disabled,at.disabled,yt.unblended,ot.disabled,((p,m)=>({u_input:p,u_output_expected:m}))(t,n),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&sr(l)){l.bindBuffer(l.PIXEL_PACK_BUFFER,this._pbo),l.readBuffer(l.COLOR_ATTACHMENT0),l.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),l.bindBuffer(l.PIXEL_PACK_BUFFER,null);const p=l.fenceSync(l.SYNC_GPU_COMMANDS_COMPLETE,0);l.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:p}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const t=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&sr(t)){const n=t.clientWaitSync(this._readbackQueue.sync,0,0);if(n===t.WAIT_FAILED)return c.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(n===t.TIMEOUT_EXPIRED)return;t.bindBuffer(t.PIXEL_PACK_BUFFER,this._pbo),t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),t.bindBuffer(t.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),t.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=Ln._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(t){let n=0;return n+=t[0]/256,n+=t[1]/65536,n+=t[2]/16777216,t[3]<127&&(n=-n),n/128}}const Vo=c.a5/128;function No(d,t){const n=d.granularity!==void 0?Math.max(d.granularity,1):1,o=n+(d.generateBorders?2:0),l=n+(d.extendToNorthPole||d.generateBorders?1:0)+(d.extendToSouthPole||d.generateBorders?1:0),p=o+1,m=l+1,_=d.generateBorders?-1:0,v=d.generateBorders||d.extendToNorthPole?-1:0,w=n+(d.generateBorders?1:0),T=n+(d.generateBorders||d.extendToSouthPole?1:0),C=p*m,M=o*l*6,z=p*m>65536;if(z&&t==="16bit")throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const R=z||t==="32bit",N=new Int16Array(2*C);let U=0;for(let X=v;X<=T;X++)for(let q=_;q<=w;q++){let Y=q/n*c.a5;q===-1&&(Y=-Vo),q===n+1&&(Y=c.a5+Vo);let Q=X/n*c.a5;X===-1&&(Q=d.extendToNorthPole?c.br:-Vo),X===n+1&&(Q=d.extendToSouthPole?c.bs:c.a5+Vo),N[U++]=Y,N[U++]=Q}const j=R?new Uint32Array(M):new Uint16Array(M);let Z=0;for(let X=0;X<l;X++)for(let q=0;q<o;q++){const Y=q+1+X*p,Q=q+(X+1)*p,H=q+1+(X+1)*p;j[Z++]=q+X*p,j[Z++]=Q,j[Z++]=Y,j[Z++]=Y,j[Z++]=Q,j[Z++]=H}return{vertices:N.buffer.slice(0),indices:j.buffer.slice(0),uses32bitIndices:R}}const jo=new c.aV({fill:new c.bt(128,2),line:new c.bt(512,0),tile:new c.bt(128,32),stencil:new c.bt(128,1),circle:3});class sc{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 Pt.projectionGlobe}get vertexShaderPreludeCode(){return Pt.projectionMercator.vertexSource}get subdivisionGranularity(){return jo}get useGlobeControls(){return!0}get latitudeErrorCorrectionRadians(){return this._errorCorrectionUsable}destroy(){this._errorMeasurement&&this._errorMeasurement.destroy()}updateGPUdependent(t){this._errorMeasurement||(this._errorMeasurement=new Ln(t));const n=c.X(this._errorQueryLatitudeDegrees),o=2*Math.atan(Math.exp(Math.PI-n*Math.PI*2))-.5*Math.PI,l=this._errorMeasurement.updateErrorLoop(n,o),p=He();l!==this._errorMeasurementLastValue&&(this._errorCorrectionPreviousValue=this._errorCorrectionUsable,this._errorMeasurementLastValue=l,this._errorMeasurementLastChangeTime=p);const m=Math.min(Math.max((p-this._errorMeasurementLastChangeTime)/1e3/.5,0),1);this._errorCorrectionUsable=c.bu(this._errorCorrectionPreviousValue,-this._errorMeasurementLastValue,c.bv(m))}_getMeshKey(t){return`${t.granularity.toString(36)}_${t.generateBorders?"b":""}${t.extendToNorthPole?"n":""}${t.extendToSouthPole?"s":""}`}getMeshFromTileID(t,n,o,l,p){const m=(p==="stencil"?jo.stencil:jo.tile).getGranularityForZoomLevel(n.z);return this._getMesh(t,{granularity:m,generateBorders:o,extendToNorthPole:n.y===0&&l,extendToSouthPole:n.y===(1<<n.z)-1&&l})}_getMesh(t,n){const o=this._getMeshKey(n);if(o in this._tileMeshCache)return this._tileMeshCache[o];const l=(function(p,m){const _=No(m,"16bit"),v=c.aW.deserialize({arrayBuffer:_.vertices,length:_.vertices.byteLength/2/2}),w=c.aY.deserialize({arrayBuffer:_.indices,length:_.indices.byteLength/2/3});return new cs(p.createVertexBuffer(v,Wt.members),p.createIndexBuffer(w),c.aX.simpleSegment(0,0,v.length,w.length))})(t,n);return this._tileMeshCache[o]=l,l}recalculate(t){}hasTransition(){const t=He();let n=!1;return n=n||(t-this._errorMeasurementLastChangeTime)/1e3<.7,n=n||this._errorMeasurement&&this._errorMeasurement.awaitingQuery,n}setErrorQueryLatitudeDegrees(t){this._errorQueryLatitudeDegrees=t}}const Ru=new c.t({type:new c.D(c.u.projection.type)});class Pi extends c.E{constructor(t){super(),this._transitionable=new c.x(Ru,void 0),this.setProjection(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new c.H(0)),this._mercatorProjection=new Oo,this._verticalPerspectiveProjection=new sc}get transitionState(){const t=this.properties.get("type");if(typeof t=="string"&&t==="mercator")return 0;if(typeof t=="string"&&t==="vertical-perspective")return 1;if(t instanceof c.bw){if(t.from==="vertical-perspective"&&t.to==="mercator")return 1-t.transition;if(t.from==="mercator"&&t.to==="vertical-perspective")return t.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(t){this._mercatorProjection.updateGPUdependent(t),this._verticalPerspectiveProjection.updateGPUdependent(t)}getMeshFromTileID(t,n,o,l,p){return this.currentProjection.getMeshFromTileID(t,n,o,l,p)}setProjection(t){this._transitionable.setValue("type",t?.type||"mercator")}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}setErrorQueryLatitudeDegrees(t){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(t),this._mercatorProjection.setErrorQueryLatitudeDegrees(t)}}function Uo(d){const t=$s(d.worldSize,d.center.lat);return 2*Math.PI*t}function ui(d,t,n,o,l){const p=1/(1<<l),m=t/c.a5*p+o*p,_=c.bz((d/c.a5*p+n*p)*Math.PI*2+Math.PI,2*Math.PI),v=2*Math.atan(Math.exp(Math.PI-m*Math.PI*2))-.5*Math.PI,w=Math.cos(v),T=new Float64Array(3);return T[0]=Math.sin(_)*w,T[1]=Math.sin(v),T[2]=Math.cos(_)*w,T}function ii(d){return(function(t,n){const o=Math.cos(n),l=new Float64Array(3);return l[0]=Math.sin(t)*o,l[1]=Math.sin(n),l[2]=Math.cos(t)*o,l})(d.lng*Math.PI/180,d.lat*Math.PI/180)}function $s(d,t){return d/(2*Math.PI)/Math.cos(t*Math.PI/180)}function Za(d){const t=Math.asin(d[1])/Math.PI*180,n=Math.sqrt(d[0]*d[0]+d[2]*d[2]);if(n>1e-6){const o=d[0]/n,l=Math.acos(d[2]/n),p=(o>0?l:-l)/Math.PI*180;return new c.V(c.W(p,-180,180),t)}return new c.V(0,t)}function Ur(d){return Math.cos(d*Math.PI/180)}function ni(d,t){const n=Ur(d),o=Ur(t);return c.at(o/n)}function oc(d,t){const n=d.rotate(t.bearingInRadians),o=t.zoom+ni(t.center.lat,0),l=c.bu(1/Ur(t.center.lat),1/Ur(Math.min(Math.abs(t.center.lat),60)),c.bx(o,7,3,0,1)),p=360/Uo({worldSize:t.worldSize,center:{lat:t.center.lat}});return new c.V(t.center.lng-n.x*p*l,c.an(t.center.lat+n.y*p,-c.ao,c.ao))}function $a(d){const t=.5*d,n=Math.sin(t),o=Math.cos(t);return Math.log(n+o)-Math.log(o-n)}function ac(d,t,n,o){const l=d.lat+n*o;if(Math.abs(n)>1){const p=(Math.sign(d.lat+n)!==Math.sign(d.lat)?-Math.abs(d.lat):Math.abs(d.lat))*Math.PI/180,m=Math.abs(d.lat+n)*Math.PI/180,_=$a(p+o*(m-p)),v=$a(p),w=$a(m);return new c.V(d.lng+t*((_-v)/(w-v)),l)}return new c.V(d.lng+t*o,l)}class Fu{constructor(t){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=t}swapBuffers(){if(!this._hadAnyChanges)return;const t=this._cachePrevious;this._cachePrevious=this._cache,this._cache=t,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(t,n,o,l){const p=`${t.z}_${t.x}_${t.y}_${l?.terrain?"t":""}`,m=this._cache.get(p);if(m)return m;const _=this._cachePrevious.get(p);if(_)return this._cache.set(p,_),_;const v=this._boundingVolumeFactory(t,n,o,l);return this._cache.set(p,v),this._hadAnyChanges=!0,v}}class ds{constructor(t,n,o,l){this.min=o,this.max=l,this.points=t,this.planes=n}static fromAabb(t,n){const o=[];for(let l=0;l<8;l++)o.push([1&~l?t[0]:n[0],(l>>1&1)==1?n[1]:t[1],(l>>2&1)==1?n[2]:t[2]]);return new ds(o,[[-1,0,0,n[0]],[1,0,0,-t[0]],[0,-1,0,n[1]],[0,1,0,-t[1]],[0,0,-1,n[2]],[0,0,1,-t[2]]],t,n)}static fromCenterSizeAngles(t,n,o){const l=c.bB([],o[0],o[1],o[2]),p=c.bC([],[n[0],0,0],l),m=c.bC([],[0,n[1],0],l),_=c.bC([],[0,0,n[2]],l),v=[...t],w=[...t];for(let C=0;C<8;C++)for(let M=0;M<3;M++){const z=t[M]+p[M]*(1&~C?-1:1)+m[M]*((C>>1&1)==1?1:-1)+_[M]*((C>>2&1)==1?1:-1);v[M]=Math.min(v[M],z),w[M]=Math.max(w[M],z)}const T=[];for(let C=0;C<8;C++){const M=[...t];c.b0(M,M,c.a$([],p,1&~C?-1:1)),c.b0(M,M,c.a$([],m,(C>>1&1)==1?1:-1)),c.b0(M,M,c.a$([],_,(C>>2&1)==1?1:-1)),T.push(M)}return new ds(T,[[...p,-c.b5(p,T[0])],[...m,-c.b5(m,T[0])],[..._,-c.b5(_,T[0])],[-p[0],-p[1],-p[2],-c.b5(p,T[7])],[-m[0],-m[1],-m[2],-c.b5(m,T[7])],[-_[0],-_[1],-_[2],-c.b5(_,T[7])]],v,w)}intersectsFrustum(t){let n=!0;const o=this.points.length,l=this.planes.length,p=t.planes.length,m=t.points.length;for(let _=0;_<p;_++){const v=t.planes[_];let w=0;for(let T=0;T<o;T++){const C=this.points[T];v[0]*C[0]+v[1]*C[1]+v[2]*C[2]+v[3]>=0&&w++}if(w===0)return 0;w<o&&(n=!1)}if(n)return 2;for(let _=0;_<l;_++){const v=this.planes[_];let w=0;for(let T=0;T<m;T++){const C=t.points[T];v[0]*C[0]+v[1]*C[1]+v[2]*C[2]+v[3]>=0&&w++}if(w===0)return 0}return 1}intersectsPlane(t){const n=this.points.length;let o=0;for(let l=0;l<n;l++){const p=this.points[l];t[0]*p[0]+t[1]*p[1]+t[2]*p[2]+t[3]>=0&&o++}return o===n?2:o===0?0:1}}function Rn(d,t,n){const o=d-t;return o<0?-o:Math.max(0,o-n)}function Hs(d,t,n,o,l){const p=d-n;let m;return m=p<0?Math.min(-p,1+p-l):p>1?Math.min(Math.max(p-l,0),1-p):0,Math.max(m,Rn(t,o,l))}class Go{constructor(){this._boundingVolumeCache=new Fu(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(t,n,o,l){const p=1<<o.z,m=1/p,_=o.x/p,v=o.y/p;let w=2;return w=Math.min(w,Hs(t,n,_,v,m)),w=Math.min(w,Hs(t,n,_+.5,-v-m,m)),w=Math.min(w,Hs(t,n,_+.5,2-v-m,m)),w}getWrap(t,n,o){const l=1<<n.z,p=1/l,m=n.x/l,_=Rn(t.x,m,p),v=Rn(t.x,m-1,p),w=Rn(t.x,m+1,p),T=Math.min(_,v,w);return T===w?1:T===v?-1:0}allowVariableZoom(t,n){return Nt(t,n)>4}allowWorldCopies(){return!1}getTileBoundingVolume(t,n,o,l){return this._boundingVolumeCache.getTileBoundingVolume(t,n,o,l)}_computeTileBoundingVolume(t,n,o,l){var p,m;let _=0,v=0;if(l?.terrain){const w=new c.a2(t.z,n,t.z,t.x,t.y),T=l.terrain.getMinMaxElevation(w);_=(p=T.minElevation)!==null&&p!==void 0?p:Math.min(0,o),v=(m=T.maxElevation)!==null&&m!==void 0?m:Math.max(0,o)}if(_/=c.bE,v/=c.bE,_+=1,v+=1,t.z<=0)return ds.fromAabb([-v,-v,-v],[v,v,v]);if(t.z===1)return ds.fromAabb([t.x===0?-v:0,t.y===0?0:-v,-v],[t.x===0?0:v,t.y===0?v:0,v]);{const w=[ui(0,0,t.x,t.y,t.z),ui(c.a5,0,t.x,t.y,t.z),ui(c.a5,c.a5,t.x,t.y,t.z),ui(0,c.a5,t.x,t.y,t.z)],T=[];for(const ce of w)T.push(c.a$([],ce,v));if(v!==_)for(const ce of w)T.push(c.a$([],ce,_));t.y===0&&T.push([0,1,0]),t.y===(1<<t.z)-1&&T.push([0,-1,0]);const C=[1,1,1],M=[-1,-1,-1];for(const ce of T)for(let he=0;he<3;he++)C[he]=Math.min(C[he],ce[he]),M[he]=Math.max(M[he],ce[he]);const z=ui(c.a5/2,c.a5/2,t.x,t.y,t.z),R=c.b4([],[0,1,0],z);c.b3(R,R);const N=c.b4([],z,R);c.b3(N,N);const U=c.b4([],w[2],w[1]);c.b3(U,U);const j=c.b4([],w[0],w[3]);c.b3(j,j),T.push(c.a$([],z,v)),t.y>=(1<<t.z)/2&&T.push(c.a$([],ui(c.a5/2,0,t.x,t.y,t.z),v)),t.y<(1<<t.z)/2&&T.push(c.a$([],ui(c.a5/2,c.a5,t.x,t.y,t.z),v));const Z=qo(z,T),X=qo(N,T),q=[-z[0],-z[1],-z[2],Z.max],Y=[z[0],z[1],z[2],-Z.min],Q=[-N[0],-N[1],-N[2],X.max],H=[N[0],N[1],N[2],-X.min],te=[...U,0],de=[...j,0],ue=[];return t.y===0?ue.push(c.bD(de,te,q),c.bD(de,te,Y)):ue.push(c.bD(Q,te,q),c.bD(Q,te,Y),c.bD(Q,de,q),c.bD(Q,de,Y)),t.y===(1<<t.z)-1?ue.push(c.bD(de,te,q),c.bD(de,te,Y)):ue.push(c.bD(H,te,q),c.bD(H,te,Y),c.bD(H,de,q),c.bD(H,de,Y)),new ds(ue,[q,Y,Q,H,te,de],C,M)}}}function qo(d,t){let n=1/0,o=-1/0;for(const l of t){const p=c.b5(d,l);n=Math.min(n,p),o=Math.max(o,p)}return{min:n,max:o}}class ps{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(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,n,o){return this._helper.interpolatePadding(t,n,o)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,n){this._helper.resize(t,n)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,n){this._helper.overrideNearFarZ(t,n)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}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(t){}constructor(t){this._cachedClippingPlane=c.bF(),this._projectionMatrix=c.bj(),this._globeViewProjMatrix32f=c.bi(),this._globeViewProjMatrixNoCorrection=c.bj(),this._globeViewProjMatrixNoCorrectionInverted=c.bj(),this._globeProjMatrixInverted=c.bj(),this._cameraPosition=c.bA(),this._globeLatitudeErrorCorrectionRadians=0,this.defaultConstrain=(n,o)=>{const l=c.an(n.lat,-c.ao,c.ao),p=c.an(+o,this.minZoom+ni(0,l),this.maxZoom);return{center:new c.V(n.lng,l),zoom:p}},this.applyConstrain=(n,o)=>this._helper.applyConstrain(n,o),this._helper=new jr({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(n,o)=>this.defaultConstrain(n,o)},t),this._coveringTilesDetailsProvider=new Go}clone(){const t=new ps;return t.apply(this,!1),t}apply(t,n,o){this._globeLatitudeErrorCorrectionRadians=o||0,this._helper.apply(t,n)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const t=c.bA();return t[0]=this._cameraPosition[0],t[1]=this._cameraPosition[1],t[2]=this._cameraPosition[2],t}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(t){const{overscaledTileID:n,applyGlobeMatrix:o}=t,l=this._helper.getMercatorTileCoordinates(n);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:l,clippingPlane:this._cachedClippingPlane,projectionTransition:o?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(t){const n=this.pitchInRadians,o=this.cameraToCenterDistance/t,l=Math.sin(n)*o,p=Math.cos(n)*o+1,m=1/Math.sqrt(l*l+p*p)*1;let _=-l,v=p;const w=Math.sqrt(_*_+v*v);_/=w,v/=w;const T=[0,_,v];c.bG(T,T,[0,0,0],-this.bearingInRadians),c.bH(T,T,[0,0,0],-1*this.center.lat*Math.PI/180),c.bI(T,T,[0,0,0],this.center.lng*Math.PI/180);const C=1/c.b7(T);return c.a$(T,T,C),[...T,-m*C]}isLocationOccluded(t){return!this.isSurfacePointVisible(ii(t))}transformLightDirection(t){const n=this._helper._center.lng*Math.PI/180,o=this._helper._center.lat*Math.PI/180,l=Math.cos(o),p=[Math.sin(n)*l,Math.sin(o),Math.cos(n)*l],m=[p[2],0,-p[0]],_=[0,0,0];c.b4(_,m,p),c.b3(m,m),c.b3(_,_);const v=[0,0,0];return c.b3(v,[m[0]*t[0]+_[0]*t[1]+p[0]*t[2],m[1]*t[0]+_[1]*t[1]+p[1]*t[2],m[2]*t[0]+_[2]*t[1]+p[2]*t[2]]),v}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(t,n,o){const l=(function(_,v,w){const T=1/(1<<w.z);return new c.a9(_/c.a5*T+w.x*T,v/c.a5*T+w.y*T)})(t,n,o.canonical),p=(m=l.y,[c.bz(l.x*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-m*Math.PI*2))-.5*Math.PI]);var m;return this.getCircleRadiusCorrection()/Math.cos(p[1])}projectTileCoordinates(t,n,o,l){const p=o.canonical,m=ui(t,n,p.x,p.y,p.z),_=1+(l?l(t,n):0)/c.bE,v=[m[0]*_,m[1]*_,m[2]*_,1];c.aH(v,v,this._globeViewProjMatrixNoCorrection);const w=this._cachedClippingPlane,T=w[0]*m[0]+w[1]*m[1]+w[2]*m[2]+w[3]<0;return{point:new c.P(v[0]/v[3],v[1]/v[3]),signedDistanceFromCamera:v[3],isOccluded:T}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;const t=$s(this.worldSize,this.center.lat),n=c.bk(),o=c.bk();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*t),c.be(n,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);const l=this.centerOffset;n[8]=2*-l.x/this._helper._width,n[9]=2*l.y/this._helper._height,this._projectionMatrix=c.bf(n),this._globeProjMatrixInverted=c.bk(),c.aB(this._globeProjMatrixInverted,n),c.O(n,n,[0,0,-this.cameraToCenterDistance]),c.bg(n,n,this.rollInRadians),c.bh(n,n,-this.pitchInRadians),c.bg(n,n,this.bearingInRadians),c.O(n,n,[0,0,-t]);const p=c.bA();p[0]=t,p[1]=t,p[2]=t,c.bh(o,n,this.center.lat*Math.PI/180),c.bJ(o,o,-this.center.lng*Math.PI/180),c.Q(o,o,p),this._globeViewProjMatrixNoCorrection=o,c.bh(n,n,this.center.lat*Math.PI/180-this._globeLatitudeErrorCorrectionRadians),c.bJ(n,n,-this.center.lng*Math.PI/180),c.Q(n,n,p),this._globeViewProjMatrix32f=new Float32Array(n),this._globeViewProjMatrixNoCorrectionInverted=c.bk(),c.aB(this._globeViewProjMatrixNoCorrectionInverted,o);const m=c.bA();this._cameraPosition=c.bA(),this._cameraPosition[2]=this.cameraToCenterDistance/t,c.bG(this._cameraPosition,this._cameraPosition,m,-this.rollInRadians),c.bH(this._cameraPosition,this._cameraPosition,m,this.pitchInRadians),c.bG(this._cameraPosition,this._cameraPosition,m,-this.bearingInRadians),c.b0(this._cameraPosition,this._cameraPosition,[0,0,1]),c.bH(this._cameraPosition,this._cameraPosition,m,-this.center.lat*Math.PI/180),c.bI(this._cameraPosition,this._cameraPosition,m,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(t);const _=c.bf(this._globeViewProjMatrixNoCorrectionInverted);c.Q(_,_,[1,1,-1]),this._cachedFrustum=Us.fromInvProjectionMatrix(_,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(t){c.w("calculateFogMatrix is not supported on globe projection.");const n=c.bk();return c.ar(n),n}getVisibleUnwrappedCoordinates(t){return[new c.bc(0,t)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){t&&c.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(t,n){if(!this._globeViewProjMatrixNoCorrection)return 1;const o=ii(t);c.a$(o,o,1+n/c.bE);const l=c.bF();return c.aH(l,[o[0],o[1],o[2],1],this._globeViewProjMatrixNoCorrection),l[2]/l[3]}populateCache(t){}getBounds(){const t=.5*this.width,n=.5*this.height,o=[new c.P(0,0),new c.P(t,0),new c.P(this.width,0),new c.P(this.width,n),new c.P(this.width,this.height),new c.P(t,this.height),new c.P(0,this.height),new c.P(0,n)],l=[];for(const C of o)l.push(this.unprojectScreenPoint(C));let p=0,m=0,_=0,v=0;const w=this.center;for(const C of l){const M=c.bK(w.lng,C.lng),z=c.bK(w.lat,C.lat);M<m&&(m=M),M>p&&(p=M),z<v&&(v=z),z>_&&(_=z)}const T=[w.lng+m,w.lat+v,w.lng+p,w.lat+_];return this.isSurfacePointOnScreen([0,1,0])&&(T[3]=90,T[0]=-180,T[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(T[1]=-90,T[0]=-180,T[2]=180),new Mt(T)}calculateCenterFromCameraLngLatAlt(t,n,o,l){return this._helper.calculateCenterFromCameraLngLatAlt(t,n,o,l)}setLocationAtPoint(t,n){const o=ii(this.unprojectScreenPoint(n)),l=ii(t),p=c.bA();c.bL(p);const m=c.bA();c.bI(m,o,p,-this.center.lng*Math.PI/180),c.bH(m,m,p,this.center.lat*Math.PI/180);const _=l[0]*l[0]+l[2]*l[2],v=m[0]*m[0];if(_<v)return;const w=Math.sqrt(_-v),T=-w,C=c.bM(l[0],l[2],m[0],w),M=c.bM(l[0],l[2],m[0],T),z=c.bA();c.bI(z,l,p,-C);const R=c.bM(z[1],z[2],m[1],m[2]),N=c.bA();c.bI(N,l,p,-M);const U=c.bM(N[1],N[2],m[1],m[2]),j=.5*Math.PI,Z=R>=-j&&R<=j,X=U>=-j&&U<=j;let q,Y;if(Z&&X){const de=this.center.lng*Math.PI/180,ue=this.center.lat*Math.PI/180;c.bN(C,de)+c.bN(R,ue)<c.bN(M,de)+c.bN(U,ue)?(q=C,Y=R):(q=M,Y=U)}else if(Z)q=C,Y=R;else{if(!X)return;q=M,Y=U}const Q=q/Math.PI*180,H=Y/Math.PI*180,te=this.center.lat;this.setCenter(new c.V(Q,c.an(H,-90,90))),this.setZoom(this.zoom+ni(te,this.center.lat))}locationToScreenPoint(t,n){const o=ii(t);if(n){const l=n.getElevationForLngLatZoom(t,this._helper._tileZoom);c.a$(o,o,1+l/c.bE)}return this._projectSurfacePointToScreen(o)}_projectSurfacePointToScreen(t){const n=c.bF();return c.aH(n,[...t,1],this._globeViewProjMatrixNoCorrection),n[0]/=n[3],n[1]/=n[3],new c.P((.5*n[0]+.5)*this.width,(.5*-n[1]+.5)*this.height)}screenPointToMercatorCoordinate(t,n){if(n){const o=n.pointCoordinate(t);if(o)return o}return c.a9.fromLngLat(this.unprojectScreenPoint(t))}screenPointToLocation(t,n){var o;return(o=this.screenPointToMercatorCoordinate(t,n))===null||o===void 0?void 0:o.toLngLat()}isPointOnMapSurface(t,n){const o=this._cameraPosition,l=this.getRayDirectionFromPixel(t);return!!this.rayPlanetIntersection(o,l)}getRayDirectionFromPixel(t){const n=c.bF();n[0]=t.x/this.width*2-1,n[1]=-1*(t.y/this.height*2-1),n[2]=1,n[3]=1,c.aH(n,n,this._globeViewProjMatrixNoCorrectionInverted),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3];const o=c.bA();o[0]=n[0]-this._cameraPosition[0],o[1]=n[1]-this._cameraPosition[1],o[2]=n[2]-this._cameraPosition[2];const l=c.bA();return c.b3(l,o),l}isSurfacePointVisible(t){const n=this._cachedClippingPlane;return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]+n[3]>=0}isSurfacePointOnScreen(t){if(!this.isSurfacePointVisible(t))return!1;const n=c.bF();return c.aH(n,[...t,1],this._globeViewProjMatrixNoCorrection),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3],n[0]>-1&&n[0]<1&&n[1]>-1&&n[1]<1&&n[2]>-1&&n[2]<1}rayPlanetIntersection(t,n){const o=c.b5(t,n),l=c.bA(),p=c.bA();c.a$(p,n,o),c.b2(l,t,p);const m=1-c.b5(l,l);if(m<0)return null;const _=c.b5(t,t)-1,v=-o+(o<0?1:-1)*Math.sqrt(m),w=_/v,T=v;return{tMin:Math.min(w,T),tMax:Math.max(w,T)}}unprojectScreenPoint(t){const n=this._cameraPosition,o=this.getRayDirectionFromPixel(t),l=this.rayPlanetIntersection(n,o);if(l){const T=c.bA();c.b0(T,n,[o[0]*l.tMin,o[1]*l.tMin,o[2]*l.tMin]);const C=c.bA();return c.b3(C,T),Za(C)}const p=this._cachedClippingPlane,m=p[0]*o[0]+p[1]*o[1]+p[2]*o[2],_=-c.bb(p,n)/m,v=c.bA();if(_>0)c.b0(v,n,[o[0]*_,o[1]*_,o[2]*_]);else{const T=c.bA();c.b0(T,n,[2*o[0],2*o[1],2*o[2]]);const C=c.bb(this._cachedClippingPlane,T);c.b2(v,T,[this._cachedClippingPlane[0]*C,this._cachedClippingPlane[1]*C,this._cachedClippingPlane[2]*C])}const w=(function(T){const C=c.bA();return C[0]=T[0]*-T[3],C[1]=T[1]*-T[3],C[2]=T[2]*-T[3],{center:C,radius:Math.sqrt(1-T[3]*T[3])}})(p);return Za((function(T,C,M){const z=c.bA();c.b2(z,M,T);const R=c.bA();return c.by(R,T,z,C/c.b9(z)),R})(w.center,w.radius,v))}getMatrixForModel(t,n){const o=c.V.convert(t),l=1/c.bE,p=c.bj();return c.bJ(p,p,o.lng/180*Math.PI),c.bh(p,p,-o.lat/180*Math.PI),c.O(p,p,[0,0,1+n/c.bE]),c.bh(p,p,.5*Math.PI),c.Q(p,p,[l,l,l]),p}getProjectionDataForCustomLayer(t=!0){const n=this.getProjectionData({overscaledTileID:new c.a2(0,0,0,0,0),applyGlobeMatrix:t});return n.tileMercatorCoords=[0,0,1,1],n}getFastPathSimpleProjectionMatrix(t){}}class Zi{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(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,n,o){return this._helper.interpolatePadding(t,n,o)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,n,o=!0){this._helper.resize(t,n,o)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,n){this._helper.overrideNearFarZ(t,n)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}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(t,n){this._globeness=t,this._globeLatitudeErrorCorrectionRadians=n,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(t){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this.defaultConstrain=(n,o)=>this.currentTransform.defaultConstrain(n,o),this.applyConstrain=(n,o)=>this._helper.applyConstrain(n,o),this._helper=new jr({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(n,o)=>this.defaultConstrain(n,o)},t),this._globeness=1,this._mercatorTransform=new qi,this._verticalPerspectiveTransform=new ps}clone(){const t=new Zi;return t._globeness=this._globeness,t._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,t.apply(this,!1),t}apply(t,n){this._helper.apply(t,n),this._mercatorTransform.apply(this,!1),this._verticalPerspectiveTransform.apply(this,!1,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(t){const n=this._mercatorTransform.getProjectionData(t),o=this._verticalPerspectiveTransform.getProjectionData(t);return{mainMatrix:this.isGlobeRendering?o.mainMatrix:n.mainMatrix,clippingPlane:o.clippingPlane,tileMercatorCoords:o.tileMercatorCoords,projectionTransition:t.applyGlobeMatrix?this._globeness:0,fallbackMatrix:n.fallbackMatrix}}isLocationOccluded(t){return this.currentTransform.isLocationOccluded(t)}transformLightDirection(t){return this.currentTransform.transformLightDirection(t)}getPixelScale(){return c.bu(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return c.bu(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(t,n,o){const l=this._mercatorTransform.getPitchedTextCorrection(t,n,o),p=this._verticalPerspectiveTransform.getPitchedTextCorrection(t,n,o);return c.bu(l,p,this._globeness)}projectTileCoordinates(t,n,o,l){return this.currentTransform.projectTileCoordinates(t,n,o,l)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,!1,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(t){return this.currentTransform.calculateFogMatrix(t)}getVisibleUnwrappedCoordinates(t){return this.currentTransform.getVisibleUnwrappedCoordinates(t)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(t){this._mercatorTransform.recalculateZoomAndCenter(t),this._verticalPerspectiveTransform.recalculateZoomAndCenter(t)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(t,n){return this.currentTransform.lngLatToCameraDepth(t,n)}populateCache(t){this._mercatorTransform.populateCache(t),this._verticalPerspectiveTransform.populateCache(t)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(t,n,o,l){return this._helper.calculateCenterFromCameraLngLatAlt(t,n,o,l)}setLocationAtPoint(t,n){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(t,n),void this.apply(this._mercatorTransform,!1);this._verticalPerspectiveTransform.setLocationAtPoint(t,n),this.apply(this._verticalPerspectiveTransform,!1)}locationToScreenPoint(t,n){return this.currentTransform.locationToScreenPoint(t,n)}screenPointToMercatorCoordinate(t,n){return this.currentTransform.screenPointToMercatorCoordinate(t,n)}screenPointToLocation(t,n){return this.currentTransform.screenPointToLocation(t,n)}isPointOnMapSurface(t,n){return this.currentTransform.isPointOnMapSurface(t,n)}getRayDirectionFromPixel(t){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(t)}getMatrixForModel(t,n){return this.currentTransform.getMatrixForModel(t,n)}getProjectionDataForCustomLayer(t=!0){const n=this._mercatorTransform.getProjectionDataForCustomLayer(t);if(!this.isGlobeRendering)return n;const o=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(t);return o.fallbackMatrix=n.mainMatrix,o}getFastPathSimpleProjectionMatrix(t){return this.currentTransform.getFastPathSimpleProjectionMatrix(t)}}class mr{get useGlobeControls(){return!0}handlePanInertia(t,n){const o=oc(t,n);return Math.abs(o.lng-n.center.lng)>180&&(o.lng=n.center.lng+179.5*Math.sign(o.lng-n.center.lng)),{easingCenter:o,easingOffset:new c.P(0,0)}}handleMapControlsRollPitchBearingZoom(t,n){const o=t.around,l=n.screenPointToLocation(o);t.bearingDelta&&n.setBearing(n.bearing+t.bearingDelta),t.pitchDelta&&n.setPitch(n.pitch+t.pitchDelta),t.rollDelta&&n.setRoll(n.roll+t.rollDelta);const p=n.zoom;t.zoomDelta&&n.setZoom(n.zoom+t.zoomDelta);const m=n.zoom-p;if(m===0)return;const _=c.bK(n.center.lng,l.lng),v=_/(Math.abs(_/180)+1),w=c.bK(n.center.lat,l.lat),T=n.getRayDirectionFromPixel(o),C=n.cameraPosition,M=-1*c.b5(C,T),z=c.bA();c.b0(z,C,[T[0]*M,T[1]*M,T[2]*M]);const R=c.b7(z)-1,N=Math.exp(.5*-Math.max(R-.3,0)),U=$s(n.worldSize,n.center.lat)/Math.min(n.width,n.height),j=c.bx(U,.9,.5,1,.25),Z=(1-c.aq(-m))*Math.min(N,j),X=n.center.lat,q=n.zoom,Y=new c.V(n.center.lng+v*Z,c.an(n.center.lat+w*Z,-c.ao,c.ao));n.setLocationAtPoint(l,o);const Q=n.center,H=c.bx(Math.abs(_),45,85,0,1),te=c.bx(U,.75,.35,0,1),de=Math.pow(Math.max(H,te),.25),ue=c.bK(Q.lng,Y.lng),ce=c.bK(Q.lat,Y.lat);n.setCenter(new c.V(Q.lng+ue*de,Q.lat+ce*de).wrap()),n.setZoom(q+ni(X,n.center.lat))}handleMapControlsPan(t,n,o){if(!t.panDelta)return;const l=n.center.lat,p=n.zoom;n.setCenter(oc(t.panDelta,n).wrap()),n.setZoom(p+ni(l,n.center.lat))}cameraForBoxAndBearing(t,n,o,l,p){const m=Gs(t,n,o,l,p),_=n.left/p.width*2-1,v=(p.width-n.right)/p.width*2-1,w=n.top/p.height*-2+1,T=(p.height-n.bottom)/p.height*-2+1,C=c.bK(o.getWest(),o.getEast())<0,M=C?o.getEast():o.getWest(),z=C?o.getWest():o.getEast(),R=Math.max(o.getNorth(),o.getSouth()),N=Math.min(o.getNorth(),o.getSouth()),U=M+.5*c.bK(M,z),j=R+.5*c.bK(R,N),Z=p.clone();Z.setCenter(m.center),Z.setBearing(m.bearing),Z.setPitch(0),Z.setRoll(0),Z.setZoom(m.zoom);const X=Z.modelViewProjectionMatrix,q=[ii(o.getNorthWest()),ii(o.getNorthEast()),ii(o.getSouthWest()),ii(o.getSouthEast()),ii(new c.V(z,j)),ii(new c.V(M,j)),ii(new c.V(U,R)),ii(new c.V(U,N))],Y=ii(m.center);let Q=Number.POSITIVE_INFINITY;for(const H of q)_<0&&(Q=mr.getLesserNonNegativeNonNull(Q,mr.solveVectorScale(H,Y,X,"x",_))),v>0&&(Q=mr.getLesserNonNegativeNonNull(Q,mr.solveVectorScale(H,Y,X,"x",v))),w>0&&(Q=mr.getLesserNonNegativeNonNull(Q,mr.solveVectorScale(H,Y,X,"y",w))),T<0&&(Q=mr.getLesserNonNegativeNonNull(Q,mr.solveVectorScale(H,Y,X,"y",T)));if(Number.isFinite(Q)&&Q!==0)return m.zoom=Z.zoom+c.at(Q),m;nc()}handleJumpToCenterZoom(t,n){const o=t.center.lat,l=t.applyConstrain(n.center?c.V.convert(n.center):t.center,t.zoom).center;t.setCenter(l.wrap());const p=n.zoom!==void 0?+n.zoom:t.zoom+ni(o,l.lat);t.zoom!==p&&t.setZoom(p)}handleEaseTo(t,n){const o=t.zoom,l=t.center,p=t.padding,m={roll:t.roll,pitch:t.pitch,bearing:t.bearing},_={roll:n.roll===void 0?t.roll:n.roll,pitch:n.pitch===void 0?t.pitch:n.pitch,bearing:n.bearing===void 0?t.bearing:n.bearing},v=n.zoom!==void 0,w=!t.isPaddingEqual(n.padding);let T=!1;const C=n.center?c.V.convert(n.center):l,M=t.applyConstrain(C,o).center;zt(t,M);const z=t.clone();z.setCenter(M),z.setZoom(v?+n.zoom:o+ni(l.lat,C.lat)),z.setBearing(n.bearing);const R=new c.P(c.an(t.centerPoint.x+n.offsetAsPoint.x,0,t.width),c.an(t.centerPoint.y+n.offsetAsPoint.y,0,t.height));z.setLocationAtPoint(M,R);const N=(n.offset&&n.offsetAsPoint.mag())>0?z.center:M,U=v?+n.zoom:o+ni(l.lat,N.lat),j=o+ni(l.lat,0),Z=U+ni(N.lat,0),X=c.bK(l.lng,N.lng),q=c.bK(l.lat,N.lat),Y=c.aq(Z-j);return T=U!==o,{easeFunc:Q=>{if(c.bo(m,_)||qa({startEulerAngles:m,endEulerAngles:_,tr:t,k:Q,useSlerp:m.roll!=_.roll}),w&&t.interpolatePadding(p,n.padding,Q),n.around)c.w("Easing around a point is not supported under globe projection."),t.setLocationAtPoint(n.around,n.aroundPoint);else{const H=Z>j?Math.min(2,Y):Math.max(.5,Y),te=Math.pow(H,1-Q),de=ac(l,X,q,Q*te);t.setCenter(de.wrap())}if(T){const H=c.G.number(j,Z,Q)+ni(0,t.center.lat);t.setZoom(H)}},isZooming:T,elevationCenter:N}}handleFlyTo(t,n){const o=n.zoom!==void 0,l=t.center,p=t.zoom,m=t.padding,_=!t.isPaddingEqual(n.padding),v=t.applyConstrain(c.V.convert(n.center||n.locationAtOffset),p).center,w=o?+n.zoom:t.zoom+ni(t.center.lat,v.lat),T=t.clone();T.setCenter(v),T.setZoom(w),T.setBearing(n.bearing);const C=new c.P(c.an(t.centerPoint.x+n.offsetAsPoint.x,0,t.width),c.an(t.centerPoint.y+n.offsetAsPoint.y,0,t.height));T.setLocationAtPoint(v,C);const M=T.center;zt(t,M);const z=(function(q,Y,Q){const H=ii(Y),te=ii(Q),de=c.b5(H,te),ue=Math.acos(de),ce=Uo(q);return ue/(2*Math.PI)*ce})(t,l,M),R=p+ni(l.lat,0),N=w+ni(M.lat,0),U=c.aq(N-R);let j;if(typeof n.minZoom=="number"){const q=+n.minZoom+ni(M.lat,0),Y=Math.min(q,R,N)+ni(0,M.lat),Q=t.applyConstrain(M,Y).zoom+ni(M.lat,0);j=c.aq(Q-R)}const Z=c.bK(l.lng,M.lng),X=c.bK(l.lat,M.lat);return{easeFunc:(q,Y,Q,H)=>{const te=ac(l,Z,X,Q);_&&t.interpolatePadding(m,n.padding,q);const de=q===1?M:te;t.setCenter(de.wrap());const ue=R+c.at(Y);t.setZoom(q===1?w:ue+ni(0,de.lat))},scaleOfZoom:U,targetCenter:M,scaleOfMinZoom:j,pixelPathLength:z}}static solveVectorScale(t,n,o,l,p){const m=l==="x"?[o[0],o[4],o[8],o[12]]:[o[1],o[5],o[9],o[13]],_=[o[3],o[7],o[11],o[15]],v=t[0]*m[0]+t[1]*m[1]+t[2]*m[2],w=t[0]*_[0]+t[1]*_[1]+t[2]*_[2],T=n[0]*m[0]+n[1]*m[1]+n[2]*m[2],C=n[0]*_[0]+n[1]*_[1]+n[2]*_[2];return T+p*w===v+p*C||_[3]*(v-T)+m[3]*(C-w)+v*C==T*w?null:(T+m[3]-p*C-p*_[3])/(T-v-p*C+p*w)}static getLesserNonNegativeNonNull(t,n){return n!==null&&n>=0&&n<t?n:t}}class Zo{constructor(t){this._globe=t,this._mercatorCameraHelper=new kn,this._verticalPerspectiveCameraHelper=new mr}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(t,n){return this.currentHelper.handlePanInertia(t,n)}handleMapControlsRollPitchBearingZoom(t,n){return this.currentHelper.handleMapControlsRollPitchBearingZoom(t,n)}handleMapControlsPan(t,n,o){this.currentHelper.handleMapControlsPan(t,n,o)}cameraForBoxAndBearing(t,n,o,l,p){return this.currentHelper.cameraForBoxAndBearing(t,n,o,l,p)}handleJumpToCenterZoom(t,n){this.currentHelper.handleJumpToCenterZoom(t,n)}handleEaseTo(t,n){return this.currentHelper.handleEaseTo(t,n)}handleFlyTo(t,n){return this.currentHelper.handleFlyTo(t,n)}}const pn=(d,t)=>c.B(d,t&&t.filter((n=>n.identifier!=="source.canvas"))),Ws=c.bO();class Ha extends c.E{constructor(t,n={}){var o,l;super(),this._rtlPluginLoaded=()=>{for(const m in this.tileManagers){const _=this.tileManagers[m].getSource().type;_!=="vector"&&_!=="geojson"||this.tileManagers[m].reload()}},this.map=t,this.dispatcher=new wn(Qn(),t._getMapId()),this.dispatcher.registerMessageHandler("GG",((m,_)=>this.getGlyphs(m,_))),this.dispatcher.registerMessageHandler("GI",((m,_)=>this.getImages(m,_))),this.dispatcher.registerMessageHandler("GDA",((m,_)=>this.getDashes(m,_))),this.imageManager=new nn,this.imageManager.setEventedParent(this);const p=((o=t._container)===null||o===void 0?void 0:o.lang)||typeof document<"u"&&((l=document.documentElement)===null||l===void 0?void 0:l.lang)||void 0;this.glyphManager=new Lr(t._requestManager,n.localIdeographFontFamily,p),this.lineAtlas=new Jn(256,512),this.crossTileSymbolIndex=new _i,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",c.bP()),F().on(ie,this._rtlPluginLoaded),this.on("data",(m=>{if(m.dataType!=="source"||m.sourceDataType!=="metadata")return;const _=this.tileManagers[m.sourceId];if(!_)return;const v=_.getSource();if(v&&v.vectorLayerIds)for(const w in this._layers){const T=this._layers[w];T.source===v.id&&this._validateLayer(T)}}))}_setInitialValues(){var t;this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new c.bQ,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(((t=this.crossTileSymbolIndex)===null||t===void 0?void 0:t.constructor)||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(t,n){var o,l,p;this._checkLoaded();const m=n===null?(p=(l=(o=this.stylesheet.state)===null||o===void 0?void 0:o[t])===null||l===void 0?void 0:l.default)!==null&&p!==void 0?p:null:n;if(c.bR(m,this._globalState[t]))return this;this._globalState[t]=m,this._applyGlobalStateChanges([t])}getGlobalState(){return this._globalState}setGlobalState(t){this._checkLoaded();const n=[];for(const o in t)!c.bR(this._globalState[o],t[o].default)&&(n.push(o),this._globalState[o]=t[o].default);this._applyGlobalStateChanges(n)}_applyGlobalStateChanges(t){if(t.length===0)return;const n=new Set,o={};for(const l of t){o[l]=this._globalState[l];for(const p in this._layers){const m=this._layers[p],_=m.getLayoutAffectingGlobalStateRefs(),v=m.getPaintAffectingGlobalStateRefs(),w=m.getVisibilityAffectingGlobalStateRefs();if(_.has(l)&&n.add(m.source),v.has(l))for(const{name:T,value:C}of v.get(l))this._updatePaintProperty(m,T,C);w?.has(l)&&(m.recalculateVisibility(),this._updateLayer(m))}}this.dispatcher.broadcast("UGS",o);for(const l in this.tileManagers)n.has(l)&&(this._reloadSource(l),this._changed=!0)}loadURL(t,n={},o){this.fire(new c.l("dataloading",{dataType:"style"})),n.validate=typeof n.validate!="boolean"||n.validate;const l=this.map._requestManager.transformRequest(t,"Style");this._loadStyleRequest=new AbortController;const p=this._loadStyleRequest;c.j(l,this._loadStyleRequest).then((m=>{this._loadStyleRequest=null,this._load(m.data,n,o)})).catch((m=>{this._loadStyleRequest=null,m&&!p.signal.aborted&&this.fire(new c.k(m))}))}loadJSON(t,n={},o){this.fire(new c.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,$t.frameAsync(this._frameRequest,this.map._ownerWindow).then((()=>{this._frameRequest=null,n.validate=n.validate!==!1,this._load(t,n,o)})).catch((()=>{}))}loadEmpty(){this.fire(new c.l("dataloading",{dataType:"style"})),this._load(Ws,{validate:!1})}_load(t,n,o){var l,p;let m=n.transformStyle?n.transformStyle(o,t):t;if(!n.validate||!pn(this,c.C(m))){m=Object.assign({},m),this._loaded=!0,this.stylesheet=m;for(const _ in m.sources)this.addSource(_,m.sources[_],{validate:!1});m.sprite?this._loadSprite(m.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(m.glyphs),this._createLayers(),this.light=new bn(this.stylesheet.light),this._setProjectionInternal(((l=this.stylesheet.projection)===null||l===void 0?void 0:l.type)||"mercator"),this.sky=new Ls(this.stylesheet.sky),this.map.setTerrain((p=this.stylesheet.terrain)!==null&&p!==void 0?p:null),this.fire(new c.l("data",{dataType:"style"})),this.fire(new c.l("style.load"))}}_createLayers(){var t,n,o;const l=c.bS(this.stylesheet.layers);this.setGlobalState((t=this.stylesheet.state)!==null&&t!==void 0?t:null),this.dispatcher.broadcast("SL",l),this._order=l.map((p=>p.id)),this._layers={},this._serializedLayers=null;for(const p of l){const m=c.bT(p,this._globalState);if(m.setEventedParent(this,{layer:{id:p.id}}),this._layers[p.id]=m,c.bU(m)&&this.tileManagers[m.source]){const _=(o=(n=p.paint)===null||n===void 0?void 0:n["raster-fade-duration"])!==null&&o!==void 0?o:m.paint.get("raster-fade-duration");this.tileManagers[m.source].setRasterFadeDuration(_)}}}_loadSprite(t,n=!1,o=void 0){this.imageManager.setLoaded(!1);const l=new AbortController;let p;this._spriteRequest=l,(function(m,_,v,w){return c._(this,void 0,void 0,(function*(){const T=wr(m),C=v>1?"@2x":"",M={},z={};for(const{id:R,url:N}of T){const U=_.transformRequest(rn(N,C,".json"),"SpriteJSON");M[R]=c.j(U,w);const j=_.transformRequest(rn(N,C,".png"),"SpriteImage");z[R]=Ni.getImage(j,w)}return yield Promise.all([...Object.values(M),...Object.values(z)]),(function(R,N){return c._(this,void 0,void 0,(function*(){const U={};for(const j in R){U[j]={};const Z=$t.getImageCanvasContext((yield N[j]).data),X=(yield R[j]).data;for(const q in X){const{width:Y,height:Q,x:H,y:te,sdf:de,pixelRatio:ue,stretchX:ce,stretchY:he,content:Ce,textFitWidth:Ie,textFitHeight:ge}=X[q];U[j][q]={data:null,pixelRatio:ue,sdf:de,stretchX:ce,stretchY:he,content:Ce,textFitWidth:Ie,textFitHeight:ge,spriteData:{width:Y,height:Q,x:H,y:te,context:Z}}}}return U}))})(M,z)}))})(t,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((m=>{if(this._spriteRequest=null,m)for(const _ in m){this._spritesImagesIds[_]=[];const v=this._spritesImagesIds[_]?this._spritesImagesIds[_].filter((w=>!(w in m))):[];for(const w of v)this.imageManager.removeImage(w),this._changedImages[w]=!0;for(const w in m[_]){const T=_==="default"?w:`${_}:${w}`;this._spritesImagesIds[_].push(T),T in this.imageManager.images?this.imageManager.updateImage(T,m[_][w],!1):this.imageManager.addImage(T,m[_][w]),n&&(this._changedImages[T]=!0)}}})).catch((m=>{this._spriteRequest=null,p=m,l.signal.aborted||this.fire(new c.k(p))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new c.l("data",{dataType:"style"})),o&&o(p)}))}_unloadSprite(){for(const t of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(t),this._changedImages[t]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new c.l("data",{dataType:"style"}))}_validateLayer(t){const n=this.tileManagers[t.source];if(!n)return;const o=t.sourceLayer;if(!o)return;const l=n.getSource();(l.type==="geojson"||l.vectorLayerIds&&l.vectorLayerIds.indexOf(o)===-1)&&this.fire(new c.k(new Error(`Source layer "${o}" does not exist on source "${l.id}" as specified by style layer "${t.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const t in this.tileManagers)if(!this.tileManagers[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(t,n=!1){const o=this._serializedAllLayers();if(!t||t.length===0)return Object.values(n?c.bV(o):o);const l=[];for(const p of t)if(o[p]){const m=n?c.bV(o[p]):o[p];l.push(m)}return l}_serializedAllLayers(){let t=this._serializedLayers;if(t)return t;t=this._serializedLayers={};const n=Object.keys(this._layers);for(const o of n){const l=this._layers[o];l.type!=="custom"&&(t[o]=l.serialize())}return t}hasTransitions(){var t,n,o;if(!((t=this.light)===null||t===void 0)&&t.hasTransition()||!((n=this.sky)===null||n===void 0)&&n.hasTransition()||!((o=this.projection)===null||o===void 0)&&o.hasTransition())return!0;for(const l in this.tileManagers)if(this.tileManagers[l].hasTransition())return!0;for(const l in this._layers)if(this._layers[l].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(t){if(!this._loaded)return;const n=this._changed;if(n){const l=Object.keys(this._updatedLayers),p=Object.keys(this._removedLayers);(l.length||p.length)&&this._updateWorkerLayers(l,p);for(const m in this._updatedSources){const _=this._updatedSources[m];if(_==="reload")this._reloadSource(m);else{if(_!=="clear")throw new Error(`Invalid action ${_}`);this._clearSource(m)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const m in this._updatedPaintProps)this._layers[m].updateTransitions(t);this.light.updateTransitions(t),this.sky.updateTransitions(t),this._resetUpdates()}const o={};for(const l in this.tileManagers){const p=this.tileManagers[l];o[l]=p.used,p.used=!1}for(const l of this._order){const p=this._layers[l];p.recalculate(t,this._availableImages),!p.isHidden(t.zoom)&&p.source&&(this.tileManagers[p.source].used=!0)}for(const l in o){const p=this.tileManagers[l];!!o[l]!=!!p.used&&p.fire(new c.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:l}))}this.light.recalculate(t),this.sky.recalculate(t),this.projection.recalculate(t),this.z=t.zoom,n&&this.fire(new c.l("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const n in this.tileManagers)this.tileManagers[n].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(t,n){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(t,!1),removedIds:n})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(t,n={}){var o;this._checkLoaded();const l=this.serialize();if(t=n.transformStyle?n.transformStyle(l,t):t,((o=n.validate)===null||o===void 0||o)&&pn(this,c.C(t)))return!1;(t=c.bV(t)).layers=c.bS(t.layers);const p=c.bW(l,t),m=this._getOperationsToPerform(p);if(m.unimplemented.length>0)throw new Error(`Unimplemented: ${m.unimplemented.join(", ")}.`);if(m.operations.length===0)return!1;for(const _ of m.operations)_();return this.stylesheet=t,this._serializedLayers=null,this.fire(new c.l("style.load",{style:this})),!0}_getOperationsToPerform(t){const n=[],o=[];for(const l of t)switch(l.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":n.push((()=>this.addLayer.apply(this,l.args)));break;case"removeLayer":n.push((()=>this.removeLayer.apply(this,l.args)));break;case"setPaintProperty":n.push((()=>this.setPaintProperty.apply(this,l.args)));break;case"setLayoutProperty":n.push((()=>this.setLayoutProperty.apply(this,l.args)));break;case"setFilter":n.push((()=>this.setFilter.apply(this,l.args)));break;case"addSource":n.push((()=>this.addSource.apply(this,l.args)));break;case"removeSource":n.push((()=>this.removeSource.apply(this,l.args)));break;case"setLayerZoomRange":n.push((()=>this.setLayerZoomRange.apply(this,l.args)));break;case"setLight":n.push((()=>this.setLight.apply(this,l.args)));break;case"setGeoJSONSourceData":n.push((()=>this.setGeoJSONSourceData.apply(this,l.args)));break;case"setGlyphs":n.push((()=>this.setGlyphs.apply(this,l.args)));break;case"setSprite":n.push((()=>this.setSprite.apply(this,l.args)));break;case"setTerrain":n.push((()=>this.map.setTerrain.apply(this,l.args)));break;case"setSky":n.push((()=>this.setSky.apply(this,l.args)));break;case"setProjection":this.setProjection.apply(this,l.args);break;case"setGlobalState":n.push((()=>this.setGlobalState.apply(this,l.args)));break;case"setTransition":n.push((()=>{}));break;default:o.push(l.command)}return{operations:n,unimplemented:o}}addImage(t,n){if(this.getImage(t))return this.fire(new c.k(new Error(`An image named "${t}" already exists.`)));this.imageManager.addImage(t,n),this._afterImageUpdated(t)}updateImage(t,n){this.imageManager.updateImage(t,n)}getImage(t){return this.imageManager.getImage(t)}removeImage(t){if(!this.getImage(t))return this.fire(new c.k(new Error(`An image named "${t}" does not exist.`)));this.imageManager.removeImage(t),this._afterImageUpdated(t)}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new c.l("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,n,o={}){if(this._checkLoaded(),this.tileManagers[t]!==void 0)throw new Error(`Source "${t}" already exists.`);if(!n.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(c.C.source,`sources.${t}`,n,null,o))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const l=this.tileManagers[t]=new Me(t,n,this.dispatcher);l.style=this,l.setEventedParent(this,(()=>({isSourceLoaded:l.loaded(),source:l.serialize(),sourceId:t}))),l.onAdd(this.map),this._changed=!0}removeSource(t){if(this._checkLoaded(),this.tileManagers[t]===void 0)throw new Error(`There is no source with this ID=${t}`);for(const o in this._layers)if(this._layers[o].source===t)return this.fire(new c.k(new Error(`Source "${t}" cannot be removed while layer "${o}" is using it.`)));const n=this.tileManagers[t];delete this.tileManagers[t],delete this._updatedSources[t],n.fire(new c.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:t})),n.setEventedParent(null),n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,n){if(this._checkLoaded(),this.tileManagers[t]===void 0)throw new Error(`There is no source with this ID=${t}`);const o=this.tileManagers[t].getSource();if(o.type!=="geojson")throw new Error(`geojsonSource.type is ${o.type}, which is !== 'geojson`);o.setData(n),this._changed=!0}getSource(t){return this.tileManagers[t]&&this.tileManagers[t].getSource()}addLayer(t,n,o={}){this._checkLoaded();const l=t.id;if(this.getLayer(l))return void this.fire(new c.k(new Error(`Layer "${l}" already exists on this map.`)));let p;if(t.type==="custom"){if(pn(this,c.bX(t)))return;p=c.bT(t,this._globalState)}else{if("source"in t&&typeof t.source=="object"&&(this.addSource(l,t.source),t=c.bV(t),t=c.e(t,{source:l})),this._validate(c.C.layer,`layers.${l}`,t,{arrayIndex:-1},o))return;p=c.bT(t,this._globalState),this._validateLayer(p),p.setEventedParent(this,{layer:{id:l}})}const m=n?this._order.indexOf(n):this._order.length;if(n&&m===-1)this.fire(new c.k(new Error(`Cannot add layer "${l}" before non-existing layer "${n}".`)));else{if(this._order.splice(m,0,l),this._layerOrderChanged=!0,this._layers[l]=p,this._removedLayers[l]&&p.source&&p.type!=="custom"){const _=this._removedLayers[l];delete this._removedLayers[l],_.type!==p.type?this._updatedSources[p.source]="clear":(this._updatedSources[p.source]="reload",this.tileManagers[p.source].pause())}this._updateLayer(p),p.onAdd&&p.onAdd(this.map)}}moveLayer(t,n){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new c.k(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===n)return;const o=this._order.indexOf(t);this._order.splice(o,1);const l=n?this._order.indexOf(n):this._order.length;n&&l===-1?this.fire(new c.k(new Error(`Cannot move layer "${t}" before non-existing layer "${n}".`))):(this._order.splice(l,0,t),this._layerOrderChanged=!0)}removeLayer(t){this._checkLoaded();const n=this._layers[t];if(!n)return void this.fire(new c.k(new Error(`Cannot remove non-existing layer "${t}".`)));n.setEventedParent(null);const o=this._order.indexOf(t);this._order.splice(o,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=n,delete this._layers[t],this._serializedLayers&&delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],n.onRemove&&n.onRemove(this.map)}getLayer(t){return this._layers[t]}getLayersOrder(){return[...this._order]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,n,o){this._checkLoaded();const l=this.getLayer(t);l?l.minzoom===n&&l.maxzoom===o||(n!=null&&(l.minzoom=n),o!=null&&(l.maxzoom=o),this._updateLayer(l)):this.fire(new c.k(new Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,n,o={}){this._checkLoaded();const l=this.getLayer(t);if(l){if(!c.bR(l.filter,n))return n==null?(l.setFilter(void 0),void this._updateLayer(l)):void(this._validate(c.C.filter,`layers.${l.id}.filter`,n,null,o)||(l.setFilter(c.bV(n)),this._updateLayer(l)))}else this.fire(new c.k(new Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return c.bV(this.getLayer(t).filter)}setLayoutProperty(t,n,o,l={}){this._checkLoaded();const p=this.getLayer(t);p?c.bR(p.getLayoutProperty(n),o)||(p.setLayoutProperty(n,o,l),this._updateLayer(p)):this.fire(new c.k(new Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,n){const o=this.getLayer(t);if(o)return o.getLayoutProperty(n);this.fire(new c.k(new Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,n,o,l={}){this._checkLoaded();const p=this.getLayer(t);p?c.bR(p.getPaintProperty(n),o)||this._updatePaintProperty(p,n,o,l):this.fire(new c.k(new Error(`Cannot style non-existing layer "${t}".`)))}_updatePaintProperty(t,n,o,l={}){t.setPaintProperty(n,o,l)&&this._updateLayer(t),c.bU(t)&&n==="raster-fade-duration"&&this.tileManagers[t.source].setRasterFadeDuration(o),this._changed=!0,this._updatedPaintProps[t.id]=!0,this._serializedLayers=null}getPaintProperty(t,n){return this.getLayer(t).getPaintProperty(n)}setFeatureState(t,n){this._checkLoaded();const o=t.source,l=t.sourceLayer,p=this.tileManagers[o];if(p===void 0)return void this.fire(new c.k(new Error(`The source '${o}' does not exist in the map's style.`)));const m=p.getSource().type;m==="geojson"&&l?this.fire(new c.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):m!=="vector"||l?(t.id===void 0&&this.fire(new c.k(new Error("The feature id parameter must be provided."))),p.setFeatureState(l,t.id,n)):this.fire(new c.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(t,n){this._checkLoaded();const o=t.source,l=this.tileManagers[o];if(l===void 0)return void this.fire(new c.k(new Error(`The source '${o}' does not exist in the map's style.`)));const p=l.getSource().type,m=p==="vector"?t.sourceLayer:void 0;p!=="vector"||m?n&&typeof t.id!="string"&&typeof t.id!="number"?this.fire(new c.k(new Error("A feature id is required to remove its specific state property."))):l.removeFeatureState(m,t.id,n):this.fire(new c.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();const n=t.source,o=t.sourceLayer,l=this.tileManagers[n];if(l!==void 0)return l.getSource().type!=="vector"||o?(t.id===void 0&&this.fire(new c.k(new Error("The feature id parameter must be provided."))),l.getFeatureState(o,t.id)):void this.fire(new c.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new c.k(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return c.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const t=c.bY(this.tileManagers,(p=>p.serialize())),n=this._serializeByIds(this._order,!0),o=this.map.getTerrain()||void 0,l=this.stylesheet;return c.bZ({version:l.version,name:l.name,metadata:l.metadata,light:l.light,sky:l.sky,center:l.center,zoom:l.zoom,bearing:l.bearing,pitch:l.pitch,sprite:l.sprite,glyphs:l.glyphs,transition:l.transition,projection:l.projection,sources:t,layers:n,terrain:o},(p=>p!==void 0))}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&this.tileManagers[t.source].getSource().type!=="raster"&&(this._updatedSources[t.source]="reload",this.tileManagers[t.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(t){const n=m=>this._layers[m].type==="fill-extrusion",o={},l=[];for(let m=this._order.length-1;m>=0;m--){const _=this._order[m];if(n(_)){o[_]=m;for(const v of t){const w=v[_];if(w)for(const T of w)l.push(T)}}}l.sort(((m,_)=>_.intersectionZ-m.intersectionZ));const p=[];for(let m=this._order.length-1;m>=0;m--){const _=this._order[m];if(n(_))for(let v=l.length-1;v>=0;v--){const w=l[v].feature;if(o[w.layer.id]<m)break;p.push(w),l.pop()}else for(const v of t){const w=v[_];if(w)for(const T of w)p.push(T.feature)}}return p}queryRenderedFeatures(t,n,o){n&&n.filter&&this._validate(c.C.filter,"queryRenderedFeatures.filter",n.filter,null,n);const l={};if(n&&n.layers){if(!(Array.isArray(n.layers)||n.layers instanceof Set))return this.fire(new c.k(new Error("parameters.layers must be an Array or a Set of strings"))),[];for(const w of n.layers){const T=this._layers[w];if(!T)return this.fire(new c.k(new Error(`The layer '${w}' does not exist in the map's style and cannot be queried for features.`))),[];l[T.source]=!0}}const p=[];n.availableImages=this._availableImages;const m=this._serializedAllLayers(),_=n.layers instanceof Set?n.layers:Array.isArray(n.layers)?new Set(n.layers):null,v=Object.assign(Object.assign({},n),{layers:_,globalState:this._globalState});for(const w in this.tileManagers)n.layers&&!l[w]||p.push(zo(this.tileManagers[w],this._layers,m,t,v,o,this.map.terrain?(T,C,M)=>this.map.terrain.getElevation(T,C,M):void 0));return this.placement&&p.push((function(w,T,C,M,z,R,N){const U={},j=R.queryRenderedSymbols(M),Z=[];for(const X of Object.keys(j).map(Number))Z.push(N[X]);Z.sort(gi);for(const X of Z){const q=X.featureIndex.lookupSymbolFeatures(j[X.bucketInstanceId],T,X.bucketIndex,X.sourceLayerIndex,{filterSpec:z.filter,globalState:z.globalState},z.layers,z.availableImages,w);for(const Y in q){const Q=U[Y]=U[Y]||[],H=q[Y];H.sort(((te,de)=>{const ue=X.featureSortOrder;if(ue){const ce=ue.indexOf(te.featureIndex);return ue.indexOf(de.featureIndex)-ce}return de.featureIndex-te.featureIndex}));for(const te of H)Q.push(te)}}return(function(X,q,Y){for(const Q in X)for(const H of X[Q])ji(H,Y[q[Q].source]);return X})(U,w,C)})(this._layers,m,this.tileManagers,t,v,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(p)}querySourceFeatures(t,n){n?.filter&&this._validate(c.C.filter,"querySourceFeatures.filter",n.filter,null,n);const o=this.tileManagers[t];return o?(function(l,p){const m=l.getRenderableIds().map((w=>l.getTileByID(w))),_=[],v={};for(let w=0;w<m.length;w++){const T=m[w],C=T.tileID.canonical.key;v[C]||(v[C]=!0,T.querySourceFeatures(_,p))}return _})(o,n?Object.assign(Object.assign({},n),{globalState:this._globalState}):{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(t,n={}){this._checkLoaded();const o=this.light.getLight();let l=!1;for(const m in t)if(!c.bR(t[m],o[m])){l=!0;break}if(!l)return;const p={now:He(),transition:c.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,n),this.light.updateTransitions(p)}getProjection(){var t;return(t=this.stylesheet)===null||t===void 0?void 0:t.projection}setProjection(t){if(this._checkLoaded(),this.stylesheet.projection=t,this.projection){if(this.projection.name===t.type)return;this.projection.destroy(),delete this.projection}this._setProjectionInternal(t.type)}getSky(){var t;return(t=this.stylesheet)===null||t===void 0?void 0:t.sky}setSky(t,n={}){this._checkLoaded();const o=this.getSky();let l=!1;if(!t&&!o)return;if(t&&!o)l=!0;else if(!t&&o)l=!0;else for(const m in t)if(!c.bR(t[m],o[m])){l=!0;break}if(!l)return;const p={now:He(),transition:c.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=t,this.sky.setSky(t,n),this.sky.updateTransitions(p)}_setProjectionInternal(t){const n=(function(o,l){const p={constrainOverride:l};if(Array.isArray(o)){const m=new Pi({type:o});return{projection:m,transform:new Zi(p),cameraHelper:new Zo(m)}}switch(o){case"mercator":return{projection:new Oo,transform:new qi(p),cameraHelper:new kn};case"globe":{const m=new Pi({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]});return{projection:m,transform:new Zi(p),cameraHelper:new Zo(m)}}case"vertical-perspective":return{projection:new sc,transform:new ps(p),cameraHelper:new mr};default:return c.w(`Unknown projection name: ${o}. Falling back to mercator projection.`),{projection:new Oo,transform:new qi(p),cameraHelper:new kn}}})(t,this.map.transformConstrain);this.projection=n.projection,this.map.migrateProjection(n.transform,n.cameraHelper);for(const o in this.tileManagers)this.tileManagers[o].reload()}_validate(t,n,o,l,p={}){return(!p||p.validate!==!1)&&pn(this,t.call(c.C,c.e({key:n,style:this.serialize(),value:o,styleSpec:c.u},l)))}_remove(t=!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),F().off(ie,this._rtlPluginLoaded);for(const n in this._layers)this._layers[n].setEventedParent(null);for(const n in this.tileManagers){const o=this.tileManagers[n];o.setEventedParent(null),o.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),t&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(t)}_clearSource(t){this.tileManagers[t].clearTiles()}_reloadSource(t){this.tileManagers[t].resume(),this.tileManagers[t].reload()}_updateSources(t){for(const n in this.tileManagers)this.tileManagers[n].update(t,this.map.terrain)}_generateCollisionBoxes(){for(const t in this.tileManagers)this._reloadSource(t)}_updatePlacement(t,n,o,l,p=!1){let m=!1,_=!1;const v={};for(const w of this._order){const T=this._layers[w];if(T.type!=="symbol")continue;if(!v[T.source]){const M=this.tileManagers[T.source];v[T.source]=M.getRenderableIds(!0).map((z=>M.getTileByID(z))).sort(((z,R)=>R.tileID.overscaledZ-z.tileID.overscaledZ||(z.tileID.isLessThan(R.tileID)?-1:1)))}const C=this.crossTileSymbolIndex.addLayer(T,v[T.source],t.center.lng);m=m||C}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((p=p||this._layerOrderChanged||o===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(He(),t.zoom))&&(this.pauseablePlacement=new st(t,this.map.terrain,this._order,p,n,o,l,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,v),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(He()),_=!0),m&&this.pauseablePlacement.placement.setStale()),_||m)for(const w of this._order){const T=this._layers[w];T.type==="symbol"&&this.placement.updateLayerOpacities(T,v[T.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(He())}_releaseSymbolFadeTiles(){for(const t in this.tileManagers)this.tileManagers[t].releaseSymbolFadeTiles()}getImages(t,n){return c._(this,void 0,void 0,(function*(){const o=yield this.imageManager.getImages(n.icons);this._updateTilesForChangedImages();const l=this.tileManagers[n.source];return l&&l.setDependencies(n.tileID.key,n.type,n.icons),o}))}getGlyphs(t,n){return c._(this,void 0,void 0,(function*(){const o=yield this.glyphManager.getGlyphs(n.stacks),l=this.tileManagers[n.source];return l&&l.setDependencies(n.tileID.key,n.type,[""]),o}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,n={}){this._checkLoaded(),t&&this._validate(c.C.glyphs,"glyphs",t,null,n)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}getDashes(t,n){return c._(this,void 0,void 0,(function*(){const o={};for(const[l,p]of Object.entries(n.dashes))o[l]=this.lineAtlas.getDash(p.dasharray,p.round);return o}))}addSprite(t,n,o={},l){this._checkLoaded();const p=[{id:t,url:n}],m=[...wr(this.stylesheet.sprite),...p];this._validate(c.C.sprite,"sprite",m,null,o)||(this.stylesheet.sprite=m,this._loadSprite(p,!0,l))}removeSprite(t){this._checkLoaded();const n=wr(this.stylesheet.sprite);if(n.find((o=>o.id===t))){if(this._spritesImagesIds[t])for(const o of this._spritesImagesIds[t])this.imageManager.removeImage(o),this._changedImages[o]=!0;n.splice(n.findIndex((o=>o.id===t)),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[t],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new c.l("data",{dataType:"style"}))}else this.fire(new c.k(new Error(`Sprite "${t}" doesn't exists on this map.`)))}getSprite(){return wr(this.stylesheet.sprite)}setSprite(t,n={},o){this._checkLoaded(),t&&this._validate(c.C.sprite,"sprite",t,null,n)||(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,o):(this._unloadSprite(),o&&o(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 t in this.tileManagers){const n=this.tileManagers[t];n.setEventedParent(null),n.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 t in this._layers){const n=this._layers[t];n.setEventedParent(null),n.onRemove&&n.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 $o=c.aU([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Bu{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,n,o,l,p,m,_,v,w){this.context=t;let T=this.boundPaintVertexBuffers.length!==l.length;for(let C=0;!T&&C<l.length;C++)this.boundPaintVertexBuffers[C]!==l[C]&&(T=!0);!this.vao||this.boundProgram!==n||this.boundLayoutVertexBuffer!==o||T||this.boundIndexBuffer!==p||this.boundVertexOffset!==m||this.boundDynamicVertexBuffer!==_||this.boundDynamicVertexBuffer2!==v||this.boundDynamicVertexBuffer3!==w?this.freshBind(n,o,l,p,m,_,v,w):(t.bindVertexArray.set(this.vao),_&&_.bind(),p&&p.dynamicDraw&&p.bind(),v&&v.bind(),w&&w.bind())}freshBind(t,n,o,l,p,m,_,v){const w=t.numAttributes,T=this.context,C=T.gl;this.vao&&this.destroy(),this.vao=T.createVertexArray(),T.bindVertexArray.set(this.vao),this.boundProgram=t,this.boundLayoutVertexBuffer=n,this.boundPaintVertexBuffers=o,this.boundIndexBuffer=l,this.boundVertexOffset=p,this.boundDynamicVertexBuffer=m,this.boundDynamicVertexBuffer2=_,this.boundDynamicVertexBuffer3=v,n.enableAttributes(C,t);for(const M of o)M.enableAttributes(C,t);m&&m.enableAttributes(C,t),_&&_.enableAttributes(C,t),v&&v.enableAttributes(C,t),n.bind(),n.setVertexAttribPointers(C,t,p);for(const M of o)M.bind(),M.setVertexAttribPointers(C,t,p);m&&(m.bind(),m.setVertexAttribPointers(C,t,p)),l&&l.bind(),_&&(_.bind(),_.setVertexAttribPointers(C,t,p)),v&&(v.bind(),v.setVertexAttribPointers(C,t,p)),T.currentNumAttributes=w}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const fs=(d,t,n,o,l)=>({u_texture:0,u_ele_delta:d,u_fog_matrix:t,u_fog_color:n?n.properties.get("fog-color"):c.bp.white,u_fog_ground_blend:n?n.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:l?0:n?n.calculateFogBlendOpacity(o):0,u_horizon_color:n?n.properties.get("horizon-color"):c.bp.white,u_horizon_fog_blend:n?n.properties.get("horizon-fog-blend"):1,u_is_globe_mode:l?1:0}),Ou={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 Xs(d){const t=[];for(let n=0;n<d.length;n++){if(d[n]===null)continue;const o=d[n].split(" ");t.push(o.pop())}return t}class Vu{constructor(t,n,o,l,p,m,_,v,w=[]){const T=t.gl;this.program=T.createProgram();const C=Xs(n.staticAttributes),M=o?o.getBinderAttributes():[],z=C.concat(M),R=Pt.prelude.staticUniforms?Xs(Pt.prelude.staticUniforms):[],N=_.staticUniforms?Xs(_.staticUniforms):[],U=n.staticUniforms?Xs(n.staticUniforms):[],j=o?o.getBinderUniforms():[],Z=R.concat(N).concat(U).concat(j),X=[];for(const ue of Z)X.indexOf(ue)<0&&X.push(ue);const q=o?o.defines():[];sr(T)&&q.unshift("#version 300 es"),p&&q.push("#define OVERDRAW_INSPECTOR;"),m&&q.push("#define TERRAIN3D;"),v&&q.push(v),w&&q.push(...w);let Y=q.concat(Pt.prelude.fragmentSource,_.fragmentSource,n.fragmentSource).join(`
|
|
813
|
+
`),Q=q.concat(Pt.prelude.vertexSource,_.vertexSource,n.vertexSource).join(`
|
|
814
|
+
`);sr(T)||(Y=(function(ue){return ue.replace(/\bin\s/g,"varying ").replace("out highp vec4 fragColor;","").replace(/fragColor/g,"gl_FragColor").replace(/texture\(/g,"texture2D(")})(Y),Q=(function(ue){return ue.replace(/\bin\s/g,"attribute ").replace(/\bout\s/g,"varying ").replace(/texture\(/g,"texture2D(")})(Q));const H=T.createShader(T.FRAGMENT_SHADER);if(T.isContextLost())return void(this.failedToCreate=!0);if(T.shaderSource(H,Y),T.compileShader(H),!T.getShaderParameter(H,T.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${T.getShaderInfoLog(H)}`);T.attachShader(this.program,H);const te=T.createShader(T.VERTEX_SHADER);if(T.isContextLost())return void(this.failedToCreate=!0);if(T.shaderSource(te,Q),T.compileShader(te),!T.getShaderParameter(te,T.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${T.getShaderInfoLog(te)}`);T.attachShader(this.program,te),this.attributes={};const de={};this.numAttributes=z.length;for(let ue=0;ue<this.numAttributes;ue++)z[ue]&&(T.bindAttribLocation(this.program,ue,z[ue]),this.attributes[z[ue]]=ue);if(T.linkProgram(this.program),!T.getProgramParameter(this.program,T.LINK_STATUS))throw new Error(`Program failed to link: ${T.getProgramInfoLog(this.program)}`);T.deleteShader(te),T.deleteShader(H);for(let ue=0;ue<X.length;ue++){const ce=X[ue];if(ce&&!de[ce]){const he=T.getUniformLocation(this.program,ce);he&&(de[ce]=he)}}this.fixedUniforms=l(t,de),this.terrainUniforms=((ue,ce)=>({u_depth:new c.b_(ue,ce.u_depth),u_terrain:new c.b_(ue,ce.u_terrain),u_terrain_dim:new c.bq(ue,ce.u_terrain_dim),u_terrain_matrix:new c.c0(ue,ce.u_terrain_matrix),u_terrain_unpack:new c.c1(ue,ce.u_terrain_unpack),u_terrain_exaggeration:new c.bq(ue,ce.u_terrain_exaggeration)}))(t,de),this.projectionUniforms=((ue,ce)=>({u_projection_matrix:new c.c0(ue,ce.u_projection_matrix),u_projection_tile_mercator_coords:new c.c1(ue,ce.u_projection_tile_mercator_coords),u_projection_clipping_plane:new c.c1(ue,ce.u_projection_clipping_plane),u_projection_transition:new c.bq(ue,ce.u_projection_transition),u_projection_fallback_matrix:new c.c0(ue,ce.u_projection_fallback_matrix)}))(t,de),this.binderUniforms=o?o.getUniforms(t,de):[]}draw(t,n,o,l,p,m,_,v,w,T,C,M,z,R,N,U,j,Z,X){const q=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(o),t.setStencilMode(l),t.setColorMode(p),t.setCullFace(m),v){t.activeTexture.set(q.TEXTURE2),q.bindTexture(q.TEXTURE_2D,v.depthTexture),t.activeTexture.set(q.TEXTURE3),q.bindTexture(q.TEXTURE_2D,v.texture);for(const Q in this.terrainUniforms)this.terrainUniforms[Q].set(v[Q])}if(w)for(const Q in w)this.projectionUniforms[Ou[Q]].set(w[Q]);if(_)for(const Q in this.fixedUniforms)this.fixedUniforms[Q].set(_[Q]);U&&U.setUniforms(t,this.binderUniforms,R,{zoom:N});let Y=0;switch(n){case q.LINES:Y=2;break;case q.TRIANGLES:Y=3;break;case q.LINE_STRIP:Y=1}for(const Q of z.get()){const H=Q.vaos||(Q.vaos={});(H[T]||(H[T]=new Bu)).bind(t,this,C,U?U.getPaintVertexBuffers():[],M,Q.vertexOffset,j,Z,X),q.drawElements(n,Q.primitiveLength*Y,q.UNSIGNED_SHORT,Q.primitiveOffset*Y*2)}}}function Wa(d,t,n){const o=1/c.aN(n,1,t.transform.tileZoom),l=Math.pow(2,n.tileID.overscaledZ),p=n.tileSize*Math.pow(2,t.transform.tileZoom)/l,m=p*(n.tileID.canonical.x+n.tileID.wrap*l),_=p*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[o,d.fromScale,d.toScale],u_fade:d.t,u_pixel_coord_upper:[m>>16,_>>16],u_pixel_coord_lower:[65535&m,65535&_]}}const Ho=(d,t,n,o)=>{const l=d.style.light,p=l.properties.get("position"),m=[p.x,p.y,p.z],_=c.c4();l.properties.get("anchor")==="viewport"&&c.c5(_,d.transform.bearingInRadians),c.c6(m,m,_);const v=d.transform.transformLightDirection(m),w=l.properties.get("color");return{u_lightpos:m,u_lightpos_globe:v,u_lightintensity:l.properties.get("intensity"),u_lightcolor:[w.r,w.g,w.b],u_vertical_gradient:+t,u_opacity:n,u_fill_translate:o}},lc=(d,t,n,o,l,p,m)=>c.e(Ho(d,t,n,o),Wa(p,d,m),{u_height_factor:-Math.pow(2,l.overscaledZ)/m.tileSize/8}),Xa=(d,t,n,o)=>c.e(Wa(t,d,n),{u_fill_translate:o}),cc=(d,t)=>({u_world:d,u_fill_translate:t}),uc=(d,t,n,o,l)=>c.e(Xa(d,t,n,l),{u_world:o}),Fn=(d,t,n,o,l)=>{const p=d.transform;let m,_,v=0;if(n.paint.get("circle-pitch-alignment")==="map"){const w=c.aN(t,1,p.zoom);m=!0,_=[w,w],v=w/(c.a5*Math.pow(2,t.tileID.overscaledZ))*2*Math.PI*l}else m=!1,_=p.pixelsToGLUnits;return{u_camera_to_center_distance:p.cameraToCenterDistance,u_scale_with_map:+(n.paint.get("circle-pitch-scale")==="map"),u_pitch_with_map:+m,u_device_pixel_ratio:d.pixelRatio,u_extrude_scale:_,u_globe_extrude_scale:v,u_translate:o}},hc=d=>({u_pixel_extrude_scale:[1/d.width,1/d.height]}),dc=d=>({u_viewport_size:[d.width,d.height]}),ms=(d,t=1)=>({u_color:d,u_overlay:0,u_overlay_scale:t}),pc=(d,t,n,o)=>{const l=c.aN(d,1,t)/(c.a5*Math.pow(2,d.tileID.overscaledZ))*2*Math.PI*o;return{u_extrude_scale:c.aN(d,1,t),u_intensity:n,u_globe_extrude_scale:l}},Ys=(d,t,n,o)=>{const l=c.N();c.c7(l,0,d.width,d.height,0,0,1);const p=d.context.gl;return{u_matrix:l,u_world:[p.drawingBufferWidth,p.drawingBufferHeight],u_image:n,u_color_ramp:o,u_opacity:t.paint.get("heatmap-opacity")}},Nu=(d,t,n)=>{const o=n.paint.get("hillshade-accent-color");let l;switch(n.paint.get("hillshade-method")){case"basic":l=4;break;case"combined":l=1;break;case"igor":l=2;break;case"multidirectional":l=3;break;default:l=0}const p=n.getIlluminationProperties();for(let m=0;m<p.directionRadians.length;m++)n.paint.get("hillshade-illumination-anchor")==="viewport"&&(p.directionRadians[m]+=d.transform.bearingInRadians);return{u_image:0,u_latrange:fc(0,t.tileID),u_exaggeration:n.paint.get("hillshade-exaggeration"),u_altitudes:p.altitudeRadians,u_azimuths:p.directionRadians,u_accent:o,u_method:l,u_highlights:p.highlightColor,u_shadows:p.shadowColor}},ju=(d,t)=>{const n=t.stride,o=c.N();return c.c7(o,0,c.a5,-c.a5,0,0,1),c.O(o,o,[0,-c.a5,0]),{u_matrix:o,u_image:1,u_dimension:[n,n],u_zoom:d.overscaledZ,u_unpack:t.getUnpackVector()}};function fc(d,t){const n=Math.pow(2,t.canonical.z),o=t.canonical.y;return[new c.a9(0,o/n).toLngLat().lat,new c.a9(0,(o+1)/n).toLngLat().lat]}const mc=(d,t,n=0)=>({u_image:0,u_unpack:t.getUnpackVector(),u_dimension:[t.stride,t.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:n,u_opacity:d.paint.get("color-relief-opacity")}),Ks=(d,t,n,o)=>{const l=d.transform;return{u_translation:Xo(d,t,n),u_ratio:o/c.aN(t,1,l.zoom),u_device_pixel_ratio:d.pixelRatio,u_units_to_pixels:[1/l.pixelsToGLUnits[0],1/l.pixelsToGLUnits[1]]}},Ya=(d,t,n,o,l)=>c.e(Ks(d,t,n,o),{u_image:0,u_image_height:l}),gc=(d,t,n,o,l)=>{const p=d.transform,m=Js(t,p);return{u_translation:Xo(d,t,n),u_texsize:t.imageAtlasTexture.size,u_ratio:o/c.aN(t,1,p.zoom),u_device_pixel_ratio:d.pixelRatio,u_image:0,u_scale:[m,l.fromScale,l.toScale],u_fade:l.t,u_units_to_pixels:[1/p.pixelsToGLUnits[0],1/p.pixelsToGLUnits[1]]}},Wo=(d,t,n,o,l)=>{const p=Js(t,d.transform);return c.e(Ks(d,t,n,o),{u_tileratio:p,u_crossfade_from:l.fromScale,u_crossfade_to:l.toScale,u_image:0,u_mix:l.t,u_lineatlas_width:d.lineAtlas.width,u_lineatlas_height:d.lineAtlas.height})},Gr=(d,t,n,o,l,p)=>{const m=Js(t,d.transform);return c.e(Ks(d,t,n,o),{u_image:0,u_image_height:p,u_tileratio:m,u_crossfade_from:l.fromScale,u_crossfade_to:l.toScale,u_image_dash:1,u_mix:l.t,u_lineatlas_width:d.lineAtlas.width,u_lineatlas_height:d.lineAtlas.height})};function Js(d,t){return 1/c.aN(d,1,t.tileZoom)}function Xo(d,t,n){return c.aO(d.transform,t,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const Ka=(d,t,n,o,l)=>{return{u_tl_parent:d,u_scale_parent:t,u_buffer_scale:1,u_fade_t:n.mix,u_opacity:n.opacity*o.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:o.paint.get("raster-brightness-min"),u_brightness_high:o.paint.get("raster-brightness-max"),u_saturation_factor:(m=o.paint.get("raster-saturation"),m>0?1-1/(1.001-m):-m),u_contrast_factor:(p=o.paint.get("raster-contrast"),p>0?1/(1-p):1+p),u_spin_weights:_c(o.paint.get("raster-hue-rotate")),u_coords_top:[l[0].x,l[0].y,l[1].x,l[1].y],u_coords_bottom:[l[3].x,l[3].y,l[2].x,l[2].y]};var p,m};function _c(d){d*=Math.PI/180;const t=Math.sin(d),n=Math.cos(d);return[(2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3]}const Yo=(d,t,n,o,l,p,m,_,v,w,T,C,M)=>{const z=m.transform;return{u_is_size_zoom_constant:+(d==="constant"||d==="source"),u_is_size_feature_constant:+(d==="constant"||d==="camera"),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:z.cameraToCenterDistance,u_pitch:z.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:z.width/z.height,u_fade_change:m.options.fadeDuration?m.symbolFadeChange:1,u_label_plane_matrix:_,u_coord_matrix:v,u_is_text:+T,u_pitch_with_map:+o,u_is_along_line:l,u_is_variable_anchor:p,u_texsize:C,u_texture:0,u_translation:w,u_pitched_scale:M}},fn=(d,t,n,o,l,p,m,_,v,w,T,C,M,z)=>{const R=m.transform;return c.e(Yo(d,t,n,o,l,p,m,_,v,w,T,C,z),{u_gamma_scale:o?Math.cos(R.pitch*Math.PI/180)*R.cameraToCenterDistance:1,u_device_pixel_ratio:m.pixelRatio,u_is_halo:1})},Ja=(d,t,n,o,l,p,m,_,v,w,T,C,M)=>c.e(fn(d,t,n,o,l,p,m,_,v,w,!0,T,0,M),{u_texsize_icon:C,u_texture_icon:1}),Uu=(d,t)=>({u_opacity:d,u_color:t}),Gu=(d,t,n,o,l)=>c.e((function(p,m,_,v){const w=_.imageManager.getPattern(p.from.toString()),T=_.imageManager.getPattern(p.to.toString()),{width:C,height:M}=_.imageManager.getPixelSize(),z=Math.pow(2,v.tileID.overscaledZ),R=v.tileSize*Math.pow(2,_.transform.tileZoom)/z,N=R*(v.tileID.canonical.x+v.tileID.wrap*z),U=R*v.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:w.tl,u_pattern_br_a:w.br,u_pattern_tl_b:T.tl,u_pattern_br_b:T.br,u_texsize:[C,M],u_mix:m.t,u_pattern_size_a:w.displaySize,u_pattern_size_b:T.displaySize,u_scale_a:m.fromScale,u_scale_b:m.toScale,u_tile_units_to_pixels:1/c.aN(v,1,_.transform.tileZoom),u_pixel_coord_upper:[N>>16,U>>16],u_pixel_coord_lower:[65535&N,65535&U]}})(n,l,t,o),{u_opacity:d}),yc=(d,t)=>{},qu={fillExtrusion:(d,t)=>({u_lightpos:new c.c2(d,t.u_lightpos),u_lightpos_globe:new c.c2(d,t.u_lightpos_globe),u_lightintensity:new c.bq(d,t.u_lightintensity),u_lightcolor:new c.c2(d,t.u_lightcolor),u_vertical_gradient:new c.bq(d,t.u_vertical_gradient),u_opacity:new c.bq(d,t.u_opacity),u_fill_translate:new c.c3(d,t.u_fill_translate)}),fillExtrusionPattern:(d,t)=>({u_lightpos:new c.c2(d,t.u_lightpos),u_lightpos_globe:new c.c2(d,t.u_lightpos_globe),u_lightintensity:new c.bq(d,t.u_lightintensity),u_lightcolor:new c.c2(d,t.u_lightcolor),u_vertical_gradient:new c.bq(d,t.u_vertical_gradient),u_height_factor:new c.bq(d,t.u_height_factor),u_opacity:new c.bq(d,t.u_opacity),u_fill_translate:new c.c3(d,t.u_fill_translate),u_image:new c.b_(d,t.u_image),u_texsize:new c.c3(d,t.u_texsize),u_pixel_coord_upper:new c.c3(d,t.u_pixel_coord_upper),u_pixel_coord_lower:new c.c3(d,t.u_pixel_coord_lower),u_scale:new c.c2(d,t.u_scale),u_fade:new c.bq(d,t.u_fade)}),fill:(d,t)=>({u_fill_translate:new c.c3(d,t.u_fill_translate)}),fillPattern:(d,t)=>({u_image:new c.b_(d,t.u_image),u_texsize:new c.c3(d,t.u_texsize),u_pixel_coord_upper:new c.c3(d,t.u_pixel_coord_upper),u_pixel_coord_lower:new c.c3(d,t.u_pixel_coord_lower),u_scale:new c.c2(d,t.u_scale),u_fade:new c.bq(d,t.u_fade),u_fill_translate:new c.c3(d,t.u_fill_translate)}),fillOutline:(d,t)=>({u_world:new c.c3(d,t.u_world),u_fill_translate:new c.c3(d,t.u_fill_translate)}),fillOutlinePattern:(d,t)=>({u_world:new c.c3(d,t.u_world),u_image:new c.b_(d,t.u_image),u_texsize:new c.c3(d,t.u_texsize),u_pixel_coord_upper:new c.c3(d,t.u_pixel_coord_upper),u_pixel_coord_lower:new c.c3(d,t.u_pixel_coord_lower),u_scale:new c.c2(d,t.u_scale),u_fade:new c.bq(d,t.u_fade),u_fill_translate:new c.c3(d,t.u_fill_translate)}),circle:(d,t)=>({u_camera_to_center_distance:new c.bq(d,t.u_camera_to_center_distance),u_scale_with_map:new c.b_(d,t.u_scale_with_map),u_pitch_with_map:new c.b_(d,t.u_pitch_with_map),u_extrude_scale:new c.c3(d,t.u_extrude_scale),u_device_pixel_ratio:new c.bq(d,t.u_device_pixel_ratio),u_globe_extrude_scale:new c.bq(d,t.u_globe_extrude_scale),u_translate:new c.c3(d,t.u_translate)}),collisionBox:(d,t)=>({u_pixel_extrude_scale:new c.c3(d,t.u_pixel_extrude_scale)}),collisionCircle:(d,t)=>({u_viewport_size:new c.c3(d,t.u_viewport_size)}),debug:(d,t)=>({u_color:new c.b$(d,t.u_color),u_overlay:new c.b_(d,t.u_overlay),u_overlay_scale:new c.bq(d,t.u_overlay_scale)}),depth:yc,clippingMask:yc,heatmap:(d,t)=>({u_extrude_scale:new c.bq(d,t.u_extrude_scale),u_intensity:new c.bq(d,t.u_intensity),u_globe_extrude_scale:new c.bq(d,t.u_globe_extrude_scale)}),heatmapTexture:(d,t)=>({u_matrix:new c.c0(d,t.u_matrix),u_world:new c.c3(d,t.u_world),u_image:new c.b_(d,t.u_image),u_color_ramp:new c.b_(d,t.u_color_ramp),u_opacity:new c.bq(d,t.u_opacity)}),hillshade:(d,t)=>({u_image:new c.b_(d,t.u_image),u_latrange:new c.c3(d,t.u_latrange),u_exaggeration:new c.bq(d,t.u_exaggeration),u_altitudes:new c.c9(d,t.u_altitudes),u_azimuths:new c.c9(d,t.u_azimuths),u_accent:new c.b$(d,t.u_accent),u_method:new c.b_(d,t.u_method),u_shadows:new c.c8(d,t.u_shadows),u_highlights:new c.c8(d,t.u_highlights)}),hillshadePrepare:(d,t)=>({u_matrix:new c.c0(d,t.u_matrix),u_image:new c.b_(d,t.u_image),u_dimension:new c.c3(d,t.u_dimension),u_zoom:new c.bq(d,t.u_zoom),u_unpack:new c.c1(d,t.u_unpack)}),colorRelief:(d,t)=>({u_image:new c.b_(d,t.u_image),u_unpack:new c.c1(d,t.u_unpack),u_dimension:new c.c3(d,t.u_dimension),u_elevation_stops:new c.b_(d,t.u_elevation_stops),u_color_stops:new c.b_(d,t.u_color_stops),u_color_ramp_size:new c.b_(d,t.u_color_ramp_size),u_opacity:new c.bq(d,t.u_opacity)}),line:(d,t)=>({u_translation:new c.c3(d,t.u_translation),u_ratio:new c.bq(d,t.u_ratio),u_device_pixel_ratio:new c.bq(d,t.u_device_pixel_ratio),u_units_to_pixels:new c.c3(d,t.u_units_to_pixels)}),lineGradient:(d,t)=>({u_translation:new c.c3(d,t.u_translation),u_ratio:new c.bq(d,t.u_ratio),u_device_pixel_ratio:new c.bq(d,t.u_device_pixel_ratio),u_units_to_pixels:new c.c3(d,t.u_units_to_pixels),u_image:new c.b_(d,t.u_image),u_image_height:new c.bq(d,t.u_image_height)}),linePattern:(d,t)=>({u_translation:new c.c3(d,t.u_translation),u_texsize:new c.c3(d,t.u_texsize),u_ratio:new c.bq(d,t.u_ratio),u_device_pixel_ratio:new c.bq(d,t.u_device_pixel_ratio),u_image:new c.b_(d,t.u_image),u_units_to_pixels:new c.c3(d,t.u_units_to_pixels),u_scale:new c.c2(d,t.u_scale),u_fade:new c.bq(d,t.u_fade)}),lineSDF:(d,t)=>({u_translation:new c.c3(d,t.u_translation),u_ratio:new c.bq(d,t.u_ratio),u_device_pixel_ratio:new c.bq(d,t.u_device_pixel_ratio),u_units_to_pixels:new c.c3(d,t.u_units_to_pixels),u_image:new c.b_(d,t.u_image),u_mix:new c.bq(d,t.u_mix),u_tileratio:new c.bq(d,t.u_tileratio),u_crossfade_from:new c.bq(d,t.u_crossfade_from),u_crossfade_to:new c.bq(d,t.u_crossfade_to),u_lineatlas_width:new c.bq(d,t.u_lineatlas_width),u_lineatlas_height:new c.bq(d,t.u_lineatlas_height)}),lineGradientSDF:(d,t)=>({u_translation:new c.c3(d,t.u_translation),u_ratio:new c.bq(d,t.u_ratio),u_device_pixel_ratio:new c.bq(d,t.u_device_pixel_ratio),u_units_to_pixels:new c.c3(d,t.u_units_to_pixels),u_image:new c.b_(d,t.u_image),u_image_height:new c.bq(d,t.u_image_height),u_tileratio:new c.bq(d,t.u_tileratio),u_crossfade_from:new c.bq(d,t.u_crossfade_from),u_crossfade_to:new c.bq(d,t.u_crossfade_to),u_image_dash:new c.b_(d,t.u_image_dash),u_mix:new c.bq(d,t.u_mix),u_lineatlas_width:new c.bq(d,t.u_lineatlas_width),u_lineatlas_height:new c.bq(d,t.u_lineatlas_height)}),raster:(d,t)=>({u_tl_parent:new c.c3(d,t.u_tl_parent),u_scale_parent:new c.bq(d,t.u_scale_parent),u_buffer_scale:new c.bq(d,t.u_buffer_scale),u_fade_t:new c.bq(d,t.u_fade_t),u_opacity:new c.bq(d,t.u_opacity),u_image0:new c.b_(d,t.u_image0),u_image1:new c.b_(d,t.u_image1),u_brightness_low:new c.bq(d,t.u_brightness_low),u_brightness_high:new c.bq(d,t.u_brightness_high),u_saturation_factor:new c.bq(d,t.u_saturation_factor),u_contrast_factor:new c.bq(d,t.u_contrast_factor),u_spin_weights:new c.c2(d,t.u_spin_weights),u_coords_top:new c.c1(d,t.u_coords_top),u_coords_bottom:new c.c1(d,t.u_coords_bottom)}),symbolIcon:(d,t)=>({u_is_size_zoom_constant:new c.b_(d,t.u_is_size_zoom_constant),u_is_size_feature_constant:new c.b_(d,t.u_is_size_feature_constant),u_size_t:new c.bq(d,t.u_size_t),u_size:new c.bq(d,t.u_size),u_camera_to_center_distance:new c.bq(d,t.u_camera_to_center_distance),u_pitch:new c.bq(d,t.u_pitch),u_rotate_symbol:new c.b_(d,t.u_rotate_symbol),u_aspect_ratio:new c.bq(d,t.u_aspect_ratio),u_fade_change:new c.bq(d,t.u_fade_change),u_label_plane_matrix:new c.c0(d,t.u_label_plane_matrix),u_coord_matrix:new c.c0(d,t.u_coord_matrix),u_is_text:new c.b_(d,t.u_is_text),u_pitch_with_map:new c.b_(d,t.u_pitch_with_map),u_is_along_line:new c.b_(d,t.u_is_along_line),u_is_variable_anchor:new c.b_(d,t.u_is_variable_anchor),u_texsize:new c.c3(d,t.u_texsize),u_texture:new c.b_(d,t.u_texture),u_translation:new c.c3(d,t.u_translation),u_pitched_scale:new c.bq(d,t.u_pitched_scale)}),symbolSDF:(d,t)=>({u_is_size_zoom_constant:new c.b_(d,t.u_is_size_zoom_constant),u_is_size_feature_constant:new c.b_(d,t.u_is_size_feature_constant),u_size_t:new c.bq(d,t.u_size_t),u_size:new c.bq(d,t.u_size),u_camera_to_center_distance:new c.bq(d,t.u_camera_to_center_distance),u_pitch:new c.bq(d,t.u_pitch),u_rotate_symbol:new c.b_(d,t.u_rotate_symbol),u_aspect_ratio:new c.bq(d,t.u_aspect_ratio),u_fade_change:new c.bq(d,t.u_fade_change),u_label_plane_matrix:new c.c0(d,t.u_label_plane_matrix),u_coord_matrix:new c.c0(d,t.u_coord_matrix),u_is_text:new c.b_(d,t.u_is_text),u_pitch_with_map:new c.b_(d,t.u_pitch_with_map),u_is_along_line:new c.b_(d,t.u_is_along_line),u_is_variable_anchor:new c.b_(d,t.u_is_variable_anchor),u_texsize:new c.c3(d,t.u_texsize),u_texture:new c.b_(d,t.u_texture),u_gamma_scale:new c.bq(d,t.u_gamma_scale),u_device_pixel_ratio:new c.bq(d,t.u_device_pixel_ratio),u_is_halo:new c.b_(d,t.u_is_halo),u_translation:new c.c3(d,t.u_translation),u_pitched_scale:new c.bq(d,t.u_pitched_scale)}),symbolTextAndIcon:(d,t)=>({u_is_size_zoom_constant:new c.b_(d,t.u_is_size_zoom_constant),u_is_size_feature_constant:new c.b_(d,t.u_is_size_feature_constant),u_size_t:new c.bq(d,t.u_size_t),u_size:new c.bq(d,t.u_size),u_camera_to_center_distance:new c.bq(d,t.u_camera_to_center_distance),u_pitch:new c.bq(d,t.u_pitch),u_rotate_symbol:new c.b_(d,t.u_rotate_symbol),u_aspect_ratio:new c.bq(d,t.u_aspect_ratio),u_fade_change:new c.bq(d,t.u_fade_change),u_label_plane_matrix:new c.c0(d,t.u_label_plane_matrix),u_coord_matrix:new c.c0(d,t.u_coord_matrix),u_is_text:new c.b_(d,t.u_is_text),u_pitch_with_map:new c.b_(d,t.u_pitch_with_map),u_is_along_line:new c.b_(d,t.u_is_along_line),u_is_variable_anchor:new c.b_(d,t.u_is_variable_anchor),u_texsize:new c.c3(d,t.u_texsize),u_texsize_icon:new c.c3(d,t.u_texsize_icon),u_texture:new c.b_(d,t.u_texture),u_texture_icon:new c.b_(d,t.u_texture_icon),u_gamma_scale:new c.bq(d,t.u_gamma_scale),u_device_pixel_ratio:new c.bq(d,t.u_device_pixel_ratio),u_is_halo:new c.b_(d,t.u_is_halo),u_translation:new c.c3(d,t.u_translation),u_pitched_scale:new c.bq(d,t.u_pitched_scale)}),background:(d,t)=>({u_opacity:new c.bq(d,t.u_opacity),u_color:new c.b$(d,t.u_color)}),backgroundPattern:(d,t)=>({u_opacity:new c.bq(d,t.u_opacity),u_image:new c.b_(d,t.u_image),u_pattern_tl_a:new c.c3(d,t.u_pattern_tl_a),u_pattern_br_a:new c.c3(d,t.u_pattern_br_a),u_pattern_tl_b:new c.c3(d,t.u_pattern_tl_b),u_pattern_br_b:new c.c3(d,t.u_pattern_br_b),u_texsize:new c.c3(d,t.u_texsize),u_mix:new c.bq(d,t.u_mix),u_pattern_size_a:new c.c3(d,t.u_pattern_size_a),u_pattern_size_b:new c.c3(d,t.u_pattern_size_b),u_scale_a:new c.bq(d,t.u_scale_a),u_scale_b:new c.bq(d,t.u_scale_b),u_pixel_coord_upper:new c.c3(d,t.u_pixel_coord_upper),u_pixel_coord_lower:new c.c3(d,t.u_pixel_coord_lower),u_tile_units_to_pixels:new c.bq(d,t.u_tile_units_to_pixels)}),terrain:(d,t)=>({u_texture:new c.b_(d,t.u_texture),u_ele_delta:new c.bq(d,t.u_ele_delta),u_fog_matrix:new c.c0(d,t.u_fog_matrix),u_fog_color:new c.b$(d,t.u_fog_color),u_fog_ground_blend:new c.bq(d,t.u_fog_ground_blend),u_fog_ground_blend_opacity:new c.bq(d,t.u_fog_ground_blend_opacity),u_horizon_color:new c.b$(d,t.u_horizon_color),u_horizon_fog_blend:new c.bq(d,t.u_horizon_fog_blend),u_is_globe_mode:new c.bq(d,t.u_is_globe_mode)}),terrainDepth:(d,t)=>({u_ele_delta:new c.bq(d,t.u_ele_delta)}),terrainCoords:(d,t)=>({u_texture:new c.b_(d,t.u_texture),u_terrain_coords_id:new c.bq(d,t.u_terrain_coords_id),u_ele_delta:new c.bq(d,t.u_ele_delta)}),projectionErrorMeasurement:(d,t)=>({u_input:new c.bq(d,t.u_input),u_output_expected:new c.bq(d,t.u_output_expected)}),atmosphere:(d,t)=>({u_sun_pos:new c.c2(d,t.u_sun_pos),u_atmosphere_blend:new c.bq(d,t.u_atmosphere_blend),u_globe_position:new c.c2(d,t.u_globe_position),u_globe_radius:new c.bq(d,t.u_globe_radius),u_inv_proj_matrix:new c.c0(d,t.u_inv_proj_matrix)}),sky:(d,t)=>({u_sky_color:new c.b$(d,t.u_sky_color),u_horizon_color:new c.b$(d,t.u_horizon_color),u_horizon:new c.c3(d,t.u_horizon),u_horizon_normal:new c.c3(d,t.u_horizon_normal),u_sky_horizon_blend:new c.bq(d,t.u_sky_horizon_blend),u_sky_blend:new c.bq(d,t.u_sky_blend)})};class vc{constructor(t,n,o){this.context=t;const l=t.gl;this.buffer=l.createBuffer(),this.dynamicDraw=!!o,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),l.bufferData(l.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?l.DYNAMIC_DRAW:l.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const n=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Zu={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class xc{constructor(t,n,o,l){this.length=n.length,this.attributes=o,this.itemSize=n.bytesPerElement,this.dynamicDraw=l,this.context=t;const p=t.gl;this.buffer=p.createBuffer(),t.bindVertexBuffer.set(this.buffer),p.bufferData(p.ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?p.DYNAMIC_DRAW:p.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw new Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);const n=this.context.gl;this.bind(),n.bufferSubData(n.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,n){for(let o=0;o<this.attributes.length;o++){const l=n.attributes[this.attributes[o].name];l!==void 0&&t.enableVertexAttribArray(l)}}setVertexAttribPointers(t,n,o){for(let l=0;l<this.attributes.length;l++){const p=this.attributes[l],m=n.attributes[p.name];m!==void 0&&t.vertexAttribPointer(m,p.components,t[Zu[p.type]],!1,this.itemSize,p.offset+this.itemSize*(o||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class lt{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class Ko extends lt{getDefault(){return c.bp.transparent}set(t){const n=this.current;(t.r!==n.r||t.g!==n.g||t.b!==n.b||t.a!==n.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Jo extends lt{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class Qa extends lt{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class Bn extends lt{getDefault(){return[!0,!0,!0,!0]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||t[3]!==n[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Qs extends lt{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class gs extends lt{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class or extends lt{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){const n=this.current;(t.func!==n.func||t.ref!==n.ref||t.mask!==n.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class bc extends lt{getDefault(){const t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class wc extends lt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.STENCIL_TEST):n.disable(n.STENCIL_TEST),this.current=t,this.dirty=!1}}class el extends lt{getDefault(){return[0,1]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class On extends lt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.DEPTH_TEST):n.disable(n.DEPTH_TEST),this.current=t,this.dirty=!1}}class Qo extends lt{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class ea extends lt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.BLEND):n.disable(n.BLEND),this.current=t,this.dirty=!1}}class eo extends lt{getDefault(){const t=this.gl;return[t.ONE,t.ZERO]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class ta extends lt{getDefault(){return c.bp.transparent}set(t){const n=this.current;(t.r!==n.r||t.g!==n.g||t.b!==n.b||t.a!==n.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Tc extends lt{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class _s extends lt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;t?n.enable(n.CULL_FACE):n.disable(n.CULL_FACE),this.current=t,this.dirty=!1}}class ys extends lt{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class Sc extends lt{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class tl extends lt{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class rt extends lt{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class ia extends lt{getDefault(){const t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){const n=this.current;(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||t[3]!==n[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class $u extends lt{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindFramebuffer(n.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class Pc extends lt{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindRenderbuffer(n.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class to extends lt{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindTexture(n.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class Hu extends lt{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.bindBuffer(n.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class Wu extends lt{getDefault(){return null}set(t){const n=this.gl;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class Mc extends lt{getDefault(){return null}set(t){var n;if(t===this.current&&!this.dirty)return;const o=this.gl;sr(o)?o.bindVertexArray(t):(n=o.getExtension("OES_vertex_array_object"))===null||n===void 0||n.bindVertexArrayOES(t),this.current=t,this.dirty=!1}}class Xu extends lt{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class il extends lt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class ra extends lt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class Vn extends lt{constructor(t,n){super(t),this.context=t,this.parent=n}getDefault(){return null}}class na extends Vn{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class rl extends Vn{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Cc extends Vn{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,t),this.current=t,this.dirty=!1}}const io="Framebuffer is not complete";class sa{constructor(t,n,o,l,p){this.context=t,this.width=n,this.height=o;const m=t.gl,_=this.framebuffer=m.createFramebuffer();if(this.colorAttachment=new na(t,_),l)this.depthAttachment=p?new Cc(t,_):new rl(t,_);else if(p)throw new Error("Stencil cannot be set without depth");if(m.checkFramebufferStatus(m.FRAMEBUFFER)!==m.FRAMEBUFFER_COMPLETE)throw new Error(io)}destroy(){const t=this.context.gl,n=this.colorAttachment.get();if(n&&t.deleteTexture(n),this.depthAttachment){const o=this.depthAttachment.get();o&&t.deleteRenderbuffer(o)}t.deleteFramebuffer(this.framebuffer)}}class ro{constructor(t){var n,o;if(this.gl=t,this.clearColor=new Ko(this),this.clearDepth=new Jo(this),this.clearStencil=new Qa(this),this.colorMask=new Bn(this),this.depthMask=new Qs(this),this.stencilMask=new gs(this),this.stencilFunc=new or(this),this.stencilOp=new bc(this),this.stencilTest=new wc(this),this.depthRange=new el(this),this.depthTest=new On(this),this.depthFunc=new Qo(this),this.blend=new ea(this),this.blendFunc=new eo(this),this.blendColor=new ta(this),this.blendEquation=new Tc(this),this.cullFace=new _s(this),this.cullFaceSide=new ys(this),this.frontFace=new Sc(this),this.program=new tl(this),this.activeTexture=new rt(this),this.viewport=new ia(this),this.bindFramebuffer=new $u(this),this.bindRenderbuffer=new Pc(this),this.bindTexture=new to(this),this.bindVertexBuffer=new Hu(this),this.bindElementBuffer=new Wu(this),this.bindVertexArray=new Mc(this),this.pixelStoreUnpack=new Xu(this),this.pixelStoreUnpackPremultiplyAlpha=new il(this),this.pixelStoreUnpackFlipY=new ra(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),sr(t)){this.HALF_FLOAT=t.HALF_FLOAT;const l=t.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(n=t.RGBA16F)!==null&&n!==void 0?n:l?.RGBA16F_EXT,this.RGB16F=(o=t.RGB16F)!==null&&o!==void 0?o:l?.RGB16F_EXT,t.getExtension("EXT_color_buffer_float")}else{t.getExtension("EXT_color_buffer_half_float"),t.getExtension("OES_texture_half_float_linear");const l=t.getExtension("OES_texture_half_float");this.HALF_FLOAT=l?.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(t,n){return new vc(this,t,n)}createVertexBuffer(t,n,o){return new xc(this,t,n,o)}createRenderbuffer(t,n,o){const l=this.gl,p=l.createRenderbuffer();return this.bindRenderbuffer.set(p),l.renderbufferStorage(l.RENDERBUFFER,t,n,o),this.bindRenderbuffer.set(null),p}createFramebuffer(t,n,o,l){return new sa(this,t,n,o,l)}clear({color:t,depth:n,stencil:o}){const l=this.gl;let p=0;t&&(p|=l.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),n!==void 0&&(p|=l.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(n),this.depthMask.set(!0)),o!==void 0&&(p|=l.STENCIL_BUFFER_BIT,this.clearStencil.set(o),this.stencilMask.set(255)),l.clear(p)}setCullFace(t){t.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)}setStencilMode(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)}setColorMode(t){c.bR(t.blendFunction,yt.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}createVertexArray(){var t;return sr(this.gl)?this.gl.createVertexArray():(t=this.gl.getExtension("OES_vertex_array_object"))===null||t===void 0?void 0:t.createVertexArrayOES()}deleteVertexArray(t){var n;return sr(this.gl)?this.gl.deleteVertexArray(t):(n=this.gl.getExtension("OES_vertex_array_object"))===null||n===void 0?void 0:n.deleteVertexArrayOES(t)}unbindVAO(){this.bindVertexArray.set(null)}}let qr;function oa(d,t,n,o,l){const p=d.context,m=d.transform,_=p.gl,v=d.useProgram("collisionBox"),w=[];let T=0,C=0;for(let j=0;j<o.length;j++){const Z=o[j],X=t.getTile(Z).getBucket(n);if(!X)continue;const q=l?X.textCollisionBox:X.iconCollisionBox,Y=X.collisionCircleArray;Y.length>0&&(w.push({circleArray:Y,circleOffset:C,coord:Z}),T+=Y.length/4,C=T),q&&v.draw(p,_.LINES,Qe.disabled,at.disabled,d.colorModeForRenderPass(),ot.disabled,hc(d.transform),d.style.map.terrain&&d.style.map.terrain.getTerrainData(Z),m.getProjectionData({overscaledTileID:Z,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),n.id,q.layoutVertexBuffer,q.indexBuffer,q.segments,null,d.transform.zoom,null,null,q.collisionVertexBuffer)}if(!l||!w.length)return;const M=d.useProgram("collisionCircle"),z=new c.ca;z.resize(4*T),z._trim();let R=0;for(const j of w)for(let Z=0;Z<j.circleArray.length/4;Z++){const X=4*Z,q=j.circleArray[X+0],Y=j.circleArray[X+1],Q=j.circleArray[X+2],H=j.circleArray[X+3];z.emplace(R++,q,Y,Q,H,0),z.emplace(R++,q,Y,Q,H,1),z.emplace(R++,q,Y,Q,H,2),z.emplace(R++,q,Y,Q,H,3)}(!qr||qr.length<2*T)&&(qr=(function(j){const Z=2*j,X=new c.cc;X.resize(Z),X._trim();for(let q=0;q<Z;q++){const Y=6*q;X.uint16[Y+0]=4*q+0,X.uint16[Y+1]=4*q+1,X.uint16[Y+2]=4*q+2,X.uint16[Y+3]=4*q+2,X.uint16[Y+4]=4*q+3,X.uint16[Y+5]=4*q+0}return X})(T));const N=p.createIndexBuffer(qr,!0),U=p.createVertexBuffer(z,c.cb.members,!0);for(const j of w){const Z=dc(d.transform);M.draw(p,_.TRIANGLES,Qe.disabled,at.disabled,d.colorModeForRenderPass(),ot.disabled,Z,d.style.map.terrain&&d.style.map.terrain.getTerrainData(j.coord),null,n.id,U,N,c.aX.simpleSegment(0,2*j.circleOffset,j.circleArray.length,j.circleArray.length/2),null,d.transform.zoom,null,null,null)}U.destroy(),N.destroy()}const Yu=c.ar(new Float32Array(16));function no(d,t,n,o,l,p){const{horizontalAlign:m,verticalAlign:_}=c.aS(d);return new c.P((-(m-.5)*t/l+o[0])*p,(-(_-.5)*n/l+o[1])*p)}function Ku(d,t,n,o,l,p){const m=t.tileAnchorPoint.add(new c.P(t.translation[0],t.translation[1]));if(t.pitchWithMap){let _=o.mult(p);n||(_=_.rotate(-l));const v=m.add(_);return ns(v.x,v.y,t.pitchedLabelPlaneMatrix,t.getElevation).point}if(n){const _=En(t.tileAnchorPoint.x+1,t.tileAnchorPoint.y,t).point.sub(d),v=Math.atan(_.y/_.x)+(_.x<0?Math.PI:0);return d.add(o.rotate(v))}return d.add(o)}function Ic(d,t,n,o,l,p,m,_,v,w,T,C){const M=d.text.placedSymbolArray,z=d.text.dynamicLayoutVertexArray,R=d.icon.dynamicLayoutVertexArray,N={};z.clear();for(let U=0;U<M.length;U++){const j=M.get(U),Z=j.hidden||!j.crossTileID||d.allowVerticalPlacement&&!j.placedOrientation?null:o[j.crossTileID];if(Z){const X=new c.P(j.anchorX,j.anchorY),q={getElevation:C,width:l.width,height:l.height,pitchedLabelPlaneMatrix:p,pitchWithMap:n,transform:l,tileAnchorPoint:X,translation:w,unwrappedTileID:T},Y=n?Lo(X.x,X.y,q):En(X.x,X.y,q),Q=ss(l.cameraToCenterDistance,Y.signedDistanceFromCamera);let H=c.aA(d.textSizeData,_,j)*Q/c.aM;n&&(H*=d.tilePixelRatio/m);const{width:te,height:de,anchor:ue,textOffset:ce,textBoxScale:he}=Z,Ce=no(ue,te,de,ce,he,H),Ie=l.getPitchedTextCorrection(X.x+w[0],X.y+w[1],T),ge=Ku(Y.point,q,t,Ce,-l.bearingInRadians,Ie),Re=d.allowVerticalPlacement&&j.placedOrientation===c.az.vertical?Math.PI/2:0;for(let Je=0;Je<j.numGlyphs;Je++)c.aG(z,ge,Re);v&&j.associatedIconIndex>=0&&(N[j.associatedIconIndex]={shiftedAnchor:ge,angle:Re})}else An(j.numGlyphs,z)}if(v){R.clear();const U=d.icon.placedSymbolArray;for(let j=0;j<U.length;j++){const Z=U.get(j);if(Z.hidden)An(Z.numGlyphs,R);else{const X=N[j];if(X)for(let q=0;q<Z.numGlyphs;q++)c.aG(R,X.shiftedAnchor,X.angle);else An(Z.numGlyphs,R)}}d.icon.dynamicLayoutVertexBuffer.updateData(R)}d.text.dynamicLayoutVertexBuffer.updateData(z)}function aa(d,t,n){return n.iconsInText&&t?"symbolTextAndIcon":d?"symbolSDF":"symbolIcon"}function la(d,t,n,o,l,p,m,_,v,w,T,C,M){const z=d.context,R=z.gl,N=d.transform,U=_==="map",j=v==="map",Z=_!=="viewport"&&n.layout.get("symbol-placement")!=="point",X=U&&!j&&!Z,q=!n.layout.get("symbol-sort-key").isConstant();let Y=!1;const Q=d.getDepthModeForSublayer(0,Qe.ReadOnly),H=n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"),te=[],de=N.getCircleRadiusCorrection();for(const ue of o){const ce=t.getTile(ue),he=ce.getBucket(n);if(!he)continue;const Ce=l?he.text:he.icon;if(!Ce||!Ce.segments.get().length||!Ce.hasVisibleVertices)continue;const Ie=Ce.programConfigurations.get(n.id),ge=l||he.sdfIcons,Re=l?he.textSizeData:he.iconSizeData,Je=j||N.pitch!==0,dt=d.useProgram(aa(ge,l,he),Ie),Tt=c.ay(Re,N.zoom),xt=d.style.map.terrain&&d.style.map.terrain.getTerrainData(ue);let It,pt,Kt,Et,hi=[0,0],Ft=null;if(l)pt=ce.glyphAtlasTexture,Kt=R.LINEAR,It=ce.glyphAtlasTexture.size,he.iconsInText&&(hi=ce.imageAtlasTexture.size,Ft=ce.imageAtlasTexture,Et=Je||d.options.rotating||d.options.zooming||Re.kind==="composite"||Re.kind==="camera"?R.LINEAR:R.NEAREST);else{const gt=n.layout.get("icon-size").constantOr(0)!==1||he.iconsNeedLinear;pt=ce.imageAtlasTexture,Kt=ge||d.options.rotating||d.options.zooming||gt||Je?R.LINEAR:R.NEAREST,It=ce.imageAtlasTexture.size}const Bt=c.aN(ce,1,d.transform.zoom),Ci=rs(U,d.transform,Bt),Xr=c.N();c.aB(Xr,Ci);const Ar=In(j,U,d.transform,Bt),Ii=c.aO(N,ce,p,m),Yr=N.getProjectionData({overscaledTileID:ue,applyGlobeMatrix:!M,applyTerrainMatrix:!0}),wo=H&&he.hasTextData(),To=n.layout.get("icon-text-fit")!=="none"&&wo&&he.hasIconData();if(Z){const gt=d.style.map.terrain?(Yi,ri)=>d.style.map.terrain.getElevation(ue,Yi,ri):null,At=n.layout.get("text-rotation-alignment")==="map";Fs(he,d,l,Ci,Xr,j,w,At,ue.toUnwrapped(),N.width,N.height,Ii,gt)}const ws=l&&H||To,Fi=Z||ws?Yu:j?Ci:d.transform.clipSpaceToPixelsMatrix,lr=ge&&n.paint.get(l?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Wi;Wi=ge?he.iconsInText?Ja(Re.kind,Tt,X,j,Z,ws,d,Fi,Ar,Ii,It,hi,de):fn(Re.kind,Tt,X,j,Z,ws,d,Fi,Ar,Ii,l,It,0,de):Yo(Re.kind,Tt,X,j,Z,ws,d,Fi,Ar,Ii,l,It,de);const Xi={program:dt,buffers:Ce,uniformValues:Wi,projectionData:Yr,atlasTexture:pt,atlasTextureIcon:Ft,atlasInterpolation:Kt,atlasInterpolationIcon:Et,isSDF:ge,hasHalo:lr};if(q&&he.canOverlap){Y=!0;const gt=Ce.segments.get();for(const At of gt)te.push({segments:new c.aX([At]),sortKey:At.sortKey,state:Xi,terrainData:xt})}else te.push({segments:Ce.segments,sortKey:0,state:Xi,terrainData:xt})}Y&&te.sort(((ue,ce)=>ue.sortKey-ce.sortKey));for(const ue of te){const ce=ue.state;if(z.activeTexture.set(R.TEXTURE0),ce.atlasTexture.bind(ce.atlasInterpolation,R.CLAMP_TO_EDGE),ce.atlasTextureIcon&&(z.activeTexture.set(R.TEXTURE1),ce.atlasTextureIcon&&ce.atlasTextureIcon.bind(ce.atlasInterpolationIcon,R.CLAMP_TO_EDGE)),ce.isSDF){const he=ce.uniformValues;ce.hasHalo&&(he.u_is_halo=1,nl(ce.buffers,ue.segments,n,d,ce.program,Q,T,C,he,ce.projectionData,ue.terrainData)),he.u_is_halo=0}nl(ce.buffers,ue.segments,n,d,ce.program,Q,T,C,ce.uniformValues,ce.projectionData,ue.terrainData)}}function nl(d,t,n,o,l,p,m,_,v,w,T){const C=o.context;l.draw(C,C.gl.TRIANGLES,p,m,_,ot.backCCW,v,T,w,n.id,d.layoutVertexBuffer,d.indexBuffer,t,n.paint,o.transform.zoom,d.programConfigurations.get(n.id),d.dynamicLayoutVertexBuffer,d.opacityVertexBuffer)}function Ec(d,t,n,o,l){const p=d.context,m=p.gl,_=at.disabled,v=new yt([m.ONE,m.ONE],c.bp.transparent,[!0,!0,!0,!0]),w=t.getBucket(n);if(!w)return;const T=o.key;let C=n.heatmapFbos.get(T);C||(C=ua(p,t.tileSize,t.tileSize),n.heatmapFbos.set(T,C)),p.bindFramebuffer.set(C.framebuffer),p.viewport.set([0,0,t.tileSize,t.tileSize]),p.clear({color:c.bp.transparent});const M=w.programConfigurations.get(n.id),z=d.useProgram("heatmap",M,!l),R=d.transform.getProjectionData({overscaledTileID:t.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),N=d.style.map.terrain.getTerrainData(o);z.draw(p,m.TRIANGLES,Qe.disabled,_,v,ot.disabled,pc(t,d.transform.zoom,n.paint.get("heatmap-intensity"),1),N,R,n.id,w.layoutVertexBuffer,w.indexBuffer,w.segments,n.paint,d.transform.zoom,M)}function ca(d,t,n,o,l){const p=d.context,m=p.gl,_=d.transform;p.setColorMode(d.colorModeForRenderPass());const v=Ac(p,t),w=n.key,T=t.heatmapFbos.get(w);if(!T)return;p.activeTexture.set(m.TEXTURE0),m.bindTexture(m.TEXTURE_2D,T.colorAttachment.get()),p.activeTexture.set(m.TEXTURE1),v.bind(m.LINEAR,m.CLAMP_TO_EDGE);const C=_.getProjectionData({overscaledTileID:n,applyTerrainMatrix:l,applyGlobeMatrix:!o});d.useProgram("heatmapTexture").draw(p,m.TRIANGLES,Qe.disabled,at.disabled,d.colorModeForRenderPass(),ot.disabled,Ys(d,t,0,1),null,C,t.id,d.rasterBoundsBuffer,d.quadTriangleIndexBuffer,d.rasterBoundsSegments,t.paint,_.zoom),T.destroy(),t.heatmapFbos.delete(w)}function ua(d,t,n){var o,l;const p=d.gl,m=p.createTexture();p.bindTexture(p.TEXTURE_2D,m),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.LINEAR),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.LINEAR);const _=(o=d.HALF_FLOAT)!==null&&o!==void 0?o:p.UNSIGNED_BYTE,v=(l=d.RGBA16F)!==null&&l!==void 0?l:p.RGBA;p.texImage2D(p.TEXTURE_2D,0,v,t,n,0,p.RGBA,_,null);const w=d.createFramebuffer(t,n,!1,!1);return w.colorAttachment.set(m),w}function Ac(d,t){return t.colorRampTexture||(t.colorRampTexture=new c.T(d,t.colorRamp,d.gl.RGBA)),t.colorRampTexture}function sl(d,t,n,o,l,p,m,_){let v=256;if(l.stepInterpolant){const w=t.getSource().maxzoom,T=m.canonical.z===w?Math.ceil(1<<d.transform.maxZoom-m.canonical.z):1;v=c.an(c.ce(p.maxLineLength/c.a5*1024*T),256,n.maxTextureSize)}return _.gradient=c.cf({expression:l.gradientExpression(),evaluationKey:"lineProgress",resolution:v,image:_.gradient||void 0,clips:p.lineClipsArray}),_.texture?_.texture.update(_.gradient):_.texture=new c.T(n,_.gradient,o.RGBA),_.version=l.gradientVersion,_.texture}function Ut(d,t,n,o,l){d.activeTexture.set(t.TEXTURE0),n.imageAtlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE),o.updatePaintBuffers(l)}function Nn(d,t,n,o,l,p){(l||d.lineAtlas.dirty)&&(t.activeTexture.set(n.TEXTURE0),d.lineAtlas.bind(t)),o.updatePaintBuffers(p)}function $i(d,t,n,o,l,p,m){const _=p.gradients[l.id];let v=_.texture;l.gradientVersion!==_.version&&(v=sl(d,t,n,o,l,p,m,_)),n.activeTexture.set(o.TEXTURE0),v.bind(l.stepInterpolant?o.NEAREST:o.LINEAR,o.CLAMP_TO_EDGE)}function ol(d,t,n,o,l,p,m,_,v){const w=p.gradients[l.id];let T=w.texture;l.gradientVersion!==w.version&&(T=sl(d,t,n,o,l,p,m,w)),n.activeTexture.set(o.TEXTURE0),T.bind(l.stepInterpolant?o.NEAREST:o.LINEAR,o.CLAMP_TO_EDGE),n.activeTexture.set(o.TEXTURE1),d.lineAtlas.bind(n),_.updatePaintBuffers(v)}function so(d,t,n,o,l){if(!n||!o||!o.imageAtlas)return;const p=o.imageAtlas.patternPositions;let m=p[n.to.toString()],_=p[n.from.toString()];if(!m&&_&&(m=_),!_&&m&&(_=m),!m||!_){const v=l.getPaintProperty(t);m=p[v],_=p[v]}m&&_&&d.setConstantPatternPositions(m,_)}function al(d,t,n,o,l,p,m,_){const v=d.context.gl,w="fill-pattern",T=n.paint.get(w),C=T&&T.constantOr(1),M=n.getCrossfadeParameters();let z,R,N,U,j;const Z=d.transform,X=n.paint.get("fill-translate"),q=n.paint.get("fill-translate-anchor");m?(R=C&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",z=v.LINES):(R=C?"fillPattern":"fill",z=v.TRIANGLES);const Y=T.constantOr(null);for(const Q of o){const H=t.getTile(Q);if(C&&!H.patternsLoaded())continue;const te=H.getBucket(n);if(!te)continue;const de=te.programConfigurations.get(n.id),ue=d.useProgram(R,de),ce=d.style.map.terrain&&d.style.map.terrain.getTerrainData(Q);C&&(d.context.activeTexture.set(v.TEXTURE0),H.imageAtlasTexture.bind(v.LINEAR,v.CLAMP_TO_EDGE),de.updatePaintBuffers(M)),so(de,w,Y,H,n);const he=Z.getProjectionData({overscaledTileID:Q,applyGlobeMatrix:!_,applyTerrainMatrix:!0}),Ce=c.aO(Z,H,X,q);if(m){U=te.indexBuffer2,j=te.segments2;const ge=[v.drawingBufferWidth,v.drawingBufferHeight];N=R==="fillOutlinePattern"&&C?uc(d,M,H,ge,Ce):cc(ge,Ce)}else U=te.indexBuffer,j=te.segments,N=C?Xa(d,M,H,Ce):{u_fill_translate:Ce};const Ie=d.stencilModeForClipping(Q);ue.draw(d.context,z,l,Ie,p,ot.backCCW,N,ce,he,n.id,te.layoutVertexBuffer,U,j,n.paint,d.transform.zoom,de)}}function mn(d,t,n,o,l,p,m,_){const v=d.context,w=v.gl,T="fill-extrusion-pattern",C=n.paint.get(T),M=C.constantOr(1),z=n.getCrossfadeParameters(),R=n.paint.get("fill-extrusion-opacity"),N=C.constantOr(null),U=d.transform;for(const j of o){const Z=t.getTile(j),X=Z.getBucket(n);if(!X)continue;const q=d.style.map.terrain&&d.style.map.terrain.getTerrainData(j),Y=X.programConfigurations.get(n.id),Q=d.useProgram(M?"fillExtrusionPattern":"fillExtrusion",Y);M&&(d.context.activeTexture.set(w.TEXTURE0),Z.imageAtlasTexture.bind(w.LINEAR,w.CLAMP_TO_EDGE),Y.updatePaintBuffers(z));const H=U.getProjectionData({overscaledTileID:j,applyGlobeMatrix:!_,applyTerrainMatrix:!0});so(Y,T,N,Z,n);const te=c.aO(U,Z,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),de=n.paint.get("fill-extrusion-vertical-gradient"),ue=M?lc(d,de,R,te,j,z,Z):Ho(d,de,R,te);Q.draw(v,v.gl.TRIANGLES,l,p,m,ot.backCCW,ue,q,H,n.id,X.layoutVertexBuffer,X.indexBuffer,X.segments,n.paint,d.transform.zoom,Y,d.style.map.terrain&&X.centroidVertexBuffer)}}function oo(d,t,n,o,l,p,m,_,v){var w;const T=d.style.projection,C=d.context,M=d.transform,z=C.gl,R=[`#define NUM_ILLUMINATION_SOURCES ${n.paint.get("hillshade-highlight-color").values.length}`],N=d.useProgram("hillshade",null,!1,R),U=!d.options.moving;for(const j of o){const Z=t.getTile(j),X=Z.fbo;if(!X)continue;const q=T.getMeshFromTileID(C,j.canonical,_,!0,"raster"),Y=(w=d.style.map.terrain)===null||w===void 0?void 0:w.getTerrainData(j);C.activeTexture.set(z.TEXTURE0),z.bindTexture(z.TEXTURE_2D,X.colorAttachment.get());const Q=M.getProjectionData({overscaledTileID:j,aligned:U,applyGlobeMatrix:!v,applyTerrainMatrix:!0});N.draw(C,z.TRIANGLES,p,l[j.overscaledZ],m,ot.backCCW,Nu(d,Z,n),Y,Q,n.id,q.vertexBuffer,q.indexBuffer,q.segments)}}function jn(d,t,n,o,l,p,m,_,v){var w;const T=d.style.projection,C=d.context,M=d.transform,z=C.gl,R=d.useProgram("colorRelief"),N=!d.options.moving;let U=!0,j=0;for(const Z of o){const X=t.getTile(Z),q=X.dem;if(U){const ue=z.getParameter(z.MAX_TEXTURE_SIZE),{elevationTexture:ce,colorTexture:he}=n.getColorRampTextures(C,ue,q.getUnpackVector());C.activeTexture.set(z.TEXTURE1),ce.bind(z.NEAREST,z.CLAMP_TO_EDGE),C.activeTexture.set(z.TEXTURE4),he.bind(z.LINEAR,z.CLAMP_TO_EDGE),U=!1,j=ce.size[0]}if(!q||!q.data)continue;const Y=q.stride,Q=q.getPixels();if(C.activeTexture.set(z.TEXTURE0),C.pixelStoreUnpackPremultiplyAlpha.set(!1),X.demTexture=X.demTexture||d.getTileTexture(Y),X.demTexture){const ue=X.demTexture;ue.update(Q,{premultiply:!1}),ue.bind(z.LINEAR,z.CLAMP_TO_EDGE)}else X.demTexture=new c.T(C,Q,z.RGBA,{premultiply:!1}),X.demTexture.bind(z.LINEAR,z.CLAMP_TO_EDGE);const H=T.getMeshFromTileID(C,Z.canonical,_,!0,"raster"),te=(w=d.style.map.terrain)===null||w===void 0?void 0:w.getTerrainData(Z),de=M.getProjectionData({overscaledTileID:Z,aligned:N,applyGlobeMatrix:!v,applyTerrainMatrix:!0});R.draw(C,z.TRIANGLES,p,l[Z.overscaledZ],m,ot.backCCW,mc(n,X.dem,j),te,de,n.id,H.vertexBuffer,H.indexBuffer,H.segments)}}const ao=[new c.P(0,0),new c.P(c.a5,0),new c.P(c.a5,c.a5),new c.P(0,c.a5)];function lo(d,t,n,o,l,p,m,_,v=!1,w=!1){const T=o[o.length-1].overscaledZ,C=d.context,M=C.gl,z=d.useProgram("raster"),R=d.transform,N=d.style.projection,U=d.colorModeForRenderPass(),j=!d.options.moving,Z=n.paint.get("raster-opacity"),X=n.paint.get("raster-resampling"),q=n.paint.get("raster-fade-duration"),Y=!!d.style.map.terrain;for(const Q of o){const H=d.getDepthModeForSublayer(Q.overscaledZ-T,Z===1?Qe.ReadWrite:Qe.ReadOnly,M.LESS),te=t.getTile(Q),de=X==="nearest"?M.NEAREST:M.LINEAR;C.activeTexture.set(M.TEXTURE0),te.texture.bind(de,M.CLAMP_TO_EDGE,M.LINEAR_MIPMAP_NEAREST),C.activeTexture.set(M.TEXTURE1);const{parentTile:ue,parentScaleBy:ce,parentTopLeft:he,fadeValues:Ce}=Dc(te,t,q,Y);te.fadeOpacity=Ce.tileOpacity,ue?(ue.fadeOpacity=Ce.parentTileOpacity,ue.texture.bind(de,M.CLAMP_TO_EDGE,M.LINEAR_MIPMAP_NEAREST)):te.texture.bind(de,M.CLAMP_TO_EDGE,M.LINEAR_MIPMAP_NEAREST),te.texture.useMipmap&&C.extTextureFilterAnisotropic&&d.transform.pitch>d.options.anisotropicFilterPitch&&M.texParameterf(M.TEXTURE_2D,C.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,C.extTextureFilterAnisotropicMax);const Ie=d.style.map.terrain&&d.style.map.terrain.getTerrainData(Q),ge=R.getProjectionData({overscaledTileID:Q,aligned:j,applyGlobeMatrix:!w,applyTerrainMatrix:!0}),Re=Ka(he,ce,Ce.fadeMix,n,_),Je=N.getMeshFromTileID(C,Q.canonical,p,m,"raster");z.draw(C,M.TRIANGLES,H,l?l[Q.overscaledZ]:at.disabled,U,v?ot.frontCCW:ot.backCCW,Re,Ie,ge,n.id,Je.vertexBuffer,Je.indexBuffer,Je.segments)}}function Dc(d,t,n,o){const l={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(n===0||o)return l;if(d.fadingParentID){const p=t.getLoadedTile(d.fadingParentID);if(!p)return l;const m=Math.pow(2,p.tileID.overscaledZ-d.tileID.overscaledZ),_=[d.tileID.canonical.x*m%1,d.tileID.canonical.y*m%1],v=(function(w,T,C){const M=He(),z=(M-T.timeAdded)/C,R=w.fadingDirection===J.Incoming,N=c.an((M-w.timeAdded)/C,0,1),U=c.an(1-z,0,1),j=R?N:U;return{tileOpacity:j,parentTileOpacity:R?U:N,fadeMix:{opacity:1,mix:1-j}}})(d,p,n);return{parentTile:p,parentScaleBy:m,parentTopLeft:_,fadeValues:v}}if(d.selfFading){const p=(function(m,_){const v=(He()-m.timeAdded)/_,w=c.an(v,0,1);return{tileOpacity:w,fadeMix:{opacity:w,mix:0}}})(d,n);return{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:p}}return l}const zc=new c.bp(1,0,0,1),kc=new c.bp(0,1,0,1),Lc=new c.bp(0,0,1,1),gn=new c.bp(1,0,1,1),Rc=new c.bp(0,1,1,1);function ll(d,t,n,o){co(d,0,t+n/2,d.transform.width,n,o)}function cl(d,t,n,o){co(d,t-n/2,0,n,d.transform.height,o)}function co(d,t,n,o,l,p){const m=d.context,_=m.gl;_.enable(_.SCISSOR_TEST),_.scissor(t*d.pixelRatio,n*d.pixelRatio,o*d.pixelRatio,l*d.pixelRatio),m.clear({color:p}),_.disable(_.SCISSOR_TEST)}function Fc(d,t,n){const o=d.context,l=o.gl,p=d.useProgram("debug"),m=Qe.disabled,_=at.disabled,v=d.colorModeForRenderPass(),w="$debug",T=d.style.map.terrain&&d.style.map.terrain.getTerrainData(n);o.activeTexture.set(l.TEXTURE0);const C=t.getTileByID(n.key).latestRawTileData,M=Math.floor((C&&C.byteLength||0)/1024),z=t.getTile(n).tileSize,R=512/Math.min(z,512)*(n.overscaledZ/d.transform.zoom)*.5;let N=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(N+=` => ${n.overscaledZ}`),(function(j,Z){j.initDebugOverlayCanvas();const X=j.debugOverlayCanvas,q=j.context.gl,Y=j.debugOverlayCanvas.getContext("2d");Y.clearRect(0,0,X.width,X.height),Y.shadowColor="white",Y.shadowBlur=2,Y.lineWidth=1.5,Y.strokeStyle="white",Y.textBaseline="top",Y.font="bold 36px Open Sans, sans-serif",Y.fillText(Z,5,5),Y.strokeText(Z,5,5),j.debugOverlayTexture.update(X),j.debugOverlayTexture.bind(q.LINEAR,q.CLAMP_TO_EDGE)})(d,`${N} ${M}kB`);const U=d.transform.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!0,applyTerrainMatrix:!0});p.draw(o,l.TRIANGLES,m,_,yt.alphaBlended,ot.disabled,ms(c.bp.transparent,R),null,U,w,d.debugBuffer,d.quadTriangleIndexBuffer,d.debugSegments),p.draw(o,l.LINE_STRIP,m,_,v,ot.disabled,ms(c.bp.red),T,U,w,d.debugBuffer,d.tileBorderIndexBuffer,d.debugSegments)}function ul(d,t,n,o){const{isRenderingGlobe:l}=o,p=d.context,m=p.gl,_=d.transform,v=d.colorModeForRenderPass(),w=d.getDepthModeFor3D(),T=d.useProgram("terrain");p.bindFramebuffer.set(null),p.viewport.set([0,0,d.width,d.height]);for(const C of n){const M=t.getTerrainMesh(C.tileID),z=d.renderToTexture.getTexture(C),R=t.getTerrainData(C.tileID);p.activeTexture.set(m.TEXTURE0),m.bindTexture(m.TEXTURE_2D,z.texture);const N=t.getMeshFrameDelta(_.zoom),U=_.calculateFogMatrix(C.tileID.toUnwrapped()),j=fs(N,U,d.style.sky,_.pitch,l),Z=_.getProjectionData({overscaledTileID:C.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});T.draw(p,m.TRIANGLES,w,at.disabled,v,ot.backCCW,j,R,Z,"terrain",M.vertexBuffer,M.indexBuffer,M.segments)}}function hl(d,t){if(!t.mesh){const n=new c.aW;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(1,1),n.emplaceBack(-1,1);const o=new c.aY;o.emplaceBack(0,1,2),o.emplaceBack(0,2,3),t.mesh=new cs(d.createVertexBuffer(n,Wt.members),d.createIndexBuffer(o),c.aX.simpleSegment(0,0,n.length,o.length))}return t.mesh}class Bc{constructor(t,n){this.context=new ro(t),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:c.ar(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Me.maxOverzooming+Me.maxUnderzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new _i}resize(t,n,o){if(this.width=Math.floor(t*o),this.height=Math.floor(n*o),this.pixelRatio=o,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const l of this.style._order)this.style._layers[l].resize()}setup(){const t=this.context,n=new c.aW;n.emplaceBack(0,0),n.emplaceBack(c.a5,0),n.emplaceBack(0,c.a5),n.emplaceBack(c.a5,c.a5),this.tileExtentBuffer=t.createVertexBuffer(n,Wt.members),this.tileExtentSegments=c.aX.simpleSegment(0,0,4,2);const o=new c.aW;o.emplaceBack(0,0),o.emplaceBack(c.a5,0),o.emplaceBack(0,c.a5),o.emplaceBack(c.a5,c.a5),this.debugBuffer=t.createVertexBuffer(o,Wt.members),this.debugSegments=c.aX.simpleSegment(0,0,4,5);const l=new c.ch;l.emplaceBack(0,0,0,0),l.emplaceBack(c.a5,0,c.a5,0),l.emplaceBack(0,c.a5,0,c.a5),l.emplaceBack(c.a5,c.a5,c.a5,c.a5),this.rasterBoundsBuffer=t.createVertexBuffer(l,$o.members),this.rasterBoundsSegments=c.aX.simpleSegment(0,0,4,2);const p=new c.aW;p.emplaceBack(0,0),p.emplaceBack(c.a5,0),p.emplaceBack(0,c.a5),p.emplaceBack(c.a5,c.a5),this.rasterBoundsBufferPosOnly=t.createVertexBuffer(p,Wt.members),this.rasterBoundsSegmentsPosOnly=c.aX.simpleSegment(0,0,4,5);const m=new c.aW;m.emplaceBack(0,0),m.emplaceBack(1,0),m.emplaceBack(0,1),m.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(m,Wt.members),this.viewportSegments=c.aX.simpleSegment(0,0,4,2);const _=new c.ci;_.emplaceBack(0),_.emplaceBack(1),_.emplaceBack(3),_.emplaceBack(2),_.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(_);const v=new c.aY;v.emplaceBack(1,0,2),v.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(v);const w=this.context.gl;this.stencilClearMode=new at({func:w.ALWAYS,mask:0},0,255,w.ZERO,w.ZERO,w.ZERO),this.tileExtentMesh=new cs(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const t=this.context,n=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const o=c.N();c.c7(o,0,this.width,this.height,0,0,1),c.Q(o,o,[n.drawingBufferWidth,n.drawingBufferHeight,0]);const l={mainMatrix:o,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:o};this.useProgram("clippingMask",null,!0).draw(t,n.TRIANGLES,Qe.disabled,this.stencilClearMode,yt.disabled,ot.disabled,null,null,l,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,n,o){if(this.currentStencilSource===t.source||!t.isTileClipped()||!n||!n.length)return;this.currentStencilSource=t.source,this.nextStencilID+n.length>256&&this.clearStencil();const l=this.context;l.setColorMode(yt.disabled),l.setDepthMode(Qe.disabled);const p={};for(const m of n)p[m.key]=this.nextStencilID++;this._renderTileMasks(p,n,o,!0),this._renderTileMasks(p,n,o,!1),this._tileClippingMaskIDs=p}_renderTileMasks(t,n,o,l){const p=this.context,m=p.gl,_=this.style.projection,v=this.transform,w=this.useProgram("clippingMask");for(const T of n){const C=t[T.key],M=this.style.map.terrain&&this.style.map.terrain.getTerrainData(T),z=_.getMeshFromTileID(this.context,T.canonical,l,!0,"stencil"),R=v.getProjectionData({overscaledTileID:T,applyGlobeMatrix:!o,applyTerrainMatrix:!0});w.draw(p,m.TRIANGLES,Qe.disabled,new at({func:m.ALWAYS,mask:0},C,255,m.KEEP,m.KEEP,m.REPLACE),yt.disabled,o?ot.disabled:ot.backCCW,null,M,R,"$clipping",z.vertexBuffer,z.indexBuffer,z.segments)}}_renderTilesDepthBuffer(){const t=this.context,n=t.gl,o=this.style.projection,l=this.transform,p=this.useProgram("depth"),m=this.getDepthModeFor3D(),_=wt(l,{tileSize:l.tileSize});for(const v of _){const w=this.style.map.terrain&&this.style.map.terrain.getTerrainData(v),T=o.getMeshFromTileID(this.context,v.canonical,!0,!0,"raster"),C=l.getProjectionData({overscaledTileID:v,applyGlobeMatrix:!0,applyTerrainMatrix:!0});p.draw(t,n.TRIANGLES,m,at.disabled,yt.disabled,ot.backCCW,null,w,C,"$clipping",T.vertexBuffer,T.indexBuffer,T.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,n=this.context.gl;return new at({func:n.NOTEQUAL,mask:255},t,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(t){const n=this.context.gl;return new at({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,n.KEEP,n.KEEP,n.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(t){const n=this.context.gl,o=t.sort(((m,_)=>_.overscaledZ-m.overscaledZ)),l=o[o.length-1].overscaledZ,p=o[0].overscaledZ-l+1;if(p>1){this.currentStencilSource=void 0,this.nextStencilID+p>256&&this.clearStencil();const m={};for(let _=0;_<p;_++)m[_+l]=new at({func:n.GEQUAL,mask:255},_+this.nextStencilID,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID+=p,[m,o]}return[{[l]:at.disabled},o]}stencilConfigForOverlapTwoPass(t){const n=this.context.gl,o=t.sort(((m,_)=>_.overscaledZ-m.overscaledZ)),l=o[o.length-1].overscaledZ,p=o[0].overscaledZ-l+1;if(this.clearStencil(),p>1){const m={},_={};for(let v=0;v<p;v++)m[v+l]=new at({func:n.GREATER,mask:255},p+1+v,255,n.KEEP,n.KEEP,n.REPLACE),_[v+l]=new at({func:n.GREATER,mask:255},1+v,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID=2*p+1,[m,_,o]}return this.nextStencilID=3,[{[l]:new at({func:n.GREATER,mask:255},2,255,n.KEEP,n.KEEP,n.REPLACE)},{[l]:new at({func:n.GREATER,mask:255},1,255,n.KEEP,n.KEEP,n.REPLACE)},o]}colorModeForRenderPass(){const t=this.context.gl;return this._showOverdrawInspector?new yt([t.CONSTANT_COLOR,t.ONE],new c.bp(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?yt.unblended:yt.alphaBlended}getDepthModeForSublayer(t,n,o){if(!this.opaquePassEnabledForLayer())return Qe.disabled;const l=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new Qe(o||this.context.gl.LEQUAL,n,[l,l])}getDepthModeFor3D(){return new Qe(this.context.gl.LEQUAL,Qe.ReadWrite,this.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,n){var o,l;this.style=t,this.options=n,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(He()),this.imageManager.beginFrame();const p=this.style._order,m=this.style.tileManagers,_={},v={},w={},T={isRenderingToTexture:!1,isRenderingGlobe:((o=t.projection)===null||o===void 0?void 0:o.transitionState)>0};for(const M in m){const z=m[M];z.used&&z.prepare(this.context),_[M]=z.getVisibleCoordinates(!1),v[M]=_[M].slice().reverse(),w[M]=z.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let M=0;M<p.length;M++)if(this.style._layers[p[M]].is3D()){this.opaquePassCutoff=M;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const M of p){const z=this.style._layers[M];if(!z.hasOffscreenPass()||z.isHidden(this.transform.zoom))continue;const R=v[z.source];(z.type==="custom"||R.length)&&this.renderLayer(this,m[z.source],z,R,T)}if((l=this.style.projection)===null||l===void 0||l.updateGPUdependent({context:this.context,useProgram:M=>this.useProgram(M)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:n.showOverdrawInspector?c.bp.black:c.bp.transparent,depth:1}),this.clearStencil(),this.style.sky&&(function(M,z){const R=M.context,N=R.gl,U=((Q,H,te)=>{const de=Math.cos(H.rollInRadians),ue=Math.sin(H.rollInRadians),ce=me(H),he=H.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:Q.properties.get("sky-color"),u_horizon_color:Q.properties.get("horizon-color"),u_horizon:[(H.width/2-ce*ue)*te,(H.height/2+ce*de)*te],u_horizon_normal:[-ue,de],u_sky_horizon_blend:Q.properties.get("sky-horizon-blend")*H.height/2*te,u_sky_blend:he}})(z,M.style.map.transform,M.pixelRatio),j=new Qe(N.LEQUAL,Qe.ReadWrite,[0,1]),Z=at.disabled,X=M.colorModeForRenderPass(),q=M.useProgram("sky"),Y=hl(R,z);q.draw(R,N.TRIANGLES,j,Z,X,ot.disabled,U,null,void 0,"sky",Y.vertexBuffer,Y.indexBuffer,Y.segments)})(this,this.style.sky),this._showOverdrawInspector=n.showOverdrawInspector,this.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=p.length-1;this.currentLayer>=0;this.currentLayer--){const M=this.style._layers[p[this.currentLayer]],z=m[M.source],R=_[M.source];this._renderTileClippingMasks(M,R,!1),this.renderLayer(this,z,M,R,T)}this.renderPass="translucent";let C=!1;for(this.currentLayer=0;this.currentLayer<p.length;this.currentLayer++){const M=this.style._layers[p[this.currentLayer]],z=m[M.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(M,T))continue;this.opaquePassEnabledForLayer()||C||(C=!0,T.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());const R=(M.type==="symbol"?w:v)[M.source];this._renderTileClippingMasks(M,_[M.source],!!this.renderToTexture),this.renderLayer(this,z,M,R,T)}if(T.isRenderingGlobe&&(function(M,z,R){const N=M.context,U=N.gl,j=M.useProgram("atmosphere"),Z=new Qe(U.LEQUAL,Qe.ReadOnly,[0,1]),X=M.transform,q=(function(he,Ce){const Ie=he.properties.get("position"),ge=[-Ie.x,-Ie.y,-Ie.z],Re=c.ar(new Float64Array(16));return he.properties.get("anchor")==="map"&&(c.bg(Re,Re,Ce.rollInRadians),c.bh(Re,Re,-Ce.pitchInRadians),c.bg(Re,Re,Ce.bearingInRadians),c.bh(Re,Re,Ce.center.lat*Math.PI/180),c.bJ(Re,Re,-Ce.center.lng*Math.PI/180)),c.cg(ge,ge,Re),ge})(R,M.transform),Y=X.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),Q=z.properties.get("atmosphere-blend")*Y.projectionTransition;if(Q===0)return;const H=$s(X.worldSize,X.center.lat),te=X.inverseProjectionMatrix,de=new Float64Array(4);de[3]=1,c.aH(de,de,X.modelViewProjectionMatrix),de[0]/=de[3],de[1]/=de[3],de[2]/=de[3],de[3]=1,c.aH(de,de,te),de[0]/=de[3],de[1]/=de[3],de[2]/=de[3],de[3]=1;const ue=((he,Ce,Ie,ge,Re)=>({u_sun_pos:he,u_atmosphere_blend:Ce,u_globe_position:Ie,u_globe_radius:ge,u_inv_proj_matrix:Re}))(q,Q,[de[0],de[1],de[2]],H,te),ce=hl(N,z);j.draw(N,U.TRIANGLES,Z,at.disabled,yt.alphaBlended,ot.disabled,ue,null,null,"atmosphere",ce.vertexBuffer,ce.indexBuffer,ce.segments)})(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const M=(function(z,R){let N=null;const U=Object.values(z._layers).flatMap((q=>q.source&&!q.isHidden(R)?[z.tileManagers[q.source]]:[])),j=U.filter((q=>q.getSource().type==="vector")),Z=U.filter((q=>q.getSource().type!=="vector")),X=q=>{(!N||N.getSource().maxzoom<q.getSource().maxzoom)&&(N=q)};return j.forEach((q=>X(q))),N||Z.forEach((q=>X(q))),N})(this.style,this.transform.zoom);M&&(function(z,R,N){for(let U=0;U<N.length;U++)Fc(z,R,N[U])})(this,M,M.getVisibleCoordinates())}this.options.showPadding&&(function(M){const z=M.transform.padding;ll(M,M.transform.height-(z.top||0),3,zc),ll(M,z.bottom||0,3,kc),cl(M,z.left||0,3,Lc),cl(M,M.transform.width-(z.right||0),3,gn);const R=M.transform.centerPoint;(function(N,U,j,Z){co(N,U-1,j-10,2,20,Z),co(N,U-10,j-1,20,2,Z)})(M,R.x,M.transform.height-R.y,Rc)})(this),this.context.setDefault()}maybeDrawDepthAndCoords(t){if(!this.style||!this.style.map||!this.style.map.terrain)return;const n=this.terrainFacilitator.matrix,o=this.transform.modelViewProjectionMatrix;let l=this.terrainFacilitator.dirty;l||(l=t?!c.cj(n,o):!c.ck(n,o)),l||(l=this.style.map.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime)),l&&(c.cl(n,o),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,(function(p,m){const _=p.context,v=_.gl,w=p.transform,T=yt.unblended,C=new Qe(v.LEQUAL,Qe.ReadWrite,[0,1]),M=m.tileManager.getRenderableTiles(),z=p.useProgram("terrainDepth");_.bindFramebuffer.set(m.getFramebuffer("depth").framebuffer),_.viewport.set([0,0,p.width/devicePixelRatio,p.height/devicePixelRatio]),_.clear({color:c.bp.transparent,depth:1});for(const R of M){const N=m.getTerrainMesh(R.tileID),U=m.getTerrainData(R.tileID),j=w.getProjectionData({overscaledTileID:R.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),Z={u_ele_delta:m.getMeshFrameDelta(w.zoom)};z.draw(_,v.TRIANGLES,C,at.disabled,T,ot.backCCW,Z,U,j,"terrain",N.vertexBuffer,N.indexBuffer,N.segments)}_.bindFramebuffer.set(null),_.viewport.set([0,0,p.width,p.height])})(this,this.style.map.terrain),(function(p,m){const _=p.context,v=_.gl,w=p.transform,T=yt.unblended,C=new Qe(v.LEQUAL,Qe.ReadWrite,[0,1]),M=m.getCoordsTexture(),z=m.tileManager.getRenderableTiles(),R=p.useProgram("terrainCoords");_.bindFramebuffer.set(m.getFramebuffer("coords").framebuffer),_.viewport.set([0,0,p.width/devicePixelRatio,p.height/devicePixelRatio]),_.clear({color:c.bp.transparent,depth:1}),m.coordsIndex=[];for(const N of z){const U=m.getTerrainMesh(N.tileID),j=m.getTerrainData(N.tileID);_.activeTexture.set(v.TEXTURE0),v.bindTexture(v.TEXTURE_2D,M.texture);const Z={u_terrain_coords_id:(255-m.coordsIndex.length)/255,u_texture:0,u_ele_delta:m.getMeshFrameDelta(w.zoom)},X=w.getProjectionData({overscaledTileID:N.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});R.draw(_,v.TRIANGLES,C,at.disabled,T,ot.backCCW,Z,j,X,"terrain",U.vertexBuffer,U.indexBuffer,U.segments),m.coordsIndex.push(N.tileID.key)}_.bindFramebuffer.set(null),_.viewport.set([0,0,p.width,p.height])})(this,this.style.map.terrain))}renderLayer(t,n,o,l,p){o.isHidden(this.transform.zoom)||(o.type==="background"||o.type==="custom"||(l||[]).length)&&(this.id=o.id,c.cm(o)?(function(m,_,v,w,T,C){if(m.renderPass!=="translucent")return;const{isRenderingToTexture:M}=C,z=at.disabled,R=m.colorModeForRenderPass();(v._unevaluatedLayout.hasValue("text-variable-anchor")||v._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&(function(N,U,j,Z,X,q,Y,Q,H){const te=U.transform,de=U.style.map.terrain,ue=X==="map",ce=q==="map";for(const he of N){const Ce=Z.getTile(he),Ie=Ce.getBucket(j);if(!Ie||!Ie.text||!Ie.text.segments.get().length)continue;const ge=c.ay(Ie.textSizeData,te.zoom),Re=c.aN(Ce,1,U.transform.zoom),Je=rs(ue,U.transform,Re),dt=j.layout.get("icon-text-fit")!=="none"&&Ie.hasIconData();if(ge){const Tt=Math.pow(2,te.zoom-Ce.tileID.overscaledZ),xt=de?(It,pt)=>de.getElevation(he,It,pt):null;Ic(Ie,ue,ce,H,te,Je,Tt,ge,dt,c.aO(te,Ce,Y,Q),he.toUnwrapped(),xt)}}})(w,m,v,_,v.layout.get("text-rotation-alignment"),v.layout.get("text-pitch-alignment"),v.paint.get("text-translate"),v.paint.get("text-translate-anchor"),T),v.paint.get("icon-opacity").constantOr(1)!==0&&la(m,_,v,w,!1,v.paint.get("icon-translate"),v.paint.get("icon-translate-anchor"),v.layout.get("icon-rotation-alignment"),v.layout.get("icon-pitch-alignment"),v.layout.get("icon-keep-upright"),z,R,M),v.paint.get("text-opacity").constantOr(1)!==0&&la(m,_,v,w,!0,v.paint.get("text-translate"),v.paint.get("text-translate-anchor"),v.layout.get("text-rotation-alignment"),v.layout.get("text-pitch-alignment"),v.layout.get("text-keep-upright"),z,R,M),_.map.showCollisionBoxes&&(oa(m,_,v,w,!0),oa(m,_,v,w,!1))})(t,n,o,l,this.style.placement.variableOffsets,p):c.cn(o)?(function(m,_,v,w,T){if(m.renderPass!=="translucent")return;const{isRenderingToTexture:C}=T,M=v.paint.get("circle-opacity"),z=v.paint.get("circle-stroke-width"),R=v.paint.get("circle-stroke-opacity"),N=!v.layout.get("circle-sort-key").isConstant();if(M.constantOr(1)===0&&(z.constantOr(1)===0||R.constantOr(1)===0))return;const U=m.context,j=U.gl,Z=m.transform,X=m.getDepthModeForSublayer(0,Qe.ReadOnly),q=at.disabled,Y=m.colorModeForRenderPass(),Q=[],H=Z.getCircleRadiusCorrection();for(let te=0;te<w.length;te++){const de=w[te],ue=_.getTile(de),ce=ue.getBucket(v);if(!ce)continue;const he=v.paint.get("circle-translate"),Ce=v.paint.get("circle-translate-anchor"),Ie=c.aO(Z,ue,he,Ce),ge=ce.programConfigurations.get(v.id),Re=m.useProgram("circle",ge),Je=ce.layoutVertexBuffer,dt=ce.indexBuffer,Tt=m.style.map.terrain&&m.style.map.terrain.getTerrainData(de),xt={programConfiguration:ge,program:Re,layoutVertexBuffer:Je,indexBuffer:dt,uniformValues:Fn(m,ue,v,Ie,H),terrainData:Tt,projectionData:Z.getProjectionData({overscaledTileID:de,applyGlobeMatrix:!C,applyTerrainMatrix:!0})};if(N){const It=ce.segments.get();for(const pt of It)Q.push({segments:new c.aX([pt]),sortKey:pt.sortKey,state:xt})}else Q.push({segments:ce.segments,sortKey:0,state:xt})}N&&Q.sort(((te,de)=>te.sortKey-de.sortKey));for(const te of Q){const{programConfiguration:de,program:ue,layoutVertexBuffer:ce,indexBuffer:he,uniformValues:Ce,terrainData:Ie,projectionData:ge}=te.state;ue.draw(U,j.TRIANGLES,X,q,Y,ot.backCCW,Ce,Ie,ge,v.id,ce,he,te.segments,v.paint,m.transform.zoom,de)}})(t,n,o,l,p):c.co(o)?(function(m,_,v,w,T){if(v.paint.get("heatmap-opacity")===0)return;const C=m.context,{isRenderingToTexture:M,isRenderingGlobe:z}=T;if(m.style.map.terrain){for(const R of w){const N=_.getTile(R);_.hasRenderableParent(R)||(m.renderPass==="offscreen"?Ec(m,N,v,R,z):m.renderPass==="translucent"&&ca(m,v,R,M,z))}C.viewport.set([0,0,m.width,m.height])}else m.renderPass==="offscreen"?(function(R,N,U,j){const Z=R.context,X=Z.gl,q=R.transform,Y=at.disabled,Q=new yt([X.ONE,X.ONE],c.bp.transparent,[!0,!0,!0,!0]);(function(H,te,de){const ue=H.gl;H.activeTexture.set(ue.TEXTURE1),H.viewport.set([0,0,te.width/4,te.height/4]);let ce=de.heatmapFbos.get(c.cd);ce?(ue.bindTexture(ue.TEXTURE_2D,ce.colorAttachment.get()),H.bindFramebuffer.set(ce.framebuffer)):(ce=ua(H,te.width/4,te.height/4),de.heatmapFbos.set(c.cd,ce))})(Z,R,U),Z.clear({color:c.bp.transparent});for(let H=0;H<j.length;H++){const te=j[H];if(N.hasRenderableParent(te))continue;const de=N.getTile(te),ue=de.getBucket(U);if(!ue)continue;const ce=ue.programConfigurations.get(U.id),he=R.useProgram("heatmap",ce),Ce=q.getProjectionData({overscaledTileID:te,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),Ie=q.getCircleRadiusCorrection();he.draw(Z,X.TRIANGLES,Qe.disabled,Y,Q,ot.backCCW,pc(de,q.zoom,U.paint.get("heatmap-intensity"),Ie),null,Ce,U.id,ue.layoutVertexBuffer,ue.indexBuffer,ue.segments,U.paint,q.zoom,ce)}Z.viewport.set([0,0,R.width,R.height])})(m,_,v,w):m.renderPass==="translucent"&&(function(R,N){const U=R.context,j=U.gl;U.setColorMode(R.colorModeForRenderPass());const Z=N.heatmapFbos.get(c.cd);Z&&(U.activeTexture.set(j.TEXTURE0),j.bindTexture(j.TEXTURE_2D,Z.colorAttachment.get()),U.activeTexture.set(j.TEXTURE1),Ac(U,N).bind(j.LINEAR,j.CLAMP_TO_EDGE),R.useProgram("heatmapTexture").draw(U,j.TRIANGLES,Qe.disabled,at.disabled,R.colorModeForRenderPass(),ot.disabled,Ys(R,N,0,1),null,null,N.id,R.viewportBuffer,R.quadTriangleIndexBuffer,R.viewportSegments,N.paint,R.transform.zoom))})(m,v)})(t,n,o,l,p):c.cp(o)?(function(m,_,v,w,T){if(m.renderPass!=="translucent")return;const{isRenderingToTexture:C}=T,M=v.paint.get("line-opacity"),z=v.paint.get("line-width");if(M.constantOr(1)===0||z.constantOr(1)===0)return;const R=m.getDepthModeForSublayer(0,Qe.ReadOnly),N=m.colorModeForRenderPass(),U=v.paint.get("line-dasharray"),j=U.constantOr(1),Z=v.paint.get("line-pattern"),X=Z.constantOr(1),q=v.paint.get("line-gradient"),Y=v.getCrossfadeParameters();let Q;Q=X?"linePattern":j&&q?"lineGradientSDF":j?"lineSDF":q?"lineGradient":"line";const H=m.context,te=H.gl,de=m.transform;let ue=!0;for(const ce of w){const he=_.getTile(ce);if(X&&!he.patternsLoaded())continue;const Ce=he.getBucket(v);if(!Ce)continue;const Ie=Ce.programConfigurations.get(v.id),ge=m.context.program.get(),Re=m.useProgram(Q,Ie),Je=ue||Re.program!==ge,dt=m.style.map.terrain&&m.style.map.terrain.getTerrainData(ce),Tt=Z.constantOr(null),xt=U&&U.constantOr(null);if(Tt&&he.imageAtlas){const hi=he.imageAtlas,Ft=hi.patternPositions[Tt.to.toString()],Bt=hi.patternPositions[Tt.from.toString()];Ft&&Bt&&Ie.setConstantPatternPositions(Ft,Bt)}else if(xt){const hi=v.layout.get("line-cap")==="round",Ft=m.lineAtlas.getDash(xt.to,hi),Bt=m.lineAtlas.getDash(xt.from,hi);Ie.setConstantDashPositions(Ft,Bt)}const It=de.getProjectionData({overscaledTileID:ce,applyGlobeMatrix:!C,applyTerrainMatrix:!0}),pt=de.getPixelScale();let Kt;X?(Kt=gc(m,he,v,pt,Y),Ut(H,te,he,Ie,Y)):j&&q?(Kt=Gr(m,he,v,pt,Y,Ce.lineClipsArray.length),ol(m,_,H,te,v,Ce,ce,Ie,Y)):j?(Kt=Wo(m,he,v,pt,Y),Nn(m,H,te,Ie,Je,Y)):q?(Kt=Ya(m,he,v,pt,Ce.lineClipsArray.length),$i(m,_,H,te,v,Ce,ce)):Kt=Ks(m,he,v,pt);const Et=m.stencilModeForClipping(ce);Re.draw(H,te.TRIANGLES,R,Et,N,ot.disabled,Kt,dt,It,v.id,Ce.layoutVertexBuffer,Ce.indexBuffer,Ce.segments,v.paint,m.transform.zoom,Ie,Ce.layoutVertexBuffer2),ue=!1}})(t,n,o,l,p):c.cq(o)?(function(m,_,v,w,T){const C=v.paint.get("fill-color"),M=v.paint.get("fill-opacity");if(M.constantOr(1)===0)return;const{isRenderingToTexture:z}=T,R=m.colorModeForRenderPass(),N=v.paint.get("fill-pattern"),U=m.opaquePassEnabledForLayer()&&!N.constantOr(1)&&C.constantOr(c.bp.transparent).a===1&&M.constantOr(0)===1?"opaque":"translucent";if(m.renderPass===U){const j=m.getDepthModeForSublayer(1,m.renderPass==="opaque"?Qe.ReadWrite:Qe.ReadOnly);al(m,_,v,w,j,R,!1,z)}if(m.renderPass==="translucent"&&v.paint.get("fill-antialias")){const j=m.getDepthModeForSublayer(v.getPaintProperty("fill-outline-color")?2:0,Qe.ReadOnly);al(m,_,v,w,j,R,!0,z)}})(t,n,o,l,p):c.cr(o)?(function(m,_,v,w,T){const C=v.paint.get("fill-extrusion-opacity");if(C===0)return;const{isRenderingToTexture:M}=T;if(m.renderPass==="translucent"){const z=new Qe(m.context.gl.LEQUAL,Qe.ReadWrite,m.depthRangeFor3D);if(C!==1||v.paint.get("fill-extrusion-pattern").constantOr(1))mn(m,_,v,w,z,at.disabled,yt.disabled,M),mn(m,_,v,w,z,m.stencilModeFor3D(),m.colorModeForRenderPass(),M);else{const R=m.colorModeForRenderPass();mn(m,_,v,w,z,at.disabled,R,M)}}})(t,n,o,l,p):c.cs(o)?(function(m,_,v,w,T){if(m.renderPass!=="offscreen"&&m.renderPass!=="translucent")return;const{isRenderingToTexture:C}=T,M=m.context,z=m.style.projection.useSubdivision,R=m.getDepthModeForSublayer(0,Qe.ReadOnly),N=m.colorModeForRenderPass();if(m.renderPass==="offscreen")(function(U,j,Z,X,q,Y,Q){const H=U.context,te=H.gl;for(const de of Z){const ue=j.getTile(de),ce=ue.dem;if(!ce||!ce.data||!ue.needsHillshadePrepare)continue;const he=ce.dim,Ce=ce.stride,Ie=ce.getPixels();if(H.activeTexture.set(te.TEXTURE1),H.pixelStoreUnpackPremultiplyAlpha.set(!1),ue.demTexture=ue.demTexture||U.getTileTexture(Ce),ue.demTexture){const Re=ue.demTexture;Re.update(Ie,{premultiply:!1}),Re.bind(te.NEAREST,te.CLAMP_TO_EDGE)}else ue.demTexture=new c.T(H,Ie,te.RGBA,{premultiply:!1}),ue.demTexture.bind(te.NEAREST,te.CLAMP_TO_EDGE);H.activeTexture.set(te.TEXTURE0);let ge=ue.fbo;if(!ge){const Re=new c.T(H,{width:he,height:he,data:null},te.RGBA);Re.bind(te.LINEAR,te.CLAMP_TO_EDGE),ge=ue.fbo=H.createFramebuffer(he,he,!0,!1),ge.colorAttachment.set(Re.texture)}H.bindFramebuffer.set(ge.framebuffer),H.viewport.set([0,0,he,he]),U.useProgram("hillshadePrepare").draw(H,te.TRIANGLES,q,Y,Q,ot.disabled,ju(ue.tileID,ce),null,null,X.id,U.rasterBoundsBuffer,U.quadTriangleIndexBuffer,U.rasterBoundsSegments),ue.needsHillshadePrepare=!1}})(m,_,w,v,R,at.disabled,N),M.viewport.set([0,0,m.width,m.height]);else if(m.renderPass==="translucent")if(z){const[U,j,Z]=m.stencilConfigForOverlapTwoPass(w);oo(m,_,v,Z,U,R,N,!1,C),oo(m,_,v,Z,j,R,N,!0,C)}else{const[U,j]=m.getStencilConfigForOverlapAndUpdateStencilID(w);oo(m,_,v,j,U,R,N,!1,C)}})(t,n,o,l,p):c.ct(o)?(function(m,_,v,w,T){if(m.renderPass!=="translucent"||!w.length)return;const{isRenderingToTexture:C}=T,M=m.style.projection.useSubdivision,z=m.getDepthModeForSublayer(0,Qe.ReadOnly),R=m.colorModeForRenderPass();if(M){const[N,U,j]=m.stencilConfigForOverlapTwoPass(w);jn(m,_,v,j,N,z,R,!1,C),jn(m,_,v,j,U,z,R,!0,C)}else{const[N,U]=m.getStencilConfigForOverlapAndUpdateStencilID(w);jn(m,_,v,U,N,z,R,!1,C)}})(t,n,o,l,p):c.bU(o)?(function(m,_,v,w,T){if(m.renderPass!=="translucent"||v.paint.get("raster-opacity")===0||!w.length)return;const{isRenderingToTexture:C}=T,M=_.getSource(),z=m.style.projection.useSubdivision;if(M instanceof Br)lo(m,_,v,w,null,!1,!1,M.tileCoords,M.flippedWindingOrder,C);else if(z){const[R,N,U]=m.stencilConfigForOverlapTwoPass(w);lo(m,_,v,U,R,!1,!0,ao,!1,C),lo(m,_,v,U,N,!0,!0,ao,!1,C)}else{const[R,N]=m.getStencilConfigForOverlapAndUpdateStencilID(w);lo(m,_,v,N,R,!1,!0,ao,!1,C)}})(t,n,o,l,p):c.cu(o)?(function(m,_,v,w,T){const C=v.paint.get("background-color"),M=v.paint.get("background-opacity");if(M===0)return;const{isRenderingToTexture:z}=T,R=m.context,N=R.gl,U=m.style.projection,j=m.transform,Z=j.tileSize,X=v.paint.get("background-pattern");if(m.isPatternMissing(X))return;const q=!X&&C.a===1&&M===1&&m.opaquePassEnabledForLayer()?"opaque":"translucent";if(m.renderPass!==q)return;const Y=at.disabled,Q=m.getDepthModeForSublayer(0,q==="opaque"?Qe.ReadWrite:Qe.ReadOnly),H=m.colorModeForRenderPass(),te=m.useProgram(X?"backgroundPattern":"background"),de=w||wt(j,{tileSize:Z,terrain:m.style.map.terrain});X&&(R.activeTexture.set(N.TEXTURE0),m.imageManager.bind(m.context));const ue=v.getCrossfadeParameters();for(const ce of de){const he=j.getProjectionData({overscaledTileID:ce,applyGlobeMatrix:!z,applyTerrainMatrix:!0}),Ce=X?Gu(M,m,X,{tileID:ce,tileSize:Z},ue):Uu(M,C),Ie=m.style.map.terrain&&m.style.map.terrain.getTerrainData(ce),ge=U.getMeshFromTileID(R,ce.canonical,!1,!0,"raster");te.draw(R,N.TRIANGLES,Q,Y,H,ot.backCCW,Ce,Ie,he,v.id,ge.vertexBuffer,ge.indexBuffer,ge.segments)}})(t,0,o,l,p):c.cv(o)&&(function(m,_,v,w){const{isRenderingGlobe:T}=w,C=m.context,M=v.implementation,z=m.style.projection,R=m.transform,N=R.getProjectionDataForCustomLayer(T),U={farZ:R.farZ,nearZ:R.nearZ,fov:R.fov*Math.PI/180,modelViewProjectionMatrix:R.modelViewProjectionMatrix,projectionMatrix:R.projectionMatrix,shaderData:{variantName:z.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;
|
|
815
|
+
uniform mat4 u_projection_matrix;
|
|
816
|
+
${z.shaderPreludeCode.vertexSource}`,define:z.shaderDefine},defaultProjectionData:N},j=M.renderingMode?M.renderingMode:"2d";if(m.renderPass==="offscreen"){const Z=M.prerender;Z&&(m.setCustomLayerDefaults(),C.setColorMode(m.colorModeForRenderPass()),Z.call(M,C.gl,U),C.setDirty(),m.setBaseState())}else if(m.renderPass==="translucent"){m.setCustomLayerDefaults(),C.setColorMode(m.colorModeForRenderPass()),C.setStencilMode(at.disabled);const Z=j==="3d"?m.getDepthModeFor3D():m.getDepthModeForSublayer(0,Qe.ReadOnly);C.setDepthMode(Z),M.render(C.gl,U),C.setDirty(),m.setBaseState(),C.bindFramebuffer.set(null)}})(t,0,o,p))}saveTileTexture(t){const n=this._tileTextures[t.size[0]];n?n.push(t):this._tileTextures[t.size[0]]=[t]}getTileTexture(t){const n=this._tileTextures[t];return n&&n.length>0?n.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const n=this.imageManager.getPattern(t.from.toString()),o=this.imageManager.getPattern(t.to.toString());return!n||!o}useProgram(t,n,o=!1,l=[]){this.cache=this.cache||{};const p=!!this.style.map.terrain,m=this.style.projection,_=o?Pt.projectionMercator:m.shaderPreludeCode,v=o?Gi:m.shaderDefine,w=t+(n?n.cacheKey:"")+`/${o?Ri:m.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(p?"/terrain":"")+(l?`/${l.join("/")}`:"");return this.cache[w]||(this.cache[w]=new Vu(this.context,Pt[t],n,qu[t],this._showOverdrawInspector,p,_,v,l)),this.cache[w]}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 t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new c.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){var t,n;if(this._tileTextures){for(const o in this._tileTextures){const l=this._tileTextures[o];if(l)for(const p of l)p.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&&((t=this.tileExtentMesh.vertexBuffer)===null||t===void 0||t.destroy()),this.tileExtentMesh&&((n=this.tileExtentMesh.indexBuffer)===null||n===void 0||n.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(const o in this.cache){const l=this.cache[o];l&&l.program&&this.context.gl.deleteProgram(l.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){const{drawingBufferWidth:t,drawingBufferHeight:n}=this.context.gl;return this.width!==t||this.height!==n}}function dl(d,t){let n,o=!1,l=null,p=null;const m=()=>{l=null,o&&(d.apply(p,n),l=setTimeout(m,t),o=!1)};return(..._)=>(o=!0,p=this,n=_,l||m(),l)}class uo{constructor(t){this._getCurrentHash=()=>{const n=window.location.hash.replace("#","");if(this._hashName){let o;return n.split("&").map((l=>l.split("="))).forEach((l=>{l[0]===this._hashName&&(o=l)})),(o&&o[1]||"").split("/")}return n.split("/")},this._onHashChange=()=>{const n=this._getCurrentHash();if(!this._isValidHash(n))return!1;const o=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(n[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+n[2],+n[1]],zoom:+n[0],bearing:o,pitch:+(n[4]||0)}),!0},this._updateHashUnthrottled=()=>{const n=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,n)},this._removeHash=()=>{const n=this._getCurrentHash();if(n.length===0)return;const o=n.join("/");let l=o;l.split("&").length>0&&(l=l.split("&")[0]),this._hashName&&(l=`${this._hashName}=${o}`);let p=window.location.hash.replace(l,"");p.startsWith("#&")?p=p.slice(0,1)+p.slice(2):p==="#"&&(p="");let m=window.location.href.replace(/(#.+)?$/,p);m=m.replace("&&","&"),window.history.replaceState(window.history.state,null,m)},this._updateHash=dl(this._updateHashUnthrottled,300),this._hashName=t&&encodeURIComponent(t)}addTo(t){return this._map=t,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(t){const n=this._map.getCenter(),o=Math.round(100*this._map.getZoom())/100,l=Math.ceil((o*Math.LN2+Math.log(512/360/.5))/Math.LN10),p=Math.pow(10,l),m=Math.round(n.lng*p)/p,_=Math.round(n.lat*p)/p,v=this._map.getBearing(),w=this._map.getPitch();let T="";if(T+=t?`/${m}/${_}/${o}`:`${o}/${_}/${m}`,(v||w)&&(T+="/"+Math.round(10*v)/10),w&&(T+=`/${Math.round(w)}`),this._hashName){const C=this._hashName;let M=!1;const z=window.location.hash.slice(1).split("&").map((R=>{const N=R.split("=")[0];return N===C?(M=!0,`${N}=${T}`):R})).filter((R=>R));return M||z.push(`${C}=${T}`),`#${z.join("&")}`}return`#${T}`}_isValidHash(t){if(t.length<3||t.some(isNaN))return!1;try{new c.V(+t[2],+t[1])}catch{return!1}const n=+t[0],o=+(t[3]||0),l=+(t[4]||0);return n>=this._map.getMinZoom()&&n<=this._map.getMaxZoom()&&o>=-180&&o<=180&&l>=this._map.getMinPitch()&&l<=this._map.getMaxPitch()}}const vs={linearity:.3,easing:c.cw(0,0,.3,1)},ar=c.e({deceleration:2500,maxSpeed:1400},vs),gr=c.e({deceleration:20,maxSpeed:1400},vs),Oc=c.e({deceleration:1e3,maxSpeed:360},vs),_r=c.e({deceleration:1e3,maxSpeed:90},vs),Ju=c.e({deceleration:1e3,maxSpeed:360},vs);class Qu{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:He(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,n=He();for(;t.length>0&&n-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,roll:0,pan:new c.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:p}of this._inertiaBuffer)n.zoom+=p.zoomDelta||0,n.bearing+=p.bearingDelta||0,n.pitch+=p.pitchDelta||0,n.roll+=p.rollDelta||0,p.panDelta&&n.pan._add(p.panDelta),p.around&&(n.around=p.around),p.pinchAround&&(n.pinchAround=p.pinchAround);const o=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,l={};if(n.pan.mag()){const p=Cr(n.pan.mag(),o,c.e({},ar,t||{})),m=n.pan.mult(p.amount/n.pan.mag()),_=this._map.cameraHelper.handlePanInertia(m,this._map.transform);l.center=_.easingCenter,l.offset=_.easingOffset,ho(l,p)}if(n.zoom){const p=Cr(n.zoom,o,gr),m=c.cx(this._map.transform.zoom+p.amount,this._map.getZoomSnap(),p.amount);l.zoom=m,ho(l,p)}if(n.bearing){const p=Cr(n.bearing,o,Oc);l.bearing=this._map.transform.bearing+c.an(p.amount,-179,179),ho(l,p)}if(n.pitch){const p=Cr(n.pitch,o,_r);l.pitch=this._map.transform.pitch+p.amount,ho(l,p)}if(n.roll){const p=Cr(n.roll,o,Ju);l.roll=this._map.transform.roll+c.an(p.amount,-179,179),ho(l,p)}if(l.zoom||l.bearing){const p=n.pinchAround===void 0?n.around:n.pinchAround;l.around=p?this._map.unproject(p):this._map.getCenter()}return this.clear(),c.e(l,{noMoveStart:!0})}}function ho(d,t){(!d.duration||d.duration<t.duration)&&(d.duration=t.duration,d.easing=t.easing)}function Cr(d,t,n){const{maxSpeed:o,linearity:l,deceleration:p}=n,m=c.an(d*l/(t/1e3),-o,o),_=Math.abs(m)/(p*l);return{easing:n.easing,duration:1e3*_,amount:m*(_/2)}}class Hi extends c.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,o,l={}){o=o instanceof MouseEvent?o:new MouseEvent(t,o);const p=pe.mousePos(n.getCanvas(),o),m=n.unproject(p);super(t,c.e({point:p,lngLat:m,originalEvent:o},l)),this._defaultPrevented=!1,this.target=n}}class po extends c.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,o){const l=t==="touchend"?o.changedTouches:o.touches,p=pe.touchPos(n.getCanvasContainer(),l),m=p.map((v=>n.unproject(v))),_=p.reduce(((v,w,T,C)=>v.add(w.div(C.length))),new c.P(0,0));super(t,{points:p,point:_,lngLats:m,lngLat:n.unproject(_),originalEvent:o}),this._defaultPrevented=!1}}class Vc extends c.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,o){super(t,{originalEvent:o}),this._defaultPrevented=!1}}class eh{constructor(t,n){this._map=t,this._clickTolerance=n.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new Vc(t.type,this._map,t))}mousedown(t,n){return this._mousedownPos=n,this._firePreventable(new Hi(t.type,this._map,t))}mouseup(t){this._map.fire(new Hi(t.type,this._map,t))}click(t,n){this._mousedownPos&&this._mousedownPos.dist(n)>=this._clickTolerance||this._map.fire(new Hi(t.type,this._map,t))}dblclick(t){return this._firePreventable(new Hi(t.type,this._map,t))}mouseover(t){this._map.fire(new Hi(t.type,this._map,t))}mouseout(t){this._map.fire(new Hi(t.type,this._map,t))}touchstart(t){return this._firePreventable(new po(t.type,this._map,t))}touchmove(t){this._map.fire(new po(t.type,this._map,t))}touchend(t){this._map.fire(new po(t.type,this._map,t))}touchcancel(t){this._map.fire(new po(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Nc{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new Hi(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Hi("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new Hi(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Zr{constructor(t){this._map=t}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(t){return this.transform.screenPointToLocation(c.P.convert(t),this._map.terrain)}}class Ir{constructor(t,n){this._map=t,this._tr=new Zr(t),this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=n.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,n){this.isEnabled()&&t.shiftKey&&t.button===0&&(pe.disableDrag(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(t,n){if(!this._active)return;const o=n;if(this._lastPos.equals(o)||!this._box&&o.dist(this._startPos)<this._clickTolerance)return;const l=this._startPos;this._lastPos=o,this._box||(this._box=pe.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",t));const p=Math.min(l.x,o.x),m=Math.max(l.x,o.x),_=Math.min(l.y,o.y),v=Math.max(l.y,o.y);pe.setTransform(this._box,`translate(${p}px,${_}px)`),this._box.style.width=m-p+"px",this._box.style.height=v-_+"px"}mouseupWindow(t,n){if(!this._active||t.button!==0)return;const o=this._startPos,l=n;if(this.reset(),pe.suppressClick(),o.x!==l.x||o.y!==l.y)return this._map.fire(new c.l("boxzoomend",{originalEvent:t})),{cameraAnimation:p=>p.fitScreenCoordinates(o,l,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&t.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(pe.remove(this._box),this._box=null),pe.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,n){return this._map.fire(new c.l(t,{originalEvent:n}))}}function De(d,t){if(d.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${d.length}, points ${t.length}`);const n={};for(let o=0;o<d.length;o++)n[d[o].identifier]=t[o];return n}class jc{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,n,o){(this.centroid||o.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=t.timeStamp),o.length===this.numTouches&&(this.centroid=(function(l){const p=new c.P(0,0);for(const m of l)p._add(m);return p.div(l.length)})(n),this.touches=De(o,n)))}touchmove(t,n,o){if(this.aborted||!this.centroid)return;const l=De(o,n);for(const p in this.touches){const m=l[p];(!m||m.dist(this.touches[p])>30)&&(this.aborted=!0)}}touchend(t,n,o){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),o.length===0){const l=!this.aborted&&this.centroid;if(this.reset(),l)return l}}}class fo{constructor(t){this.singleTap=new jc(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,n,o){this.singleTap.touchstart(t,n,o)}touchmove(t,n,o){this.singleTap.touchmove(t,n,o)}touchend(t,n,o){const l=this.singleTap.touchend(t,n,o);if(l){const p=t.timeStamp-this.lastTime<500,m=!this.lastTap||this.lastTap.dist(l)<30;if(p&&m||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=l,this.count===this.numTaps)return this.reset(),l}}}class Uc{constructor(t){this._tr=new Zr(t),this._zoomIn=new fo({numTouches:1,numTaps:2}),this._zoomOut=new fo({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,n,o){this._zoomIn.touchstart(t,n,o),this._zoomOut.touchstart(t,n,o)}touchmove(t,n,o){this._zoomIn.touchmove(t,n,o),this._zoomOut.touchmove(t,n,o)}touchend(t,n,o){const l=this._zoomIn.touchend(t,n,o),p=this._zoomOut.touchend(t,n,o),m=this._tr;return l?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:c.cx(m.zoom+1,_.getZoomSnap()),around:m.unproject(l)},{originalEvent:t})}):p?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:c.cx(m.zoom-1,_.getZoomSnap()),around:m.unproject(p)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class $r{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset()}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t)}_move(...t){const n=this._moveFunction(...t);if(n.bearingDelta||n.pitchDelta||n.rollDelta||n.around||n.panDelta)return this._active=!0,n}dragStart(t,n){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=Array.isArray(n)?n[0]:n,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,n){if(!this.isEnabled())return;const o=this._lastPoint;if(!o)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);const l=Array.isArray(n)?n[0]:n;return!this._moved&&l.dist(o)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=l,this._move(o,l))}dragEnd(t){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(t)&&(this._moved&&pe.suppressClick(),this.reset(t))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}const mo=0,pl=2,th={[mo]:1,[pl]:2};class Un{constructor(t){this._correctEvent=t.checkCorrectEvent}startMove(t){const n=pe.mouseButton(t);this._eventButton=n}endMove(t){delete this._eventButton}isValidStartEvent(t){return this._correctEvent(t)}isValidMoveEvent(t){return!(function(n,o){const l=th[o];return n.buttons===void 0||(n.buttons&l)!==l})(t,this._eventButton)}isValidEndEvent(t){return pe.mouseButton(t)===this._eventButton}}class Gc{constructor(){this._firstTouch=void 0}_isOneFingerTouch(t){return t.targetTouches.length===1}_isSameTouchEvent(t){return t.targetTouches[0].identifier===this._firstTouch}startMove(t){this._firstTouch=t.targetTouches[0].identifier}endMove(t){delete this._firstTouch}isValidStartEvent(t){return this._isOneFingerTouch(t)}isValidMoveEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}isValidEndEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}}class fl{constructor(t=new Un({checkCorrectEvent:()=>!0}),n=new Gc){this.mouseMoveStateManager=t,this.oneFingerTouchMoveStateManager=n}_executeRelevantHandler(t,n,o){return t instanceof MouseEvent?n(t):typeof TouchEvent<"u"&&t instanceof TouchEvent?o(t):void 0}startMove(t){this._executeRelevantHandler(t,(n=>this.mouseMoveStateManager.startMove(n)),(n=>this.oneFingerTouchMoveStateManager.startMove(n)))}endMove(t){this._executeRelevantHandler(t,(n=>this.mouseMoveStateManager.endMove(n)),(n=>this.oneFingerTouchMoveStateManager.endMove(n)))}isValidStartEvent(t){return this._executeRelevantHandler(t,(n=>this.mouseMoveStateManager.isValidStartEvent(n)),(n=>this.oneFingerTouchMoveStateManager.isValidStartEvent(n)))}isValidMoveEvent(t){return this._executeRelevantHandler(t,(n=>this.mouseMoveStateManager.isValidMoveEvent(n)),(n=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(n)))}isValidEndEvent(t){return this._executeRelevantHandler(t,(n=>this.mouseMoveStateManager.isValidEndEvent(n)),(n=>this.oneFingerTouchMoveStateManager.isValidEndEvent(n)))}}const ha=d=>{d.mousedown=d.dragStart,d.mousemoveWindow=d.dragMove,d.mouseup=d.dragEnd,d.contextmenu=t=>{t.preventDefault()}};class qc{constructor(t,n){this._clickTolerance=t.clickTolerance||1,this._map=n,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new c.P(0,0)}_shouldBePrevented(t){return t<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(t,n,o){return this._calculateTransform(t,n,o)}touchmove(t,n,o){if(this._active){if(!this._shouldBePrevented(o.length))return t.preventDefault(),this._calculateTransform(t,n,o);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",t)}}touchend(t,n,o){this._calculateTransform(t,n,o),this._active&&this._shouldBePrevented(o.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,n,o){o.length>0&&(this._active=!0);const l=De(o,n),p=new c.P(0,0),m=new c.P(0,0);let _=0;for(const w in l){const T=l[w],C=this._touches[w];C&&(p._add(T),m._add(T.sub(C)),_++,l[w]=T)}if(this._touches=l,this._shouldBePrevented(_)||!m.mag())return;const v=m.div(_);return this._sum._add(v),this._sum.mag()<this._clickTolerance?void 0:{around:p.div(_),panDelta:v}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ml{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(t,n,o){this._firstTwoTouches||o.length<2||(this._firstTwoTouches=[o[0].identifier,o[1].identifier],this._start([n[0],n[1]]))}touchmove(t,n,o){if(!this._firstTwoTouches)return;t.preventDefault();const[l,p]=this._firstTwoTouches,m=da(o,n,l),_=da(o,n,p);if(!m||!_)return;const v=this._aroundCenter?null:m.add(_).div(2);return this._move([m,_],v,t)}touchend(t,n,o){if(!this._firstTwoTouches)return;const[l,p]=this._firstTwoTouches,m=da(o,n,l),_=da(o,n,p);m&&_||(this._active&&pe.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&t.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function da(d,t,n){for(let o=0;o<d.length;o++)if(d[o].identifier===n)return t[o]}function gl(d,t){return Math.log(d/t)/Math.LN2}class Zc extends ml{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,n){const o=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(gl(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:gl(this._distance,o),pinchAround:n}}}function _l(d,t){return 180*d.angleWith(t)/Math.PI}class $c extends ml{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,n,o){const l=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:_l(this._vector,l),pinchAround:n}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());const n=25/(Math.PI*this._minDiameter)*360,o=_l(t,this._startVector);return Math.abs(o)<n}}function yl(d){return Math.abs(d.y)>Math.abs(d.x)}class Hr extends ml{constructor(t){super(),this._currentTouchCount=0,this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,n,o){super.touchstart(t,n,o),this._currentTouchCount=o.length}_start(t){this._lastPoints=t,yl(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,n,o){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const l=t[0].sub(this._lastPoints[0]),p=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(l,p,o.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(l.y+p.y)/2*-.5}):void 0}gestureBeginsVertically(t,n,o){if(this._valid!==void 0)return this._valid;const l=t.mag()>=2,p=n.mag()>=2;if(!l&&!p)return;if(!l||!p)return this._firstMove===void 0&&(this._firstMove=o),o-this._firstMove<100&&void 0;const m=t.y>0==n.y>0;return yl(t)&&yl(n)&&m}}const vt={panStep:100,bearingStep:15,pitchStep:10};class Hc{constructor(t){this._tr=new Zr(t);const n=vt;this._panStep=n.panStep,this._bearingStep=n.bearingStep,this._pitchStep=n.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let n=0,o=0,l=0,p=0,m=0;switch(t.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:t.shiftKey?o=-1:(t.preventDefault(),p=-1);break;case 39:t.shiftKey?o=1:(t.preventDefault(),p=1);break;case 38:t.shiftKey?l=1:(t.preventDefault(),m=-1);break;case 40:t.shiftKey?l=-1:(t.preventDefault(),m=1);break;default:return}return this._rotationDisabled&&(o=0,l=0),{cameraAnimation:_=>{const v=this._tr;_.easeTo({duration:300,easeId:"keyboardHandler",easing:pa,zoom:n?c.cx(v.zoom+n*(t.shiftKey?2:1),_.getZoomSnap()):v.zoom,bearing:v.bearing+o*this._bearingStep,pitch:v.pitch+l*this._pitchStep,offset:[-p*this._panStep,-m*this._panStep],center:v.center},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function pa(d){return d*(2-d)}const go=4.000244140625,vl=1/450;class xl{constructor(t,n){this._onTimeout=o=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(o)},this._map=t,this._tr=new Zr(t),this._triggerRenderFrame=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=vl}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&t.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(t){return!!this._map.cooperativeGestures.isEnabled()&&!(t.ctrlKey||this._map.cooperativeGestures.isBypassed(t))}wheel(t){if(!this.isEnabled())return;if(this._shouldBePrevented(t))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",t);let n=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const o=He(),l=o-(this._lastWheelEventTime||0);this._lastWheelEventTime=o,n!==0&&n%go==0?this._type="wheel":n!==0&&Math.abs(n)<4?this._type="trackpad":l>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(l*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),t.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=t,this._delta-=n,this._active||this._start(t)),t.preventDefault()}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const n=pe.mousePos(this._map.getCanvas(),t),o=this._tr;this._aroundPoint=this._aroundCenter?o.transform.locationToScreenPoint(c.V.convert(o.center)):n,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const t=this._tr.transform;if(typeof this._lastExpectedZoom=="number"){const _=t.zoom-this._lastExpectedZoom;typeof this._startZoom=="number"&&(this._startZoom+=_),typeof this._targetZoom=="number"&&(this._targetZoom+=_)}if(this._delta!==0){const _=this._type==="wheel"&&Math.abs(this._delta)>go?this._wheelZoomRate:this._defaultZoomRate;let v=2/(1+Math.exp(-Math.abs(this._delta*_)));this._delta<0&&v!==0&&(v=1/v);const w=typeof this._targetZoom!="number"?t.scale:c.aq(this._targetZoom),T=t.applyConstrain(t.getCameraLngLat(),c.at(w*v)).zoom,C=this._map.getZoomSnap();if(this._type==="wheel"&&C>0){const M=c.cx(t.zoom,C);this._targetZoom=c.cx(T,C,T-M)}else this._targetZoom=T;this._type==="wheel"&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const n=typeof this._targetZoom!="number"?t.zoom:this._targetZoom,o=this._startZoom,l=this._easing;let p,m=!1;if(this._type==="wheel"&&o&&l){const _=He()-this._lastWheelEventTime,v=Math.min((_+5)/200,1),w=l(v);p=c.G.number(o,n,w),v<1?this._frameId||(this._frameId=!0):m=!0}else p=n,m=!0;return this._active=!0,m&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout}),200)),this._lastExpectedZoom=p,{noInertia:!0,needsRenderFrame:!m,zoomDelta:p-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let n=c.cz;if(this._prevEase){const o=this._prevEase,l=(He()-o.start)/o.duration,p=o.easing(l+.01)-o.easing(l),m=.27/Math.sqrt(p*p+1e-4)*.01,_=Math.sqrt(.0729-m*m);n=c.cw(m,_,.25,1)}return this._prevEase={start:He(),duration:t,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class bl{constructor(t,n){this._clickZoom=t,this._tapZoom=n}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 Wc{constructor(t){this._tr=new Zr(t),this.reset()}reset(){this._active=!1}dblclick(t,n){return t.preventDefault(),{cameraAnimation:o=>{o.easeTo({duration:300,zoom:c.cx(this._tr.zoom+(t.shiftKey?-1:1),o.getZoomSnap()),around:this._tr.unproject(n)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ih{constructor(){this._tap=new fo({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(t,n,o){if(!this._swipePoint)if(this._tapTime){const l=n[0],p=t.timeStamp-this._tapTime<500,m=this._tapPoint.dist(l)<30;p&&m?o.length>0&&(this._swipePoint=l,this._swipeTouch=o[0].identifier):this.reset()}else this._tap.touchstart(t,n,o)}touchmove(t,n,o){if(this._tapTime){if(this._swipePoint){if(o[0].identifier!==this._swipeTouch)return;const l=n[0],p=l.y-this._swipePoint.y;return this._swipePoint=l,t.preventDefault(),this._active=!0,{zoomDelta:p/128}}}else this._tap.touchmove(t,n,o)}touchend(t,n,o){if(this._tapTime)this._swipePoint&&o.length===0&&this.reset();else{const l=this._tap.touchend(t,n,o);l&&(this._tapTime=t.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 yr{constructor(t,n,o){this._el=t,this._mousePan=n,this._touchPan=o}enable(t){this._inertiaOptions=t||{},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 _o{constructor(t,n,o,l){this._pitchWithRotate=t.pitchWithRotate,this._rollEnabled=t.rollEnabled,this._mouseRotate=n,this._mousePitch=o,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 Be{constructor(t,n,o,l){this._el=t,this._touchZoom=n,this._touchRotate=o,this._tapDragZoom=l,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("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 Ge{constructor(t,n){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=t,this._options=n,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const t=this._map.getCanvasContainer();t.classList.add("maplibregl-cooperative-gestures"),this._container=pe.create("div","maplibregl-cooperative-gesture-screen",t);let n=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(n=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const o=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),l=document.createElement("div");l.className="maplibregl-desktop-message",l.textContent=n,this._container.appendChild(l);const p=document.createElement("div");p.className="maplibregl-mobile-message",p.textContent=o,this._container.appendChild(p),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(pe.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(t){return t[this._bypassKey]}notifyGestureBlocked(t,n){this._enabled&&(this._map.fire(new c.l("cooperativegestureprevented",{gestureType:t,originalEvent:n})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}}const _n=d=>d.zoom||d.drag||d.roll||d.pitch||d.rotate;class Xc extends c.l{}function xs(d){return d.panDelta&&d.panDelta.mag()||d.zoomDelta||d.bearingDelta||d.pitchDelta||d.rollDelta}class Mi{get _ownerDocument(){var t;return((t=this._el)===null||t===void 0?void 0:t.ownerDocument)||document}get _ownerWindow(){var t,n;return((n=(t=this._el)===null||t===void 0?void 0:t.ownerDocument)===null||n===void 0?void 0:n.defaultView)||window}constructor(t,n){this.handleWindowEvent=l=>{this.handleEvent(l,`${l.type}Window`)},this.handleEvent=(l,p)=>{if(l.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const m=l.type==="renderFrame"?void 0:l,_={needsRenderFrame:!1},v={},w={};for(const{handlerName:M,handler:z,allowed:R}of this._handlers){if(!z.isEnabled())continue;let N;if(this._blockedByActive(w,R,M))z.reset();else if(z[p||l.type]){if(c.cA(l,p||l.type)){const U=pe.mousePos(this._map.getCanvas(),l);N=z[p||l.type](l,U)}else if(c.cB(l,p||l.type)){const U=this._getMapTouches(l.touches),j=pe.touchPos(this._map.getCanvas(),U);N=z[p||l.type](l,j,U)}else c.cC(p||l.type)||(N=z[p||l.type](l));this.mergeHandlerResult(_,v,N,M,m),N&&N.needsRenderFrame&&this._triggerRenderFrame()}(N||z.isActive())&&(w[M]=z)}const T={};for(const M in this._previousActiveHandlers)w[M]||(T[M]=m);this._previousActiveHandlers=w,(Object.keys(T).length||xs(_))&&(this._changes.push([_,v,T]),this._triggerRenderFrame()),(Object.keys(w).length||xs(_))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:C}=_;C&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],C(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Qu(t),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n);const o=this._el;this._listeners=[[o,"touchstart",{passive:!0}],[o,"touchmove",{passive:!1}],[o,"touchend",void 0],[o,"touchcancel",void 0],[o,"mousedown",void 0],[o,"mousemove",void 0],[o,"mouseup",void 0],[this._ownerDocument,"mousemove",{capture:!0}],[this._ownerDocument,"mouseup",void 0],[o,"mouseover",void 0],[o,"mouseout",void 0],[o,"dblclick",void 0],[o,"click",void 0],[o,"keydown",{capture:!1}],[o,"keyup",void 0],[o,"wheel",{passive:!1}],[o,"contextmenu",void 0],[this._ownerWindow,"blur",void 0]];for(const[l,p,m]of this._listeners)pe.addEventListener(l,p,l===this._ownerDocument?this.handleWindowEvent:this.handleEvent,m)}destroy(){for(const[t,n,o]of this._listeners)pe.removeEventListener(t,n,t===this._ownerDocument?this.handleWindowEvent:this.handleEvent,o)}_addDefaultHandlers(t){const n=this._map,o=n.getCanvasContainer();this._add("mapEvent",new eh(n,t));const l=n.boxZoom=new Ir(n,t);this._add("boxZoom",l),t.interactive&&t.boxZoom&&l.enable();const p=n.cooperativeGestures=new Ge(n,t.cooperativeGestures);this._add("cooperativeGestures",p),t.cooperativeGestures&&p.enable();const m=new Uc(n),_=new Wc(n);n.doubleClickZoom=new bl(_,m),this._add("tapZoom",m),this._add("clickZoom",_),t.interactive&&t.doubleClickZoom&&n.doubleClickZoom.enable();const v=new ih;this._add("tapDragZoom",v);const w=n.touchPitch=new Hr(n);this._add("touchPitch",w),t.interactive&&t.touchPitch&&n.touchPitch.enable(t.touchPitch);const T=()=>n.project(n.getCenter()),C=(function({enable:q,clickTolerance:Y,aroundCenter:Q=!0,minPixelCenterThreshold:H=100,rotateDegreesPerPixelMoved:te=.8},de){const ue=new Un({checkCorrectEvent:ce=>pe.mouseButton(ce)===0&&ce.ctrlKey||pe.mouseButton(ce)===2&&!ce.ctrlKey});return new $r({clickTolerance:Y,move:(ce,he)=>{const Ce=de();if(Q&&Math.abs(Ce.y-ce.y)>H)return{bearingDelta:c.cy(new c.P(ce.x,he.y),he,Ce)};let Ie=(he.x-ce.x)*te;return Q&&he.y<Ce.y&&(Ie=-Ie),{bearingDelta:Ie}},moveStateManager:ue,enable:q,assignEvents:ha})})(t,T),M=(function({enable:q,clickTolerance:Y,pitchDegreesPerPixelMoved:Q=-.5}){const H=new Un({checkCorrectEvent:te=>pe.mouseButton(te)===0&&te.ctrlKey||pe.mouseButton(te)===2});return new $r({clickTolerance:Y,move:(te,de)=>({pitchDelta:(de.y-te.y)*Q}),moveStateManager:H,enable:q,assignEvents:ha})})(t),z=(function({enable:q,clickTolerance:Y,rollDegreesPerPixelMoved:Q=.3},H){const te=new Un({checkCorrectEvent:de=>pe.mouseButton(de)===2&&de.ctrlKey});return new $r({clickTolerance:Y,move:(de,ue)=>{const ce=H();let he=(ue.x-de.x)*Q;return ue.y<ce.y&&(he=-he),{rollDelta:he}},moveStateManager:te,enable:q,assignEvents:ha})})(t,T);n.dragRotate=new _o(t,C,M,z),this._add("mouseRotate",C,["mousePitch"]),this._add("mousePitch",M,["mouseRotate","mouseRoll"]),this._add("mouseRoll",z,["mousePitch"]),t.interactive&&t.dragRotate&&n.dragRotate.enable();const R=(function({enable:q,clickTolerance:Y}){const Q=new Un({checkCorrectEvent:H=>pe.mouseButton(H)===0&&!H.ctrlKey});return new $r({clickTolerance:Y,move:(H,te)=>({around:te,panDelta:te.sub(H)}),activateOnStart:!0,moveStateManager:Q,enable:q,assignEvents:ha})})(t),N=new qc(t,n);n.dragPan=new yr(o,R,N),this._add("mousePan",R),this._add("touchPan",N,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&n.dragPan.enable(t.dragPan);const U=new $c,j=new Zc;n.touchZoomRotate=new Be(o,j,U,v),this._add("touchRotate",U,["touchPan","touchZoom"]),this._add("touchZoom",j,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&n.touchZoomRotate.enable(t.touchZoomRotate),this._add("blockableMapEvent",new Nc(n));const Z=n.scrollZoom=new xl(n,(()=>this._triggerRenderFrame()));this._add("scrollZoom",Z,["mousePan"]),t.interactive&&t.scrollZoom&&n.scrollZoom.enable(t.scrollZoom);const X=n.keyboard=new Hc(n);this._add("keyboard",X),t.interactive&&t.keyboard&&n.keyboard.enable()}_add(t,n,o){this._handlers.push({handlerName:t,handler:n,allowed:o}),this._handlersById[t]=n}stop(t){if(!this._updatingCamera){for(const{handler:n}of this._handlers)n.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!_n(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,n,o){for(const l in t)if(l!==o&&(!n||n.indexOf(l)<0))return!0;return!1}_getMapTouches(t){const n=[];for(const o of t)this._el.contains(o.target)&&n.push(o);return n}mergeHandlerResult(t,n,o,l,p){if(!o)return;c.e(t,o);const m={handlerName:l,originalEvent:o.originalEvent||p};o.zoomDelta!==void 0&&(n.zoom=m),o.panDelta!==void 0&&(n.drag=m),o.rollDelta!==void 0&&(n.roll=m),o.pitchDelta!==void 0&&(n.pitch=m),o.bearingDelta!==void 0&&(n.rotate=m)}_applyChanges(){const t={},n={},o={};for(const[l,p,m]of this._changes)l.panDelta&&(t.panDelta=(t.panDelta||new c.P(0,0))._add(l.panDelta)),l.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+l.zoomDelta),l.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+l.bearingDelta),l.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+l.pitchDelta),l.rollDelta&&(t.rollDelta=(t.rollDelta||0)+l.rollDelta),l.around!==void 0&&(t.around=l.around),l.pinchAround!==void 0&&(t.pinchAround=l.pinchAround),l.noInertia&&(t.noInertia=l.noInertia),c.e(n,p),c.e(o,m);this._updateMapTransform(t,n,o),this._changes=[]}_updateMapTransform(t,n,o){const l=this._map,p=l._getTransformForUpdate(),m=l.terrain;if(!(xs(t)||m&&this._terrainMovement))return this._fireEvents(n,o,!0);l._stop(!0);let{panDelta:_,zoomDelta:v,bearingDelta:w,pitchDelta:T,rollDelta:C,around:M,pinchAround:z}=t;z!==void 0&&(M=z),M=M||l.transform.centerPoint,m&&!p.isPointOnMapSurface(M)&&(M=p.centerPoint);const R={panDelta:_,zoomDelta:v,rollDelta:C,pitchDelta:T,bearingDelta:w,around:M};this._map.cameraHelper.useGlobeControls&&!p.isPointOnMapSurface(M)&&(M=p.centerPoint);const N=M.distSqr(p.centerPoint)<.01?p.center:p.screenPointToLocation(_?M.sub(_):M);this._handleMapControls({terrain:m,tr:p,deltasForHelper:R,preZoomAroundLoc:N,combinedEventsInProgress:n,panDelta:_}),l._applyUpdatedTransform(p),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(n,o,!0)}_handleMapControls({terrain:t,tr:n,deltasForHelper:o,preZoomAroundLoc:l,combinedEventsInProgress:p,panDelta:m}){const _=this._map.cameraHelper;if(_.handleMapControlsRollPitchBearingZoom(o,n),t)return _.useGlobeControls?(this._terrainMovement||!p.drag&&!p.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void _.handleMapControlsPan(o,n,l)):this._terrainMovement||!p.drag&&!p.zoom?void(p.drag&&this._terrainMovement&&m?n.setCenter(n.screenPointToLocation(n.centerPoint.sub(m))):_.handleMapControlsPan(o,n,l)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void _.handleMapControlsPan(o,n,l));_.handleMapControlsPan(o,n,l)}_fireEvents(t,n,o){const l=_n(this._eventsInProgress),p=_n(t),m={};for(const C in t){const{originalEvent:M}=t[C];this._eventsInProgress[C]||(m[`${C}start`]=M),this._eventsInProgress[C]=t[C]}!l&&p&&this._fireEvent("movestart",p.originalEvent);for(const C in m)this._fireEvent(C,m[C]);p&&this._fireEvent("move",p.originalEvent);for(const C in t){const{originalEvent:M}=t[C];this._fireEvent(C,M)}const _={};let v;for(const C in this._eventsInProgress){const{handlerName:M,originalEvent:z}=this._eventsInProgress[C];this._handlersById[M].isActive()||(delete this._eventsInProgress[C],v=n[M]||z,_[`${C}end`]=v)}for(const C in _)this._fireEvent(C,_[C]);const w=_n(this._eventsInProgress),T=(l||p)&&!w;if(T&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const C=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&C.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(C)}if(o&&T){this._updatingCamera=!0;const C=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),M=z=>z!==0&&-this._bearingSnap<z&&z<this._bearingSnap;!C||!C.essential&&$t.prefersReducedMotion?(this._map.fire(new c.l("moveend",{originalEvent:v})),M(this._map.getBearing())&&this._map.resetNorth()):(M(C.bearing||this._map.getBearing())&&(C.bearing=0),C.freezeElevation=!0,this._map.easeTo(C,{originalEvent:v})),this._updatingCamera=!1}}_fireEvent(t,n){this._map.fire(new c.l(t,n?{originalEvent:n}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((t=>{delete this._frameId,this.handleEvent(new Xc("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class vr extends c.E{constructor(t,n,o){super(),this._renderFrameCallback=()=>{const l=Math.min((He()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(l)),l<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=o.bearingSnap,this._zoomSnap=o.zoomSnap,this.cameraHelper=n,this.on("moveend",(()=>{delete this._requestedCameraState}))}migrateProjection(t,n){t.apply(this.transform,!0),this.transform=t,this.cameraHelper=n}getCenter(){return new c.V(this.transform.center.lng,this.transform.center.lat)}setCenter(t,n){return this.jumpTo({center:t},n)}getCenterElevation(){return this.transform.elevation}setCenterElevation(t,n){return this.jumpTo({elevation:t},n),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(t){this._centerClampedToGround=t}panBy(t,n,o){return t=c.P.convert(t).mult(-1),this.panTo(this.transform.center,c.e({offset:t},n),o)}panTo(t,n,o){return this.easeTo(c.e({center:t},n),o)}getZoom(){return this.transform.zoom}setZoom(t,n){return this.jumpTo({zoom:t},n),this}zoomTo(t,n,o){return this.easeTo(c.e({zoom:t},n),o)}zoomIn(t,n){return this.zoomTo(c.cx(this.getZoom()+1,this._zoomSnap),t,n),this}zoomOut(t,n){return this.zoomTo(c.cx(this.getZoom()-1,this._zoomSnap),t,n),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(t,n){return t!=this.transform.fov&&(this.transform.setFov(t),this.fire(new c.l("movestart",n)).fire(new c.l("move",n)).fire(new c.l("moveend",n))),this}getBearing(){return this.transform.bearing}setZoomSnap(t){return this._zoomSnap=t,this}getZoomSnap(){return this._zoomSnap}setBearing(t,n){return this.jumpTo({bearing:t},n),this}getPadding(){return this.transform.padding}setPadding(t,n){return this.jumpTo({padding:t},n),this}rotateTo(t,n,o){return this.easeTo(c.e({bearing:t},n),o)}resetNorth(t,n){return this.rotateTo(0,c.e({duration:1e3},t),n),this}resetNorthPitch(t,n){return this.easeTo(c.e({bearing:0,pitch:0,roll:0,duration:1e3},t),n),this}snapToNorth(t,n){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,n):this}getPitch(){return this.transform.pitch}setPitch(t,n){return this.jumpTo({pitch:t},n),this}getRoll(){return this.transform.roll}setRoll(t,n){return this.jumpTo({roll:t},n),this}cameraForBounds(t,n){t=Mt.convert(t).adjustAntiMeridian();const o=n&&n.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),o,n)}_cameraForBoxAndBearing(t,n,o,l){const p={top:0,bottom:0,right:0,left:0};if(typeof(l=c.e({padding:p,offset:[0,0],maxZoom:this.transform.maxZoom},l)).padding=="number"){const w=l.padding;l.padding={top:w,bottom:w,right:w,left:w}}const m=c.e(p,l.padding);l.padding=m;const _=this.transform,v=new Mt(t,n);return this.cameraHelper.cameraForBoxAndBearing(l,m,v,o,_)}fitBounds(t,n,o){return this._fitInternal(this.cameraForBounds(t,n),n,o)}fitScreenCoordinates(t,n,o,l,p){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(c.P.convert(t)),this.transform.screenPointToLocation(c.P.convert(n)),o,l),l,p)}_fitInternal(t,n,o){return t?(delete(n=c.e(t,n)).padding,n.linear?this.easeTo(n,o):this.flyTo(n,o)):this}jumpTo(t,n){this.stop();const o=this._getTransformForUpdate();let l=!1,p=!1,m=!1;const _=o.zoom;this.cameraHelper.handleJumpToCenterZoom(o,t);const v=o.zoom!==_;return"elevation"in t&&o.elevation!==+t.elevation&&o.setElevation(+t.elevation),"bearing"in t&&o.bearing!==+t.bearing&&(l=!0,o.setBearing(+t.bearing)),"pitch"in t&&o.pitch!==+t.pitch&&(p=!0,o.setPitch(+t.pitch)),"roll"in t&&o.roll!==+t.roll&&(m=!0,o.setRoll(+t.roll)),t.padding==null||o.isPaddingEqual(t.padding)||o.setPadding(t.padding),this._applyUpdatedTransform(o),this.fire(new c.l("movestart",n)).fire(new c.l("move",n)),v&&this.fire(new c.l("zoomstart",n)).fire(new c.l("zoom",n)).fire(new c.l("zoomend",n)),l&&this.fire(new c.l("rotatestart",n)).fire(new c.l("rotate",n)).fire(new c.l("rotateend",n)),p&&this.fire(new c.l("pitchstart",n)).fire(new c.l("pitch",n)).fire(new c.l("pitchend",n)),m&&this.fire(new c.l("rollstart",n)).fire(new c.l("roll",n)).fire(new c.l("rollend",n)),this.fire(new c.l("moveend",n))}calculateCameraOptionsFromTo(t,n,o,l=0){const p=c.a9.fromLngLat(t,n),m=c.a9.fromLngLat(o,l),_=m.x-p.x,v=m.y-p.y,w=m.z-p.z,T=Math.hypot(_,v,w);if(T===0)throw new Error("Can't calculate camera options with same From and To");const C=Math.hypot(_,v),M=c.at(this.transform.cameraToCenterDistance/T/this.transform.tileSize),z=180*Math.atan2(_,-v)/Math.PI;let R=180*Math.acos(C/T)/Math.PI;return R=w<0?90-R:90+R,{center:m.toLngLat(),elevation:l,zoom:M,pitch:R,bearing:z}}calculateCameraOptionsFromCameraLngLatAltRotation(t,n,o,l,p){const m=this.transform.calculateCenterFromCameraLngLatAlt(t,n,o,l);return{center:m.center,elevation:m.elevation,zoom:m.zoom,bearing:o,pitch:l,roll:p}}easeTo(t,n){this._stop(!1,t.easeId),((t=c.e({offset:[0,0],duration:500,easing:c.cz},t)).animate===!1||!t.essential&&$t.prefersReducedMotion)&&(t.duration=0);const o=this._getTransformForUpdate(),l=this.getBearing(),p=o.pitch,m=o.roll,_="bearing"in t?this._normalizeBearing(t.bearing,l):l,v="pitch"in t?+t.pitch:p,w="roll"in t?this._normalizeBearing(t.roll,m):m,T="padding"in t?t.padding:o.padding,C=c.P.convert(t.offset);let M,z;t.around&&(M=c.V.convert(t.around),z=o.locationToScreenPoint(M));const R={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},N=this.cameraHelper.handleEaseTo(o,{bearing:_,pitch:v,roll:w,padding:T,around:M,aroundPoint:z,offsetAsPoint:C,offset:t.offset,zoom:t.zoom,center:t.center});return this._rotating=this._rotating||l!==_,this._pitching=this._pitching||v!==p,this._rolling=this._rolling||w!==m,this._padding=!o.isPaddingEqual(T),this._zooming=this._zooming||N.isZooming,this._easeId=t.easeId,this._prepareEase(n,t.noMoveStart,R),this.terrain&&this._prepareElevation(N.elevationCenter),this._ease((U=>{N.easeFunc(U),this.terrain&&!t.freezeElevation&&this._updateElevation(U),this._applyUpdatedTransform(o),this._fireMoveEvents(n)}),(U=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(n,U)}),t),this}_prepareEase(t,n,o={}){this._moving=!0,n||o.moving||this.fire(new c.l("movestart",t)),this._zooming&&!o.zooming&&this.fire(new c.l("zoomstart",t)),this._rotating&&!o.rotating&&this.fire(new c.l("rotatestart",t)),this._pitching&&!o.pitching&&this.fire(new c.l("pitchstart",t)),this._rolling&&!o.rolling&&this.fire(new c.l("rollstart",t))}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(t,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(t){this._elevationStart!==void 0&&this._elevationCenter!==void 0||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&n!==this._elevationTarget){const o=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(o-(n-(o*t+this._elevationStart))/(1-t)),this._elevationTarget=n}this.transform.setElevation(c.G.number(this._elevationStart,this._elevationTarget,t))}_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(t){if(!this.terrain&&t.elevation>=0&&t.pitch<=90)return{};const n=t.getCameraLngLat(),o=t.getCameraAltitude(),l=this.terrain?this.terrain.getElevationForLngLatZoom(n,t.zoom):0;if(o<l){const p=this.calculateCameraOptionsFromTo(n,l,t.center,t.elevation);return{pitch:p.pitch,zoom:p.zoom}}return{}}_applyUpdatedTransform(t){const n=[];if(n.push((l=>this._elevateCameraIfInsideTerrain(l))),this.transformCameraUpdate&&n.push((l=>this.transformCameraUpdate(l))),!n.length)return;const o=t.clone();for(const l of n){const p=o.clone(),{center:m,zoom:_,roll:v,pitch:w,bearing:T,elevation:C}=l(p);m&&p.setCenter(m),C!==void 0&&p.setElevation(C),_!==void 0&&p.setZoom(_),v!==void 0&&p.setRoll(v),w!==void 0&&p.setPitch(w),T!==void 0&&p.setBearing(T),o.apply(p,!1)}this.transform.apply(o,!1)}_fireMoveEvents(t){this.fire(new c.l("move",t)),this._zooming&&this.fire(new c.l("zoom",t)),this._rotating&&this.fire(new c.l("rotate",t)),this._pitching&&this.fire(new c.l("pitch",t)),this._rolling&&this.fire(new c.l("roll",t))}_afterEase(t,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;const o=this._zooming,l=this._rotating,p=this._pitching,m=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,o&&this.fire(new c.l("zoomend",t)),l&&this.fire(new c.l("rotateend",t)),p&&this.fire(new c.l("pitchend",t)),m&&this.fire(new c.l("rollend",t)),this.fire(new c.l("moveend",t))}flyTo(t,n){if(!t.essential&&$t.prefersReducedMotion){const he=c.U(t,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(he,n)}this.stop(),t=c.e({offset:[0,0],speed:1.2,curve:1.42,easing:c.cz},t);const o=this._getTransformForUpdate(),l=o.bearing,p=o.pitch,m=o.roll,_=o.padding,v="bearing"in t?this._normalizeBearing(t.bearing,l):l,w="pitch"in t?+t.pitch:p,T="roll"in t?this._normalizeBearing(t.roll,m):m,C="padding"in t?t.padding:o.padding,M=c.P.convert(t.offset);let z=o.centerPoint.add(M);const R=o.screenPointToLocation(z),N=this.cameraHelper.handleFlyTo(o,{bearing:v,pitch:w,roll:T,padding:C,locationAtOffset:R,offsetAsPoint:M,center:t.center,minZoom:t.minZoom,zoom:t.zoom});let U=t.curve;const j=Math.max(o.width,o.height),Z=j/N.scaleOfZoom,X=N.pixelPathLength;typeof N.scaleOfMinZoom=="number"&&(U=Math.sqrt(j/N.scaleOfMinZoom/X*2));const q=U*U;function Y(he){const Ce=(Z*Z-j*j+(he?-1:1)*q*q*X*X)/(2*(he?Z:j)*q*X);return Math.log(Math.sqrt(Ce*Ce+1)-Ce)}function Q(he){return(Math.exp(he)-Math.exp(-he))/2}function H(he){return(Math.exp(he)+Math.exp(-he))/2}const te=Y(!1);let de=function(he){return H(te)/H(te+U*he)},ue=function(he){return j*((H(te)*(Q(Ce=te+U*he)/H(Ce))-Q(te))/q)/X;var Ce},ce=(Y(!0)-te)/U;if(Math.abs(X)<2e-6||!isFinite(ce)){if(Math.abs(j-Z)<1e-6)return this.easeTo(t,n);const he=Z<j?-1:1;ce=Math.abs(Math.log(Z/j))/U,ue=()=>0,de=Ce=>Math.exp(he*U*Ce)}return t.duration="duration"in t?+t.duration:1e3*ce/("screenSpeed"in t?+t.screenSpeed/U:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=l!==v,this._pitching=w!==p,this._rolling=T!==m,this._padding=!o.isPaddingEqual(C),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(N.targetCenter),this._ease((he=>{const Ce=he*ce,Ie=1/de(Ce),ge=ue(Ce);this._rotating&&o.setBearing(c.G.number(l,v,he)),this._pitching&&o.setPitch(c.G.number(p,w,he)),this._rolling&&o.setRoll(c.G.number(m,T,he)),this._padding&&(o.interpolatePadding(_,C,he),z=o.centerPoint.add(M)),N.easeFunc(he,Ie,ge,z),this.terrain&&!t.freezeElevation&&this._updateElevation(he),this._applyUpdatedTransform(o),this._fireMoveEvents(n)}),(()=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(n)}),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,n){var o;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const l=this._onEaseEnd;delete this._onEaseEnd,l.call(this,n)}return t||(o=this.handlers)===null||o===void 0||o.stop(!1),this}_ease(t,n,o){o.animate===!1||o.duration===0?(t(1),n()):(this._easeStart=He(),this._easeOptions=o,this._onEaseFrame=t,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,n){t=c.W(t,-180,180);const o=Math.abs(t-n);return Math.abs(t-360-n)<o&&(t-=360),Math.abs(t+360-n)<o&&(t+=360),t}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLat(c.V.convert(t),this.transform):null}}const wl={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class Yc{constructor(t=wl){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=n=>{!n||n.sourceDataType!=="metadata"&&n.sourceDataType!=="visibility"&&n.dataType!=="style"&&n.type!=="terrain"||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?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=t}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options.compact,this._container=pe.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=pe.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=pe.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(){pe.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(t,n){const o=this._map._getUIString(`AttributionControl.${n}`);t.title=o,t.setAttribute("aria-label",o)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map((l=>typeof l!="string"?"":l))):typeof this.options.customAttribution=="string"&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const l=this._map.style.stylesheet;this.styleOwner=l.owner,this.styleId=l.id}const n=this._map.style.tileManagers;for(const l in n){const p=n[l];if(p.used||p.usedForTerrain){const m=p.getSource();m.attribution&&t.indexOf(m.attribution)<0&&t.push(m.attribution)}}t=t.filter((l=>String(l).trim())),t.sort(((l,p)=>l.length-p.length)),t=t.filter(((l,p)=>{for(let m=p+1;m<t.length;m++)if(t[m].indexOf(l)>=0)return!1;return!0}));const o=t.join(" | ");o!==this._attribHTML&&(this._attribHTML=o,t.length?(this._innerContainer.innerHTML=pe.sanitize(o),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Kc{constructor(t={}){this._updateCompact=()=>{const n=this._container.children;if(n.length){const o=n[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&o.classList.add("maplibregl-compact"):o.classList.remove("maplibregl-compact")}},this.options=t}getDefaultPosition(){return"bottom-left"}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=pe.create("div","maplibregl-ctrl");const n=pe.create("a","maplibregl-ctrl-logo");return n.target="_blank",n.rel="noopener nofollow",n.href="https://maplibre.org/",n.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),n.setAttribute("rel","noopener nofollow"),this._container.appendChild(n),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){pe.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class rh{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const n=++this._id;return this._queue.push({callback:t,id:n,cancelled:!1}),n}remove(t){const n=this._currentlyRunning,o=n?this._queue.concat(n):this._queue;for(const l of o)if(l.id===t)return void(l.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const n=this._currentlyRunning=this._queue;this._queue=[];for(const o of n)if(!o.cancelled&&(o.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var yo=c.aU([{name:"a_pos3d",type:"Int16",components:3}]);class kt extends c.E{constructor(t){super(),this._lastTilesetChange=He(),this.tileManager=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=t._source.tileSize*2**this.deltaZoom,t.usedForTerrain=!0,t.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null}getSource(){return this.tileManager._source}update(t,n){this.tileManager.update(t,n),this._renderableTilesKeys=[];const o={};for(const l of wt(t,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n,calculateTileZoom:this.tileManager._source.calculateTileZoom}))o[l.key]=!0,this._renderableTilesKeys.push(l.key),this._tiles[l.key]||(l.terrainRttPosMatrix32f=new Float64Array(16),c.c7(l.terrainRttPosMatrix32f,0,c.a5,c.a5,0,0,1),this._tiles[l.key]=new oe(l,this.tileSize),this._lastTilesetChange=He());for(const l in this._tiles)o[l]||delete this._tiles[l]}freeRtt(t){for(const n in this._tiles){const o=this._tiles[n];(!t||o.tileID.equals(t)||o.tileID.isChildOf(t)||t.isChildOf(o.tileID))&&(o.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((t=>this.getTileByID(t)))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t,n){return n?this._getTerrainCoordsForTileRanges(t,n):this._getTerrainCoordsForRegularTile(t)}_getTerrainCoordsForRegularTile(t){const n={};for(const o of this._renderableTilesKeys){const l=this._tiles[o].tileID,p=t.clone(),m=c.bk();if(l.canonical.equals(t.canonical))c.c7(m,0,c.a5,c.a5,0,0,1);else if(l.canonical.isChildOf(t.canonical)){const _=l.canonical.z-t.canonical.z,v=l.canonical.x-(l.canonical.x>>_<<_),w=l.canonical.y-(l.canonical.y>>_<<_),T=c.a5>>_;c.c7(m,0,T,T,0,0,1),c.O(m,m,[-v*T,-w*T,0])}else{if(!t.canonical.isChildOf(l.canonical))continue;{const _=t.canonical.z-l.canonical.z,v=t.canonical.x-(t.canonical.x>>_<<_),w=t.canonical.y-(t.canonical.y>>_<<_),T=c.a5>>_;c.c7(m,0,c.a5,c.a5,0,0,1),c.O(m,m,[v*T,w*T,0]),c.Q(m,m,[1/2**_,1/2**_,0])}}p.terrainRttPosMatrix32f=new Float32Array(m),n[o]=p}return n}_getTerrainCoordsForTileRanges(t,n){const o={};for(const l of this._renderableTilesKeys){const p=this._tiles[l].tileID;if(!this._isWithinTileRanges(p,n))continue;const m=t.clone(),_=c.bk();if(p.canonical.z===t.canonical.z){const v=t.canonical.x-p.canonical.x+t.wrap*(1<<t.canonical.z),w=t.canonical.y-p.canonical.y;c.c7(_,0,c.a5,c.a5,0,0,1),c.O(_,_,[v*c.a5,w*c.a5,0])}else if(p.canonical.z>t.canonical.z){const v=p.canonical.z-t.canonical.z,w=p.canonical.x-(p.canonical.x>>v<<v)+t.wrap*(1<<p.canonical.z),T=p.canonical.y-(p.canonical.y>>v<<v),C=t.canonical.x-(p.canonical.x>>v),M=t.canonical.y-(p.canonical.y>>v),z=c.a5>>v;c.c7(_,0,z,z,0,0,1),c.O(_,_,[-w*z+C*c.a5,-T*z+M*c.a5,0])}else{const v=t.canonical.z-p.canonical.z,w=t.canonical.x-(t.canonical.x>>v<<v)+t.wrap*(1<<t.canonical.z),T=t.canonical.y-(t.canonical.y>>v<<v),C=(t.canonical.x>>v)-p.canonical.x,M=(t.canonical.y>>v)-p.canonical.y,z=c.a5<<v;c.c7(_,0,z,z,0,0,1),c.O(_,_,[w*c.a5+C*z,T*c.a5+M*z,0])}m.terrainRttPosMatrix32f=new Float32Array(_),o[l]=m}return o}getSourceTile(t,n){const o=this.tileManager._source;let l=t.overscaledZ-this.deltaZoom;if(l>o.maxzoom&&(l=o.maxzoom),l<o.minzoom)return;this._sourceTileCache[t.key]||(this._sourceTileCache[t.key]=t.scaledTo(l).key);let p=this.findTileInCaches(this._sourceTileCache[t.key]);if(!p?.dem&&n)for(;l>=o.minzoom&&!p?.dem;)p=this.findTileInCaches(t.scaledTo(l--).key);return p}findTileInCaches(t){let n=this.tileManager.getTileByID(t);return n||(n=this.tileManager._outOfViewCache.getByKey(t),n)}anyTilesAfterTime(t=Date.now()){return this._lastTilesetChange>=t}_isWithinTileRanges(t,n){const o=n[t.canonical.z];return!!o&&(t.wrap>o.minWrap||t.wrap<o.maxWrap||t.canonical.x>=o.minTileXWrapped&&t.canonical.x<=o.maxTileXWrapped&&t.canonical.y>=o.minTileY&&t.canonical.y<=o.maxTileY)}}class Gt{constructor(t,n,o){this._meshCache={},this.painter=t,this.tileManager=new kt(n),this.options=o,this.exaggeration=typeof o.exaggeration=="number"?o.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,n,o,l=c.a5){var p;const m=t.normalizeCoordinates(n,o,l);if(!m)return 0;const _=this.getTerrainData(m.tileID),v=(p=_.tile)===null||p===void 0?void 0:p.dem;if(!v)return 0;const w=c.cD([],[m.x/l*c.a5,m.y/l*c.a5],_.u_terrain_matrix),T=[w[0]*v.dim,w[1]*v.dim],C=Math.floor(T[0]),M=Math.floor(T[1]),z=T[0]-C,R=T[1]-M;return v.get(C,M)*(1-z)*(1-R)+v.get(C+1,M)*z*(1-R)+v.get(C,M+1)*(1-z)*R+v.get(C+1,M+1)*z*R}getElevationForLngLatZoom(t,n){if(!c.cE(n,t.wrap()))return 0;const{tileID:o,mercatorX:l,mercatorY:p}=this._getOverscaledTileIDFromLngLatZoom(t,n);return this.getElevation(o,l%c.a5,p%c.a5,c.a5)}getElevationForLngLat(t,n){const o=wt(n,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this});let l=0;for(const p of o)p.canonical.z>l&&(l=Math.min(p.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(t,l)}getElevation(t,n,o,l=c.a5){return this.getDEMElevation(t,n,o,l)*this.exaggeration}getTerrainData(t){if(!this._emptyDemTexture){const l=this.painter.context,p=new c.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new c.T(l,p,l.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new c.T(l,new c.R({width:1,height:1}),l.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(l.gl.NEAREST,l.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=c.ar([])}const n=this.tileManager.getSourceTile(t,!0);if(n&&n.dem&&(!n.demTexture||n.needsTerrainPrepare)){const l=this.painter.context;n.demTexture=this.painter.getTileTexture(n.dem.stride),n.demTexture?n.demTexture.update(n.dem.getPixels(),{premultiply:!1}):n.demTexture=new c.T(l,n.dem.getPixels(),l.gl.RGBA,{premultiply:!1}),n.demTexture.bind(l.gl.NEAREST,l.gl.CLAMP_TO_EDGE),n.needsTerrainPrepare=!1}const o=n&&n.toString()+n.tileID.key+t.key;if(o&&!this._demMatrixCache[o]){const l=this.tileManager.getSource().maxzoom;let p=t.canonical.z-n.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=l?p=t.canonical.z-l:c.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const m=t.canonical.x-(t.canonical.x>>p<<p),_=t.canonical.y-(t.canonical.y>>p<<p),v=c.cF(new Float64Array(16),[1/(c.a5<<p),1/(c.a5<<p),0]);c.O(v,v,[m*c.a5,_*c.a5,0]),this._demMatrixCache[t.key]={matrix:v,coord:t}}return{u_depth:2,u_terrain:3,u_terrain_dim:n&&n.dem&&n.dem.dim||1,u_terrain_matrix:o?this._demMatrixCache[t.key].matrix:this._emptyDemMatrix,u_terrain_unpack:n&&n.dem&&n.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(n&&n.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:n}}getFramebuffer(t){const n=this.painter,o=n.width/devicePixelRatio,l=n.height/devicePixelRatio;return!this._fbo||this._fbo.width===o&&this._fbo.height===l||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new c.T(n.context,{width:o,height:l,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new c.T(n.context,{width:o,height:l,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=n.context.createFramebuffer(o,l,!0,!1),this._fbo.depthAttachment.set(n.context.createRenderbuffer(n.context.gl.DEPTH_COMPONENT16,o,l))),this._fbo.colorAttachment.set(t==="coords"?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const t=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const n=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let p=0,m=0;p<this._coordsTextureSize;p++)for(let _=0;_<this._coordsTextureSize;_++,m+=4)n[m+0]=255&_,n[m+1]=255&p,n[m+2]=_>>8<<4|p>>8,n[m+3]=0;const o=new c.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),l=new c.T(t,o,t.gl.RGBA,{premultiply:!1});return l.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=l,l}pointCoordinate(t){this.painter.maybeDrawDepthAndCoords(!0);const n=new Uint8Array(4),o=this.painter.context,l=o.gl,p=Math.round(t.x*this.painter.pixelRatio/devicePixelRatio),m=Math.round(t.y*this.painter.pixelRatio/devicePixelRatio),_=Math.round(this.painter.height/devicePixelRatio);o.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),l.readPixels(p,_-m-1,1,1,l.RGBA,l.UNSIGNED_BYTE,n),o.bindFramebuffer.set(null);const v=n[0]+(n[2]>>4<<8),w=n[1]+((15&n[2])<<8),T=this.coordsIndex[255-n[3]],C=T&&this.tileManager.getTileByID(T);if(!C)return null;const M=this._coordsTextureSize,z=(1<<C.tileID.canonical.z)*M;return new c.a9((C.tileID.canonical.x*M+v)/z+C.tileID.wrap,(C.tileID.canonical.y*M+w)/z,this.getElevation(C.tileID,v,w,M))}depthAtPoint(t){const n=new Uint8Array(4),o=this.painter.context,l=o.gl;return o.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),l.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,l.RGBA,l.UNSIGNED_BYTE,n),o.bindFramebuffer.set(null),(n[0]/16777216+n[1]/65536+n[2]/256+n[3])/256}getTerrainMesh(t){var n;const o=((n=this.painter.style.projection)===null||n===void 0?void 0:n.transitionState)>0,l=o&&t.canonical.y===0,p=o&&t.canonical.y===(1<<t.canonical.z)-1,m=`m_${l?"n":""}_${p?"s":""}`;if(this._meshCache[m])return this._meshCache[m];const _=this.painter.context,v=new c.cG,w=new c.aY,T=this.meshSize,C=c.a5/T,M=T*T;for(let H=0;H<=T;H++)for(let te=0;te<=T;te++)v.emplaceBack(te*C,H*C,0);for(let H=0;H<M;H+=T+1)for(let te=0;te<T;te++)w.emplaceBack(te+H,T+te+H+1,T+te+H+2),w.emplaceBack(te+H,T+te+H+2,te+H+1);const z=v.length,R=z+(T+1),N=(T+1)*T,U=l?c.br:0,j=l?0:1,Z=p?c.bs:c.a5,X=p?0:1;for(let H=0;H<=T;H++)v.emplaceBack(H*C,U,j);for(let H=0;H<=T;H++)v.emplaceBack(H*C,Z,X);for(let H=0;H<T;H++)w.emplaceBack(N+H,R+H,R+H+1),w.emplaceBack(N+H,R+H+1,N+H+1),w.emplaceBack(0+H,z+H+1,z+H),w.emplaceBack(0+H,0+H+1,z+H+1);const q=v.length,Y=q+2*(T+1);for(const H of[0,1])for(let te=0;te<=T;te++)for(const de of[0,1])v.emplaceBack(H*c.a5,te*C,de);for(let H=0;H<2*T;H+=2)w.emplaceBack(q+H,q+H+1,q+H+3),w.emplaceBack(q+H,q+H+3,q+H+2),w.emplaceBack(Y+H,Y+H+3,Y+H+1),w.emplaceBack(Y+H,Y+H+2,Y+H+3);const Q=new cs(_.createVertexBuffer(v,yo.members),_.createIndexBuffer(w),c.aX.simpleSegment(0,0,v.length,w.length));return this._meshCache[m]=Q,Q}getMeshFrameDelta(t){return 2*Math.PI*c.bE/Math.pow(2,Math.max(t,0))/5}getMinTileElevationForLngLatZoom(t,n){var o;if(!c.cE(n,t.wrap()))return 0;const{tileID:l}=this._getOverscaledTileIDFromLngLatZoom(t,n);return(o=this.getMinMaxElevation(l).minElevation)!==null&&o!==void 0?o:0}getMinMaxElevation(t){const n=this.getTerrainData(t).tile,o={minElevation:null,maxElevation:null};return n&&n.dem&&(o.minElevation=n.dem.min*this.exaggeration,o.maxElevation=n.dem.max*this.exaggeration),o}_getOverscaledTileIDFromLngLatZoom(t,n){const o=c.a9.fromLngLat(t.wrap()),l=(1<<n)*c.a5,p=o.x*l,m=o.y*l,_=Math.floor(p/c.a5),v=Math.floor(m/c.a5);return{tileID:new c.a2(n,0,n,_,v),mercatorX:p,mercatorY:m}}}class Jc{constructor(t,n,o){this._context=t,this._size=n,this._tileSize=o,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const t of this._objects)t.texture.destroy(),t.fbo.destroy()}_createObject(t){const n=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),o=new c.T(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return o.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),n.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),n.colorAttachment.set(o.texture),{id:t,fbo:n,texture:o,stamp:-1,inUse:!1}}getObjectForId(t){return this._objects[t]}useObject(t){t.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter((n=>t.id!==n)),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(const n of this._recentlyUsed)if(!this._objects[n].inUse)return this._objects[n];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const t=this._createObject(this._objects.length);return this._objects.push(t),t}freeObject(t){t.inUse=!1}freeAllObjects(){for(const t of this._objects)this.freeObject(t)}isFull(){return!(this._objects.length<this._size)&&this._objects.some((t=>!t.inUse))===!1}}const Er={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class fa{constructor(t,n){this.painter=t,this.terrain=n,this.pool=new Jc(t.context,30,n.tileManager.tileSize*n.qualityFactor)}destruct(){this.pool.destruct()}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,n){var o,l;this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=t._order.filter((p=>!t._layers[p].isHidden(n))),this._coordsAscending={};for(const p in t.tileManagers){this._coordsAscending[p]={};const m=t.tileManagers[p].getVisibleCoordinates(),_=t.tileManagers[p].getSource(),v=_ instanceof Br?_.terrainTileRanges:null;for(const w of m){const T=this.terrain.tileManager.getTerrainCoords(w,v);for(const C in T)this._coordsAscending[p][C]||(this._coordsAscending[p][C]=[]),this._coordsAscending[p][C].push(T[C])}}this._rttFingerprints={};for(const p of t._order){const m=t._layers[p],_=m.source;if(Er[m.type]&&!this._rttFingerprints[_]){this._rttFingerprints[_]={};const v=(l=(o=t.tileManagers[_])===null||o===void 0?void 0:o.getState().revision)!==null&&l!==void 0?l:0;for(const w in this._coordsAscending[_])this._rttFingerprints[_][w]=`${this._coordsAscending[_][w].map((T=>T.key)).sort().join()}#${v}`}}for(const p of this._renderableTiles)for(const m in this._rttFingerprints){const _=this._rttFingerprints[m][p.tileID.key];_&&_!==p.rttFingerprint[m]&&(p.rtt=[])}}renderLayer(t,n){if(t.isHidden(this.painter.transform.zoom))return!1;const o=Object.assign(Object.assign({},n),{isRenderingToTexture:!0}),l=t.type,p=this.painter,m=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(Er[l]&&(this._prevType&&Er[this._prevType]||this._stacks.push([]),this._prevType=l,this._stacks[this._stacks.length-1].push(t.id),!m))return!0;if(Er[this._prevType]||Er[l]&&m){this._prevType=l;const _=this._stacks.length-1,v=this._stacks[_]||[];for(const w of this._renderableTiles){if(this.pool.isFull()&&(ul(this.painter,this.terrain,this._rttTiles,o),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(w),w.rtt[_]){const C=this.pool.getObjectForId(w.rtt[_].id);if(C.stamp===w.rtt[_].stamp){this.pool.useObject(C);continue}}const T=this.pool.getOrCreateFreeObject();this.pool.useObject(T),this.pool.stampObject(T),w.rtt[_]={id:T.id,stamp:T.stamp},p.context.bindFramebuffer.set(T.fbo.framebuffer),p.context.clear({color:c.bp.transparent,stencil:0}),p.currentStencilSource=void 0;for(let C=0;C<v.length;C++){const M=p.style._layers[v[C]],z=M.source?this._coordsAscending[M.source][w.tileID.key]:[w.tileID];p.context.viewport.set([0,0,T.fbo.width,T.fbo.height]),p._renderTileClippingMasks(M,z,!0),p.renderLayer(p,p.style.tileManagers[M.source],M,z,o),M.source&&(w.rttFingerprint[M.source]=this._rttFingerprints[M.source][w.tileID.key])}}return ul(this.painter,this.terrain,this._rttTiles,o),this._rttTiles=[],this.pool.freeAllObjects(),Er[l]}return!1}}const Tl={"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":"Drag to rotate map, click to reset 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 \u2318 + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},Sl=Te,ma={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:wl,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:c.c.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,anisotropicFilterPitch:20},vo={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};class Pl{constructor(t,n,o=!1){this.mousedown=p=>{this.startMove(p,pe.mousePos(this.element,p)),pe.addEventListener(window,"mousemove",this.mousemove),pe.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=p=>{this.move(p,pe.mousePos(this.element,p))},this.mouseup=p=>{this._rotatePitchHandler.dragEnd(p),this.offTemp()},this.touchstart=p=>{p.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=pe.touchPos(this.element,p.targetTouches)[0],this.startMove(p,this._startPos),pe.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),pe.addEventListener(window,"touchend",this.touchend))},this.touchmove=p=>{p.targetTouches.length!==1?this.reset():(this._lastPos=pe.touchPos(this.element,p.targetTouches)[0],this.move(p,this._lastPos))},this.touchend=p=>{p.targetTouches.length===0&&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=n;const l=new fl;this._rotatePitchHandler=new $r({clickTolerance:3,move:(p,m)=>{const _=n.getBoundingClientRect(),v=new c.P((_.bottom-_.top)/2,(_.right-_.left)/2);return{bearingDelta:c.cy(new c.P(p.x,m.y),m,v),pitchDelta:o?-.5*(m.y-p.y):void 0}},moveStateManager:l,enable:!0,assignEvents:()=>{}}),this.map=t,pe.addEventListener(n,"mousedown",this.mousedown),pe.addEventListener(n,"touchstart",this.touchstart,{passive:!1}),pe.addEventListener(n,"touchcancel",this.reset)}startMove(t,n){this._rotatePitchHandler.dragStart(t,n),pe.disableDrag()}move(t,n){const o=this.map,{bearingDelta:l,pitchDelta:p}=this._rotatePitchHandler.dragMove(t,n)||{};l&&o.setBearing(o.getBearing()+l),p&&o.setPitch(o.getPitch()+p)}off(){const t=this.element;pe.removeEventListener(t,"mousedown",this.mousedown),pe.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),pe.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),pe.removeEventListener(window,"touchend",this.touchend),pe.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){pe.enableDrag(),pe.removeEventListener(window,"mousemove",this.mousemove),pe.removeEventListener(window,"mouseup",this.mouseup),pe.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),pe.removeEventListener(window,"touchend",this.touchend)}}let Wr;function ga(d,t,n,o=!1){if(o||!n.getCoveringTilesDetailsProvider().allowWorldCopies())return d?.wrap();const l=new c.V(d.lng,d.lat);if(d=new c.V(d.lng,d.lat),t){const p=new c.V(d.lng-360,d.lat),m=new c.V(d.lng+360,d.lat),_=n.locationToScreenPoint(d).distSqr(t);n.locationToScreenPoint(p).distSqr(t)<_?d=p:n.locationToScreenPoint(m).distSqr(t)<_&&(d=m)}for(;Math.abs(d.lng-n.center.lng)>180;){const p=n.locationToScreenPoint(d);if(p.x>=0&&p.y>=0&&p.x<=n.width&&p.y<=n.height)break;d.lng>n.center.lng?d.lng-=360:d.lng+=360}return d.lng!==l.lng&&n.isPointOnMapSurface(n.locationToScreenPoint(d))?d:l}const xo={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 _a(d,t,n){const o=d.classList;for(const l in xo)o.remove(`maplibregl-${n}-anchor-${l}`);o.add(`maplibregl-${n}-anchor-${t}`)}class bo extends c.E{constructor(t){if(super(),this._onClick=n=>{this.fire(new c.l("click",{originalEvent:n}))},this._onKeyPress=n=>{const o=n.code,l=n.charCode||n.keyCode;o!=="Space"&&o!=="Enter"&&l!==32&&l!==13||this.togglePopup()},this._onMapClick=n=>{const o=n.originalEvent.target,l=this._element;this._popup&&(o===l||l.contains(o))&&this.togglePopup()},this._update=n=>{if(!this._map)return;const o=this._map.loaded()&&!this._map.isMoving();(n?.type==="terrain"||n?.type==="render"&&!o)&&this._map.once("render",this._update),this._lngLat=ga(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 l="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?l=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(l=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let p="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?p="rotateX(0deg)":this._pitchAlignment==="map"&&(p=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||n&&n.type!=="moveend"||(this._pos=this._pos.round()),pe.setTransform(this._element,`${xo[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${p} ${l}`),$t.frameAsync(new AbortController,this._map._ownerWindow).then((()=>{this._updateOpacity(n&&n.type==="moveend")})).catch((()=>{}))},this._onMove=n=>{if(!this._isDragging){const o=this._clickTolerance||this._map._clickTolerance;this._isDragging=n.point.dist(this._pointerdownPos)>=o}this._isDragging&&(this._pos=n.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new c.l("dragstart"))),this.fire(new c.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),this._state==="active"&&this.fire(new c.l("dragend")),this._state="inactive"},this._addDragHandler=n=>{this._element.contains(n.originalEvent.target)&&(n.preventDefault(),this._positionDelta=n.point.sub(this._pos).add(this._offset),this._pointerdownPos=n.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=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._subpixelPositioning=t&&t.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment!=="auto"?t.pitchAlignment:this._rotationAlignment,this.setOpacity(t?.opacity,t?.opacityWhenCovered),t&&t.element)this._element=t.element,this._offset=c.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=pe.create("div");const n=pe.createNS("http://www.w3.org/2000/svg","svg"),o=41,l=27;n.setAttributeNS(null,"display","block"),n.setAttributeNS(null,"height",`${o}px`),n.setAttributeNS(null,"width",`${l}px`),n.setAttributeNS(null,"viewBox",`0 0 ${l} ${o}`);const p=pe.createNS("http://www.w3.org/2000/svg","g");p.setAttributeNS(null,"stroke","none"),p.setAttributeNS(null,"stroke-width","1"),p.setAttributeNS(null,"fill","none"),p.setAttributeNS(null,"fill-rule","evenodd");const m=pe.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"fill-rule","nonzero");const _=pe.createNS("http://www.w3.org/2000/svg","g");_.setAttributeNS(null,"transform","translate(3.0, 29.0)"),_.setAttributeNS(null,"fill","#000000");const v=[{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 j of v){const Z=pe.createNS("http://www.w3.org/2000/svg","ellipse");Z.setAttributeNS(null,"opacity","0.04"),Z.setAttributeNS(null,"cx","10.5"),Z.setAttributeNS(null,"cy","5.80029008"),Z.setAttributeNS(null,"rx",j.rx),Z.setAttributeNS(null,"ry",j.ry),_.appendChild(Z)}const w=pe.createNS("http://www.w3.org/2000/svg","g");w.setAttributeNS(null,"fill",this._color);const T=pe.createNS("http://www.w3.org/2000/svg","path");T.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"),w.appendChild(T);const C=pe.createNS("http://www.w3.org/2000/svg","g");C.setAttributeNS(null,"opacity","0.25"),C.setAttributeNS(null,"fill","#000000");const M=pe.createNS("http://www.w3.org/2000/svg","path");M.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"),C.appendChild(M);const z=pe.createNS("http://www.w3.org/2000/svg","g");z.setAttributeNS(null,"transform","translate(6.0, 7.0)"),z.setAttributeNS(null,"fill","#FFFFFF");const R=pe.createNS("http://www.w3.org/2000/svg","g");R.setAttributeNS(null,"transform","translate(8.0, 8.0)");const N=pe.createNS("http://www.w3.org/2000/svg","circle");N.setAttributeNS(null,"fill","#000000"),N.setAttributeNS(null,"opacity","0.25"),N.setAttributeNS(null,"cx","5.5"),N.setAttributeNS(null,"cy","5.5"),N.setAttributeNS(null,"r","5.4999962");const U=pe.createNS("http://www.w3.org/2000/svg","circle");U.setAttributeNS(null,"fill","#FFFFFF"),U.setAttributeNS(null,"cx","5.5"),U.setAttributeNS(null,"cy","5.5"),U.setAttributeNS(null,"r","5.4999962"),R.appendChild(N),R.appendChild(U),m.appendChild(_),m.appendChild(w),m.appendChild(C),m.appendChild(z),m.appendChild(R),n.appendChild(m),n.setAttributeNS(null,"height",o*this._scale+"px"),n.setAttributeNS(null,"width",l*this._scale+"px"),this._element.appendChild(n),this._offset=c.P.convert(t&&t.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(n=>{n.preventDefault()})),this._element.addEventListener("mousedown",(n=>{n.preventDefault()})),_a(this._element,this._anchor,"marker"),this._element.addEventListener("click",this._onClick),t&&t.className)for(const n of t.className.split(" "))this._element.classList.add(n);this._popup=null}addTo(t){return this.remove(),this._map=t,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",t._getUIString("Marker.Title")),this._element.hasAttribute("role")||this._element.setAttribute("role","button"),t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),t.on("terrain",this._update),t.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),pe.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=c.V.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){const l=Math.abs(13.5)/Math.SQRT2;t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[l,-1*(38.1-13.5+l)],"bottom-right":[-l,-1*(38.1-13.5+l)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=t,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(t){return this._subpixelPositioning=t,this}getPopup(){return this._popup}togglePopup(){const t=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:t?(t.isOpen()?t.remove():(t.setLngLat(this._lngLat),t.addTo(this._map)),this):this}_updateOpacity(t=!1){var n,o;const l=(n=this._map)===null||n===void 0?void 0:n.terrain,p=this._map.transform.isLocationOccluded(this._lngLat);if(!l||p){const z=p?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==z&&(this._element.style.opacity=z))}if(t)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null}),100)}const m=this._map,_=m.terrain.depthAtPoint(this._pos),v=m.terrain.getElevationForLngLat(this._lngLat,m.transform);if(m.transform.lngLatToCameraDepth(this._lngLat,v)-_<.006)return void(this._element.style.opacity=this._opacity);const w=-this._offset.y/m.transform.pixelsPerMeter,T=Math.sin(m.getPitch()*Math.PI/180)*w,C=m.terrain.depthAtPoint(new c.P(this._pos.x,this._pos.y-this._offset.y)),M=m.transform.lngLatToCameraDepth(this._lngLat,v+T)-C>.006;!((o=this._popup)===null||o===void 0)&&o.isOpen()&&M&&this._popup.remove(),this._element.style.opacity=M?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(t){return this._offset=c.P.convert(t),this._update(),this}addClassName(t){this._element.classList.add(t)}removeClassName(t){this._element.classList.remove(t)}toggleClassName(t){return this._element.classList.toggle(t)}setDraggable(t){return this._draggable=!!t,this._map&&(t?(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(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&t!=="auto"?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(t,n){return(this._opacity===void 0||t===void 0&&n===void 0)&&(this._opacity="1",this._opacityWhenCovered="0.2"),t!==void 0&&(this._opacity=t),n!==void 0&&(this._opacityWhenCovered=n),this._map&&this._updateOpacity(!0),this}}const Ml={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let bs=0,Gn=!1;const ya={maxWidth:100,unit:"metric"};function va(d,t,n){const o=n&&n.maxWidth||100,l=d._container.clientHeight/2,p=d._container.clientWidth/2,m=d.unproject([p-o/2,l]),_=d.unproject([p+o/2,l]),v=Math.round(d.project(_).x-d.project(m).x),w=Math.min(o,v,d._container.clientWidth),T=m.distanceTo(_);if(n&&n.unit==="imperial"){const C=3.2808*T;C>5280?qn(t,w,C/5280,d._getUIString("ScaleControl.Miles")):qn(t,w,C,d._getUIString("ScaleControl.Feet"))}else n&&n.unit==="nautical"?qn(t,w,T/1852,d._getUIString("ScaleControl.NauticalMiles")):T>=1e3?qn(t,w,T/1e3,d._getUIString("ScaleControl.Kilometers")):qn(t,w,T,d._getUIString("ScaleControl.Meters"))}function qn(d,t,n,o){const l=(function(p){const m=Math.pow(10,`${Math.floor(p)}`.length-1);let _=p/m;return _=_>=10?10:_>=5?5:_>=3?3:_>=2?2:_>=1?1:(function(v){const w=Math.pow(10,Math.ceil(-Math.log(v)/Math.LN10));return Math.round(v*w)/w})(_),m*_})(n);d.style.width=t*(l/n)+"px",d.innerHTML=`${l} ${o}`}const xa={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},Cl=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function ba(d){if(d){if(typeof d=="number"){const t=Math.round(Math.abs(d)/Math.SQRT2);return{center:new c.P(0,0),top:new c.P(0,d),"top-left":new c.P(t,t),"top-right":new c.P(-t,t),bottom:new c.P(0,-d),"bottom-left":new c.P(t,-t),"bottom-right":new c.P(-t,-t),left:new c.P(d,0),right:new c.P(-d,0)}}if(d instanceof c.P||Array.isArray(d)){const t=c.P.convert(d);return{center:t,top:t,"top-left":t,"top-right":t,bottom:t,"bottom-left":t,"bottom-right":t,left:t,right:t}}return{center:c.P.convert(d.center||[0,0]),top:c.P.convert(d.top||[0,0]),"top-left":c.P.convert(d["top-left"]||[0,0]),"top-right":c.P.convert(d["top-right"]||[0,0]),bottom:c.P.convert(d.bottom||[0,0]),"bottom-left":c.P.convert(d["bottom-left"]||[0,0]),"bottom-right":c.P.convert(d["bottom-right"]||[0,0]),left:c.P.convert(d.left||[0,0]),right:c.P.convert(d.right||[0,0])}}return ba(new c.P(0,0))}const Il=Te;D.AJAXError=c.cJ,D.EXTENT=c.a5,D.Event=c.l,D.Evented=c.E,D.LngLat=c.V,D.MercatorCoordinate=c.a9,D.Point=c.P,D.addProtocol=c.cK,D.config=c.c,D.removeProtocol=c.cL,D.AttributionControl=Yc,D.BoxZoomHandler=Ir,D.CanvasSource=ts,D.CooperativeGesturesHandler=Ge,D.DoubleClickZoomHandler=bl,D.DragPanHandler=yr,D.DragRotateHandler=_o,D.EdgeInsets=Nr,D.FullscreenControl=class extends c.E{constructor(d={}){var t;super(),this._onFullscreenChange=()=>{var n;let o=window.document.fullscreenElement||window.document.webkitFullscreenElement;for(;!((n=o?.shadowRoot)===null||n===void 0)&&n.fullscreenElement;)o=o.shadowRoot.fullscreenElement;o===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,this._pseudo=(t=d.pseudo)!==null&&t!==void 0&&t,d&&d.container&&(d.container instanceof HTMLElement?this._container=d.container:c.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(d){return this._map=d,this._container||(this._container=this._map.getContainer()),this._controlContainer=pe.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){pe.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const d=this._fullscreenButton=pe.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);pe.create("span","maplibregl-ctrl-icon",d).setAttribute("aria-hidden","true"),d.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const d=this._getTitle();this._fullscreenButton.setAttribute("aria-label",d),this._fullscreenButton.title=d}_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 c.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new c.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){this._pseudo?this._togglePseudoFullScreen():window.document.exitFullscreen?window.document.exitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._pseudo?this._togglePseudoFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},D.GeoJSONSource=Fr,D.GeolocateControl=class extends c.E{constructor(d){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new c.l("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("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&&this._watchState!=="OFF"&&this._updateMarker(t),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new c.l("geolocate",t)),this._finish()}},this._updateCamera=t=>{const n=new c.V(t.coords.longitude,t.coords.latitude),o=t.coords.accuracy,l=this._map.getBearing(),p=c.e({bearing:l},this.options.fitBoundsOptions),m=Mt.fromLngLat(n,o);this._map.fitBounds(m,p,{geolocateSource:!0})},this._updateMarker=t=>{if(t){const n=new c.V(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=t.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=t=>{if(this._map){if(t.code===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._geolocateButton.disabled=!0;const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(t.code===3&&Gn)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new c.l("error",t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=pe.create("button","maplibregl-ctrl-geolocate",this._container),pe.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=t=>{if(this._map){if(t===!1){c.w("Geolocation support is not available so the GeolocateControl will be disabled.");const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}else{const n=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=pe.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new bo({element:this._dotElement}),this._circleElement=pe.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new bo({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",(n=>{const o=n?.[0]instanceof ResizeObserverEntry;n.geolocateSource||this._watchState!=="ACTIVE_LOCK"||o||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 c.l("trackuserlocationend")),this.fire(new c.l("userlocationlostfocus")))}))}},this.options=c.e({},Ml,d)}onAdd(d){return this._map=d,this._container=pe.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),(function(){return c._(this,arguments,void 0,(function*(t=!1){if(Wr!==void 0&&!t)return Wr;if(window.navigator.permissions===void 0)return Wr=!!window.navigator.geolocation,Wr;try{Wr=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{Wr=!!window.navigator.geolocation}return Wr}))})().then((t=>this._finishSetupUI(t))),this._container}onRemove(){this._geolocationWatchID!==void 0&&(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(),pe.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,bs=0,Gn=!1}_isOutOfMapMaxBounds(d){const t=this._map.getMaxBounds(),n=d.coords;return t&&(n.longitude<t.getWest()||n.longitude>t.getEast()||n.latitude<t.getSouth()||n.latitude>t.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 d=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&d))return;const t=this._map.project(d),n=this._map.unproject([t.x+100,t.y]),o=d.distanceTo(n)/100,l=2*this._accuracy/o;this._circleElement.style.width=`${l.toFixed(2)}px`,this._circleElement.style.height=`${l.toFixed(2)}px`}trigger(){if(!this._setup)return c.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 c.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":bs--,Gn=!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 c.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 c.l("trackuserlocationstart")),this.fire(new c.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(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let d;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),bs++,bs>1?(d={maximumAge:6e5,timeout:0},Gn=!0):(d=this.options.positionOptions,Gn=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,d)}}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)}},D.GlobeControl=class{constructor(){this._toggleProjection=()=>{var d;const t=(d=this._map.getProjection())===null||d===void 0?void 0:d.type;this._map.setProjection(t!=="mercator"&&t?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var d;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),((d=this._map.getProjection())===null||d===void 0?void 0:d.type)==="globe"?(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(d){return this._map=d,this._container=pe.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=pe.create("button","maplibregl-ctrl-globe",this._container),pe.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._map.on("projectiontransition",this._updateGlobeIcon),this._container}onRemove(){pe.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._map.off("projectiontransition",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},D.Hash=uo,D.ImageSource=Br,D.KeyboardHandler=Hc,D.LngLatBounds=Mt,D.LogoControl=Kc,D.Map=class extends vr{get _ownerWindow(){var d,t;return((t=(d=this._container)===null||d===void 0?void 0:d.ownerDocument)===null||t===void 0?void 0:t.defaultView)||window}constructor(d){var t,n;c.cH.mark(c.cI.create);const o=Object.assign(Object.assign(Object.assign({},ma),d),{canvasContextAttributes:Object.assign(Object.assign({},ma.canvasContextAttributes),d.canvasContextAttributes)});if(o.minZoom!=null&&o.maxZoom!=null&&o.minZoom>o.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(o.minPitch!=null&&o.maxPitch!=null&&o.minPitch>o.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(o.minPitch!=null&&o.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(o.maxPitch!=null&&o.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const l=new qi,p=new kn;o.minZoom!==void 0&&l.setMinZoom(o.minZoom),o.maxZoom!==void 0&&l.setMaxZoom(o.maxZoom),o.minPitch!==void 0&&l.setMinPitch(o.minPitch),o.maxPitch!==void 0&&l.setMaxPitch(o.maxPitch),o.renderWorldCopies!==void 0&&l.setRenderWorldCopies(o.renderWorldCopies),o.transformConstrain!==null&&l.setConstrainOverride(o.transformConstrain),super(l,p,{bearingSnap:o.bearingSnap,zoomSnap:o.zoomSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new rh,this._controls=[],this._mapId=c.af(),this._lostContextStyle={style:null,images:null},this._contextLost=_=>{if(_.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.painter.destroy(),this._lostContextStyle=this._getStyleAndImages(),this.style){for(const v of Object.values(this.style._layers))if(v.type==="custom"&&console.warn(`Custom layer with id '${v.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),v._listeners)for(const[w]of Object.entries(v._listeners))console.warn(`Custom layer with id '${v.id}' had event listeners for event '${w}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this.style.destroy(),this.style=null,this.fire(new c.l("webglcontextlost",{originalEvent:_}))}else this.fire(new c.l("webglcontextlost",{originalEvent:_}))},this._contextRestored=_=>{this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&(this.style.imageManager.images=this._lostContextStyle.images),this._lostContextStyle={style:null,images:null},this._setupPainter(),this.resize(),this._update(),this._resizeInternal(),this.fire(new c.l("webglcontextrestored",{originalEvent:_}))},this._onMapScroll=_=>{if(_.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=o.interactive,this._maxTileCacheSize=o.maxTileCacheSize,this._maxTileCacheZoomLevels=o.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},o.canvasContextAttributes),this._trackResize=o.trackResize===!0,this._bearingSnap=o.bearingSnap,this._zoomSnap=o.zoomSnap,this._centerClampedToGround=o.centerClampedToGround,this._refreshExpiredTiles=o.refreshExpiredTiles===!0,this._fadeDuration=o.fadeDuration,this._crossSourceCollisions=o.crossSourceCollisions===!0,this._collectResourceTiming=o.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},Tl),o.locale),this._clickTolerance=o.clickTolerance,this._overridePixelRatio=o.pixelRatio,this._maxCanvasSize=o.maxCanvasSize,this._zoomLevelsToOverscale=o.experimentalZoomLevelsToOverscale,this.transformCameraUpdate=o.transformCameraUpdate,this.transformConstrain=o.transformConstrain,this.cancelPendingTileRequestsWhileZooming=o.cancelPendingTileRequestsWhileZooming===!0,this.setAnisotropicFilterPitch(o.anisotropicFilterPitch),o.reduceMotion!==void 0&&($t.prefersReducedMotion=o.reduceMotion),this._imageQueueHandle=Ni.addThrottleControl((()=>this.isMoving())),this._requestManager=new zs(o.transformRequest),this._container=this._resolveContainer(o.container),o.maxBounds&&this.setMaxBounds(o.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})),typeof window<"u"&&(this._ownerWindow.addEventListener("online",this._onWindowOnline,!1),this._setupResizeObserver()),this.handlers=new Mi(this,o),this._hash=o.hash&&new uo(typeof o.hash=="string"&&o.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:o.center,elevation:o.elevation,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch,roll:o.roll}),o.bounds&&(this.resize(),this.fitBounds(o.bounds,c.e({},o.fitBoundsOptions,{duration:0}))));const m=typeof o.style=="string"||((n=(t=o.style)===null||t===void 0?void 0:t.projection)===null||n===void 0?void 0:n.type)!=="globe";this.resize(null,m),this._localIdeographFontFamily=o.localIdeographFontFamily,this._validateStyle=o.validateStyle,o.style&&this.setStyle(o.style,{localIdeographFontFamily:o.localIdeographFontFamily}),o.attributionControl&&this.addControl(new Yc(typeof o.attributionControl=="boolean"?void 0:o.attributionControl)),o.maplibreLogo&&this.addControl(new Kc,o.logoPosition),this.on("style.load",(()=>{if(m||this._resizeTransform(),this.transform.unmodified){const _=c.U(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(_)}})),this.on("data",(_=>{this._update(_.dataType==="style"),this.fire(new c.l(`${_.dataType}data`,_))})),this.on("dataloading",(_=>{this.fire(new c.l(`${_.dataType}dataloading`,_))})),this.on("dataabort",(_=>{this.fire(new c.l("sourcedataabort",_))}))}_getMapId(){return this._mapId}setGlobalStateProperty(d,t){return this.style.setGlobalStateProperty(d,t),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(d,t){if(t===void 0&&(t=d.getDefaultPosition?d.getDefaultPosition():"top-right"),!d||!d.onAdd)return this.fire(new c.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=d.onAdd(this);this._controls.push(d);const o=this._controlPositions[t];return t.indexOf("bottom")!==-1?o.insertBefore(n,o.firstChild):o.appendChild(n),this}removeControl(d){if(!d||!d.onRemove)return this.fire(new c.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const t=this._controls.indexOf(d);return t>-1&&this._controls.splice(t,1),d.onRemove(this),this}hasControl(d){return this._controls.indexOf(d)>-1}coveringTiles(d){return wt(this.transform,d)}calculateCameraOptionsFromTo(d,t,n,o){return o==null&&this.terrain&&(o=this.terrain.getElevationForLngLat(n,this.transform)),super.calculateCameraOptionsFromTo(d,t,n,o)}resize(d,t=!0){if(this._lostContextStyle.style!==null)return this;this._resizeInternal(t);const n=!this._moving;return n&&(this.stop(),this.fire(new c.l("movestart",d)).fire(new c.l("move",d))),this.fire(new c.l("resize",d)),n&&this.fire(new c.l("moveend",d)),this}_resizeInternal(d=!0){const[t,n]=this._containerDimensions(),o=this._getClampedPixelRatio(t,n);if(this._resizeCanvas(t,n,o),this.painter.resize(t,n,o),this.painter.overLimit()){const l=this.painter.context.gl;this._maxCanvasSize=[l.drawingBufferWidth,l.drawingBufferHeight];const p=this._getClampedPixelRatio(t,n);this._resizeCanvas(t,n,p),this.painter.resize(t,n,p)}this._resizeTransform(d)}_resizeTransform(d=!0){var t;const[n,o]=this._containerDimensions();this.transform.resize(n,o,d),(t=this._requestedCameraState)===null||t===void 0||t.resize(n,o,d)}_getClampedPixelRatio(d,t){const{0:n,1:o}=this._maxCanvasSize,l=this.getPixelRatio(),p=d*l,m=t*l;return Math.min(p>n?n/p:1,m>o?o/m:1)*l}getPixelRatio(){var d;return(d=this._overridePixelRatio)!==null&&d!==void 0?d:devicePixelRatio}setPixelRatio(d){this._overridePixelRatio=d,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(d){return this.transform.setMaxBounds(Mt.convert(d)),this._update()}setMinZoom(d){if((d=d??-2)>=-2&&d<=this.transform.maxZoom){const t=this.transform.zoom,n=this._getTransformForUpdate();return n.setMinZoom(d),this._applyUpdatedTransform(n),this._update(),t!==this.transform.zoom&&this.fire(new c.l("zoomstart")).fire(new c.l("zoom")).fire(new c.l("zoomend")).fire(new c.l("movestart")).fire(new c.l("move")).fire(new c.l("moveend")),this}throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(d){if((d=d??22)>=this.transform.minZoom){const t=this.transform.zoom,n=this._getTransformForUpdate();return n.setMaxZoom(d),this._applyUpdatedTransform(n),this._update(),t!==this.transform.zoom&&this.fire(new c.l("zoomstart")).fire(new c.l("zoom")).fire(new c.l("zoomend")).fire(new c.l("movestart")).fire(new c.l("move")).fire(new c.l("moveend")),this}throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(d){if((d=d??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(d>=0&&d<=this.transform.maxPitch){const t=this.transform.pitch,n=this._getTransformForUpdate();return n.setMinPitch(d),this._applyUpdatedTransform(n),this._update(),t!==this.transform.pitch&&this.fire(new c.l("pitchstart")).fire(new c.l("pitch")).fire(new c.l("pitchend")).fire(new c.l("movestart")).fire(new c.l("move")).fire(new c.l("moveend")),this}throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(d){if((d=d??60)>180)throw new Error("maxPitch must be less than or equal to 180");if(d>=this.transform.minPitch){const t=this.transform.pitch,n=this._getTransformForUpdate();return n.setMaxPitch(d),this._applyUpdatedTransform(n),this._update(),t!==this.transform.pitch&&this.fire(new c.l("pitchstart")).fire(new c.l("pitch")).fire(new c.l("pitchend")).fire(new c.l("movestart")).fire(new c.l("move")).fire(new c.l("moveend")),this}throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getAnisotropicFilterPitch(){return this._anisotropicFilterPitch}setAnisotropicFilterPitch(d){if((d=d??20)>180)throw new Error("anisotropicFilterPitch must be less than or equal to 180");if(d<0)throw new Error("anisotropicFilterPitch must be greater than or equal to 0");return this._anisotropicFilterPitch=d,this._update()}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(d){return this.transform.setRenderWorldCopies(d),this._update()}setTransformConstrain(d){return this.transform.setConstrainOverride(d),this._update()}project(d){return this.transform.locationToScreenPoint(c.V.convert(d),this.style&&this.terrain)}unproject(d){return this.transform.screenPointToLocation(c.P.convert(d),this.terrain)}isMoving(){var d;return this._moving||((d=this.handlers)===null||d===void 0?void 0:d.isMoving())}isZooming(){var d;return this._zooming||((d=this.handlers)===null||d===void 0?void 0:d.isZooming())}isRotating(){var d;return this._rotating||((d=this.handlers)===null||d===void 0?void 0:d.isRotating())}_createDelegatedListener(d,t,n){if(d==="mouseenter"||d==="mouseover"){let o=!1;return{layers:t,listener:n,delegates:{mousemove:p=>{const m=t.filter((v=>this.getLayer(v))),_=m.length!==0?this.queryRenderedFeatures(p.point,{layers:m}):[];_.length?o||(o=!0,n.call(this,new Hi(d,this,p.originalEvent,{features:_}))):o=!1},mouseout:()=>{o=!1}}}}if(d==="mouseleave"||d==="mouseout"){let o=!1;return{layers:t,listener:n,delegates:{mousemove:m=>{const _=t.filter((v=>this.getLayer(v)));(_.length!==0?this.queryRenderedFeatures(m.point,{layers:_}):[]).length?o=!0:o&&(o=!1,n.call(this,new Hi(d,this,m.originalEvent)))},mouseout:m=>{o&&(o=!1,n.call(this,new Hi(d,this,m.originalEvent)))}}}}{const o=l=>{const p=t.filter((_=>this.getLayer(_))),m=p.length!==0?this.queryRenderedFeatures(l.point,{layers:p}):[];m.length&&(l.features=m,n.call(this,l),delete l.features)};return{layers:t,listener:n,delegates:{[d]:o}}}}_saveDelegatedListener(d,t){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[d]=this._delegatedListeners[d]||[],this._delegatedListeners[d].push(t)}_removeDelegatedListener(d,t,n){if(!this._delegatedListeners||!this._delegatedListeners[d])return;const o=this._delegatedListeners[d];for(let l=0;l<o.length;l++){const p=o[l];if(p.listener===n&&p.layers.length===t.length&&p.layers.every((m=>t.includes(m)))){for(const m in p.delegates)this.off(m,p.delegates[m]);return void o.splice(l,1)}}}on(d,t,n){if(n===void 0)return super.on(d,t);const o=typeof t=="string"?[t]:t,l=this._createDelegatedListener(d,o,n);this._saveDelegatedListener(d,l);for(const p in l.delegates)this.on(p,l.delegates[p]);return{unsubscribe:()=>{this._removeDelegatedListener(d,o,n)}}}once(d,t,n){if(n===void 0)return super.once(d,t);const o=typeof t=="string"?[t]:t,l=this._createDelegatedListener(d,o,n);for(const p in l.delegates){const m=l.delegates[p];l.delegates[p]=(..._)=>{this._removeDelegatedListener(d,o,n),m(..._)}}this._saveDelegatedListener(d,l);for(const p in l.delegates)this.once(p,l.delegates[p]);return this}off(d,t,n){return n===void 0?super.off(d,t):(this._removeDelegatedListener(d,typeof t=="string"?[t]:t,n),this)}queryRenderedFeatures(d,t){if(!this.style)return[];let n;const o=d instanceof c.P||Array.isArray(d),l=o?d:[[0,0],[this.transform.width,this.transform.height]];if(t=t||(o?{}:d)||{},l instanceof c.P||typeof l[0]=="number")n=[c.P.convert(l)];else{const p=c.P.convert(l[0]),m=c.P.convert(l[1]);n=[p,new c.P(m.x,p.y),m,new c.P(p.x,m.y),p]}return this.style.queryRenderedFeatures(n,t,this.transform)}querySourceFeatures(d,t){return this.style.querySourceFeatures(d,t)}setStyle(d,t){return(t=c.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},t)).diff!==!1&&t.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&d?(this._diffStyle(d,t),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._updateStyle(d,t))}setTransformRequest(d){return this._requestManager.setTransformRequest(d),this}_getUIString(d){const t=this._locale[d];if(t==null)throw new Error(`Missing UI string '${d}'`);return t}_updateStyle(d,t){var n,o;if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(d,t)));const l=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!d)),d?(this.style=new Ha(this,t||{}),this.style.setEventedParent(this,{style:this.style}),typeof d=="string"?this.style.loadURL(d,t,l):this.style.loadJSON(d,t,l),this):((o=(n=this.style)===null||n===void 0?void 0:n.projection)===null||o===void 0||o.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Ha(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(d,t){if(typeof d=="string"){const n=this._requestManager.transformRequest(d,"Style");c.j(n,new AbortController).then((o=>{this._updateDiff(o.data,t)})).catch((o=>{o&&this.fire(new c.k(o))}))}else typeof d=="object"&&this._updateDiff(d,t)}_updateDiff(d,t){try{this.style.setState(d,t)&&this._update(!0)}catch(n){c.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(d,t)}}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():c.w("There is no style added to the map.")}addSource(d,t){return this._lazyInitEmptyStyle(),this.style.addSource(d,t),this._update(!0)}isSourceLoaded(d){const t=this.style&&this.style.tileManagers[d];if(t!==void 0)return t.loaded();this.fire(new c.k(new Error(`There is no tile manager with ID '${d}'`)))}setTerrain(d){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),d){const t=this.style.tileManagers[d.source];if(!t)throw new Error(`cannot load terrain, because there exists no source with ID: ${d.source}`);this.terrain===null&&t.reload();for(const n in this.style._layers){const o=this.style._layers[n];o.type==="hillshade"&&o.source===d.source&&c.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."),o.type==="color-relief"&&o.source===d.source&&c.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 Gt(this.painter,t,d),this.painter.renderToTexture=new fa(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=n=>{var o;n.dataType==="style"?this.terrain.tileManager.freeRtt():n.dataType==="source"&&n.tile&&(n.sourceId!==d.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))),((o=n.source)===null||o===void 0?void 0:o.type)==="image"?this.terrain.tileManager.freeRtt():this.terrain.tileManager.freeRtt(n.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 c.l("terrain",{terrain:d})),this}getTerrain(){var d,t;return(t=(d=this.terrain)===null||d===void 0?void 0:d.options)!==null&&t!==void 0?t:null}areTilesLoaded(){const d=this.style&&this.style.tileManagers;for(const t of Object.values(d))if(!t.areTilesLoaded())return!1;return!0}removeSource(d){return this.style.removeSource(d),this._update(!0)}getSource(d){return this.style.getSource(d)}setSourceTileLodParams(d,t,n){if(n){const o=this.getSource(n);if(!o)throw new Error(`There is no source with ID "${n}", cannot set LOD parameters`);o.calculateTileZoom=qe(Math.max(1,d),Math.max(1,t))}else for(const o in this.style.tileManagers)this.style.tileManagers[o].getSource().calculateTileZoom=qe(Math.max(1,d),Math.max(1,t));return this._update(!0),this}refreshTiles(d,t){const n=this.style.tileManagers[d];if(!n)throw new Error(`There is no tile manager with ID "${d}", cannot refresh tile`);t===void 0?n.reload(!0):n.refreshTiles(t.map((o=>new c.ac(o.z,o.x,o.y))))}addImage(d,t,n={}){const{pixelRatio:o=1,sdf:l=!1,stretchX:p,stretchY:m,content:_,textFitWidth:v,textFitHeight:w}=n;if(this._lazyInitEmptyStyle(),!(t instanceof HTMLImageElement||c.b(t))){if(t.width===void 0||t.height===void 0)return this.fire(new c.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:T,height:C,data:M}=t,z=t;return this.style.addImage(d,{data:new c.R({width:T,height:C},new Uint8Array(M)),pixelRatio:o,stretchX:p,stretchY:m,content:_,textFitWidth:v,textFitHeight:w,sdf:l,version:0,userImage:z}),z.onAdd&&z.onAdd(this,d),this}}{const{width:T,height:C,data:M}=$t.getImageData(t);this.style.addImage(d,{data:new c.R({width:T,height:C},M),pixelRatio:o,stretchX:p,stretchY:m,content:_,textFitWidth:v,textFitHeight:w,sdf:l,version:0})}}updateImage(d,t){const n=this.style.getImage(d);if(!n)return this.fire(new c.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const o=t instanceof HTMLImageElement||c.b(t)?$t.getImageData(t):t,{width:l,height:p,data:m}=o;if(l===void 0||p===void 0)return this.fire(new c.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(l!==n.data.width||p!==n.data.height)return this.fire(new c.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const _=!(t instanceof HTMLImageElement||c.b(t));return n.data.replace(m,_),this.style.updateImage(d,n),this}getImage(d){return this.style.getImage(d)}hasImage(d){return d?!!this.style.getImage(d):(this.fire(new c.k(new Error("Missing required image id"))),!1)}removeImage(d){this.style.removeImage(d)}loadImage(d){return Ni.getImage(this._requestManager.transformRequest(d,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(d,t){return this._lazyInitEmptyStyle(),this.style.addLayer(d,t),this._update(!0)}moveLayer(d,t){return this.style.moveLayer(d,t),this._update(!0)}removeLayer(d){return this.style.removeLayer(d),this._update(!0)}getLayer(d){return this.style.getLayer(d)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(d,t,n){return this.style.setLayerZoomRange(d,t,n),this._update(!0)}setFilter(d,t,n={}){return this.style.setFilter(d,t,n),this._update(!0)}getFilter(d){return this.style.getFilter(d)}setPaintProperty(d,t,n,o={}){return this.style.setPaintProperty(d,t,n,o),this._update(!0)}getPaintProperty(d,t){return this.style.getPaintProperty(d,t)}setLayoutProperty(d,t,n,o={}){return this.style.setLayoutProperty(d,t,n,o),this._update(!0)}getLayoutProperty(d,t){return this.style.getLayoutProperty(d,t)}setGlyphs(d,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(d,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(d,t,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(d,t,n,(o=>{o||this._update(!0)})),this}removeSprite(d){return this._lazyInitEmptyStyle(),this.style.removeSprite(d),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(d,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(d,t,(n=>{n||this._update(!0)})),this}setLight(d,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(d,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(d,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(d,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(d,t){return this.style.setFeatureState(d,t),this._update()}removeFeatureState(d,t){return this.style.removeFeatureState(d,t),this._update()}getFeatureState(d){return this.style.getFeatureState(d)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let d=0,t=0;return this._container&&(d=this._container.clientWidth||400,t=this._container.clientHeight||300),[d,t]}_setupResizeObserver(){var d;let t=!1;const n=dl((l=>{this._trackResize&&!this._removed&&(this.resize(l),this.redraw())}),50),o=(d=this._ownerWindow.ResizeObserver)!==null&&d!==void 0?d:ResizeObserver;this._resizeObserver=new o((l=>{t?n(l):t=!0})),this._resizeObserver.observe(this._container)}_resolveContainer(d){if(typeof d=="string"){const t=document.getElementById(d);if(!t)throw new Error(`Container '${d}' not found.`);return t}if(d instanceof HTMLElement||d&&typeof d=="object"&&d.nodeType===1)return d;throw new Error("Invalid type: 'container' must be a String or HTMLElement.")}_setupContainer(){const d=this._container;d.classList.add("maplibregl-map");const t=this._canvasContainer=pe.create("div","maplibregl-canvas-container",d);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=pe.create("canvas","maplibregl-canvas",t),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 n=this._containerDimensions(),o=this._getClampedPixelRatio(n[0],n[1]);this._resizeCanvas(n[0],n[1],o);const l=this._controlContainer=pe.create("div","maplibregl-control-container",d),p=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((m=>{p[m]=pe.create("div",`maplibregl-ctrl-${m} `,l)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(d,t,n){this._canvas.width=Math.floor(n*d),this._canvas.height=Math.floor(n*t),this._canvas.style.width=`${d}px`,this._canvas.style.height=`${t}px`}_setupPainter(){const d=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let t=null;this._canvas.addEventListener("webglcontextcreationerror",(o=>{t={requestedAttributes:d},o&&(t.statusMessage=o.statusMessage,t.type=o.type)}),{once:!0});let n=null;if(n=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,d):this._canvas.getContext("webgl2",d)||this._canvas.getContext("webgl",d),!n){const o="Failed to initialize WebGL";throw t?(t.message=o,new Error(JSON.stringify(t))):new Error(o)}this.painter=new Bc(n,this.transform),pr.testSupport(n)}migrateProjection(d,t){super.migrateProjection(d,t),this.painter.transform=d,this.fire(new c.l("projectiontransition",{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(d){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||d,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(d){return this._update(),this._renderTaskQueue.add(d)}_cancelRenderFrame(d){this._renderTaskQueue.remove(d)}_render(d){var t,n,o,l,p;const m=this._idleTriggered?this._fadeDuration:0,_=((t=this.style.projection)===null||t===void 0?void 0:t.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(d),this._removed)return;let v=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const C=this.transform.zoom,M=He();this.style.zoomHistory.update(C,M);const z=new c.H(C,{now:M,fadeDuration:m,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),R=z.crossFadingFactor();R===1&&R===this._crossFadingFactor||(v=!0,this._crossFadingFactor=R),this.style.update(z)}const w=((n=this.style.projection)===null||n===void 0?void 0:n.transitionState)>0!==_;(o=this.style.projection)===null||o===void 0||o.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState((l=this.style.projection)===null||l===void 0?void 0:l.transitionState,(p=this.style.projection)===null||p===void 0?void 0:p.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||w)&&(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,m,this._crossSourceCollisions,w),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:m,showPadding:this.showPadding,anisotropicFilterPitch:this.getAnisotropicFilterPitch()}),this.fire(new c.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,c.cH.mark(c.cI.load),this.fire(new c.l("load"))),this.style&&(this.style.hasTransitions()||v)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const T=this._sourcesDirty||this._styleDirty||this._placementDirty;return T||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new c.l("idle")),!this._loaded||this._fullyLoaded||T||(this._fullyLoaded=!0,c.cH.mark(c.cI.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var d;this._hash&&this._hash.remove();for(const n of this._controls)n.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),typeof window<"u"&&this._ownerWindow.removeEventListener("online",this._onWindowOnline,!1),Ni.removeThrottleControl(this._imageQueueHandle),(d=this._resizeObserver)===null||d===void 0||d.disconnect();const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t?.loseContext&&t.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),pe.remove(this._canvasContainer),pe.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),c.cH.remove(),this._removed=!0,this.fire(new c.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,$t.frame(this._frameRequest,(d=>{c.cH.recordStartOfFrameAt(d),this._frameRequest=null;try{this._render(d)}catch(t){if(!c.Z(t)&&!(function(n){return n.message===io})(t))throw t}}),(()=>{}),this._ownerWindow))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(d){this._showTileBoundaries!==d&&(this._showTileBoundaries=d,this._update())}get showPadding(){return!!this._showPadding}set showPadding(d){this._showPadding!==d&&(this._showPadding=d,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(d){this._showCollisionBoxes!==d&&(this._showCollisionBoxes=d,d?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(d){this._showOverdrawInspector!==d&&(this._showOverdrawInspector=d,this._update())}get repaint(){return!!this._repaint}set repaint(d){this._repaint!==d&&(this._repaint=d,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(d){this._vertices=d,this._update()}get version(){return Sl}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(d){return this._lazyInitEmptyStyle(),this.style.setProjection(d),this._update(!0)}},D.MapMouseEvent=Hi,D.MapTouchEvent=po,D.MapWheelEvent=Vc,D.Marker=bo,D.NavigationControl=class{constructor(d){this._updateZoomButtons=()=>{const t=this._map.getZoom(),n=t===this._map.getMaxZoom(),o=t===this._map.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=o,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",o.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=(t,n)=>{const o=this._map._getUIString(`NavigationControl.${n}`);t.title=o,t.setAttribute("aria-label",o)},this.options=c.e({},vo,d),this._container=pe.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(t=>this._map.zoomIn({},{originalEvent:t}))),pe.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(t=>this._map.zoomOut({},{originalEvent:t}))),pe.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})})),this._compassIcon=pe.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(d){return this._map=d,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 Pl(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){pe.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(d,t){const n=pe.create("button",d,this._container);return n.type="button",n.addEventListener("click",t),n}},D.Popup=class extends c.E{constructor(d){super(),this._updateOpacity=()=>{this.options.locationOccludedOpacity!==void 0&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"")},this.remove=()=>(this._content&&pe.remove(this._content),this._container&&(pe.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 c.l("close"))),this),this._onMouseUp=t=>{this._update(t.point)},this._onMouseMove=t=>{this._update(t.point)},this._onDrag=t=>{this._update(t.point)},this._update=t=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=pe.create("div","maplibregl-popup",this._map.getContainer()),this._tip=pe.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const m of this.options.className.split(" "))this._container.classList.add(m);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=ga(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!t)return;const n=this._flatPos=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&t?t:this._map.transform.locationToScreenPoint(this._lngLat));let o=this.options.anchor;const l=ba(this.options.offset);if(!o){const m=this._container.offsetWidth,_=this._container.offsetHeight,v=(function(T){var C,M,z,R;return T?{top:(C=T.top)!==null&&C!==void 0?C:0,right:(M=T.right)!==null&&M!==void 0?M:0,bottom:(z=T.bottom)!==null&&z!==void 0?z:0,left:(R=T.left)!==null&&R!==void 0?R:0}:{top:0,right:0,bottom:0,left:0}})(this.options.padding);let w;w=n.y+l.bottom.y<_+v.top?["top"]:n.y>this._map.transform.height-_-v.bottom?["bottom"]:[],n.x<m/2+v.left?w.push("left"):n.x>this._map.transform.width-m/2-v.right&&w.push("right"),o=w.length===0?"bottom":w.join("-")}let p=n.add(l[o]);this.options.subpixelPositioning||(p=p.round()),pe.setTransform(this._container,`${xo[o]} translate(${p.x}px,${p.y}px)`),_a(this._container,o,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=c.e(Object.create(xa),d)}addTo(d){return this._map&&this.remove(),this._map=d,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 c.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(d){return this._lngLat=c.V.convert(d),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(d){return this.setDOMContent(document.createTextNode(d))}setHTML(d){const t=document.createDocumentFragment(),n=document.createElement("body");let o;for(n.innerHTML=d;o=n.firstChild,o;)t.appendChild(o);return this.setDOMContent(t)}getMaxWidth(){var d;return(d=this._container)===null||d===void 0?void 0:d.style.maxWidth}setMaxWidth(d){return this.options.maxWidth=d,this._update(),this}setDOMContent(d){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=pe.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(d),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(d){return this._container&&this._container.classList.add(d),this}removeClassName(d){return this._container&&this._container.classList.remove(d),this}setOffset(d){return this.options.offset=d,this._update(),this}toggleClassName(d){if(this._container)return this._container.classList.toggle(d)}setSubpixelPositioning(d){this.options.subpixelPositioning=d}setPadding(d){this.options.padding=d,this._update()}_createCloseButton(){this.options.closeButton&&(this._closeButton=pe.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const d=this._container.querySelector(Cl);d&&d.focus()}},D.RasterDEMTileSource=an,D.RasterTileSource=Pn,D.ScaleControl=class{constructor(d){this._onMove=()=>{va(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,va(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},ya),d)}getDefaultPosition(){return"bottom-left"}onAdd(d){return this._map=d,this._container=pe.create("div","maplibregl-ctrl maplibregl-ctrl-scale",d.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){pe.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},D.ScrollZoomHandler=xl,D.Style=Ha,D.TerrainControl=class{constructor(d){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=d}onAdd(d){return this._map=d,this._container=pe.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=pe.create("button","maplibregl-ctrl-terrain",this._container),pe.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(){pe.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},D.TwoFingersTouchPitchHandler=Hr,D.TwoFingersTouchRotateHandler=$c,D.TwoFingersTouchZoomHandler=Zc,D.TwoFingersTouchZoomRotateHandler=Be,D.VectorTileSource=es,D.VideoSource=cn,D.addSourceType=(d,t)=>c._(void 0,void 0,void 0,(function*(){if(is(d))throw new Error(`A source type called "${d}" already exists.`);((n,o)=>{Rs[n]=o})(d,t)})),D.clearPrewarmedResources=function(){const d=fi;d&&(d.isPreloaded()&&d.numActive()===1?(d.release(on),fi=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()"))},D.createTileMesh=No,D.getMaxParallelImageRequests=function(){return c.c.MAX_PARALLEL_IMAGE_REQUESTS},D.getRTLTextPluginStatus=function(){return F().getRTLTextPluginStatus()},D.getVersion=function(){return Il},D.getWorkerCount=function(){return Rr.workerCount},D.getWorkerUrl=function(){return c.c.WORKER_URL},D.importScriptInWorkers=function(d){return Tn().broadcast("IS",d)},D.isTimeFrozen=function(){return tr.isFrozen()},D.now=He,D.prewarm=function(){Qn().acquire(on)},D.restoreNow=function(){tr.restoreNow()},D.setMaxParallelImageRequests=function(d){c.c.MAX_PARALLEL_IMAGE_REQUESTS=d},D.setNow=function(d){tr.setNow(d)},D.setRTLTextPlugin=function(d,t){return F().setRTLTextPlugin(d,t)},D.setWorkerCount=function(d){Rr.workerCount=d},D.setWorkerUrl=function(d){c.c.WORKER_URL=d}}));var Ne=Se;return Ne}))})(Yl)),Yl.exports}var nt=Ef(),Yt=Va(nt);class nd extends nt.Evented{constructor(){super(...arguments),this._locale="en",this._apiKey="",this._pixelRatio=1,this._webHost="https://www.maptoolkit.net",this._staticHost="https://static.maptoolkit.net",this._stylesHost="https://styles.maptoolkit.net",this._iconsHost="https://icons.maptoolkit.net",this._dataHost="https://data.maptoolkit.net",this._routingHost="https://routing.maptoolkit.net",this._geocoderHost="https://geocoder.maptoolkit.net",this._dataconnectorHost="https://dataconnector.maptoolkit.net",this._dataconnectorCdnHost="https://dataconnector-cdn.maptoolkit.net",this._staticmapHost="https://staticmap.maptoolkit.net",this._vtcCdnHost="https://vtc-cdn.maptoolkit.net",this._vtcHost="https://vtc.maptoolkit.net",this._rtcCdnHost="https://rtc-cdn.maptoolkit.net"}get locale(){return this._locale}set locale(re){this._locale=re,this.fire("config.locale.set")}get apiKey(){return this._apiKey||console.warn("Maptoolkit API key is not set."),this._apiKey}set apiKey(re){this._apiKey=re,this.fire("config.apiKey.set")}get pixelRatio(){return this._pixelRatio}set pixelRatio(re){this._pixelRatio=re,this.fire("config.pixelRatio.set")}get webHost(){return this._webHost}set webHost(re){this._webHost=re,this.fire("config.webHost.set")}get staticHost(){return this._staticHost}set staticHost(re){this._staticHost=re,this.fire("config.staticHost.set")}get stylesHost(){return this._stylesHost}set stylesHost(re){this._stylesHost=re,this.fire("config.stylesHost.set")}get iconsHost(){return this._iconsHost}set iconsHost(re){this._iconsHost=re,this.fire("config.iconsHost.set")}get dataHost(){return this._dataHost}set dataHost(re){this._dataHost=re,this.fire("config.dataHost.set")}get routingHost(){return this._routingHost}set routingHost(re){this._routingHost=re,this.fire("config.routingHost.set")}get geocoderHost(){return this._geocoderHost}set geocoderHost(re){this._geocoderHost=re,this.fire("config.geocoderHost.set")}get dataconnectorHost(){return this._dataconnectorHost}set dataconnectorHost(re){this._dataconnectorHost=re,this.fire("config.dataconnectorHost.set")}get dataconnectorCdnHost(){return this._dataconnectorCdnHost}set dataconnectorCdnHost(re){this._dataconnectorCdnHost=re,this.fire("config.dataconnectorCdnHost.set")}get staticmapHost(){return this._staticmapHost}set staticmapHost(re){this._staticmapHost=re,this.fire("config.staticmapHost.set")}get vtcCdnHost(){return this._vtcCdnHost}set vtcCdnHost(re){this._vtcCdnHost=re,this.fire("config.vtcCdnHost.set")}get vtcHost(){return this._vtcHost}set vtcHost(re){this._vtcHost=re,this.fire("config.vtcHost.set")}get rtcCdnHost(){return this._rtcCdnHost}set rtcCdnHost(re){this._rtcCdnHost=re,this.fire("config.rtcCdnHost.set")}}const ei=new nd;nt.addProtocol("maptoolkit",(Ke,re)=>new Promise(Se=>{const Ae=Ke.url.slice(13).split("?")[0].split("/"),$e=new URLSearchParams(Ke.url.split("#")[0].split("?")[1]);let Ne=null;const[D,c,Te]=Ae;if(D==="styles")Ne=new URL(`/${c}/${Te}.json`,ei.stylesHost);else if(D==="icons"){const _t=ei.pixelRatio>1?`@${Math.min(Math.ceil(ei.pixelRatio),4)}x`:"",ct=Ke.type==="json"?"json":"png";Ne=new URL(`/${c.replace(/(@\dx)?\.(json|png)$/,"")}${_t}.${ct}`,ei.iconsHost)}else D==="fonts"?Ne=new URL(`/fonts/${Ae.slice(2).join("/")}`,ei.staticHost):D==="vtc"||D==="rtc"?Ke.type==="json"?Ne=new URL(`/${Ae.slice(1).join("/")}.json`,ei[`${D}CdnHost`]):Ne=new URL(`/${Ae.slice(1).join("/")}`,ei[`${D}CdnHost`]):D==="data"&&(Ne=new URL(`/${c}/${Te}.json`,ei.dataHost));Ne&&($e.forEach((_t,ct)=>{Ne?.searchParams.set(ct,_t)}),Ne.searchParams.set("api_key",ei.apiKey),fetch(Ne).then(_t=>Ke.type==="json"?_t.json():_t.arrayBuffer()).then(_t=>{_t?Se({data:_t}):re.abort()}).catch(()=>{re.abort()}))}));var Af="11.0.0-beta.1";const sd={de:{"AttributionControl.ToggleAttribution":"Attribution ein-/ausblenden","AttributionControl.MapFeedback":"Feedback zur Karte","FullscreenControl.Enter":"Vollbild einschalten","FullscreenControl.Exit":"Vollbild ausschalten","GeolocateControl.FindMyLocation":"Suche meinen Standort","GeolocateControl.LocationNotAvailable":"Standort nicht verf\xFCgbar","LogoControl.Title":"MapLibre Logo","Map.Title":"Karte","Marker.Title":"Kartenmarker","NavigationControl.ResetBearing":"Nach Norden ausrichten","NavigationControl.ZoomIn":"Einzoomen","NavigationControl.ZoomOut":"Auszoomen","Popup.Close":"Popup schlie\xDFen","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","TerrainControl.Enable":"Terrain einschalten","TerrainControl.Disable":"Terrain ausschalten","CooperativeGesturesHandler.WindowsHelpText":"Strg + Scroll um zu zoomen","CooperativeGesturesHandler.MacHelpText":"\u2318 + Scroll um zu zoomen","CooperativeGesturesHandler.MobileHelpText":"Benutze zwei Finger um die Karte zu bewegen","TerrainControl.ToggleTilt":"Karte kippen und Terrain umschalten, versuche Strg + Ziehen","PitchControl.ChangePitch":"Ziehen um Karte zu kippen","CompassControl.ResetBearing":"Nach Norden ausrichten","CompassControl.RotateLeft":"-90\xB0 drehen, versuche Strg + Ziehen","CompassControl.RotateRight":"+90\xB0 drehen, versuche Strg + Ziehen","StyleControl.Group.Styles":"Styles","StyleControl.Group.Layers":"Ebenen","StyleControl.Style.Terrain":"Terrain","StyleControl.Style.Light":"Light","StyleControl.Style.Dark":"Dark","StyleControl.Style.City":"CityMaps","StyleControl.Style.Green":"Green","StyleControl.Style.Winter":"Winter","StyleControl.Style.Satellite":"Satellit","StyleControl.Style.Hiking":"Wandern","StyleControl.Style.Cycling":"Fahrrad","StyleControl.Style.Pistes":"Schi","StyleControl.Style.Protected":"Naturschutzgebiete","StyleControl.Style.Oepnv":"\xD6PNV","IsochroneControl.Tooltip.foot":"Zieh' mich auf die Karte, um {range} Min-Fu\xDFweg anzuzeigen","IsochroneControl.Tooltip.bike":"Zieh' mich auf die Karte, um {range} Min-Radweg anzuzeigen","IsochroneControl.Tooltip.car":"Zieh' mich auf die Karte, um {range} Min-Autofahrt anzuzeigen"},en:{"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","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":"Use \u2318 + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map","TerrainControl.ToggleTilt":"Tilt map and toggle terrain, try Ctrl + mouse drag","PitchControl.ChangePitch":"Drag to change map pitch","CompassControl.ResetBearing":"Reset bearing to north","CompassControl.RotateLeft":"Rotate -90\xB0, try Ctrl + mouse drag","CompassControl.RotateRight":"Rotate +90\xB0, try Ctrl + mouse drag","StyleControl.Group.Styles":"Styles","StyleControl.Group.Layers":"Overlays","StyleControl.Style.Terrain":"Terrain","StyleControl.Style.Light":"Light","StyleControl.Style.Dark":"Dark","StyleControl.Style.City":"CityMaps","StyleControl.Style.Green":"Green","StyleControl.Style.Winter":"Winter","StyleControl.Style.Satellite":"Satellite","StyleControl.Style.Hiking":"Hiking","StyleControl.Style.Cycling":"Cycling","StyleControl.Style.Pistes":"Skiing","StyleControl.Style.Protected":"Protected Areas","StyleControl.Style.Oepnv":"\xD6PNV","IsochroneControl.Tooltip.foot":"Drag me onto the map to show a {range}-min walking area.","IsochroneControl.Tooltip.bike":"Drag me onto the map to show a {range}-min cycling area.","IsochroneControl.Tooltip.car":"Drag me onto the map to show a {range}-min driving area."}};function Df(){return sd[ei.locale||"en"]}const zf={scale:{maxWidth:80,unit:"metric"}};class od{constructor(re){this.options=Object.assign(zf,re),this._attribCtrl=new nt.AttributionControl(this.options),this.options.scale!==!1&&(this._scaleCtrl=new nt.ScaleControl(this.options.scale))}getDefaultPosition(){return"bottom-right"}onAdd(re){this._map=re;const Se=this._attribCtrl.onAdd(re);if(Se.classList.add("maptoolkit-ctrl-attrib"),this._scaleCtrl){const Ae=this._scaleCtrl.onAdd(re);Ae.classList.remove("maplibregl-ctrl"),Se.appendChild(Ae)}return this._container=Se,this._container}onRemove(){this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._map=void 0}}const kf={};class ad{constructor(re){this.options=Object.assign(kf,re)}getDefaultPosition(){return"bottom-left"}onAdd(re){this._map=re,this._container=document.createElement("div"),this._container.classList.add("maplibregl-ctrl","maptoolkit-ctrl","maptoolkit-ctrl-logo");const Se=document.createElement("a");Se.classList.add("maptoolkit-ctrl-logo-anchor"),Se.href=ei.webHost,Se.target="_blank";const Ae=document.createElement("img");return Ae.classList.add("maptoolkit-ctrl-logo-image"),Ae.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJ0AAAAwCAYAAAALpHjmAAAAAXNSR0IArs4c6QAAFyJJREFUeF7tXAtUU1e63jxCoxfESqxFbRFHwQdOlasGkfLSCe2ACmKcK1axWh+oLdhlg/Qh1WoR7ChY310KlhEHUdAKCtyqYBWCL2AEheltSG3FF2mjsZYCMXd9mbOztocAIYhTHM5aXZaTvf+99/9/+9//ax8L0v10JgeEKpVqb01NTdLYsWMvEEIedeZgXYW2RVeZaBecp6VEIhmRnZ19YfPmzW9FR0cfJoTUd8F1PPEpd4PuibPUQFB4+PDhNdOnT5dt2LDhw5iYmK2EkHudN1zXodwNus6TlaNCoShydnYeFB0dHZ+QkBDXDbp/MbsbdJ0DOsv4+PhZMpnsbyC/YcOGnTExMau6Qdcy6Cyrq6ulhBB7V1fXZEJIoxlysbx48eI4oVDo6+bmlvQfaMvYy+XydLFYHMCA7iNCSJ0ZvGyzS0lJiQNtJBaLVcY6mNKmzYGeUANjms6xoaFBIRAIhEeOHAkJCQn5ygyvS/Tbb79V2djYOHSAxhNa4tMnI5FI3A4fPlxma2trhdG3bt164O23336nE0AnvH79+s6XXnopnK5SpVJliUSiuYSQB9y7Zm1++umnUw4ODtOYNqYySVBdXT0dCkmtVh9uCeBtEeODznLlypWvb9y4MRsda2pqCgcPHozJtccAFmRmZu4MCQmZDxpZWVl7p0+f/m47abQ179/z7wYHgk6yE0HnWFZWlv7KK6+8SseqqKioHjVqFDTs99w7R7lcnky1LidX5eDBg32ZNqbw01alUh3t06ePPxo3NDSo0tPTfefOnXu1vUqJDzphYmLi2sjIyPfoLDZu3DhFJpMdbwdhx/v371+2s7N7ETQKCgpK/Pz8QgghN01Z2TPQxuBA0LXs27cvZ968eQs7gQeuJ0+ezPL39x9Oxzp//vx1sVgcSAip4N4Nyc7OPhAYGDiWAebtUaNGvUYIKTOR35YJCQl/fu+9946x7UtLS790d3df1l6NyQedCJopODh4CiVeXl7+zejRo/G3KdpOcOzYsaigoKAE2r+mpga76k+EkP8zcYFdudljJ8UzBDpbmUw2Pz4+Hva54cnPz/86ICAAR3m7FAofdE5FRUXZEyZMcKOUm5qadDExMVM+++yzEyZoO9Hdu3flIpHoD7T/gwcPtHZ2dthlpu6qrgw6OBApYrE4mF3EkSNHjoWEhLzdzuPMFD48LU0nJIQEVFVVpbu6uj6HiUGuUql0e25uLkJBHQKda21trdzR0bE3u+KSkpI8Dw+Pv7Sh7SxTUlIWh4eHb+dza8aMGXMOHz6cZgJoTWF0Z7WxzMvLc3JwcHgBA6hUqjsBAQGwi9qTuhqiVqvL7O3t/+sZA50lIeSPIpEoYv78+aE9e/bUffXVV8WXL1/eAwuKh4s2+cjXdOMbGxvl1tbWj71vbGysnz179p8yMjLOtiJxkUKhuIBgKL9NUlLSxqioqNW/49CJpVwunyIWi4/QucNQfu6556CxTTEr9N2kUqlXcHDwFrVa/YcBAwYIvby8BA4ODhY5OTkXg4KCZnRhTYfl2RNCRhFCRhBCoO2qCSFXCCG3mY1pmZWVNTU4ODiLx8dhrOfOgksgk8ki+Oc27fzNN9+ke3t7v9WC0fhYMJQPOu54gTfbKXGqJ6D6bJOTk9fMmzcPXrb+McMsEBBC+hNC4BUOt7GxcbS2tnaUSqWO/fr1u5CQkLCmi4MObMExa8uxCHnkh7yTwDYuLi5y1apV61rjIwu6ZoxnhQkhhIaGjs7Pz6deEfuzvUKhOOrs7OxjDADFxcUVnp6eQZ3A9CeANz0JUVxc3CerVq1awmMWANSaduePD4HYEUJwvOL/cVRDQ8DmgVYwWWuauLCnZdOZOB1iL5PJYuLj46Nb4yMLOlFeXt4BiUQyuaURuJgbXGS2WkLvsSUkJGRbWDSPNet0OnLr1i11//79PTiVbOoCnma7JwU6/pyh/XpyL6EVzMnutMaHLg+6IVeuXMl2c3NzZVFKo+p4d+/evV969+49kqex7MvKyo6xAUpoRbYfPGCBQADQnTfCQUS53xSJRL6PHj0a36tXr94WFhZ6Q7y+vl7d0NBQrFQq41uoR9NH23v27NlLpVLlurq6fnnx4sVXnJ2dI21tbSWgo9Ppfnnw4EH5t99+u8XDwwNxJr5jYHv9+vWtTU1NPqw9ijlXVlaeHThwoN4k4OgbSwvqU34YUyAQ+AmFwt50zLq6Onh7pqQS9Tbl0KFD/2KExm5XV9fMFgD7pEBnGF+n0+EIJRYWFvUXL178ICAgoIaTmYHX9PecnJxPmeCw/vd79+55sBji8xHZElY1jVar1WdZzys6Olq1fv36PqxjkZmZmRAaGvohxwRLqVTqmZaWdoZtg37x8fGGfCAmGR0dHZmQkIDyHlbozQxPY9saE7906VKIEdA46XQ6JfrA8K+srMwZM2YM4kZGH6SIYmNjF27bto3mJ/U1b3l5eTj6WnygrZVKJbIzcAZYu1TP6IEDB4Yb0/IgWFdX992JEyeCW4rcL1u2zGHNmjVfODg4IIBu9Llz5055WVlZCAMA2u5JgE4POHd3978j9UkJQ8EsXLjwtYyMjCJOZk4NDQ1VbJvs7GzZlClTPod+QOqvLT5yYB1qAN24ceNeO3/+PGJxhmfSpElFERERw2bMmNGHvrx58yaOSngwsFNs5XJ5KhuXqq6u/s3d3f3MvXv3JrNATElJ2fTmm2/G8hwRoYuLy2vV1dUGb6clxms0mlu9evWC98QK3Uun033TGmD4v3GpPdiXyE1ajhs3TsJftzF6nF0KYNAgt61CochuyY5labSSMrK/fft24QsvvPBKW2vA+ouLiz15wOso6P4BbzMwMPAAC6abN29qZ8yYsa+oqAiA+gcHuvEajaaIPcG4qMR6QojGVD5aWFi8SkEniIuLk7FeB5gwYsSIhB49egy/dOmSIUOB9xzCEyUSiSub2MZvsbGx8rVr1x5TKpWxTk5ONpSZXPR6Fg80sHn8qqqqvhKJRDZVVVW/KhQKotFomhBymDp1qg2rQRISEt6Ijo4+wGhLX51Od9qYwFQqlQ7vEbLg/07nTwjRuri4TK2srMzkh4n4fXJycq4FBQUBdAgVCCoqKt4dOXLkBrYdZ79qn3/+eUuhUPjYuNBW/fr1g6NFnQmhXC5PFIvFi1ka0Oo3btxo7Nevn4ClwWhbumHQrSOgm5qVldXfGOCCgoKOX758OZUQAt7STe6l0WgKWNBxJVuonvkJfCwvL8/kr5vPRwsLCz/KGPvMzMxNNEmPhlCvDg4Oi7RareDs2bPbJ06cSA1iwjFwmlwuj2GZBkEPHz78g7t3714tKSnZMn78+JfpoEYS0fQnZD/eEAgEzrAjGhoaIJSH+HvPnj1Bc+bMMYxrRFs2Ax3syZkzZyoKCwv1x66Pj8+g1NTUISz4cOT17dsXNuZPhJCxIpFowdSpU6ft2bOnH50U6AwcOPAy/m5sbFQ/fPgQ9iAqbhAwdlSr1d+ypsi5c+cezp0797tbt27dEggEvVesWOG8evVqEbtp9u3bt3TevHm7sGlwHKGUndUwR48ebXj33XerKY1PP/3UdenSpb1YwfFy4WaDLjU19dN169bFs+NDfhKJJJsBHPhDzaFWQUf56Ofn53fw4MGhxvgoEAhK6+rqdlDQOZ4+fTrL19dXjMbYVeXl5Q/GjBnzOo6hRYsWrdu1axeSyIYHJdgRERExLOOTkpK+jYqKWk4IUe/fv39nWFjYGNqBc0IgaH7IBSEF59DQULewsLBRAwYMsLexsemhVCqb6uvr/WfNmmUINnPeM9xxuvuagS4qKqoyKSkJ2Y+L3NgjwsPDF6SkpBhSe3g/c+bMVzl7BaaD+6JFi95h18jF6VYSQlBF0UAI+ZEQcgsbgp95+f777xtcXFz+3tDQcIoDJdY0Ydu2bREsaLg8NkqDHiQnJ69n44JlZWUPxGJxplarzdNqtbVcqGVCRkbGQta84eKl0I7YnGaBDsennZ0dYbUWADdz5sziwsLCbVqtNp/bkKz93RroIA+secyiRYtWtsJHNU4KCjpXhUKRy3pv3HESxjF7elVV1Raad4PQ+B5qfX29zt3dfeO1a9eQBhMkJSXteOeddx4Lv4wfP/71Cxcu5LLgNcWQpu2NVGs0Ax1MgmvXrn1BCFFw/V4ihMzWaDRreUcD7i38lQv/tBQywfzPMPOFEJqdCtxmQ2UOUkIaQgjMimGenp5vnzt3Tl/ihYcpflDzw1OcWQKbt4SjAQ0/WiqVyg4ePGgwb3gnhlmg4x95UDKTJ08u4gCHI5XNMtDmbYEO7VqK07F8fERBN76hoaGQVbVbtmz5OjIyMoLbueLVq1dvXLNmDTSV0efQoUM/SaVSMPgkAqRvvfXWB1988QVieoaH82B3MO6/yYY0iJgCOh8fn+VnzpzZxzgseruxtrY2nc0pM0YwNEZ74nSOWVlZu9hKHIZXbCWNvZWVVWBTU9N+ygDOCfMjhPx8+vTpdHqy4Pfo6OhkI1kLew8Pj+XFxcX6CD/AUVlZibIk2IawLc0CHejwvW3GUcJmNZZv7gjoHguyA3SWoaGhYYcOHYLhyAIETPiA81Id+/btO6+8vPwTR0dHfTUs/5k4ceLeoqIilDSBGfbe3t5vFBYWIkRieHgFnc0KBKDiZTLZnYKCgjvotGnTJtdp06YZnBFTQMcVFxxiA9jwzM+cOXOcNXJ5l2XaBbrPP//8r8uXL4dTpH+4mkEURNDCSbxullasqKgAYKZCk6SkpGwLDw83mCxcqhDHJluxYZ+YmPgBW9946tSpa5MmTZrJmSlmgQ72Z11dnTXLW0z4hx9+2Pfyyy8jK2PsquQTBV2zwk1MYMKECR/K5XJ6bQ7xG4/ExMTdkZGRBiORMh2L8PHxWajVanM4W0OvXerq6nJZA55X0GmflZWVymoM7phKIYR8Swh5fsOGDUujo6MN4QQzQdcsrANTwNbW9g2tVgvHAKGT9oBO5OHhsZjVPk1NTfXvv//+DF75V7MCiLS0tNLZs2fjNLjNPwmYuJgh7QZnY//+/UfYUjFOq8JuNlvTQV6BgYGVBQUFw0ePHk1zqXpxcoWZAD8feGaBDrzu0aOHN5tOhKZrVrjJNUR4II8Z3Gn48OFLL1++/B7fLV68eHHO7t27ETCmMR3M36u0tPQEuyheQWezY4oTCnYajPdBRUVFB9jaPlNAhzEaGxvjNBpNeVNT04v9+/cPYe8QYGL5+fnqgIAAaCbYL0hNiWQy2Uo2Z4h20MwuLi7/fPHFF8UqlQrZBWQGUGExqbS09G/s2gCaH3/88ZP6+voCjOvs7LyGjb8hFDJlypStubm5sCNhUAcrlcrdbFgJsbibN2/GYu52dnaD+vTps54FHOTi5+f3kVwu38tpRLM0HadxN7i7u/tnZmYGsHPAuktKSnZ5eHhE8YBnFuhAD1p86NCh58BHmpFwunLlSh6bukCAd9iwYShnhhFNz3fsiElpaWmJrEfJtcWlEwiEDdyOzs7OTgsMDDSUUvMqNxxlMtn6+Pj4N6nGhGCuXLmSamNjc7Vv376z+EFTU0AHewVPSxkCCG7SpEnJjCmA5vZz5sxZ/uWXXxqqI/jmAxcmgkGMMMIfpVLp2rS0tKC24nuUzoEDB5RhYWEQJHU2PJcsWfLJjh07YO/on9bmjt+2bNlCowOQCzRRR0D3P1i3u7v7gvz8/CD2RMJYV69eXeXm5raJsb9NAZ2tt7d3ON+sYnlpYWGhz0i41dbWfsMa2VydPa4h8nOlQzw9PWPOnj07nwqV87rgudF0CR1jiDEPlinoRDVGs93OFzb7tymga60/mLlixQqEVGCrssWH+g1VW1t7uCWbFRsiLCzMm6spFFlZWUmWL1/+/ubNm0e2BHDW/PDy8kJ0H3lYmA7YyI6EkCmJiYkrjZks/HVwjhq0JBwTajt2BHRQKggD+fn7+0fl5ORM4Aejc3JykOZK5IBnCuj0FcZKpfIgX3vS9dCMxPhHjx6VsIzjjjnkMI3F1CR5eXm7JRJJbyYYDDuMX7LcTJNhYO4TC2CelhAidnd3l2VnZ//ZmLBxDKanp/9Gg7YdAR1iU5GRkYqMjAwIH7bcD2zxIYKbS5Ysid++fbuvMRDh+FywYMESrgIaSxlMCAmSSqVLN27c6GSMydCqe/fu1Sxbtgze9EGuZJ9eDYTdCxqh4eHhs+Li4oYb4wFoxMfHqz7++GNU6eI0gQlD7a2Ogg60EBCXhIeHr0xOTnZj146Ntnnz5qncxSzPVjIS9IRDhXGrfKQZidEI/lpbW/83OCkQCFQlJSUHGLuB3XQgOsLT03NFbGzs9OPHj99ISkqCUSs3YngiWCiJjIyMbWxs1Cf/Qfvo0aPrlEolrjjqDXjsNBsbm6CoqKhANze3Hr169bK+ceNGfXZ29u2TJ08WI0MRHh7u17t3b4vS0tIdZ86cSW8tOLxgwYLbQqFQ5+Hh0Qu07t+/31RQUKBJTU0tbGxsRDiHBnD5ZUZ6zePv7x+OQDXScOirUCgelpSU/HzixAnEF3Fjv5Tb+QCNEyHE38bGZuK0adMm+Pr69qP9Kioqft26devlhw8fQqPiODRWTwfNABo+AoFg0pw5c3x8fX3t6Lzlcvn9lJSUKxyNrzlbl4IWLNXb2RKJJBA8Bn+rq6tP5ebmbmFyxE4eHh5viMXiWbw22zhnBDJFLDMAax82bBg2gl5W9vb2mrVr10Zyax4Jk6Jv377jeLJEvp6tE4RMA/39/Rfx+VhZWVmckZGxDscrmD2eEIKUFcIhPxNCyrlJswuk4AOYkLkYa2VlpdRqtTDGjV3MoEJBVmIAOltZWd3RarWXuMAthI4FIyOAbMFoQgiuLSIoeoujjbgXsgFDraysBFqtFg5GFQPwZsHhiIiIgp07d/4vIQTpI9BCHRtiT+j7HQdYY3VttPIXvICHjrmg731mLvAYEfyldi6dP8qxUQQBgdExkb1AWVAld4y19MUmjAtBoaTMhUfjBgcMjIuALZ8GZIF+4B0dF+tkAU7bwLZ+nlvTPzkgUbDQtYMOxQFOIqwBJhZOBX3mhhvPyogsKT5YWiiDM/CR48V5gI4WGuJf/AeBAGwtMQmMhj2Gyzu/cChvqTiRTxtC/M0Ibex4MAR1dAA+xoaHBwHjb5p/5fdtBjouCY1dDBroC+aBFhjcVhEluzbMCX2xRsybBRvf5MI6IVzMn+2HPvyS7pbMTloKDr6y825LFuAN+lLZ8cvIsaa22mBOdO0UB3iHudPiU/7vLcmSpYW1UH6A93qZdvUP6LQEuk77bgiDGEPxZvdHD1tz35r/1g269vGLbS1MSUl5k165RM2cWq3+0draWtWOimHzR+/CPbtBZ77wkNwON3Z7jssxw2N90hdxzJ/t76hnN+jMF4bRgDIXLEe2A56yMUfM/BGfkZ7doDNfkEJvb+8F/Og7FyxHmAH1fO35OoD5M+liPbtBZ77AhKGhoTPY6hyk+QYPHvzR3bt3jQXLzR/pGevZDTrzBSocNGhQcE1NDe5s6B8uv4oKDZobNZ/6M9yzq4POq6SkZL+9vb3+bsOvv/7auGnTpg2pqalP40vmAhcXl0B6kw15XS8vL9QU4itG/wmfRTN7W3R10CEaHyoQCPQ1d42NjcgAIMWGz5J1thGPYOlknU6H8i+CGjUvL695qJzq9lpbx2NXBx2qQ5Bmwb+oMEaIAqmb1rIHZu9QIx3xVYLTSJK3UFP4JMd6Zmh1ddD9uwXhq9FovtZoNKR///5LjdQU/rvn97scvxt0HROLvsZsz549iqioKJSh4yZXW/ndjo34DPTuBl3HhOhVW1uLjwcl3L17F3dt2Ys5HaP8DPfuBl3HhAtHBtcyUTL1NJyXjs32d9K7G3QdEwTKmWgdW3ee1URe/j+RFHPchjfb3wAAAABJRU5ErkJggg==",Ae.alt="Maptoolkit Logo",Se.appendChild(Ae),this._container.appendChild(Se),this._container}onRemove(){this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._map=void 0}}function Lf(Ke,re){const Se=new URL(ei.staticmapHost);return Se.searchParams.set("api_key",ei.apiKey),Se.searchParams.set("maptype",`${Ke}-${re}`),Se.searchParams.set("size","166x166"),Se.searchParams.set("center","47.329,12.787"),Se.searchParams.set("zoom","12"),Se.toString()}const Xn={TERRAIN:"maptoolkit://styles/toursprung/terrain",LIGHT:"maptoolkit://styles/toursprung/light",DARK:"maptoolkit://styles/toursprung/dark",CITY:"maptoolkit://styles/citymaps2go/Ulmon",GREEN:"maptoolkit://styles/toursprung/printmaps-green",WINTER:"maptoolkit://styles/toursprung/terrainwinter"};function Rf(Ke){if(Ke){if(Ke.type==="line")return Ke.paint?.["line-opacity"]<=.001;if(Ke.type==="fill")return Ke.paint?.["fill-opacity"]<=.001;if(Ke.type==="symbol")return Ke.layout?.["icon-image"]?Ke.paint?.["icon-opacity"]<=.001:Ke.paint?.["text-opacity"]<=.001;if(Ke.type==="circle")return Ke.paint?.["circle-opacity"]<=.001}return!1}function ld(Ke){if(Ke){let re=0;for(const Se in Ke._vectorTileFeature)typeof Ke._vectorTileFeature[Se]=="number"&&(re+=Ke._vectorTileFeature[Se]);return re}}function Ff(Ke,re){if(!Ke||!re)return!1;const Se=Ke.id===void 0?ld(Ke):Ke.id,Ae=re.id===void 0?ld(re):re.id;return Se===Ae}const Bf={maxPitch:75,center:{lng:11.40037,lat:47.26816},zoom:12};let cd=class extends nt.Map{constructor(re){re?.apiKey&&(ei.apiKey=re.apiKey),typeof re?.locale=="string"&&(ei.locale=re?.locale),re=Object.assign({style:Xn.TERRAIN},Bf,re);const Se=document.createElement("div");Se.classList.add("maptoolkit-map"),Se.style.width=Se.style.height="100%",super({...re,container:Se,attributionControl:!1,maplibreLogo:!1}),ei.pixelRatio=this.getPixelRatio(),this._locale=Object.assign({},Df(),typeof re.locale=="object"?re.locale:null),re.attributionControl!==!1&&this.addControl(new od(re.attributionControl)),re.logoControl!==!1&&this.addControl(new ad(re.logoControl));let Ae;this.on("mousemove",$e=>{const Ne=[[$e.point.x-3,$e.point.y-3],[$e.point.x+3,$e.point.y+3]],D=this._getFeatureAtPoint(Ne);if(D?.layer?.metadata){if(D.layer.metadata["maptoolkit:clickable"]===!0){if(this._canvasContainer.style.cursor="pointer",!Ff(Ae,D)){if(Ae){const Te=$e;Te.feature=Ae,this.fire("feature.mouseout",Te),Ae=void 0}const c=$e;c.feature=Ae=D,this.fire("feature.mouseover",c)}}else if(this._canvasContainer.style.cursor="",Ae){const c=$e;c.feature=Ae,this.fire("feature.mouseout",c),Ae=void 0}}}),this.on("click",$e=>{const Ne=[[$e.point.x-3,$e.point.y-3],[$e.point.x+3,$e.point.y+3]],D=this._getFeatureAtPoint(Ne);if(D?.layer?.metadata&&D.layer.metadata["maptoolkit:clickable"]===!0){const c=$e;c.feature=D,this.fire("feature.click",c)}}),re.container&&this.setContainer(re.container)}_getFeatureAtPoint(re){return this.queryRenderedFeatures(re).filter(Se=>!Rf(Se.layer))[0]}setContainer(re){if(typeof re=="string"){const Se=document.getElementById(re);Se?this._parent=Se:console.error(`Container with id "${re}" not found.`)}else re instanceof HTMLElement&&(this._parent=re);return this._parent?(this._parent.contains(this._container)||(this._parent.innerHTML=""),this._parent.appendChild(this._container)&&this.resize()):console.error("Invalid type: 'container' must be a String or HTMLElement."),this}remove(){return this._container.remove(),this._parent=void 0,this}setStyle(re,Se,Ae){return Ae!==!0&&this.fire("style.set",{style:re}),super.setStyle(re,Se)}_getUIString(re,Se){try{const Ae=super._getUIString(re);return Se&&typeof Se=="object"?Ae.replace(/{(.*?)}/g,($e,Ne)=>Ne in Se?Se[Ne]:$e):Ae}catch(Ae){return console.warn(Ae),""}}addControl(re,Se){return super.addControl(re,Se),this}_setupContainer(){super._setupContainer();const re=document.createElement("div");re.classList.add("maplibregl-ctrl-top-center"),this._controlContainer.insertBefore(re,this._controlPositions["top-right"]),this._controlPositions["top-center"]=re;const Se=document.createElement("div");Se.classList.add("maplibregl-ctrl-bottom-center"),this._controlContainer.insertBefore(Se,this._controlPositions["bottom-right"]),this._controlPositions["bottom-center"]=Se}};const ud={type:"raster-dem",tiles:[`${ei.dataconnectorCdnHost}/maptoolkit/terrainrgb/{z}/{x}/{y}.webp`],encoding:"terrarium",minzoom:5,maxzoom:12},Iu={knobSize:16,sliderSize:52,autoHide:!1};class Eu{constructor(re){this.options=Object.assign(Iu,re),this._active=!1}getDefaultPosition(){return"bottom-left"}onAdd(re){this._map=re;const Se=this.options.knobSize||Iu.knobSize||16,Ae=this.options.sliderSize||Iu.sliderSize||52;this._container=document.createElement("div"),this._container.classList.add("maplibregl-ctrl","maptoolkit-ctrl","maptoolkit-ctrl-pitch"),this._container.style.height=`${Ae}px`;const $e=document.createElement("div");$e.classList.add("maptoolkit-ctrl-pitch-slide");const Ne=document.createElement("div");Ne.classList.add("maptoolkit-ctrl-pitch-knob"),Ne.title=re._getUIString("PitchControl.ChangePitch"),Ne.style.width=Ne.style.height=`${Se}px`,Ne.style.margin=`-${Se/2}px calc(50% - ${Se/2}px)`;let D=0,c=re.getPitch()/re.getMaxPitch()*(Ae-Se),Te=c;this._onMouseDown=ct=>(this._active=!0,D=ct instanceof TouchEvent?ct.touches[0]?.pageY:ct.pageY,c=re.getPitch()/re.getMaxPitch()*(Ae-Se),ct.stopPropagation(),ct.preventDefault(),!1),this._onMouseMove=ct=>{if(this._active){const Si=D-(ct instanceof TouchEvent?ct.touches[0]?.pageY:ct.pageY);Te=Math.max(0,Math.min(Ae-Se,c+Si)),re.setPitch(Te/(Ae-Se)*re.getMaxPitch())}},this._onMouseUp=()=>{this._active=!1,c=Te},Ne.addEventListener("mousedown",this._onMouseDown),Ne.addEventListener("touchstart",this._onMouseDown),window.addEventListener("mousemove",this._onMouseMove),window.addEventListener("touchmove",this._onMouseMove),window.addEventListener("mouseup",this._onMouseUp),window.addEventListener("touchend",this._onMouseUp);let _t;return this._onPitch=()=>{Ne.style.top=`${Ae-re.getPitch()/re.getMaxPitch()*Ae}px`,clearTimeout(_t),this.options.autoHide&&(this.isHidden()&&re.transform.pitch>0?this.show():!this.isHidden()&&re.transform.pitch===0&&(_t=setTimeout(()=>this.hide(),400)))},re.on("pitch",this._onPitch),this._onPitch({}),this._container.appendChild($e),this._container.appendChild(Ne),this._container}onRemove(){this._onMouseUp&&(window.removeEventListener("mousedown",this._onMouseUp),window.removeEventListener("touchstart",this._onMouseUp)),this._onMouseMove&&(window.removeEventListener("mousemove",this._onMouseMove),window.removeEventListener("touchmove",this._onMouseMove)),this._onMouseUp&&(window.removeEventListener("mouseup",this._onMouseUp),window.removeEventListener("touchend",this._onMouseUp)),this._map&&this._onPitch&&this._map.off("pitch",this._onPitch),this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._map=void 0}isActive(){return this._active}isHidden(){return this._container?this._container.classList.contains("maptoolkit-ctrl-pitch-hide"):!0}show(){return this._container&&(this._container.style.height=`${this.options.sliderSize}px`,this._container.classList.remove("maptoolkit-ctrl-pitch-hide")),this}hide(){return this._container&&(this._container.style.height="0px",this._container.classList.add("maptoolkit-ctrl-pitch-hide")),this}}const Of={};class Au{constructor(re){this.options=Object.assign(Of,re)}getDefaultPosition(){return"bottom-left"}onAdd(re){this._map=re,this._container=document.createElement("div"),this._container.classList.add("maplibregl-ctrl","maptoolkit-ctrl","maptoolkit-ctrl-compass");const Se=document.createElement("div");Se.classList.add("maptoolkit-ctrl-compass-img");const Ae=document.createElement("div");Ae.classList.add("maptoolkit-ctrl-compass-label"),Ae.title=re._getUIString("CompassControl.ResetBearing"),Ae.addEventListener("click",()=>re.resetNorth());const $e=document.createElement("div");$e.classList.add("maptoolkit-ctrl-compass-arrow-left"),$e.title=re._getUIString("CompassControl.RotateLeft"),$e.addEventListener("click",()=>re.easeTo({bearing:re.getBearing()+90}));const Ne=document.createElement("div");return Ne.classList.add("maptoolkit-ctrl-compass-arrow-right"),Ne.title=re._getUIString("CompassControl.RotateRight"),Ne.addEventListener("click",()=>re.easeTo({bearing:re.getBearing()-90})),this._onRotate=()=>{let D=(re.transform.bearing+360)%360;Se.style.transform=`rotate(${D*-1}deg)`,D<0&&(D+=360),D>315||D<=45?Ae.innerText="N":D>45&&D<=135?Ae.innerText="E":D>135&&D<=225?Ae.innerText="S":D>225&&D<=315&&(Ae.innerText="W")},re.on("rotate",this._onRotate),this._onRotate({}),this._container.appendChild(Se),this._container.appendChild($e),this._container.appendChild(Ae),this._container.appendChild(Ne),this._container}onRemove(){this._map&&this._onRotate&&this._map.off("rotate",this._onRotate),this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._map=void 0}}const Vf={pitch:60,globe:!1};class Du{constructor(re){this.options=Object.assign(Vf,re),this._active=!1,this._enabled=!1,this._loaded=!1}getDefaultPosition(){return"bottom-left"}onAdd(re){this._map=re,this._container=document.createElement("div"),this._container.classList.add("maplibregl-ctrl","maplibregl-ctrl-group","maptoolkit-ctrl","maptoolkit-ctrl-terrain");const Se=document.createElement("button");Se.title=re._getUIString("TerrainControl.ToggleTilt"),Se.addEventListener("click",()=>{this._active||(this._enabled?this.disable():this.enable())}),this._container.appendChild(Se);function Ae(){Se.innerText=re.transform.pitch>0?"2D":"3D"}return Ae(),this._onPitch=$e=>{this._active||(this._active=!0),re.transform.pitch>0&&!this._enabled?(Ae(),this._enabled=!0,$e.originalEvent instanceof MouseEvent?(this._update(),this._loaded=!0):this._loaded?this._update():re.once("pitchend",()=>{this._update(),this._loaded=!0})):re.transform.pitch==0&&this._enabled&&(Ae(),this._update(),this._enabled=!1)},this._onPitchEnd=()=>{this._active=!1},this._onStyleSet=()=>{this._map&&this._map.once("styledata",$e=>{typeof this._projection>"u"&&(this._projection=$e.target.getProjection()||{type:"mercator"}),this._update()})},re.on("pitch",this._onPitch),re.on("pitchend",this._onPitchEnd),re.on("style.set",this._onStyleSet),this._onStyleSet({target:re}),this._container}onRemove(){this.disable(),this._map&&(this._onPitch&&this._map.off("pitch",this._onPitch),this._onPitchEnd&&this._map.off("pitchend",this._onPitchEnd),this._onStyleSet&&this._map.off("style.set",this._onStyleSet)),this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._map=void 0}_update(){this._terrain(this._enabled),this.options.globe&&this._globe(this._enabled)}_terrain(re){this._map&&(this._map.style._loaded?re===!0?(this._map.getSource("maptoolkit-terrain")||this._map.addSource("maptoolkit-terrain",ud),this._map.setTerrain({source:"maptoolkit-terrain"})):this._map.setTerrain(null):this._map.once("styledata",()=>this._terrain(re)))}_globe(re){this._map&&(this._map.style._loaded?this._projection&&this._projection.type!=="globe"&&(re===!0?this._map.setProjection({type:"globe"}):this._map.setProjection(this._projection)):this._map.once("styledata",()=>this._globe(re)))}enable(){return this._map&&!this._enabled&&this._map.transform.pitch===0&&this._map.easeTo({pitch:this.options.pitch}),this}disable(){return this._map&&this._enabled&&this._map.transform.pitch>0&&this._map.easeTo({pitch:0}),this}isEnabled(){return this._enabled}isActive(){return this._active}isLoaded(){return this._loaded}}const Nf={navigationControl:{showCompass:!1},pitchControl:{autoHide:!0}};class jf{constructor(re){this.options=Object.assign(Nf,re),this._navigationControl=new nt.NavigationControl(this.options.navigationControl),this.options.terrainControl!==!1&&(this._terrainControl=new Du(this.options.terrainControl)),this.options.pitchControl!==!1&&(this._pitchControl=new Eu(this.options.pitchControl)),this.options.compassControl!==!1&&(this._compassControl=new Au(this.options.compassControl))}getDefaultPosition(){return"bottom-right"}onAdd(re){return this._container=document.createElement("div"),this._container.classList.add("maptoolkit-ctrl-navigation"),this._container.appendChild(this._navigationControl.onAdd(re)),this._compassControl instanceof Au&&this._container.appendChild(this._compassControl.onAdd(re)),this._pitchControl instanceof Eu&&this._container.appendChild(this._pitchControl.onAdd(re)),this._terrainControl instanceof Du&&this._container.appendChild(this._terrainControl.onAdd(re)),this._container}onRemove(){this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._map=void 0}}function hd(Ke){let re=0;for(let Se=0;Se<Ke.length;Se++)re+=Ke.charCodeAt(Se);return re.toString(16)}const dd={styles:[{id:"Terrain",value:Xn.TERRAIN},{id:"Light",value:Xn.LIGHT},{id:"Dark",value:Xn.DARK},{id:"City",value:Xn.CITY},{id:"Green",value:Xn.GREEN},{id:"Winter",value:Xn.WINTER}]};class Uf{constructor(re){if(console.log(dd),this.options=Object.assign({},dd,re),this.options.styles){this.options.styles=this.options.styles.filter(Se=>Se.id&&Se.value);for(const Se of this.options.styles)if(!Se.image&&typeof Se.value=="string"&&/^maptoolkit:\/\/styles\/[A-z0-9_-]+\/[A-z0-9_-]+$/.test(Se.value)){const[Ae,$e]=Se.value.split("/").slice(-2);Se.image=Lf(Ae,$e)}}console.log(this.options)}getDefaultPosition(){return"bottom-left"}onAdd(re){this._map=re,this._container=document.createElement("div"),this._container.classList.add("maplibregl-ctrl","maplibregl-ctrl-group","maptoolkit-ctrl","maptoolkit-ctrl-style","maptoolkit-ctrl-style-bottom-left"),this._groups=document.createElement("div"),this._groups.classList.add("maplibregl-ctrl-group","maptoolkit-ctrl-style-groups");const Se=document.createElement("button");Se.classList.add("maptoolkit-ctrl-style-close"),Se.addEventListener("click",()=>this.close()),this._groups.appendChild(Se);const Ae=document.createElement("button");Ae.classList.add("maptoolkit-ctrl-style-current");const $e=document.createElement("div");$e.classList.add("maptoolkit-ctrl-style-current-image"),Ae.appendChild($e);const Ne=document.createElement("label");Ne.classList.add("maptoolkit-ctrl-style-current-name"),Ae.appendChild(Ne);const D=(({id:Te,styles:_t,onClick:ct,isCollapsed:Si})=>{const dr=document.createElement("div");dr.classList.add("maptoolkit-ctrl-style-group"),Si&&dr.classList.add("maptoolkit-ctrl-style-group-collapsed");const $t=document.createElement("h2");$t.classList.add("maptoolkit-ctrl-style-group-name"),$t.textContent=re._getUIString(`StyleControl.Group.${Te}`)||Te,dr.appendChild($t);const tr=document.createElement("ul");return tr.classList.add("maptoolkit-ctrl-style-group-list"),_t.forEach(He=>{const pe=document.createElement("li");pe.classList.add("maptoolkit-ctrl-style-group-list-item"),this._map?._styleId===hd(typeof He.value=="string"?He.value:JSON.stringify(He.value))&&(pe.classList.add("maptoolkit-ctrl-style-group-list-item-active"),He.image&&$e.style.setProperty("background-image",`url(${He.image})`),Ne.textContent=re._getUIString(`StyleControl.Style.${He.id}`)||He.id);const pr=document.createElement("button"),bt=document.createElement("div");bt.classList.add("maptoolkit-ctrl-style-group-list-item-image"),He.image&&bt.style.setProperty("background-image",`url(${He.image})`),pr.appendChild(bt);const mt=document.createElement("label");mt.classList.add("maptoolkit-ctrl-style-group-list-item-name"),mt.textContent=re._getUIString(`StyleControl.Style.${He.id}`)||He.id,pr.appendChild(mt),pr.addEventListener("click",kr=>{typeof ct=="function"&&ct({originalEvent:kr,style:He})}),pe.appendChild(pr),tr.appendChild(pe)}),dr.appendChild(tr),dr})({id:"Styles",styles:this.options.styles,onClick:Te=>{const _t=Te.originalEvent.target.closest("ul"),ct=Te.originalEvent.target.parentElement;[..._t.children].forEach(Si=>{Si===ct?Si.classList.add("maptoolkit-ctrl-style-group-list-item-active"):Si.classList.remove("maptoolkit-ctrl-style-group-list-item-active")}),Te.style&&(this._map&&Te.style.value&&this._map._styleId!==hd(typeof Te.style.value=="string"?Te.style.value:JSON.stringify(Te.style.value))&&this._map.setStyle(Te.style.value),$e.style.removeProperty("background-image"),Te.style.image&&$e.style.setProperty("background-image",`url(${Te.style.image})`),Ne.textContent=re._getUIString(`StyleControl.Style.${Te.style.id}`)||Te.style.id)}});this._groups.appendChild(D);const c=document.createElement("button");return c.classList.add("maptoolkit-ctrl-style-expand"),c.textContent=re._getUIString("StyleControl.Group.Layers"),c.addEventListener("click",()=>{D.classList.remove("maptoolkit-ctrl-style-group-collapsed"),this._resize&&this._resize()}),this._groups.appendChild(c),Ae.addEventListener("click",()=>{this._groups?.classList.contains("maptoolkit-ctrl-style-groups-active")?this.close():this.open()}),this._resize(),this._map.on("resize",this._resize.bind(this)),this._container.appendChild(Ae),this._container.appendChild(this._groups),this._container}onRemove(){this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._map=void 0}open(){if(this._groups){const re=[...this._groups.querySelectorAll(".maptoolkit-ctrl-style-group")];for(const Se of re)Se.querySelectorAll(".maptoolkit-ctrl-style-group-list-item-active").length||Se.classList.add("maptoolkit-ctrl-style-group-collapsed");this._groups.classList.add("maptoolkit-ctrl-style-groups-active"),this._container&&this._container.parentElement&&(this._container.parentElement.style.zIndex="99"),this._resize&&this._resize()}}close(){this._groups&&(this._groups.classList.remove("maptoolkit-ctrl-style-groups-active"),this._container&&this._container.parentElement&&(this._container.parentElement.style.zIndex=""))}_resize(){if(this._map&&this._container){const re=this._map.getContainer().getBoundingClientRect(),Se=this._container.getBoundingClientRect(),Ae={top:Se.top-re.top,bottom:re.bottom-Se.bottom,left:Se.left-re.left,right:re.right-Se.right},$e=window.getComputedStyle(this._container);let Ne=re.width,D=re.height;for(const c in this._map._controlPositions)if(this._map._controlPositions[c]?.contains(this._container)){/^top/.test(c)&&(D-=Ae.top+parseFloat($e.marginTop)),/^bottom/.test(c)&&(D-=Ae.bottom+parseFloat($e.marginBottom)),/left$/.test(c)&&(Ne-=Ae.left+parseFloat($e.marginLeft)),/right$/.test(c)&&(Ne-=Ae.right+parseFloat($e.marginRight));break}window.matchMedia("only screen and (max-width: 768px)").matches||(Ne-=Se.width),this._groups&&(this._groups.style.setProperty("max-width",`${Ne}px`),this._groups.style.setProperty("max-height",`${D}px`))}}}const Gf={range:10,type:"foot",fitBounds:!0};class qf{constructor(re){this.options=Object.assign({},Gf,re),this._id=`maptoolkit-ctrl-isochrone-${Math.random().toString(36).substring(2,9)}`,this._dragging=!1,this._container=document.createElement("div"),this._container.classList.add("maplibregl-ctrl","maplibregl-ctrl-group","maptoolkit-ctrl","maptoolkit-ctrl-isochrone");const Se=document.createElement("div");Se.classList.add("maptoolkit-ctrl-isochrone-chronee",`maptoolkit-ctrl-isochrone-chronee-${this.options.type}`),Se.setAttribute("draggable","true"),Se.addEventListener("dragstart",Ne=>{const D=Ne;D.dataTransfer&&(D.dataTransfer.setData("dragged","true"),D.dataTransfer.setData("maptoolkit-ctrl-isochrone",this._id)),this._dragging=!0}),Se.addEventListener("dragend",()=>{this._dragging=!1});const Ae=document.createElement("button");Ae.classList.add("maptoolkit-ctrl-isochrone-chronee-remove"),Ae.addEventListener("click",()=>{this.removeFromMap()});const $e=this._tooltip=document.createElement("div");this._tooltip.classList.add("maplibregl-ctrl-group","maptoolkit-ctrl-isochrone-tooltip"),this._container.appendChild(Ae),this._container.appendChild(Se),this._container.appendChild($e),this._onDrag=Ne=>{Ne.preventDefault()},this._onDrop=Ne=>{if(Ne.preventDefault(),this._map&&this._container){const D=Ne;if(D.dataTransfer?.getData("maptoolkit-ctrl-isochrone")===this._id){const c=this._map.unproject({x:D.offsetX,y:D.offsetY});this.addToMap(c)}}},this._onStyleChange=()=>{this._map&&this._map.once("idle",()=>{this._marker&&this._marker._map===this._map&&this._addPolygon(this._marker.getLngLat())})}}getDefaultPosition(){return"bottom-right"}onAdd(re){this._map instanceof cd&&this._map!==re&&this.onRemove(),this._map=re;try{this.options.range&&(this._tooltip.innerText=re._getUIString(`IsochroneControl.Tooltip.${this.options.type}`,{range:this.options.range.toString()}))}catch(Ae){this._tooltip.remove(),console.warn(Ae)}const Se=re.getCanvas();return Se.addEventListener("dragover",this._onDrag),Se.addEventListener("dragenter",this._onDrag),Se.addEventListener("dragleave",this._onDrag),Se.addEventListener("drop",this._onDrop),re.on("style.set",this._onStyleChange),this._container}addToMap(re){this._addMarker(re),this._addPolygon(re),this._container&&this._container.classList.add("maptoolkit-ctrl-isochrone-active")}removeFromMap(){this._removeMarker(),this._removePolygon(),this._container&&this._container.classList.remove("maptoolkit-ctrl-isochrone-active")}_addMarker(re){if(this._map&&(this._removeMarker(),re)){const Se=document.createElement("div"),Ae=document.createElement("div");Ae.classList.add("maptoolkit-ctrl-isochrone-chronee",`maptoolkit-ctrl-isochrone-chronee-${this.options.type}`);const $e=document.createElement("button");$e.classList.add("maptoolkit-ctrl-isochrone-chronee-remove"),$e.addEventListener("click",()=>{this.removeFromMap()}),Se.appendChild($e),Se.appendChild(Ae),this._marker=new nt.Marker({element:Se,anchor:"center",draggable:!0}),this._marker.on("dragend",Ne=>this._addPolygon(Ne.target.getLngLat())),this._marker.on("click",Ne=>Ne.preventDefault()),this._marker.setLngLat(re).addTo(this._map)}}_removeMarker(){this._marker&&this._marker.remove()}_addPolygon(re){if(this._removePolygon(),ei.apiKey&&this._map&&re){const Se=this._map,Ae=new URL("isochrone",ei.routingHost);Ae.pathname="isochrone",Ae.searchParams.set("api_key",ei.apiKey.toString()),this.options.type&&Ae.searchParams.set("routeType",this.options.type),this.options.range&&Ae.searchParams.set("time",this.options.range.toString());const $e=Array.isArray(re)?[re[1],re[0]]:"lat"in re?[re.lat,"lon"in re?re.lon:re.lng]:void 0;$e&&(Ae.searchParams.set("point",$e.join(",")),this._abortController&&this._abortController.abort(),this._abortController=new AbortController,fetch(Ae.toString(),{signal:this._abortController.signal}).then(Ne=>Ne.json()).then(Ne=>{this._removePolygon();const D=[Ne.map(c=>[c[1],c[0]])];if(Se.addSource(this._id,{type:"geojson",data:{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:D}}]}}),Se.addLayer({id:`${this._id}-fill`,type:"fill",source:this._id,paint:{"fill-color":"#aaaafa","fill-opacity":.2}}),Se.addLayer({id:`${this._id}-line`,type:"line",source:this._id,paint:{"line-color":"#aaaafa","line-opacity":.8,"line-width":1.4}}),this.options.fitBounds){const c=new nt.LngLatBounds,Te=Object.assign({padding:100},this.options.fitBounds);D.forEach(_t=>_t.forEach(ct=>c.extend(ct))),Se.fitBounds(c,Te)}}).catch(Ne=>{Ne.name!=="AbortError"&&console.error(Ne)}))}}_removePolygon(){this._map&&this._container&&(this._map.getLayer(`${this._id}-fill`)&&this._map.removeLayer(`${this._id}-fill`),this._map.getLayer(`${this._id}-line`)&&this._map.removeLayer(`${this._id}-line`),this._map.getSource(this._id)&&this._map.removeSource(this._id))}onRemove(){if(this.removeFromMap(),this._map){const re=this._map.getCanvas();re.removeEventListener("dragover",this._onDrag),re.removeEventListener("dragenter",this._onDrag),re.removeEventListener("dragleave",this._onDrag),re.removeEventListener("drop",this._onDrop),this._map.off("style.set",this._onStyleChange)}this._container?.parentNode&&this._container.parentNode.removeChild(this._container),this._map=void 0}}const Zf=Yt.Map,$f=Yt.NavigationControl,Hf=Yt.AttributionControl,Wf=Yt.LogoControl,Xf=Yt.TerrainControl,Yf=Yt.config,{Hash:Kf,Style:Jf,Event:Qf,AJAXError:em,createTileMesh:tm}=Yt,im=Af,rm=Yt.addProtocol,nm=Yt.removeProtocol,sm=Yt.addSourceType,om=Yt.prewarm,am=Yt.clearPrewarmedResources,lm=Yt.getVersion,cm=Yt.getWorkerCount,um=Yt.setWorkerCount,hm=Yt.getMaxParallelImageRequests,dm=Yt.setMaxParallelImageRequests,pm=Yt.getWorkerUrl,fm=Yt.setWorkerUrl,mm=Yt.setRTLTextPlugin,gm=Yt.getRTLTextPluginStatus,_m=Yt.importScriptInWorkers;ke.AJAXError=em,ke.AttributionControl=od,ke.AttributionControlMLGL=Hf,ke.BoxZoomHandler=nt.BoxZoomHandler,ke.CanvasSource=nt.CanvasSource,ke.CompassControl=Au,ke.Config=nd,ke.CooperativeGesturesHandler=nt.CooperativeGesturesHandler,ke.DoubleClickZoomHandler=nt.DoubleClickZoomHandler,ke.DragPanHandler=nt.DragPanHandler,ke.DragRotateHandler=nt.DragRotateHandler,ke.EdgeInsets=nt.EdgeInsets,ke.Event=Qf,ke.Evented=nt.Evented,ke.FullscreenControl=nt.FullscreenControl,ke.GeoJSONSource=nt.GeoJSONSource,ke.GeolocateControl=nt.GeolocateControl,ke.GlobeControl=nt.GlobeControl,ke.Hash=Kf,ke.ImageSource=nt.ImageSource,ke.IsochroneControl=qf,ke.KeyboardHandler=nt.KeyboardHandler,ke.LngLat=nt.LngLat,ke.LngLatBounds=nt.LngLatBounds,ke.LogoControl=ad,ke.LogoControlMLGL=Wf,ke.Map=cd,ke.MapMLGL=Zf,ke.MapMouseEvent=nt.MapMouseEvent,ke.MapTouchEvent=nt.MapTouchEvent,ke.MapWheelEvent=nt.MapWheelEvent,ke.Marker=nt.Marker,ke.MercatorCoordinate=nt.MercatorCoordinate,ke.NavigationControl=jf,ke.NavigationControlMLGL=$f,ke.PitchControl=Eu,ke.Point=nt.Point,ke.Popup=nt.Popup,ke.RasterDEMTileSource=nt.RasterDEMTileSource,ke.RasterTileSource=nt.RasterTileSource,ke.STYLES=Xn,ke.ScaleControl=nt.ScaleControl,ke.ScrollZoomHandler=nt.ScrollZoomHandler,ke.Style=Jf,ke.StyleControl=Uf,ke.TERRAIN=ud,ke.TerrainControl=Du,ke.TerrainControlMLGL=Xf,ke.TwoFingersTouchPitchHandler=nt.TwoFingersTouchPitchHandler,ke.TwoFingersTouchRotateHandler=nt.TwoFingersTouchRotateHandler,ke.TwoFingersTouchZoomHandler=nt.TwoFingersTouchZoomHandler,ke.TwoFingersTouchZoomRotateHandler=nt.TwoFingersTouchZoomRotateHandler,ke.VectorTileSource=nt.VectorTileSource,ke.VideoSource=nt.VideoSource,ke.addProtocol=rm,ke.addSourceType=sm,ke.clearPrewarmedResources=am,ke.config=ei,ke.configMLGL=Yf,ke.createTileMesh=tm,ke.getMaxParallelImageRequests=hm,ke.getRTLTextPluginStatus=gm,ke.getVersion=lm,ke.getWorkerCount=cm,ke.getWorkerUrl=pm,ke.importScriptInWorkers=_m,ke.locale=sd,ke.prewarm=om,ke.removeProtocol=nm,ke.setMaxParallelImageRequests=dm,ke.setRTLTextPlugin=mm,ke.setWorkerCount=um,ke.setWorkerUrl=fm,ke.version=im}));
|
|
817
|
+
//# sourceMappingURL=maptoolkit.js.map
|