@datosgeo-atdt/geo-ui 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,823 @@
1
+ (function(Br,Ar){typeof exports=="object"&&typeof module<"u"?Ar(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],Ar):(Br=typeof globalThis<"u"?globalThis:Br||self,Ar(Br.GeoUI={},Br.jsxRuntime,Br.React))})(this,(function(Br,Ar,Ln){"use strict";var rx=Object.defineProperty;var nx=(Br,Ar,Ln)=>Ar in Br?rx(Br,Ar,{enumerable:!0,configurable:!0,writable:!0,value:Ln}):Br[Ar]=Ln;var vt=(Br,Ar,Ln)=>nx(Br,typeof Ar!="symbol"?Ar+"":Ar,Ln);function Ad(F){return F&&F.__esModule&&Object.prototype.hasOwnProperty.call(F,"default")?F.default:F}var pc={exports:{}};/**
2
+ * MapLibre GL JS
3
+ * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.15.0/LICENSE.txt
4
+ */var ym=pc.exports,Dd;function xm(){return Dd||(Dd=1,(function(F,C){(function(D,$){F.exports=$()})(ym,(function(){var D={},$={};function Q(P,c,le){if($[P]=le,P==="index"){var Pe="var sharedModule = {}; ("+$.shared+")(sharedModule); ("+$.worker+")(sharedModule);",Be={};return $.shared(Be),$.index(D,Be),typeof window<"u"&&D.setWorkerUrl(window.URL.createObjectURL(new Blob([Pe],{type:"text/javascript"}))),D}}Q("shared",["exports"],(function(P){function c(r,e,i,s){return new(i||(i=Promise))((function(o,u){function h(y){try{g(s.next(y))}catch(v){u(v)}}function f(y){try{g(s.throw(y))}catch(v){u(v)}}function g(y){var v;y.done?o(y.value):(v=y.value,v instanceof i?v:new i((function(w){w(v)}))).then(h,f)}g((s=s.apply(r,e||[])).next())}))}function le(r,e){this.x=r,this.y=e}function Pe(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Be,Ne;typeof SuppressedError=="function"&&SuppressedError,le.prototype={clone(){return new le(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),o=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=o,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:le},le.convert=function(r){if(r instanceof le)return r;if(Array.isArray(r))return new le(+r[0],+r[1]);if(r.x!==void 0&&r.y!==void 0)return new le(+r.x,+r.y);throw new Error("Expected [x, y] or {x, y} point format")};var Ye=(function(){if(Ne)return Be;function r(e,i,s,o){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*(o-i)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=i,this.p2x=s,this.p2y=o}return Ne=1,Be=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,o=0;o<8;o++){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,o=0;o<20&&(u=this.sampleCurveX(s),!(Math.abs(u-e)<i));o++)e>u?f=s:g=s,s=.5*(g-f)+f;return s},solve:function(e,i){return this.sampleCurveY(this.solveCurveX(e,i))}},Be})(),rt=Pe(Ye);let Ct,Je;function ge(){return Ct==null&&(Ct=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),Ct}function Xt(){if(Je==null&&(Je=!1,ge())){const e=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(e){for(let s=0;s<25;s++){const o=4*s;e.fillStyle=`rgb(${o},${o+1},${o+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){Je=!0;break}}}return Je||!1}var zt=1e-6,st=typeof Float32Array<"u"?Float32Array:Array;function fi(){var r=new st(9);return st!=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 Qt(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 Mi(){var r=new st(3);return st!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r}function dt(r){var e=r[0],i=r[1],s=r[2];return Math.sqrt(e*e+i*i+s*s)}function he(r,e,i){var s=new st(3);return s[0]=r,s[1]=e,s[2]=i,s}function pe(r,e,i){return r[0]=e[0]+i[0],r[1]=e[1]+i[1],r[2]=e[2]+i[2],r}function De(r,e,i){return r[0]=e[0]*i,r[1]=e[1]*i,r[2]=e[2]*i,r}function Oe(r,e,i){var s=e[0],o=e[1],u=e[2],h=i[0],f=i[1],g=i[2];return r[0]=o*g-u*f,r[1]=u*h-s*g,r[2]=s*f-o*h,r}var je,at=dt;function jt(r,e,i){var s=e[0],o=e[1],u=e[2],h=e[3];return r[0]=i[0]*s+i[4]*o+i[8]*u+i[12]*h,r[1]=i[1]*s+i[5]*o+i[9]*u+i[13]*h,r[2]=i[2]*s+i[6]*o+i[10]*u+i[14]*h,r[3]=i[3]*s+i[7]*o+i[11]*u+i[15]*h,r}function $t(){var r=new st(4);return st!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r[3]=1,r}function ei(r,e,i,s){var o=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),v=Math.sin(s),w=Math.cos(s);switch(o){case"xyz":r[0]=h*y*w+f*g*v,r[1]=f*g*w-h*y*v,r[2]=f*y*v+h*g*w,r[3]=f*y*w-h*g*v;break;case"xzy":r[0]=h*y*w-f*g*v,r[1]=f*g*w-h*y*v,r[2]=f*y*v+h*g*w,r[3]=f*y*w+h*g*v;break;case"yxz":r[0]=h*y*w+f*g*v,r[1]=f*g*w-h*y*v,r[2]=f*y*v-h*g*w,r[3]=f*y*w+h*g*v;break;case"yzx":r[0]=h*y*w+f*g*v,r[1]=f*g*w+h*y*v,r[2]=f*y*v-h*g*w,r[3]=f*y*w-h*g*v;break;case"zxy":r[0]=h*y*w-f*g*v,r[1]=f*g*w+h*y*v,r[2]=f*y*v+h*g*w,r[3]=f*y*w-h*g*v;break;case"zyx":r[0]=h*y*w-f*g*v,r[1]=f*g*w+h*y*v,r[2]=f*y*v-h*g*w,r[3]=f*y*w+h*g*v;break;default:throw new Error("Unknown angle order "+o)}return r}function ot(){var r=new st(2);return st!=Float32Array&&(r[0]=0,r[1]=0),r}function Nt(r,e){var i=new st(2);return i[0]=r,i[1]=e,i}Mi(),je=new st(4),st!=Float32Array&&(je[0]=0,je[1]=0,je[2]=0,je[3]=0),Mi(),he(1,0,0),he(0,1,0),$t(),$t(),fi(),ot();const Ze=8192;function xi(r,e,i){return e*(Ze/(r.tileSize*Math.pow(2,i-r.tileID.overscaledZ)))}function ht(r,e){return(r%e+e)%e}function _t(r,e,i){return r*(1-i)+e*i}function tt(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 Yt(r,e,i,s){const o=new rt(r,e,i,s);return u=>o.solve(u)}const Tt=Yt(.25,.1,.25,1);function Ut(r,e,i){return Math.min(i,Math.max(e,r))}function mi(r,e,i){const s=i-e,o=((r-e)%s+s)%s+e;return o===e?i:o}function lt(r,...e){for(const i of e)for(const s in i)r[s]=i[s];return r}let It=1;function Lt(r,e,i){const s={};for(const o in r)s[o]=e.call(this,r[o],o,r);return s}function ct(r,e,i){const s={};for(const o in r)e.call(this,r[o],o,r)&&(s[o]=r[o]);return s}function Rt(r){return Array.isArray(r)?r.map(Rt):typeof r=="object"&&r?Lt(r,Rt):r}const ri={};function yt(r){ri[r]||(typeof console<"u"&&console.warn(r),ri[r]=!0)}function kt(r,e,i){return(i.y-r.y)*(e.x-r.x)>(e.y-r.y)*(i.x-r.x)}function xt(r){return typeof WorkerGlobalScope<"u"&&r!==void 0&&r instanceof WorkerGlobalScope}let Vt=null;function pt(r){return typeof ImageBitmap<"u"&&r instanceof ImageBitmap}const Wt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function mr(r,e,i,s,o){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==null?void 0: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*o*4);if(yield u.copyTo(g,(function(y,v,w,S,M){const A=4*Math.max(-v,0),z=(Math.max(0,w)-w)*S*4+A,R=4*S,j=Math.max(0,v),X=Math.max(0,w);return{rect:{x:j,y:X,width:Math.min(y.width,v+S)-j,height:Math.min(y.height,w+M)-X},layout:[{offset:z,stride:R}]}})(r,e,i,s,o)),f)for(let y=0;y<g.length;y+=4){const v=g[y];g[y]=g[y+2],g[y+2]=v}return g}finally{u.close()}}))}let gr,Oi;function Or(r,e,i,s){return r.addEventListener(e,i,s),{unsubscribe:()=>{r.removeEventListener(e,i,s)}}}function Di(r){return r*Math.PI/180}function vi(r){return r/Math.PI*180}const ce={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},B={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},O="AbortError";class U extends Error{constructor(e=O){super(e instanceof Error?e.message:e),this.name=O,e instanceof Error&&e.stack&&(this.stack=e.stack)}}function re(r){return r.name===O}const ne={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function fe(r){return ne.REGISTERED_PROTOCOLS[r.substring(0,r.indexOf("://"))]}const de="global-dispatcher";class ae extends Error{constructor(e,i,s,o){super(`AJAXError: ${i} (${e}): ${s}`),this.status=e,this.statusText=i,this.url=s,this.body=o}}const we=()=>xt(self)?self.worker&&self.worker.referrer:(window.location.protocol==="blob:"?window.parent:window).location.href,ke=function(r,e){if(/:\/\//.test(r.url)&&!/^https?:|^file:/.test(r.url)){const s=fe(r.url);if(s)return s(r,e);if(xt(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:r,targetMapId:de},e)}if(!(/^file:/.test(i=r.url)||/^file:/.test(we())&&!/^\w+:/.test(i))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return(function(s,o){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:we(),signal:o.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 re(y)?y:new ae(0,y.message,s.url,new Blob)}if(!h.ok){const y=yield h.blob();throw new ae(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 o.signal.throwIfAborted(),{data:g,cacheControl:h.headers.get("Cache-Control"),expires:h.headers.get("Expires")}}))})(r,e);if(xt(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:r,mustQueue:!0,targetMapId:de},e)}var i;return(function(s,o){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(!o.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(v){return void h(v)}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 ae(g.status,g.statusText,s.url,y))}},o.signal.addEventListener("abort",(()=>{g.abort(),h(new U(o.signal.reason))})),g.send(s.body)}))})(r,e)};function Ee(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 We(r,e,i){i[r]&&i[r].indexOf(e)!==-1||(i[r]=i[r]||[],i[r].push(e))}function Qe(r,e,i){if(i&&i[r]){const s=i[r].indexOf(e);s!==-1&&i[r].splice(s,1)}}class ft{constructor(e,i={}){lt(this,i),this.type=e}}class ti extends ft{constructor(e,i={}){super("error",lt({error:e},i))}}class Gt{on(e,i){return this._listeners=this._listeners||{},We(e,i,this._listeners),{unsubscribe:()=>{this.off(e,i)}}}off(e,i){return Qe(e,i,this._listeners),Qe(e,i,this._oneTimeListeners),this}once(e,i){return i?(this._oneTimeListeners=this._oneTimeListeners||{},We(e,i,this._oneTimeListeners),this):new Promise((s=>this.once(e,s)))}fire(e,i){typeof e=="string"&&(e=new ft(e,i||{}));const s=e.type;if(this.listens(s)){e.target=this;const o=this._listeners&&this._listeners[s]?this._listeners[s].slice():[];for(const f of o)f.call(this,e);const u=this._oneTimeListeners&&this._oneTimeListeners[s]?this._oneTimeListeners[s].slice():[];for(const f of u)Qe(s,f,this._oneTimeListeners),f.call(this,e);const h=this._eventedParent;h&&(lt(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),h.fire(e))}else e instanceof ti&&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 ye={$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 ni=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function sr(r,e){const i={};for(const s in r)s!=="ref"&&(i[s]=r[s]);return ni.forEach((s=>{s in e&&(i[s]=e[s])})),i}function mt(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(!mt(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(!mt(r[i],e[i]))return!1;return!0}return r===e}function Kt(r,e){r.push(e)}function ar(r,e,i){Kt(i,{command:"addSource",args:[r,e[r]]})}function gi(r,e,i){Kt(e,{command:"removeSource",args:[r]}),i[r]=!0}function zi(r,e,i,s){gi(r,i,s),ar(r,e,i)}function si(r,e,i){let s;for(s in r[i])if(Object.prototype.hasOwnProperty.call(r[i],s)&&s!=="data"&&!mt(r[i][s],e[i][s]))return!1;for(s in e[i])if(Object.prototype.hasOwnProperty.call(e[i],s)&&s!=="data"&&!mt(r[i][s],e[i][s]))return!1;return!0}function $i(r,e,i,s,o,u){r=r||{},e=e||{};for(const h in r)Object.prototype.hasOwnProperty.call(r,h)&&(mt(r[h],e[h])||i.push({command:u,args:[s,h,e[h],o]}));for(const h in e)Object.prototype.hasOwnProperty.call(e,h)&&!Object.prototype.hasOwnProperty.call(r,h)&&(mt(r[h],e[h])||i.push({command:u,args:[s,h,e[h],o]}))}function Ns(r){return r.id}function Us(r,e){return r[e.id]=e,r}class Re{constructor(e,i,s,o){this.message=(e?`${e}: `:"")+s,o&&(this.identifier=o),i!=null&&i.__line__&&(this.line=i.__line__)}}function _r(r,...e){for(const i of e)for(const s in i)r[s]=i[s];return r}class yr extends Error{constructor(e,i){super(i),this.message=i,this.key=e}}class ja{constructor(e,i=[]){this.parent=e,this.bindings={};for(const[s,o]of i)this.bindings[s]=o}concat(e){return new ja(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 Vr={kind:"null"},qe={kind:"number"},St={kind:"string"},Pt={kind:"boolean"},Dr={kind:"color"},Na={kind:"projectionDefinition"},pn={kind:"object"},bt={kind:"value"},Gs={kind:"collator"},qs={kind:"formatted"},Ua={kind:"padding"},cs={kind:"colorArray"},Zs={kind:"numberArray"},us={kind:"resolvedImage"},$s={kind:"variableAnchorOffsetCollection"};function xr(r,e){return{kind:"array",itemType:r,N:e}}function Jt(r){if(r.kind==="array"){const e=Jt(r.itemType);return typeof r.N=="number"?`array<${e}, ${r.N}>`:r.itemType.kind==="value"?"array":`array<${e}>`}return r.kind}const Ga=[Vr,qe,St,Pt,Dr,Na,qs,pn,xr(bt),Ua,Zs,cs,us,$s];function hs(r,e){if(e.kind==="error")return null;if(r.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!hs(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 Ga)if(!hs(i,e))return null}}return`Expected ${Jt(r)} but found ${Jt(e)} instead.`}function Ws(r,e){return e.some((i=>i.kind===r.kind))}function Bn(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 Hr(r,e){return r.kind==="array"&&e.kind==="array"?r.itemType.kind===e.itemType.kind&&typeof r.N=="number":r.kind===e.kind}const xc=.96422,On=.82521,qa=4/29,ki=6/29,vc=3*ki*ki,bc=ki*ki*ki,Hs=Math.PI/180,wc=180/Math.PI;function Tc(r){return(r%=360)<0&&(r+=360),r}function Sc([r,e,i,s]){let o,u;const h=Jo((.2225045*(r=Za(r))+.7168786*(e=Za(e))+.0606169*(i=Za(i)))/1);r===e&&e===i?o=u=h:(o=Jo((.4360747*r+.3850649*e+.1430804*i)/xc),u=Jo((.0139322*r+.0971045*e+.7141733*i)/On));const f=116*h-16;return[f<0?0:f,500*(o-h),200*(h-u),s]}function Za(r){return r<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)}function Jo(r){return r>bc?Math.pow(r,1/3):r/vc+qa}function Qo([r,e,i,s]){let o=(r+16)/116,u=isNaN(e)?o:o+e/500,h=isNaN(i)?o:o-i/200;return o=1*tl(o),u=xc*tl(u),h=On*tl(h),[el(3.1338561*u-1.6168667*o-.4906146*h),el(-.9787684*u+1.9161415*o+.033454*h),el(.0719453*u-.2289914*o+1.4052427*h),s]}function el(r){return(r=r<=.00304?12.92*r:1.055*Math.pow(r,1/2.4)-.055)<0?0:r>1?1:r}function tl(r){return r>ki?r*r*r:vc*(r-qa)}const ah=Object.hasOwn||function(r,e){return Object.prototype.hasOwnProperty.call(r,e)};function Xs(r,e){return ah(r,e)?r[e]:void 0}function $a(r){return parseInt(r.padEnd(2,r),16)/255}function Pc(r,e){return ds(e?r/100:r,0,1)}function ds(r,e,i){return Math.min(Math.max(e,r),i)}function il(r){return!r.some(Number.isNaN)}const Ys={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 wn(r,e,i){return r+i*(e-r)}function ps(r,e,i){return r.map(((s,o)=>wn(s,e[o],i)))}class Mt{constructor(e,i,s,o=1,u=!0){this.r=e,this.g=i,this.b=s,this.a=o,u||(this.r*=o,this.g*=o,this.b*=o,o||this.overwriteGetter("rgb",[e,i,s,o]))}static parse(e){if(e instanceof Mt)return e;if(typeof e!="string")return;const i=(function(s){if((s=s.toLowerCase().trim())==="transparent")return[0,0,0,0];const o=Xs(Ys,s);if(o){const[h,f,g]=o;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[$a(s.slice(f,f+=h)),$a(s.slice(f,f+=h)),$a(s.slice(f,f+=h)),$a(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,v,w,S,M,A,z,R,j,X]=h,N=[v||" ",M||" ",R].join("");if(N===" "||N===" /"||N===",,"||N===",,,"){const G=[y,S,z].join(""),K=G==="%%%"?100:G===""?255:0;if(K){const te=[ds(+g/K,0,1),ds(+w/K,0,1),ds(+A/K,0,1),j?Pc(+j,X):1];if(il(te))return te}}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,v,w,S,M,A]=u,z=[g||" ",v||" ",S].join("");if(z===" "||z===" /"||z===",,"||z===",,,"){const R=[+f,ds(+y,0,100),ds(+w,0,100),M?Pc(+M,A):1];if(il(R))return(function([j,X,N,G]){function K(te){const me=(te+j/30)%12,Ie=X*Math.min(N,1-N);return N-Ie*Math.max(-1,Math.min(me-3,9-me,1))}return j=Tc(j),X/=100,N/=100,[K(0),K(8),K(4),G]})(R)}}})(e);return i?new Mt(...i,!1):void 0}get rgb(){const{r:e,g:i,b:s,a:o}=this,u=o||1/0;return this.overwriteGetter("rgb",[e/u,i/u,s/u,o])}get hcl(){return this.overwriteGetter("hcl",(function(e){const[i,s,o,u]=Sc(e),h=Math.sqrt(s*s+o*o);return[Math.round(1e4*h)?Tc(Math.atan2(o,s)*wc):NaN,h,i,u]})(this.rgb))}get lab(){return this.overwriteGetter("lab",Sc(this.rgb))}overwriteGetter(e,i){return Object.defineProperty(this,e,{value:i}),i}toString(){const[e,i,s,o]=this.rgb;return`rgba(${[e,i,s].map((u=>Math.round(255*u))).join(",")},${o})`}static interpolate(e,i,s,o="rgb"){switch(o){case"rgb":{const[u,h,f,g]=ps(e.rgb,i.rgb,s);return new Mt(u,h,f,g,!1)}case"hcl":{const[u,h,f,g]=e.hcl,[y,v,w,S]=i.hcl;let M,A;if(isNaN(u)||isNaN(y))isNaN(u)?isNaN(y)?M=NaN:(M=y,f!==1&&f!==0||(A=v)):(M=u,w!==1&&w!==0||(A=h));else{let N=y-u;y>u&&N>180?N-=360:y<u&&u-y>180&&(N+=360),M=u+s*N}const[z,R,j,X]=(function([N,G,K,te]){return N=isNaN(N)?0:N*Hs,Qo([K,Math.cos(N)*G,Math.sin(N)*G,te])})([M,A??wn(h,v,s),wn(f,w,s),wn(g,S,s)]);return new Mt(z,R,j,X,!1)}case"lab":{const[u,h,f,g]=Qo(ps(e.lab,i.lab,s));return new Mt(u,h,f,g,!1)}}}}Mt.black=new Mt(0,0,0,1),Mt.white=new Mt(1,1,1,1),Mt.transparent=new Mt(0,0,0,0),Mt.red=new Mt(1,0,0,1);class rl{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 oh=["bottom","center","top"];class nl{constructor(e,i,s,o,u,h){this.text=e,this.image=i,this.scale=s,this.fontStack=o,this.textColor=u,this.verticalAlign=h}}class Pr{constructor(e){this.sections=e}static fromString(e){return new Pr([new nl(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 Pr?e:Pr.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map((e=>e.text)).join("")}}class ur{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof ur)return e;if(typeof e=="number")return new ur([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 ur(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,i,s){return new ur(ps(e.values,i.values,s))}}class Ii{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Ii)return e;if(typeof e=="number")return new Ii([e]);if(Array.isArray(e)){for(const i of e)if(typeof i!="number")return;return new Ii(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,i,s){return new Ii(ps(e.values,i.values,s))}}class ut{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof ut)return e;if(typeof e=="string"){const s=Mt.parse(e);return s?new ut([s]):void 0}if(!Array.isArray(e))return;const i=[];for(const s of e){if(typeof s!="string")return;const o=Mt.parse(s);if(!o)return;i.push(o)}return new ut(i)}toString(){return JSON.stringify(this.values)}static interpolate(e,i,s,o="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(Mt.interpolate(e.values[h],i.values[h],s,o));return new ut(u)}}class ai extends Error{constructor(e){super(e),this.name="RuntimeError"}toJSON(){return this.message}}const Tn=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class vr{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof vr)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],o=e[i+1];if(typeof s!="string"||!Tn.has(s)||!Array.isArray(o)||o.length!==2||typeof o[0]!="number"||typeof o[1]!="number")return}return new vr(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,i,s){const o=e.values,u=i.values;if(o.length!==u.length)throw new ai(`Cannot interpolate values of different length. from: ${e.toString()}, to: ${i.toString()}`);const h=[];for(let f=0;f<o.length;f+=2){if(o[f]!==u[f])throw new ai(`Cannot interpolate values containing mismatched anchors. from[${f}]: ${o[f]}, to[${f}]: ${u[f]}`);h.push(o[f]);const[g,y]=o[f+1],[v,w]=u[f+1];h.push([wn(g,v,s),wn(y,w,s)])}return new vr(h)}}class zr{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new zr({name:e,available:!1}):null}}class br{constructor(e,i,s){this.from=e,this.to=i,this.transition=s}static interpolate(e,i,s){return new br(e,i,s)}static parse(e){return e instanceof br?e:Array.isArray(e)&&e.length===3&&typeof e[0]=="string"&&typeof e[1]=="string"&&typeof e[2]=="number"?new br(e[0],e[1],e[2]):typeof e=="object"&&typeof e.from=="string"&&typeof e.to=="string"&&typeof e.transition=="number"?new br(e.from,e.to,e.transition):typeof e=="string"?new br(e,e,1):void 0}}function fs(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 Sn(r){if(r===null||typeof r=="string"||typeof r=="boolean"||typeof r=="number"||r instanceof br||r instanceof Mt||r instanceof rl||r instanceof Pr||r instanceof ur||r instanceof Ii||r instanceof ut||r instanceof vr||r instanceof zr)return!0;if(Array.isArray(r)){for(const e of r)if(!Sn(e))return!1;return!0}if(typeof r=="object"){for(const e in r)if(!Sn(r[e]))return!1;return!0}return!1}function Vi(r){if(r===null)return Vr;if(typeof r=="string")return St;if(typeof r=="boolean")return Pt;if(typeof r=="number")return qe;if(r instanceof Mt)return Dr;if(r instanceof br)return Na;if(r instanceof rl)return Gs;if(r instanceof Pr)return qs;if(r instanceof ur)return Ua;if(r instanceof Ii)return Zs;if(r instanceof ut)return cs;if(r instanceof vr)return $s;if(r instanceof zr)return us;if(Array.isArray(r)){const e=r.length;let i;for(const s of r){const o=Vi(s);if(i){if(i===o)continue;i=bt;break}i=o}return xr(i||bt,e)}return pn}function Vn(r){const e=typeof r;return r===null?"":e==="string"||e==="number"||e==="boolean"?String(r):r instanceof Mt||r instanceof br||r instanceof Pr||r instanceof ur||r instanceof Ii||r instanceof ut||r instanceof vr||r instanceof zr?r.toString():JSON.stringify(r)}class on{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(!Sn(e[1]))return i.error("invalid value");const s=e[1];let o=Vi(s);const u=i.expectedType;return o.kind!=="array"||o.N!==0||!u||u.kind!=="array"||typeof u.N=="number"&&u.N!==0||(o=u),new on(o,s)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const Wa={string:St,number:qe,boolean:Pt,object:pn};class Mr{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,o=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 Wa)||y==="object")return i.error('The item type argument of "array" must be one of string, number, boolean',1);f=Wa[y],o++}else f=bt;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],o++}s=xr(f,g)}else{if(!Wa[u])throw new Error(`Types doesn't contain name = ${u}`);s=Wa[u]}const h=[];for(;o<e.length;o++){const f=i.parse(e[o],o,bt);if(!f)return null;h.push(f)}return new Mr(s,h)}evaluate(e){for(let i=0;i<this.args.length;i++){const s=this.args[i].evaluate(e);if(!hs(this.type,Vi(s)))return s;if(i===this.args.length-1)throw new ai(`Expected value to be of type ${Jt(this.type)}, but found ${Jt(Vi(s))} instead.`)}throw new Error}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const jn={"to-boolean":Pt,"to-color":Dr,"to-number":qe,"to-string":St};class fn{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(!jn[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 o=jn[s],u=[];for(let h=1;h<e.length;h++){const f=i.parse(e[h],h,bt);if(!f)return null;u.push(f)}return new fn(o,u)}evaluate(e){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(e);case"color":{let i,s;for(const o of this.args){if(i=o.evaluate(e),s=null,i instanceof Mt)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.`:fs(i[0],i[1],i[2],i[3]),!s))return new Mt(i[0]/255,i[1]/255,i[2]/255,i[3])}throw new ai(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 o=ur.parse(i);if(o)return o}throw new ai(`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 o=Ii.parse(i);if(o)return o}throw new ai(`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 o=ut.parse(i);if(o)return o}throw new ai(`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 o=vr.parse(i);if(o)return o}throw new ai(`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 o=Number(i);if(!isNaN(o))return o}throw new ai(`Could not convert ${JSON.stringify(i)} to number.`)}case"formatted":return Pr.fromString(Vn(this.args[0].evaluate(e)));case"resolvedImage":return zr.fromString(Vn(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return Vn(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const Mc=["Unknown","Point","LineString","Polygon"];class sl{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"?Mc[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=Mt.parse(e),this._parseColorCache.set(e,i)),i}}class Nn{constructor(e,i,s=[],o,u=new ja,h=[]){this.registry=e,this.path=s,this.key=s.map((f=>`[${f}]`)).join(""),this.scope=u,this.errors=h,this.expectedType=o,this._isConstant=i}parse(e,i,s,o,u={}){return i?this.concat(i,s,o)._parse(e,u):this._parse(e,u)}_parse(e,i){function s(o,u,h){return h==="assert"?new Mr(u,[o]):h==="coerce"?new fn(u,[o]):o}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 o=e[0];if(typeof o!="string")return this.error(`Expression name must be a string, but found ${typeof o} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const u=this.registry[o];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 on)&&h.type.kind!=="resolvedImage"&&this._isConstant(h)){const f=new sl;try{h=new on(h.type,h.evaluate(f))}catch(g){return this.error(g.message),null}}return h}return this.error(`Unknown expression "${o}". 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 o=typeof e=="number"?this.path.concat(e):this.path,u=s?this.scope.concat(s):this.scope;return new Nn(this.registry,this._isConstant,o,i||null,u,this.errors)}error(e,...i){const s=`${this.key}${i.map((o=>`[${o}]`)).join("")}`;this.errors.push(new yr(s,e))}checkSubtype(e,i){const s=hs(e,i);return s&&this.error(s),s}}class oi{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 o=i.parse(e[e.length-1],e.length-1,i.expectedType,s);return o?new oi(s,o):null}outputDefined(){return this.result.outputDefined()}}class ms{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 ms(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 Ft{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,qe),o=i.parse(e[2],2,xr(i.expectedType||bt));return s&&o?new Ft(o.type.itemType,s,o):null}evaluate(e){const i=this.index.evaluate(e),s=this.input.evaluate(e);if(i<0)throw new ai(`Array index out of bounds: ${i} < 0.`);if(i>=s.length)throw new ai(`Array index out of bounds: ${i} > ${s.length-1}.`);if(i!==Math.floor(i))throw new ai(`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 wt{constructor(e,i){this.type=Pt,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,bt),o=i.parse(e[2],2,bt);return s&&o?Ws(s.type,[Pt,St,qe,Vr,bt])?new wt(s,o):i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Jt(s.type)} instead`):null}evaluate(e){const i=this.needle.evaluate(e),s=this.haystack.evaluate(e);if(!s)return!1;if(!Bn(i,["boolean","string","number","null"]))throw new ai(`Expected first argument to be of type boolean, string, number or null, but found ${Jt(Vi(i))} instead.`);if(!Bn(s,["string","array"]))throw new ai(`Expected second argument to be of type array or string, but found ${Jt(Vi(s))} instead.`);return s.indexOf(i)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class gs{constructor(e,i,s){this.type=qe,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,bt),o=i.parse(e[2],2,bt);if(!s||!o)return null;if(!Ws(s.type,[Pt,St,qe,Vr,bt]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Jt(s.type)} instead`);if(e.length===4){const u=i.parse(e[3],3,qe);return u?new gs(s,o,u):null}return new gs(s,o)}evaluate(e){const i=this.needle.evaluate(e),s=this.haystack.evaluate(e);if(!Bn(i,["boolean","string","number","null"]))throw new ai(`Expected first argument to be of type boolean, string, number or null, but found ${Jt(Vi(i))} instead.`);let o;if(this.fromIndex&&(o=this.fromIndex.evaluate(e)),Bn(s,["string"])){const u=s.indexOf(i,o);return u===-1?-1:[...s.slice(0,u)].length}if(Bn(s,["array"]))return s.indexOf(i,o);throw new ai(`Expected second argument to be of type array or string, but found ${Jt(Vi(s))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class Bt{constructor(e,i,s,o,u,h){this.inputType=e,this.type=i,this.input=s,this.cases=o,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,o;i.expectedType&&i.expectedType.kind!=="value"&&(o=i.expectedType);const u={},h=[];for(let y=2;y<e.length-1;y+=2){let v=e[y];const w=e[y+1];Array.isArray(v)||(v=[v]);const S=i.concat(y);if(v.length===0)return S.error("Expected at least one branch label.");for(const A of v){if(typeof A!="number"&&typeof A!="string")return S.error("Branch labels must be numbers or strings.");if(typeof A=="number"&&Math.abs(A)>Number.MAX_SAFE_INTEGER)return S.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof A=="number"&&Math.floor(A)!==A)return S.error("Numeric branch labels must be integer values.");if(s){if(S.checkSubtype(s,Vi(A)))return null}else s=Vi(A);if(u[String(A)]!==void 0)return S.error("Branch labels must be unique.");u[String(A)]=h.length}const M=i.parse(w,y,o);if(!M)return null;o=o||M.type,h.push(M)}const f=i.parse(e[1],1,bt);if(!f)return null;const g=i.parse(e[e.length-1],e.length-1,o);return g?f.type.kind!=="value"&&i.concat(1).checkSubtype(s,f.type)?null:new Bt(s,o,f,u,h,g):null}evaluate(e){const i=this.input.evaluate(e);return(Vi(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 Ks{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 o=[];for(let h=1;h<e.length-1;h+=2){const f=i.parse(e[h],h,Pt);if(!f)return null;const g=i.parse(e[h+1],h+1,s);if(!g)return null;o.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 Ks(s,o,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 jr{constructor(e,i,s,o){this.type=e,this.input=i,this.beginIndex=s,this.endIndex=o}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,bt),o=i.parse(e[2],2,qe);if(!s||!o)return null;if(!Ws(s.type,[xr(bt),St,bt]))return i.error(`Expected first argument to be of type array or string, but found ${Jt(s.type)} instead`);if(e.length===4){const u=i.parse(e[3],3,qe);return u?new jr(s.type,s,o,u):null}return new jr(s.type,s,o)}evaluate(e){const i=this.input.evaluate(e),s=this.beginIndex.evaluate(e);let o;if(this.endIndex&&(o=this.endIndex.evaluate(e)),Bn(i,["string"]))return[...i].slice(s,o).join("");if(Bn(i,["array"]))return i.slice(s,o);throw new ai(`Expected first argument to be of type array or string, but found ${Jt(Vi(i))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function _s(r,e){const i=r.length-1;let s,o,u=0,h=i,f=0;for(;u<=h;)if(f=Math.floor((u+h)/2),s=r[f],o=r[f+1],s<=e){if(f===i||e<o)return f;u=f+1}else{if(!(s>e))throw new ai("Input is not a number.");h=f-1}return 0}class Pn{constructor(e,i,s){this.type=e,this.input=i,this.labels=[],this.outputs=[];for(const[o,u]of s)this.labels.push(o),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,qe);if(!s)return null;const o=[];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,v=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(o.length&&o[o.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 w=i.parse(g,v,u);if(!w)return null;u=u||w.type,o.push([f,w])}return new Pn(u,s,o)}evaluate(e){const i=this.labels,s=this.outputs;if(i.length===1)return s[0].evaluate(e);const o=this.input.evaluate(e);if(o<=i[0])return s[0].evaluate(e);const u=i.length;return o>=i[u-1]?s[u-1].evaluate(e):s[_s(i,o)].evaluate(e)}eachChild(e){e(this.input);for(const i of this.outputs)e(i)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function Ic(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Js,al,lh=(function(){if(al)return Js;function r(e,i,s,o){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*(o-i)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=i,this.p2x=s,this.p2y=o}return al=1,Js=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,o=0;o<8;o++){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,o=0;o<20&&(u=this.sampleCurveX(s),!(Math.abs(u-e)<i));o++)e>u?f=s:g=s,s=.5*(g-f)+f;return s},solve:function(e,i){return this.sampleCurveY(this.solveCurveX(e,i))}},Js})(),Ec=Ic(lh);class wr{constructor(e,i,s,o,u){this.type=e,this.operator=i,this.interpolation=s,this.input=o,this.labels=[],this.outputs=[];for(const[h,f]of u)this.labels.push(h),this.outputs.push(f)}static interpolationFactor(e,i,s,o){let u=0;if(e.name==="exponential")u=ln(i,e.base,s,o);else if(e.name==="linear")u=ln(i,1,s,o);else if(e.name==="cubic-bezier"){const h=e.controlPoints;u=new Ec(h[0],h[1],h[2],h[3]).solve(ln(i,1,s,o))}return u}static parse(e,i){let[s,o,u,...h]=e;if(!Array.isArray(o)||o.length===0)return i.error("Expected an interpolation type expression.",1);if(o[0]==="linear")o={name:"linear"};else if(o[0]==="exponential"){const y=o[1];if(typeof y!="number")return i.error("Exponential interpolation requires a numeric base.",1,1);o={name:"exponential",base:y}}else{if(o[0]!=="cubic-bezier")return i.error(`Unknown interpolation type ${String(o[0])}`,1,0);{const y=o.slice(1);if(y.length!==4||y.some((v=>typeof v!="number"||v<0||v>1)))return i.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);o={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,qe),!u)return null;const f=[];let g=null;s!=="interpolate-hcl"&&s!=="interpolate-lab"||i.expectedType==cs?i.expectedType&&i.expectedType.kind!=="value"&&(g=i.expectedType):g=Dr;for(let y=0;y<h.length;y+=2){const v=h[y],w=h[y+1],S=y+3,M=y+4;if(typeof v!="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]>=v)return i.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',S);const A=i.parse(w,M,g);if(!A)return null;g=g||A.type,f.push([v,A])}return Hr(g,qe)||Hr(g,Na)||Hr(g,Dr)||Hr(g,Ua)||Hr(g,Zs)||Hr(g,cs)||Hr(g,$s)||Hr(g,xr(qe))?new wr(g,s,o,u,f):i.error(`Type ${Jt(g)} is not interpolatable.`)}evaluate(e){const i=this.labels,s=this.outputs;if(i.length===1)return s[0].evaluate(e);const o=this.input.evaluate(e);if(o<=i[0])return s[0].evaluate(e);const u=i.length;if(o>=i[u-1])return s[u-1].evaluate(e);const h=_s(i,o),f=wr.interpolationFactor(this.interpolation,o,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 wn(g,y,f);case"color":return Mt.interpolate(g,y,f);case"padding":return ur.interpolate(g,y,f);case"colorArray":return ut.interpolate(g,y,f);case"numberArray":return Ii.interpolate(g,y,f);case"variableAnchorOffsetCollection":return vr.interpolate(g,y,f);case"array":return ps(g,y,f);case"projectionDefinition":return br.interpolate(g,y,f)}case"interpolate-hcl":switch(this.type.kind){case"color":return Mt.interpolate(g,y,f,"hcl");case"colorArray":return ut.interpolate(g,y,f,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Mt.interpolate(g,y,f,"lab");case"colorArray":return ut.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 ln(r,e,i,s){const o=s-i,u=r-i;return o===0?0:e===1?u/o:(Math.pow(e,u)-1)/(Math.pow(e,o)-1)}const bi={color:Mt.interpolate,number:wn,padding:ur.interpolate,numberArray:Ii.interpolate,colorArray:ut.interpolate,variableAnchorOffsetCollection:vr.interpolate,array:ps};class Un{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 o=i.expectedType;o&&o.kind!=="value"&&(s=o);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=o&&u.some((f=>hs(o,f.type)));return new Un(h?bt:s,u)}evaluate(e){let i,s=null,o=0;for(const u of this.args)if(o++,s=u.evaluate(e),s&&s instanceof zr&&!s.available&&(i||(i=s.name),s=null,o===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 ol(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 Qs(r,e,i,s){return s.compare(e,i)===0}function Ri(r,e,i){const s=r!=="=="&&r!=="!=";return class _m{constructor(u,h,f){this.type=Pt,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,bt);if(!g)return null;if(!ol(f,g.type))return h.concat(1).error(`"${f}" comparisons are not supported for type '${Jt(g.type)}'.`);let y=h.parse(u[2],2,bt);if(!y)return null;if(!ol(f,y.type))return h.concat(2).error(`"${f}" comparisons are not supported for type '${Jt(y.type)}'.`);if(g.type.kind!==y.type.kind&&g.type.kind!=="value"&&y.type.kind!=="value")return h.error(`Cannot compare types '${Jt(g.type)}' and '${Jt(y.type)}'.`);s&&(g.type.kind==="value"&&y.type.kind!=="value"?g=new Mr(y.type,[g]):g.type.kind!=="value"&&y.type.kind==="value"&&(y=new Mr(g.type,[y])));let v=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(v=h.parse(u[3],3,Gs),!v)return null}return new _m(g,y,v)}evaluate(u){const h=this.lhs.evaluate(u),f=this.rhs.evaluate(u);if(s&&this.hasUntypedArgument){const g=Vi(h),y=Vi(f);if(g.kind!==y.kind||g.kind!=="string"&&g.kind!=="number")throw new ai(`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=Vi(h),y=Vi(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 Cc=Ri("==",(function(r,e,i){return e===i}),Qs),ll=Ri("!=",(function(r,e,i){return e!==i}),(function(r,e,i,s){return!Qs(0,e,i,s)})),Ac=Ri("<",(function(r,e,i){return e<i}),(function(r,e,i,s){return s.compare(e,i)<0})),ch=Ri(">",(function(r,e,i){return e>i}),(function(r,e,i,s){return s.compare(e,i)>0})),ys=Ri("<=",(function(r,e,i){return e<=i}),(function(r,e,i,s){return s.compare(e,i)<=0})),Ha=Ri(">=",(function(r,e,i){return e>=i}),(function(r,e,i,s){return s.compare(e,i)>=0}));class xs{constructor(e,i,s){this.type=Gs,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 o=i.parse(s["case-sensitive"]!==void 0&&s["case-sensitive"],1,Pt);if(!o)return null;const u=i.parse(s["diacritic-sensitive"]!==void 0&&s["diacritic-sensitive"],1,Pt);if(!u)return null;let h=null;return s.locale&&(h=i.parse(s.locale,1,St),!h)?null:new xs(o,u,h)}evaluate(e){return new rl(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 cl{constructor(e,i,s,o,u){this.type=St,this.number=e,this.locale=i,this.currency=s,this.minFractionDigits=o,this.maxFractionDigits=u}static parse(e,i){if(e.length!==3)return i.error("Expected two arguments.");const s=i.parse(e[1],1,qe);if(!s)return null;const o=e[2];if(typeof o!="object"||Array.isArray(o))return i.error("NumberFormat options argument must be an object.");let u=null;if(o.locale&&(u=i.parse(o.locale,1,St),!u))return null;let h=null;if(o.currency&&(h=i.parse(o.currency,1,St),!h))return null;let f=null;if(o["min-fraction-digits"]&&(f=i.parse(o["min-fraction-digits"],1,qe),!f))return null;let g=null;return o["max-fraction-digits"]&&(g=i.parse(o["max-fraction-digits"],1,qe),!g)?null:new cl(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 ea{constructor(e){this.type=qs,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 o=[];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,qe),!g))return null;let y=null;if(f["text-font"]&&(y=i.parse(f["text-font"],1,xr(St)),!y))return null;let v=null;if(f["text-color"]&&(v=i.parse(f["text-color"],1,Dr),!v))return null;let w=null;if(f["vertical-align"]){if(typeof f["vertical-align"]=="string"&&!oh.includes(f["vertical-align"]))return i.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${f["vertical-align"]}' instead.`);if(w=i.parse(f["vertical-align"],1,St),!w)return null}const S=o[o.length-1];S.scale=g,S.font=y,S.textColor=v,S.verticalAlign=w}else{const g=i.parse(e[h],1,bt);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,o.push({content:g,scale:null,font:null,textColor:null,verticalAlign:null})}}return new ea(o)}evaluate(e){return new Pr(this.sections.map((i=>{const s=i.content.evaluate(e);return Vi(s)===us?new nl("",s,null,null,null,i.verticalAlign?i.verticalAlign.evaluate(e):null):new nl(Vn(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 vs{constructor(e){this.type=us,this.input=e}static parse(e,i){if(e.length!==2)return i.error("Expected two arguments.");const s=i.parse(e[1],1,St);return s?new vs(s):i.error("No image name provided.")}evaluate(e){const i=this.input.evaluate(e),s=zr.fromString(i);return s&&e.availableImages&&(s.available=e.availableImages.indexOf(i)>-1),s}eachChild(e){e(this.input)}outputDefined(){return!1}}class bs{constructor(e){this.type=qe,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 ${Jt(s.type)} instead.`):new bs(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 ai(`Expected value to be of type string or array, but found ${Jt(Vi(i))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const Wi=8192;function Dc(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,o=Math.pow(2,e.z);return[Math.round(i*o*Wi),Math.round(s*o*Wi)]}function ws(r,e){const i=Math.pow(2,e.z);return[(o=(r[0]/Wi+e.x)/i,360*o-180),(s=(r[1]/Wi+e.y)/i,360/Math.PI*Math.atan(Math.exp((180-360*s)*Math.PI/180))-90)];var s,o}function ta(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 Gn(r,e){return!(r[0]<=e[0]||r[2]>=e[2]||r[1]<=e[1]||r[3]>=e[3])}function uh(r,e,i){const s=r[0]-e[0],o=r[1]-e[1],u=r[0]-i[0],h=r[1]-i[1];return s*h-u*o==0&&s*u<=0&&o*h<=0}function Xa(r,e,i,s){return(o=[s[0]-i[0],s[1]-i[1]])[0]*(u=[e[0]-r[0],e[1]-r[1]])[1]-o[1]*u[0]!=0&&!(!ul(r,e,i,s)||!ul(i,s,r,e));var o,u}function hh(r,e,i){for(const s of i)for(let o=0;o<s.length-1;++o)if(Xa(r,e,s[o],s[o+1]))return!0;return!1}function Ts(r,e,i=!1){let s=!1;for(const f of e)for(let g=0;g<f.length-1;g++){if(uh(r,f[g],f[g+1]))return i;(u=f[g])[1]>(o=r)[1]!=(h=f[g+1])[1]>o[1]&&o[0]<(h[0]-u[0])*(o[1]-u[1])/(h[1]-u[1])+u[0]&&(s=!s)}var o,u,h;return s}function Ya(r,e){for(const i of e)if(Ts(r,i))return!0;return!1}function zc(r,e){for(const i of r)if(!Ts(i,e))return!1;for(let i=0;i<r.length-1;++i)if(hh(r[i],r[i+1],e))return!1;return!0}function kc(r,e){for(const i of e)if(zc(r,i))return!0;return!1}function ul(r,e,i,s){const o=s[0]-i[0],u=s[1]-i[1],h=(r[0]-i[0])*u-o*(r[1]-i[1]),f=(e[0]-i[0])*u-o*(e[1]-i[1]);return h>0&&f<0||h<0&&f>0}function hl(r,e,i){const s=[];for(let o=0;o<r.length;o++){const u=[];for(let h=0;h<r[o].length;h++){const f=Dc(r[o][h],i);ta(e,f),u.push(f)}s.push(u)}return s}function dl(r,e,i){const s=[];for(let o=0;o<r.length;o++){const u=hl(r[o],e,i);s.push(u)}return s}function Rc(r,e,i,s){if(r[0]<i[0]||r[0]>i[2]){const o=.5*s;let u=r[0]-i[0]>o?-s:i[0]-r[0]>o?s:0;u===0&&(u=r[0]-i[2]>o?-s:i[2]-r[0]>o?s:0),r[0]+=u}ta(e,r)}function Fc(r,e,i,s){const o=Math.pow(2,s.z)*Wi,u=[s.x*Wi,s.y*Wi],h=[];for(const f of r)for(const g of f){const y=[g.x+u[0],g.y+u[1]];Rc(y,e,i,o),h.push(y)}return h}function Lc(r,e,i,s){const o=Math.pow(2,s.z)*Wi,u=[s.x*Wi,s.y*Wi],h=[];for(const g of r){const y=[];for(const v of g){const w=[v.x+u[0],v.y+u[1]];ta(e,w),y.push(w)}h.push(y)}if(e[2]-e[0]<=o/2){(f=e)[0]=f[1]=1/0,f[2]=f[3]=-1/0;for(const g of h)for(const y of g)Rc(y,e,i,o)}var f;return h}class qn{constructor(e,i){this.type=Pt,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(Sn(e[1])){const s=e[1];if(s.type==="FeatureCollection"){const o=[];for(const u of s.features){const{type:h,coordinates:f}=u.geometry;h==="Polygon"&&o.push(f),h==="MultiPolygon"&&o.push(...f)}if(o.length)return new qn(s,{type:"MultiPolygon",coordinates:o})}else if(s.type==="Feature"){const o=s.geometry.type;if(o==="Polygon"||o==="MultiPolygon")return new qn(s,s.geometry)}else if(s.type==="Polygon"||s.type==="MultiPolygon")return new qn(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 o=[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=hl(s.coordinates,u,h),g=Fc(i.geometry(),o,u,h);if(!Gn(o,u))return!1;for(const y of g)if(!Ts(y,f))return!1}if(s.type==="MultiPolygon"){const f=dl(s.coordinates,u,h),g=Fc(i.geometry(),o,u,h);if(!Gn(o,u))return!1;for(const y of g)if(!Ya(y,f))return!1}return!0})(e,this.geometries);if(e.geometryType()==="LineString")return(function(i,s){const o=[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=hl(s.coordinates,u,h),g=Lc(i.geometry(),o,u,h);if(!Gn(o,u))return!1;for(const y of g)if(!zc(y,f))return!1}if(s.type==="MultiPolygon"){const f=dl(s.coordinates,u,h),g=Lc(i.geometry(),o,u,h);if(!Gn(o,u))return!1;for(const y of g)if(!kc(y,f))return!1}return!0})(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let Bc=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 o=r-1>>1,u=e[o];if(i(s,u)>=0)break;e[r]=u,r=o}e[r]=s}_down(r){const{data:e,compare:i}=this,s=this.length>>1,o=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],o)>=0)break;e[r]=e[u],r=u}e[r]=o}};function pl(r,e,i=0,s=r.length-1,o=Oc){for(;s>i;){if(s-i>600){const g=s-i+1,y=e-i+1,v=Math.log(g),w=.5*Math.exp(2*v/3),S=.5*Math.sqrt(v*w*(g-w)/g)*(y-g/2<0?-1:1);pl(r,e,Math.max(i,Math.floor(e-y*w/g+S)),Math.min(s,Math.floor(e+(g-y)*w/g+S)),o)}const u=r[e];let h=i,f=s;for(Ss(r,i,e),o(r[s],u)>0&&Ss(r,i,s);h<f;){for(Ss(r,h,f),h++,f--;o(r[h],u)<0;)h++;for(;o(r[f],u)>0;)f--}o(r[i],u)===0?Ss(r,i,f):(f++,Ss(r,f,s)),f<=e&&(i=f+1),e<=f&&(s=f-1)}}function Ss(r,e,i){const s=r[e];r[e]=r[i],r[i]=s}function Oc(r,e){return r<e?-1:r>e?1:0}function Ka(r,e){if(r.length<=1)return[r];const i=[];let s,o;for(const u of r){const h=ph(u);h!==0&&(u.area=Math.abs(h),o===void 0&&(o=h<0),o===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||(pl(i[u],e,1,i[u].length-1,dh),i[u]=i[u].slice(0,e));return i}function dh(r,e){return e.area-r.area}function ph(r){let e=0;for(let i,s,o=0,u=r.length,h=u-1;o<u;h=o++)i=r[o],s=r[h],e+=(s.x-i.x)*(i.y+s.y);return e}const Vc=1/298.257223563,ia=Vc*(2-Vc),jc=Math.PI/180;class fl{constructor(e){const i=6378.137*jc*1e3,s=Math.cos(e*jc),o=1/(1-ia*(1-s*s)),u=Math.sqrt(o);this.kx=i*u*s,this.ky=i*u*o*(1-ia)}distance(e,i){const s=this.wrap(e[0]-i[0])*this.kx,o=(e[1]-i[1])*this.ky;return Math.sqrt(s*s+o*o)}pointOnLine(e,i){let s,o,u,h,f=1/0;for(let g=0;g<e.length-1;g++){let y=e[g][0],v=e[g][1],w=this.wrap(e[g+1][0]-y)*this.kx,S=(e[g+1][1]-v)*this.ky,M=0;w===0&&S===0||(M=(this.wrap(i[0]-y)*this.kx*w+(i[1]-v)*this.ky*S)/(w*w+S*S),M>1?(y=e[g+1][0],v=e[g+1][1]):M>0&&(y+=w/this.kx*M,v+=S/this.ky*M)),w=this.wrap(i[0]-y)*this.kx,S=(i[1]-v)*this.ky;const A=w*w+S*S;A<f&&(f=A,s=y,o=v,u=g,h=M)}return{point:[s,o],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 Nc(r,e){return e[0]-r[0]}function Ja(r){return r[1]-r[0]+1}function Xr(r,e){return r[1]>=r[0]&&r[1]<e}function Qa(r,e){if(r[0]>r[1])return[null,null];const i=Ja(r);if(e){if(i===2)return[r,null];const o=Math.floor(i/2);return[[r[0],r[0]+o],[r[0]+o,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 ml(r,e){if(!Xr(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)ta(i,r[s]);return i}function gl(r){const e=[1/0,1/0,-1/0,-1/0];for(const i of r)for(const s of i)ta(e,s);return e}function _l(r){return r[0]!==-1/0&&r[1]!==-1/0&&r[2]!==1/0&&r[3]!==1/0}function eo(r,e,i){if(!_l(r)||!_l(e))return NaN;let s=0,o=0;return r[2]<e[0]&&(s=e[0]-r[2]),r[0]>e[2]&&(s=r[0]-e[2]),r[1]>e[3]&&(o=r[1]-e[3]),r[3]<e[1]&&(o=e[1]-r[3]),i.distance([0,0],[s,o])}function Zn(r,e,i){const s=i.pointOnLine(e,r);return i.distance(r,s.point)}function yl(r,e,i,s,o){const u=Math.min(Zn(r,[i,s],o),Zn(e,[i,s],o)),h=Math.min(Zn(i,[r,e],o),Zn(s,[r,e],o));return Math.min(u,h)}function fh(r,e,i,s,o){if(!Xr(e,r.length)||!Xr(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 v=i[y],w=i[y+1];if(Xa(f,g,v,w))return 0;u=Math.min(u,yl(f,g,v,w,o))}}return u}function Uc(r,e,i,s,o){if(!Xr(e,r.length)||!Xr(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,o.distance(r[h],i[f])),u===0)return u;return u}function mh(r,e,i){if(Ts(r,e,!0))return 0;let s=1/0;for(const o of e){const u=o[0],h=o[o.length-1];if(u!==h&&(s=Math.min(s,Zn(r,[h,u],i)),s===0))return s;const f=i.pointOnLine(o,r);if(s=Math.min(s,i.distance(r,f.point)),s===0)return s}return s}function gh(r,e,i,s){if(!Xr(e,r.length))return NaN;for(let u=e[0];u<=e[1];++u)if(Ts(r[u],i,!0))return 0;let o=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,v=g.length,w=v-1;y<v;w=y++){const S=g[w],M=g[y];if(Xa(h,f,S,M))return 0;o=Math.min(o,yl(h,f,S,M,s))}}return o}function Gc(r,e){for(const i of r)for(const s of i)if(Ts(s,e,!0))return!0;return!1}function _h(r,e,i,s=1/0){const o=gl(r),u=gl(e);if(s!==1/0&&eo(o,u,i)>=s)return s;if(Gn(o,u)){if(Gc(r,e))return 0}else if(Gc(e,r))return 0;let h=1/0;for(const f of r)for(let g=0,y=f.length,v=y-1;g<y;v=g++){const w=f[v],S=f[g];for(const M of e)for(let A=0,z=M.length,R=z-1;A<z;R=A++){const j=M[R],X=M[A];if(Xa(w,S,j,X))return 0;h=Math.min(h,yl(w,S,j,X,i))}}return h}function qt(r,e,i,s,o,u){if(!u)return;const h=eo(ml(s,u),o,i);h<e&&r.push([h,u,[0,0]])}function to(r,e,i,s,o,u,h){if(!u||!h)return;const f=eo(ml(s,u),ml(o,h),i);f<e&&r.push([f,u,h])}function io(r,e,i,s,o=1/0){let u=Math.min(s.distance(r[0],i[0][0]),o);if(u===0)return u;const h=new Bc([[0,[0,r.length-1],[0,0]]],Nc),f=gl(i);for(;h.length>0;){const g=h.pop();if(g[0]>=u)continue;const y=g[1],v=e?50:100;if(Ja(y)<=v){if(!Xr(y,r.length))return NaN;if(e){const w=gh(r,y,i,s);if(isNaN(w)||w===0)return w;u=Math.min(u,w)}else for(let w=y[0];w<=y[1];++w){const S=mh(r[w],i,s);if(u=Math.min(u,S),u===0)return 0}}else{const w=Qa(y,e);qt(h,u,s,r,f,w[0]),qt(h,u,s,r,f,w[1])}}return u}function ro(r,e,i,s,o,u=1/0){let h=Math.min(u,o.distance(r[0],i[0]));if(h===0)return h;const f=new Bc([[0,[0,r.length-1],[0,i.length-1]]],Nc);for(;f.length>0;){const g=f.pop();if(g[0]>=h)continue;const y=g[1],v=g[2],w=e?50:100,S=s?50:100;if(Ja(y)<=w&&Ja(v)<=S){if(!Xr(y,r.length)&&Xr(v,i.length))return NaN;let M;if(e&&s)M=fh(r,y,i,v,o),h=Math.min(h,M);else if(e&&!s){const A=r.slice(y[0],y[1]+1);for(let z=v[0];z<=v[1];++z)if(M=Zn(i[z],A,o),h=Math.min(h,M),h===0)return h}else if(!e&&s){const A=i.slice(v[0],v[1]+1);for(let z=y[0];z<=y[1];++z)if(M=Zn(r[z],A,o),h=Math.min(h,M),h===0)return h}else M=Uc(r,y,i,v,o),h=Math.min(h,M)}else{const M=Qa(y,e),A=Qa(v,s);to(f,h,o,r,i,M[0],A[0]),to(f,h,o,r,i,M[0],A[1]),to(f,h,o,r,i,M[1],A[0]),to(f,h,o,r,i,M[1],A[1])}}return h}function xl(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 $n{constructor(e,i){this.type=qe,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(Sn(e[1])){const s=e[1];if(s.type==="FeatureCollection")return new $n(s,s.features.map((o=>xl(o.geometry))).flat());if(s.type==="Feature")return new $n(s,xl(s.geometry));if("type"in s&&"coordinates"in s)return new $n(s,xl(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 o=i.geometry(),u=o.flat().map((g=>ws([g.x,g.y],i.canonical)));if(o.length===0)return NaN;const h=new fl(u[0][1]);let f=1/0;for(const g of s){switch(g.type){case"Point":f=Math.min(f,ro(u,!1,[g.coordinates],!1,h,f));break;case"LineString":f=Math.min(f,ro(u,!1,g.coordinates,!0,h,f));break;case"Polygon":f=Math.min(f,io(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 o=i.geometry(),u=o.flat().map((g=>ws([g.x,g.y],i.canonical)));if(o.length===0)return NaN;const h=new fl(u[0][1]);let f=1/0;for(const g of s){switch(g.type){case"Point":f=Math.min(f,ro(u,!0,[g.coordinates],!1,h,f));break;case"LineString":f=Math.min(f,ro(u,!0,g.coordinates,!0,h,f));break;case"Polygon":f=Math.min(f,io(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 o=i.geometry();if(o.length===0||o[0].length===0)return NaN;const u=Ka(o,0).map((g=>g.map((y=>y.map((v=>ws([v.x,v.y],i.canonical))))))),h=new fl(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,io([g.coordinates],!1,y,h,f));break;case"LineString":f=Math.min(f,io(g.coordinates,!0,y,h,f));break;case"Polygon":f=Math.min(f,_h(y,g.coordinates,h,f))}if(f===0)return f}return f})(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class ra{constructor(e){this.type=bt,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 ra(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?Xs(s,this.key):null}eachChild(){}outputDefined(){return!1}}const Ps={"==":Cc,"!=":ll,">":ch,"<":Ac,">=":Ha,"<=":ys,array:Mr,at:Ft,boolean:Mr,case:Ks,coalesce:Un,collator:xs,format:ea,image:vs,in:wt,"index-of":gs,interpolate:wr,"interpolate-hcl":wr,"interpolate-lab":wr,length:bs,let:oi,literal:on,match:Bt,number:Mr,"number-format":cl,object:Mr,slice:jr,step:Pn,string:Mr,"to-boolean":fn,"to-color":fn,"to-number":fn,"to-string":fn,var:ms,within:qn,distance:$n,"global-state":ra};class Nr{constructor(e,i,s,o){this.name=e,this.type=i,this._evaluate=s,this.args=o}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],o=Nr.definitions[s];if(!o)return i.error(`Unknown expression "${s}". If you wanted a literal array, use ["literal", [...]].`,0);const u=Array.isArray(o)?o[0]:o.type,h=Array.isArray(o)?[[o[1],o[2]]]:o.overloads,f=h.filter((([y])=>!Array.isArray(y)||y.length===e.length-1));let g=null;for(const[y,v]of f){g=new Nn(i.registry,no,i.path,null,i.scope);const w=[];let S=!1;for(let M=1;M<e.length;M++){const A=e[M],z=Array.isArray(y)?y[M-1]:y.type,R=g.parse(A,1+w.length,z);if(!R){S=!0;break}w.push(R)}if(!S)if(Array.isArray(y)&&y.length!==w.length)g.error(`Expected ${y.length} arguments, but found ${w.length} instead.`);else{for(let M=0;M<w.length;M++){const A=Array.isArray(y)?y[M]:y.type,z=w[M];g.concat(M+1).checkSubtype(A,z.type)}if(g.errors.length===0)return new Nr(s,u,v,w)}}if(f.length===1)i.errors.push(...g.errors);else{const y=(f.length?f:h).map((([w])=>{return S=w,Array.isArray(S)?`(${S.map(Jt).join(", ")})`:`(${Jt(S.type)}...)`;var S})).join(" | "),v=[];for(let w=1;w<e.length;w++){const S=i.parse(e[w],1+v.length);if(!S)return null;v.push(Jt(S.type))}i.error(`Expected arguments of type ${y}, but found (${v.join(", ")}) instead.`)}return null}static register(e,i){Nr.definitions=i;for(const s in i)e[s]=Nr}}function qc(r,[e,i,s,o]){e=e.evaluate(r),i=i.evaluate(r),s=s.evaluate(r);const u=o?o.evaluate(r):1,h=fs(e,i,s,u);if(h)throw new ai(h);return new Mt(e/255,i/255,s/255,u,!1)}function Zc(r,e){return r in e}function vl(r,e){const i=e[r];return i===void 0?null:i}function Wn(r){return{type:r}}function no(r){if(r instanceof ms)return no(r.boundExpression);if(r instanceof Nr&&r.name==="error"||r instanceof xs||r instanceof qn||r instanceof $n||r instanceof ra)return!1;const e=r instanceof fn||r instanceof Mr;let i=!0;return r.eachChild((s=>{i=e?i&&no(s):i&&s instanceof on})),!!i&&so(r)&&ao(r,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function so(r){if(r instanceof Nr&&(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 qn||r instanceof $n)return!1;let e=!0;return r.eachChild((i=>{e&&!so(i)&&(e=!1)})),e}function na(r){if(r instanceof Nr&&r.name==="feature-state")return!1;let e=!0;return r.eachChild((i=>{e&&!na(i)&&(e=!1)})),e}function ao(r,e){if(r instanceof Nr&&e.indexOf(r.name)>=0)return!1;let i=!0;return r.eachChild((s=>{i&&!ao(s,e)&&(i=!1)})),i}function $c(r){return{result:"success",value:r}}function Ms(r){return{result:"error",value:r}}function Is(r){return r["property-type"]==="data-driven"||r["property-type"]==="cross-faded-data-driven"}function Wc(r){return!!r.expression&&r.expression.parameters.indexOf("zoom")>-1}function bl(r){return!!r.expression&&r.expression.interpolated}function Et(r){return r instanceof Number?"number":r instanceof String?"string":r instanceof Boolean?"boolean":Array.isArray(r)?"array":r===null?"null":typeof r}function oo(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)&&Vi(r)===pn}function yh(r){return r}function Hc(r,e){const i=r.stops&&typeof r.stops[0][0]=="object",s=i||!(i||r.property!==void 0),o=r.type||(bl(e)?"exponential":"interval"),u=(function(v){switch(v.type){case"color":return Mt.parse;case"padding":return ur.parse;case"numberArray":return Ii.parse;case"colorArray":return ut.parse;default:return null}})(e);if(u&&((r=_r({},r)).stops&&(r.stops=r.stops.map((v=>[v[0],u(v[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(v){switch(v){case"exponential":return Xc;case"interval":return vh;case"categorical":return xh;case"identity":return bh;default:throw new Error(`Unknown function type "${v}"`)}})(o);let g,y;if(o==="categorical"){g=Object.create(null);for(const v of r.stops)g[v[0]]=v[1];y=typeof r.stops[0][0]}if(i){const v={},w=[];for(let A=0;A<r.stops.length;A++){const z=r.stops[A],R=z[0].zoom;v[R]===void 0&&(v[R]={zoom:R,type:r.type,property:r.property,default:r.default,stops:[]},w.push(R)),v[R].stops.push([z[0].value,z[1]])}const S=[];for(const A of w)S.push([v[A].zoom,Hc(v[A],e)]);const M={name:"linear"};return{kind:"composite",interpolationType:M,interpolationFactor:wr.interpolationFactor.bind(void 0,M),zoomStops:S.map((A=>A[0])),evaluate:({zoom:A},z)=>Xc({stops:S,base:r.base},e,A).evaluate(A,z)}}if(s){const v=o==="exponential"?{name:"exponential",base:r.base!==void 0?r.base:1}:null;return{kind:"camera",interpolationType:v,interpolationFactor:wr.interpolationFactor.bind(void 0,v),zoomStops:r.stops.map((w=>w[0])),evaluate:({zoom:w})=>f(r,e,w,g,y)}}return{kind:"source",evaluate(v,w){const S=w&&w.properties?w.properties[r.property]:void 0;return S===void 0?sa(r.default,e.default):f(r,e,S,g,y)}}}function sa(r,e,i){return r!==void 0?r:e!==void 0?e:i!==void 0?i:void 0}function xh(r,e,i,s,o){return sa(typeof i===o?s[i]:void 0,r.default,e.default)}function vh(r,e,i){if(Et(i)!=="number")return sa(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 o=_s(r.stops.map((u=>u[0])),i);return r.stops[o][1]}function Xc(r,e,i){const s=r.base!==void 0?r.base:1;if(Et(i)!=="number")return sa(r.default,e.default);const o=r.stops.length;if(o===1||i<=r.stops[0][0])return r.stops[0][1];if(i>=r.stops[o-1][0])return r.stops[o-1][1];const u=_s(r.stops.map((v=>v[0])),i),h=(function(v,w,S,M){const A=M-S,z=v-S;return A===0?0:w===1?z/A:(Math.pow(w,z)-1)/(Math.pow(w,A)-1)})(i,s,r.stops[u][0],r.stops[u+1][0]),f=r.stops[u][1],g=r.stops[u+1][1],y=bi[e.type]||yh;return typeof f.evaluate=="function"?{evaluate(...v){const w=f.evaluate.apply(void 0,v),S=g.evaluate.apply(void 0,v);if(w!==void 0&&S!==void 0)return y(w,S,h,r.colorSpace)}}:y(f,g,h,r.colorSpace)}function bh(r,e,i){switch(e.type){case"color":i=Mt.parse(i);break;case"formatted":i=Pr.fromString(i.toString());break;case"resolvedImage":i=zr.fromString(i.toString());break;case"padding":i=ur.parse(i);break;case"colorArray":i=ut.parse(i);break;case"numberArray":i=Ii.parse(i);break;default:Et(i)===e.type||e.type==="enum"&&e.values[i]||(i=void 0)}return sa(i,r.default,e.default)}Nr.register(Ps,{error:[{kind:"error"},[St],(r,[e])=>{throw new ai(e.evaluate(r))}],typeof:[St,[bt],(r,[e])=>Jt(Vi(e.evaluate(r)))],"to-rgba":[xr(qe,4),[Dr],(r,[e])=>{const[i,s,o,u]=e.evaluate(r).rgb;return[255*i,255*s,255*o,u]}],rgb:[Dr,[qe,qe,qe],qc],rgba:[Dr,[qe,qe,qe,qe],qc],has:{type:Pt,overloads:[[[St],(r,[e])=>Zc(e.evaluate(r),r.properties())],[[St,pn],(r,[e,i])=>Zc(e.evaluate(r),i.evaluate(r))]]},get:{type:bt,overloads:[[[St],(r,[e])=>vl(e.evaluate(r),r.properties())],[[St,pn],(r,[e,i])=>vl(e.evaluate(r),i.evaluate(r))]]},"feature-state":[bt,[St],(r,[e])=>vl(e.evaluate(r),r.featureState||{})],properties:[pn,[],r=>r.properties()],"geometry-type":[St,[],r=>r.geometryType()],id:[bt,[],r=>r.id()],zoom:[qe,[],r=>r.globals.zoom],"heatmap-density":[qe,[],r=>r.globals.heatmapDensity||0],elevation:[qe,[],r=>r.globals.elevation||0],"line-progress":[qe,[],r=>r.globals.lineProgress||0],accumulated:[bt,[],r=>r.globals.accumulated===void 0?null:r.globals.accumulated],"+":[qe,Wn(qe),(r,e)=>{let i=0;for(const s of e)i+=s.evaluate(r);return i}],"*":[qe,Wn(qe),(r,e)=>{let i=1;for(const s of e)i*=s.evaluate(r);return i}],"-":{type:qe,overloads:[[[qe,qe],(r,[e,i])=>e.evaluate(r)-i.evaluate(r)],[[qe],(r,[e])=>-e.evaluate(r)]]},"/":[qe,[qe,qe],(r,[e,i])=>e.evaluate(r)/i.evaluate(r)],"%":[qe,[qe,qe],(r,[e,i])=>e.evaluate(r)%i.evaluate(r)],ln2:[qe,[],()=>Math.LN2],pi:[qe,[],()=>Math.PI],e:[qe,[],()=>Math.E],"^":[qe,[qe,qe],(r,[e,i])=>Math.pow(e.evaluate(r),i.evaluate(r))],sqrt:[qe,[qe],(r,[e])=>Math.sqrt(e.evaluate(r))],log10:[qe,[qe],(r,[e])=>Math.log(e.evaluate(r))/Math.LN10],ln:[qe,[qe],(r,[e])=>Math.log(e.evaluate(r))],log2:[qe,[qe],(r,[e])=>Math.log(e.evaluate(r))/Math.LN2],sin:[qe,[qe],(r,[e])=>Math.sin(e.evaluate(r))],cos:[qe,[qe],(r,[e])=>Math.cos(e.evaluate(r))],tan:[qe,[qe],(r,[e])=>Math.tan(e.evaluate(r))],asin:[qe,[qe],(r,[e])=>Math.asin(e.evaluate(r))],acos:[qe,[qe],(r,[e])=>Math.acos(e.evaluate(r))],atan:[qe,[qe],(r,[e])=>Math.atan(e.evaluate(r))],min:[qe,Wn(qe),(r,e)=>Math.min(...e.map((i=>i.evaluate(r))))],max:[qe,Wn(qe),(r,e)=>Math.max(...e.map((i=>i.evaluate(r))))],abs:[qe,[qe],(r,[e])=>Math.abs(e.evaluate(r))],round:[qe,[qe],(r,[e])=>{const i=e.evaluate(r);return i<0?-Math.round(-i):Math.round(i)}],floor:[qe,[qe],(r,[e])=>Math.floor(e.evaluate(r))],ceil:[qe,[qe],(r,[e])=>Math.ceil(e.evaluate(r))],"filter-==":[Pt,[St,bt],(r,[e,i])=>r.properties()[e.value]===i.value],"filter-id-==":[Pt,[bt],(r,[e])=>r.id()===e.value],"filter-type-==":[Pt,[St],(r,[e])=>r.geometryType()===e.value],"filter-<":[Pt,[St,bt],(r,[e,i])=>{const s=r.properties()[e.value],o=i.value;return typeof s==typeof o&&s<o}],"filter-id-<":[Pt,[bt],(r,[e])=>{const i=r.id(),s=e.value;return typeof i==typeof s&&i<s}],"filter->":[Pt,[St,bt],(r,[e,i])=>{const s=r.properties()[e.value],o=i.value;return typeof s==typeof o&&s>o}],"filter-id->":[Pt,[bt],(r,[e])=>{const i=r.id(),s=e.value;return typeof i==typeof s&&i>s}],"filter-<=":[Pt,[St,bt],(r,[e,i])=>{const s=r.properties()[e.value],o=i.value;return typeof s==typeof o&&s<=o}],"filter-id-<=":[Pt,[bt],(r,[e])=>{const i=r.id(),s=e.value;return typeof i==typeof s&&i<=s}],"filter->=":[Pt,[St,bt],(r,[e,i])=>{const s=r.properties()[e.value],o=i.value;return typeof s==typeof o&&s>=o}],"filter-id->=":[Pt,[bt],(r,[e])=>{const i=r.id(),s=e.value;return typeof i==typeof s&&i>=s}],"filter-has":[Pt,[bt],(r,[e])=>e.value in r.properties()],"filter-has-id":[Pt,[],r=>r.id()!==null&&r.id()!==void 0],"filter-type-in":[Pt,[xr(St)],(r,[e])=>e.value.indexOf(r.geometryType())>=0],"filter-id-in":[Pt,[xr(bt)],(r,[e])=>e.value.indexOf(r.id())>=0],"filter-in-small":[Pt,[St,xr(bt)],(r,[e,i])=>i.value.indexOf(r.properties()[e.value])>=0],"filter-in-large":[Pt,[St,xr(bt)],(r,[e,i])=>(function(s,o,u,h){for(;u<=h;){const f=u+h>>1;if(o[f]===s)return!0;o[f]>s?h=f-1:u=f+1}return!1})(r.properties()[e.value],i.value,0,i.value.length-1)],all:{type:Pt,overloads:[[[Pt,Pt],(r,[e,i])=>e.evaluate(r)&&i.evaluate(r)],[Wn(Pt),(r,e)=>{for(const i of e)if(!i.evaluate(r))return!1;return!0}]]},any:{type:Pt,overloads:[[[Pt,Pt],(r,[e,i])=>e.evaluate(r)||i.evaluate(r)],[Wn(Pt),(r,e)=>{for(const i of e)if(i.evaluate(r))return!0;return!1}]]},"!":[Pt,[Pt],(r,[e])=>!e.evaluate(r)],"is-supported-script":[Pt,[St],(r,[e])=>{const i=r.globals&&r.globals.isSupportedScript;return!i||i(e.evaluate(r))}],upcase:[St,[St],(r,[e])=>e.evaluate(r).toUpperCase()],downcase:[St,[St],(r,[e])=>e.evaluate(r).toLowerCase()],concat:[St,Wn(bt),(r,e)=>e.map((i=>Vn(i.evaluate(r)))).join("")],"resolved-locale":[St,[Gs],(r,[e])=>e.evaluate(r).resolvedLocale()]});class wl{constructor(e,i,s){this.expression=e,this._warningHistory={},this._evaluator=new sl,this._defaultValue=i?(function(o){if(o.type==="color"&&oo(o.default))return new Mt(0,0,0,0);switch(o.type){case"color":return Mt.parse(o.default)||null;case"padding":return ur.parse(o.default)||null;case"numberArray":return Ii.parse(o.default)||null;case"colorArray":return ut.parse(o.default)||null;case"variableAnchorOffsetCollection":return vr.parse(o.default)||null;case"projectionDefinition":return br.parse(o.default)||null;default:return o.default===void 0?null:o.default}})(i):null,this._enumValues=i&&i.type==="enum"?i.values:null,this._globalState=s}evaluateWithoutErrorHandling(e,i,s,o,u,h){return this._globalState&&(e=Hn(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=i,this._evaluator.featureState=s,this._evaluator.canonical=o,this._evaluator.availableImages=u||null,this._evaluator.formattedSection=h,this.expression.evaluate(this._evaluator)}evaluate(e,i,s,o,u,h){this._globalState&&(e=Hn(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=i||null,this._evaluator.featureState=s||null,this._evaluator.canonical=o,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 ai(`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 Es(r){return Array.isArray(r)&&r.length>0&&typeof r[0]=="string"&&r[0]in Ps}function aa(r,e,i){const s=new Nn(Ps,no,[],e?(function(u){const h={color:Dr,string:St,number:qe,enum:St,boolean:Pt,formatted:qs,padding:Ua,numberArray:Zs,colorArray:cs,projectionDefinition:Na,resolvedImage:us,variableAnchorOffsetCollection:$s};return u.type==="array"?xr(h[u.value]||bt,u.length):h[u.type]})(e):void 0),o=s.parse(r,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return o?$c(new wl(o,e,i)):Ms(s.errors)}class lo{constructor(e,i,s){this.kind=e,this._styleExpression=i,this.isStateDependent=e!=="constant"&&!na(i.expression),this.globalStateRefs=Mn(i.expression),this._globalState=s}evaluateWithoutErrorHandling(e,i,s,o,u,h){return this._globalState&&(e=Hn(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,i,s,o,u,h)}evaluate(e,i,s,o,u,h){return this._globalState&&(e=Hn(e,this._globalState)),this._styleExpression.evaluate(e,i,s,o,u,h)}}class Tl{constructor(e,i,s,o,u){this.kind=e,this.zoomStops=s,this._styleExpression=i,this.isStateDependent=e!=="camera"&&!na(i.expression),this.globalStateRefs=Mn(i.expression),this.interpolationType=o,this._globalState=u}evaluateWithoutErrorHandling(e,i,s,o,u,h){return this._globalState&&(e=Hn(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,i,s,o,u,h)}evaluate(e,i,s,o,u,h){return this._globalState&&(e=Hn(e,this._globalState)),this._styleExpression.evaluate(e,i,s,o,u,h)}interpolationFactor(e,i,s){return this.interpolationType?wr.interpolationFactor(this.interpolationType,e,i,s):0}}function Sl(r,e,i){const s=aa(r,e,i);if(s.result==="error")return s;const o=s.value.expression,u=so(o);if(!u&&!Is(e))return Ms([new yr("","data expressions not supported")]);const h=ao(o,["zoom"]);if(!h&&!Wc(e))return Ms([new yr("","zoom expressions not supported")]);const f=uo(o);return f||h?f instanceof yr?Ms([f]):f instanceof wr&&!bl(e)?Ms([new yr("",'"interpolate" expressions cannot be used with this property')]):$c(f?new Tl(u?"camera":"composite",s.value,f.labels,f instanceof wr?f.interpolation:void 0,i):new lo(u?"constant":"source",s.value,i)):Ms([new yr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class co{constructor(e,i){this._parameters=e,this._specification=i,_r(this,Hc(this._parameters,this._specification))}static deserialize(e){return new co(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function uo(r){let e=null;if(r instanceof oi)e=uo(r.result);else if(r instanceof Un){for(const i of r.args)if(e=uo(i),e)break}else(r instanceof Pn||r instanceof wr)&&r.input instanceof Nr&&r.input.name==="zoom"&&(e=r);return e instanceof yr||r.eachChild((i=>{const s=uo(i);s instanceof yr?e=s:!e&&s?e=new yr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&s&&e!==s&&(e=new yr("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function Mn(r,e=new Set){return r instanceof ra&&e.add(r.key),r.eachChild((i=>{Mn(i,e)})),e}function Hn(r,e){const{zoom:i,heatmapDensity:s,elevation:o,lineProgress:u,isSupportedScript:h,accumulated:f}=r??{};return{zoom:i,heatmapDensity:s,elevation:o,lineProgress:u,isSupportedScript:h,accumulated:f,globalState:e}}function Pl(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(!Pl(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}const wh={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function oa(r,e){if(r==null)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};Pl(r)||(r=la(r));const i=aa(r,wh,e);if(i.result==="error")throw new Error(i.value.map((s=>`${s.key}: ${s.message}`)).join(", "));return{filter:(s,o,u)=>i.value.evaluate(s,o,{},u),needGeometry:Yc(r),getGlobalStateRefs:()=>Mn(i.value.expression)}}function Th(r,e){return r<e?-1:r>e?1:0}function Yc(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(Yc(r[e]))return!0;return!1}function la(r){if(!r)return!0;const e=r[0];return r.length<=1?e!=="any":e==="=="?ho(r[1],r[2],"=="):e==="!="?ca(ho(r[1],r[2],"==")):e==="<"||e===">"||e==="<="||e===">="?ho(r[1],r[2],e):e==="any"?(i=r.slice(1),["any"].concat(i.map(la))):e==="all"?["all"].concat(r.slice(1).map(la)):e==="none"?["all"].concat(r.slice(1).map(la).map(ca)):e==="in"?Kc(r[1],r.slice(2)):e==="!in"?ca(Kc(r[1],r.slice(2))):e==="has"?Jc(r[1]):e!=="!has"||ca(Jc(r[1]));var i}function ho(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 Kc(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(Th)]]:["filter-in-small",r,["literal",e]]}}function Jc(r){switch(r){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",r]}}function ca(r){return["!",r]}function po(r){const e=typeof r;if(e==="number"||e==="boolean"||e==="string"||r==null)return JSON.stringify(r);if(Array.isArray(r)){let o="[";for(const u of r)o+=`${po(u)},`;return`${o}]`}const i=Object.keys(r).sort();let s="{";for(let o=0;o<i.length;o++)s+=`${JSON.stringify(i[o])}:${po(r[i[o]])},`;return`${s}}`}function Qc(r){let e="";for(const i of ni)e+=`/${po(r[i])}`;return e}function eu(r){const e=r.value;return e?[new Re(r.key,e,"constants have been deprecated as of v8")]:[]}function ji(r){return r instanceof Number||r instanceof String||r instanceof Boolean?r.valueOf():r}function Xn(r){if(Array.isArray(r))return r.map(Xn);if(r instanceof Object&&!(r instanceof Number||r instanceof String||r instanceof Boolean)){const e={};for(const i in r)e[i]=Xn(r[i]);return e}return ji(r)}function kr(r){const e=r.key,i=r.value,s=r.valueSpec||{},o=r.objectElementValidators||{},u=r.style,h=r.styleSpec,f=r.validateSpec;let g=[];const y=Et(i);if(y!=="object")return[new Re(e,i,`object expected, ${y} found`)];for(const v in i){const w=v.split(".")[0],S=Xs(s,w)||s["*"];let M;if(Xs(o,w))M=o[w];else if(Xs(s,w)){if(i[v]===void 0)continue;M=f}else if(o["*"])M=o["*"];else{if(!s["*"]){g.push(new Re(e,i[v],`unknown property "${v}"`));continue}M=f}g=g.concat(M({key:(e&&`${e}.`)+v,value:i[v],valueSpec:S,style:u,styleSpec:h,object:i,objectKey:v,validateSpec:f},i))}for(const v in s)o[v]||s[v].required&&s[v].default===void 0&&i[v]===void 0&&g.push(new Re(e,i,`missing required property "${v}"`));return g}function fo(r){const e=r.value,i=r.valueSpec,s=r.style,o=r.styleSpec,u=r.key,h=r.arrayElementValidator||r.validateSpec;if(Et(e)!=="array")return[new Re(u,e,`array expected, ${Et(e)} found`)];if(i.length&&e.length!==i.length)return[new Re(u,e,`array length ${i.length} expected, length ${e.length} found`)];let f={type:i.value,values:i.values};o.$version<7&&(f.function=i.function),Et(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:o,key:`${u}[${y}]`}));return g}function ua(r){const e=r.key,i=r.value,s=r.valueSpec;let o=Et(i);return o==="number"&&i!=i&&(o="NaN"),o!=="number"?[new Re(e,i,`number expected, ${o} found`)]:"minimum"in s&&i<s.minimum?[new Re(e,i,`${i} is less than the minimum value ${s.minimum}`)]:"maximum"in s&&i>s.maximum?[new Re(e,i,`${i} is greater than the maximum value ${s.maximum}`)]:[]}function mo(r){const e=r.valueSpec,i=ji(r.value.type);let s,o,u,h={};const f=i!=="categorical"&&r.value.property===void 0,g=!f,y=Et(r.value.stops)==="array"&&Et(r.value.stops[0])==="array"&&Et(r.value.stops[0][0])==="object",v=kr({key:r.key,value:r.value,valueSpec:r.styleSpec.function,validateSpec:r.validateSpec,style:r.style,styleSpec:r.styleSpec,objectElementValidators:{stops:function(M){if(i==="identity")return[new Re(M.key,M.value,'identity function may not have a "stops" property')];let A=[];const z=M.value;return A=A.concat(fo({key:M.key,value:z,valueSpec:M.valueSpec,validateSpec:M.validateSpec,style:M.style,styleSpec:M.styleSpec,arrayElementValidator:w})),Et(z)==="array"&&z.length===0&&A.push(new Re(M.key,z,"array must have at least one stop")),A},default:function(M){return M.validateSpec({key:M.key,value:M.value,valueSpec:e,validateSpec:M.validateSpec,style:M.style,styleSpec:M.styleSpec})}}});return i==="identity"&&f&&v.push(new Re(r.key,r.value,'missing required property "property"')),i==="identity"||r.value.stops||v.push(new Re(r.key,r.value,'missing required property "stops"')),i==="exponential"&&r.valueSpec.expression&&!bl(r.valueSpec)&&v.push(new Re(r.key,r.value,"exponential functions not supported")),r.styleSpec.$version>=8&&(g&&!Is(r.valueSpec)?v.push(new Re(r.key,r.value,"property functions not supported")):f&&!Wc(r.valueSpec)&&v.push(new Re(r.key,r.value,"zoom functions not supported"))),i!=="categorical"&&!y||r.value.property!==void 0||v.push(new Re(r.key,r.value,'"property" property is required')),v;function w(M){let A=[];const z=M.value,R=M.key;if(Et(z)!=="array")return[new Re(R,z,`array expected, ${Et(z)} found`)];if(z.length!==2)return[new Re(R,z,`array length 2 expected, length ${z.length} found`)];if(y){if(Et(z[0])!=="object")return[new Re(R,z,`object expected, ${Et(z[0])} found`)];if(z[0].zoom===void 0)return[new Re(R,z,"object stop key must have zoom")];if(z[0].value===void 0)return[new Re(R,z,"object stop key must have value")];if(u&&u>ji(z[0].zoom))return[new Re(R,z[0].zoom,"stop zoom values must appear in ascending order")];ji(z[0].zoom)!==u&&(u=ji(z[0].zoom),o=void 0,h={}),A=A.concat(kr({key:`${R}[0]`,value:z[0],valueSpec:{zoom:{}},validateSpec:M.validateSpec,style:M.style,styleSpec:M.styleSpec,objectElementValidators:{zoom:ua,value:S}}))}else A=A.concat(S({key:`${R}[0]`,value:z[0],validateSpec:M.validateSpec,style:M.style,styleSpec:M.styleSpec},z));return Es(Xn(z[1]))?A.concat([new Re(`${R}[1]`,z[1],"expressions are not allowed in function stops.")]):A.concat(M.validateSpec({key:`${R}[1]`,value:z[1],valueSpec:e,validateSpec:M.validateSpec,style:M.style,styleSpec:M.styleSpec}))}function S(M,A){const z=Et(M.value),R=ji(M.value),j=M.value!==null?M.value:A;if(s){if(z!==s)return[new Re(M.key,j,`${z} stop domain type must match previous stop domain type ${s}`)]}else s=z;if(z!=="number"&&z!=="string"&&z!=="boolean")return[new Re(M.key,j,"stop domain value must be a number, string, or boolean")];if(z!=="number"&&i!=="categorical"){let X=`number expected, ${z} found`;return Is(e)&&i===void 0&&(X+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Re(M.key,j,X)]}return i!=="categorical"||z!=="number"||isFinite(R)&&Math.floor(R)===R?i!=="categorical"&&z==="number"&&o!==void 0&&R<o?[new Re(M.key,j,"stop domain values must appear in ascending order")]:(o=R,i==="categorical"&&R in h?[new Re(M.key,j,"stop domain values must be unique")]:(h[R]=!0,[])):[new Re(M.key,j,`integer expected, found ${R}`)]}}function In(r){const e=(r.expressionContext==="property"?Sl:aa)(Xn(r.value),r.valueSpec);if(e.result==="error")return e.value.map((s=>new Re(`${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 Re(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"&&!na(i))return[new Re(r.key,r.value,'"feature-state" data expressions are not supported with layout properties.')];if(r.expressionContext==="filter"&&!na(i))return[new Re(r.key,r.value,'"feature-state" data expressions are not supported with filters.')];if(r.expressionContext&&r.expressionContext.indexOf("cluster")===0){if(!ao(i,["zoom","feature-state"]))return[new Re(r.key,r.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(r.expressionContext==="cluster-initial"&&!so(i))return[new Re(r.key,r.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function ha(r){const e=r.key,i=r.value,s=Et(i);return s!=="string"?[new Re(e,i,`color expected, ${s} found`)]:Mt.parse(String(i))?[]:[new Re(e,i,`color expected, "${i}" found`)]}function Yn(r){const e=r.key,i=r.value,s=r.valueSpec,o=[];return Array.isArray(s.values)?s.values.indexOf(ji(i))===-1&&o.push(new Re(e,i,`expected one of [${s.values.join(", ")}], ${JSON.stringify(i)} found`)):Object.keys(s.values).indexOf(ji(i))===-1&&o.push(new Re(e,i,`expected one of [${Object.keys(s.values).join(", ")}], ${JSON.stringify(i)} found`)),o}function Cs(r){return Pl(Xn(r.value))?In(_r({},r,{expressionContext:"filter",valueSpec:{value:"boolean"}})):tu(r)}function tu(r){const e=r.value,i=r.key;if(Et(e)!=="array")return[new Re(i,e,`array expected, ${Et(e)} found`)];const s=r.styleSpec;let o,u=[];if(e.length<1)return[new Re(i,e,"filter array must have at least 1 element")];switch(u=u.concat(Yn({key:`${i}[0]`,value:e[0],valueSpec:s.filter_operator,style:r.style,styleSpec:r.styleSpec})),ji(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&ji(e[1])==="$type"&&u.push(new Re(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&u.push(new Re(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(o=Et(e[1]),o!=="string"&&u.push(new Re(`${i}[1]`,e[1],`string expected, ${o} found`)));for(let h=2;h<e.length;h++)o=Et(e[h]),ji(e[1])==="$type"?u=u.concat(Yn({key:`${i}[${h}]`,value:e[h],valueSpec:s.geometry_type,style:r.style,styleSpec:r.styleSpec})):o!=="string"&&o!=="number"&&o!=="boolean"&&u.push(new Re(`${i}[${h}]`,e[h],`string, number, or boolean expected, ${o} found`));break;case"any":case"all":case"none":for(let h=1;h<e.length;h++)u=u.concat(tu({key:`${i}[${h}]`,value:e[h],style:r.style,styleSpec:r.styleSpec}));break;case"has":case"!has":o=Et(e[1]),e.length!==2?u.push(new Re(i,e,`filter array for "${e[0]}" operator must have 2 elements`)):o!=="string"&&u.push(new Re(`${i}[1]`,e[1],`string expected, ${o} found`))}return u}function iu(r,e){const i=r.key,s=r.validateSpec,o=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:o,styleSpec:u});const v=r.valueSpec||g[f];if(!v)return[new Re(i,h,`unknown property "${f}"`)];let w;if(Et(h)==="string"&&Is(v)&&!v.tokens&&(w=/^{([^}]+)}$/.exec(h)))return[new Re(i,h,`"${f}" does not support interpolation syntax
5
+ Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(w[1])} }\`.`)];const S=[];return r.layerType==="symbol"&&f==="text-font"&&oo(Xn(h))&&ji(h.type)==="identity"&&S.push(new Re(i,h,'"text-font" does not support identity functions')),S.concat(s({key:r.key,value:h,valueSpec:v,style:o,styleSpec:u,expressionContext:"property",propertyType:e,propertyKey:f}))}function ru(r){return iu(r,"paint")}function nu(r){return iu(r,"layout")}function su(r){let e=[];const i=r.value,s=r.key,o=r.style,u=r.styleSpec;if(Et(i)!=="object")return[new Re(s,i,`object expected, ${Et(i)} found`)];i.type||i.ref||e.push(new Re(s,i,'either "type" or "ref" is required'));let h=ji(i.type);const f=ji(i.ref);if(i.id){const g=ji(i.id);for(let y=0;y<r.arrayIndex;y++){const v=o.layers[y];ji(v.id)===g&&e.push(new Re(s,i.id,`duplicate layer id "${i.id}", previously used at line ${v.id.__line__}`))}}if("ref"in i){let g;["type","source","source-layer","filter","layout"].forEach((y=>{y in i&&e.push(new Re(s,i[y],`"${y}" is prohibited for ref layers`))})),o.layers.forEach((y=>{ji(y.id)===f&&(g=y)})),g?g.ref?e.push(new Re(s,i.ref,"ref cannot reference another ref layer")):h=ji(g.type):e.push(new Re(s,i.ref,`ref layer "${f}" not found`))}else if(h!=="background")if(i.source){const g=o.sources&&o.sources[i.source],y=g&&ji(g.type);g?y==="vector"&&h==="raster"?e.push(new Re(s,i.source,`layer "${i.id}" requires a raster source`)):y!=="raster-dem"&&h==="hillshade"||y!=="raster-dem"&&h==="color-relief"?e.push(new Re(s,i.source,`layer "${i.id}" requires a raster-dem source`)):y==="raster"&&h!=="raster"?e.push(new Re(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 Re(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 Re(s,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new Re(s,i,`layer "${i.id}" must specify a "source-layer"`)):e.push(new Re(s,i.source,`source "${i.source}" not found`))}else e.push(new Re(s,i,'missing required property "source"'));return e=e.concat(kr({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:Cs,layout:g=>kr({layer:i,key:g.key,value:g.value,style:g.style,styleSpec:g.styleSpec,validateSpec:g.validateSpec,objectElementValidators:{"*":y=>nu(_r({layerType:h},y))}}),paint:g=>kr({layer:i,key:g.key,value:g.value,style:g.style,styleSpec:g.styleSpec,validateSpec:g.validateSpec,objectElementValidators:{"*":y=>ru(_r({layerType:h},y))}})}})),e}function En(r){const e=r.value,i=r.key,s=Et(e);return s!=="string"?[new Re(i,e,`string expected, ${s} found`)]:[]}const Ml={promoteId:function({key:r,value:e}){if(Et(e)==="string")return En({key:r,value:e});{const i=[];for(const s in e)i.push(...En({key:`${r}.${s}`,value:e[s]}));return i}}};function Il(r){const e=r.value,i=r.key,s=r.styleSpec,o=r.style,u=r.validateSpec;if(!e.type)return[new Re(i,e,'"type" is required')];const h=ji(e.type);let f;switch(h){case"vector":case"raster":return f=kr({key:i,value:e,valueSpec:s[`source_${h.replace("-","_")}`],style:r.style,styleSpec:s,objectElementValidators:Ml,validateSpec:u}),f;case"raster-dem":return f=(function(g){var y;const v=(y=g.sourceName)!==null&&y!==void 0?y:"",w=g.value,S=g.styleSpec,M=S.source_raster_dem,A=g.style;let z=[];const R=Et(w);if(w===void 0)return z;if(R!=="object")return z.push(new Re("source_raster_dem",w,`object expected, ${R} found`)),z;const j=ji(w.encoding)==="custom",X=["redFactor","greenFactor","blueFactor","baseShift"],N=g.value.encoding?`"${g.value.encoding}"`:"Default";for(const G in w)!j&&X.includes(G)?z.push(new Re(G,w[G],`In "${v}": "${G}" is only valid when "encoding" is set to "custom". ${N} encoding found`)):M[G]?z=z.concat(g.validateSpec({key:G,value:w[G],valueSpec:M[G],validateSpec:g.validateSpec,style:A,styleSpec:S})):z.push(new Re(G,w[G],`unknown property "${G}"`));return z})({sourceName:i,value:e,style:r.style,styleSpec:s,validateSpec:u}),f;case"geojson":if(f=kr({key:i,value:e,valueSpec:s.source_geojson,style:o,styleSpec:s,validateSpec:u,objectElementValidators:Ml}),e.cluster)for(const g in e.clusterProperties){const[y,v]=e.clusterProperties[g],w=typeof y=="string"?[y,["accumulated"],["get",g]]:y;f.push(...In({key:`${i}.${g}.map`,value:v,expressionContext:"cluster-map"})),f.push(...In({key:`${i}.${g}.reduce`,value:w,expressionContext:"cluster-reduce"}))}return f;case"video":return kr({key:i,value:e,valueSpec:s.source_video,style:o,validateSpec:u,styleSpec:s});case"image":return kr({key:i,value:e,valueSpec:s.source_image,style:o,validateSpec:u,styleSpec:s});case"canvas":return[new Re(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Yn({key:`${i}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function da(r){const e=r.value,i=r.styleSpec,s=i.light,o=r.style;let u=[];const h=Et(e);if(e===void 0)return u;if(h!=="object")return u=u.concat([new Re("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:o,styleSpec:i}):s[f]?r.validateSpec({key:f,value:e[f],valueSpec:s[f],validateSpec:r.validateSpec,style:o,styleSpec:i}):[new Re(f,e[f],`unknown property "${f}"`)])}return u}function au(r){const e=r.value,i=r.styleSpec,s=i.sky,o=r.style,u=Et(e);if(e===void 0)return[];if(u!=="object")return[new Re("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:o,styleSpec:i}):[new Re(f,e[f],`unknown property "${f}"`)]);return h}function El(r){const e=r.value,i=r.styleSpec,s=i.terrain,o=r.style;let u=[];const h=Et(e);if(e===void 0)return u;if(h!=="object")return u=u.concat([new Re("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:o,styleSpec:i}):[new Re(f,e[f],`unknown property "${f}"`)]);return u}function Cl(r){let e=[];const i=r.value,s=r.key;if(Array.isArray(i)){const o=[],u=[];for(const h in i)i[h].id&&o.includes(i[h].id)&&e.push(new Re(s,i,`all the sprites' ids must be unique, but ${i[h].id} is duplicated`)),o.push(i[h].id),i[h].url&&u.includes(i[h].url)&&e.push(new Re(s,i,`all the sprites' URLs must be unique, but ${i[h].url} is duplicated`)),u.push(i[h].url),e=e.concat(kr({key:`${s}[${h}]`,value:i[h],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:r.validateSpec}));return e}return En({key:s,value:i})}function ou(r){return!!r&&r.constructor===Object}function Al(r){return ou(r.value)?[]:[new Re(r.key,r.value,`object expected, ${Et(r.value)} found`)]}const Dl={"*":()=>[],array:fo,boolean:function(r){const e=r.value,i=r.key,s=Et(e);return s!=="boolean"?[new Re(i,e,`boolean expected, ${s} found`)]:[]},number:ua,color:ha,constants:eu,enum:Yn,filter:Cs,function:mo,layer:su,object:kr,source:Il,light:da,sky:au,terrain:El,projection:function(r){const e=r.value,i=r.styleSpec,s=i.projection,o=r.style,u=Et(e);if(e===void 0)return[];if(u!=="object")return[new Re("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:o,styleSpec:i}):[new Re(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=Et(i);return s!=="array"||(function(o){return Array.isArray(o)&&o.length===3&&typeof o[0]=="string"&&typeof o[1]=="string"&&typeof o[2]=="number"})(i)||(function(o){return!!["interpolate","step","literal"].includes(o[0])})(i)?["array","string"].includes(s)?[]:[new Re(e,i,`projection expected, invalid type "${s}" found`)]:[new Re(e,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:En,formatted:function(r){return En(r).length===0?[]:In(r)},resolvedImage:function(r){return En(r).length===0?[]:In(r)},padding:function(r){const e=r.key,i=r.value;if(Et(i)==="array"){if(i.length<1||i.length>4)return[new Re(e,i,`padding requires 1 to 4 values; ${i.length} values found`)];const s={type:"number"};let o=[];for(let u=0;u<i.length;u++)o=o.concat(r.validateSpec({key:`${e}[${u}]`,value:i[u],validateSpec:r.validateSpec,valueSpec:s}));return o}return ua({key:e,value:i,valueSpec:{}})},numberArray:function(r){const e=r.key,i=r.value;if(Et(i)==="array"){const s={type:"number"};if(i.length<1)return[new Re(e,i,"array length at least 1 expected, length 0 found")];let o=[];for(let u=0;u<i.length;u++)o=o.concat(r.validateSpec({key:`${e}[${u}]`,value:i[u],validateSpec:r.validateSpec,valueSpec:s}));return o}return ua({key:e,value:i,valueSpec:{}})},colorArray:function(r){const e=r.key,i=r.value;if(Et(i)==="array"){if(i.length<1)return[new Re(e,i,"array length at least 1 expected, length 0 found")];let s=[];for(let o=0;o<i.length;o++)s=s.concat(ha({key:`${e}[${o}]`,value:i[o]}));return s}return ha({key:e,value:i})},variableAnchorOffsetCollection:function(r){const e=r.key,i=r.value,s=Et(i),o=r.styleSpec;if(s!=="array"||i.length<1||i.length%2!=0)return[new Re(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(Yn({key:`${e}[${h}]`,value:i[h],valueSpec:o.layout_symbol["text-anchor"]})),u=u.concat(fo({key:`${e}[${h+1}]`,value:i[h+1],valueSpec:{length:2,value:"number"},validateSpec:r.validateSpec,style:r.style,styleSpec:o}));return u},sprite:Cl,state:Al,fontFaces:function(r){const e=r.key,i=r.value,s=r.validateSpec,o=r.styleSpec,u=r.style;if(!ou(i))return[new Re(e,i,`object expected, ${Et(i)} found`)];const h=[];for(const f in i){const g=i[f],y=Et(g);if(y==="string")h.push(...En({key:`${e}.${f}`,value:g}));else if(y==="array"){const v={url:{type:"string",required:!0},"unicode-range":{type:"array",value:"string"}};for(const[w,S]of g.entries())h.push(...kr({key:`${e}.${f}[${w}]`,value:S,valueSpec:v,styleSpec:o,style:u,validateSpec:s}))}else h.push(new Re(`${e}.${f}`,g,`string or array expected, ${y} found`))}return h}};function Cn(r){const e=r.value,i=r.valueSpec,s=r.styleSpec;return r.validateSpec=Cn,i.expression&&oo(ji(e))?mo(r):i.expression&&Es(Xn(e))?In(r):i.type&&Dl[i.type]?Dl[i.type](r):kr(_r({},r,{valueSpec:i.type?s[i.type]:i}))}function lu(r){const e=r.value,i=r.key,s=En(r);return s.length||(e.indexOf("{fontstack}")===-1&&s.push(new Re(i,e,'"glyphs" url must include a "{fontstack}" token')),e.indexOf("{range}")===-1&&s.push(new Re(i,e,'"glyphs" url must include a "{range}" token'))),s}function Ur(r,e=ye){let i=[];return i=i.concat(Cn({key:"",value:r,valueSpec:e.$root,styleSpec:e,style:r,validateSpec:Cn,objectElementValidators:{glyphs:lu,"*":()=>[]}})),r.constants&&(i=i.concat(eu({key:"constants",value:r.constants}))),cu(i)}function Yr(r){return function(e){return r(Object.assign({},e,{validateSpec:Cn}))}}function cu(r){return[].concat(r).sort(((e,i)=>e.line-i.line))}function Kr(r){return function(...e){return cu(r.apply(this,e))}}Ur.source=Kr(Yr(Il)),Ur.sprite=Kr(Yr(Cl)),Ur.glyphs=Kr(Yr(lu)),Ur.light=Kr(Yr(da)),Ur.sky=Kr(Yr(au)),Ur.terrain=Kr(Yr(El)),Ur.state=Kr(Yr(Al)),Ur.layer=Kr(Yr(su)),Ur.filter=Kr(Yr(Cs)),Ur.paintProperty=Kr(Yr(ru)),Ur.layoutProperty=Kr(Yr(nu));const Sh={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"};class pa{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=aa(e,Sh,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=Mn(i.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}}const fa=ye,Ji=Ur,ma=Ji.light,uu=Ji.sky,Ph=Ji.paintProperty,Mh=Ji.layoutProperty;function As(r,e){let i=!1;if(e&&e.length)for(const s of e)r.fire(new ti(new Error(s.message))),i=!0;return i}class Ds{constructor(e,i,s){const o=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],v=h[3+g+1];o.push(y===v?null:h.subarray(y,v))}const f=h[3+o.length+1];this.keys=h.subarray(h[3+o.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++)o.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,o,u){this._forEachCell(i,s,o,u,this._insertCell,this.uid++,void 0,void 0),this.keys.push(e),this.bboxes.push(i),this.bboxes.push(s),this.bboxes.push(o),this.bboxes.push(u)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(e,i,s,o,u,h){this.cells[u].push(h)}query(e,i,s,o,u){const h=this.min,f=this.max;if(e<=h&&i<=h&&f<=s&&f<=o&&!u)return Array.prototype.slice.call(this.keys);{const g=[];return this._forEachCell(e,i,s,o,this._queryCell,g,{},u),g}}_queryCell(e,i,s,o,u,h,f,g){const y=this.cells[u];if(y!==null){const v=this.keys,w=this.bboxes;for(let S=0;S<y.length;S++){const M=y[S];if(f[M]===void 0){const A=4*M;(g?g(w[A+0],w[A+1],w[A+2],w[A+3]):e<=w[A+2]&&i<=w[A+3]&&s>=w[A+0]&&o>=w[A+1])?(f[M]=!0,h.push(v[M])):f[M]=!1}}}}_forEachCell(e,i,s,o,u,h,f,g){const y=this._convertToCellCoord(e),v=this._convertToCellCoord(i),w=this._convertToCellCoord(s),S=this._convertToCellCoord(o);for(let M=y;M<=w;M++)for(let A=v;A<=S;A++){const z=this.d*A+M;if((!g||g(this._convertFromCellCoord(M),this._convertFromCellCoord(A),this._convertFromCellCoord(M+1),this._convertFromCellCoord(A+1)))&&u.call(this,e,i,s,o,z,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 o=new Int32Array(i+s+this.keys.length+this.bboxes.length);o[0]=this.extent,o[1]=this.n,o[2]=this.padding;let u=i;for(let h=0;h<e.length;h++){const f=e[h];o[3+h]=u,o.set(f,u),u+=f.length}return o[3+e.length]=u,o.set(this.keys,u),u+=this.keys.length,o[3+e.length+1]=u,o.set(this.bboxes,u),u+=this.bboxes.length,o.buffer}static serialize(e,i){const s=e.toArrayBuffer();return i&&i.push(s),{buffer:s}}static deserialize(e){return new Ds(e.buffer)}}const Jr={};function Xe(r,e,i={}){if(Jr[r])throw new Error(`${r} is already registered.`);Object.defineProperty(e,"_classRegistryKey",{value:r,writeable:!1}),Jr[r]={klass:e,omit:i.omit||[],shallow:i.shallow||[]}}Xe("Object",Object),Xe("Set",Set),Xe("TransferableGridIndex",Ds),Xe("Color",Mt),Xe("Error",Error),Xe("AJAXError",ae),Xe("ResolvedImage",zr),Xe("StylePropertyFunction",co),Xe("StyleExpression",wl,{omit:["_evaluator"]}),Xe("ZoomDependentExpression",Tl),Xe("ZoomConstantExpression",lo),Xe("CompoundExpression",Nr,{omit:["_evaluate"]});for(const r in Ps)Ps[r]._classRegistryKey||Xe(`Expression_${r}`,Ps[r]);function go(r){return r&&typeof ArrayBuffer<"u"&&(r instanceof ArrayBuffer||r.constructor&&r.constructor.name==="ArrayBuffer")}function zl(r){return r.$name||r.constructor._classRegistryKey}function zs(r){return!(function(e){if(e===null||typeof e!="object")return!1;const i=zl(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||go(r)||pt(r)||ArrayBuffer.isView(r)||r instanceof ImageData)}function ga(r,e){if(zs(r))return(go(r)||pt(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(ga(h,e));return u}if(typeof r!="object")throw new Error("can't serialize object of type "+typeof r);const i=zl(r);if(!i)throw new Error(`can't serialize object of unregistered class ${r.constructor.name}`);if(!Jr[i])throw new Error(`${i} is not registered.`);const{klass:s}=Jr[i],o=s.serialize?s.serialize(r,e):{};if(s.serialize){if(e&&o===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)||Jr[i].omit.indexOf(u)>=0)continue;const h=r[u];o[u]=Jr[i].shallow.indexOf(u)>=0?h:ga(h,e)}r instanceof Error&&(o.message=r.message)}if(o.$name)throw new Error("$name property is reserved for worker serialization logic.");return i!=="Object"&&(o.$name=i),o}function _a(r){if(zs(r))return r;if(Array.isArray(r))return r.map(_a);if(typeof r!="object")throw new Error("can't deserialize object of type "+typeof r);const e=zl(r)||"Object";if(!Jr[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:i}=Jr[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 o of Object.keys(r)){if(o==="$name")continue;const u=r[o];s[o]=Jr[e].shallow.indexOf(o)>=0?u:_a(u)}return s}class kl{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 ya(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 Rl(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 hu(r){return/\s/u.test(String.fromCodePoint(r))}function ks(r){for(const e of r)if(Rl(e.codePointAt(0)))return!0;return!1}function Ih(r){for(const e of r)if(!du(e.codePointAt(0)))return!1;return!0}function _o(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 yo=_o(["Arab","Dupl","Mong","Ougr","Syrc"]);function du(r){return!yo.test(String.fromCodePoint(r))}function Fl(r){return!(Rl(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 pu=_o(["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 Ll(r){return pu.test(String.fromCodePoint(r))}function Bl(r,e){return!(!e&&Ll(r)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(r)))}function fu(r){for(const e of r)if(Ll(e.codePointAt(0)))return!0;return!1}const An=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(An.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 o=new Promise((u=>setTimeout((()=>u()),this.TIMEOUT)));if(yield Promise.race([s,o]),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 ii{constructor(e,i){this.isSupportedScript=Eh,this.zoom=e,i?(this.now=i.now||0,this.fadeDuration=i.fadeDuration||0,this.zoomHistory=i.zoomHistory||new kl,this.transition=i.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new kl,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 Eh(r){return(function(e,i){for(const s of e)if(!Bl(s.codePointAt(0),i))return!1;return!0})(r,An.getRTLTextPluginStatus()==="loaded")}const xa="-transition";class xo{constructor(e,i,s){this.property=e,this.value=i,this.expression=(function(o,u,h){if(oo(o))return new co(o,u);if(Es(o)){const f=Sl(o,u,h);if(f.result==="error")throw new Error(f.value.map((g=>`${g.key}: ${g.message}`)).join(", "));return f.value}{let f=o;return u.type==="color"&&typeof o=="string"?f=Mt.parse(o):u.type!=="padding"||typeof o!="number"&&!Array.isArray(o)?u.type!=="numberArray"||typeof o!="number"&&!Array.isArray(o)?u.type!=="colorArray"||typeof o!="string"&&!Array.isArray(o)?u.type==="variableAnchorOffsetCollection"&&Array.isArray(o)?f=vr.parse(o):u.type==="projectionDefinition"&&typeof o=="string"&&(f=br.parse(o)):f=ut.parse(o):f=Ii.parse(o):f=ur.parse(o),{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 vo{constructor(e,i){this.property=e,this.value=new xo(e,void 0,i)}transitioned(e,i){return new mu(this.property,this.value,i,lt({},e.transition,this.transition),e.now)}untransitioned(){return new mu(this.property,this.value,null,{},0)}}class Ol{constructor(e,i){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=i}getValue(e){return Rt(this._values[e].value.value)}setValue(e,i){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new vo(this._values[e].property,this._globalState)),this._values[e].value=new xo(this._values[e].property,i===null?void 0:Rt(i),this._globalState)}getTransition(e){return Rt(this._values[e].transition)}setTransition(e,i){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new vo(this._values[e].property,this._globalState)),this._values[e].transition=Rt(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 o=this.getTransition(i);o!==void 0&&(e[`${i}${xa}`]=o)}return e}transitioned(e,i){const s=new gu(this._properties);for(const o of Object.keys(this._values))s._values[o]=this._values[o].transitioned(e,i._values[o]);return s}untransitioned(){const e=new gu(this._properties);for(const i of Object.keys(this._values))e._values[i]=this._values[i].untransitioned();return e}}class mu{constructor(e,i,s,o,u){this.property=e,this.value=i,this.begin=u+o.delay||0,this.end=this.begin+o.duration||0,e.specification.transition&&(o.delay||o.duration)&&(this.prior=s)}possiblyEvaluate(e,i,s){const o=e.now||0,u=this.value.possiblyEvaluate(e,i,s),h=this.prior;if(h){if(o>this.end)return this.prior=null,u;if(this.value.isDataDriven())return this.prior=null,u;if(o<this.begin)return h.possiblyEvaluate(e,i,s);{const f=(o-this.begin)/(this.end-this.begin);return this.property.interpolate(h.possiblyEvaluate(e,i,s),u,tt(f))}}return u}}class gu{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,i,s){const o=new va(this._properties);for(const u of Object.keys(this._values))o._values[u]=this._values[u].possiblyEvaluate(e,i,s);return o}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class _u{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 Rt(this._values[e].value)}setValue(e,i){this._values[e]=new xo(this._values[e].property,i===null?void 0:Rt(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 o=new va(this._properties);for(const u of Object.keys(this._values))o._values[u]=this._values[u].possiblyEvaluate(e,i,s);return o}}class Qr{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,o){return this.property.evaluate(this.value,this.parameters,e,i,s,o)}}class va{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class et{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 o=bi[this.specification.type];return o?o(e,i,s):e}}class nt{constructor(e,i){this.specification=e,this.overrides=i}possiblyEvaluate(e,i,s,o){return new Qr(this,e.expression.kind==="constant"||e.expression.kind==="camera"?{kind:"constant",value:e.expression.evaluate(i,null,{},s,o)}: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 Qr(this,{kind:"constant",value:void 0},e.parameters);const o=bi[this.specification.type];if(o){const u=o(e.value.value,i.value.value,s);return new Qr(this,{kind:"constant",value:u},e.parameters)}return e}evaluate(e,i,s,o,u,h){return e.kind==="constant"?e.value:e.evaluate(i,s,o,u,h)}}class ba extends nt{possiblyEvaluate(e,i,s,o){if(e.value===void 0)return new Qr(this,{kind:"constant",value:void 0},i);if(e.expression.kind==="constant"){const u=e.expression.evaluate(i,null,{},s,o),h=e.property.specification.type==="resolvedImage"&&typeof u!="string"?u.name:u,f=this._calculate(h,h,h,i);return new Qr(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 Qr(this,{kind:"constant",value:u},i)}return new Qr(this,e.expression,i)}evaluate(e,i,s,o,u,h){if(e.kind==="source"){const f=e.evaluate(i,s,o,u,h);return this._calculate(f,f,f,i)}return e.kind==="composite"?this._calculate(e.evaluate({zoom:Math.floor(i.zoom)-1},s,o),e.evaluate({zoom:Math.floor(i.zoom)},s,o),e.evaluate({zoom:Math.floor(i.zoom)+1},s,o),i):e.value}_calculate(e,i,s,o){return o.zoom>o.zoomHistory.lastIntegerZoom?{from:e,to:i}:{from:s,to:i}}interpolate(e){return e}}class bo{constructor(e){this.specification=e}possiblyEvaluate(e,i,s,o){if(e.value!==void 0){if(e.expression.kind==="constant"){const u=e.expression.evaluate(i,null,{},s,o);return this._calculate(u,u,u,i)}return this._calculate(e.expression.evaluate(new ii(Math.floor(i.zoom-1),i)),e.expression.evaluate(new ii(Math.floor(i.zoom),i)),e.expression.evaluate(new ii(Math.floor(i.zoom+1),i)),i)}}_calculate(e,i,s,o){return o.zoom>o.zoomHistory.lastIntegerZoom?{from:e,to:i}:{from:s,to:i}}interpolate(e){return e}}class wo{constructor(e){this.specification=e}possiblyEvaluate(e,i,s,o){return!!e.expression.evaluate(i,null,{},s,o)}interpolate(){return!1}}class Tr{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 o=this.defaultPropertyValues[i]=new xo(s,void 0,void 0),u=this.defaultTransitionablePropertyValues[i]=new vo(s,void 0);this.defaultTransitioningPropertyValues[i]=u.untransitioned(),this.defaultPossiblyEvaluatedValues[i]=o.possiblyEvaluate({})}}}Xe("DataDrivenProperty",nt),Xe("DataConstantProperty",et),Xe("CrossFadedDataDrivenProperty",ba),Xe("CrossFadedProperty",bo),Xe("ColorRampProperty",wo);class Gr extends Gt{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},e.type!=="custom"&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,this._visibilityExpression=(function(o,u){return new pa(o,u)})(this.visibility,s),e.type!=="background"&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter,this._featureFilter=oa(e.filter,s)),i.layout&&(this._unevaluatedLayout=new _u(i.layout,s)),i.paint)){this._transitionablePaint=new Ol(i.paint,s);for(const o in e.paint)this.setPaintProperty(o,e.paint[o],{validate:!1});for(const o in e.layout)this.setLayoutProperty(o,e.layout[o],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new va(i.paint)}}setFilter(e){this.filter=e,this._featureFilter=oa(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 o of s.getGlobalStateRefs())e.add(o)}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 o=this._transitionablePaint._values[s].value;for(const u of o.getGlobalStateRefs()){const h=(e=i.get(u))!==null&&e!==void 0?e:[];h.push({name:s,value:o.value}),i.set(u,h)}}return i}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(e,i,s={}){if(i==null||!this._validate(Mh,`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(xa)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,i,s={}){if(i!=null&&this._validate(Ph,`layers.${this.id}.paint.${e}`,e,i,s))return!1;if(e.endsWith(xa))return this._transitionablePaint.setTransition(e.slice(0,-11),i||void 0),!1;{const o=this._transitionablePaint._values[e],u=o.property.specification["property-type"]==="cross-faded-data-driven",h=o.value.isDataDriven(),f=o.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),ct(e,((i,s)=>!(i===void 0||s==="layout"&&!Object.keys(i).length||s==="paint"&&!Object.keys(i).length)))}_validate(e,i,s,o,u={}){return(!u||u.validate!==!1)&&As(this,e.call(Ji,{key:i,layerType:this.type,objectKey:s,value:o,styleSpec:ye,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 Qr&&Is(i.property.specification)&&(i.value.kind==="source"||i.value.kind==="composite")&&i.value.isStateDependent)return!0}return!1}}let Vl;var yu={get paint(){return Vl=Vl||new Tr({"raster-opacity":new et(ye.paint_raster["raster-opacity"]),"raster-hue-rotate":new et(ye.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new et(ye.paint_raster["raster-brightness-min"]),"raster-brightness-max":new et(ye.paint_raster["raster-brightness-max"]),"raster-saturation":new et(ye.paint_raster["raster-saturation"]),"raster-contrast":new et(ye.paint_raster["raster-contrast"]),"raster-resampling":new et(ye.paint_raster["raster-resampling"]),"raster-fade-duration":new et(ye.paint_raster["raster-fade-duration"])})}};class Ch extends Gr{constructor(e,i){super(e,yu,i)}}const Ah={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class wa{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 Ei{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 Ni(r,e=1){let i=0,s=0;return{members:r.map((o=>{const u=Ah[o.type].BYTES_PER_ELEMENT,h=i=Kn(i,Math.max(e,u)),f=o.components||1;return s=Math.max(s,u),i+=u*f,{name:o.name,type:o.type,components:f,offset:h}})),size:Kn(i,Math.max(s,e)),alignment:e}}function Kn(r,e){return Math.ceil(r/e)*e}class Ta extends Ei{_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 o=2*e;return this.int16[o+0]=i,this.int16[o+1]=s,e}}Ta.prototype.bytesPerElement=4,Xe("StructArrayLayout2i4",Ta);class To extends Ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,i,s)}emplace(e,i,s,o){const u=3*e;return this.int16[u+0]=i,this.int16[u+1]=s,this.int16[u+2]=o,e}}To.prototype.bytesPerElement=6,Xe("StructArrayLayout3i6",To);class jl extends Ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,s,o){const u=this.length;return this.resize(u+1),this.emplace(u,e,i,s,o)}emplace(e,i,s,o,u){const h=4*e;return this.int16[h+0]=i,this.int16[h+1]=s,this.int16[h+2]=o,this.int16[h+3]=u,e}}jl.prototype.bytesPerElement=8,Xe("StructArrayLayout4i8",jl);class So extends Ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,s,o,u,h){const f=this.length;return this.resize(f+1),this.emplace(f,e,i,s,o,u,h)}emplace(e,i,s,o,u,h,f){const g=6*e;return this.int16[g+0]=i,this.int16[g+1]=s,this.int16[g+2]=o,this.int16[g+3]=u,this.int16[g+4]=h,this.int16[g+5]=f,e}}So.prototype.bytesPerElement=12,Xe("StructArrayLayout2i4i12",So);class Nl extends Ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,s,o,u,h){const f=this.length;return this.resize(f+1),this.emplace(f,e,i,s,o,u,h)}emplace(e,i,s,o,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]=o,this.uint8[y+5]=u,this.uint8[y+6]=h,this.uint8[y+7]=f,e}}Nl.prototype.bytesPerElement=8,Xe("StructArrayLayout2i4ub8",Nl);class Sa extends Ei{_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 o=2*e;return this.float32[o+0]=i,this.float32[o+1]=s,e}}Sa.prototype.bytesPerElement=8,Xe("StructArrayLayout2f8",Sa);class mn extends Ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,s,o,u,h,f,g,y,v){const w=this.length;return this.resize(w+1),this.emplace(w,e,i,s,o,u,h,f,g,y,v)}emplace(e,i,s,o,u,h,f,g,y,v,w){const S=10*e;return this.uint16[S+0]=i,this.uint16[S+1]=s,this.uint16[S+2]=o,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]=v,this.uint16[S+9]=w,e}}mn.prototype.bytesPerElement=20,Xe("StructArrayLayout10ui20",mn);class Po extends Ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,s,o,u,h,f,g){const y=this.length;return this.resize(y+1),this.emplace(y,e,i,s,o,u,h,f,g)}emplace(e,i,s,o,u,h,f,g,y){const v=8*e;return this.uint16[v+0]=i,this.uint16[v+1]=s,this.uint16[v+2]=o,this.uint16[v+3]=u,this.uint16[v+4]=h,this.uint16[v+5]=f,this.uint16[v+6]=g,this.uint16[v+7]=y,e}}Po.prototype.bytesPerElement=16,Xe("StructArrayLayout8ui16",Po);class Pa extends Ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,s,o,u,h,f,g,y,v,w,S){const M=this.length;return this.resize(M+1),this.emplace(M,e,i,s,o,u,h,f,g,y,v,w,S)}emplace(e,i,s,o,u,h,f,g,y,v,w,S,M){const A=12*e;return this.int16[A+0]=i,this.int16[A+1]=s,this.int16[A+2]=o,this.int16[A+3]=u,this.uint16[A+4]=h,this.uint16[A+5]=f,this.uint16[A+6]=g,this.uint16[A+7]=y,this.int16[A+8]=v,this.int16[A+9]=w,this.int16[A+10]=S,this.int16[A+11]=M,e}}Pa.prototype.bytesPerElement=24,Xe("StructArrayLayout4i4ui4i24",Pa);class Mo extends Ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,i,s)}emplace(e,i,s,o){const u=3*e;return this.float32[u+0]=i,this.float32[u+1]=s,this.float32[u+2]=o,e}}Mo.prototype.bytesPerElement=12,Xe("StructArrayLayout3f12",Mo);class Ma extends Ei{_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}}Ma.prototype.bytesPerElement=4,Xe("StructArrayLayout1ul4",Ma);class Ul extends Ei{_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,o,u,h,f,g,y){const v=this.length;return this.resize(v+1),this.emplace(v,e,i,s,o,u,h,f,g,y)}emplace(e,i,s,o,u,h,f,g,y,v){const w=10*e,S=5*e;return this.int16[w+0]=i,this.int16[w+1]=s,this.int16[w+2]=o,this.int16[w+3]=u,this.int16[w+4]=h,this.int16[w+5]=f,this.uint32[S+3]=g,this.uint16[w+8]=y,this.uint16[w+9]=v,e}}Ul.prototype.bytesPerElement=20,Xe("StructArrayLayout6i1ul2ui20",Ul);class Rs extends Ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,s,o,u,h){const f=this.length;return this.resize(f+1),this.emplace(f,e,i,s,o,u,h)}emplace(e,i,s,o,u,h,f){const g=6*e;return this.int16[g+0]=i,this.int16[g+1]=s,this.int16[g+2]=o,this.int16[g+3]=u,this.int16[g+4]=h,this.int16[g+5]=f,e}}Rs.prototype.bytesPerElement=12,Xe("StructArrayLayout2i2i2i12",Rs);class Jn extends Ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,s,o,u){const h=this.length;return this.resize(h+1),this.emplace(h,e,i,s,o,u)}emplace(e,i,s,o,u,h){const f=4*e,g=8*e;return this.float32[f+0]=i,this.float32[f+1]=s,this.float32[f+2]=o,this.int16[g+6]=u,this.int16[g+7]=h,e}}Jn.prototype.bytesPerElement=16,Xe("StructArrayLayout2f1f2i16",Jn);class Gl extends Ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,s,o,u,h){const f=this.length;return this.resize(f+1),this.emplace(f,e,i,s,o,u,h)}emplace(e,i,s,o,u,h,f){const g=16*e,y=4*e,v=8*e;return this.uint8[g+0]=i,this.uint8[g+1]=s,this.float32[y+1]=o,this.float32[y+2]=u,this.int16[v+6]=h,this.int16[v+7]=f,e}}Gl.prototype.bytesPerElement=16,Xe("StructArrayLayout2ub2f2i16",Gl);class Ia extends Ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,i,s)}emplace(e,i,s,o){const u=3*e;return this.uint16[u+0]=i,this.uint16[u+1]=s,this.uint16[u+2]=o,e}}Ia.prototype.bytesPerElement=6,Xe("StructArrayLayout3ui6",Ia);class Qn extends Ei{_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,o,u,h,f,g,y,v,w,S,M,A,z,R,j){const X=this.length;return this.resize(X+1),this.emplace(X,e,i,s,o,u,h,f,g,y,v,w,S,M,A,z,R,j)}emplace(e,i,s,o,u,h,f,g,y,v,w,S,M,A,z,R,j,X){const N=24*e,G=12*e,K=48*e;return this.int16[N+0]=i,this.int16[N+1]=s,this.uint16[N+2]=o,this.uint16[N+3]=u,this.uint32[G+2]=h,this.uint32[G+3]=f,this.uint32[G+4]=g,this.uint16[N+10]=y,this.uint16[N+11]=v,this.uint16[N+12]=w,this.float32[G+7]=S,this.float32[G+8]=M,this.uint8[K+36]=A,this.uint8[K+37]=z,this.uint8[K+38]=R,this.uint32[G+10]=j,this.int16[N+22]=X,e}}Qn.prototype.bytesPerElement=48,Xe("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",Qn);class ql extends Ei{_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,o,u,h,f,g,y,v,w,S,M,A,z,R,j,X,N,G,K,te,me,Ie,Se,Ce,Ve,ze){const Me=this.length;return this.resize(Me+1),this.emplace(Me,e,i,s,o,u,h,f,g,y,v,w,S,M,A,z,R,j,X,N,G,K,te,me,Ie,Se,Ce,Ve,ze)}emplace(e,i,s,o,u,h,f,g,y,v,w,S,M,A,z,R,j,X,N,G,K,te,me,Ie,Se,Ce,Ve,ze,Me){const be=32*e,He=16*e;return this.int16[be+0]=i,this.int16[be+1]=s,this.int16[be+2]=o,this.int16[be+3]=u,this.int16[be+4]=h,this.int16[be+5]=f,this.int16[be+6]=g,this.int16[be+7]=y,this.uint16[be+8]=v,this.uint16[be+9]=w,this.uint16[be+10]=S,this.uint16[be+11]=M,this.uint16[be+12]=A,this.uint16[be+13]=z,this.uint16[be+14]=R,this.uint16[be+15]=j,this.uint16[be+16]=X,this.uint16[be+17]=N,this.uint16[be+18]=G,this.uint16[be+19]=K,this.uint16[be+20]=te,this.uint16[be+21]=me,this.uint16[be+22]=Ie,this.uint32[He+12]=Se,this.float32[He+13]=Ce,this.float32[He+14]=Ve,this.uint16[be+30]=ze,this.uint16[be+31]=Me,e}}ql.prototype.bytesPerElement=64,Xe("StructArrayLayout8i15ui1ul2f2ui64",ql);class Io extends Ei{_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}}Io.prototype.bytesPerElement=4,Xe("StructArrayLayout1f4",Io);class Eo extends Ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,i,s)}emplace(e,i,s,o){const u=3*e;return this.uint16[6*e+0]=i,this.float32[u+1]=s,this.float32[u+2]=o,e}}Eo.prototype.bytesPerElement=12,Xe("StructArrayLayout1ui2f12",Eo);class Zl extends Ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,i,s)}emplace(e,i,s,o){const u=4*e;return this.uint32[2*e+0]=i,this.uint16[u+2]=s,this.uint16[u+3]=o,e}}Zl.prototype.bytesPerElement=8,Xe("StructArrayLayout1ul2ui8",Zl);class d extends Ei{_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 o=2*e;return this.uint16[o+0]=i,this.uint16[o+1]=s,e}}d.prototype.bytesPerElement=4,Xe("StructArrayLayout2ui4",d);class t extends Ei{_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}}t.prototype.bytesPerElement=2,Xe("StructArrayLayout1ui2",t);class n extends Ei{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,s,o){const u=this.length;return this.resize(u+1),this.emplace(u,e,i,s,o)}emplace(e,i,s,o,u){const h=4*e;return this.float32[h+0]=i,this.float32[h+1]=s,this.float32[h+2]=o,this.float32[h+3]=u,e}}n.prototype.bytesPerElement=16,Xe("StructArrayLayout4f16",n);class a extends wa{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 le(this.anchorPointX,this.anchorPointY)}}a.prototype.size=20;class l extends Ul{get(e){return new a(this,e)}}Xe("CollisionBoxArray",l);class p extends wa{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]}}p.prototype.size=48;class m extends Qn{get(e){return new p(this,e)}}Xe("PlacedSymbolArray",m);class _ extends wa{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]}}_.prototype.size=64;class x extends ql{get(e){return new _(this,e)}}Xe("SymbolInstanceArray",x);class b extends Io{getoffsetX(e){return this.float32[1*e+0]}}Xe("GlyphOffsetArray",b);class T extends To{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}Xe("SymbolLineVertexArray",T);class E extends wa{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]}}E.prototype.size=12;class I extends Eo{get(e){return new E(this,e)}}Xe("TextAnchorOffsetArray",I);class k extends wa{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]}}k.prototype.size=8;class V extends Zl{get(e){return new k(this,e)}}Xe("FeatureIndexArray",V);class q extends Ta{}class W extends Ta{}class Z extends Ta{}class Y extends So{}class ie extends Nl{}class H extends Sa{}class ee extends mn{}class se extends Po{}class J extends Pa{}class oe extends Mo{}class Te extends Ma{}class _e extends Rs{}class xe extends Gl{}class ve extends Ia{}class Fe extends d{}const Le=Ni([{name:"a_pos",components:2,type:"Int16"}],4),{members:Ae}=Le;class Ue{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,i,s,o){const u=this.segments[this.segments.length-1];return e>Ue.MAX_VERTEX_ARRAY_LENGTH&&yt(`Max vertices per segment is ${Ue.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${Ue.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!u||u.vertexLength+e>Ue.MAX_VERTEX_ARRAY_LENGTH||u.sortKey!==o?this.createNewSegment(i,s,o):u}createNewSegment(e,i,s){const o={vertexOffset:e.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0,vaos:{}};return s!==void 0&&(o.sortKey=s),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(o),o}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,o){return new Ue([{vertexOffset:e,primitiveOffset:i,vertexLength:s,primitiveLength:o,vaos:{},sortKey:0}])}}function gt(r,e){return 256*(r=Ut(Math.floor(r),0,255))+Ut(Math.floor(e),0,255)}Ue.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Xe("SegmentVector",Ue);const Ht=Ni([{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"}]),_i=Ni([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var li,wi,ci,Fi={exports:{}},Ti={exports:{}},Qi={exports:{}},qi=(function(){if(ci)return Fi.exports;ci=1;var r=(li||(li=1,Ti.exports=function(i,s){var o,u,h,f,g,y,v,w;for(u=i.length-(o=3&i.length),h=s,g=3432918353,y=461845907,w=0;w<u;)v=255&i.charCodeAt(w)|(255&i.charCodeAt(++w))<<8|(255&i.charCodeAt(++w))<<16|(255&i.charCodeAt(++w))<<24,++w,h=27492+(65535&(f=5*(65535&(h=(h^=v=(65535&(v=(v=(65535&v)*g+(((v>>>16)*g&65535)<<16)&4294967295)<<15|v>>>17))*y+(((v>>>16)*y&65535)<<16)&4294967295)<<13|h>>>19))+((5*(h>>>16)&65535)<<16)&4294967295))+((58964+(f>>>16)&65535)<<16);switch(v=0,o){case 3:v^=(255&i.charCodeAt(w+2))<<16;case 2:v^=(255&i.charCodeAt(w+1))<<8;case 1:h^=v=(65535&(v=(v=(65535&(v^=255&i.charCodeAt(w)))*g+(((v>>>16)*g&65535)<<16)&4294967295)<<15|v>>>17))*y+(((v>>>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}),Ti.exports),e=(wi||(wi=1,Qi.exports=function(i,s){for(var o,u=i.length,h=s^u,f=0;u>=4;)o=1540483477*(65535&(o=255&i.charCodeAt(f)|(255&i.charCodeAt(++f))<<8|(255&i.charCodeAt(++f))<<16|(255&i.charCodeAt(++f))<<24))+((1540483477*(o>>>16)&65535)<<16),h=1540483477*(65535&h)+((1540483477*(h>>>16)&65535)<<16)^(o=1540483477*(65535&(o^=o>>>24))+((1540483477*(o>>>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}),Qi.exports);return Fi.exports=r,Fi.exports.murmur3=r,Fi.exports.murmur2=e,Fi.exports})(),Ui=Pe(qi);class or{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,i,s,o){this.ids.push(Dn(e)),this.positions.push(i,s,o)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const i=Dn(e);let s=0,o=this.ids.length-1;for(;s<o;){const h=s+o>>1;this.ids[h]>=i?o=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),o=new Uint32Array(e.positions);return gn(s,o,0,s.length-1),i&&i.push(s.buffer,o.buffer),{ids:s,positions:o}}static deserialize(e){const i=new or;return i.ids=e.ids,i.positions=e.positions,i.indexed=!0,i}}function Dn(r){const e=+r;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:Ui(String(r))}function gn(r,e,i,s){for(;i<s;){const o=r[i+s>>1];let u=i-1,h=s+1;for(;;){do u++;while(r[u]<o);do h--;while(r[h]>o);if(u>=h)break;cn(r,u,h),cn(e,3*u,3*h),cn(e,3*u+1,3*h+1),cn(e,3*u+2,3*h+2)}h-i<s-h?(gn(r,e,i,h),i=h+1):(gn(r,e,h+1,s),s=h)}}function cn(r,e,i){const s=r[e];r[e]=r[i],r[i]=s}Xe("FeaturePositionMap",or);class Ir{constructor(e,i){this.gl=e.gl,this.location=i}}class es extends Ir{constructor(e,i){super(e,i),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}}class Ea extends Ir{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 ts extends Ir{constructor(e,i){super(e,i),this.current=Mt.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 qr=new Float32Array(16);function un(r){return[gt(255*r.r,255*r.g),gt(255*r.b,255*r.a)]}class en{constructor(e,i,s){this.value=e,this.uniformNames=i.map((o=>`u_${o}`)),this.type=s}setUniform(e,i,s){e.set(s.constantOr(this.value))}getBinding(e,i,s){return this.type==="color"?new ts(e,i):new es(e,i)}}class tn{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,o){let u=null;o==="u_pattern_to"?u=this.patternTo:o==="u_pattern_from"?u=this.patternFrom:o==="u_dasharray_to"?u=this.dashTo:o==="u_dasharray_from"?u=this.dashFrom:o==="u_pixel_ratio_to"?u=this.pixelRatioTo:o==="u_pixel_ratio_from"&&(u=this.pixelRatioFrom),u!==null&&e.set(u)}getBinding(e,i,s){return s.substr(0,9)==="u_pattern"||s.substr(0,12)==="u_dasharray_"?new Ea(e,i):new es(e,i)}}class hi{constructor(e,i,s,o){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 o}populatePaintArray(e,i,s){const o=this.paintVertexArray.length,u=this.expression.evaluate(new ii(0,s),i,{},s.canonical,[],s.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(o,e,u)}updatePaintArray(e,i,s,o,u){const h=this.expression.evaluate(new ii(0,u),s,o);this._setPaintValue(e,i,h)}_setPaintValue(e,i,s){if(this.type==="color"){const o=un(s);for(let u=e;u<i;u++)this.paintVertexArray.emplace(u,o[0],o[1])}else{for(let o=e;o<i;o++)this.paintVertexArray.emplace(o,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 ui{constructor(e,i,s,o,u,h){this.expression=e,this.uniformNames=i.map((f=>`u_${f}_t`)),this.type=s,this.useIntegerZoom=o,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 o=this.expression.evaluate(new ii(this.zoom,s),i,{},s.canonical,[],s.formattedSection),u=this.expression.evaluate(new ii(this.zoom+1,s),i,{},s.canonical,[],s.formattedSection),h=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(h,e,o,u)}updatePaintArray(e,i,s,o,u){const h=this.expression.evaluate(new ii(this.zoom,u),s,o),f=this.expression.evaluate(new ii(this.zoom+1,u),s,o);this._setPaintValue(e,i,h,f)}_setPaintValue(e,i,s,o){if(this.type==="color"){const u=un(s),h=un(o);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,o);this.maxValue=Math.max(this.maxValue,Math.abs(s),Math.abs(o))}}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,o=Ut(this.expression.interpolationFactor(s,this.zoom,this.zoom+1),0,1);e.set(o)}getBinding(e,i,s){return new es(e,i)}}class Yi{constructor(e,i,s,o,u,h){this.expression=e,this.type=i,this.useIntegerZoom=s,this.zoom=o,this.layerId=h,this.zoomInPaintVertexArray=new u,this.zoomOutPaintVertexArray=new u}populatePaintArray(e,i,s){const o=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(o,e,this.getPositionIds(i),s)}updatePaintArray(e,i,s,o,u){this._setPaintValues(e,i,this.getPositionIds(s),u)}_setPaintValues(e,i,s,o){const u=this.getPositions(o);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 Ki extends Yi{getPositions(e){return e.imagePositions}getPositionIds(e){return e.patterns&&e.patterns[this.layerId]}getVertexAttributes(){return Ht.members}emplace(e,i,s,o){e.emplace(i,s.tlbr[0],s.tlbr[1],s.tlbr[2],s.tlbr[3],o.tlbr[0],o.tlbr[1],o.tlbr[2],o.tlbr[3],s.pixelRatio,o.pixelRatio)}}class xu extends Yi{getPositions(e){return e.dashPositions}getPositionIds(e){return e.dashes&&e.dashes[this.layerId]}getVertexAttributes(){return _i.members}emplace(e,i,s,o){e.emplace(i,0,s.y,s.height,s.width,0,o.y,o.height,o.width)}}class vu{constructor(e,i,s){this.binders={},this._buffers=[];const o=[];for(const u in e.paint._values){if(!s(u))continue;const h=e.paint.get(u);if(!(h instanceof Qr&&Is(h.property.specification)))continue;const f=Dh(u,e.type),g=h.value,y=h.property.specification.type,v=h.property.useIntegerZoom,w=h.property.specification["property-type"],S=w==="cross-faded"||w==="cross-faded-data-driven";if(g.kind==="constant")this.binders[u]=S?new tn(g.value,f):new en(g.value,f,y),o.push(`/u_${u}`);else if(g.kind==="source"||S){const M=bu(u,y,"source");this.binders[u]=S?u==="line-dasharray"?new xu(g,y,v,i,M,e.id):new Ki(g,y,v,i,M,e.id):new hi(g,f,y,M),o.push(`/a_${u}`)}else{const M=bu(u,y,"composite");this.binders[u]=new ui(g,f,y,v,i,M),o.push(`/z_${u}`)}}this.cacheKey=o.sort().join("")}getMaxValue(e){const i=this.binders[e];return i instanceof hi||i instanceof ui?i.maxValue:0}populatePaintArrays(e,i,s){for(const o in this.binders){const u=this.binders[o];(u instanceof hi||u instanceof ui||u instanceof Yi)&&u.populatePaintArray(e,i,s)}}setConstantPatternPositions(e,i){for(const s in this.binders){const o=this.binders[s];o instanceof tn&&o.setConstantPatternPositions(e,i)}}setConstantDashPositions(e,i){for(const s in this.binders){const o=this.binders[s];o instanceof tn&&o.setConstantDashPositions(e,i)}}updatePaintArrays(e,i,s,o,u){let h=!1;for(const f in e){const g=i.getPositions(f);for(const y of g){const v=s.feature(y.index);for(const w in this.binders){const S=this.binders[w];if((S instanceof hi||S instanceof ui||S instanceof Yi)&&S.expression.isStateDependent===!0){const M=o.paint.get(w);S.expression=M.value,S.updatePaintArray(y.start,y.end,v,e[f],u),h=!0}}}}return h}defines(){const e=[];for(const i in this.binders){const s=this.binders[i];(s instanceof en||s instanceof tn)&&e.push(...s.uniformNames.map((o=>`#define HAS_UNIFORM_${o}`)))}return e}getBinderAttributes(){const e=[];for(const i in this.binders){const s=this.binders[i];if(s instanceof hi||s instanceof ui)for(let o=0;o<s.paintVertexAttributes.length;o++)e.push(s.paintVertexAttributes[o].name);else if(s instanceof Yi){const o=s.getVertexAttributes();for(const u of o)e.push(u.name)}}return e}getBinderUniforms(){const e=[];for(const i in this.binders){const s=this.binders[i];if(s instanceof en||s instanceof tn||s instanceof ui)for(const o of s.uniformNames)e.push(o)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,i){const s=[];for(const o in this.binders){const u=this.binders[o];if(u instanceof en||u instanceof tn||u instanceof ui){for(const h of u.uniformNames)if(i[h]){const f=u.getBinding(e,i[h],h);s.push({name:h,property:o,binding:f})}}}return s}setUniforms(e,i,s,o){for(const{name:u,property:h,binding:f}of i)this.binders[h].setUniform(f,o,s.get(h),u)}updatePaintBuffers(e){this._buffers=[];for(const i in this.binders){const s=this.binders[i];if(e&&s instanceof Yi){const o=e.fromScale===2?s.zoomInPaintVertexBuffer:s.zoomOutPaintVertexBuffer;o&&this._buffers.push(o)}else(s instanceof hi||s instanceof ui)&&s.paintVertexBuffer&&this._buffers.push(s.paintVertexBuffer)}}upload(e){for(const i in this.binders){const s=this.binders[i];(s instanceof hi||s instanceof ui||s instanceof Yi)&&s.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const i=this.binders[e];(i instanceof hi||i instanceof ui||i instanceof Yi)&&i.destroy()}}}class is{constructor(e,i,s=()=>!0){this.programConfigurations={};for(const o of e)this.programConfigurations[o.id]=new vu(o,i,s);this.needsUpload=!1,this._featureMap=new or,this._bufferOffset=0}populatePaintArrays(e,i,s,o){for(const u in this.programConfigurations)this.programConfigurations[u].populatePaintArrays(e,i,o);i.id!==void 0&&this._featureMap.add(i.id,s,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,i,s,o){for(const u of s)this.needsUpload=this.programConfigurations[u.id].updatePaintArrays(e,this._featureMap,i,u,o)||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 Dh(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 bu(r,e,i){const s={color:{source:Sa,composite:n},number:{source:Io,composite:Sa}},o=(function(u){return{"line-pattern":{source:ee,composite:ee},"fill-pattern":{source:ee,composite:ee},"fill-extrusion-pattern":{source:ee,composite:ee},"line-dasharray":{source:se,composite:se}}[u]})(r);return o&&o[i]||s[e][i]}Xe("ConstantBinder",en),Xe("CrossFadedConstantBinder",tn),Xe("SourceExpressionBinder",hi),Xe("CrossFadedPatternBinder",Ki),Xe("CrossFadedDasharrayBinder",xu),Xe("CompositeExpressionBinder",ui),Xe("ProgramConfiguration",vu,{omit:["_buffers"]}),Xe("ProgramConfigurationSet",is);const $l=Math.pow(2,14)-1,zn=-$l-1;function kn(r){const e=Ze/r.extent,i=r.loadGeometry();for(let s=0;s<i.length;s++){const o=i[s];for(let u=0;u<o.length;u++){const h=o[u],f=Math.round(h.x*e),g=Math.round(h.y*e);h.x=Ut(f,zn,$l),h.y=Ut(g,zn,$l),(f<h.x||f>h.x+1||g<h.y||g>h.y+1)&&yt("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return i}function Rn(r,e){return{type:r.type,id:r.id,properties:r.properties,geometry:e?kn(r):[]}}const Wl=-32768;function Hl(r,e,i,s,o){r.emplaceBack(Wl+8*e+s,Wl+8*i+o)}class Co{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 W,this.indexArray=new ve,this.segments=new Ue,this.programConfigurations=new is(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((i=>i.isStateDependent())).map((i=>i.id))}populate(e,i,s){const o=this.layers[0],u=[];let h=null,f=!1,g=o.type==="heatmap";if(o.type==="circle"){const v=o;h=v.layout.get("circle-sort-key"),f=!h.isConstant(),g=g||v.paint.get("circle-pitch-alignment")==="map"}const y=g?i.subdivisionGranularity.circle:1;for(const{feature:v,id:w,index:S,sourceLayerIndex:M}of e){const A=this.layers[0]._featureFilter.needGeometry,z=Rn(v,A);if(!this.layers[0]._featureFilter.filter(new ii(this.zoom),z,s))continue;const R=f?h.evaluate(z,{},s):void 0,j={id:w,properties:v.properties,type:v.type,sourceLayerIndex:M,index:S,geometry:A?z.geometry:kn(v),patterns:{},sortKey:R};u.push(j)}f&&u.sort(((v,w)=>v.sortKey-w.sortKey));for(const v of u){const{geometry:w,index:S,sourceLayerIndex:M}=v,A=e[S].feature;this.addFeature(v,w,S,s,y),i.featureIndex.insert(A,w,S,M,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,Ae),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,o,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 v=y.x,w=y.y;if(v<0||v>=Ze||w<0||w>=Ze)continue;const S=this.segments.prepareSegment(f*f,this.layoutVertexArray,this.indexArray,e.sortKey),M=S.vertexLength;for(let A=0;A<f;A++)for(let z=0;z<f;z++)Hl(this.layoutVertexArray,v,w,h[z],h[A]);for(let A=0;A<f-1;A++)for(let z=0;z<f-1;z++){const R=M+A*f+z,j=M+(A+1)*f+z;this.indexArray.emplaceBack(R,j+1,R+1),this.indexArray.emplaceBack(R,j,j+1)}S.vertexLength+=f*f,S.primitiveLength+=(f-1)*(f-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,s,{imagePositions:{},canonical:o})}}function Ao(r,e){for(let i=0;i<r.length;i++)if(Do(e,r[i]))return!0;for(let i=0;i<e.length;i++)if(Do(r,e[i]))return!0;return!!zh(r,e)}function wu(r,e,i){return!!Do(r,e)||!!kh(e,r,i)}function sp(r,e){if(r.length===1)return op(e,r[0]);for(let i=0;i<e.length;i++){const s=e[i];for(let o=0;o<s.length;o++)if(Do(r,s[o]))return!0}for(let i=0;i<r.length;i++)if(op(e,r[i]))return!0;for(let i=0;i<e.length;i++)if(zh(r,e[i]))return!0;return!1}function kg(r,e,i){if(r.length>1){if(zh(r,e))return!0;for(let s=0;s<e.length;s++)if(kh(e[s],r,i))return!0}for(let s=0;s<r.length;s++)if(kh(r[s],e,i))return!0;return!1}function zh(r,e){if(r.length===0||e.length===0)return!1;for(let i=0;i<r.length-1;i++){const s=r[i],o=r[i+1];for(let u=0;u<e.length-1;u++)if(Rg(s,o,e[u],e[u+1]))return!0}return!1}function Rg(r,e,i,s){return kt(r,i,s)!==kt(e,i,s)&&kt(r,e,i)!==kt(r,e,s)}function kh(r,e,i){const s=i*i;if(e.length===1)return r.distSqr(e[0])<s;for(let o=1;o<e.length;o++)if(ap(r,e[o-1],e[o])<s)return!0;return!1}function ap(r,e,i){const s=e.distSqr(i);if(s===0)return r.distSqr(e);const o=((r.x-e.x)*(i.x-e.x)+(r.y-e.y)*(i.y-e.y))/s;return r.distSqr(o<0?e:o>1?i:i.sub(e)._mult(o)._add(e))}function op(r,e){let i,s,o,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],o=i[g],s.y>e.y!=o.y>e.y&&e.x<(o.x-s.x)*(e.y-s.y)/(o.y-s.y)+s.x&&(u=!u)}return u}function Do(r,e){let i=!1;for(let s=0,o=r.length-1;s<r.length;o=s++){const u=r[s],h=r[o];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 Fg(r,e,i){const s=i[0],o=i[2];if(r.x<s.x&&e.x<s.x||r.x>o.x&&e.x>o.x||r.y<s.y&&e.y<s.y||r.y>o.y&&e.y>o.y)return!1;const u=kt(r,e,i[0]);return u!==kt(r,e,i[1])||u!==kt(r,e,i[2])||u!==kt(r,e,i[3])}function zo(r,e,i){const s=e.paint.get(r).value;return s.kind==="constant"?s.value:i.programConfigurations.get(e.id).getMaxValue(r)}function Tu(r){return Math.sqrt(r[0]*r[0]+r[1]*r[1])}function Su(r,e,i,s,o){if(!e[0]&&!e[1])return r;const u=le.convert(e)._mult(o);i==="viewport"&&u._rotate(-s);const h=[];for(let f=0;f<r.length;f++)h.push(r[f].sub(u));return h}function Lg(r){const e=[];for(let i=0;i<r.length;i++){const s=r[i],o=e.at(-1);(i===0||o&&!s.equals(o))&&e.push(s)}return e}function Bg({queryGeometry:r,size:e},i){return wu(r,i,e)}function Og({queryGeometry:r,size:e,transform:i,unwrappedTileID:s,getElevation:o},u){return wu(r,u,e*(i.projectTileCoordinates(u.x,u.y,s,o).signedDistanceFromCamera/i.cameraToCenterDistance))}function Vg({queryGeometry:r,size:e,transform:i,unwrappedTileID:s,getElevation:o},u){const h=i.projectTileCoordinates(u.x,u.y,s,o).signedDistanceFromCamera,f=e*(i.cameraToCenterDistance/h);return wu(r,Rh(u,i,s,o),f)}function jg({queryGeometry:r,size:e,transform:i,unwrappedTileID:s,getElevation:o},u){return wu(r,Rh(u,i,s,o),e)}function lp({queryGeometry:r,size:e,transform:i,unwrappedTileID:s,getElevation:o,pitchAlignment:u="map",pitchScale:h="map"},f){const g=u==="map"?h==="map"?Bg:Og:h==="map"?Vg:jg,y={queryGeometry:r,size:e,transform:i,unwrappedTileID:s,getElevation:o};for(const v of f)for(const w of v)if(g(y,w))return!0;return!1}function Rh(r,e,i,s){const o=e.projectTileCoordinates(r.x,r.y,i,s).point;return new le((.5*o.x+.5)*e.width,(.5*-o.y+.5)*e.height)}let cp,up;Xe("CircleBucket",Co,{omit:["layers"]});var Ng={get paint(){return up=up||new Tr({"circle-radius":new nt(ye.paint_circle["circle-radius"]),"circle-color":new nt(ye.paint_circle["circle-color"]),"circle-blur":new nt(ye.paint_circle["circle-blur"]),"circle-opacity":new nt(ye.paint_circle["circle-opacity"]),"circle-translate":new et(ye.paint_circle["circle-translate"]),"circle-translate-anchor":new et(ye.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new et(ye.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new et(ye.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new nt(ye.paint_circle["circle-stroke-width"]),"circle-stroke-color":new nt(ye.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new nt(ye.paint_circle["circle-stroke-opacity"])})},get layout(){return cp=cp||new Tr({"circle-sort-key":new nt(ye.layout_circle["circle-sort-key"])})}};class Ug extends Gr{constructor(e,i){super(e,Ng,i)}createBucket(e){return new Co(e)}queryRadius(e){const i=e;return zo("circle-radius",this,i)+zo("circle-stroke-width",this,i)+Tu(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:e,feature:i,featureState:s,geometry:o,transform:u,pixelsToTileUnits:h,unwrappedTileID:f,getElevation:g}){const y=Su(e,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-u.bearingInRadians,h),v=this.paint.get("circle-radius").evaluate(i,s)+this.paint.get("circle-stroke-width").evaluate(i,s),w=this.paint.get("circle-pitch-scale"),S=this.paint.get("circle-pitch-alignment");let M,A;return S==="map"?(M=y,A=v*h):(M=(function(z,R,j,X){return z.map((N=>Rh(N,R,j,X)))})(y,u,f,g),A=v),lp({queryGeometry:M,size:A,transform:u,unwrappedTileID:f,getElevation:g,pitchAlignment:S,pitchScale:w},o)}}class hp extends Co{}let dp;Xe("HeatmapBucket",hp,{omit:["layers"]});var Gg={get paint(){return dp=dp||new Tr({"heatmap-radius":new nt(ye.paint_heatmap["heatmap-radius"]),"heatmap-weight":new nt(ye.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new et(ye.paint_heatmap["heatmap-intensity"]),"heatmap-color":new wo(ye.paint_heatmap["heatmap-color"]),"heatmap-opacity":new et(ye.paint_heatmap["heatmap-opacity"])})}};function Fh(r,{width:e,height:i},s,o){if(o){if(o instanceof Uint8ClampedArray)o=new Uint8Array(o.buffer);else if(o.length!==e*i*s)throw new RangeError(`mismatched image size. expected: ${o.length} but got: ${e*i*s}`)}else o=new Uint8Array(e*i*s);return r.width=e,r.height=i,r.data=o,r}function pp(r,{width:e,height:i},s){if(e===r.width&&i===r.height)return;const o=Fh({},{width:e,height:i},s);Lh(r,o,{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=o.data}function Lh(r,e,i,s,o,u){if(o.width===0||o.height===0)return e;if(o.width>r.width||o.height>r.height||i.x>r.width-o.width||i.y>r.height-o.height)throw new RangeError("out of range source coordinates for image copy");if(o.width>e.width||o.height>e.height||s.x>e.width-o.width||s.y>e.height-o.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<o.height;g++){const y=((i.y+g)*r.width+i.x)*u,v=((s.y+g)*e.width+s.x)*u;for(let w=0;w<o.width*u;w++)f[v+w]=h[y+w]}return e}class Xl{constructor(e,i){Fh(this,e,1,i)}resize(e){pp(this,e,1)}clone(){return new Xl({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,i,s,o,u){Lh(e,i,s,o,u,1)}}class Rr{constructor(e,i){Fh(this,e,4,i)}resize(e){pp(this,e,4)}replace(e,i){i?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new Rr({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,i,s,o,u){Lh(e,i,s,o,u,4)}setPixel(e,i,s){const o=4*(e*this.width+i);this.data[o+0]=Math.round(255*s.r/s.a),this.data[o+1]=Math.round(255*s.g/s.a),this.data[o+2]=Math.round(255*s.b/s.a),this.data[o+3]=Math.round(255*s.a)}}function fp(r){const e={},i=r.resolution||256,s=r.clips?r.clips.length:1,o=r.image||new Rr({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);o.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 v=g/(i-1),{start:w,end:S}=r.clips[h];u(f,y,w*(1-v)+S*v)}else for(let h=0,f=0;h<i;h++,f+=4)u(0,f,h/(i-1));return o}Xe("AlphaImage",Xl),Xe("RGBAImage",Rr);const Bh="big-fb";class qg extends Gr{createBucket(e){return new hp(e)}constructor(e,i){super(e,Gg,i),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){e==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=fp({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(Bh)&&this.heatmapFbos.delete(Bh)}queryRadius(e){return zo("heatmap-radius",this,e)}queryIntersectsFeature({queryGeometry:e,feature:i,featureState:s,geometry:o,transform:u,pixelsToTileUnits:h,unwrappedTileID:f,getElevation:g}){return lp({queryGeometry:e,size:this.paint.get("heatmap-radius").evaluate(i,s)*h,transform:u,unwrappedTileID:f,getElevation:g},o)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&!this.isHidden()}}let mp;var Zg={get paint(){return mp=mp||new Tr({"hillshade-illumination-direction":new et(ye.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-altitude":new et(ye.paint_hillshade["hillshade-illumination-altitude"]),"hillshade-illumination-anchor":new et(ye.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new et(ye.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new et(ye.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new et(ye.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new et(ye.paint_hillshade["hillshade-accent-color"]),"hillshade-method":new et(ye.paint_hillshade["hillshade-method"])})}};class $g extends Gr{constructor(e,i){super(e,Zg,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,o=this.paint.get("hillshade-shadow-color").values;const u=Math.max(e.length,i.length,s.length,o.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))),o=o.concat(Array(u-o.length).fill(o.at(-1)));const h=i.map(Di);return{directionRadians:e.map(Di),altitudeRadians:h,shadowColor:o,highlightColor:s}}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&!this.isHidden()}}let gp;var Wg={get paint(){return gp=gp||new Tr({"color-relief-opacity":new et(ye["paint_color-relief"]["color-relief-opacity"]),"color-relief-color":new wo(ye["paint_color-relief"]["color-relief-color"])})}};class Oh{constructor(e,i,s,o){this.context=e,this.format=s,this.texture=e.gl.createTexture(),this.update(i,o)}update(e,i,s){const{width:o,height:u}=e,h=!(this.size&&this.size[0]===o&&this.size[1]===u||s),{context:f}=this,{gl:g}=f;if(this.useMipmap=!!(i&&i.useMipmap),g.bindTexture(g.TEXTURE_2D,this.texture),f.pixelStoreUnpackFlipY.set(!1),f.pixelStoreUnpack.set(1),f.pixelStoreUnpackPremultiplyAlpha.set(this.format===g.RGBA&&(!i||i.premultiply!==!1)),h)this.size=[o,u],e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||pt(e)?g.texImage2D(g.TEXTURE_2D,0,this.format,this.format,g.UNSIGNED_BYTE,e):g.texImage2D(g.TEXTURE_2D,0,this.format,o,u,0,this.format,g.UNSIGNED_BYTE,e.data);else{const{x:y,y:v}=s||{x:0,y:0};e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||pt(e)?g.texSubImage2D(g.TEXTURE_2D,0,y,v,g.RGBA,g.UNSIGNED_BYTE,e):g.texSubImage2D(g.TEXTURE_2D,0,y,v,o,u,g.RGBA,g.UNSIGNED_BYTE,e.data)}this.useMipmap&&this.isSizePowerOfTwo()&&g.generateMipmap(g.TEXTURE_2D),f.pixelStoreUnpackFlipY.setDefault(),f.pixelStoreUnpack.setDefault(),f.pixelStoreUnpackPremultiplyAlpha.setDefault()}bind(e,i,s){const{context:o}=this,{gl:u}=o;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}}class _p{constructor(e,i,s,o=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 yt(`"${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=o,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 v=0;v<g;v++){const w=this.get(y,v);w>this.max&&(this.max=w),w<this.min&&(this.min=w)}}get(e,i){const s=new Uint8Array(this.data.buffer),o=4*this._idx(e,i);return this.unpack(s[o],s[o+1],s[o+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 yp(e,this.getUnpackVector())}getPixels(){return new Rr({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 o=i*this.dim,u=i*this.dim+this.dim,h=s*this.dim,f=s*this.dim+this.dim;switch(i){case-1:o=u-1;break;case 1:u=o+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 v=h;v<f;v++)for(let w=o;w<u;w++)this.data[this._idx(w,v)]=e.data[this._idx(w+g,v+y)]}}function yp(r,e){const i=e[0],s=e[1],o=e[2],u=e[3],h=Math.min(i,s,o),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/o)%256}}Xe("DEMData",_p);class Hg extends Gr{constructor(e,i){super(e,Wg,i)}_createColorRamp(e){const i={elevationStops:[],colorStops:[]},s=this._transitionablePaint._values["color-relief-color"].value.expression;if(s instanceof lo&&s._styleExpression.expression instanceof wr){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=[Mt.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 o={elevationStops:[],colorStops:[]},u=(i.elevationStops.length-1)/(e-1);for(let h=0;h<i.elevationStops.length-.5;h+=u)o.elevationStops.push(i.elevationStops[Math.round(h)]),o.colorStops.push(i.colorStops[Math.round(h)]);return yt(`Too many colors in specification of ${this.id} color-relief layer, may not render properly. Max possible colors: ${e}, provided: ${i.elevationStops.length}`),o}_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 o=this._createColorRamp(i),u=new Rr({width:o.colorStops.length,height:1}),h=new Rr({width:o.colorStops.length,height:1});for(let f=0;f<o.elevationStops.length;f++){const g=yp(o.elevationStops[f],s);h.setPixel(0,f,new Mt(g.r/255,g.g/255,g.b/255,1)),u.setPixel(0,f,o.colorStops[f])}return this.colorRampTextures={elevationTexture:new Oh(e,h,e.gl.RGBA),colorTexture:new Oh(e,u,e.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return!this.isHidden()&&!!this.colorRampTextures}}const Xg=Ni([{name:"a_pos",components:2,type:"Int16"}],4),{members:Yg}=Xg;function Pu(r,e,i){const s=i.patternDependencies;let o=!1;for(const u of e){const h=u.paint.get(`${r}-pattern`);h.isConstant()||(o=!0);const f=h.constantOr(null);f&&(o=!0,s[f.to]=!0,s[f.from]=!0)}return o}function Vh(r,e,i,s,o){const{zoom:u}=s,h=o.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,{},o.availableImages),v=g.evaluate({zoom:u},i,{},o.availableImages),w=g.evaluate({zoom:u+1},i,{},o.availableImages);y=y&&y.name?y.name:y,v=v&&v.name?v.name:v,w=w&&w.name?w.name:w,h[y]=!0,h[v]=!0,h[w]=!0,i.patterns[f.id]={min:y,mid:v,max:w}}}return i}function xp(r,e,i,s,o){let u;if(o===(function(h,f,g,y){let v=0;for(let w=f,S=g-y;w<g;w+=y)v+=(h[S]-h[w])*(h[w+1]+h[S+1]),S=w;return v})(r,e,i,s)>0)for(let h=e;h<i;h+=s)u=Tp(h/s|0,r[h],r[h+1],u);else for(let h=i-s;h>=e;h-=s)u=Tp(h/s|0,r[h],r[h+1],u);return u&&ko(u,u.next)&&(Ql(u),u=u.next),u}function Ca(r,e){if(!r)return r;e||(e=r);let i,s=r;do if(i=!1,s.steiner||!ko(s,s.next)&&Zi(s.prev,s,s.next)!==0)s=s.next;else{if(Ql(s),s=e=s.prev,s===s.next)break;i=!0}while(i||s!==e);return e}function Yl(r,e,i,s,o,u,h){if(!r)return;!h&&u&&(function(g,y,v,w){let S=g;do S.z===0&&(S.z=jh(S.x,S.y,y,v,w)),S.prevZ=S.prev,S.nextZ=S.next,S=S.next;while(S!==g);S.prevZ.nextZ=null,S.prevZ=null,(function(M){let A,z=1;do{let R,j=M;M=null;let X=null;for(A=0;j;){A++;let N=j,G=0;for(let te=0;te<z&&(G++,N=N.nextZ,N);te++);let K=z;for(;G>0||K>0&&N;)G!==0&&(K===0||!N||j.z<=N.z)?(R=j,j=j.nextZ,G--):(R=N,N=N.nextZ,K--),X?X.nextZ=R:M=R,R.prevZ=X,X=R;j=N}X.nextZ=null,z*=2}while(A>1)})(S)})(r,s,o,u);let f=r;for(;r.prev!==r.next;){const g=r.prev,y=r.next;if(u?Jg(r,s,o,u):Kg(r))e.push(g.i,r.i,y.i),Ql(r),r=y.next,f=y.next;else if((r=y)===f){h?h===1?Yl(r=Qg(Ca(r),e),e,i,s,o,u,2):h===2&&e_(r,e,i,s,o,u):Yl(Ca(r),e,i,s,o,u,1);break}}}function Kg(r){const e=r.prev,i=r,s=r.next;if(Zi(e,i,s)>=0)return!1;const o=e.x,u=i.x,h=s.x,f=e.y,g=i.y,y=s.y,v=Math.min(o,u,h),w=Math.min(f,g,y),S=Math.max(o,u,h),M=Math.max(f,g,y);let A=s.next;for(;A!==e;){if(A.x>=v&&A.x<=S&&A.y>=w&&A.y<=M&&Kl(o,f,u,g,h,y,A.x,A.y)&&Zi(A.prev,A,A.next)>=0)return!1;A=A.next}return!0}function Jg(r,e,i,s){const o=r.prev,u=r,h=r.next;if(Zi(o,u,h)>=0)return!1;const f=o.x,g=u.x,y=h.x,v=o.y,w=u.y,S=h.y,M=Math.min(f,g,y),A=Math.min(v,w,S),z=Math.max(f,g,y),R=Math.max(v,w,S),j=jh(M,A,e,i,s),X=jh(z,R,e,i,s);let N=r.prevZ,G=r.nextZ;for(;N&&N.z>=j&&G&&G.z<=X;){if(N.x>=M&&N.x<=z&&N.y>=A&&N.y<=R&&N!==o&&N!==h&&Kl(f,v,g,w,y,S,N.x,N.y)&&Zi(N.prev,N,N.next)>=0||(N=N.prevZ,G.x>=M&&G.x<=z&&G.y>=A&&G.y<=R&&G!==o&&G!==h&&Kl(f,v,g,w,y,S,G.x,G.y)&&Zi(G.prev,G,G.next)>=0))return!1;G=G.nextZ}for(;N&&N.z>=j;){if(N.x>=M&&N.x<=z&&N.y>=A&&N.y<=R&&N!==o&&N!==h&&Kl(f,v,g,w,y,S,N.x,N.y)&&Zi(N.prev,N,N.next)>=0)return!1;N=N.prevZ}for(;G&&G.z<=X;){if(G.x>=M&&G.x<=z&&G.y>=A&&G.y<=R&&G!==o&&G!==h&&Kl(f,v,g,w,y,S,G.x,G.y)&&Zi(G.prev,G,G.next)>=0)return!1;G=G.nextZ}return!0}function Qg(r,e){let i=r;do{const s=i.prev,o=i.next.next;!ko(s,o)&&bp(s,i,i.next,o)&&Jl(s,o)&&Jl(o,s)&&(e.push(s.i,i.i,o.i),Ql(i),Ql(i.next),i=r=o),i=i.next}while(i!==r);return Ca(i)}function e_(r,e,i,s,o,u){let h=r;do{let f=h.next.next;for(;f!==h.prev;){if(h.i!==f.i&&s_(h,f)){let g=wp(h,f);return h=Ca(h,h.next),g=Ca(g,g.next),Yl(h,e,i,s,o,u,0),void Yl(g,e,i,s,o,u,0)}f=f.next}h=h.next}while(h!==r)}function t_(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 i_(r,e){const i=(function(o,u){let h=u;const f=o.x,g=o.y;let y,v=-1/0;if(ko(o,h))return h;do{if(ko(o,h.next))return h.next;if(g<=h.y&&g>=h.next.y&&h.next.y!==h.y){const z=h.x+(g-h.y)*(h.next.x-h.x)/(h.next.y-h.y);if(z<=f&&z>v&&(v=z,y=h.x<h.next.x?h:h.next,z===f))return y}h=h.next}while(h!==u);if(!y)return null;const w=y,S=y.x,M=y.y;let A=1/0;h=y;do{if(f>=h.x&&h.x>=S&&f!==h.x&&vp(g<M?f:v,g,S,M,g<M?v:f,g,h.x,h.y)){const z=Math.abs(g-h.y)/(f-h.x);Jl(h,o)&&(z<A||z===A&&(h.x>y.x||h.x===y.x&&r_(y,h)))&&(y=h,A=z)}h=h.next}while(h!==w);return y})(r,e);if(!i)return e;const s=wp(i,r);return Ca(s,s.next),Ca(i,i.next)}function r_(r,e){return Zi(r.prev,r,e.prev)<0&&Zi(e.next,r,r.next)<0}function jh(r,e,i,s,o){return(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=(r-i)*o|0)|r<<8))|r<<4))|r<<2))|r<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-s)*o|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function n_(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 vp(r,e,i,s,o,u,h,f){return(o-h)*(e-f)>=(r-h)*(u-f)&&(r-h)*(s-f)>=(i-h)*(e-f)&&(i-h)*(u-f)>=(o-h)*(s-f)}function Kl(r,e,i,s,o,u,h,f){return!(r===h&&e===f)&&vp(r,e,i,s,o,u,h,f)}function s_(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!(function(i,s){let o=i;do{if(o.i!==i.i&&o.next.i!==i.i&&o.i!==s.i&&o.next.i!==s.i&&bp(o,o.next,i,s))return!0;o=o.next}while(o!==i);return!1})(r,e)&&(Jl(r,e)&&Jl(e,r)&&(function(i,s){let o=i,u=!1;const h=(i.x+s.x)/2,f=(i.y+s.y)/2;do o.y>f!=o.next.y>f&&o.next.y!==o.y&&h<(o.next.x-o.x)*(f-o.y)/(o.next.y-o.y)+o.x&&(u=!u),o=o.next;while(o!==i);return u})(r,e)&&(Zi(r.prev,r,e.prev)||Zi(r,e.prev,e))||ko(r,e)&&Zi(r.prev,r,r.next)>0&&Zi(e.prev,e,e.next)>0)}function Zi(r,e,i){return(e.y-r.y)*(i.x-e.x)-(e.x-r.x)*(i.y-e.y)}function ko(r,e){return r.x===e.x&&r.y===e.y}function bp(r,e,i,s){const o=Iu(Zi(r,e,i)),u=Iu(Zi(r,e,s)),h=Iu(Zi(i,s,r)),f=Iu(Zi(i,s,e));return o!==u&&h!==f||!(o!==0||!Mu(r,i,e))||!(u!==0||!Mu(r,s,e))||!(h!==0||!Mu(i,r,s))||!(f!==0||!Mu(i,e,s))}function Mu(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 Iu(r){return r>0?1:r<0?-1:0}function Jl(r,e){return Zi(r.prev,r,r.next)<0?Zi(r,e,r.next)>=0&&Zi(r,r.prev,e)>=0:Zi(r,e,r.prev)<0||Zi(r,r.next,e)<0}function wp(r,e){const i=Nh(r.i,r.x,r.y),s=Nh(e.i,e.x,e.y),o=r.next,u=e.prev;return r.next=e,e.prev=r,i.next=o,o.prev=i,s.next=i,i.prev=s,u.next=s,s.prev=u,s}function Tp(r,e,i,s){const o=Nh(r,e,i);return s?(o.next=s.next,o.prev=s,s.next.prev=o,s.next=o):(o.prev=o,o.next=o),o}function Ql(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 Nh(r,e,i){return{i:r,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class Ro{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 Eu{constructor(e){this.fill=e.fill,this.line=e.line,this.tile=e.tile,this.stencil=e.stencil,this.circle=e.circle}}Eu.noSubdivision=new Eu({fill:new Ro(0,0),line:new Ro(0,0),tile:new Ro(0,0),stencil:new Ro(0,0),circle:1}),Xe("SubdivisionGranularityExpression",Ro),Xe("SubdivisionGranularitySetting",Eu);const Fo=-32768,ec=32767;class a_{constructor(e,i){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=e,this._granularityCellSize=Ze/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),o=0|Math.round(i),u=this._getKey(s,o);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,o),h}_subdivideTrianglesScanline(e){if(this._granularity<2)return(function(o,u){const h=[];for(let f=0;f<u.length;f+=3){const g=u[f],y=u[f+1],v=u[f+2],w=o[2*g],S=o[2*g+1];(o[2*y]-w)*(o[2*v+1]-S)-(o[2*y+1]-S)*(o[2*v]-w)>0?(h.push(g),h.push(v),h.push(y)):(h.push(g),h.push(y),h.push(v))}return h})(this._vertexBuffer,e);const i=[],s=e.length;for(let o=0;o<s;o+=3){const u=[e[o+0],e[o+1],e[o+2]],h=[this._vertexBuffer[2*e[o+0]+0],this._vertexBuffer[2*e[o+0]+1],this._vertexBuffer[2*e[o+1]+0],this._vertexBuffer[2*e[o+1]+1],this._vertexBuffer[2*e[o+2]+0],this._vertexBuffer[2*e[o+2]+1]];let f=1/0,g=1/0,y=-1/0,v=-1/0;for(let z=0;z<3;z++){const R=h[2*z],j=h[2*z+1];f=Math.min(f,R),y=Math.max(y,R),g=Math.min(g,j),v=Math.max(v,j)}if(f===y||g===v)continue;const w=Math.floor(f/this._granularityCellSize),S=Math.ceil(y/this._granularityCellSize),M=Math.floor(g/this._granularityCellSize),A=Math.ceil(v/this._granularityCellSize);if(w!==S||M!==A)for(let z=M;z<A;z++){const R=this._scanlineGenerateVertexRingForCellRow(z,h,u);o_(this._vertexBuffer,R,i)}else i.push(...u)}return i}_scanlineGenerateVertexRingForCellRow(e,i,s){const o=e*this._granularityCellSize,u=o+this._granularityCellSize,h=[];for(let f=0;f<3;f++){const g=i[2*f],y=i[2*f+1],v=i[2*(f+1)%6],w=i[(2*(f+1)+1)%6],S=i[2*(f+2)%6],M=i[(2*(f+2)+1)%6],A=v-g,z=w-y,R=A===0,j=z===0,X=(o-y)/z,N=(u-y)/z,G=Math.min(X,N),K=Math.max(X,N);if(!j&&(G>=1||K<=0)||j&&(y<o||y>u)){w>=o&&w<=u&&h.push(s[(f+1)%3]);continue}!j&&G>0&&h.push(this._vertexToIndex(g+A*G,y+z*G));const te=g+A*Math.max(G,0),me=g+A*Math.min(K,1);R||this._generateIntraEdgeVertices(h,g,y,v,w,te,me),!j&&K<1&&h.push(this._vertexToIndex(g+A*K,y+z*K)),(j||w>=o&&w<=u)&&h.push(s[(f+1)%3]),!j&&(w<=o||w>=u)&&this._generateInterEdgeVertices(h,g,y,v,w,S,M,me,o,u)}return h}_generateIntraEdgeVertices(e,i,s,o,u,h,f){const g=o-i,y=u-s,v=y===0,w=v?Math.min(i,o):Math.min(h,f),S=v?Math.max(i,o):Math.max(h,f),M=Math.floor(w/this._granularityCellSize)+1,A=Math.ceil(S/this._granularityCellSize)-1;if(v?i<o:h<f)for(let z=M;z<=A;z++){const R=z*this._granularityCellSize;e.push(this._vertexToIndex(R,s+y*(R-i)/g))}else for(let z=A;z>=M;z--){const R=z*this._granularityCellSize;e.push(this._vertexToIndex(R,s+y*(R-i)/g))}}_generateInterEdgeVertices(e,i,s,o,u,h,f,g,y,v){const w=u-s,S=h-o,M=f-u,A=(y-u)/M,z=(v-u)/M,R=Math.min(A,z),j=Math.max(A,z),X=o+S*R;let N=Math.floor(Math.min(X,g)/this._granularityCellSize)+1,G=Math.ceil(Math.max(X,g)/this._granularityCellSize)-1,K=g<X;const te=M===0;if(te&&(f===y||f===v))return;if(te||R>=1||j<=0){const Ie=s-f,Se=h+(i-h)*Math.min((y-f)/Ie,(v-f)/Ie);N=Math.floor(Math.min(Se,g)/this._granularityCellSize)+1,G=Math.ceil(Math.max(Se,g)/this._granularityCellSize)-1,K=g<Se}const me=w>0?v:y;if(K)for(let Ie=N;Ie<=G;Ie++)e.push(this._vertexToIndex(Ie*this._granularityCellSize,me));else for(let Ie=G;Ie>=N;Ie--)e.push(this._vertexToIndex(Ie*this._granularityCellSize,me))}_generateOutline(e){const i=[];for(const s of e){const o=Aa(s,this._granularity,!0),u=this._pointArrayToIndices(o),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===Fo&&(e[i+1]=-32767),s===ec&&(e[i+1]=32766)}}_generatePoleQuad(e,i,s,o,u,h){o>u!=(h===Fo)?(e.push(i),e.push(s),e.push(this._vertexToIndex(o,h)),e.push(s),e.push(this._vertexToIndex(u,h)),e.push(this._vertexToIndex(o,h))):(e.push(s),e.push(i),e.push(this._vertexToIndex(o,h)),e.push(this._vertexToIndex(u,h)),e.push(s),e.push(this._vertexToIndex(o,h)))}_fillPoles(e,i,s){const o=this._vertexBuffer,u=Ze,h=e.length;for(let f=2;f<h;f+=3){const g=e[f-2],y=e[f-1],v=e[f],w=o[2*g],S=o[2*g+1],M=o[2*y],A=o[2*y+1],z=o[2*v],R=o[2*v+1];i&&(S===0&&A===0&&this._generatePoleQuad(e,g,y,w,M,Fo),A===0&&R===0&&this._generatePoleQuad(e,y,v,M,z,Fo),R===0&&S===0&&this._generatePoleQuad(e,v,g,z,w,Fo)),s&&(S===u&&A===u&&this._generatePoleQuad(e,g,y,w,M,ec),A===u&&R===u&&this._generatePoleQuad(e,y,v,M,z,ec),R===u&&S===u&&this._generatePoleQuad(e,v,g,z,w,ec))}}_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:o}=(function(f){const g=[],y=[];for(const v of f)if(v.length!==0){v!==f[0]&&g.push(y.length/2);for(let w=0;w<v.length;w++)y.push(v[w].x),y.push(v[w].y)}return{flattened:y,holeIndices:g}})(e);let u;this._initializeVertices(s);try{const f=(function(y,v,w=2){const S=v&&v.length,M=S?v[0]*w:y.length;let A=xp(y,0,M,w,!0);const z=[];if(!A||A.next===A.prev)return z;let R,j,X;if(S&&(A=(function(N,G,K,te){const me=[];for(let Ie=0,Se=G.length;Ie<Se;Ie++){const Ce=xp(N,G[Ie]*te,Ie<Se-1?G[Ie+1]*te:N.length,te,!1);Ce===Ce.next&&(Ce.steiner=!0),me.push(n_(Ce))}me.sort(t_);for(let Ie=0;Ie<me.length;Ie++)K=i_(me[Ie],K);return K})(y,v,A,w)),y.length>80*w){R=y[0],j=y[1];let N=R,G=j;for(let K=w;K<M;K+=w){const te=y[K],me=y[K+1];te<R&&(R=te),me<j&&(j=me),te>N&&(N=te),me>G&&(G=me)}X=Math.max(N-R,G-j),X=X!==0?32767/X:0}return Yl(A,z,w,R,j,X,0),z})(s,o),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 o=0;o<i.length;o++)s.push(this._vertexToIndex(e[2*i[o]],e[2*i[o]+1]));return s}_pointArrayToIndices(e){const i=[];for(let s=0;s<e.length;s++){const o=e[s];i.push(this._vertexToIndex(o.x,o.y))}return i}}function Sp(r,e,i,s=!0){return new a_(i,e).subdividePolygonInternal(r,s)}function Aa(r,e,i=!1){if(!r||r.length<1)return[];if(r.length<2)return[];const s=r[0],o=r[r.length-1],u=i&&(s.x!==o.x||s.y!==o.y);if(e<2)return u?[...r,r[0]]:[...r];const h=Math.floor(Ze/e),f=[];f.push(new le(r[0].x,r[0].y));const g=r.length,y=u?g:g-1;for(let v=0;v<y;v++){const w=r[v],S=v<g-1?r[v+1]:r[0],M=w.x,A=w.y,z=S.x,R=S.y,j=M!==z,X=A!==R;if(!j&&!X)continue;const N=z-M,G=R-A,K=Math.abs(N),te=Math.abs(G);let me=M,Ie=A;for(;;){const Ce=N>0?(Math.floor(me/h)+1)*h:(Math.ceil(me/h)-1)*h,Ve=G>0?(Math.floor(Ie/h)+1)*h:(Math.ceil(Ie/h)-1)*h,ze=Math.abs(me-Ce),Me=Math.abs(Ie-Ve),be=Math.abs(me-z),He=Math.abs(Ie-R),$e=j?ze/K:Number.POSITIVE_INFINITY,Ke=X?Me/te:Number.POSITIVE_INFINITY;if((be<=ze||!j)&&(He<=Me||!X))break;if($e<Ke&&j||!X){me=Ce,Ie+=G*$e;const Ge=new le(me,Math.round(Ie));f[f.length-1].x===Ge.x&&f[f.length-1].y===Ge.y||f.push(Ge)}else{me+=N*Ke,Ie=Ve;const Ge=new le(Math.round(me),Ie);f[f.length-1].x===Ge.x&&f[f.length-1].y===Ge.y||f.push(Ge)}}const Se=new le(z,R);f[f.length-1].x===Se.x&&f[f.length-1].y===Se.y||f.push(Se)}return f}function o_(r,e,i){if(e.length===0)throw new Error("Subdivision vertex ring is empty.");let s=0,o=r[2*e[0]];for(let g=1;g<e.length;g++){const y=r[2*e[g]];y<o&&(o=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,v=r[2*e[g]],w=r[2*e[y]],S=r[2*e[h]],M=r[2*e[h]+1],A=r[2*e[f]+1];let z=!1;if(v<w)z=!0;else if(v>w)z=!1;else{const R=A-M,j=-(r[2*e[f]]-S),X=M<A?1:-1;((v-S)*R+(r[2*e[g]+1]-M)*j)*X>((w-S)*R+(r[2*e[y]+1]-M)*j)*X&&(z=!0)}if(z){const R=e[g],j=e[h],X=e[f];R!==j&&R!==X&&j!==X&&i.push(X,j,R),h--,h<0&&(h=u-1)}else{const R=e[y],j=e[h],X=e[f];R!==j&&R!==X&&j!==X&&i.push(X,j,R),f++,f>=u&&(f=0)}if(g===y)break}}function Pp(r,e,i,s,o,u,h,f,g){const y=o.length/2,v=h&&f&&g;if(y<Ue.MAX_VERTEX_ARRAY_LENGTH){const w=e.prepareSegment(y,i,s),S=w.vertexLength;for(let z=0;z<u.length;z+=3)s.emplaceBack(S+u[z],S+u[z+1],S+u[z+2]);let M,A;w.vertexLength+=y,w.primitiveLength+=u.length/3,v&&(A=h.prepareSegment(y,i,f),M=A.vertexLength,A.vertexLength+=y);for(let z=0;z<o.length;z+=2)r(o[z],o[z+1]);if(v)for(let z=0;z<g.length;z++){const R=g[z];for(let j=1;j<R.length;j+=2)f.emplaceBack(M+R[j-1],M+R[j]);A.primitiveLength+=R.length/2}}else(function(w,S,M,A,z,R){const j=[];for(let te=0;te<A.length/2;te++)j.push(-1);const X={count:0};let N=0,G=w.getOrCreateLatestSegment(S,M),K=G.vertexLength;for(let te=2;te<z.length;te+=3){const me=z[te-2],Ie=z[te-1],Se=z[te];let Ce=j[me]<N,Ve=j[Ie]<N,ze=j[Se]<N;G.vertexLength+((Ce?1:0)+(Ve?1:0)+(ze?1:0))>Ue.MAX_VERTEX_ARRAY_LENGTH&&(G=w.createNewSegment(S,M),N=X.count,Ce=!0,Ve=!0,ze=!0,K=0);const Me=tc(j,A,R,X,me,Ce,G),be=tc(j,A,R,X,Ie,Ve,G),He=tc(j,A,R,X,Se,ze,G);M.emplaceBack(K+Me-N,K+be-N,K+He-N),G.primitiveLength++}})(e,i,s,o,u,r),v&&(function(w,S,M,A,z,R){const j=[];for(let te=0;te<A.length/2;te++)j.push(-1);const X={count:0};let N=0,G=w.getOrCreateLatestSegment(S,M),K=G.vertexLength;for(let te=0;te<z.length;te++){const me=z[te];for(let Ie=1;Ie<z[te].length;Ie+=2){const Se=me[Ie-1],Ce=me[Ie];let Ve=j[Se]<N,ze=j[Ce]<N;G.vertexLength+((Ve?1:0)+(ze?1:0))>Ue.MAX_VERTEX_ARRAY_LENGTH&&(G=w.createNewSegment(S,M),N=X.count,Ve=!0,ze=!0,K=0);const Me=tc(j,A,R,X,Se,Ve,G),be=tc(j,A,R,X,Ce,ze,G);M.emplaceBack(K+Me-N,K+be-N),G.primitiveLength++}}})(h,i,f,o,g,r),e.forceNewSegmentOnNextPrepare(),h==null||h.forceNewSegmentOnNextPrepare()}function tc(r,e,i,s,o,u,h){if(u){const f=s.count;return i(e[2*o],e[2*o+1]),r[o]=s.count,s.count++,h.vertexLength++,f}return r[o]}class Uh{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 Z,this.indexArray=new ve,this.indexArray2=new Fe,this.programConfigurations=new is(e.layers,e.zoom),this.segments=new Ue,this.segments2=new Ue,this.stateDependentLayerIds=this.layers.filter((i=>i.isStateDependent())).map((i=>i.id))}populate(e,i,s){this.hasDependencies=Pu("fill",this.layers,i);const o=this.layers[0].layout.get("fill-sort-key"),u=!o.isConstant(),h=[];for(const{feature:f,id:g,index:y,sourceLayerIndex:v}of e){const w=this.layers[0]._featureFilter.needGeometry,S=Rn(f,w);if(!this.layers[0]._featureFilter.filter(new ii(this.zoom),S,s))continue;const M=u?o.evaluate(S,{},s,i.availableImages):void 0,A={id:g,properties:f.properties,type:f.type,sourceLayerIndex:v,index:y,geometry:w?S.geometry:kn(f),patterns:{},sortKey:M};h.push(A)}u&&h.sort(((f,g)=>f.sortKey-g.sortKey));for(const f of h){const{geometry:g,index:y,sourceLayerIndex:v}=f;if(this.hasDependencies){const w=Vh("fill",this.layers,f,{zoom:this.zoom},i);this.patternFeatures.push(w)}else this.addFeature(f,g,y,s,{},i.subdivisionGranularity);i.featureIndex.insert(e[y].feature,g,y,v,this.index)}}update(e,i,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,i,this.stateDependentLayers,{imagePositions:s})}addFeatures(e,i,s){for(const o of this.patternFeatures)this.addFeature(o,o.geometry,o.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,Yg),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,o,u,h){for(const f of Ka(i,500)){const g=Sp(f,o,h.fill.getGranularityForZoomLevel(o.z)),y=this.layoutVertexArray;Pp(((v,w)=>{y.emplaceBack(v,w)}),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:o})}}let Mp,Ip;Xe("FillBucket",Uh,{omit:["layers","patternFeatures"]});var l_={get paint(){return Ip=Ip||new Tr({"fill-antialias":new et(ye.paint_fill["fill-antialias"]),"fill-opacity":new nt(ye.paint_fill["fill-opacity"]),"fill-color":new nt(ye.paint_fill["fill-color"]),"fill-outline-color":new nt(ye.paint_fill["fill-outline-color"]),"fill-translate":new et(ye.paint_fill["fill-translate"]),"fill-translate-anchor":new et(ye.paint_fill["fill-translate-anchor"]),"fill-pattern":new ba(ye.paint_fill["fill-pattern"])})},get layout(){return Mp=Mp||new Tr({"fill-sort-key":new nt(ye.layout_fill["fill-sort-key"])})}};class c_ extends Gr{constructor(e,i){super(e,l_,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 Uh(e)}queryRadius(){return Tu(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:i,transform:s,pixelsToTileUnits:o}){return sp(Su(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-s.bearingInRadians,o),i)}isTileClipped(){return!0}}const u_=Ni([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),h_=Ni([{name:"a_centroid",components:2,type:"Int16"}],4),{members:d_}=u_;class ic{constructor(e,i,s,o,u){this.properties={},this.extent=s,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=o,this._values=u,e.readFields(p_,this,i)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const i=e.readVarint()+e.pos,s=[];let o,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&&(o&&s.push(o),o=[]),o&&o.push(new le(f,g));else{if(u!==7)throw new Error(`unknown command ${u}`);o&&o.push(o[0].clone())}}return o&&s.push(o),s}bbox(){const e=this._pbf;e.pos=this._geometry;const i=e.readVarint()+e.pos;let s=1,o=0,u=0,h=0,f=1/0,g=-1/0,y=1/0,v=-1/0;for(;e.pos<i;){if(o<=0){const w=e.readVarint();s=7&w,o=w>>3}if(o--,s===1||s===2)u+=e.readSVarint(),h+=e.readSVarint(),u<f&&(f=u),u>g&&(g=u),h<y&&(y=h),h>v&&(v=h);else if(s!==7)throw new Error(`unknown command ${s}`)}return[f,y,g,v]}toGeoJSON(e,i,s){const o=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)/o-180,360/Math.PI*Math.atan(Math.exp((1-2*(S.y+h)/o)*Math.PI))-90]}function y(S){return S.map(g)}let v;if(this.type===1){const S=[];for(const A of f)S.push(A[0]);const M=y(S);v=S.length===1?{type:"Point",coordinates:M[0]}:{type:"MultiPoint",coordinates:M}}else if(this.type===2){const S=f.map(y);v=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=Ep(f),M=[];for(const A of S)M.push(A.map(y));v=M.length===1?{type:"Polygon",coordinates:M[0]}:{type:"MultiPolygon",coordinates:M}}}const w={type:"Feature",geometry:v,properties:this.properties};return this.id!=null&&(w.id=this.id),w}}function p_(r,e,i){r===1?e.id=i.readVarint():r===2?(function(s,o){const u=s.readVarint()+s.pos;for(;s.pos<u;){const h=o._keys[s.readVarint()],f=o._values[s.readVarint()];o.properties[h]=f}})(i,e):r===3?e.type=i.readVarint():r===4&&(e._geometry=i.pos)}function Ep(r){const e=r.length;if(e<=1)return[r];const i=[];let s,o;for(let u=0;u<e;u++){const h=f_(r[u]);h!==0&&(o===void 0&&(o=h<0),o===h<0?(s&&i.push(s),s=[r[u]]):s&&s.push(r[u]))}return s&&i.push(s),i}function f_(r){let e=0;for(let i,s,o=0,u=r.length,h=u-1;o<u;h=o++)i=r[o],s=r[h],e+=(s.x-i.x)*(i.y+s.y);return e}ic.types=["Unknown","Point","LineString","Polygon"];class m_{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(g_,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 ic(this._pbf,i,this.extent,this._keys,this._values)}}function g_(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 o=null;const u=s.readVarint()+s.pos;for(;s.pos<u;){const h=s.readVarint()>>3;o=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(o==null)throw new Error("unknown feature value");return o})(i))}class Cp{constructor(e,i){this.layers=e.readFields(__,{},i)}}function __(r,e,i){if(r===3){const s=new m_(i,i.readVarint()+i.pos);s.length&&(e[s.name]=s)}}const Gh=Math.pow(2,13);function rc(r,e,i,s,o,u,h,f){r.emplaceBack(e,i,2*Math.floor(s*Gh)+h,o*Gh*2,u*Gh*2,Math.round(f))}class qh{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 Y,this.centroidVertexArray=new q,this.indexArray=new ve,this.programConfigurations=new is(e.layers,e.zoom),this.segments=new Ue,this.stateDependentLayerIds=this.layers.filter((i=>i.isStateDependent())).map((i=>i.id))}populate(e,i,s){this.features=[],this.hasDependencies=Pu("fill-extrusion",this.layers,i);for(const{feature:o,id:u,index:h,sourceLayerIndex:f}of e){const g=this.layers[0]._featureFilter.needGeometry,y=Rn(o,g);if(!this.layers[0]._featureFilter.filter(new ii(this.zoom),y,s))continue;const v={id:u,sourceLayerIndex:f,index:h,geometry:g?y.geometry:kn(o),properties:o.properties,type:o.type,patterns:{}};this.hasDependencies?this.features.push(Vh("fill-extrusion",this.layers,v,{zoom:this.zoom},i)):this.addFeature(v,v.geometry,h,s,{},i.subdivisionGranularity),i.featureIndex.insert(o,v.geometry,h,f,this.index,!0)}}addFeatures(e,i,s){for(const o of this.features){const{geometry:u}=o;this.addFeature(o,u,o.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,d_),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,h_.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,o,u,h){for(const f of Ka(i,500)){const g={x:0,y:0,sampleCount:0},y=this.layoutVertexArray.length;this.processPolygon(g,o,e,f,h);const v=this.layoutVertexArray.length-y,w=Math.floor(g.x/g.sampleCount),S=Math.floor(g.y/g.sampleCount);for(let M=0;M<v;M++)this.centroidVertexArray.emplaceBack(w,S)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,s,{imagePositions:u,canonical:o})}processPolygon(e,i,s,o,u){if(o.length<1||Ap(o[0]))return;for(const w of o)w.length!==0&&y_(e,w);const h={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},f=u.fill.getGranularityForZoomLevel(i.z),g=ic.types[s.type]==="Polygon";for(const w of o){if(w.length===0||Ap(w))continue;const S=Aa(w,f,g);this._generateSideFaces(S,h)}if(!g)return;const y=Sp(o,i,f,!1),v=this.layoutVertexArray;Pp(((w,S)=>{rc(v,w,S,0,0,1,1,0)}),this.segments,this.layoutVertexArray,this.indexArray,y.verticesFlattened,y.indicesTriangles)}_generateSideFaces(e,i){let s=0;for(let o=1;o<e.length;o++){const u=e[o],h=e[o-1];if(x_(u,h))continue;i.segment.vertexLength+4>Ue.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),rc(this.layoutVertexArray,u.x,u.y,f.x,f.y,0,0,s),rc(this.layoutVertexArray,u.x,u.y,f.x,f.y,0,1,s),s+=g,rc(this.layoutVertexArray,h.x,h.y,f.x,f.y,0,0,s),rc(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 y_(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 x_(r,e){return r.x===e.x&&(r.x<0||r.x>Ze)||r.y===e.y&&(r.y<0||r.y>Ze)}function Ap(r){return r.every((e=>e.x<0))||r.every((e=>e.x>Ze))||r.every((e=>e.y<0))||r.every((e=>e.y>Ze))}let Dp;Xe("FillExtrusionBucket",qh,{omit:["layers","features"]});var v_={get paint(){return Dp=Dp||new Tr({"fill-extrusion-opacity":new et(ye["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new nt(ye["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new et(ye["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new et(ye["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new ba(ye["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new nt(ye["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new nt(ye["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new et(ye["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class b_ extends Gr{constructor(e,i){super(e,v_,i)}createBucket(e){return new qh(e)}queryRadius(){return Tu(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:i,featureState:s,geometry:o,transform:u,pixelsToTileUnits:h,pixelPosMatrix:f}){const g=Su(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),v=this.paint.get("fill-extrusion-base").evaluate(i,s),w=(function(M,A){const z=[];for(const R of M){const j=[R.x,R.y,0,1];jt(j,j,A),z.push(new le(j[0]/j[3],j[1]/j[3]))}return z})(g,f),S=(function(M,A,z,R){const j=[],X=[],N=R[8]*A,G=R[9]*A,K=R[10]*A,te=R[11]*A,me=R[8]*z,Ie=R[9]*z,Se=R[10]*z,Ce=R[11]*z;for(const Ve of M){const ze=[],Me=[];for(const be of Ve){const He=be.x,$e=be.y,Ke=R[0]*He+R[4]*$e+R[12],Ge=R[1]*He+R[5]*$e+R[13],it=R[2]*He+R[6]*$e+R[14],Ot=R[3]*He+R[7]*$e+R[15],At=it+K,Si=Ot+te,pr=Ke+me,Hi=Ge+Ie,Pi=it+Se,yi=Ot+Ce,Zt=new le((Ke+N)/Si,(Ge+G)/Si);Zt.z=At/Si,ze.push(Zt);const Li=new le(pr/yi,Hi/yi);Li.z=Pi/yi,Me.push(Li)}j.push(ze),X.push(Me)}return[j,X]})(o,v,y,f);return(function(M,A,z){let R=1/0;sp(z,A)&&(R=zp(z,A[0]));for(let j=0;j<A.length;j++){const X=A[j],N=M[j];for(let G=0;G<X.length-1;G++){const K=X[G],te=[K,X[G+1],N[G+1],N[G],K];Ao(z,te)&&(R=Math.min(R,zp(z,te)))}}return R!==1/0&&R})(S[0],S[1],w)}}function nc(r,e){return r.x*e.x+r.y*e.y}function zp(r,e){if(r.length===1){let i=0;const s=e[i++];let o;for(;!o||s.equals(o);)if(o=e[i++],!o)return 1/0;for(;i<e.length;i++){const u=e[i],h=r[0],f=o.sub(s),g=u.sub(s),y=h.sub(s),v=nc(f,f),w=nc(f,g),S=nc(g,g),M=nc(y,f),A=nc(y,g),z=v*S-w*w,R=(S*M-w*A)/z,j=(v*A-w*M)/z,X=s.z*(1-R-j)+o.z*R+u.z*j;if(isFinite(X))return X}return 1/0}{let i=1/0;for(const s of e)i=Math.min(i,s.z);return i}}const w_=Ni([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:T_}=w_,S_=Ni([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:P_}=S_,M_=Math.cos(Math.PI/180*37.5),kp=Math.pow(2,14)/.5;class Zh{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 ie,this.layoutVertexArray2=new H,this.indexArray=new ve,this.programConfigurations=new is(e.layers,e.zoom),this.segments=new Ue,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((i=>i.isStateDependent())).map((i=>i.id))}populate(e,i,s){this.hasDependencies=Pu("line",this.layers,i)||this.hasLineDasharray(this.layers);const o=this.layers[0].layout.get("line-sort-key"),u=!o.isConstant(),h=[];for(const{feature:f,id:g,index:y,sourceLayerIndex:v}of e){const w=this.layers[0]._featureFilter.needGeometry,S=Rn(f,w);if(!this.layers[0]._featureFilter.filter(new ii(this.zoom),S,s))continue;const M=u?o.evaluate(S,{},s):void 0,A={id:g,properties:f.properties,type:f.type,sourceLayerIndex:v,index:y,geometry:w?S.geometry:kn(f),patterns:{},dashes:{},sortKey:M};h.push(A)}u&&h.sort(((f,g)=>f.sortKey-g.sortKey));for(const f of h){const{geometry:g,index:y,sourceLayerIndex:v}=f;this.hasDependencies?(Pu("line",this.layers,i)?Vh("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,v,this.index)}}update(e,i,s,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,i,this.stateDependentLayers,{imagePositions:s,dashPositions:o})}addFeatures(e,i,s,o){for(const u of this.patternFeatures)this.addFeature(u,u.geometry,u.index,i,s,o,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,P_)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,T_),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,o,u,h,f){const g=this.layers[0].layout,y=g.get("line-join").evaluate(e,{}),v=g.get("line-cap"),w=g.get("line-miter-limit"),S=g.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const M of i)this.addLine(M,e,y,v,w,S,o,f);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,s,{imagePositions:u,dashPositions:h,canonical:o})}addLine(e,i,s,o,u,h,f,g){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=Aa(e,f?g.line.getGranularityForZoomLevel(f.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let N=0;N<e.length-1;N++)this.totalDistance+=e[N].dist(e[N+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const y=ic.types[i.type]==="Polygon";let v=e.length;for(;v>=2&&e[v-1].equals(e[v-2]);)v--;let w=0;for(;w<v-1&&e[w].equals(e[w+1]);)w++;if(v<(y?3:2))return;s==="bevel"&&(u=1.05);const S=this.overscaling<=16?122880/(512*this.overscaling):0,M=this.segments.prepareSegment(10*v,this.layoutVertexArray,this.indexArray);let A,z,R,j,X;this.e1=this.e2=-1,y&&(A=e[v-2],X=e[w].sub(A)._unit()._perp());for(let N=w;N<v;N++){if(R=N===v-1?y?e[w+1]:void 0:e[N+1],R&&e[N].equals(R))continue;X&&(j=X),A&&(z=A),A=e[N],X=R?R.sub(A)._unit()._perp():j,j=j||X;let G=j.add(X);G.x===0&&G.y===0||G._unit();const K=j.x*X.x+j.y*X.y,te=G.x*X.x+G.y*X.y,me=te!==0?1/te:1/0,Ie=2*Math.sqrt(2-2*te),Se=te<M_&&z&&R,Ce=j.x*X.y-j.y*X.x>0;if(Se&&N>w){const Me=A.dist(z);if(Me>2*S){const be=A.sub(A.sub(z)._mult(S/Me)._round());this.updateDistance(z,be),this.addCurrentVertex(be,j,0,0,M),z=be}}const Ve=z&&R;let ze=Ve?s:y?"butt":o;if(Ve&&ze==="round"&&(me<h?ze="miter":me<=2&&(ze="fakeround")),ze==="miter"&&me>u&&(ze="bevel"),ze==="bevel"&&(me>2&&(ze="flipbevel"),me<u&&(ze="miter")),z&&this.updateDistance(z,A),ze==="miter")G._mult(me),this.addCurrentVertex(A,G,0,0,M);else if(ze==="flipbevel"){if(me>100)G=X.mult(-1);else{const Me=me*j.add(X).mag()/j.sub(X).mag();G._perp()._mult(Me*(Ce?-1:1))}this.addCurrentVertex(A,G,0,0,M),this.addCurrentVertex(A,G.mult(-1),0,0,M)}else if(ze==="bevel"||ze==="fakeround"){const Me=-Math.sqrt(me*me-1),be=Ce?Me:0,He=Ce?0:Me;if(z&&this.addCurrentVertex(A,j,be,He,M),ze==="fakeround"){const $e=Math.round(180*Ie/Math.PI/20);for(let Ke=1;Ke<$e;Ke++){let Ge=Ke/$e;if(Ge!==.5){const Ot=Ge-.5;Ge+=Ge*Ot*(Ge-1)*((1.0904+K*(K*(3.55645-1.43519*K)-3.2452))*Ot*Ot+(.848013+K*(.215638*K-1.06021)))}const it=X.sub(j)._mult(Ge)._add(j)._unit()._mult(Ce?-1:1);this.addHalfVertex(A,it.x,it.y,!1,Ce,0,M)}}R&&this.addCurrentVertex(A,X,-be,-He,M)}else if(ze==="butt")this.addCurrentVertex(A,G,0,0,M);else if(ze==="square"){const Me=z?1:-1;this.addCurrentVertex(A,G,Me,Me,M)}else ze==="round"&&(z&&(this.addCurrentVertex(A,j,0,0,M),this.addCurrentVertex(A,j,1,1,M,!0)),R&&(this.addCurrentVertex(A,X,-1,-1,M,!0),this.addCurrentVertex(A,X,0,0,M)));if(Se&&N<v-1){const Me=A.dist(R);if(Me>2*S){const be=A.add(R.sub(A)._mult(S/Me)._round());this.updateDistance(A,be),this.addCurrentVertex(be,X,0,0,M),A=be}}}}addCurrentVertex(e,i,s,o,u,h=!1){const f=i.y*o-i.x,g=-i.y-i.x*o;this.addHalfVertex(e,i.x+i.y*s,i.y-i.x*s,h,!1,s,u),this.addHalfVertex(e,f,g,h,!0,-o,u),this.distance>kp/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,i,s,o,u,h))}addHalfVertex({x:e,y:i},s,o,u,h,f,g){const y=.5*(this.lineClips?this.scaledDistance*(kp-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(u?1:0),(i<<1)+(h?1:0),Math.round(63*s)+128,Math.round(63*o)+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 v=g.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,v,this.e2),g.primitiveLength++),h?this.e2=v:this.e1=v}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,o){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},v={dasharray:h.value.evaluate({zoom:s+1},i,{}),round:f},w=`${g.dasharray.join(",")},${g.round}`,S=`${y.dasharray.join(",")},${y.round}`,M=`${v.dasharray.join(",")},${v.round}`;o.dashDependencies[w]=g,o.dashDependencies[S]=y,o.dashDependencies[M]=v,i.dashes[u.id]={min:w,mid:S,max:M}}}}let Rp,Fp;Xe("LineBucket",Zh,{omit:["layers","patternFeatures"]});var Lp={get paint(){return Fp=Fp||new Tr({"line-opacity":new nt(ye.paint_line["line-opacity"]),"line-color":new nt(ye.paint_line["line-color"]),"line-translate":new et(ye.paint_line["line-translate"]),"line-translate-anchor":new et(ye.paint_line["line-translate-anchor"]),"line-width":new nt(ye.paint_line["line-width"]),"line-gap-width":new nt(ye.paint_line["line-gap-width"]),"line-offset":new nt(ye.paint_line["line-offset"]),"line-blur":new nt(ye.paint_line["line-blur"]),"line-dasharray":new ba(ye.paint_line["line-dasharray"]),"line-pattern":new ba(ye.paint_line["line-pattern"]),"line-gradient":new wo(ye.paint_line["line-gradient"])})},get layout(){return Rp=Rp||new Tr({"line-cap":new et(ye.layout_line["line-cap"]),"line-join":new nt(ye.layout_line["line-join"]),"line-miter-limit":new et(ye.layout_line["line-miter-limit"]),"line-round-limit":new et(ye.layout_line["line-round-limit"]),"line-sort-key":new nt(ye.layout_line["line-sort-key"])})}};class I_ extends nt{possiblyEvaluate(e,i){return i=new ii(Math.floor(i.zoom),{now:i.now,fadeDuration:i.fadeDuration,zoomHistory:i.zoomHistory,transition:i.transition}),super.possiblyEvaluate(e,i)}evaluate(e,i,s,o){return i=lt({},i,{zoom:Math.floor(i.zoom)}),super.evaluate(e,i,s,o)}}let Cu;class E_ extends Gr{constructor(e,i){super(e,Lp,i),this.gradientVersion=0,Cu||(Cu=new I_(Lp.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 Pn,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 Zh(e)}queryRadius(e){const i=e,s=Bp(zo("line-width",this,i),zo("line-gap-width",this,i)),o=zo("line-offset",this,i);return s/2+Math.abs(o)+Tu(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:i,featureState:s,geometry:o,transform:u,pixelsToTileUnits:h}){const f=Su(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-u.bearingInRadians,h),g=h/2*Bp(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&&(o=(function(v,w){const S=[];for(let M=0;M<v.length;M++){const A=Lg(v[M]),z=[];for(let R=0;R<A.length;R++){const j=A[R],X=A[R-1],N=A[R+1],G=R===0?new le(0,0):j.sub(X)._unit()._perp(),K=R===A.length-1?new le(0,0):N.sub(j)._unit()._perp(),te=G._add(K)._unit(),me=te.x*K.x+te.y*K.y;me!==0&&te._mult(1/me),z.push(te._mult(w)._add(j))}S.push(z)}return S})(o,y*h)),(function(v,w,S){for(let M=0;M<w.length;M++){const A=w[M];if(v.length>=3){for(let z=0;z<A.length;z++)if(Do(v,A[z]))return!0}if(kg(v,A,S))return!0}return!1})(f,o,g)}isTileClipped(){return!0}}function Bp(r,e){return e>0?e+2*r:r}const C_=Ni([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),A_=Ni([{name:"a_projected_pos",components:3,type:"Float32"}],4);Ni([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const D_=Ni([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Ni([{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 Op=Ni([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),z_=Ni([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function k_(r,e,i){return r.sections.forEach((s=>{s.text=(function(o,u,h){const f=u.layout.get("text-transform").evaluate(h,{});return f==="uppercase"?o=o.toLocaleUpperCase():f==="lowercase"&&(o=o.toLocaleLowerCase()),An.applyArabicShaping&&(o=An.applyArabicShaping(o)),o})(s.text,e,i)})),r}Ni([{name:"triangle",components:3,type:"Uint16"}]),Ni([{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"}]),Ni([{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"}]),Ni([{type:"Float32",name:"offsetX"}]),Ni([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Ni([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);var er=24;const sc={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},R_={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},F_={40:!0};function Vp(r,e,i,s,o,u){if("fontStack"in e){const h=i[e.fontStack],f=h&&h[r];return f?f.metrics.advance*e.scale+o:0}{const h=s[e.imageName];return h?h.displaySize[0]*e.scale*er/u+o:0}}function jp(r,e,i,s){const o=Math.pow(r-e,2);return s?r<e?o/2:2*o:o+Math.abs(i)*i}function L_(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 Np(r,e,i,s,o,u){let h=null,f=jp(e,i,o,u);for(const g of s){const y=jp(e-g.x,i,o,u)+g.badness;y<=f&&(h=g,f=y)}return{index:r,x:e,priorBreak:h,badness:f}}function Up(r){return r?Up(r.priorBreak).concat(r.index):[]}class Lo{constructor(e="",i=[],s=[]){this.text=e,this.sections=i,this.sectionIndex=s,this.imageSectionID=null}static fromFeature(e,i){const s=new Lo;for(let o=0;o<e.sections.length;o++){const u=e.sections[o];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 o=e[Symbol.iterator]();let u=o.next();const h=e[Symbol.iterator]();h.next();let f=h.next();for(;!u.done;)i+=!f.done&&Fl(f.value.codePointAt(0))&&!sc[f.value]||!s.premature&&Fl(s.value.codePointAt(0))&&!sc[s.value]||!sc[u.value]?u.value:sc[u.value],s={value:u.value,premature:!1},u=o.next(),f=h.next();return i})(this.text)}hasZeroWidthSpaces(){return this.text.includes("​")}trim(){const e=this.text.match(/^\s*/),i=e?e[0].length:0,s=this.text.match(/\S\s*$/),o=s?s[0].length-1:0;this.text=this.text.substring(i,this.text.length-o),this.sectionIndex=this.sectionIndex.slice(i,this.sectionIndex.length-o)}substring(e,i){const s=[...this.text].slice(e,i).join(""),o=this.sectionIndex.slice(e,i);return new Lo(s,this.sections,o)}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 o=0;o<this.length();o++){const u=this.getSection(o);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 yt("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)):yt("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,o,u){const h=[],f=this.determineAverageLineWidth(e,i,s,o,u),g=this.hasZeroWidthSpaces();let y=0,v=0;const w=this.text[Symbol.iterator]();let S=w.next();const M=this.text[Symbol.iterator]();M.next();let A=M.next();const z=this.text[Symbol.iterator]();z.next(),z.next();let R=z.next();for(;!S.done;){const j=this.getSection(v),X=S.value.codePointAt(0);if(hu(X)||(y+=Vp(X,j,s,o,e,u)),!A.done){const N=ya(X),G=A.value.codePointAt(0);(R_[X]||N||"imageName"in j||!R.done&&F_[G])&&h.push(Np(v+1,y,f,h,L_(X,G,N&&g),!1))}v++,S=w.next(),A=M.next(),R=z.next()}return Up(Np(this.length(),y,f,h,0,!0))}determineAverageLineWidth(e,i,s,o,u){let h=0,f=0;for(const g of this.text){const y=this.getSection(f);h+=Vp(g.codePointAt(0),y,s,o,e,u),f++}return h/Math.max(1,Math.ceil(h/i))}}const $h=4294967296,Gp=1/$h,qp=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");class Au{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 o=this.readVarint(),u=o>>3,h=this.pos;this.type=7&o,e(u,i,this),this.pos===h&&this.skip(o)}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)*$h;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*$h;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,o;return o=i[this.pos++],s=127&o,o<128?s:(o=i[this.pos++],s|=(127&o)<<7,o<128?s:(o=i[this.pos++],s|=(127&o)<<14,o<128?s:(o=i[this.pos++],s|=(127&o)<<21,o<128?s:(o=i[this.pos],s|=(15&o)<<28,(function(u,h,f){const g=f.buf;let y,v;if(v=g[f.pos++],y=(112&v)>>4,v<128||(v=g[f.pos++],y|=(127&v)<<3,v<128)||(v=g[f.pos++],y|=(127&v)<<10,v<128)||(v=g[f.pos++],y|=(127&v)<<17,v<128)||(v=g[f.pos++],y|=(127&v)<<24,v<128)||(v=g[f.pos++],y|=(1&v)<<31,v<128))return Bo(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&&qp?qp.decode(this.buf.subarray(i,e)):(function(s,o,u){let h="",f=o;for(;f<u;){const g=s[f];let y,v,w,S=null,M=g>239?4:g>223?3:g>191?2:1;if(f+M>u)break;M===1?g<128&&(S=g):M===2?(y=s[f+1],(192&y)==128&&(S=(31&g)<<6|63&y,S<=127&&(S=null))):M===3?(y=s[f+1],v=s[f+2],(192&y)==128&&(192&v)==128&&(S=(15&g)<<12|(63&y)<<6|63&v,(S<=2047||S>=55296&&S<=57343)&&(S=null))):M===4&&(y=s[f+1],v=s[f+2],w=s[f+3],(192&y)==128&&(192&v)==128&&(192&w)==128&&(S=(15&g)<<18|(63&y)<<12|(63&v)<<6|63&w,(S<=65535||S>=1114112)&&(S=null))),S===null?(S=65533,M=1):S>65535&&(S-=65536,h+=String.fromCharCode(S>>>10&1023|55296),S=56320|1023&S),h+=String.fromCharCode(S),f+=M}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*Gp),!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*Gp),!0),this.pos+=8}writeVarint(e){(e=+e||0)>268435455||e<0?(function(i,s){let o,u;if(i>=0?(o=i%4294967296|0,u=i/4294967296|0):(o=~(-i%4294967296),u=~(-i/4294967296),4294967295^o?o=o+1|0:(o=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)})(o,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(o,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?(o[h++]=239,o[h++]=191,o[h++]=189):g=f;continue}if(f<56320){o[h++]=239,o[h++]=191,o[h++]=189,g=f;continue}f=g-55296<<10|f-56320|65536,g=null}else g&&(o[h++]=239,o[h++]=191,o[h++]=189,g=null);f<128?o[h++]=f:(f<2048?o[h++]=f>>6|192:(f<65536?o[h++]=f>>12|224:(o[h++]=f>>18|240,o[h++]=f>>12&63|128),o[h++]=f>>6&63|128),o[h++]=63&f|128)}return h})(this.buf,e,this.pos);const s=this.pos-i;s>=128&&Zp(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 o=this.pos-s;o>=128&&Zp(s,o,this),this.pos=s-1,this.writeVarint(o),this.pos+=o}writeMessage(e,i,s){this.writeTag(e,2),this.writeRawMessage(i,s)}writePackedVarint(e,i){i.length&&this.writeMessage(e,B_,i)}writePackedSVarint(e,i){i.length&&this.writeMessage(e,O_,i)}writePackedBoolean(e,i){i.length&&this.writeMessage(e,N_,i)}writePackedFloat(e,i){i.length&&this.writeMessage(e,V_,i)}writePackedDouble(e,i){i.length&&this.writeMessage(e,j_,i)}writePackedFixed32(e,i){i.length&&this.writeMessage(e,U_,i)}writePackedSFixed32(e,i){i.length&&this.writeMessage(e,G_,i)}writePackedFixed64(e,i){i.length&&this.writeMessage(e,q_,i)}writePackedSFixed64(e,i){i.length&&this.writeMessage(e,Z_,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 Bo(r,e,i){return i?4294967296*e+(r>>>0):4294967296*(e>>>0)+(r>>>0)}function Zp(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 o=i.pos-1;o>=r;o--)i.buf[o+s]=i.buf[o]}function B_(r,e){for(let i=0;i<r.length;i++)e.writeVarint(r[i])}function O_(r,e){for(let i=0;i<r.length;i++)e.writeSVarint(r[i])}function V_(r,e){for(let i=0;i<r.length;i++)e.writeFloat(r[i])}function j_(r,e){for(let i=0;i<r.length;i++)e.writeDouble(r[i])}function N_(r,e){for(let i=0;i<r.length;i++)e.writeBoolean(r[i])}function U_(r,e){for(let i=0;i<r.length;i++)e.writeFixed32(r[i])}function G_(r,e){for(let i=0;i<r.length;i++)e.writeSFixed32(r[i])}function q_(r,e){for(let i=0;i<r.length;i++)e.writeFixed64(r[i])}function Z_(r,e){for(let i=0;i<r.length;i++)e.writeSFixed64(r[i])}function $_(r,e,i){r===1&&i.readMessage(W_,e)}function W_(r,e,i){if(r===3){const{id:s,bitmap:o,width:u,height:h,left:f,top:g,advance:y}=i.readMessage(H_,{});e.push({id:s,bitmap:new Xl({width:u+6,height:h+6},o),metrics:{width:u,height:h,left:f,top:g,advance:y}})}}function H_(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 $p(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 o=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),o=Math.max(o,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:o,h:u,fill:e/(o*u)||0}}class Wh{constructor(e,{pixelRatio:i,version:s,stretchX:o,stretchY:u,content:h,textFitWidth:f,textFitHeight:g}){this.paddedRect=e,this.pixelRatio=i,this.stretchX=o,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 Wp{constructor(e,i){const s={},o={};this.haveRenderCallbacks=[];const u=[];this.addImages(e,s,u),this.addImages(i,o,u);const{w:h,h:f}=$p(u),g=new Rr({width:h||1,height:f||1});for(const y in e){const v=e[y],w=s[y].paddedRect;Rr.copy(v.data,g,{x:0,y:0},{x:w.x+1,y:w.y+1},v.data)}for(const y in i){const v=i[y],w=o[y].paddedRect,S=w.x+1,M=w.y+1,A=v.data.width,z=v.data.height;Rr.copy(v.data,g,{x:0,y:0},{x:S,y:M},v.data),Rr.copy(v.data,g,{x:0,y:z-1},{x:S,y:M-1},{width:A,height:1}),Rr.copy(v.data,g,{x:0,y:0},{x:S,y:M+z},{width:A,height:1}),Rr.copy(v.data,g,{x:A-1,y:0},{x:S-1,y:M},{width:1,height:z}),Rr.copy(v.data,g,{x:0,y:0},{x:S+A,y:M},{width:1,height:z})}this.image=g,this.iconPositions=s,this.patternPositions=o}addImages(e,i,s){for(const o in e){const u=e[o],h={x:0,y:0,w:u.data.width+2,h:u.data.height+2};s.push(h),i[o]=new Wh(h,u),u.hasRenderCallback&&this.haveRenderCallbacks.push(o)}}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[o,u]=e.tl;s.update(i.data,void 0,{x:o,y:u})}}var Fs;function Du(r,e,i,s,o,u,h,f,g,y,v,w,S,M,A){const z=Lo.fromFeature(r,o);let R;w===P.az.vertical&&z.verticalizePunctuation();let j=z.determineLineBreaks(y,u,e,s,M);const{processBidirectionalText:X,processStyledBidirectionalText:N}=An;if(X&&z.sections.length===1){R=[],j=j.map((me=>z.toCodeUnitIndex(me)));const te=X(z.toString(),j);for(const me of te){const Ie=[...me].map((()=>0));R.push(new Lo(me,z.sections,Ie))}}else if(N){R=[],j=j.map((Se=>z.toCodeUnitIndex(Se)));let te=0;const me=[];for(const Se of z.text)me.push(...Array(Se.length).fill(z.sectionIndex[te])),te++;const Ie=N(z.text,me,j);for(const Se of Ie){const Ce=[];let Ve="";for(const ze of Se[0])Ce.push(Se[1][Ve.length]),Ve+=ze;R.push(new Lo(Se[0],z.sections,Ce))}}else R=(function(te,me){const Ie=[];let Se=0;for(const Ce of me)Ie.push(te.substring(Se,Ce)),Se=Ce;return Se<te.length()&&Ie.push(te.substring(Se,te.length())),Ie})(z,j);const G=[],K={positionedLines:G,text:z.toString(),top:v[1],bottom:v[1],left:v[0],right:v[0],writingMode:w,iconsInText:!1,verticalizable:!1};return(function(te,me,Ie,Se,Ce,Ve,ze,Me,be,He,$e,Ke){let Ge=0,it=0,Ot=0,At=0;const Si=Me==="right"?1:Me==="left"?0:.5,pr=er/Ke;let Hi=0;for(const Zt of Ce){Zt.trim();const Li=Zt.getMaxScale(),Gi={positionedGlyphs:[],lineOffset:0};te.positionedLines[Hi]=Gi;const di=Gi.positionedGlyphs;let Fr=0;if(!Zt.length()){it+=Ve,++Hi;continue}const fr=X_(Se,Zt,pr);let Lr=0;for(const rr of Zt.text){const Ci=Zt.getSection(Lr),Xi=rr.codePointAt(0),Bi=Y_(be,$e,Xi),nr={glyph:Xi,imageName:null,x:Ge,y:it+-17,vertical:Bi,scale:1,fontStack:"",sectionIndex:Zt.getSectionIndex(Lr),metrics:null,rect:null};let ss;if("fontStack"in Ci){if(ss=K_(Ci,Xi,Bi,fr,me,Ie),!ss)continue;nr.fontStack=Ci.fontStack}else{if(te.iconsInText=!0,Ci.scale*=pr,ss=J_(Ci,Bi,Li,fr,Se),!ss)continue;Fr=Math.max(Fr,ss.imageOffset),nr.imageName=Ci.imageName}const{rect:xn,metrics:dc,baselineOffset:js}=ss;nr.y+=js,nr.scale=Ci.scale,nr.metrics=dc,nr.rect=xn,di.push(nr),Bi?(te.verticalizable=!0,Ge+=("imageName"in Ci?dc.advance:er)*Ci.scale+He):Ge+=dc.advance*Ci.scale+He,Lr++}di.length!==0&&(Ot=Math.max(Ge-He,Ot),Q_(di,0,di.length-1,Si)),Ge=0,Gi.lineOffset=Math.max(Fr,(Li-1)*er);const hn=Ve*Li+Fr;it+=hn,At=Math.max(hn,At),++Hi}const{horizontalAlign:Pi,verticalAlign:yi}=Hh(ze);(function(Zt,Li,Gi,di,Fr,fr,Lr,hn,rr){const Ci=(Li-Gi)*Fr;let Xi=0;Xi=fr!==Lr?-hn*di- -17:-di*rr*Lr+.5*Lr;for(const Bi of Zt)for(const nr of Bi.positionedGlyphs)nr.x+=Ci,nr.y+=Xi})(te.positionedLines,Si,Pi,yi,Ot,At,Ve,it,Ce.length),te.top+=-yi*it,te.bottom=te.top+it,te.left+=-Pi*Ot,te.right=te.left+Ot})(K,e,i,s,R,h,f,g,w,y,S,A),!(function(te){for(const me of te)if(me.positionedGlyphs.length!==0)return!1;return!0})(G)&&K}function Hh(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 X_(r,e,i){const s=e.getMaxScale()*er,{maxImageWidth:o,maxImageHeight:u}=e.getMaxImageSize(r),h=Math.max(s,u*i);return{verticalLineContentWidth:Math.max(s,o*i),horizontalLineContentHeight:h}}function Hp(r){switch(r){case"top":return 0;case"center":return .5;default:return 1}}function Y_(r,e,i){return!(r===P.az.horizontal||!e&&!Rl(i)||e&&(hu(i)||(s=i,new RegExp("\\p{sc=Arab}","u").test(String.fromCodePoint(s)))));var s}function K_(r,e,i,s,o,u){const h=u[r.fontStack],f=(function(y,v,w,S){if(y&&y.rect)return y;const M=v[w.fontStack],A=M&&M[S];return A?{rect:null,metrics:A.metrics}:null})(h&&h[e],o,r,e);if(f===null)return null;let g;if(i)g=s.verticalLineContentWidth-r.scale*er;else{const y=Hp(r.verticalAlign);g=(s.horizontalLineContentHeight-r.scale*er)*y}return{rect:f.rect,metrics:f.metrics,baselineOffset:g}}function J_(r,e,i,s,o){const u=o[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 v=Hp(r.verticalAlign);y=(s.horizontalLineContentHeight-f[1]*r.scale)*v}return{rect:h,metrics:g,baselineOffset:y,imageOffset:(e?f[0]:f[1])*r.scale-er*i}}function Q_(r,e,i,s){if(s===0)return;const o=r[i],u=(r[i].x+o.metrics.advance*o.scale)*s;for(let h=e;h<=i;h++)r[h].x-=u}function ey(r,e,i){const{horizontalAlign:s,verticalAlign:o}=Hh(i),u=e[0]-r.displaySize[0]*s,h=e[1]-r.displaySize[1]*o;return{image:r,top:h,bottom:h+r.displaySize[1],left:u,right:u+r.displaySize[0]}}function Xp(r){var e,i;let s=r.left,o=r.top,u=r.right-s,h=r.bottom-o;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 v=Math.ceil(h*y);s*=v/u,u=v}}else if(f==="proportional"&&g==="stretchOnly"&&y!==0&&u/h>y){const v=Math.ceil(u/y);o*=v/h,h=v}return{x1:s,y1:o,x2:s+u,y2:o+h}}function Yp(r,e,i,s,o,u){const h=r.image;let f;if(h.content){const R=h.content,j=h.pixelRatio||1;f=[R[0]/j,R[1]/j,h.displaySize[0]-R[2]/j,h.displaySize[1]-R[3]/j]}const g=e.left*u,y=e.right*u;let v,w,S,M;i==="width"||i==="both"?(M=o[0]+g-s[3],w=o[0]+y+s[1]):(M=o[0]+(g+y-h.displaySize[0])/2,w=M+h.displaySize[0]);const A=e.top*u,z=e.bottom*u;return i==="height"||i==="both"?(v=o[1]+A-s[0],S=o[1]+z+s[2]):(v=o[1]+(A+z-h.displaySize[1])/2,S=v+h.displaySize[1]),{image:h,top:v,right:w,bottom:S,left:M,collisionPadding:f}}Xe("ImagePosition",Wh),Xe("ImageAtlas",Wp),P.az=void 0,(Fs=P.az||(P.az={}))[Fs.none=0]="none",Fs[Fs.horizontal=1]="horizontal",Fs[Fs.vertical=2]="vertical",Fs[Fs.horizontalOnly=3]="horizontalOnly";const rs=128,Ls=32640;function Kp(r,e){const{expression:i}=e;if(i.kind==="constant")return{kind:"constant",layoutSize:i.evaluate(new ii(r+1))};if(i.kind==="source")return{kind:"source"};{const{zoomStops:s,interpolationType:o}=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:o}:{kind:"camera",minZoom:f,maxZoom:g,minSize:i.evaluate(new ii(f)),maxSize:i.evaluate(new ii(g)),interpolationType:o}}}function Xh(r,e,i){let s="never";const o=r.get(e);return o?s=o:r.get(i)&&(s="always"),s}const ty=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function zu(r,e,i,s,o,u,h,f,g,y,v,w,S){const M=f?Math.min(Ls,Math.round(f[0])):0,A=f?Math.min(Ls,Math.round(f[1])):0;r.emplaceBack(e,i,Math.round(32*s),Math.round(32*o),u,h,(M<<1)+(g?1:0),A,16*y,16*v,256*w,256*S)}function Yh(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 iy(r){for(const e of r.sections)if(fu(e.text))return!0;return!1}class Kh{constructor(e){this.layoutVertexArray=new J,this.indexArray=new ve,this.programConfigurations=e,this.segments=new Ue,this.dynamicLayoutVertexArray=new oe,this.opacityVertexArray=new Te,this.hasVisibleVertices=!1,this.placedSymbolArray=new m}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(e,i,s,o){this.isEmpty()||(s&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,C_.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,i),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,A_.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,ty,!0),this.opacityVertexBuffer.itemSize=1),(s||o)&&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())}}Xe("SymbolBuffers",Kh);class Jh{constructor(e,i,s){this.layoutVertexArray=new e,this.layoutAttributes=i,this.indexArray=new s,this.segments=new Ue,this.collisionVertexArray=new xe}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,D_.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}Xe("CollisionBuffers",Jh);class Oo{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=Kp(this.zoom,i["text-size"]),this.iconSizeData=Kp(this.zoom,i["icon-size"]);const s=this.layers[0].layout,o=s.get("symbol-sort-key"),u=s.get("symbol-z-order");this.canOverlap=Xh(s,"text-overlap","text-allow-overlap")!=="never"||Xh(s,"icon-overlap","icon-allow-overlap")!=="never"||s.get("text-ignore-placement")||s.get("icon-ignore-placement"),this.sortFeaturesByKey=u!=="viewport-y"&&!o.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=>P.az[h]))),this.stateDependentLayerIds=this.layers.filter((h=>h.isStateDependent())).map((h=>h.id)),this.sourceID=e.sourceID}createArrays(){this.text=new Kh(new is(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new Kh(new is(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new b,this.lineVertexArray=new T,this.symbolInstances=new x,this.textAnchorOffsets=new I}calculateGlyphDependencies(e,i,s,o,u){for(const h of e)if(i[h.codePointAt(0)]=!0,(s||o)&&u){const f=sc[h];f&&(i[f.codePointAt(0)]=!0)}}populate(e,i,s){const o=this.layers[0],u=o.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 Pr&&!f.value.value.isEmpty()||f.value.value.toString().length>0)&&(h.value.kind!=="constant"||h.value.value.length>0),v=g.value.kind!=="constant"||!!g.value.value||Object.keys(g.parameters).length>0,w=u.get("symbol-sort-key");if(this.features=[],!y&&!v)return;const S=i.iconDependencies,M=i.glyphDependencies,A=i.availableImages,z=new ii(this.zoom);for(const{feature:R,id:j,index:X,sourceLayerIndex:N}of e){const G=o._featureFilter.needGeometry,K=Rn(R,G);if(!o._featureFilter.filter(z,K,s))continue;let te,me;if(G||(K.geometry=kn(R)),y){const Se=o.getValueAndResolveTokens("text-field",K,s,A),Ce=Pr.factory(Se),Ve=this.hasRTLText=this.hasRTLText||iy(Ce);(!Ve||An.getRTLTextPluginStatus()==="unavailable"||Ve&&An.isParsed())&&(te=k_(Ce,o,K))}if(v){const Se=o.getValueAndResolveTokens("icon-image",K,s,A);me=Se instanceof zr?Se:zr.fromString(Se)}if(!te&&!me)continue;const Ie=this.sortFeaturesByKey?w.evaluate(K,{},s):void 0;if(this.features.push({id:j,text:te,icon:me,index:X,sourceLayerIndex:N,geometry:K.geometry,properties:R.properties,type:ic.types[R.type],sortKey:Ie}),me&&(S[me.name]=!0),te){const Se=h.evaluate(K,{},s).join(","),Ce=u.get("text-rotation-alignment")!=="viewport"&&u.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(P.az.vertical)>=0;for(const Ve of te.sections)if(Ve.image)S[Ve.image.name]=!0;else{const ze=ks(te.toString()),Me=Ve.fontStack||Se,be=M[Me]=M[Me]||{};this.calculateGlyphDependencies(Ve.text,be,Ce,this.allowVerticalPlacement,ze)}}}u.get("symbol-placement")==="line"&&(this.features=(function(R){const j={},X={},N=[];let G=0;function K(Se){N.push(R[Se]),G++}function te(Se,Ce,Ve){const ze=X[Se];return delete X[Se],X[Ce]=ze,N[ze].geometry[0].pop(),N[ze].geometry[0]=N[ze].geometry[0].concat(Ve[0]),ze}function me(Se,Ce,Ve){const ze=j[Ce];return delete j[Ce],j[Se]=ze,N[ze].geometry[0].shift(),N[ze].geometry[0]=Ve[0].concat(N[ze].geometry[0]),ze}function Ie(Se,Ce,Ve){const ze=Ve?Ce[0][Ce[0].length-1]:Ce[0][0];return`${Se}:${ze.x}:${ze.y}`}for(let Se=0;Se<R.length;Se++){const Ce=R[Se],Ve=Ce.geometry,ze=Ce.text?Ce.text.toString():null;if(!ze){K(Se);continue}const Me=Ie(ze,Ve),be=Ie(ze,Ve,!0);if(Me in X&&be in j&&X[Me]!==j[be]){const He=me(Me,be,Ve),$e=te(Me,be,N[He].geometry);delete j[Me],delete X[be],X[Ie(ze,N[$e].geometry,!0)]=$e,N[He].geometry=null}else Me in X?te(Me,be,Ve):be in j?me(Me,be,Ve):(K(Se),j[Me]=G-1,X[be]=G-1)}return N.filter((Se=>Se.geometry))})(this.features)),this.sortFeaturesByKey&&this.features.sort(((R,j)=>R.sortKey-j.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 o=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:o},f<i.length-1&&(o+=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,o,u,h,f,g,y,v,w,S){const M=e.indexArray,A=e.layoutVertexArray,z=e.segments.prepareSegment(4*i.length,A,M,this.canOverlap?h.sortKey:void 0),R=this.glyphOffsetArray.length,j=z.vertexLength,X=this.allowVerticalPlacement&&f===P.az.vertical?Math.PI/2:0,N=h.text&&h.text.sections;for(let G=0;G<i.length;G++){const{tl:K,tr:te,bl:me,br:Ie,tex:Se,pixelOffsetTL:Ce,pixelOffsetBR:Ve,minFontScaleX:ze,minFontScaleY:Me,glyphOffset:be,isSDF:He,sectionIndex:$e}=i[G],Ke=z.vertexLength,Ge=be[1];zu(A,g.x,g.y,K.x,Ge+K.y,Se.x,Se.y,s,He,Ce.x,Ce.y,ze,Me),zu(A,g.x,g.y,te.x,Ge+te.y,Se.x+Se.w,Se.y,s,He,Ve.x,Ce.y,ze,Me),zu(A,g.x,g.y,me.x,Ge+me.y,Se.x,Se.y+Se.h,s,He,Ce.x,Ve.y,ze,Me),zu(A,g.x,g.y,Ie.x,Ge+Ie.y,Se.x+Se.w,Se.y+Se.h,s,He,Ve.x,Ve.y,ze,Me),Yh(e.dynamicLayoutVertexArray,g,X),M.emplaceBack(Ke,Ke+2,Ke+1),M.emplaceBack(Ke+1,Ke+2,Ke+3),z.vertexLength+=4,z.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(be[0]),G!==i.length-1&&$e===i[G+1].sectionIndex||e.programConfigurations.populatePaintArrays(A.length,h,h.index,{imagePositions:{},canonical:S,formattedSection:N&&N[$e]})}e.placedSymbolArray.emplaceBack(g.x,g.y,R,this.glyphOffsetArray.length-R,j,y,v,g.segment,s?s[0]:0,s?s[1]:0,o[0],o[1],f,0,!1,0,w)}_addCollisionDebugVertex(e,i,s,o,u,h){return i.emplaceBack(0,0),e.emplaceBack(s.x,s.y,o,u,Math.round(h.x),Math.round(h.y))}addCollisionDebugVertices(e,i,s,o,u,h,f){const g=u.segments.prepareSegment(4,u.layoutVertexArray,u.indexArray),y=g.vertexLength,v=u.layoutVertexArray,w=u.collisionVertexArray,S=f.anchorX,M=f.anchorY;this._addCollisionDebugVertex(v,w,h,S,M,new le(e,i)),this._addCollisionDebugVertex(v,w,h,S,M,new le(s,i)),this._addCollisionDebugVertex(v,w,h,S,M,new le(s,o)),this._addCollisionDebugVertex(v,w,h,S,M,new le(e,o)),g.vertexLength+=4;const A=u.indexArray;A.emplaceBack(y,y+1),A.emplaceBack(y+1,y+2),A.emplaceBack(y+2,y+3),A.emplaceBack(y+3,y),g.primitiveLength+=4}addDebugCollisionBoxes(e,i,s,o){for(let u=e;u<i;u++){const h=this.collisionBoxArray.get(u);this.addCollisionDebugVertices(h.x1,h.y1,h.x2,h.y2,o?this.textCollisionBox:this.iconCollisionBox,h.anchorPoint,s)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Jh(_e,Op.members,Fe),this.iconCollisionBox=new Jh(_e,Op.members,Fe);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,o,u,h,f,g,y){const v={};for(let w=i;w<s;w++){const S=e.get(w);v.textBox={x1:S.x1,y1:S.y1,x2:S.x2,y2:S.y2,anchorPointX:S.anchorPointX,anchorPointY:S.anchorPointY},v.textFeatureIndex=S.featureIndex;break}for(let w=o;w<u;w++){const S=e.get(w);v.verticalTextBox={x1:S.x1,y1:S.y1,x2:S.x2,y2:S.y2,anchorPointX:S.anchorPointX,anchorPointY:S.anchorPointY},v.verticalTextFeatureIndex=S.featureIndex;break}for(let w=h;w<f;w++){const S=e.get(w);v.iconBox={x1:S.x1,y1:S.y1,x2:S.x2,y2:S.y2,anchorPointX:S.anchorPointX,anchorPointY:S.anchorPointY},v.iconFeatureIndex=S.featureIndex;break}for(let w=g;w<y;w++){const S=e.get(w);v.verticalIconBox={x1:S.x1,y1:S.y1,x2:S.x2,y2:S.y2,anchorPointX:S.anchorPointX,anchorPointY:S.anchorPointY},v.verticalIconFeatureIndex=S.featureIndex;break}return v}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),o=s.vertexStartIndex+4*s.numGlyphs;for(let u=s.vertexStartIndex;u<o;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),o=[],u=[],h=[];for(let f=0;f<this.symbolInstances.length;++f){h.push(f);const g=this.symbolInstances.get(f);o.push(0|Math.round(i*g.anchorX+s*g.anchorY)),u.push(g.featureIndex)}return h.sort(((f,g)=>o[f]-o[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(((o,u,h)=>{o>=0&&h.indexOf(o)===u&&this.addIndicesForPlacedSymbol(this.text,o)})),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 Jp,Qp;Xe("SymbolBucket",Oo,{omit:["layers","collisionBoxArray","features","compareText"]}),Oo.MAX_GLYPHS=65535,Oo.addDynamicAttributes=Yh;var Qh={get paint(){return Qp=Qp||new Tr({"icon-opacity":new nt(ye.paint_symbol["icon-opacity"]),"icon-color":new nt(ye.paint_symbol["icon-color"]),"icon-halo-color":new nt(ye.paint_symbol["icon-halo-color"]),"icon-halo-width":new nt(ye.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nt(ye.paint_symbol["icon-halo-blur"]),"icon-translate":new et(ye.paint_symbol["icon-translate"]),"icon-translate-anchor":new et(ye.paint_symbol["icon-translate-anchor"]),"text-opacity":new nt(ye.paint_symbol["text-opacity"]),"text-color":new nt(ye.paint_symbol["text-color"],{runtimeType:Dr,getOverride:r=>r.textColor,hasOverride:r=>!!r.textColor}),"text-halo-color":new nt(ye.paint_symbol["text-halo-color"]),"text-halo-width":new nt(ye.paint_symbol["text-halo-width"]),"text-halo-blur":new nt(ye.paint_symbol["text-halo-blur"]),"text-translate":new et(ye.paint_symbol["text-translate"]),"text-translate-anchor":new et(ye.paint_symbol["text-translate-anchor"])})},get layout(){return Jp=Jp||new Tr({"symbol-placement":new et(ye.layout_symbol["symbol-placement"]),"symbol-spacing":new et(ye.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new et(ye.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nt(ye.layout_symbol["symbol-sort-key"]),"symbol-z-order":new et(ye.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new et(ye.layout_symbol["icon-allow-overlap"]),"icon-overlap":new et(ye.layout_symbol["icon-overlap"]),"icon-ignore-placement":new et(ye.layout_symbol["icon-ignore-placement"]),"icon-optional":new et(ye.layout_symbol["icon-optional"]),"icon-rotation-alignment":new et(ye.layout_symbol["icon-rotation-alignment"]),"icon-size":new nt(ye.layout_symbol["icon-size"]),"icon-text-fit":new et(ye.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new et(ye.layout_symbol["icon-text-fit-padding"]),"icon-image":new nt(ye.layout_symbol["icon-image"]),"icon-rotate":new nt(ye.layout_symbol["icon-rotate"]),"icon-padding":new nt(ye.layout_symbol["icon-padding"]),"icon-keep-upright":new et(ye.layout_symbol["icon-keep-upright"]),"icon-offset":new nt(ye.layout_symbol["icon-offset"]),"icon-anchor":new nt(ye.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new et(ye.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new et(ye.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new et(ye.layout_symbol["text-rotation-alignment"]),"text-field":new nt(ye.layout_symbol["text-field"]),"text-font":new nt(ye.layout_symbol["text-font"]),"text-size":new nt(ye.layout_symbol["text-size"]),"text-max-width":new nt(ye.layout_symbol["text-max-width"]),"text-line-height":new et(ye.layout_symbol["text-line-height"]),"text-letter-spacing":new nt(ye.layout_symbol["text-letter-spacing"]),"text-justify":new nt(ye.layout_symbol["text-justify"]),"text-radial-offset":new nt(ye.layout_symbol["text-radial-offset"]),"text-variable-anchor":new et(ye.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new nt(ye.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new nt(ye.layout_symbol["text-anchor"]),"text-max-angle":new et(ye.layout_symbol["text-max-angle"]),"text-writing-mode":new et(ye.layout_symbol["text-writing-mode"]),"text-rotate":new nt(ye.layout_symbol["text-rotate"]),"text-padding":new et(ye.layout_symbol["text-padding"]),"text-keep-upright":new et(ye.layout_symbol["text-keep-upright"]),"text-transform":new nt(ye.layout_symbol["text-transform"]),"text-offset":new nt(ye.layout_symbol["text-offset"]),"text-allow-overlap":new et(ye.layout_symbol["text-allow-overlap"]),"text-overlap":new et(ye.layout_symbol["text-overlap"]),"text-ignore-placement":new et(ye.layout_symbol["text-ignore-placement"]),"text-optional":new et(ye.layout_symbol["text-optional"])})}};class ef{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:Vr,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}}Xe("FormatSectionOverride",ef,{omit:["defaultValue"]});class ku extends Gr{constructor(e,i){super(e,Qh,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 o=[];for(const u of s)o.indexOf(u)<0&&o.push(u);this.layout._values["text-writing-mode"]=o}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,i,s,o){const u=this.layout.get(e).evaluate(i,{},s,o),h=this._unevaluatedLayout._values[e];return h.isDataDriven()||Es(h.value)||!u?u:(function(f,g){return g.replace(/{([^{}]+)}/g,((y,v)=>f&&v in f?String(f[v]):""))})(i.properties,u)}createBucket(e){return new Oo(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of Qh.paint.overridableProperties){if(!ku.hasPaintOverride(this.layout,e))continue;const i=this.paint.get(e),s=new ef(i),o=new wl(s,i.property.specification);let u=null;u=i.value.kind==="constant"||i.value.kind==="source"?new lo("source",o):new Tl("composite",o,i.value.zoomStops),this.paint._values[e]=new Qr(i.property,u,i.parameters)}}_handleOverridablePaintPropertyUpdate(e,i,s){return!(!this.layout||i.isDataDriven()||s.isDataDriven())&&ku.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,i){const s=e.get("text-field"),o=Qh.paint.properties[i];let u=!1;const h=f=>{for(const g of f)if(o.overrides&&o.overrides.hasOverride(g))return void(u=!0)};if(s.value.kind==="constant"&&s.value.value instanceof Pr)h(s.value.value.sections);else if(s.value.kind==="source"||s.value.kind==="composite"){const f=y=>{u||(y instanceof on&&Vi(y.value)===qs?h(y.value.sections):y instanceof ea?h(y.sections):y.eachChild(f))},g=s.value;g._styleExpression&&f(g._styleExpression.expression)}return u}}let tf;var ry={get paint(){return tf=tf||new Tr({"background-color":new et(ye.paint_background["background-color"]),"background-pattern":new bo(ye.paint_background["background-pattern"]),"background-opacity":new et(ye.paint_background["background-opacity"])})}};class ny extends Gr{constructor(e,i){super(e,ry,i)}}class sy extends Gr{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 ay{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 oy={once:!0},ed=63710088e-1;class Bs{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 Bs(mi(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,o=e.lat*i,u=Math.sin(s)*Math.sin(o)+Math.cos(s)*Math.cos(o)*Math.cos((e.lng-this.lng)*i);return ed*Math.acos(Math.min(u,1))}static convert(e){if(e instanceof Bs)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new Bs(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new Bs(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 rf=2*Math.PI*ed;function nf(r){return rf*Math.cos(r*Math.PI/180)}function sf(r){return(180+r)/360}function af(r){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+r*Math.PI/360)))/360}function of(r,e){return r/nf(e)}function lf(r){return 360*r-180}function Ru(r){return 360/Math.PI*Math.atan(Math.exp((180-360*r)*Math.PI/180))-90}function cf(r,e){return r*nf(Ru(e))}class ac{constructor(e,i,s=0){this.x=+e,this.y=+i,this.z=+s}static fromLngLat(e,i=0){const s=Bs.convert(e);return new ac(sf(s.lng),af(s.lat),of(i,s.lat))}toLngLat(){return new Bs(lf(this.x),Ru(this.y))}toAltitude(){return cf(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/rf*(e=Ru(this.y),1/Math.cos(e*Math.PI/180));var e}}function uf(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 td{constructor(e,i,s){if(!(function(o,u,h){return!(o<0||o>25||h<0||h>=Math.pow(2,o)||u<0||u>=Math.pow(2,o))})(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=Vo(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 o=(function(h,f,g){var y=uf(256*h,256*(f=Math.pow(2,g)-f-1),g),v=uf(256*(h+1),256*(f+1),g);return y[0]+","+y[1]+","+v[0]+","+v[1]})(this.x,this.y,this.z),u=(function(h,f,g){let y,v="";for(let w=h;w>0;w--)y=1<<w-1,v+=(f&y?1:0)+(g&y?2:0);return v})(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,u).replace(/{bbox-epsg-3857}/g,o)}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 le((e.x*i-this.x)*Ze,(e.y*i-this.y)*Ze)}toString(){return`${this.z}/${this.x}/${this.y}`}}class hf{constructor(e,i){this.wrap=e,this.canonical=i,this.key=Vo(e,i.z,i.z,i.x,i.y)}}class rn{constructor(e,i,s,o,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 td(s,+o,+u),this.key=Vo(i,e,s,o,u)}clone(){return new rn(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 rn(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new rn(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?Vo(this.wrap*+i,e,this.canonical.z,this.canonical.x,this.canonical.y):Vo(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 rn(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,o=2*this.canonical.y;return[new rn(i,this.wrap,i,s,o),new rn(i,this.wrap,i,s+1,o),new rn(i,this.wrap,i,s,o+1),new rn(i,this.wrap,i,s+1,o+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 rn(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new rn(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 hf(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(e){return this.canonical.getTilePoint(new ac(e.x-this.wrap,e.y))}}function Vo(r,e,i,s,o){(r*=2)<0&&(r=-1*r-1);const u=1<<i;return(u*u*r+u*o+s).toString(36)+i.toString(36)+e.toString(36)}function id(r,e){return e?r.properties[e]:r.id}function ly(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 o=r.addOrUpdateProperties.findIndex((u=>u.key===s));o>-1&&r.addOrUpdateProperties.splice(o,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 df(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((o=>[o.id,o]))),s.update=new Map((i=r.update)===null||i===void 0?void 0:i.map((o=>[o.id,o]))),s}Xe("CanonicalTileID",td),Xe("OverscaledTileID",rn,{omit:["terrainRttPosMatrix32f"]});class Da{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 Da;return i.extend(e(new le(this.minX,this.minY))),i.extend(e(new le(this.maxX,this.minY))),i.extend(e(new le(this.minX,this.maxY))),i.extend(e(new le(this.maxX,this.maxY))),i}static fromPoints(e){const i=new Da;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 pf{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 ff{constructor(e,i,s,o,u){this.type="Feature",this._vectorTileFeature=e,this._x=s,this._y=o,this._z=i,this.properties=e.properties,this.id=u}projectPoint(e,i,s,o){return[360*(e.x+i)/o-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+s)/o)*Math.PI))-90]}projectLine(e,i,s,o){return e.map((u=>this.projectPoint(u,i,s,o)))}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,o=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,o,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,o,i)));this._geometry=h.length===1?{type:"LineString",coordinates:h[0]}:{type:"MultiLineString",coordinates:h};break}case 3:{const h=Ep(u),f=[];for(const g of h)f.push(g.map((y=>this.projectLine(y,s,o,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 jo{constructor(e,i,s){vt(this,"_name");vt(this,"dataBuffer");vt(this,"nullabilityBuffer");vt(this,"_size");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 Fu extends jo{}class rd extends Fu{getValueFromBuffer(e){return this.dataBuffer[e]}}class nd extends Fu{getValueFromBuffer(e){return this.dataBuffer[e]}}class mf extends jo{constructor(i,s,o,u){super(i,s,u);vt(this,"delta");this.delta=o}}class sd extends mf{constructor(e,i,s,o){super(e,Int32Array.of(i),s,o)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}}class ad extends jo{constructor(e,i,s){super(e,Int32Array.of(i),s)}getValueFromBuffer(e){return this.dataBuffer[0]}}class cy{constructor(e,i,s,o,u=4096){vt(this,"_name");vt(this,"_geometryVector");vt(this,"_idVector");vt(this,"_propertyVectors");vt(this,"_extent");vt(this,"propertyVectorsMap");this._name=e,this._geometryVector=i,this._idVector=s,this._propertyVectors=o,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 o=e==null?void 0: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:o,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 o;this.idVector&&(o=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:o,geometry:u,properties:h})}return e}containsMaxSaveIntegerValues(e){return e instanceof rd||e instanceof ad&&e instanceof sd||e instanceof nd}}class uy{constructor(e){vt(this,"value");this.value=e}get(){return this.value}set(e){this.value=e}increment(){return this.value++}add(e){this.value+=e}}var Dt,ns,hr,_n,za,Zr,tr,ir,gf,nn;function lr(r,e,i){const s=new Int32Array(i);let o=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[o++]=g}return e.set(u),s}function Lu(r,e,i){const s=new BigInt64Array(i);for(let o=0;o<s.length;o++)s[o]=dy(r,e);return s}function hy(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(o,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+(o>>>0);throw new Error("Expected varint not more than 10 bytes")})(i,r,e)))))}function _f(r,e,i,s){throw new Error("FastPFor is not implemented yet.")}function ka(r){return r>>>1^-(1&r)}function No(r){return r>>1n^-(1n&r)}function dy(r,e){let i=0n,s=0,o=e.get();for(;o<r.length;){const u=r[o++];if(i|=BigInt(127&u)<<BigInt(s),!(128&u))break;if(s+=7,s>=64)throw new Error("Varint too long")}return e.set(o),i}function yf(r,e,i){const s=new Int32Array(i);let o=0;for(let u=0;u<e;u++){const h=r[u];s.fill(r[u+e],o,o+h),o+=h}return s}function xf(r,e,i){const s=new BigInt64Array(i);let o=0;for(let u=0;u<e;u++){const h=Number(r[u]);s.fill(r[u+e],o,o+h),o+=h}return s}function vf(r,e,i){const s=new Float64Array(i);let o=0;for(let u=0;u<e;u++){const h=r[u];s.fill(r[u+e],o,o+h),o+=h}return s}function od(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 bf(r){r[0]=r[0]>>>1^-(1&r[0]),r[1]=r[1]>>>1^-(1&r[1]);const e=r.length/4*4;let i=2;if(e>=4)for(;i<e-4;i+=4){const s=r[i],o=r[i+1],u=r[i+2],h=r[i+3];r[i]=(s>>>1^-(1&s))+r[i-2],r[i+1]=(o>>>1^-(1&o))+r[i-1],r[i+2]=(u>>>1^-(1&u))+r[i],r[i+3]=(h>>>1^-(1&h))+r[i+1]}for(;i!=r.length;i+=2)r[i]=(r[i]>>>1^-(1&r[i]))+r[i-2],r[i+1]=(r[i+1]>>>1^-(1&r[i+1]))+r[i-1]}(function(r){r.NONE="NONE",r.DELTA="DELTA",r.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",r.RLE="RLE",r.MORTON="MORTON",r.PDE="PDE"})(Dt||(Dt={})),(function(r){r.NONE="NONE",r.FAST_PFOR="FAST_PFOR",r.VARINT="VARINT",r.ALP="ALP"})(ns||(ns={})),(function(r){r.PRESENT="PRESENT",r.DATA="DATA",r.OFFSET="OFFSET",r.LENGTH="LENGTH"})(hr||(hr={}));class ld{constructor(e,i,s){vt(this,"_dictionaryType");vt(this,"_offsetType");vt(this,"_lengthType");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 Er(r,e){const i=(function(s,o){const u=s[o.get()],h=Object.values(hr)[u>>4];let f=null;switch(h){case hr.DATA:f=new ld(Object.values(_n)[15&u]);break;case hr.OFFSET:f=new ld(null,Object.values(za)[15&u]);break;case hr.LENGTH:f=new ld(null,null,Object.values(Zr)[15&u])}o.increment();const g=s[o.get()],y=Object.values(Dt)[g>>5],v=Object.values(Dt)[g>>2&7],w=Object.values(ns)[3&g];o.increment();const S=lr(s,o,2),M=S[0];return{physicalStreamType:h,logicalStreamType:f,logicalLevelTechnique1:y,logicalLevelTechnique2:v,physicalLevelTechnique:w,numValues:M,byteLength:S[1],decompressedCount:M}})(r,e);return i.logicalLevelTechnique1===Dt.MORTON?(function(s,o,u){const h=lr(o,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):Dt.RLE!==i.logicalLevelTechnique1&&Dt.RLE!==i.logicalLevelTechnique2||ns.NONE===i.physicalLevelTechnique?i:(function(s,o,u){const h=lr(o,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"})(_n||(_n={})),(function(r){r.VERTEX="VERTEX",r.INDEX="INDEX",r.STRING="STRING",r.KEY="KEY"})(za||(za={})),(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"})(Zr||(Zr={})),(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"})(tr||(tr={}));class yn{constructor(e,i){vt(this,"values");vt(this,"_size");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 Cr(r,e,i,s,o){return(function(u,h,f){switch(h.logicalLevelTechnique1){case Dt.DELTA:return h.logicalLevelTechnique2===Dt.RLE?(function(g,y,v){const w=new Int32Array(v);let S=0,M=0;for(let A=0;A<y;A++){const z=g[A],R=ka(g[A+y]);for(let j=0;j<z;j++)M+=R,w[S++]=M}return w})(u,h.runs,h.numRleValues):((function(g){g[0]=g[0]>>>1^-(1&g[0]);const y=g.length/4*4;let v=1;if(y>=4)for(;v<y-4;v+=4){const w=g[v],S=g[v+1],M=g[v+2],A=g[v+3];g[v]=(w>>>1^-(1&w))+g[v-1],g[v+1]=(S>>>1^-(1&S))+g[v],g[v+2]=(M>>>1^-(1&M))+g[v+1],g[v+3]=(A>>>1^-(1&A))+g[v+2]}for(;v!=g.length;++v)g[v]=(g[v]>>>1^-(1&g[v]))+g[v-1]})(u),u);case Dt.RLE:return(function(g,y,v){return v?(function(w,S,M){const A=new Int32Array(M);let z=0;for(let R=0;R<S;R++){const j=w[R];let X=w[R+S];X=X>>>1^-(1&X),A.fill(X,z,z+j),z+=j}return A})(g,y.runs,y.numRleValues):yf(g,y.runs,y.numRleValues)})(u,h,f);case Dt.MORTON:return od(u),u;case Dt.COMPONENTWISE_DELTA:return bf(u),u;case Dt.NONE:return f&&(function(g){for(let y=0;y<g.length;y++){const v=g[y];g[y]=v>>>1^-(1&v)}})(u),u;default:throw new Error(`The specified Logical level technique is not supported: ${h.logicalLevelTechnique1}`)}})(Bu(r,e,i),i,s)}function Os(r,e,i){return(function(s,o){if(o.logicalLevelTechnique1===Dt.DELTA&&o.logicalLevelTechnique2===Dt.NONE)return(function(h){const f=new Int32Array(h.length+1);f[0]=0,f[1]=ka(h[0]);let g=f[1],y=2;for(;y!=f.length;++y){const v=h[y-1];g+=v>>>1^-(1&v),f[y]=f[y-1]+g}return f})(s);if(o.logicalLevelTechnique1===Dt.RLE&&o.logicalLevelTechnique2===Dt.NONE)return(function(h,f,g){const y=new Int32Array(g+1);y[0]=0;let v=1,w=y[0];for(let S=0;S<f;S++){const M=h[S],A=h[S+f];for(let z=v;z<v+M;z++)y[z]=A+w,w=y[z];v+=M}return y})(s,o.runs,o.numRleValues);if(o.logicalLevelTechnique1===Dt.NONE&&o.logicalLevelTechnique2===Dt.NONE){(function(h){let f=0;for(let g=0;g<h.length;g++)h[g]+=f,f=h[g]})(s);const u=new Int32Array(o.numValues+1);return u[0]=0,u.set(s,1),u}if(o.logicalLevelTechnique1===Dt.DELTA&&o.logicalLevelTechnique2===Dt.RLE){const u=(function(h,f,g){const y=new Int32Array(g+1);y[0]=0;let v=1,w=y[0];for(let S=0;S<f;S++){const M=h[S];let A=h[S+f];A=A>>>1^-(1&A);for(let z=v;z<v+M;z++)y[z]=A+w,w=y[z];v+=M}return y})(s,o.runs,o.numRleValues);return od(u),u}throw new Error("Only delta encoding is supported for transforming length to offset streams yet.")})(Bu(r,e,i),i)}function Bu(r,e,i){const s=i.physicalLevelTechnique;if(s===ns.FAST_PFOR)return _f();if(s===ns.VARINT)return lr(r,e,i.numValues);if(s===ns.NONE){const o=e.get();e.add(i.byteLength);const u=r.subarray(o,e.get());return new Int32Array(u)}throw new Error("Specified physicalLevelTechnique is not supported (yet).")}function cd(r,e,i,s){const o=Bu(r,e,i);if(o.length===1){const u=o[0];return s?ka(u):u}return s?(function(u){return ka(u[1])})(o):(function(u){return u[1]})(o)}function wf(r,e,i){return(function(s){if(s.length==2){const o=ka(s[1]);return[o,o]}return[ka(s[2]),ka(s[3])]})(Bu(r,e,i))}function Tf(r,e,i){return(function(s){if(s.length==2){const o=No(s[1]);return[o,o]}return[No(s[2]),No(s[3])]})(Lu(r,e,i.numValues))}function Sf(r,e,i,s){return(function(o,u,h){switch(u.logicalLevelTechnique1){case Dt.DELTA:return u.logicalLevelTechnique2===Dt.RLE?(function(f,g,y){const v=new BigInt64Array(y);let w=0,S=0n;for(let M=0;M<g;M++){const A=Number(f[M]),z=No(f[M+g]);for(let R=0;R<A;R++)S+=z,v[w++]=S}return v})(o,u.runs,u.numRleValues):((function(f){f[0]=f[0]>>1n^-(1n&f[0]);const g=f.length/4*4;let y=1;if(g>=4)for(;y<g-4;y+=4){const v=f[y],w=f[y+1],S=f[y+2],M=f[y+3];f[y]=(v>>1n^-(1n&v))+f[y-1],f[y+1]=(w>>1n^-(1n&w))+f[y],f[y+2]=(S>>1n^-(1n&S))+f[y+1],f[y+3]=(M>>1n^-(1n&M))+f[y+2]}for(;y!=f.length;++y)f[y]=(f[y]>>1n^-(1n&f[y]))+f[y-1]})(o),o);case Dt.RLE:return(function(f,g,y){return y?(function(v,w,S){const M=new BigInt64Array(S);let A=0;for(let z=0;z<w;z++){const R=Number(v[z]);let j=v[z+w];j=j>>1n^-(1n&j),M.fill(j,A,A+R),A+=R}return M})(f,g.runs,g.numRleValues):xf(f,g.runs,g.numRleValues)})(o,u,h);case Dt.NONE:return h&&(function(f){for(let g=0;g<f.length;g++){const y=f[g];f[g]=y>>1n^-(1n&y)}})(o),o;default:throw new Error(`The specified Logical level technique is not supported: ${u.logicalLevelTechnique1}`)}})(Lu(r,e,i.numValues),i,s)}function Pf(r,e,i,s){const o=Lu(r,e,i.numValues);if(o.length===1){const u=o[0];return s?No(u):u}return s?(function(u){return No(u[1])})(o):(function(u){return u[1]})(o)}function ud(r,e,i,s,o){return(function(u,h,f,g){switch(h.logicalLevelTechnique1){case Dt.DELTA:return h.logicalLevelTechnique2===Dt.RLE&&(u=yf(u,h.runs,h.numRleValues)),(function(y,v){const w=new Int32Array(y.size());let S=0;y.get(0)?(w[0]=y.get(0)?v[0]>>>1^-(1&v[0]):0,S=1):w[0]=0;let M=1;for(;M!=w.length;++M)w[M]=y.get(M)?w[M-1]+(v[S]>>>1^-(1&v[S++])):w[M-1];return w})(g,u);case Dt.RLE:return(function(y,v,w,S){const M=v;return w?(function(A,z,R){const j=new Int32Array(A.size());let X=0;for(let N=0;N<R;N++){const G=z[N];let K=z[N+R];K=K>>>1^-(1&K);for(let te=X;te<X+G;te++)A.get(te)?j[te]=K:(j[te]=0,X++);X+=G}return j})(S,y,M.runs):(function(A,z,R){const j=new Int32Array(A.size());let X=0;for(let N=0;N<R;N++){const G=z[N],K=z[N+R];for(let te=X;te<X+G;te++)A.get(te)?j[te]=K:(j[te]=0,X++);X+=G}return j})(S,y,M.runs)})(u,h,f,g);case Dt.MORTON:return od(u),u;case Dt.COMPONENTWISE_DELTA:return bf(u),u;case Dt.NONE:return u=f?(function(y,v){const w=new Int32Array(y.size());let S=0,M=0;for(;M!=w.length;++M)if(y.get(M)){const A=v[S++];w[M]=A>>>1^-(1&A)}else w[M]=0;return w})(g,u):(function(y,v){const w=new Int32Array(y.size());let S=0,M=0;for(;M!=w.length;++M)w[M]=y.get(M)?v[S++]:0;return w})(g,u),u;default:throw new Error("The specified Logical level technique is not supported")}})(i.physicalLevelTechnique===ns.FAST_PFOR?_f():lr(r,e,i.numValues),i,s,o)}function Ou(r,e,i,s){const o=r.logicalLevelTechnique1;if(o===Dt.RLE)return r.runs===1?tr.CONST:tr.FLAT;const u=e instanceof yn?e.size():e;if(o===Dt.DELTA&&r.logicalLevelTechnique2===Dt.RLE){const h=r.runs,f=2;if(r.numRleValues!==u)return tr.FLAT;if(h===1)return tr.SEQUENCE;if(h===2){const g=s.get();let y;if(r.physicalLevelTechnique===ns.VARINT)y=lr(i,s,4);else{const v=s.get();y=new Int32Array(i.buffer,i.byteOffset+v,4)}if(s.set(g),y[2]===f&&y[3]===f)return tr.SEQUENCE}}return r.numValues===1?tr.CONST:tr.FLAT}class Mf extends Fu{getValueFromBuffer(e){return this.dataBuffer[e]}}class If extends mf{constructor(e,i,s,o){super(e,BigInt64Array.of(i),s,o)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}}class Uo{constructor(e,i,s){vt(this,"_geometryOffsets");vt(this,"_partOffsets");vt(this,"_ringOffsets");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 hd(r,e,i){return{x:Ef(r,e)-i,y:Ef(r>>1,e)-i}}function Ef(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"})(ir||(ir={})),(function(r){r[r.POINT=0]="POINT",r[r.LINESTRING=1]="LINESTRING",r[r.POLYGON=2]="POLYGON"})(gf||(gf={})),(function(r){r[r.MORTON=0]="MORTON",r[r.VEC_2=1]="VEC_2",r[r.VEC_3=2]="VEC_3"})(nn||(nn={}));class py{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 Cf(r){const e=new Array(r.numGeometries);let i=1,s=1,o=1,u=0;const h=new py;let f=0,g=0;const y=r.mortonSettings,v=r.topologyVector,w=v.geometryOffsets,S=v.partOffsets,M=v.ringOffsets,A=r.vertexOffsets,z=r.containsPolygonGeometry(),R=r.vertexBuffer;for(let j=0;j<r.numGeometries;j++){const X=r.geometryType(j);if(X===ir.POINT){if(A&&A.length!==0)if(r.vertexBufferType===nn.VEC_2){const N=2*A[g++],G=new le(R[N],R[N+1]);e[u++]=h.createPoint(G)}else{const N=hd(R[A[g++]],y.numBits,y.coordinateShift),G=new le(N.x,N.y);e[u++]=h.createPoint(G)}else{const N=new le(R[f++],R[f++]);e[u++]=h.createPoint(N)}w&&o++,S&&i++,M&&s++}else if(X===ir.MULTIPOINT){const N=w[o]-w[o-1];o++;const G=new Array(N);if(A&&A.length!==0){for(let K=0;K<N;K++){const te=2*A[g++];G[K]=new le(R[te],R[te+1])}e[u++]=h.createMultiPoint(G)}else{for(let K=0;K<N;K++){const te=R[f++],me=R[f++];G[K]=new le(te,me)}e[u++]=h.createMultiPoint(G)}}else if(X===ir.LINESTRING){let N,G=0;z?(G=M[s]-M[s-1],s++):G=S[i]-S[i-1],i++,A&&A.length!==0?(N=r.vertexBufferType===nn.VEC_2?pd(R,A,g,G,!1):fd(R,A,g,G,!1,y),g+=G):(N=dd(R,f,G,!1),f+=2*G),e[u++]=h.createLineString(N),w&&o++}else if(X===ir.POLYGON){const N=S[i]-S[i-1];i++;const G=new Array(N-1);let K=M[s]-M[s-1];if(s++,A&&A.length!==0){const te=r.vertexBufferType===nn.VEC_2?ju(R,A,g,K):Nu(R,A,g,K,0,y);g+=K;for(let me=0;me<G.length;me++)K=M[s]-M[s-1],s++,G[me]=r.vertexBufferType===nn.VEC_2?ju(R,A,g,K):Nu(R,A,g,K,0,y),g+=K;e[u++]=h.createPolygon(te,G)}else{const te=Vu(R,f,K);f+=2*K;for(let me=0;me<G.length;me++)K=M[s]-M[s-1],s++,G[me]=Vu(R,f,K),f+=2*K;e[u++]=h.createPolygon(te,G)}w&&o++}else if(X===ir.MULTILINESTRING){const N=w[o]-w[o-1];o++;const G=new Array(N);if(A&&A.length!==0){for(let K=0;K<N;K++){let te=0;z?(te=M[s]-M[s-1],s++):te=S[i]-S[i-1],i++;const me=r.vertexBufferType===nn.VEC_2?pd(R,A,g,te,!1):fd(R,A,g,te,!1,y);G[K]=me,g+=te}e[u++]=h.createMultiLineString(G)}else{for(let K=0;K<N;K++){let te=0;z?(te=M[s]-M[s-1],s++):te=S[i]-S[i-1],i++,G[K]=dd(R,f,te,!1),f+=2*te}e[u++]=h.createMultiLineString(G)}}else{if(X!==ir.MULTIPOLYGON)throw new Error("The specified geometry type is currently not supported.");{const N=w[o]-w[o-1];o++;const G=new Array(N);let K=0;if(A&&A.length!==0){for(let te=0;te<N;te++){const me=S[i]-S[i-1];i++;const Ie=new Array(me-1);K=M[s]-M[s-1],s++;const Se=r.vertexBufferType===nn.VEC_2?ju(R,A,g,K):Nu(R,A,g,K,0,y);g+=K;for(let Ce=0;Ce<Ie.length;Ce++)K=M[s]-M[s-1],s++,Ie[Ce]=r.vertexBufferType===nn.VEC_2?ju(R,A,g,K):Nu(R,A,g,K,0,y),g+=K;G[te]=h.createPolygon(Se,Ie)}e[u++]=h.createMultiPolygon(G)}else{for(let te=0;te<N;te++){const me=S[i]-S[i-1];i++;const Ie=new Array(me-1);K=M[s]-M[s-1],s++;const Se=Vu(R,f,K);f+=2*K;for(let Ce=0;Ce<Ie.length;Ce++){const Ve=M[s]-M[s-1];s++,Ie[Ce]=Vu(R,f,Ve),f+=2*Ve}G[te]=h.createPolygon(Se,Ie)}e[u++]=h.createMultiPolygon(G)}}}}return e}function Vu(r,e,i){return dd(r,e,i,!0)}function ju(r,e,i,s){return pd(r,e,i,s,!0)}function Nu(r,e,i,s,o,u){return fd(r,e,i,s,!0,u)}function dd(r,e,i,s){const o=new Array(s?i+1:i);for(let u=0;u<2*i;u+=2)o[u/2]=new le(r[e+u],r[e+u+1]);return s&&(o[o.length-1]=o[0]),o}function pd(r,e,i,s,o){const u=new Array(o?s+1:s);for(let h=0;h<2*s;h+=2){const f=2*e[i+h/2];u[h/2]=new le(r[f],r[f+1])}return o&&(u[u.length-1]=u[0]),u}function fd(r,e,i,s,o,u){const h=new Array(o?s+1:s);for(let f=0;f<s;f++){const g=hd(r[e[i+f]],u.numBits,u.coordinateShift);h[f]=new le(g.x,g.y)}return o&&(h[h.length-1]=h[0]),h}class Af{constructor(e,i,s,o,u){vt(this,"_vertexBufferType");vt(this,"_topologyVector");vt(this,"_vertexOffsets");vt(this,"_vertexBuffer");vt(this,"_mortonSettings");this._vertexBufferType=e,this._topologyVector=i,this._vertexOffsets=s,this._vertexBuffer=o,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=Cf(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=hd(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 Cf(this)}get mortonSettings(){return this._mortonSettings}}class Df extends Af{constructor(i,s,o,u,h,f,g){super(o,u,h,f,g);vt(this,"_numGeometries");vt(this,"_geometryType");this._numGeometries=i,this._geometryType=s}geometryType(i){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===ir.POLYGON||this._geometryType===ir.MULTIPOLYGON}containsSingleGeometryType(){return!0}}class zf extends Af{constructor(i,s,o,u,h,f){super(i,o,u,h,f);vt(this,"_geometryTypes");this._geometryTypes=s}geometryType(i){return this._geometryTypes[i]}get numGeometries(){return this._geometryTypes.length}containsPolygonGeometry(){for(let i=0;i<this.numGeometries;i++)if(this.geometryType(i)===ir.POLYGON||this.geometryType(i)===ir.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}}class kf{constructor(e,i,s,o){vt(this,"_triangleOffsets");vt(this,"_indexBuffer");vt(this,"_vertexBuffer");vt(this,"_topologyVector");this._triangleOffsets=e,this._indexBuffer=i,this._vertexBuffer=s,this._topologyVector=o}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,o=i.ringOffsets,u=i.geometryOffsets;let h=0,f=1,g=1,y=1;for(let v=0;v<this.numGeometries;v++)switch(this.geometryType(v)){case ir.POLYGON:{const w=s[f]-s[f-1];f++;const S=[];for(let M=0;M<w;M++){const A=o[g]-o[g-1];g++;const z=[];for(let R=0;R<A;R++){const j=this._vertexBuffer[h++],X=this._vertexBuffer[h++];z.push(new le(j,X))}z.length>0&&z.push(z[0]),S.push(z)}e[v]=S,u&&y++}break;case ir.MULTIPOLYGON:{const w=u[y]-u[y-1];y++;const S=[];for(let M=0;M<w;M++){const A=s[f]-s[f-1];f++;for(let z=0;z<A;z++){const R=o[g]-o[g-1];g++;const j=[];for(let X=0;X<R;X++){const N=this._vertexBuffer[h++],G=this._vertexBuffer[h++];j.push(new le(N,G))}j.length>0&&j.push(j[0]),S.push(j)}}e[v]=S}}return e}[Symbol.iterator](){return null}}function Rf(r,e,i,s,o,u){return new fy(r,e,i,s,o,u)}class fy extends kf{constructor(i,s,o,u,h,f){super(o,u,h,f);vt(this,"_numGeometries");vt(this,"_geometryType");this._numGeometries=i,this._geometryType=s}geometryType(i){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}}function Ff(r,e,i,s,o){return new my(r,e,i,s,o)}class my extends kf{constructor(i,s,o,u,h){super(s,o,u,h);vt(this,"_geometryTypes");this._geometryTypes=i}geometryType(i){return this._geometryTypes[i]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}}function gy(r,e,i,s,o){const u=Er(r,i);let h=null,f=null,g=null,y=null,v=null,w=null,S=null,M=null;if(Ou(u,s,r,i)===tr.CONST){const z=cd(r,i,u,!1);for(let R=0;R<e-1;R++){const j=Er(r,i);switch(j.physicalStreamType){case hr.LENGTH:switch(j.logicalStreamType.lengthType){case Zr.GEOMETRIES:h=Os(r,i,j);break;case Zr.PARTS:f=Os(r,i,j);break;case Zr.RINGS:g=Os(r,i,j);break;case Zr.TRIANGLES:S=Os(r,i,j)}break;case hr.OFFSET:switch(j.logicalStreamType.offsetType){case za.VERTEX:y=Cr(r,i,j,!1);break;case za.INDEX:M=Cr(r,i,j,!1)}break;case hr.DATA:_n.VERTEX===j.logicalStreamType.dictionaryType?v=Cr(r,i,j,!0):(w={numBits:j.numBits,coordinateShift:j.coordinateShift},v=Cr(r,i,j,!1))}}return M!==null?h!=null||f!=null?Rf(s,z,S,M,v,new Uo(h,f,g)):Rf(s,z,S,M,v):w===null?(function(R,j,X,N,G){return new Df(R,j,nn.VEC_2,X,N,G)})(s,z,new Uo(h,f,g),y,v):(function(R,j,X,N,G,K){return new Df(R,j,nn.MORTON,X,N,G,K)})(s,z,new Uo(h,f,g),y,v,w)}const A=Cr(r,i,u,!1);for(let z=0;z<e-1;z++){const R=Er(r,i);switch(R.physicalStreamType){case hr.LENGTH:switch(R.logicalStreamType.lengthType){case Zr.GEOMETRIES:h=Cr(r,i,R,!1);break;case Zr.PARTS:f=Cr(r,i,R,!1);break;case Zr.RINGS:g=Cr(r,i,R,!1);break;case Zr.TRIANGLES:S=Os(r,i,R)}break;case hr.OFFSET:switch(R.logicalStreamType.offsetType){case za.VERTEX:y=Cr(r,i,R,!1);break;case za.INDEX:M=Cr(r,i,R,!1)}break;case hr.DATA:_n.VERTEX===R.logicalStreamType.dictionaryType?v=Cr(r,i,R,!0):(w={numBits:R.numBits,coordinateShift:R.coordinateShift},v=Cr(r,i,R,!1))}}return M!==null&&f===null?Ff(A,S,M,v):(h!==null?(h=md(A,h,2),f!==null&&g!==null?(f=Lf(A,h,f,!1),g=(function(z,R,j,X){const N=new Int32Array(j[j.length-1]+1);let G=0;N[0]=G;let K=1,te=1,me=0;for(let Ie=0;Ie<z.length;Ie++){const Se=z[Ie],Ce=R[Ie+1]-R[Ie];if(Se!==0&&Se!==3)for(let Ve=0;Ve<Ce;Ve++){const ze=j[K]-j[K-1];K++;for(let Me=0;Me<ze;Me++)G=N[te++]=G+X[me++]}else for(let Ve=0;Ve<Ce;Ve++)N[te++]=++G,K++}return N})(A,h,f,g)):f!==null&&(f=(function(z,R,j){const X=new Int32Array(R[R.length-1]+1);let N=0;X[0]=N;let G=1,K=0;for(let te=0;te<z.length;te++){const me=z[te],Ie=R[te+1]-R[te];if(me===4||me===1)for(let Se=0;Se<Ie;Se++)N=X[G++]=N+j[K++];else for(let Se=0;Se<Ie;Se++)X[G++]=++N}return X})(A,h,f))):f!==null&&g!==null?(f=md(A,f,1),g=Lf(A,f,g,!0)):f!==null&&(f=md(A,f,0)),M!==null?Ff(A,S,M,v,new Uo(h,f,g)):w===null?(function(z,R,j,X){return new zf(nn.VEC_2,z,R,j,X)})(A,new Uo(h,f,g),y,v):(function(z,R,j,X,N){return new zf(nn.MORTON,z,R,j,X,N)})(A,new Uo(h,f,g),y,v,w))}function md(r,e,i){const s=new Int32Array(r.length+1);let o=0;s[0]=o;let u=0;for(let h=0;h<r.length;h++)o=s[h+1]=o+(r[h]>i?e[u++]:1);return s}function Lf(r,e,i,s){const o=new Int32Array(e[e.length-1]+1);let u=0;o[0]=u;let h=1,f=0;for(let g=0;g<r.length;g++){const y=r[g],v=e[g+1]-e[g];if(y===5||y===2||s&&(y===4||y===1))for(let w=0;w<v;w++)u=o[h++]=u+i[f++];else for(let w=0;w<v;w++)o[h++]=++u}return o}class _y extends jo{constructor(i,s,o){super(i,s.getBuffer(),o);vt(this,"dataVector");this.dataVector=s}getValueFromBuffer(i){return this.dataVector.get(i)}}class yy extends Fu{getValueFromBuffer(e){return this.dataBuffer[e]}}class Bf extends jo{constructor(e,i,s){super(e,BigInt64Array.of(i),s)}getValueFromBuffer(e){return this.dataBuffer[0]}}function oc(r,e,i){return Of(r,Math.ceil(e/8),i)}function Of(r,e,i){const s=new Uint8Array(e);let o=0;for(;o<e;){const u=r[i.increment()];if(u<=127){const h=u+3,f=r[i.increment()],g=o+h;s.fill(f,o,g),o=g}else{const h=256-u;for(let f=0;f<h;f++)s[o++]=r[i.increment()]}}return s}const xy=new TextDecoder;function gd(r,e,i){return i-e>=12?xy.decode(r.subarray(e,i)):(function(s,o,u){let h="",f=o;for(;f<u;){const g=s[f];let y,v,w,S=null,M=g>239?4:g>223?3:g>191?2:1;if(f+M>u)break;M===1?g<128&&(S=g):M===2?(y=s[f+1],(192&y)==128&&(S=(31&g)<<6|63&y,S<=127&&(S=null))):M===3?(y=s[f+1],v=s[f+2],(192&y)==128&&(192&v)==128&&(S=(15&g)<<12|(63&y)<<6|63&v,(S<=2047||S>=55296&&S<=57343)&&(S=null))):M===4&&(y=s[f+1],v=s[f+2],w=s[f+3],(192&y)==128&&(192&v)==128&&(192&w)==128&&(S=(15&g)<<18|(63&y)<<12|(63&v)<<6|63&w,(S<=65535||S>=1114112)&&(S=null))),S===null?(S=65533,M=1):S>65535&&(S-=65536,h+=String.fromCharCode(S>>>10&1023|55296),S=56320|1023&S),h+=String.fromCharCode(S),f+=M}return h})(r,e,i)}class _d extends jo{constructor(i,s,o,u){super(i,o,u);vt(this,"offsetBuffer");this.offsetBuffer=s}}class Vf extends _d{constructor(i,s,o,u){super(i,s,o,u??s.length-1);vt(this,"textEncoder");this.textEncoder=new TextEncoder}getValueFromBuffer(i){return gd(this.dataBuffer,this.offsetBuffer[i],this.offsetBuffer[i+1])}}class Go extends _d{constructor(i,s,o,u,h){super(i,o,u,h??s.length);vt(this,"indexBuffer");vt(this,"textEncoder");this.indexBuffer=s,this.indexBuffer=s,this.textEncoder=new TextEncoder}getValueFromBuffer(i){const s=this.indexBuffer[i];return gd(this.dataBuffer,this.offsetBuffer[s],this.offsetBuffer[s+1])}}class jf extends _d{constructor(i,s,o,u,h,f,g){super(i,o,u,g);vt(this,"indexBuffer");vt(this,"symbolOffsetBuffer");vt(this,"symbolTableBuffer");vt(this,"textEncoder");vt(this,"symbolLengthBuffer");vt(this,"lengthBuffer");vt(this,"decodedDictionary");this.indexBuffer=s,this.symbolOffsetBuffer=h,this.symbolTableBuffer=f,this.textEncoder=new TextEncoder}getValueFromBuffer(i){this.decodedDictionary==null&&(this.symbolLengthBuffer==null&&(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer),this.lengthBuffer=this.offsetToLengthBuffer(this.offsetBuffer)),this.decodedDictionary=(function(o,u,h){const f=[],g=new Array(u.length).fill(0);for(let y=1;y<u.length;y++)g[y]=g[y-1]+u[y-1];for(let y=0;y<h.length;y++)if(h[y]===255)f.push(h[++y]);else{const v=u[h[y]],w=g[h[y]];for(let S=0;S<v;S++)f.push(o[w+S])}return new Uint8Array(f)})(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer));const s=this.indexBuffer[i];return gd(this.decodedDictionary,this.offsetBuffer[s],this.offsetBuffer[s+1])}offsetToLengthBuffer(i){const s=new Uint32Array(i.length-1);let o=i[0];for(let u=1;u<i.length;u++){const h=i[u];s[u-1]=h-o,o=h}return s}}function vy(r,e,i,s,o,u){return i.type==="scalarType"?(function(h,f,g,y,v,w){let S=null,M=0;if(h===0)return null;if(w.nullable){const z=Er(f,g);M=z.numValues;const R=g.get(),j=oc(f,M,g);g.set(R+z.byteLength),S=new yn(j,z.numValues)}const A=S??y;switch(v.physicalType){case 4:case 3:return(function(z,R,j,X,N){const G=Er(z,R),K=Ou(G,N,z,R),te=X.physicalType===3;if(K===tr.FLAT){const me=lc(N)?ud(z,R,G,te,N):Cr(z,R,G,te);return new rd(j.name,me,N)}if(K===tr.SEQUENCE){const me=wf(z,R,G);return new sd(j.name,me[0],me[1],G.numRleValues)}{const me=cd(z,R,G,te);return new ad(j.name,me,N)}})(f,g,w,v,A);case 9:return(function(z,R,j,X,N){let G=null,K=null,te=null,me=null,Ie=null,Se=null,Ce=null,Ve=null;for(let ze=0;ze<X;ze++){const Me=Er(R,j);if(Me.byteLength!==0)switch(Me.physicalStreamType){case hr.PRESENT:{const be=oc(R,Me.numValues,j);Se=new yn(be,Me.numValues);break}case hr.OFFSET:K=N!=null||Se!=null?ud(R,j,Me,!1,N??Se):Cr(R,j,Me,!1);break;case hr.LENGTH:{const be=Os(R,j,Me);Zr.DICTIONARY===Me.logicalStreamType.lengthType?G=be:Zr.SYMBOL===Me.logicalStreamType.lengthType?me=be:Ce=be;break}case hr.DATA:{const be=R.subarray(j.get(),j.get()+Me.byteLength);j.add(Me.byteLength);const He=Me.logicalStreamType.dictionaryType;_n.FSST===He?Ie=be:_n.SINGLE===He||_n.SHARED===He?te=be:_n.NONE===He&&(Ve=be);break}}}return(function(ze,Me,be,He,$e,Ke,Ge){return Me?new jf(ze,be,He,$e,Ke,Me,Ge):null})(z,Ie,K,G,te,me,N??Se)??(function(ze,Me,be,He,$e){return Me?$e?new Go(ze,be,He,Me,$e):new Go(ze,be,He,Me):null})(z,te,K,G,N??Se)??(function(ze,Me,be,He,$e){if(!Me||!be)return null;if(He)return $e?new Go(ze,He,Me,be,$e):new Go(ze,He,Me,be);if($e&&$e.size()!==Me.length-1){const Ke=new Int32Array($e.size());let Ge=0;for(let it=0;it<$e.size();it++)Ke[it]=$e.get(it)?Ge++:0;return new Go(ze,Ke,Me,be,$e)}return $e?new Vf(ze,Me,be,$e):new Vf(ze,Me,be)})(z,Ce,Ve,K,N??Se)})(w.name,f,g,w.nullable?h-1:h,S);case 0:return(function(z,R,j,X,N){const G=Er(z,R),K=G.numValues,te=R.get(),me=lc(N)?(function(Se,Ce,Ve,ze){const Me=Of(Se,Math.ceil(Ce/8),Ve),be=new yn(Me,Ce),He=ze.size(),$e=new yn(new Uint8Array(He),He);let Ke=0;for(let Ge=0;Ge<ze.size();Ge++){const it=!!ze.get(Ge)&&be.get(Ke++);$e.set(Ge,it)}return $e.getBuffer()})(z,K,R,N):oc(z,K,R);R.set(te+G.byteLength);const Ie=new yn(me,K);return new _y(j.name,Ie,N)})(f,g,w,0,A);case 6:case 5:return(function(z,R,j,X,N){const G=Er(z,R),K=Ou(G,X,z,R),te=N.physicalType===5;if(K===tr.FLAT){const me=lc(X)?(function(Ie,Se,Ce,Ve,ze){return(function(Me,be,He,$e){switch(be.logicalLevelTechnique1){case Dt.DELTA:return be.logicalLevelTechnique2===Dt.RLE&&(Me=xf(Me,be.runs,be.numRleValues)),(function(Ke,Ge){const it=new BigInt64Array(Ke.size());let Ot=0;Ke.get(0)?(it[0]=Ke.get(0)?Ge[0]>>1n^-(1n&Ge[0]):0n,Ot=1):it[0]=0n;let At=1;for(;At!=it.length;++At)it[At]=Ke.get(At)?it[At-1]+(Ge[Ot]>>1n^-(1n&Ge[Ot++])):it[At-1];return it})($e,Me);case Dt.RLE:return(function(Ke,Ge,it,Ot){const At=Ge;return it?(function(Si,pr,Hi){const Pi=new BigInt64Array(Si.size());let yi=0;for(let Zt=0;Zt<Hi;Zt++){const Li=Number(pr[Zt]);let Gi=pr[Zt+Hi];Gi=Gi>>1n^-(1n&Gi);for(let di=yi;di<yi+Li;di++)Si.get(di)?Pi[di]=Gi:(Pi[di]=0n,yi++);yi+=Li}return Pi})(Ot,Ke,At.runs):(function(Si,pr,Hi){const Pi=new BigInt64Array(Si.size());let yi=0;for(let Zt=0;Zt<Hi;Zt++){const Li=Number(pr[Zt]),Gi=pr[Zt+Hi];for(let di=yi;di<yi+Li;di++)Si.get(di)?Pi[di]=Gi:(Pi[di]=0n,yi++);yi+=Li}return Pi})(Ot,Ke,At.runs)})(Me,be,He,$e);case Dt.NONE:return Me=He?(function(Ke,Ge){const it=new BigInt64Array(Ke.size());let Ot=0,At=0;for(;At!=it.length;++At)if(Ke.get(At)){const Si=Ge[Ot++];it[At]=Si>>1n^-(1n&Si)}else it[At]=0n;return it})($e,Me):(function(Ke,Ge){const it=new BigInt64Array(Ke.size());let Ot=0,At=0;for(;At!=it.length;++At)it[At]=Ke.get(At)?Ge[Ot++]:0n;return it})($e,Me),Me;default:throw new Error("The specified Logical level technique is not supported")}})(Lu(Ie,Se,Ce.numValues),Ce,Ve,ze)})(z,R,G,te,X):Sf(z,R,G,te);return new Mf(j.name,me,X)}if(K===tr.SEQUENCE){const me=Tf(z,R,G);return new If(j.name,me[0],me[1],G.numRleValues)}{const me=Pf(z,R,G,te);return new Bf(j.name,me,X)}})(f,g,w,A,v);case 7:return(function(z,R,j,X){const N=Er(z,R),G=lc(X)?(function(K,te,me,Ie){const Se=te.get(),Ce=Se+Ie*Float32Array.BYTES_PER_ELEMENT,Ve=new Uint8Array(K.subarray(Se,Ce)).buffer,ze=new Float32Array(Ve);te.set(Ce);const Me=me.size(),be=new Float32Array(Me);let He=0;for(let $e=0;$e<Me;$e++)be[$e]=me.get($e)?ze[He++]:0;return be})(z,R,X,N.numValues):(function(K,te,me){const Ie=te.get(),Se=Ie+me*Float32Array.BYTES_PER_ELEMENT,Ce=new Uint8Array(K.subarray(Ie,Se)).buffer,Ve=new Float32Array(Ce);return te.set(Se),Ve})(z,R,N.numValues);return new yy(j.name,G,X)})(f,g,w,A);case 8:return(function(z,R,j,X){const N=Er(z,R),G=lc(X)?(function(K,te,me,Ie){const Se=te.get(),Ce=Se+Ie*Float64Array.BYTES_PER_ELEMENT,Ve=new Uint8Array(K.subarray(Se,Ce)).buffer,ze=new Float64Array(Ve);te.set(Ce);const Me=me.size(),be=new Float64Array(Me);let He=0;for(let $e=0;$e<Me;$e++)be[$e]=me.get($e)?ze[He++]:0;return be})(z,R,X,N.numValues):(function(K,te,me){const Ie=te.get(),Se=Ie+me*Float64Array.BYTES_PER_ELEMENT,Ce=new Uint8Array(K.subarray(Ie,Se)).buffer,Ve=new Float64Array(Ce);return te.set(Se),Ve})(z,R,N.numValues);return new nd(j.name,G,X)})(f,g,w,A);default:throw new Error(`The specified data type for the field is currently not supported: ${v}`)}})(s,r,e,o,i.scalarType,i):s!=1?null:(function(h,f,g,y){let v=null,w=null,S=null,M=null,A=!1;for(;!A;){const X=Er(h,f);switch(X.physicalStreamType){case hr.LENGTH:Zr.DICTIONARY===X.logicalStreamType.lengthType?v=Os(h,f,X):S=Os(h,f,X);break;case hr.DATA:_n.SINGLE===X.logicalStreamType.dictionaryType||_n.SHARED===X.logicalStreamType.dictionaryType?(w=h.subarray(f.get(),f.get()+X.byteLength),A=!0):M=h.subarray(f.get(),f.get()+X.byteLength),f.add(X.byteLength)}}const z=g.complexType.children,R=[];let j=0;for(const X of z){const N=lr(h,f,1)[0];if(N==0)continue;const G=`${g.name}${X.name==="default"?"":":"+X.name}`;if(N!==2||X.type!=="scalarField"||X.scalarField.physicalType!==9)throw new Error("Currently only optional string fields are implemented for a struct.");const K=Er(h,f),te=oc(h,K.numValues,f),me=Er(h,f),Ie=me.decompressedCount!==y?ud(h,f,me,!1,new yn(te,K.numValues)):Cr(h,f,me,!1);R[j++]=M?new jf(G,Ie,v,w,S,M,new yn(te,K.numValues)):new Go(G,Ie,v,w,new yn(te,K.numValues))}return R})(r,e,i,o)}function lc(r){return r instanceof yn}function by(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 wy=new TextDecoder;function Nf(r,e){const i=lr(r,e,1)[0];if(i===0)return"";const s=e.get(),o=r.subarray(s,s+i);return e.add(i),wy.decode(o)}function Uf(r,e){const i=lr(r,e,1)[0]>>>0,s=!!(4&i),o=!!(2&i),u=lr(r,e,1)[0]>>>0,h={};if(1&i&&(h.nullable=!0),o){const f={};if(s?(f.type="logicalType",f.logicalType=u):(f.type="physicalType",f.physicalType=u),8&i){const g=lr(r,e,1)[0]>>>0;f.children=new Array(g);for(let y=0;y<g;y++)f.children[y]=Uf(r,e)}h.type="complexField",h.complexField=f}else{const f={};s?(f.type="logicalType",f.logicalType=u):(f.type="physicalType",f.physicalType=u),h.type="scalarField",h.scalarField=f}return h}function Ty(r,e){const i=lr(r,e,1)[0]>>>0,s=(function(o){switch(o){case 0:case 1:case 2:case 3:{const u={};u.nullable=!!(1&o),u.columnScope=0;const h={};return h.physicalType=o>1?6:4,h.type="physicalType",u.scalarType=h,u.type="scalarType",u}case 4:{const u={nullable:!1,columnScope:0},h={type:"physicalType",physicalType:0};return u.type="complexType",u.complexType=h,u}case 30:{const u={nullable:!1,columnScope:0},h={type:"physicalType",physicalType:1};return u.type="complexType",u.complexType=h,u}default:return(function(u){let h=null;switch(u){case 10:case 11:h=0;break;case 12:case 13:h=1;break;case 14:case 15:h=2;break;case 16:case 17:h=3;break;case 18:case 19:h=4;break;case 20:case 21:h=5;break;case 22:case 23:h=6;break;case 24:case 25:h=7;break;case 26:case 27:h=8;break;case 28:case 29:h=9;break;default:return null}const f={};f.nullable=!!(1&u),f.columnScope=0;const g={type:"physicalType"};return g.physicalType=h,f.type="scalarType",f.scalarType=g,f})(o)}})(i);if(!s)throw new Error(`Unsupported column type code: ${i}`);if((function(o){return o>=10})(i)?s.name=Nf(r,e):i>=0&&i<=3?s.name="id":i===4&&(s.name="geometry"),(function(o){return o===30})(i)){const o=lr(r,e,1)[0]>>>0,u=s.complexType;u.children=new Array(o);for(let h=0;h<o;h++)u.children[h]=Uf(r,e)}return s}function Sy(r,e){const i={featureTables:[]},s={};s.name=Nf(r,e);const o=lr(r,e,1)[0]>>>0,u=lr(r,e,1)[0]>>>0;s.columns=new Array(u);for(let h=0;h<u;h++)s.columns[h]=Ty(r,e);return i.featureTables.push(s),[i,o]}function Py(r,e,i,s,o,u,h=!1){const f=e.scalarType.physicalType,g=Ou(o,u,r,i);if(f===4)switch(g){case tr.FLAT:{const y=Cr(r,i,o,!1);return new rd(s,y,u)}case tr.SEQUENCE:{const y=wf(r,i,o);return new sd(s,y[0],y[1],o.numRleValues)}case tr.CONST:{const y=cd(r,i,o,!1);return new ad(s,y,u)}}else switch(g){case tr.FLAT:{if(h){const v=(function(w,S,M,A){const z=(function(R,j,X){const N=new Float64Array(j);for(let G=0;G<j;G++)N[G]=hy(R,X);return N})(w,M.numValues,S);return(function(R,j,X){switch(j.logicalLevelTechnique1){case Dt.DELTA:return j.logicalLevelTechnique2===Dt.RLE&&(R=vf(R,j.runs,j.numRleValues)),(function(N){N[0]=N[0]%2==1?(N[0]+1)/-2:N[0]/2;const G=N.length/4*4;let K=1;if(G>=4)for(;K<G-4;K+=4){const te=N[K],me=N[K+1],Ie=N[K+2],Se=N[K+3];N[K]=(te%2==1?(te+1)/-2:te/2)+N[K-1],N[K+1]=(me%2==1?(me+1)/-2:me/2)+N[K],N[K+2]=(Ie%2==1?(Ie+1)/-2:Ie/2)+N[K+1],N[K+3]=(Se%2==1?(Se+1)/-2:Se/2)+N[K+2]}for(;K!=N.length;++K)N[K]=(N[K]%2==1?(N[K]+1)/-2:N[K]/2)+N[K-1]})(R),R;case Dt.RLE:return(function(N,G,K){return vf(N,G.runs,G.numRleValues)})(R,j);case Dt.NONE:return R;default:throw new Error(`The specified Logical level technique is not supported: ${j.logicalLevelTechnique1}`)}})(z,M)})(r,i,o);return new nd(s,v,u)}const y=Sf(r,i,o,!1);return new Mf(s,y,u)}case tr.SEQUENCE:{const y=Tf(r,i,o);return new If(s,y[0],y[1],o.numRleValues)}case tr.CONST:{const y=Pf(r,i,o,!1);return new Bf(s,y,u)}}throw new Error("Vector type not supported for id column.")}class My{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 ir.POINT:case ir.MULTIPOINT:this.type=1;break;case ir.LINESTRING:case ir.MULTILINESTRING:this.type=2;break;case ir.POLYGON:case ir.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 o of i)s.push(new le(o.x,o.y));e.push(s)}return e}}class Iy{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 My(this.features[e],this.extent)}}class Gf{constructor(e){this.layers={};const i=(function(s,o,u=!0){const h=new uy(0),f=[];for(;h.get()<s.length;){const g=lr(s,h,1)[0]>>>0,y=h.get()+g;if(y>s.length)throw new Error(`Block overruns tile: ${y} > ${s.length}`);if(lr(s,h,1)[0]>>>0!=1){h.set(y);continue}const v=Sy(s,h),w=v[1],S=v[0].featureTables[0];let M=null,A=null;const z=[];let R=0;for(const X of S.columns){const N=X.name;if(N==="id"){let G=null;if(X.nullable){const te=Er(s,h),me=h.get(),Ie=oc(s,te.numValues,h);h.set(me+te.byteLength),G=new yn(Ie,te.numValues)}const K=Er(s,h);R=K.decompressedCount,M=Py(s,X,h,N,K,G??R,u)}else if(N==="geometry"){const G=lr(s,h,1)[0];if(R===0){const K=h.get();R=Er(s,h).decompressedCount,h.set(K)}A=gy(s,G,h,R)}else{const G=by(X)?lr(s,h,1)[0]:1;if(G===0&&X.type==="scalarType")continue;const K=vy(s,h,X,G,R);if(K)if(Array.isArray(K))for(const te of K)z.push(te);else z.push(K)}}const j=new cy(S.name,A,M,z,w);f.push(j),h.set(y)}return f})(new Uint8Array(e));this.layers=i.reduce(((s,o)=>Object.assign(Object.assign({},s),{[o.name]:new Iy(o)})),{})}}class Ey{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 o=[];for(const u of s)o.push(new le(u[0],u[1]));e.push(o)}return e}}const cc="_geojsonTileLayer";function Cy(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,Ay,i);const s=i.keys;for(const u of s)e.writeStringField(3,u);const o=i.values;for(const u of o)e.writeMessage(4,ky,u)}function Ay(r,e){if(!r.feature)return;const i=r.feature;i.id!==void 0&&e.writeVarintField(1,i.id),e.writeMessage(2,Dy,r),e.writeVarintField(3,i.type),e.writeMessage(4,zy,i)}function Dy(r,e){var i;for(const s in(i=r.feature)==null?void 0:i.properties){let o=r.feature.properties[s],u=r.keycache[s];if(o==null)continue;u===void 0&&(r.keys.push(s),u=r.keys.length-1,r.keycache[s]=u),e.writeVarint(u),typeof o!="string"&&typeof o!="boolean"&&typeof o!="number"&&(o=JSON.stringify(o));const h=typeof o+":"+o;let f=r.valuecache[h];f===void 0&&(r.values.push(o),f=r.values.length-1,r.valuecache[h]=f),e.writeVarint(f)}}function yd(r,e){return(e<<3)+(7&r)}function qf(r){return r<<1^r>>31}function zy(r,e){const i=r.loadGeometry(),s=r.type;let o=0,u=0;for(const h of i){let f=1;s===1&&(f=h.length),e.writeVarint(yd(1,f));const g=s===3?h.length-1:h.length;for(let y=0;y<g;y++){y===1&&s!==1&&e.writeVarint(yd(2,g-1));const v=h[y].x-o,w=h[y].y-u;e.writeVarint(qf(v)),e.writeVarint(qf(w)),o+=v,u+=w}r.type===3&&e.writeVarint(yd(7,1))}}function ky(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 Zf{constructor(e,i){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new Ds(Ze,16,0),this.grid3D=new Ds(Ze,16,0),this.featureIndexArray=new V,this.promoteId=i}insert(e,i,s,o,u,h){const f=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(s,o,u);const g=h?this.grid3D:this.grid;for(let y=0;y<i.length;y++){const v=i[y],w=[1/0,1/0,-1/0,-1/0];for(let S=0;S<v.length;S++){const M=v[S];w[0]=Math.min(w[0],M.x),w[1]=Math.min(w[1],M.y),w[2]=Math.max(w[2],M.x),w[3]=Math.max(w[3],M.y)}w[0]<Ze&&w[1]<Ze&&w[2]>=0&&w[3]>=0&&g.insert(f,w[0],w[1],w[2],w[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=this.encoding!=="mlt"?new Cp(new Au(this.rawTileData)).layers:new Gf(this.rawTileData).layers,this.sourceLayerCoder=new pf(this.vtLayers?Object.keys(this.vtLayers).sort():[cc])),this.vtLayers}query(e,i,s,o){this.loadVTLayers();const u=e.params,h=Ze/e.tileSize/e.scale,f=oa(u.filter,u.globalState),g=e.queryGeometry,y=e.queryPadding*h,v=Da.fromPoints(g),w=this.grid.query(v.minX-y,v.minY-y,v.maxX+y,v.maxY+y),S=Da.fromPoints(e.cameraQueryGeometry).expandBy(y),M=this.grid3D.query(S.minX,S.minY,S.maxX,S.maxY,((R,j,X,N)=>(function(G,K,te,me,Ie){for(const Ce of G)if(K<=Ce.x&&te<=Ce.y&&me>=Ce.x&&Ie>=Ce.y)return!0;const Se=[new le(K,te),new le(K,Ie),new le(me,Ie),new le(me,te)];if(G.length>2){for(const Ce of Se)if(Do(G,Ce))return!0}for(let Ce=0;Ce<G.length-1;Ce++)if(Fg(G[Ce],G[Ce+1],Se))return!0;return!1})(e.cameraQueryGeometry,R-y,j-y,X+y,N+y)));for(const R of M)w.push(R);w.sort(Ry);const A={};let z;for(let R=0;R<w.length;R++){const j=w[R];if(j===z)continue;z=j;const X=this.featureIndexArray.get(j);let N=null;this.loadMatchingFeature(A,X.bucketIndex,X.sourceLayerIndex,X.featureIndex,f,u.layers,u.availableImages,i,s,o,((G,K,te)=>(N||(N=kn(G)),K.queryIntersectsFeature({queryGeometry:g,feature:G,featureState:te,geometry:N,zoom:this.z,transform:e.transform,pixelsToTileUnits:h,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation}))))}return A}loadMatchingFeature(e,i,s,o,u,h,f,g,y,v,w){const S=this.bucketLayerIDs[i];if(h&&!S.some((R=>h.has(R))))return;const M=this.sourceLayerCoder.decode(s),A=this.vtLayers[M].feature(o);if(u.needGeometry){const R=Rn(A,!0);if(!u.filter(new ii(this.tileID.overscaledZ),R,this.tileID.canonical))return}else if(!u.filter(new ii(this.tileID.overscaledZ),A))return;const z=this.getId(A,M);for(let R=0;R<S.length;R++){const j=S[R];if(h&&!h.has(j))continue;const X=g[j];if(!X)continue;let N={};z&&v&&(N=v.getState(X.sourceLayer||cc,z));const G=lt({},y[j]);G.paint=$f(G.paint,X.paint,A,N,f),G.layout=$f(G.layout,X.layout,A,N,f);const K=!w||w(A,X,N);if(!K)continue;const te=new ff(A,this.z,this.x,this.y,z);te.layer=G;let me=e[j];me===void 0&&(me=e[j]=[]),me.push({featureIndex:o,feature:te,intersectionZ:K})}}lookupSymbolFeatures(e,i,s,o,u,h,f,g){const y={};this.loadVTLayers();const v=oa(u.filterSpec,u.globalState);for(const w of e)this.loadMatchingFeature(y,s,o,w,v,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 o=e.id;return this.promoteId&&(o=e.properties[typeof this.promoteId=="string"?this.promoteId:this.promoteId[i]],typeof o=="boolean"&&(o=Number(o)),o===void 0&&(!((s=e.properties)===null||s===void 0)&&s.cluster)&&this.promoteId&&(o=Number(e.properties.cluster_id))),o}}function $f(r,e,i,s,o){return Lt(r,((u,h)=>{const f=e instanceof va?e.get(h):null;return f&&f.evaluate?f.evaluate(i,s,o):f}))}function Ry(r,e){return e-r}function Wf(r,e,i,s,o){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 v=f[y],w=f[y+1];v.x<e&&w.x<e||(v.x<e?v=new le(e,v.y+(e-v.x)/(w.x-v.x)*(w.y-v.y))._round():w.x<e&&(w=new le(e,v.y+(e-v.x)/(w.x-v.x)*(w.y-v.y))._round()),v.y<i&&w.y<i||(v.y<i?v=new le(v.x+(i-v.y)/(w.y-v.y)*(w.x-v.x),i)._round():w.y<i&&(w=new le(v.x+(i-v.y)/(w.y-v.y)*(w.x-v.x),i)._round()),v.x>=s&&w.x>=s||(v.x>=s?v=new le(s,v.y+(s-v.x)/(w.x-v.x)*(w.y-v.y))._round():w.x>=s&&(w=new le(s,v.y+(s-v.x)/(w.x-v.x)*(w.y-v.y))._round()),v.y>=o&&w.y>=o||(v.y>=o?v=new le(v.x+(o-v.y)/(w.y-v.y)*(w.x-v.x),o)._round():w.y>=o&&(w=new le(v.x+(o-v.y)/(w.y-v.y)*(w.x-v.x),o)._round()),g&&v.equals(g[g.length-1])||(g=[v],u.push(g)),g.push(w)))))}}return u}function Hf(r,e,i,s,o){switch(e){case 1:return(function(u,h,f,g){const y=[];for(const v of u)for(const w of v){const S=g===0?w.x:w.y;S>=h&&S<=f&&y.push([w])}return y})(r,i,s,o);case 2:return Xf(r,i,s,o,!1);case 3:return Xf(r,i,s,o,!0)}return[]}function Fy(r,e,i,s,o){const u=s===0?Ly:By;let h=[];const f=[];for(let v=0;v<r.length-1;v++){const w=r[v],S=r[v+1],M=s===0?w.x:w.y,A=s===0?S.x:S.y;let z=!1;M<e?A>e&&h.push(u(w,S,e)):M>i?A<i&&h.push(u(w,S,i)):h.push(w),A<e&&M>=e&&(h.push(u(w,S,e)),z=!0),A>i&&M<=i&&(h.push(u(w,S,i)),z=!0),!o&&z&&(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]),o&&h.length>0&&!h[0].equals(h[h.length-1])&&h.push(new le(h[0].x,h[0].y)),h.length>0&&f.push(h),f}function Xf(r,e,i,s,o){const u=[];for(const h of r){const f=Fy(h,e,i,s,o);f.length>0&&u.push(...f)}return u}function Ly(r,e,i){return new le(i,r.y+(i-r.x)/(e.x-r.x)*(e.y-r.y))}function By(r,e,i){return new le(r.x+(i-r.y)/(e.y-r.y)*(e.x-r.x),i)}Xe("FeatureIndex",Zf,{omit:["rawTileData","sourceLayerCoder"]});class Vs extends le{constructor(e,i,s,o){super(e,i),this.angle=s,o!==void 0&&(this.segment=o)}clone(){return new Vs(this.x,this.y,this.angle,this.segment)}}function Yf(r,e,i,s,o){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 v=r[h],w=r[h+1];if(!w)return!1;let S=r[h-1].angleTo(v)-v.angleTo(w);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>o)return!1;h++,f+=v.dist(w)}return!0}function Kf(r){let e=0;for(let i=0;i<r.length-1;i++)e+=r[i].dist(r[i+1]);return e}function Jf(r,e,i){return r?.6*e*i:0}function Qf(r,e){return Math.max(r?r.right-r.left:0,e?e.right-e.left:0)}function Oy(r,e,i,s,o,u){const h=Jf(i,o,u),f=Qf(i,s)*u;let g=0;const y=Kf(r)/2;for(let v=0;v<r.length-1;v++){const w=r[v],S=r[v+1],M=w.dist(S);if(g+M>y){const A=(y-g)/M,z=bi.number(w.x,S.x,A),R=bi.number(w.y,S.y,A),j=new Vs(z,R,S.angleTo(w),v);return j._round(),!h||Yf(r,j,f,h,e)?j:void 0}g+=M}}function Vy(r,e,i,s,o,u,h,f,g){const y=Jf(s,u,h),v=Qf(s,o),w=v*h,S=r[0].x===0||r[0].x===g||r[0].y===0||r[0].y===g;return e-w<e/4&&(e=w+e/4),em(r,S?e/2*f%e:(v/2+2*u)*h*f%e,e,y,i,w,S,!1,g)}function em(r,e,i,s,o,u,h,f,g){const y=u/2,v=Kf(r);let w=0,S=e-i,M=[];for(let A=0;A<r.length-1;A++){const z=r[A],R=r[A+1],j=z.dist(R),X=R.angleTo(z);for(;S+i<w+j;){S+=i;const N=(S-w)/j,G=bi.number(z.x,R.x,N),K=bi.number(z.y,R.y,N);if(G>=0&&G<g&&K>=0&&K<g&&S-y>=0&&S+y<=v){const te=new Vs(G,K,X,A);te._round(),s&&!Yf(r,te,u,s,o)||M.push(te)}}w+=j}return f||M.length||h||(M=em(r,w/2,i,s,o,u,h,!0,g)),M}function tm(r,e,i,s){const o=[],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 v=u.stretchX||[[0,f]],w=u.stretchY||[[0,g]],S=(be,He)=>be+He[1]-He[0],M=v.reduce(S,0),A=w.reduce(S,0),z=f-M,R=g-A;let j=0,X=M,N=0,G=A,K=0,te=z,me=0,Ie=R;if(u.content&&s){const be=u.content,He=be[2]-be[0],$e=be[3]-be[1];(u.textFitWidth||u.textFitHeight)&&(y=Xp(r)),j=Uu(v,0,be[0]),N=Uu(w,0,be[1]),X=Uu(v,be[0],be[2]),G=Uu(w,be[1],be[3]),K=be[0]-j,me=be[1]-N,te=He-X,Ie=$e-G}const Se=y.x1,Ce=y.y1,Ve=y.x2-Se,ze=y.y2-Ce,Me=(be,He,$e,Ke)=>{const Ge=Gu(be.stretch-j,X,Ve,Se),it=qu(be.fixed-K,te,be.stretch,M),Ot=Gu(He.stretch-N,G,ze,Ce),At=qu(He.fixed-me,Ie,He.stretch,A),Si=Gu($e.stretch-j,X,Ve,Se),pr=qu($e.fixed-K,te,$e.stretch,M),Hi=Gu(Ke.stretch-N,G,ze,Ce),Pi=qu(Ke.fixed-me,Ie,Ke.stretch,A),yi=new le(Ge,Ot),Zt=new le(Si,Ot),Li=new le(Si,Hi),Gi=new le(Ge,Hi),di=new le(it/h,At/h),Fr=new le(pr/h,Pi/h),fr=e*Math.PI/180;if(fr){const rr=Math.sin(fr),Ci=Math.cos(fr),Xi=[Ci,-rr,rr,Ci];yi._matMult(Xi),Zt._matMult(Xi),Gi._matMult(Xi),Li._matMult(Xi)}const Lr=be.stretch+be.fixed,hn=He.stretch+He.fixed;return{tl:yi,tr:Zt,bl:Gi,br:Li,tex:{x:u.paddedRect.x+1+Lr,y:u.paddedRect.y+1+hn,w:$e.stretch+$e.fixed-Lr,h:Ke.stretch+Ke.fixed-hn},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:di,pixelOffsetBR:Fr,minFontScaleX:te/h/Ve,minFontScaleY:Ie/h/ze,isSDF:i}};if(s&&(u.stretchX||u.stretchY)){const be=im(v,z,M),He=im(w,R,A);for(let $e=0;$e<be.length-1;$e++){const Ke=be[$e],Ge=be[$e+1];for(let it=0;it<He.length-1;it++)o.push(Me(Ke,He[it],Ge,He[it+1]))}}else o.push(Me({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:f+1},{fixed:0,stretch:g+1}));return o}function Uu(r,e,i){let s=0;for(const o of r)s+=Math.max(e,Math.min(i,o[1]))-Math.max(e,Math.min(i,o[0]));return s}function im(r,e,i){const s=[{fixed:-1,stretch:0}];for(const[o,u]of r){const h=s[s.length-1];s.push({fixed:o-h.stretch,stretch:h.stretch}),s.push({fixed:o-h.stretch,stretch:h.stretch+(u-o)})}return s.push({fixed:e+1,stretch:i}),s}function Gu(r,e,i,s){return r/e*i+s}function qu(r,e,i,s){return r-e*i/s}Xe("Anchor",Vs);class Zu{constructor(e,i,s,o,u,h,f,g,y,v){var w;if(this.boxStartIndex=e.length,y){let S=h.top,M=h.bottom;const A=h.collisionPadding;A&&(S-=A[1],M+=A[3]);let z=M-S;z>0&&(z=Math.max(10,z),this.circleDiameter=z)}else{const S=!((w=h.image)===null||w===void 0)&&w.content&&(h.image.textFitWidth||h.image.textFitHeight)?Xp(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 M=h.collisionPadding;if(M&&(S.x1-=M[0]*f,S.y1-=M[1]*f,S.x2+=M[2]*f,S.y2+=M[3]*f),v){const A=new le(S.x1,S.y1),z=new le(S.x2,S.y1),R=new le(S.x1,S.y2),j=new le(S.x2,S.y2),X=v*Math.PI/180;A._rotate(X),z._rotate(X),R._rotate(X),j._rotate(X),S.x1=Math.min(A.x,z.x,R.x,j.x),S.x2=Math.max(A.x,z.x,R.x,j.x),S.y1=Math.min(A.y,z.y,R.y,j.y),S.y2=Math.max(A.y,z.y,R.y,j.y)}e.emplaceBack(i.x,i.y,S.x1,S.y1,S.x2,S.y2,s,o,u)}this.boxEndIndex=e.length}}class jy{constructor(e=[],i=(s,o)=>s<o?-1:s>o?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,o=i[e];for(;e>0;){const u=e-1>>1,h=i[u];if(s(o,h)>=0)break;i[e]=h,e=u}i[e]=o}_down(e){const{data:i,compare:s}=this,o=this.length>>1,u=i[e];for(;e<o;){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 Ny(r,e=1,i=!1){const s=Da.fromPoints(r[0]),o=Math.min(s.width(),s.height());let u=o/2;const h=new jy([],Uy),{minX:f,minY:g,maxX:y,maxY:v}=s;if(o===0)return new le(f,g);for(let M=f;M<y;M+=o)for(let A=g;A<v;A+=o)h.push(new qo(M+u,A+u,u,r));let w=(function(M){let A=0,z=0,R=0;const j=M[0];for(let X=0,N=j.length,G=N-1;X<N;G=X++){const K=j[X],te=j[G],me=K.x*te.y-te.x*K.y;z+=(K.x+te.x)*me,R+=(K.y+te.y)*me,A+=3*me}return new qo(z/A,R/A,0,M)})(r),S=h.length;for(;h.length;){const M=h.pop();(M.d>w.d||!w.d)&&(w=M,i&&console.log("found best %d after %d probes",Math.round(1e4*M.d)/1e4,S)),M.max-w.d<=e||(u=M.h/2,h.push(new qo(M.p.x-u,M.p.y-u,u,r)),h.push(new qo(M.p.x+u,M.p.y-u,u,r)),h.push(new qo(M.p.x-u,M.p.y+u,u,r)),h.push(new qo(M.p.x+u,M.p.y+u,u,r)),S+=4)}return i&&(console.log(`num probes: ${S}`),console.log(`best distance: ${w.d}`)),w.p}function Uy(r,e){return e.max-r.max}function qo(r,e,i,s){this.p=new le(r,e),this.h=i,this.d=(function(o,u){let h=!1,f=1/0;for(let g=0;g<u.length;g++){const y=u[g];for(let v=0,w=y.length,S=w-1;v<w;S=v++){const M=y[v],A=y[S];M.y>o.y!=A.y>o.y&&o.x<(A.x-M.x)*(o.y-M.y)/(A.y-M.y)+M.x&&(h=!h),f=Math.min(f,ap(o,M,A))}}return(h?1:-1)*Math.sqrt(f)})(this.p,s),this.max=this.d+this.h*Math.SQRT2}var dr;P.aP=void 0,(dr=P.aP||(P.aP={}))[dr.center=1]="center",dr[dr.left=2]="left",dr[dr.right=3]="right",dr[dr.top=4]="top",dr[dr.bottom=5]="bottom",dr[dr["top-left"]=6]="top-left",dr[dr["top-right"]=7]="top-right",dr[dr["bottom-left"]=8]="bottom-left",dr[dr["bottom-right"]=9]="bottom-right";const xd=Number.POSITIVE_INFINITY;function rm(r,e){return e[1]!==xd?(function(i,s,o){let u=0,h=0;switch(s=Math.abs(s),o=Math.abs(o),i){case"top-right":case"top-left":case"top":h=o-7;break;case"bottom-right":case"bottom-left":case"bottom":h=7-o}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 o=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":o=-h;break;case"top-left":case"bottom-left":o=h;break;case"left":o=s;break;case"right":o=-s}return[o,u]})(r,e[0])}function nm(r,e,i){var s;const o=r.layout,u=(s=o.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 v=g[y]=f[y],w=f[y+1].map((S=>S*er));v.startsWith("top")?w[1]-=7:v.startsWith("bottom")&&(w[1]+=7),g[y+1]=w}return new vr(g)}const h=o.get("text-variable-anchor");if(h){let f;f=r._unevaluatedLayout.getValue("text-radial-offset")!==void 0?[o.get("text-radial-offset").evaluate(e,{},i)*er,xd]:o.get("text-offset").evaluate(e,{},i).map((y=>y*er));const g=[];for(const y of h)g.push(y,rm(y,f));return new vr(g)}return null}function vd(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 Gy(r,e,i,s,o,u,h,f,g,y,v,w){let S=u.textMaxSize.evaluate(e,{});S===void 0&&(S=h);const M=r.layers[0].layout,A=M.get("icon-offset").evaluate(e,{},v),z=am(i.horizontal),R=h/24,j=r.tilePixelRatio*R,X=r.tilePixelRatio*S/24,N=r.tilePixelRatio*f,G=r.tilePixelRatio*M.get("symbol-spacing"),K=M.get("text-padding")*r.tilePixelRatio,te=(function($e,Ke,Ge,it=1){const Ot=$e.get("icon-padding").evaluate(Ke,{},Ge),At=Ot&&Ot.values;return[At[0]*it,At[1]*it,At[2]*it,At[3]*it]})(M,e,v,r.tilePixelRatio),me=M.get("text-max-angle")/180*Math.PI,Ie=M.get("text-rotation-alignment")!=="viewport"&&M.get("symbol-placement")!=="point",Se=M.get("icon-rotation-alignment")==="map"&&M.get("symbol-placement")!=="point",Ce=M.get("symbol-placement"),Ve=G/2,ze=M.get("icon-text-fit");let Me;s&&ze!=="none"&&(r.allowVerticalPlacement&&i.vertical&&(Me=Yp(s,i.vertical,ze,M.get("icon-text-fit-padding"),A,R)),z&&(s=Yp(s,z,ze,M.get("icon-text-fit-padding"),A,R)));const be=v?w.line.getGranularityForZoomLevel(v.z):1,He=($e,Ke)=>{Ke.x<0||Ke.x>=Ze||Ke.y<0||Ke.y>=Ze||(function(Ge,it,Ot,At,Si,pr,Hi,Pi,yi,Zt,Li,Gi,di,Fr,fr,Lr,hn,rr,Ci,Xi,Bi,nr,ss,xn,dc){const js=Ge.addToLineVertexArray(it,Ot);let Ra,Zo,$o,Wo,um=0,hm=0,dm=0,pm=0,Ed=-1,Cd=-1;const as={};let fm=Ui("");if(Ge.allowVerticalPlacement&&At.vertical){const Sr=Pi.layout.get("text-rotate").evaluate(Bi,{},xn)+90;$o=new Zu(yi,it,Zt,Li,Gi,At.vertical,di,Fr,fr,Sr),Hi&&(Wo=new Zu(yi,it,Zt,Li,Gi,Hi,hn,rr,fr,Sr))}if(Si){const Sr=Pi.layout.get("icon-rotate").evaluate(Bi,{}),sn=Pi.layout.get("icon-text-fit")!=="none",Fa=tm(Si,Sr,ss,sn),bn=Hi?tm(Hi,Sr,ss,sn):void 0;Zo=new Zu(yi,it,Zt,Li,Gi,Si,hn,rr,!1,Sr),um=4*Fa.length;const La=Ge.iconSizeData;let Fn=null;La.kind==="source"?(Fn=[rs*Pi.layout.get("icon-size").evaluate(Bi,{})],Fn[0]>Ls&&yt(`${Ge.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):La.kind==="composite"&&(Fn=[rs*nr.compositeIconSizes[0].evaluate(Bi,{},xn),rs*nr.compositeIconSizes[1].evaluate(Bi,{},xn)],(Fn[0]>Ls||Fn[1]>Ls)&&yt(`${Ge.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),Ge.addSymbols(Ge.icon,Fa,Fn,Xi,Ci,Bi,P.az.none,it,js.lineStartIndex,js.lineLength,-1,xn),Ed=Ge.icon.placedSymbolArray.length-1,bn&&(hm=4*bn.length,Ge.addSymbols(Ge.icon,bn,Fn,Xi,Ci,Bi,P.az.vertical,it,js.lineStartIndex,js.lineLength,-1,xn),Cd=Ge.icon.placedSymbolArray.length-1)}const mm=Object.keys(At.horizontal);for(const Sr of mm){const sn=At.horizontal[Sr];if(!Ra){fm=Ui(sn.text);const bn=Pi.layout.get("text-rotate").evaluate(Bi,{},xn);Ra=new Zu(yi,it,Zt,Li,Gi,sn,di,Fr,fr,bn)}const Fa=sn.positionedLines.length===1;if(dm+=sm(Ge,it,sn,pr,Pi,fr,Bi,Lr,js,At.vertical?P.az.horizontal:P.az.horizontalOnly,Fa?mm:[Sr],as,Ed,nr,xn),Fa)break}At.vertical&&(pm+=sm(Ge,it,At.vertical,pr,Pi,fr,Bi,Lr,js,P.az.vertical,["vertical"],as,Cd,nr,xn));const $y=Ra?Ra.boxStartIndex:Ge.collisionBoxArray.length,Wy=Ra?Ra.boxEndIndex:Ge.collisionBoxArray.length,Hy=$o?$o.boxStartIndex:Ge.collisionBoxArray.length,Xy=$o?$o.boxEndIndex:Ge.collisionBoxArray.length,Yy=Zo?Zo.boxStartIndex:Ge.collisionBoxArray.length,Ky=Zo?Zo.boxEndIndex:Ge.collisionBoxArray.length,Jy=Wo?Wo.boxStartIndex:Ge.collisionBoxArray.length,Qy=Wo?Wo.boxEndIndex:Ge.collisionBoxArray.length;let vn=-1;const Wu=(Sr,sn)=>Sr&&Sr.circleDiameter?Math.max(Sr.circleDiameter,sn):sn;vn=Wu(Ra,vn),vn=Wu($o,vn),vn=Wu(Zo,vn),vn=Wu(Wo,vn);const gm=vn>-1?1:0;gm&&(vn*=dc/er),Ge.glyphOffsetArray.length>=Oo.MAX_GLYPHS&&yt("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),Bi.sortKey!==void 0&&Ge.addToSortKeyRanges(Ge.symbolInstances.length,Bi.sortKey);const ex=nm(Pi,Bi,xn),[tx,ix]=(function(Sr,sn){const Fa=Sr.length,bn=sn==null?void 0:sn.values;if((bn==null?void 0:bn.length)>0)for(let La=0;La<bn.length;La+=2){const Fn=bn[La+1];Sr.emplaceBack(P.aP[bn[La]],Fn[0],Fn[1])}return[Fa,Sr.length]})(Ge.textAnchorOffsets,ex);Ge.symbolInstances.emplaceBack(it.x,it.y,as.right>=0?as.right:-1,as.center>=0?as.center:-1,as.left>=0?as.left:-1,as.vertical||-1,Ed,Cd,fm,$y,Wy,Hy,Xy,Yy,Ky,Jy,Qy,Zt,dm,pm,um,hm,gm,0,di,vn,tx,ix)})(r,Ke,$e,i,s,o,Me,r.layers[0],r.collisionBoxArray,e.index,e.sourceLayerIndex,r.index,j,[K,K,K,K],Ie,g,N,te,Se,A,e,u,y,v,h)};if(Ce==="line")for(const $e of Wf(e.geometry,0,0,Ze,Ze)){const Ke=Aa($e,be),Ge=Vy(Ke,G,me,i.vertical||z,s,24,X,r.overscaling,Ze);for(const it of Ge)z&&qy(r,z.text,Ve,it)||He(Ke,it)}else if(Ce==="line-center"){for(const $e of e.geometry)if($e.length>1){const Ke=Aa($e,be),Ge=Oy(Ke,me,i.vertical||z,s,24,X);Ge&&He(Ke,Ge)}}else if(e.type==="Polygon")for(const $e of Ka(e.geometry,0)){const Ke=Ny($e,16);He(Aa($e[0],be,!0),new Vs(Ke.x,Ke.y,0))}else if(e.type==="LineString")for(const $e of e.geometry){const Ke=Aa($e,be);He(Ke,new Vs(Ke[0].x,Ke[0].y,0))}else if(e.type==="Point")for(const $e of e.geometry)for(const Ke of $e)He([Ke],new Vs(Ke.x,Ke.y,0))}function sm(r,e,i,s,o,u,h,f,g,y,v,w,S,M,A){const z=(function(X,N,G,K,te,me,Ie,Se){const Ce=K.layout.get("text-rotate").evaluate(me,{})*Math.PI/180,Ve=[];for(const ze of N.positionedLines)for(const Me of ze.positionedGlyphs){if(!Me.rect)continue;const be=Me.rect||{};let He=4,$e=!0,Ke=1,Ge=0;const it=(te||Se)&&Me.vertical,Ot=Me.metrics.advance*Me.scale/2;if(Se&&N.verticalizable&&(Ge=ze.lineOffset/2-(Me.imageName?-(er-Me.metrics.width*Me.scale)/2:(Me.scale-1)*er)),Me.imageName){const rr=Ie[Me.imageName];$e=rr.sdf,Ke=rr.pixelRatio,He=1/Ke}const At=te?[Me.x+Ot,Me.y]:[0,0];let Si=te?[0,0]:[Me.x+Ot+G[0],Me.y+G[1]-Ge],pr=[0,0];it&&(pr=Si,Si=[0,0]);const Hi=Me.metrics.isDoubleResolution?2:1,Pi=(Me.metrics.left-He)*Me.scale-Ot+Si[0],yi=(-Me.metrics.top-He)*Me.scale+Si[1],Zt=Pi+be.w/Hi*Me.scale/Ke,Li=yi+be.h/Hi*Me.scale/Ke,Gi=new le(Pi,yi),di=new le(Zt,yi),Fr=new le(Pi,Li),fr=new le(Zt,Li);if(it){const rr=new le(-Ot,Ot- -17),Ci=-Math.PI/2,Xi=12-Ot,Bi=new le(22-Xi,-(Me.imageName?Xi:0)),nr=new le(...pr);Gi._rotateAround(Ci,rr)._add(Bi)._add(nr),di._rotateAround(Ci,rr)._add(Bi)._add(nr),Fr._rotateAround(Ci,rr)._add(Bi)._add(nr),fr._rotateAround(Ci,rr)._add(Bi)._add(nr)}if(Ce){const rr=Math.sin(Ce),Ci=Math.cos(Ce),Xi=[Ci,-rr,rr,Ci];Gi._matMult(Xi),di._matMult(Xi),Fr._matMult(Xi),fr._matMult(Xi)}const Lr=new le(0,0),hn=new le(0,0);Ve.push({tl:Gi,tr:di,bl:Fr,br:fr,tex:be,writingMode:N.writingMode,glyphOffset:At,sectionIndex:Me.sectionIndex,isSDF:$e,pixelOffsetTL:Lr,pixelOffsetBR:hn,minFontScaleX:0,minFontScaleY:0})}return Ve})(0,i,f,o,u,h,s,r.allowVerticalPlacement),R=r.textSizeData;let j=null;R.kind==="source"?(j=[rs*o.layout.get("text-size").evaluate(h,{})],j[0]>Ls&&yt(`${r.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):R.kind==="composite"&&(j=[rs*M.compositeTextSizes[0].evaluate(h,{},A),rs*M.compositeTextSizes[1].evaluate(h,{},A)],(j[0]>Ls||j[1]>Ls)&&yt(`${r.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),r.addSymbols(r.text,z,j,f,u,h,y,e,g.lineStartIndex,g.lineLength,S,A);for(const X of v)w[X]=r.text.placedSymbolArray.length-1;return 4*z.length}function am(r){for(const e in r)return r[e];return null}function qy(r,e,i,s){const o=r.compareText;if(e in o){const u=o[e];for(let h=u.length-1;h>=0;h--)if(s.dist(u[h])<i)return!0}else o[e]=[];return o[e].push(s),!1}const om=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class bd{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 o=s>>4;if(o!==1)throw new Error(`Got v${o} data when expected v1.`);const u=om[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 bd(f,h,u,e)}constructor(e,i=64,s=Float64Array,o){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=om.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}.`);o&&o instanceof ArrayBuffer?(this.data=o,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 wd(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,i,s,o){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 v=g.pop()||0,w=g.pop()||0,S=g.pop()||0;if(w-S<=f){for(let R=S;R<=w;R++){const j=h[2*R],X=h[2*R+1];j>=e&&j<=s&&X>=i&&X<=o&&y.push(u[R])}continue}const M=S+w>>1,A=h[2*M],z=h[2*M+1];A>=e&&A<=s&&z>=i&&z<=o&&y.push(u[M]),(v===0?e<=A:i<=z)&&(g.push(S),g.push(M-1),g.push(1-v)),(v===0?s>=A:o>=z)&&(g.push(M+1),g.push(w),g.push(1-v))}return y}within(e,i,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:o,coords:u,nodeSize:h}=this,f=[0,o.length-1,0],g=[],y=s*s;for(;f.length;){const v=f.pop()||0,w=f.pop()||0,S=f.pop()||0;if(w-S<=h){for(let R=S;R<=w;R++)cm(u[2*R],u[2*R+1],e,i)<=y&&g.push(o[R]);continue}const M=S+w>>1,A=u[2*M],z=u[2*M+1];cm(A,z,e,i)<=y&&g.push(o[M]),(v===0?e-s<=A:i-s<=z)&&(f.push(S),f.push(M-1),f.push(1-v)),(v===0?e+s>=A:i+s>=z)&&(f.push(M+1),f.push(w),f.push(1-v))}return g}}function wd(r,e,i,s,o,u){if(o-s<=i)return;const h=s+o>>1;lm(r,e,h,s,o,u),wd(r,e,i,s,h-1,1-u),wd(r,e,i,h+1,o,1-u)}function lm(r,e,i,s,o,u){for(;o>s;){if(o-s>600){const y=o-s+1,v=i-s+1,w=Math.log(y),S=.5*Math.exp(2*w/3),M=.5*Math.sqrt(w*S*(y-S)/y)*(v-y/2<0?-1:1);lm(r,e,i,Math.max(s,Math.floor(i-v*S/y+M)),Math.min(o,Math.floor(i+(y-v)*S/y+M)),u)}const h=e[2*i+u];let f=s,g=o;for(uc(r,e,s,i),e[2*o+u]>h&&uc(r,e,s,o);f<g;){for(uc(r,e,f,g),f++,g--;e[2*f+u]<h;)f++;for(;e[2*g+u]>h;)g--}e[2*s+u]===h?uc(r,e,s,g):(g++,uc(r,e,g,o)),g<=i&&(s=g+1),i<=g&&(o=g-1)}}function uc(r,e,i,s){Td(r,i,s),Td(e,2*i,2*s),Td(e,2*i+1,2*s+1)}function Td(r,e,i){const s=r[e];r[e]=r[i],r[i]=s}function cm(r,e,i,s){const o=r-i,u=e-s;return o*o+u*u}var Sd;P.cH=void 0,(Sd=P.cH||(P.cH={})).create="create",Sd.load="load",Sd.fullLoad="fullLoad";let $u=null,hc=[];const Pd=1e3/60,Md="loadTime",Id="fullLoadTime",Zy={mark(r){performance.mark(r)},frame(r){const e=r;$u!=null&&hc.push(e-$u),$u=e},clearMetrics(){$u=null,hc=[],performance.clearMeasures(Md),performance.clearMeasures(Id);for(const r in P.cH)performance.clearMarks(P.cH[r])},getPerformanceMetrics(){performance.measure(Md,P.cH.create,P.cH.load),performance.measure(Id,P.cH.create,P.cH.fullLoad);const r=performance.getEntriesByName(Md)[0].duration,e=performance.getEntriesByName(Id)[0].duration,i=hc.length,s=1/(hc.reduce(((u,h)=>u+h),0)/i/1e3),o=hc.filter((u=>u>Pd)).reduce(((u,h)=>u+(h-Pd)/Pd),0);return{loadTime:r,fullLoadTime:e,fps:s,percentDroppedFrames:o/(i+o)*100,totalFrames:i}}};P.$=ge,P.A=st,P.B=As,P.C=Ji,P.D=et,P.E=Gt,P.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)}},P.G=bi,P.H=ii,P.I=Wh,P.J=uu,P.K=function(r){if(Vt==null){const e=r.navigator?r.navigator.userAgent:null;Vt=!!r.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Vt},P.L=class{constructor(r,e){this.target=r,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new ay((()=>this.process())),this.subscription=Or(this.target,"message",(i=>this.receive(i)),!1),this.globalScope=xt(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 o=Math.round(1e18*Math.random()).toString(36).substring(0,10),u=e?Or(e.signal,"abort",(()=>{u==null||u.unsubscribe(),delete this.resolveRejects[o];const g={id:o,type:"<cancel>",origin:location.origin,targetMapId:r.targetMapId,sourceMapId:this.mapId};this.target.postMessage(g)}),oy):null;this.resolveRejects[o]={resolve:g=>{u==null||u.unsubscribe(),i(g)},reject:g=>{u==null||u.unsubscribe(),s(g)}};const h=[],f=Object.assign(Object.assign({},r),{id:o,sourceMapId:this.mapId,origin:location.origin,data:ga(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(xt(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 o=this.resolveRejects[r];return delete this.resolveRejects[r],o?void(e.error?o.reject(_a(e.error)):o.resolve(_a(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=_a(e.data),s=new AbortController;this.abortControllers[r]=s;try{const o=yield this.messageHandlers[e.type](e.sourceMapId,i,s);this.completeTask(r,null,o)}catch(o){this.completeTask(r,o)}}))}completeTask(r,e,i){const s=[];delete this.abortControllers[r];const o={id:r,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:e?ga(e):null,data:ga(i,s)};this.target.postMessage(o,{transfer:s})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},P.M=de,P.N=function(){var r=new st(16);return st!=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},P.O=function(r,e,i){var s,o,u,h,f,g,y,v,w,S,M,A,z=i[0],R=i[1],j=i[2];return e===r?(r[12]=e[0]*z+e[4]*R+e[8]*j+e[12],r[13]=e[1]*z+e[5]*R+e[9]*j+e[13],r[14]=e[2]*z+e[6]*R+e[10]*j+e[14],r[15]=e[3]*z+e[7]*R+e[11]*j+e[15]):(o=e[1],u=e[2],h=e[3],f=e[4],g=e[5],y=e[6],v=e[7],w=e[8],S=e[9],M=e[10],A=e[11],r[0]=s=e[0],r[1]=o,r[2]=u,r[3]=h,r[4]=f,r[5]=g,r[6]=y,r[7]=v,r[8]=w,r[9]=S,r[10]=M,r[11]=A,r[12]=s*z+f*R+w*j+e[12],r[13]=o*z+g*R+S*j+e[13],r[14]=u*z+y*R+M*j+e[14],r[15]=h*z+v*R+A*j+e[15]),r},P.P=le,P.Q=function(r,e,i){var s=i[0],o=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]*o,r[5]=e[5]*o,r[6]=e[6]*o,r[7]=e[7]*o,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},P.R=Rr,P.S=function(r,e,i){var s=e[0],o=e[1],u=e[2],h=e[3],f=e[4],g=e[5],y=e[6],v=e[7],w=e[8],S=e[9],M=e[10],A=e[11],z=e[12],R=e[13],j=e[14],X=e[15],N=i[0],G=i[1],K=i[2],te=i[3];return r[0]=N*s+G*f+K*w+te*z,r[1]=N*o+G*g+K*S+te*R,r[2]=N*u+G*y+K*M+te*j,r[3]=N*h+G*v+K*A+te*X,r[4]=(N=i[4])*s+(G=i[5])*f+(K=i[6])*w+(te=i[7])*z,r[5]=N*o+G*g+K*S+te*R,r[6]=N*u+G*y+K*M+te*j,r[7]=N*h+G*v+K*A+te*X,r[8]=(N=i[8])*s+(G=i[9])*f+(K=i[10])*w+(te=i[11])*z,r[9]=N*o+G*g+K*S+te*R,r[10]=N*u+G*y+K*M+te*j,r[11]=N*h+G*v+K*A+te*X,r[12]=(N=i[12])*s+(G=i[13])*f+(K=i[14])*w+(te=i[15])*z,r[13]=N*o+G*g+K*S+te*R,r[14]=N*u+G*y+K*M+te*j,r[15]=N*h+G*v+K*A+te*X,r},P.T=Oh,P.U=function(r,e){const i={};for(let s=0;s<e.length;s++){const o=e[s];o in r&&(i[o]=r[o])}return i},P.V=Bs,P.W=mi,P.X=af,P.Y=sf,P.Z=re,P._=c,P.a=U,P.a$=De,P.a0=Xt,P.a1=mr,P.a2=rn,P.a3=lf,P.a4=Ru,P.a5=Ze,P.a6=function(r,e,i){if(!r)return e||{};if(!e)return r||{};const s=df(r),o=df(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 v=h.update.get(g);v&&(f.update.set(g,ly(v,y)),h.update.delete(g))}})(s,o);const u={};if((s.removeAll||o.removeAll)&&(u.removeAll=!0),u.remove=new Set([...s.remove,...o.remove]),u.add=new Map([...s.add,...o.add]),u.update=new Map([...s.update,...o.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)},P.a7=function(r,e){const i=new Map;if(r==null||r.type==null)return i;if(r.type==="Feature"){const s=id(r,e);return s==null?void 0:(i.set(s,r),i)}if(r.type==="FeatureCollection"){const s=new Set;for(const o of r.features){const u=id(o,e);if(u==null||s.has(u))return;s.add(u),i.set(u,o)}return i}},P.a8=function(r,e,i){var s,o;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=id(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||((o=h.addOrUpdateProperties)===null||o===void 0?void 0:o.length)>0;if(!g&&!y)continue;u.push(f.geometry);const v=Object.assign({},f);if(r.set(h.id,v),g&&(u.push(h.newGeometry),v.geometry=h.newGeometry),y){if(v.properties=h.removeAllProperties?{}:Object.assign({},v.properties||{}),h.removeProperties)for(const w of h.removeProperties)delete v.properties[w];if(h.addOrUpdateProperties)for(const{key:w,value:S}of h.addOrUpdateProperties)v.properties[w]=S}}return u},P.a9=ac,P.aA=function(r,{uSize:e,uSizeT:i},{lowerSize:s,upperSize:o}){return r.kind==="source"?s/rs:r.kind==="composite"?bi.number(s/rs,o/rs,i):e},P.aB=function(r,e){var i=e[0],s=e[1],o=e[2],u=e[3],h=e[4],f=e[5],g=e[6],y=e[7],v=e[8],w=e[9],S=e[10],M=e[11],A=e[12],z=e[13],R=e[14],j=e[15],X=i*f-s*h,N=i*g-o*h,G=i*y-u*h,K=s*g-o*f,te=s*y-u*f,me=o*y-u*g,Ie=v*z-w*A,Se=v*R-S*A,Ce=v*j-M*A,Ve=w*R-S*z,ze=w*j-M*z,Me=S*j-M*R,be=X*Me-N*ze+G*Ve+K*Ce-te*Se+me*Ie;return be?(r[0]=(f*Me-g*ze+y*Ve)*(be=1/be),r[1]=(o*ze-s*Me-u*Ve)*be,r[2]=(z*me-R*te+j*K)*be,r[3]=(S*te-w*me-M*K)*be,r[4]=(g*Ce-h*Me-y*Se)*be,r[5]=(i*Me-o*Ce+u*Se)*be,r[6]=(R*G-A*me-j*N)*be,r[7]=(v*me-S*G+M*N)*be,r[8]=(h*ze-f*Ce+y*Ie)*be,r[9]=(s*Ce-i*ze-u*Ie)*be,r[10]=(A*te-z*G+j*X)*be,r[11]=(w*G-v*te-M*X)*be,r[12]=(f*Se-h*Ve-g*Ie)*be,r[13]=(i*Ve-s*Se+o*Ie)*be,r[14]=(z*N-A*K-R*X)*be,r[15]=(v*K-w*N+S*X)*be,r):null},P.aC=ot,P.aD=function(r){var e=r[0],i=r[1];return Math.sqrt(e*e+i*i)},P.aE=function(r){return r[0]=0,r[1]=0,r},P.aF=function(r,e,i){return r[0]=e[0]*i,r[1]=e[1]*i,r},P.aG=Yh,P.aH=jt,P.aI=function(r,e,i,s){const o=e.y-r.y,u=e.x-r.x,h=s.y-i.y,f=s.x-i.x,g=h*u-f*o;if(g===0)return null;const y=(f*(r.y-i.y)-h*(r.x-i.x))/g;return new le(r.x+y*u,r.y+y*o)},P.aJ=Wf,P.aK=Ao,P.aL=function(r){let e=1/0,i=1/0,s=-1/0,o=-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),o=Math.max(o,u.y);return[e,i,s,o]},P.aM=er,P.aN=xi,P.aO=function(r,e,i,s,o=!1){if(!i[0]&&!i[1])return[0,0];const u=o?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[o?i[0]:xi(e,i[0],r.zoom),o?i[1]:xi(e,i[1],r.zoom)]},P.aQ=Xh,P.aR=vd,P.aS=Hh,P.aT=bd,P.aU=Ni,P.aV=Eu,P.aW=q,P.aX=Ue,P.aY=ve,P.aZ=vi,P.a_=cf,P.aa=Da,P.ab=25,P.ac=td,P.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 o=window.document.createElement("source");Ee(s)||(e.crossOrigin="Anonymous"),o.src=s,e.appendChild(o)}}))},P.ae=Re,P.af=function(){return It++},P.ag=l,P.ah=Oo,P.ai=cc,P.aj=oa,P.ak=Rn,P.al=ff,P.am=function(r){const e={};if(r.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((i,s,o,u)=>{const h=o||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},P.an=Ut,P.ao=85.051129,P.ap=Di,P.aq=function(r){return Math.pow(2,r)},P.ar=Qt,P.as=of,P.at=function(r){return Math.log(r)/Math.LN2},P.au=function(r){var e=r[0],i=r[1];return e*e+i*i},P.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,o=1/0,u=-1/0;const h=[];for(const g of r){const{x:y,y:v,z:w}=g.canonical,S=Math.pow(2,e-w),M=y*S,A=v*S;h.push({id:g,x:M,y:A}),M<i&&(i=M),M>s&&(s=M),A<o&&(o=A),A>u&&(u=A)}const f=new Set;for(const g of h)g.x!==i&&g.x!==s&&g.y!==o&&g.y!==u||f.add(g.id);return f},P.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},P.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 o={value:e,timeout:void 0};if(i!==void 0&&(o.timeout=setTimeout((()=>{this.remove(r,o)}),i)),this.data[s].push(o),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),o=this.data[i][s];return this.data[i].splice(s,1),o.timeout&&clearTimeout(o.timeout),this.data[i].length===0&&delete this.data[i],this.onRemove(o.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)}},P.ay=function(r,e){let i=0,s=0;if(r.kind==="constant")s=r.layoutSize;else if(r.kind!=="source"){const{interpolationType:o,minZoom:u,maxZoom:h}=r,f=o?Ut(wr.interpolationFactor(o,e,u,h),0,1):0;r.kind==="camera"?s=bi.number(r.minSize,r.maxSize,f):i=f}return{uSizeT:i,uSize:s}},P.b=pt,P.b$=ts,P.b0=pe,P.b1=function(r){var e=new st(3);return e[0]=r[0],e[1]=r[1],e[2]=r[2],e},P.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},P.b3=function(r,e){var i=e[0],s=e[1],o=e[2],u=i*i+s*s+o*o;return u>0&&(u=1/Math.sqrt(u)),r[0]=e[0]*u,r[1]=e[1]*u,r[2]=e[2]*u,r},P.b4=Oe,P.b5=function(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]},P.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},P.b7=dt,P.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},P.b9=at,P.bA=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},P.bB=ei,P.bC=function(r,e,i){var s=i[0],o=i[1],u=i[2],h=i[3],f=e[0],g=e[1],y=e[2],v=o*y-u*g,w=u*f-s*y,S=s*g-o*f;return r[0]=f+h*(v+=v)+o*(S+=S)-u*(w+=w),r[1]=g+h*w+u*v-s*S,r[2]=y+h*S+s*w-o*v,r},P.bD=function(r,e,i){const s=(function(g){var y=g[3],v=g[4],w=g[5],S=g[6],M=g[7],A=g[8];return g[0]*(A*v-w*M)+g[1]*(-A*y+w*S)+g[2]*(M*y-v*S)})([r[0],r[1],r[2],e[0],e[1],e[2],i[0],i[1],i[2]]);if(s===0)return null;const o=Oe([],[e[0],e[1],e[2]],[i[0],i[1],i[2]]),u=Oe([],[i[0],i[1],i[2]],[r[0],r[1],r[2]]),h=Oe([],[r[0],r[1],r[2]],[e[0],e[1],e[2]]),f=De([],o,-r[3]);return pe(f,f,De([],u,-e[3])),pe(f,f,De([],h,-i[3])),De(f,f,1/s),f},P.bE=ed,P.bF=function(){return new Float64Array(4)},P.bG=function(r,e,i,s){var o=[],u=[];return o[0]=e[0]-i[0],o[1]=e[1]-i[1],o[2]=e[2]-i[2],u[0]=o[0]*Math.cos(s)-o[1]*Math.sin(s),u[1]=o[0]*Math.sin(s)+o[1]*Math.cos(s),u[2]=o[2],r[0]=u[0]+i[0],r[1]=u[1]+i[1],r[2]=u[2]+i[2],r},P.bH=function(r,e,i,s){var o=[],u=[];return o[0]=e[0]-i[0],o[1]=e[1]-i[1],o[2]=e[2]-i[2],u[0]=o[0],u[1]=o[1]*Math.cos(s)-o[2]*Math.sin(s),u[2]=o[1]*Math.sin(s)+o[2]*Math.cos(s),r[0]=u[0]+i[0],r[1]=u[1]+i[1],r[2]=u[2]+i[2],r},P.bI=function(r,e,i,s){var o=[],u=[];return o[0]=e[0]-i[0],o[1]=e[1]-i[1],o[2]=e[2]-i[2],u[0]=o[2]*Math.sin(s)+o[0]*Math.cos(s),u[1]=o[1],u[2]=o[2]*Math.cos(s)-o[0]*Math.sin(s),r[0]=u[0]+i[0],r[1]=u[1]+i[1],r[2]=u[2]+i[2],r},P.bJ=function(r,e,i){var s=Math.sin(i),o=Math.cos(i),u=e[0],h=e[1],f=e[2],g=e[3],y=e[8],v=e[9],w=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*o-y*s,r[1]=h*o-v*s,r[2]=f*o-w*s,r[3]=g*o-S*s,r[8]=u*s+y*o,r[9]=h*s+v*o,r[10]=f*s+w*o,r[11]=g*s+S*o,r},P.bK=function(r,e){const i=ht(r,360),s=ht(e,360),o=s-i,u=s>i?o-360:o+360;return Math.abs(o)<Math.abs(u)?o:u},P.bL=function(r){return r[0]=0,r[1]=0,r[2]=0,r},P.bM=function(r,e,i,s){const o=Math.sqrt(r*r+e*e),u=Math.sqrt(i*i+s*s);r/=o,e/=o,i/=u,s/=u;const h=Math.acos(r*i+e*s);return-e*i+r*s>0?h:-h},P.bN=function(r,e){const i=ht(r,2*Math.PI),s=ht(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))},P.bO=function(){const r={},e=ye.$version;for(const i in ye.$root){const s=ye.$root[i];if(s.required){let o=null;o=i==="version"?e:s.type==="array"?[]:{},o!=null&&(r[i]=o)}}return r},P.bP=we,P.bQ=kl,P.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},P.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]=sr(r[i],e[r[i].ref]));return r},P.bT=function(r,e){if(r.type==="custom")return new sy(r,e);switch(r.type){case"background":return new ny(r,e);case"circle":return new Ug(r,e);case"color-relief":return new Hg(r,e);case"fill":return new c_(r,e);case"fill-extrusion":return new b_(r,e);case"heatmap":return new qg(r,e);case"hillshade":return new $g(r,e);case"line":return new E_(r,e);case"raster":return new Ch(r,e);case"symbol":return new ku(r,e)}},P.bU=r=>r.type==="raster",P.bV=Rt,P.bW=function(r,e){if(!r)return[{command:"setStyle",args:[e]}];let i=[];try{if(!mt(r.version,e.version))return[{command:"setStyle",args:[e]}];mt(r.center,e.center)||i.push({command:"setCenter",args:[e.center]}),mt(r.state,e.state)||i.push({command:"setGlobalState",args:[e.state]}),mt(r.centerAltitude,e.centerAltitude)||i.push({command:"setCenterAltitude",args:[e.centerAltitude]}),mt(r.zoom,e.zoom)||i.push({command:"setZoom",args:[e.zoom]}),mt(r.bearing,e.bearing)||i.push({command:"setBearing",args:[e.bearing]}),mt(r.pitch,e.pitch)||i.push({command:"setPitch",args:[e.pitch]}),mt(r.roll,e.roll)||i.push({command:"setRoll",args:[e.roll]}),mt(r.sprite,e.sprite)||i.push({command:"setSprite",args:[e.sprite]}),mt(r.glyphs,e.glyphs)||i.push({command:"setGlyphs",args:[e.glyphs]}),mt(r.transition,e.transition)||i.push({command:"setTransition",args:[e.transition]}),mt(r.light,e.light)||i.push({command:"setLight",args:[e.light]}),mt(r.terrain,e.terrain)||i.push({command:"setTerrain",args:[e.terrain]}),mt(r.sky,e.sky)||i.push({command:"setSky",args:[e.sky]}),mt(r.projection,e.projection)||i.push({command:"setProjection",args:[e.projection]});const s={},o=[];(function(h,f,g,y){let v;for(v in f=f||{},h=h||{})Object.prototype.hasOwnProperty.call(h,v)&&(Object.prototype.hasOwnProperty.call(f,v)||gi(v,g,y));for(v in f)Object.prototype.hasOwnProperty.call(f,v)&&(Object.prototype.hasOwnProperty.call(h,v)?mt(h[v],f[v])||(h[v].type==="geojson"&&f[v].type==="geojson"&&si(h,f,v)?Kt(g,{command:"setGeoJSONSourceData",args:[v,f[v].data]}):zi(v,f,g,y)):ar(v,f,g))})(r.sources,e.sources,o,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(o),(function(h,f,g){f=f||[];const y=(h=h||[]).map(Ns),v=f.map(Ns),w=h.reduce(Us,{}),S=f.reduce(Us,{}),M=y.slice(),A=Object.create(null);let z,R,j,X,N;for(let G=0,K=0;G<y.length;G++)z=y[G],Object.prototype.hasOwnProperty.call(S,z)?K++:(Kt(g,{command:"removeLayer",args:[z]}),M.splice(M.indexOf(z,K),1));for(let G=0,K=0;G<v.length;G++)z=v[v.length-1-G],M[M.length-1-G]!==z&&(Object.prototype.hasOwnProperty.call(w,z)?(Kt(g,{command:"removeLayer",args:[z]}),M.splice(M.lastIndexOf(z,M.length-K),1)):K++,X=M[M.length-G],Kt(g,{command:"addLayer",args:[S[z],X]}),M.splice(M.length-G,0,z),A[z]=!0);for(let G=0;G<v.length;G++)if(z=v[G],R=w[z],j=S[z],!A[z]&&!mt(R,j))if(mt(R.source,j.source)&&mt(R["source-layer"],j["source-layer"])&&mt(R.type,j.type)){for(N in $i(R.layout,j.layout,g,z,null,"setLayoutProperty"),$i(R.paint,j.paint,g,z,null,"setPaintProperty"),mt(R.filter,j.filter)||Kt(g,{command:"setFilter",args:[z,j.filter]}),mt(R.minzoom,j.minzoom)&&mt(R.maxzoom,j.maxzoom)||Kt(g,{command:"setLayerZoomRange",args:[z,j.minzoom,j.maxzoom]}),R)Object.prototype.hasOwnProperty.call(R,N)&&N!=="layout"&&N!=="paint"&&N!=="filter"&&N!=="metadata"&&N!=="minzoom"&&N!=="maxzoom"&&(N.indexOf("paint.")===0?$i(R[N],j[N],g,z,N.slice(6),"setPaintProperty"):mt(R[N],j[N])||Kt(g,{command:"setLayerProperty",args:[z,N,j[N]]}));for(N in j)Object.prototype.hasOwnProperty.call(j,N)&&!Object.prototype.hasOwnProperty.call(R,N)&&N!=="layout"&&N!=="paint"&&N!=="filter"&&N!=="metadata"&&N!=="minzoom"&&N!=="maxzoom"&&(N.indexOf("paint.")===0?$i(R[N],j[N],g,z,N.slice(6),"setPaintProperty"):mt(R[N],j[N])||Kt(g,{command:"setLayerProperty",args:[z,N,j[N]]}))}else Kt(g,{command:"removeLayer",args:[z]}),X=M[M.lastIndexOf(z)+1],Kt(g,{command:"addLayer",args:[j,X]})})(u,e.layers,i)}catch(s){console.warn("Unable to compute style diff:",s),i=[{command:"setStyle",args:[e]}]}return i},P.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},P.bY=Lt,P.bZ=ct,P.b_=class extends Ir{constructor(r,e){super(r,e),this.current=0}set(r){this.current!==r&&(this.current=r,this.gl.uniform1i(this.location,r))}},P.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},P.bb=function(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]+r[3]},P.bc=hf,P.bd=Vo,P.be=function(r,e,i,s,o){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,o!=null&&o!==1/0){var h=1/(s-o);r[10]=(o+s)*h,r[14]=2*o*s*h}else r[10]=-1,r[14]=-2*s;return r},P.bf=function(r){var e=new st(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},P.bg=function(r,e,i){var s=Math.sin(i),o=Math.cos(i),u=e[0],h=e[1],f=e[2],g=e[3],y=e[4],v=e[5],w=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*o+y*s,r[1]=h*o+v*s,r[2]=f*o+w*s,r[3]=g*o+S*s,r[4]=y*o-u*s,r[5]=v*o-h*s,r[6]=w*o-f*s,r[7]=S*o-g*s,r},P.bh=function(r,e,i){var s=Math.sin(i),o=Math.cos(i),u=e[4],h=e[5],f=e[6],g=e[7],y=e[8],v=e[9],w=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*o+y*s,r[5]=h*o+v*s,r[6]=f*o+w*s,r[7]=g*o+S*s,r[8]=y*o-u*s,r[9]=v*o-h*s,r[10]=w*o-f*s,r[11]=S*o-g*s,r},P.bi=function(){const r=new Float32Array(16);return Qt(r),r},P.bj=function(){const r=new Float64Array(16);return Qt(r),r},P.bk=function(){return new Float64Array(16)},P.bl=function(r,e,i){const s=new Float64Array(4);return ei(s,r,e-90,i),s},P.bm=function(r,e,i,s){var o,u,h,f,g,y=e[0],v=e[1],w=e[2],S=e[3],M=i[0],A=i[1],z=i[2],R=i[3];return(u=y*M+v*A+w*z+S*R)<0&&(u=-u,M=-M,A=-A,z=-z,R=-R),1-u>zt?(o=Math.acos(u),h=Math.sin(o),f=Math.sin((1-s)*o)/h,g=Math.sin(s*o)/h):(f=1-s,g=s),r[0]=f*y+g*M,r[1]=f*v+g*A,r[2]=f*w+g*z,r[3]=f*S+g*R,r},P.bn=function(r){const e=new Float64Array(9);(function(u,h){var f=h[0],g=h[1],y=h[2],v=h[3],w=f+f,S=g+g,M=y+y,A=f*w,z=g*w,R=g*S,j=y*w,X=y*S,N=y*M,G=v*w,K=v*S,te=v*M;u[0]=1-R-N,u[3]=z-te,u[6]=j+K,u[1]=z+te,u[4]=1-A-N,u[7]=X-G,u[2]=j-K,u[5]=X+G,u[8]=1-A-R})(e,r);const i=vi(-Math.asin(Ut(e[2],-1,1)));let s,o;return Math.hypot(e[5],e[8])<.001?(s=0,o=-vi(Math.atan2(e[3],e[4]))):(s=vi(e[5]===0&&e[8]===0?0:Math.atan2(e[5],e[8])),o=vi(e[1]===0&&e[0]===0?0:Math.atan2(e[1],e[0]))),{roll:s,pitch:i+90,bearing:o}},P.bo=function(r,e){return r.roll==e.roll&&r.pitch==e.pitch&&r.bearing==e.bearing},P.bp=Mt,P.bq=es,P.br=Fo,P.bs=ec,P.bt=Ro,P.bu=_t,P.bv=tt,P.bw=br,P.bx=function(r,e,i,s,o){return _t(s,o,Ut((r-e)/(i-e),0,1))},P.by=ht,P.bz=function(){return new Float64Array(3)},P.c=ne,P.c$=function(r,e,i,s,o){return c(this,void 0,void 0,(function*(){if(Xt())try{return yield mr(r,e,i,s,o)}catch{}return(function(u,h,f,g,y){const v=u.width,w=u.height;gr&&Oi||(gr=new OffscreenCanvas(v,w),Oi=gr.getContext("2d",{willReadFrequently:!0})),gr.width=v,gr.height=w,Oi.drawImage(u,0,0,v,w);const S=Oi.getImageData(h,f,g,y);return Oi.clearRect(0,0,v,w),S.data})(r,e,i,s,o)}))},P.c0=class extends Ir{constructor(r,e){super(r,e),this.current=qr}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}}},P.c1=Ea,P.c2=class extends Ir{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]))}},P.c3=class extends Ir{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]))}},P.c4=fi,P.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},P.c6=function(r,e,i){var s=e[0],o=e[1],u=e[2];return r[0]=s*i[0]+o*i[3]+u*i[6],r[1]=s*i[1]+o*i[4]+u*i[7],r[2]=s*i[2]+o*i[5]+u*i[8],r},P.c7=function(r,e,i,s,o,u,h){var f=1/(e-i),g=1/(s-o),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]=(o+s)*g,r[14]=(h+u)*y,r[15]=1,r},P.c8=class extends Ir{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)}}},P.c9=class extends Ir{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)}}},P.cA=function(r,e){return ce[e]&&"touches"in r},P.cB=function(r){return ce[r]||B[r]},P.cC=function(r,e,i){var s=e[0],o=e[1];return r[0]=i[0]*s+i[4]*o+i[12],r[1]=i[1]*s+i[5]*o+i[13],r},P.cD=function(r,e){const{x:i,y:s}=ac.fromLngLat(e);return!(r<0||r>25||s<0||s>=1||i<0||i>=1)},P.cE=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},P.cF=class extends To{},P.cG=Zy,P.cI=ae,P.cJ=function(r,e){ne.REGISTERED_PROTOCOLS[r]=e},P.cK=function(r){delete ne.REGISTERED_PROTOCOLS[r]},P.cL=function(r,e){const i={};for(let o=0;o<r.length;o++){const u=e&&e[r[o].id]||Qc(r[o]);e&&(e[r[o].id]=u);let h=i[u];h||(h=i[u]=[]),h.push(r[o])}const s=[];for(const o in i)s.push(i[o]);return s},P.cM=Xe,P.cN=pf,P.cO=Zf,P.cP=Wp,P.cQ=function(r){r.bucket.createArrays(),r.bucket.tilePixelRatio=Ze/(512*r.bucket.overscaling),r.bucket.compareText={},r.bucket.iconsNeedLinear=!1;const e=r.bucket.layers[0],i=e.layout,s=e._unevaluatedLayout._values,o={layoutIconSize:s["icon-size"].possiblyEvaluate(new ii(r.bucket.zoom+1),r.canonical),layoutTextSize:s["text-size"].possiblyEvaluate(new ii(r.bucket.zoom+1),r.canonical),textMaxSize:s["text-size"].possiblyEvaluate(new ii(18))};if(r.bucket.textSizeData.kind==="composite"){const{minZoom:y,maxZoom:v}=r.bucket.textSizeData;o.compositeTextSizes=[s["text-size"].possiblyEvaluate(new ii(y),r.canonical),s["text-size"].possiblyEvaluate(new ii(v),r.canonical)]}if(r.bucket.iconSizeData.kind==="composite"){const{minZoom:y,maxZoom:v}=r.bucket.iconSizeData;o.compositeIconSizes=[s["icon-size"].possiblyEvaluate(new ii(y),r.canonical),s["icon-size"].possiblyEvaluate(new ii(v),r.canonical)]}const u=i.get("text-line-height")*er,h=i.get("text-rotation-alignment")!=="viewport"&&i.get("symbol-placement")!=="point",f=i.get("text-keep-upright"),g=i.get("text-size");for(const y of r.bucket.features){const v=i.get("text-font").evaluate(y,{},r.canonical).join(","),w=g.evaluate(y,{},r.canonical),S=o.layoutTextSize.evaluate(y,{},r.canonical),M=o.layoutIconSize.evaluate(y,{},r.canonical),A={horizontal:{},vertical:void 0},z=y.text;let R,j=[0,0];if(z){const G=z.toString(),K=i.get("text-letter-spacing").evaluate(y,{},r.canonical)*er,te=Ih(G)?K:0,me=i.get("text-anchor").evaluate(y,{},r.canonical),Ie=nm(e,y,r.canonical);if(!Ie){const ze=i.get("text-radial-offset").evaluate(y,{},r.canonical);j=ze?rm(me,[ze*er,xd]):i.get("text-offset").evaluate(y,{},r.canonical).map((Me=>Me*er))}let Se=h?"center":i.get("text-justify").evaluate(y,{},r.canonical);const Ce=i.get("symbol-placement")==="point"?i.get("text-max-width").evaluate(y,{},r.canonical)*er:1/0,Ve=()=>{r.bucket.allowVerticalPlacement&&ks(G)&&(A.vertical=Du(z,r.glyphMap,r.glyphPositions,r.imagePositions,v,Ce,u,me,"left",te,j,P.az.vertical,!0,S,w))};if(!h&&Ie){const ze=new Set;if(Se==="auto")for(let be=0;be<Ie.values.length;be+=2)ze.add(vd(Ie.values[be]));else ze.add(Se);let Me=!1;for(const be of ze)if(!A.horizontal[be])if(Me)A.horizontal[be]=A.horizontal[0];else{const He=Du(z,r.glyphMap,r.glyphPositions,r.imagePositions,v,Ce,u,"center",be,te,j,P.az.horizontal,!1,S,w);He&&(A.horizontal[be]=He,Me=He.positionedLines.length===1)}Ve()}else{Se==="auto"&&(Se=vd(me));const ze=Du(z,r.glyphMap,r.glyphPositions,r.imagePositions,v,Ce,u,me,Se,te,j,P.az.horizontal,!1,S,w);ze&&(A.horizontal[Se]=ze),Ve(),ks(G)&&h&&f&&(A.vertical=Du(z,r.glyphMap,r.glyphPositions,r.imagePositions,v,Ce,u,me,Se,te,j,P.az.vertical,!1,S,w))}}let X=!1;if(y.icon&&y.icon.name){const G=r.imageMap[y.icon.name];G&&(R=ey(r.imagePositions[y.icon.name],i.get("icon-offset").evaluate(y,{},r.canonical),i.get("icon-anchor").evaluate(y,{},r.canonical)),X=!!G.sdf,r.bucket.sdfIcons===void 0?r.bucket.sdfIcons=X:r.bucket.sdfIcons!==X&&yt("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(G.pixelRatio!==r.bucket.pixelRatio||i.get("icon-rotate").constantOr(1)!==0)&&(r.bucket.iconsNeedLinear=!0))}const N=am(A.horizontal)||A.vertical;r.bucket.iconsInText=!!N&&N.iconsInText,(N||R)&&Gy(r.bucket,y,A,R,r.imageMap,o,S,M,j,X,r.canonical,r.subdivisionGranularity)}r.showCollisionBoxes&&r.bucket.generateCollisionDebugBuffers()},P.cR=Uh,P.cS=qh,P.cT=Zh,P.cU=function(r){const e=new Au;return(function(i,s){for(const o in i.layers)s.writeMessage(3,Cy,i.layers[o])})(r,e),e.finish()},P.cV=function(r,e,i,s,o,u){let h=Hf(r,e,i,o,0);return h=Hf(h,e,s,u,1),h},P.cW=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()}},P.cX=Cp,P.cY=Au,P.cZ=Gf,P.c_=class{constructor(r){this._marks={start:[r.url,"start"].join("#"),end:[r.url,"end"].join("#"),measure:r.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let r=performance.getEntriesByName(this._marks.measure);return r.length===0&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),r=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),r}},P.ca=class extends Jn{},P.cb=z_,P.cc=class extends Ia{},P.cd=Bh,P.ce=function(r){return r<=1?1:Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))},P.cf=fp,P.cg=function(r,e,i){var s=e[0],o=e[1],u=e[2],h=i[3]*s+i[7]*o+i[11]*u+i[15];return r[0]=(i[0]*s+i[4]*o+i[8]*u+i[12])/(h=h||1),r[1]=(i[1]*s+i[5]*o+i[9]*u+i[13])/h,r[2]=(i[2]*s+i[6]*o+i[10]*u+i[14])/h,r},P.ch=class extends jl{},P.ci=class extends t{},P.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]},P.ck=function(r,e){var i=r[0],s=r[1],o=r[2],u=r[3],h=r[4],f=r[5],g=r[6],y=r[7],v=r[8],w=r[9],S=r[10],M=r[11],A=r[12],z=r[13],R=r[14],j=r[15],X=e[0],N=e[1],G=e[2],K=e[3],te=e[4],me=e[5],Ie=e[6],Se=e[7],Ce=e[8],Ve=e[9],ze=e[10],Me=e[11],be=e[12],He=e[13],$e=e[14],Ke=e[15];return Math.abs(i-X)<=zt*Math.max(1,Math.abs(i),Math.abs(X))&&Math.abs(s-N)<=zt*Math.max(1,Math.abs(s),Math.abs(N))&&Math.abs(o-G)<=zt*Math.max(1,Math.abs(o),Math.abs(G))&&Math.abs(u-K)<=zt*Math.max(1,Math.abs(u),Math.abs(K))&&Math.abs(h-te)<=zt*Math.max(1,Math.abs(h),Math.abs(te))&&Math.abs(f-me)<=zt*Math.max(1,Math.abs(f),Math.abs(me))&&Math.abs(g-Ie)<=zt*Math.max(1,Math.abs(g),Math.abs(Ie))&&Math.abs(y-Se)<=zt*Math.max(1,Math.abs(y),Math.abs(Se))&&Math.abs(v-Ce)<=zt*Math.max(1,Math.abs(v),Math.abs(Ce))&&Math.abs(w-Ve)<=zt*Math.max(1,Math.abs(w),Math.abs(Ve))&&Math.abs(S-ze)<=zt*Math.max(1,Math.abs(S),Math.abs(ze))&&Math.abs(M-Me)<=zt*Math.max(1,Math.abs(M),Math.abs(Me))&&Math.abs(A-be)<=zt*Math.max(1,Math.abs(A),Math.abs(be))&&Math.abs(z-He)<=zt*Math.max(1,Math.abs(z),Math.abs(He))&&Math.abs(R-$e)<=zt*Math.max(1,Math.abs(R),Math.abs($e))&&Math.abs(j-Ke)<=zt*Math.max(1,Math.abs(j),Math.abs(Ke))},P.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},P.cm=r=>r.type==="symbol",P.cn=r=>r.type==="circle",P.co=r=>r.type==="heatmap",P.cp=r=>r.type==="line",P.cq=r=>r.type==="fill",P.cr=r=>r.type==="fill-extrusion",P.cs=r=>r.type==="hillshade",P.ct=r=>r.type==="color-relief",P.cu=r=>r.type==="background",P.cv=r=>r.type==="custom",P.cw=Yt,P.cx=function(r,e,i){const s=Nt(e.x-i.x,e.y-i.y),o=Nt(r.x-i.x,r.y-i.y),u=Math.atan2(s[0]*o[1]-s[1]*o[0],(function(h,f){return h[0]*f[0]+h[1]*f[1]})(s,o));return vi(u)},P.cy=Tt,P.cz=function(r,e){return B[e]&&(r instanceof MouseEvent||r instanceof WheelEvent)},P.d=Ee,P.d0=_p,P.d1=Pe,P.d2=class{constructor(r,e){this.layers={[cc]:this},this.name=cc,this.version=e?e.version:1,this.extent=e?e.extent:4096,this.length=r.length,this.features=r}feature(r){return new Ey(this.features[r],this.extent)}},P.d3=aa,P.d4=An,P.e=lt,P.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.`)}})),P.g=fe,P.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=Wt}))},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 o=new Blob([new Uint8Array(r)],{type:"image/png"});s.src=r.byteLength?URL.createObjectURL(o):Wt})),P.i=xt,P.j=(r,e)=>ke(lt(r,{type:"json"}),e),P.k=ti,P.l=ft,P.m=ke,P.n=(r,e)=>ke(lt(r,{type:"arrayBuffer"}),e),P.o=function(r){return new Au(r).readFields($_,[])},P.p=$p,P.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))},P.r=Xl,P.s=Or,P.t=Tr,P.u=ye,P.v=fa,P.w=yt,P.x=Ol,P.y=ma,P.z=xa})),Q("worker",["./shared"],(function(P){class c{constructor(B,O){this.keyCache={},B&&this.replace(B,O)}replace(B,O){this._layerConfigs={},this._layers={},this.update(B,[],O)}update(B,O,U){for(const ne of B){this._layerConfigs[ne.id]=ne;const fe=this._layers[ne.id]=P.bT(ne,U);fe._featureFilter=P.aj(fe.filter,U),this.keyCache[ne.id]&&delete this.keyCache[ne.id]}for(const ne of O)delete this.keyCache[ne],delete this._layerConfigs[ne],delete this._layers[ne];this.familiesBySource={};const re=P.cL(Object.values(this._layerConfigs),this.keyCache);for(const ne of re){const fe=ne.map((We=>this._layers[We.id])),de=fe[0];if(de.isHidden())continue;const ae=de.source||"";let we=this.familiesBySource[ae];we||(we=this.familiesBySource[ae]={});const ke=de.sourceLayer||P.ai;let Ee=we[ke];Ee||(Ee=we[ke]=[]),Ee.push(fe)}}}class le{constructor(B){const O={},U=[];for(const de in B){const ae=B[de],we=O[de]={};for(const ke in ae){const Ee=ae[+ke];if(!Ee||Ee.bitmap.width===0||Ee.bitmap.height===0)continue;const We={x:0,y:0,w:Ee.bitmap.width+2,h:Ee.bitmap.height+2};U.push(We),we[ke]={rect:We,metrics:Ee.metrics}}}const{w:re,h:ne}=P.p(U),fe=new P.r({width:re||1,height:ne||1});for(const de in B){const ae=B[de];for(const we in ae){const ke=ae[+we];if(!ke||ke.bitmap.width===0||ke.bitmap.height===0)continue;const Ee=O[de][we].rect;P.r.copy(ke.bitmap,fe,{x:0,y:0},{x:Ee.x+1,y:Ee.y+1},ke.bitmap)}}this.image=fe,this.positions=O}}P.cM("GlyphAtlas",le);class Pe{constructor(B){this.tileID=new P.a2(B.tileID.overscaledZ,B.tileID.wrap,B.tileID.canonical.z,B.tileID.canonical.x,B.tileID.canonical.y),this.uid=B.uid,this.zoom=B.zoom,this.pixelRatio=B.pixelRatio,this.tileSize=B.tileSize,this.source=B.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=B.showCollisionBoxes,this.collectResourceTiming=!!B.collectResourceTiming,this.returnDependencies=!!B.returnDependencies,this.promoteId=B.promoteId,this.inFlightDependencies=[]}parse(B,O,U,re,ne){return P._(this,void 0,void 0,(function*(){this.status="parsing",this.data=B,this.collisionBoxArray=new P.ag;const fe=new P.cN(Object.keys(B.layers).sort()),de=new P.cO(this.tileID,this.promoteId);de.bucketLayerIDs=[];const ae={},we={featureIndex:de,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:U,subdivisionGranularity:ne},ke=O.familiesBySource[this.source];for(const si in ke){const $i=B.layers[si];if(!$i)continue;$i.version===1&&P.w(`Vector tile source "${this.source}" layer "${si}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const Ns=fe.encode(si),Us=[];for(let Re=0;Re<$i.length;Re++){const _r=$i.feature(Re),yr=de.getId(_r,si);Us.push({feature:_r,id:yr,index:Re,sourceLayerIndex:Ns})}for(const Re of ke[si]){const _r=Re[0];_r.source!==this.source&&P.w(`layer.source = ${_r.source} does not equal this.source = ${this.source}`),_r.isHidden(this.zoom,!0)||(Be(Re,this.zoom,U),(ae[_r.id]=_r.createBucket({index:de.bucketLayerIDs.length,layers:Re,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Ns,sourceID:this.source})).populate(Us,we,this.tileID.canonical),de.bucketLayerIDs.push(Re.map((yr=>yr.id))))}}const Ee=P.bY(we.glyphDependencies,(si=>Object.keys(si).map(Number)));this.inFlightDependencies.forEach((si=>si==null?void 0:si.abort())),this.inFlightDependencies=[];let We=Promise.resolve({});if(Object.keys(Ee).length){const si=new AbortController;this.inFlightDependencies.push(si),We=re.sendAsync({type:"GG",data:{stacks:Ee,source:this.source,tileID:this.tileID,type:"glyphs"}},si)}const Qe=Object.keys(we.iconDependencies);let ft=Promise.resolve({});if(Qe.length){const si=new AbortController;this.inFlightDependencies.push(si),ft=re.sendAsync({type:"GI",data:{icons:Qe,source:this.source,tileID:this.tileID,type:"icons"}},si)}const ti=Object.keys(we.patternDependencies);let Gt=Promise.resolve({});if(ti.length){const si=new AbortController;this.inFlightDependencies.push(si),Gt=re.sendAsync({type:"GI",data:{icons:ti,source:this.source,tileID:this.tileID,type:"patterns"}},si)}const ye=we.dashDependencies;let ni=Promise.resolve({});if(Object.keys(ye).length){const si=new AbortController;this.inFlightDependencies.push(si),ni=re.sendAsync({type:"GDA",data:{dashes:ye}},si)}const[sr,mt,Kt,ar]=yield Promise.all([We,ft,Gt,ni]),gi=new le(sr),zi=new P.cP(mt,Kt);for(const si in ae){const $i=ae[si];$i instanceof P.ah?(Be($i.layers,this.zoom,U),P.cQ({bucket:$i,glyphMap:sr,glyphPositions:gi.positions,imageMap:mt,imagePositions:zi.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:we.subdivisionGranularity})):$i.hasDependencies&&($i instanceof P.cR||$i instanceof P.cS||$i instanceof P.cT)&&(Be($i.layers,this.zoom,U),$i.addFeatures(we,this.tileID.canonical,zi.patternPositions,ar))}return this.status="done",{buckets:Object.values(ae).filter((si=>!si.isEmpty())),featureIndex:de,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:gi.image,imageAtlas:zi,dashPositions:ar,glyphMap:this.returnDependencies?sr:null,iconMap:this.returnDependencies?mt:null,glyphPositions:this.returnDependencies?gi.positions:null}}))}}function Be(ce,B,O){const U=new P.H(B);for(const re of ce)re.recalculate(U,O)}class Ne{constructor(B,O,U,re,ne){this.type=B,this.properties=U||{},this.extent=ne,this.pointsArray=O,this.id=re}loadGeometry(){return this.pointsArray.map((B=>B.map((O=>new P.P(O.x,O.y)))))}}class Ye{constructor(B,O,U){this.version=2,this._myFeatures=B,this.name=O,this.length=B.length,this.extent=U}feature(B){return this._myFeatures[B]}}class rt{constructor(){this.layers={}}addLayer(B){this.layers[B.name]=B}}function Ct(ce){let B=P.cU(ce);return B.byteOffset===0&&B.byteLength===B.buffer.byteLength||(B=new Uint8Array(B)),{vectorTile:ce,rawData:B.buffer}}function Je(ce,B,O){const{extent:U}=ce,re=Math.pow(2,O.z-B.z),ne=(O.x-B.x*re)*U,fe=(O.y-B.y*re)*U,de=[];for(let ae=0;ae<ce.length;ae++){const we=ce.feature(ae);let ke=we.loadGeometry();for(const We of ke)for(const Qe of We)Qe.x=Qe.x*re-ne,Qe.y=Qe.y*re-fe;const Ee=128;ke=P.cV(ke,we.type,-Ee,-Ee,U+Ee,U+Ee),ke.length!==0&&de.push(new Ne(we.type,ke,we.properties,we.id,U))}return new Ye(de,ce.name,U)}class ge{constructor(B,O,U){this.actor=B,this.layerIndex=O,this.availableImages=U,this.fetching={},this.loading={},this.loaded={},this.overzoomedTileResultCache=new P.cW(1e3)}loadVectorTile(B,O){return P._(this,void 0,void 0,(function*(){const U=yield P.n(B.request,O);try{return{vectorTile:B.encoding!=="mlt"?new P.cX(new P.cY(U.data)):new P.cZ(U.data),rawData:U.data,cacheControl:U.cacheControl,expires:U.expires}}catch(re){const ne=new Uint8Array(U.data);let fe=`Unable to parse the tile at ${B.request.url}, `;throw fe+=ne[0]===31&&ne[1]===139?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${re.message}`,new Error(fe)}}))}loadTile(B){return P._(this,void 0,void 0,(function*(){const{uid:O,overzoomParameters:U}=B;U&&(B.request=U.overzoomRequest);const re=!!(B&&B.request&&B.request.collectResourceTiming)&&new P.c_(B.request),ne=new Pe(B);this.loading[O]=ne;const fe=new AbortController;ne.abort=fe;try{const de=yield this.loadVectorTile(B,fe);if(delete this.loading[O],!de)return null;if(U){const We=this._getOverzoomTile(B,de.vectorTile);de.rawData=We.rawData,de.vectorTile=We.vectorTile}const ae=de.rawData,we={};de.expires&&(we.expires=de.expires),de.cacheControl&&(we.cacheControl=de.cacheControl);const ke={};if(re){const We=re.finish();We&&(ke.resourceTiming=JSON.parse(JSON.stringify(We)))}ne.vectorTile=de.vectorTile;const Ee=ne.parse(de.vectorTile,this.layerIndex,this.availableImages,this.actor,B.subdivisionGranularity);this.loaded[O]=ne,this.fetching[O]={rawTileData:ae,cacheControl:we,resourceTiming:ke};try{const We=yield Ee;return P.e({rawTileData:ae.slice(0),encoding:B.encoding},We,we,ke)}finally{delete this.fetching[O]}}catch(de){throw delete this.loading[O],ne.status="done",this.loaded[O]=ne,de}}))}_getOverzoomTile(B,O){const{tileID:U,source:re,overzoomParameters:ne}=B,{maxZoomTileID:fe}=ne,de=`${fe.key}_${U.key}`,ae=this.overzoomedTileResultCache.get(de);if(ae)return ae;const we=new rt,ke=this.layerIndex.familiesBySource[re];for(const We in ke){const Qe=O.layers[We];if(!Qe)continue;const ft=Je(Qe,fe,U.canonical);ft.length>0&&we.addLayer(ft)}const Ee=Ct(we);return this.overzoomedTileResultCache.set(de,Ee),Ee}reloadTile(B){return P._(this,void 0,void 0,(function*(){const O=B.uid;if(!this.loaded||!this.loaded[O])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const U=this.loaded[O];if(U.showCollisionBoxes=B.showCollisionBoxes,U.status==="parsing"){const re=yield U.parse(U.vectorTile,this.layerIndex,this.availableImages,this.actor,B.subdivisionGranularity);let ne;if(this.fetching[O]){const{rawTileData:fe,cacheControl:de,resourceTiming:ae}=this.fetching[O];delete this.fetching[O],ne=P.e({rawTileData:fe.slice(0),encoding:B.encoding},re,de,ae)}else ne=re;return ne}if(U.status==="done"&&U.vectorTile)return U.parse(U.vectorTile,this.layerIndex,this.availableImages,this.actor,B.subdivisionGranularity)}))}abortTile(B){return P._(this,void 0,void 0,(function*(){const O=this.loading,U=B.uid;O&&O[U]&&O[U].abort&&(O[U].abort.abort(),delete O[U])}))}removeTile(B){return P._(this,void 0,void 0,(function*(){this.loaded&&this.loaded[B.uid]&&delete this.loaded[B.uid]}))}}class Xt{constructor(){this.loaded={}}loadTile(B){return P._(this,void 0,void 0,(function*(){const{uid:O,encoding:U,rawImageData:re,redFactor:ne,greenFactor:fe,blueFactor:de,baseShift:ae}=B,we=re.width+2,ke=re.height+2,Ee=P.b(re)?new P.R({width:we,height:ke},yield P.c$(re,-1,-1,we,ke)):re,We=new P.d0(O,Ee,U,ne,fe,de,ae);return this.loaded=this.loaded||{},this.loaded[O]=We,We}))}removeTile(B){const O=this.loaded,U=B.uid;O&&O[U]&&delete O[U]}}var zt,st,fi=(function(){if(st)return zt;function ce(O,U){if(O.length!==0){B(O[0],U);for(var re=1;re<O.length;re++)B(O[re],!U)}}function B(O,U){for(var re=0,ne=0,fe=0,de=O.length,ae=de-1;fe<de;ae=fe++){var we=(O[fe][0]-O[ae][0])*(O[ae][1]+O[fe][1]),ke=re+we;ne+=Math.abs(re)>=Math.abs(we)?re-ke+we:we-ke+re,re=ke}re+ne>=0!=!!U&&O.reverse()}return st=1,zt=function O(U,re){var ne,fe=U&&U.type;if(fe==="FeatureCollection")for(ne=0;ne<U.features.length;ne++)O(U.features[ne],re);else if(fe==="GeometryCollection")for(ne=0;ne<U.geometries.length;ne++)O(U.geometries[ne],re);else if(fe==="Feature")O(U.geometry,re);else if(fe==="Polygon")ce(U.coordinates,re);else if(fe==="MultiPolygon")for(ne=0;ne<U.coordinates.length;ne++)ce(U.coordinates[ne],re);return U}})(),Qt=P.d1(fi);const Mi={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:ce=>ce},dt=Math.fround||(he=new Float32Array(1),ce=>(he[0]=+ce,he[0]));var he;class pe{constructor(B){this.options=Object.assign(Object.create(Mi),B),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(B){const{log:O,minZoom:U,maxZoom:re}=this.options;O&&console.time("total time");const ne=`prepare ${B.length} points`;O&&console.time(ne),this.points=B;const fe=[];for(let ae=0;ae<B.length;ae++){const we=B[ae];if(!we.geometry)continue;const[ke,Ee]=we.geometry.coordinates,We=dt(je(ke)),Qe=dt(at(Ee));fe.push(We,Qe,1/0,ae,-1,1),this.options.reduce&&fe.push(0)}let de=this.trees[re+1]=this._createTree(fe);O&&console.timeEnd(ne);for(let ae=re;ae>=U;ae--){const we=+Date.now();de=this.trees[ae]=this._createTree(this._cluster(de,ae)),O&&console.log("z%d: %d clusters in %dms",ae,de.numItems,+Date.now()-we)}return O&&console.timeEnd("total time"),this}getClusters(B,O){let U=((B[0]+180)%360+360)%360-180;const re=Math.max(-90,Math.min(90,B[1]));let ne=B[2]===180?180:((B[2]+180)%360+360)%360-180;const fe=Math.max(-90,Math.min(90,B[3]));if(B[2]-B[0]>=360)U=-180,ne=180;else if(U>ne){const Ee=this.getClusters([U,re,180,fe],O),We=this.getClusters([-180,re,ne,fe],O);return Ee.concat(We)}const de=this.trees[this._limitZoom(O)],ae=de.range(je(U),at(fe),je(ne),at(re)),we=de.data,ke=[];for(const Ee of ae){const We=this.stride*Ee;ke.push(we[We+5]>1?De(we,We,this.clusterProps):this.points[we[We+3]])}return ke}getChildren(B){const O=this._getOriginId(B),U=this._getOriginZoom(B),re="No cluster with the specified id.",ne=this.trees[U];if(!ne)throw new Error(re);const fe=ne.data;if(O*this.stride>=fe.length)throw new Error(re);const de=this.options.radius/(this.options.extent*Math.pow(2,U-1)),ae=ne.within(fe[O*this.stride],fe[O*this.stride+1],de),we=[];for(const ke of ae){const Ee=ke*this.stride;fe[Ee+4]===B&&we.push(fe[Ee+5]>1?De(fe,Ee,this.clusterProps):this.points[fe[Ee+3]])}if(we.length===0)throw new Error(re);return we}getLeaves(B,O,U){const re=[];return this._appendLeaves(re,B,O=O||10,U=U||0,0),re}getTile(B,O,U){const re=this.trees[this._limitZoom(B)],ne=Math.pow(2,B),{extent:fe,radius:de}=this.options,ae=de/fe,we=(U-ae)/ne,ke=(U+1+ae)/ne,Ee={features:[]};return this._addTileFeatures(re.range((O-ae)/ne,we,(O+1+ae)/ne,ke),re.data,O,U,ne,Ee),O===0&&this._addTileFeatures(re.range(1-ae/ne,we,1,ke),re.data,ne,U,ne,Ee),O===ne-1&&this._addTileFeatures(re.range(0,we,ae/ne,ke),re.data,-1,U,ne,Ee),Ee.features.length?Ee:null}getClusterExpansionZoom(B){let O=this._getOriginZoom(B)-1;for(;O<=this.options.maxZoom;){const U=this.getChildren(B);if(O++,U.length!==1)break;B=U[0].properties.cluster_id}return O}_appendLeaves(B,O,U,re,ne){const fe=this.getChildren(O);for(const de of fe){const ae=de.properties;if(ae&&ae.cluster?ne+ae.point_count<=re?ne+=ae.point_count:ne=this._appendLeaves(B,ae.cluster_id,U,re,ne):ne<re?ne++:B.push(de),B.length===U)break}return ne}_createTree(B){const O=new P.aT(B.length/this.stride|0,this.options.nodeSize,Float32Array);for(let U=0;U<B.length;U+=this.stride)O.add(B[U],B[U+1]);return O.finish(),O.data=B,O}_addTileFeatures(B,O,U,re,ne,fe){for(const de of B){const ae=de*this.stride,we=O[ae+5]>1;let ke,Ee,We;if(we)ke=Oe(O,ae,this.clusterProps),Ee=O[ae],We=O[ae+1];else{const ti=this.points[O[ae+3]];ke=ti.properties;const[Gt,ye]=ti.geometry.coordinates;Ee=je(Gt),We=at(ye)}const Qe={type:1,geometry:[[Math.round(this.options.extent*(Ee*ne-U)),Math.round(this.options.extent*(We*ne-re))]],tags:ke};let ft;ft=we||this.options.generateId?O[ae+3]:this.points[O[ae+3]].id,ft!==void 0&&(Qe.id=ft),fe.features.push(Qe)}}_limitZoom(B){return Math.max(this.options.minZoom,Math.min(Math.floor(+B),this.options.maxZoom+1))}_cluster(B,O){const{radius:U,extent:re,reduce:ne,minPoints:fe}=this.options,de=U/(re*Math.pow(2,O)),ae=B.data,we=[],ke=this.stride;for(let Ee=0;Ee<ae.length;Ee+=ke){if(ae[Ee+2]<=O)continue;ae[Ee+2]=O;const We=ae[Ee],Qe=ae[Ee+1],ft=B.within(ae[Ee],ae[Ee+1],de),ti=ae[Ee+5];let Gt=ti;for(const ye of ft){const ni=ye*ke;ae[ni+2]>O&&(Gt+=ae[ni+5])}if(Gt>ti&&Gt>=fe){let ye,ni=We*ti,sr=Qe*ti,mt=-1;const Kt=(Ee/ke<<5)+(O+1)+this.points.length;for(const ar of ft){const gi=ar*ke;if(ae[gi+2]<=O)continue;ae[gi+2]=O;const zi=ae[gi+5];ni+=ae[gi]*zi,sr+=ae[gi+1]*zi,ae[gi+4]=Kt,ne&&(ye||(ye=this._map(ae,Ee,!0),mt=this.clusterProps.length,this.clusterProps.push(ye)),ne(ye,this._map(ae,gi)))}ae[Ee+4]=Kt,we.push(ni/Gt,sr/Gt,1/0,Kt,-1,Gt),ne&&we.push(mt)}else{for(let ye=0;ye<ke;ye++)we.push(ae[Ee+ye]);if(Gt>1)for(const ye of ft){const ni=ye*ke;if(!(ae[ni+2]<=O)){ae[ni+2]=O;for(let sr=0;sr<ke;sr++)we.push(ae[ni+sr])}}}}return we}_getOriginId(B){return B-this.points.length>>5}_getOriginZoom(B){return(B-this.points.length)%32}_map(B,O,U){if(B[O+5]>1){const fe=this.clusterProps[B[O+6]];return U?Object.assign({},fe):fe}const re=this.points[B[O+3]].properties,ne=this.options.map(re);return U&&ne===re?Object.assign({},ne):ne}}function De(ce,B,O){return{type:"Feature",id:ce[B+3],properties:Oe(ce,B,O),geometry:{type:"Point",coordinates:[(U=ce[B],360*(U-.5)),jt(ce[B+1])]}};var U}function Oe(ce,B,O){const U=ce[B+5],re=U>=1e4?`${Math.round(U/1e3)}k`:U>=1e3?Math.round(U/100)/10+"k":U,ne=ce[B+6],fe=ne===-1?{}:Object.assign({},O[ne]);return Object.assign(fe,{cluster:!0,cluster_id:ce[B+3],point_count:U,point_count_abbreviated:re})}function je(ce){return ce/360+.5}function at(ce){const B=Math.sin(ce*Math.PI/180),O=.5-.25*Math.log((1+B)/(1-B))/Math.PI;return O<0?0:O>1?1:O}function jt(ce){const B=(180-360*ce)*Math.PI/180;return 360*Math.atan(Math.exp(B))/Math.PI-90}function $t(ce,B,O,U){let re=U;const ne=B+(O-B>>1);let fe,de=O-B;const ae=ce[B],we=ce[B+1],ke=ce[O],Ee=ce[O+1];for(let We=B+3;We<O;We+=3){const Qe=ei(ce[We],ce[We+1],ae,we,ke,Ee);if(Qe>re)fe=We,re=Qe;else if(Qe===re){const ft=Math.abs(We-ne);ft<de&&(fe=We,de=ft)}}re>U&&(fe-B>3&&$t(ce,B,fe,U),ce[fe+2]=re,O-fe>3&&$t(ce,fe,O,U))}function ei(ce,B,O,U,re,ne){let fe=re-O,de=ne-U;if(fe!==0||de!==0){const ae=((ce-O)*fe+(B-U)*de)/(fe*fe+de*de);ae>1?(O=re,U=ne):ae>0&&(O+=fe*ae,U+=de*ae)}return fe=ce-O,de=B-U,fe*fe+de*de}function ot(ce,B,O,U){const re={id:ce??null,type:B,geometry:O,tags:U,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(B==="Point"||B==="MultiPoint"||B==="LineString")Nt(re,O);else if(B==="Polygon")Nt(re,O[0]);else if(B==="MultiLineString")for(const ne of O)Nt(re,ne);else if(B==="MultiPolygon")for(const ne of O)Nt(re,ne[0]);return re}function Nt(ce,B){for(let O=0;O<B.length;O+=3)ce.minX=Math.min(ce.minX,B[O]),ce.minY=Math.min(ce.minY,B[O+1]),ce.maxX=Math.max(ce.maxX,B[O]),ce.maxY=Math.max(ce.maxY,B[O+1])}function Ze(ce,B,O,U){if(!B.geometry)return;const re=B.geometry.coordinates;if(re&&re.length===0)return;const ne=B.geometry.type,fe=Math.pow(O.tolerance/((1<<O.maxZoom)*O.extent),2);let de=[],ae=B.id;if(O.promoteId?ae=B.properties[O.promoteId]:O.generateId&&(ae=U||0),ne==="Point")xi(re,de);else if(ne==="MultiPoint")for(const we of re)xi(we,de);else if(ne==="LineString")ht(re,de,fe,!1);else if(ne==="MultiLineString"){if(O.lineMetrics){for(const we of re)de=[],ht(we,de,fe,!1),ce.push(ot(ae,"LineString",de,B.properties));return}_t(re,de,fe,!1)}else if(ne==="Polygon")_t(re,de,fe,!0);else{if(ne!=="MultiPolygon"){if(ne==="GeometryCollection"){for(const we of B.geometry.geometries)Ze(ce,{id:ae,geometry:we,properties:B.properties},O,U);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const we of re){const ke=[];_t(we,ke,fe,!0),de.push(ke)}}ce.push(ot(ae,ne,de,B.properties))}function xi(ce,B){B.push(tt(ce[0]),Yt(ce[1]),0)}function ht(ce,B,O,U){let re,ne,fe=0;for(let ae=0;ae<ce.length;ae++){const we=tt(ce[ae][0]),ke=Yt(ce[ae][1]);B.push(we,ke,0),ae>0&&(fe+=U?(re*ke-we*ne)/2:Math.sqrt(Math.pow(we-re,2)+Math.pow(ke-ne,2))),re=we,ne=ke}const de=B.length-3;B[2]=1,$t(B,0,de,O),B[de+2]=1,B.size=Math.abs(fe),B.start=0,B.end=B.size}function _t(ce,B,O,U){for(let re=0;re<ce.length;re++){const ne=[];ht(ce[re],ne,O,U),B.push(ne)}}function tt(ce){return ce/360+.5}function Yt(ce){const B=Math.sin(ce*Math.PI/180),O=.5-.25*Math.log((1+B)/(1-B))/Math.PI;return O<0?0:O>1?1:O}function Tt(ce,B,O,U,re,ne,fe,de){if(U/=B,ne>=(O/=B)&&fe<U)return ce;if(fe<O||ne>=U)return null;const ae=[];for(const we of ce){const ke=we.geometry;let Ee=we.type;const We=re===0?we.minX:we.minY,Qe=re===0?we.maxX:we.maxY;if(We>=O&&Qe<U){ae.push(we);continue}if(Qe<O||We>=U)continue;let ft=[];if(Ee==="Point"||Ee==="MultiPoint")Ut(ke,ft,O,U,re);else if(Ee==="LineString")mi(ke,ft,O,U,re,!1,de.lineMetrics);else if(Ee==="MultiLineString")It(ke,ft,O,U,re,!1);else if(Ee==="Polygon")It(ke,ft,O,U,re,!0);else if(Ee==="MultiPolygon")for(const ti of ke){const Gt=[];It(ti,Gt,O,U,re,!0),Gt.length&&ft.push(Gt)}if(ft.length){if(de.lineMetrics&&Ee==="LineString"){for(const ti of ft)ae.push(ot(we.id,Ee,ti,we.tags));continue}Ee!=="LineString"&&Ee!=="MultiLineString"||(ft.length===1?(Ee="LineString",ft=ft[0]):Ee="MultiLineString"),Ee!=="Point"&&Ee!=="MultiPoint"||(Ee=ft.length===3?"Point":"MultiPoint"),ae.push(ot(we.id,Ee,ft,we.tags))}}return ae.length?ae:null}function Ut(ce,B,O,U,re){for(let ne=0;ne<ce.length;ne+=3){const fe=ce[ne+re];fe>=O&&fe<=U&&Lt(B,ce[ne],ce[ne+1],ce[ne+2])}}function mi(ce,B,O,U,re,ne,fe){let de=lt(ce);const ae=re===0?ct:Rt;let we,ke,Ee=ce.start;for(let Gt=0;Gt<ce.length-3;Gt+=3){const ye=ce[Gt],ni=ce[Gt+1],sr=ce[Gt+2],mt=ce[Gt+3],Kt=ce[Gt+4],ar=re===0?ye:ni,gi=re===0?mt:Kt;let zi=!1;fe&&(we=Math.sqrt(Math.pow(ye-mt,2)+Math.pow(ni-Kt,2))),ar<O?gi>O&&(ke=ae(de,ye,ni,mt,Kt,O),fe&&(de.start=Ee+we*ke)):ar>U?gi<U&&(ke=ae(de,ye,ni,mt,Kt,U),fe&&(de.start=Ee+we*ke)):Lt(de,ye,ni,sr),gi<O&&ar>=O&&(ke=ae(de,ye,ni,mt,Kt,O),zi=!0),gi>U&&ar<=U&&(ke=ae(de,ye,ni,mt,Kt,U),zi=!0),!ne&&zi&&(fe&&(de.end=Ee+we*ke),B.push(de),de=lt(ce)),fe&&(Ee+=we)}let We=ce.length-3;const Qe=ce[We],ft=ce[We+1],ti=re===0?Qe:ft;ti>=O&&ti<=U&&Lt(de,Qe,ft,ce[We+2]),We=de.length-3,ne&&We>=3&&(de[We]!==de[0]||de[We+1]!==de[1])&&Lt(de,de[0],de[1],de[2]),de.length&&B.push(de)}function lt(ce){const B=[];return B.size=ce.size,B.start=ce.start,B.end=ce.end,B}function It(ce,B,O,U,re,ne){for(const fe of ce)mi(fe,B,O,U,re,ne,!1)}function Lt(ce,B,O,U){ce.push(B,O,U)}function ct(ce,B,O,U,re,ne){const fe=(ne-B)/(U-B);return Lt(ce,ne,O+(re-O)*fe,1),fe}function Rt(ce,B,O,U,re,ne){const fe=(ne-O)/(re-O);return Lt(ce,B+(U-B)*fe,ne,1),fe}function ri(ce,B){const O=[];for(let U=0;U<ce.length;U++){const re=ce[U],ne=re.type;let fe;if(ne==="Point"||ne==="MultiPoint"||ne==="LineString")fe=yt(re.geometry,B);else if(ne==="MultiLineString"||ne==="Polygon"){fe=[];for(const de of re.geometry)fe.push(yt(de,B))}else if(ne==="MultiPolygon"){fe=[];for(const de of re.geometry){const ae=[];for(const we of de)ae.push(yt(we,B));fe.push(ae)}}O.push(ot(re.id,ne,fe,re.tags))}return O}function yt(ce,B){const O=[];O.size=ce.size,ce.start!==void 0&&(O.start=ce.start,O.end=ce.end);for(let U=0;U<ce.length;U+=3)O.push(ce[U]+B,ce[U+1],ce[U+2]);return O}function kt(ce,B){if(ce.transformed)return ce;const O=1<<ce.z,U=ce.x,re=ce.y;for(const ne of ce.features){const fe=ne.geometry,de=ne.type;if(ne.geometry=[],de===1)for(let ae=0;ae<fe.length;ae+=2)ne.geometry.push(xt(fe[ae],fe[ae+1],B,O,U,re));else for(let ae=0;ae<fe.length;ae++){const we=[];for(let ke=0;ke<fe[ae].length;ke+=2)we.push(xt(fe[ae][ke],fe[ae][ke+1],B,O,U,re));ne.geometry.push(we)}}return ce.transformed=!0,ce}function xt(ce,B,O,U,re,ne){return[Math.round(O*(ce*U-re)),Math.round(O*(B*U-ne))]}function Vt(ce,B,O,U,re){const ne=B===re.maxZoom?0:re.tolerance/((1<<B)*re.extent),fe={features:[],numPoints:0,numSimplified:0,numFeatures:ce.length,source:null,x:O,y:U,z:B,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const de of ce)pt(fe,de,ne,re);return fe}function pt(ce,B,O,U){const re=B.geometry,ne=B.type,fe=[];if(ce.minX=Math.min(ce.minX,B.minX),ce.minY=Math.min(ce.minY,B.minY),ce.maxX=Math.max(ce.maxX,B.maxX),ce.maxY=Math.max(ce.maxY,B.maxY),ne==="Point"||ne==="MultiPoint")for(let de=0;de<re.length;de+=3)fe.push(re[de],re[de+1]),ce.numPoints++,ce.numSimplified++;else if(ne==="LineString")Wt(fe,re,ce,O,!1,!1);else if(ne==="MultiLineString"||ne==="Polygon")for(let de=0;de<re.length;de++)Wt(fe,re[de],ce,O,ne==="Polygon",de===0);else if(ne==="MultiPolygon")for(let de=0;de<re.length;de++){const ae=re[de];for(let we=0;we<ae.length;we++)Wt(fe,ae[we],ce,O,!0,we===0)}if(fe.length){let de=B.tags||null;if(ne==="LineString"&&U.lineMetrics){de={};for(const we in B.tags)de[we]=B.tags[we];de.mapbox_clip_start=re.start/re.size,de.mapbox_clip_end=re.end/re.size}const ae={geometry:fe,type:ne==="Polygon"||ne==="MultiPolygon"?3:ne==="LineString"||ne==="MultiLineString"?2:1,tags:de};B.id!==null&&(ae.id=B.id),ce.features.push(ae)}}function Wt(ce,B,O,U,re,ne){const fe=U*U;if(U>0&&B.size<(re?fe:U))return void(O.numPoints+=B.length/3);const de=[];for(let ae=0;ae<B.length;ae+=3)(U===0||B[ae+2]>fe)&&(O.numSimplified++,de.push(B[ae],B[ae+1])),O.numPoints++;re&&(function(ae,we){let ke=0;for(let Ee=0,We=ae.length,Qe=We-2;Ee<We;Qe=Ee,Ee+=2)ke+=(ae[Ee]-ae[Qe])*(ae[Ee+1]+ae[Qe+1]);if(ke>0===we)for(let Ee=0,We=ae.length;Ee<We/2;Ee+=2){const Qe=ae[Ee],ft=ae[Ee+1];ae[Ee]=ae[We-2-Ee],ae[Ee+1]=ae[We-1-Ee],ae[We-2-Ee]=Qe,ae[We-1-Ee]=ft}})(de,ne),ce.push(de)}const mr={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class gr{constructor(B,O){const U=(O=this.options=(function(ne,fe){for(const de in fe)ne[de]=fe[de];return ne})(Object.create(mr),O)).debug;if(U&&console.time("preprocess data"),O.maxZoom<0||O.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(O.promoteId&&O.generateId)throw new Error("promoteId and generateId cannot be used together.");let re=(function(ne,fe){const de=[];if(ne.type==="FeatureCollection")for(let ae=0;ae<ne.features.length;ae++)Ze(de,ne.features[ae],fe,ae);else Ze(de,ne.type==="Feature"?ne:{geometry:ne},fe);return de})(B,O);this.tiles={},this.tileCoords=[],U&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",O.indexMaxZoom,O.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),re=(function(ne,fe){const de=fe.buffer/fe.extent;let ae=ne;const we=Tt(ne,1,-1-de,de,0,-1,2,fe),ke=Tt(ne,1,1-de,2+de,0,-1,2,fe);return(we||ke)&&(ae=Tt(ne,1,-de,1+de,0,-1,2,fe)||[],we&&(ae=ri(we,1).concat(ae)),ke&&(ae=ae.concat(ri(ke,-1)))),ae})(re,O),re.length&&this.splitTile(re,0,0,0),U&&(re.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(B,O,U,re,ne,fe,de){const ae=[B,O,U,re],we=this.options,ke=we.debug;for(;ae.length;){re=ae.pop(),U=ae.pop(),O=ae.pop(),B=ae.pop();const Ee=1<<O,We=Oi(O,U,re);let Qe=this.tiles[We];if(!Qe&&(ke>1&&console.time("creation"),Qe=this.tiles[We]=Vt(B,O,U,re,we),this.tileCoords.push({z:O,x:U,y:re}),ke)){ke>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",O,U,re,Qe.numFeatures,Qe.numPoints,Qe.numSimplified),console.timeEnd("creation"));const zi=`z${O}`;this.stats[zi]=(this.stats[zi]||0)+1,this.total++}if(Qe.source=B,ne==null){if(O===we.indexMaxZoom||Qe.numPoints<=we.indexMaxPoints)continue}else{if(O===we.maxZoom||O===ne)continue;if(ne!=null){const zi=ne-O;if(U!==fe>>zi||re!==de>>zi)continue}}if(Qe.source=null,B.length===0)continue;ke>1&&console.time("clipping");const ft=.5*we.buffer/we.extent,ti=.5-ft,Gt=.5+ft,ye=1+ft;let ni=null,sr=null,mt=null,Kt=null,ar=Tt(B,Ee,U-ft,U+Gt,0,Qe.minX,Qe.maxX,we),gi=Tt(B,Ee,U+ti,U+ye,0,Qe.minX,Qe.maxX,we);B=null,ar&&(ni=Tt(ar,Ee,re-ft,re+Gt,1,Qe.minY,Qe.maxY,we),sr=Tt(ar,Ee,re+ti,re+ye,1,Qe.minY,Qe.maxY,we),ar=null),gi&&(mt=Tt(gi,Ee,re-ft,re+Gt,1,Qe.minY,Qe.maxY,we),Kt=Tt(gi,Ee,re+ti,re+ye,1,Qe.minY,Qe.maxY,we),gi=null),ke>1&&console.timeEnd("clipping"),ae.push(ni||[],O+1,2*U,2*re),ae.push(sr||[],O+1,2*U,2*re+1),ae.push(mt||[],O+1,2*U+1,2*re),ae.push(Kt||[],O+1,2*U+1,2*re+1)}}getTile(B,O,U){B=+B,O=+O,U=+U;const re=this.options,{extent:ne,debug:fe}=re;if(B<0||B>24)return null;const de=1<<B,ae=Oi(B,O=O+de&de-1,U);if(this.tiles[ae])return kt(this.tiles[ae],ne);fe>1&&console.log("drilling down to z%d-%d-%d",B,O,U);let we,ke=B,Ee=O,We=U;for(;!we&&ke>0;)ke--,Ee>>=1,We>>=1,we=this.tiles[Oi(ke,Ee,We)];return we&&we.source?(fe>1&&(console.log("found parent tile z%d-%d-%d",ke,Ee,We),console.time("drilling down")),this.splitTile(we.source,ke,Ee,We,B,O,U),fe>1&&console.timeEnd("drilling down"),this.tiles[ae]?kt(this.tiles[ae],ne):null):null}}function Oi(ce,B,O){return 32*((1<<ce)*O+B)+ce}class Or extends ge{constructor(B,O,U,re=Di){super(B,O,U),this._dataUpdateable=new Map,this._createGeoJSONIndex=re}loadVectorTile(B,O){return P._(this,void 0,void 0,(function*(){const U=B.tileID.canonical;if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");const re=this._geoJSONIndex.getTile(U.z,U.x,U.y);return re?Ct(new P.d2(re.features,{version:2,extent:P.a5})):null}))}loadData(B){return P._(this,void 0,void 0,(function*(){var O;(O=this._pendingRequest)===null||O===void 0||O.abort();const U=this._startPerformance(B);this._pendingRequest=new AbortController;try{(!this._pendingData||B.request||B.data||B.dataDiff)&&(this._pendingData=this.loadAndProcessGeoJSON(B,this._pendingRequest));const re=yield this._pendingData;this._geoJSONIndex=this._createGeoJSONIndex(re,B),this.loaded={};const ne={};return B.request&&(ne.data=re),this._finishPerformance(U,B,ne),ne}catch(re){if(delete this._pendingRequest,P.Z(re))return{abandoned:!0};throw re}}))}_startPerformance(B){var O;if(!((O=B==null?void 0:B.request)===null||O===void 0)&&O.collectResourceTiming)return new P.c_(B.request)}_finishPerformance(B,O,U){if(!B)return;const re=B.finish();re&&(U.resourceTiming={},U.resourceTiming[O.source]=JSON.parse(JSON.stringify(re)))}getData(){return P._(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(B){const O=this.loaded;return O&&O[B.uid]?super.reloadTile(B):this.loadTile(B)}loadAndProcessGeoJSON(B,O){return P._(this,void 0,void 0,(function*(){let U;if(B.request?U=yield this.loadGeoJSONFromUrl(B.request,B.promoteId,O):B.data?U=this._loadGeoJSONFromObject(B.data,B.promoteId):B.dataDiff&&(U=this._loadGeoJSONFromDiff(B.dataDiff,B.promoteId,B.source)),delete this._pendingRequest,typeof U!="object")throw new Error(`Input data given to '${B.source}' is not a valid GeoJSON object.`);return Qt(U,!0),B.filter&&(U=this._filterGeoJSON(U,B.filter)),U}))}loadGeoJSONFromUrl(B,O,U){return P._(this,void 0,void 0,(function*(){const re=yield P.j(B,U);return this._dataUpdateable=P.a7(re.data,O),re.data}))}_loadGeoJSONFromObject(B,O){return this._dataUpdateable=P.a7(B,O),B}_loadGeoJSONFromDiff(B,O,U){if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${U}`);P.a8(this._dataUpdateable,B,O);const re=Array.from(this._dataUpdateable.values());return this._toFeatureCollection(re)}_filterGeoJSON(B,O){const U=P.d3(O,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(U.result==="error")throw new Error(U.value.map((ne=>`${ne.key}: ${ne.message}`)).join(", "));const re=B.features.filter((ne=>U.value.evaluate({zoom:0},ne)));return this._toFeatureCollection(re)}_toFeatureCollection(B){return{type:"FeatureCollection",features:B}}removeSource(B){return P._(this,void 0,void 0,(function*(){this._pendingRequest&&this._pendingRequest.abort()}))}getClusterExpansionZoom(B){return this._geoJSONIndex.getClusterExpansionZoom(B.clusterId)}getClusterChildren(B){return this._geoJSONIndex.getChildren(B.clusterId)}getClusterLeaves(B){return this._geoJSONIndex.getLeaves(B.clusterId,B.limit,B.offset)}}function Di(ce,B){return B.cluster?new pe((function({superclusterOptions:O,clusterProperties:U}){if(!U||!O)return O;const re={},ne={},fe={accumulated:null,zoom:0},de={properties:null},ae=Object.keys(U);for(const we of ae){const[ke,Ee]=U[we],We=P.d3(Ee),Qe=P.d3(typeof ke=="string"?[ke,["accumulated"],["get",we]]:ke);re[we]=We.value,ne[we]=Qe.value}return O.map=we=>{de.properties=we;const ke={};for(const Ee of ae)ke[Ee]=re[Ee].evaluate(fe,de);return ke},O.reduce=(we,ke)=>{de.properties=ke;for(const Ee of ae)fe.accumulated=we[Ee],we[Ee]=ne[Ee].evaluate(fe,de)},O})(B)).load(ce.features):(function(O,U){return new gr(O,U)})(ce,B.geojsonVtOptions)}class vi{constructor(B){this.self=B,this.actor=new P.L(B),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(O,U)=>{if(this.externalWorkerSourceTypes[O])throw new Error(`Worker source with name "${O}" already registered.`);this.externalWorkerSourceTypes[O]=U},this.self.addProtocol=P.cJ,this.self.removeProtocol=P.cK,this.self.registerRTLTextPlugin=O=>{P.d4.setMethods(O)},this.actor.registerMessageHandler("LDT",((O,U)=>this._getDEMWorkerSource(O,U.source).loadTile(U))),this.actor.registerMessageHandler("RDT",((O,U)=>P._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(O,U.source).removeTile(U)})))),this.actor.registerMessageHandler("GCEZ",((O,U)=>P._(this,void 0,void 0,(function*(){return this._getWorkerSource(O,U.type,U.source).getClusterExpansionZoom(U)})))),this.actor.registerMessageHandler("GCC",((O,U)=>P._(this,void 0,void 0,(function*(){return this._getWorkerSource(O,U.type,U.source).getClusterChildren(U)})))),this.actor.registerMessageHandler("GCL",((O,U)=>P._(this,void 0,void 0,(function*(){return this._getWorkerSource(O,U.type,U.source).getClusterLeaves(U)})))),this.actor.registerMessageHandler("LD",((O,U)=>this._getWorkerSource(O,U.type,U.source).loadData(U))),this.actor.registerMessageHandler("GD",((O,U)=>this._getWorkerSource(O,U.type,U.source).getData())),this.actor.registerMessageHandler("LT",((O,U)=>this._getWorkerSource(O,U.type,U.source).loadTile(U))),this.actor.registerMessageHandler("RT",((O,U)=>this._getWorkerSource(O,U.type,U.source).reloadTile(U))),this.actor.registerMessageHandler("AT",((O,U)=>this._getWorkerSource(O,U.type,U.source).abortTile(U))),this.actor.registerMessageHandler("RMT",((O,U)=>this._getWorkerSource(O,U.type,U.source).removeTile(U))),this.actor.registerMessageHandler("RS",((O,U)=>P._(this,void 0,void 0,(function*(){if(!this.workerSources[O]||!this.workerSources[O][U.type]||!this.workerSources[O][U.type][U.source])return;const re=this.workerSources[O][U.type][U.source];delete this.workerSources[O][U.type][U.source],re.removeSource!==void 0&&re.removeSource(U)})))),this.actor.registerMessageHandler("RM",(O=>P._(this,void 0,void 0,(function*(){delete this.layerIndexes[O],delete this.availableImages[O],delete this.workerSources[O],delete this.demWorkerSources[O],this.globalStates.delete(O)})))),this.actor.registerMessageHandler("SR",((O,U)=>P._(this,void 0,void 0,(function*(){this.referrer=U})))),this.actor.registerMessageHandler("SRPS",((O,U)=>this._syncRTLPluginState(O,U))),this.actor.registerMessageHandler("IS",((O,U)=>P._(this,void 0,void 0,(function*(){this.self.importScripts(U)})))),this.actor.registerMessageHandler("SI",((O,U)=>this._setImages(O,U))),this.actor.registerMessageHandler("UL",((O,U)=>P._(this,void 0,void 0,(function*(){this._getLayerIndex(O).update(U.layers,U.removedIds,this._getGlobalState(O))})))),this.actor.registerMessageHandler("UGS",((O,U)=>P._(this,void 0,void 0,(function*(){const re=this._getGlobalState(O);for(const ne in U)re[ne]=U[ne]})))),this.actor.registerMessageHandler("SL",((O,U)=>P._(this,void 0,void 0,(function*(){this._getLayerIndex(O).replace(U,this._getGlobalState(O))}))))}_getGlobalState(B){let O=this.globalStates.get(B);return O||(O={},this.globalStates.set(B,O)),O}_setImages(B,O){return P._(this,void 0,void 0,(function*(){this.availableImages[B]=O;for(const U in this.workerSources[B]){const re=this.workerSources[B][U];for(const ne in re)re[ne].availableImages=O}}))}_syncRTLPluginState(B,O){return P._(this,void 0,void 0,(function*(){return yield P.d4.syncState(O,this.self.importScripts)}))}_getAvailableImages(B){let O=this.availableImages[B];return O||(O=[]),O}_getLayerIndex(B){let O=this.layerIndexes[B];return O||(O=this.layerIndexes[B]=new c),O}_getWorkerSource(B,O,U){if(this.workerSources[B]||(this.workerSources[B]={}),this.workerSources[B][O]||(this.workerSources[B][O]={}),!this.workerSources[B][O][U]){const re={sendAsync:(ne,fe)=>(ne.targetMapId=B,this.actor.sendAsync(ne,fe))};switch(O){case"vector":this.workerSources[B][O][U]=new ge(re,this._getLayerIndex(B),this._getAvailableImages(B));break;case"geojson":this.workerSources[B][O][U]=new Or(re,this._getLayerIndex(B),this._getAvailableImages(B));break;default:this.workerSources[B][O][U]=new this.externalWorkerSourceTypes[O](re,this._getLayerIndex(B),this._getAvailableImages(B))}}return this.workerSources[B][O][U]}_getDEMWorkerSource(B,O){return this.demWorkerSources[B]||(this.demWorkerSources[B]={}),this.demWorkerSources[B][O]||(this.demWorkerSources[B][O]=new Xt),this.demWorkerSources[B][O]}}return P.i(self)&&(self.worker=new vi(self)),vi})),Q("index",["exports","./shared"],(function(P,c){var le="5.15.0";function Pe(){var d=new c.A(4);return c.A!=Float32Array&&(d[1]=0,d[2]=0),d[0]=1,d[3]=1,d}let Be,Ne,Ye;const rt={frame(d,t,n){const a=requestAnimationFrame((p=>{l(),t(p)})),{unsubscribe:l}=c.s(d.signal,"abort",(()=>{l(),cancelAnimationFrame(a),n(new c.a(d.signal.reason))}),!1)},frameAsync(d){return new Promise(((t,n)=>{this.frame(d,t,n)}))},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=>(Be||(Be=document.createElement("a")),Be.href=d,Be.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return Ye!==void 0?Ye:!!matchMedia&&(Ne==null&&(Ne=matchMedia("(prefers-reduced-motion: reduce)")),Ne.matches)},set prefersReducedMotion(d){Ye=d}},Ct=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 Je(){return Ct.getCurrentTime()}class ge{static testProp(t){if(!ge.docStyle)return t[0];for(let n=0;n<t.length;n++)if(t[n]in ge.docStyle)return t[n];return t[0]}static create(t,n,a){const l=window.document.createElement(t);return n!==void 0&&(l.className=n),a&&a.appendChild(l),l}static createNS(t,n){return window.document.createElementNS(t,n)}static disableDrag(){ge.docStyle&&ge.selectProp&&(ge.userSelect=ge.docStyle[ge.selectProp],ge.docStyle[ge.selectProp]="none")}static enableDrag(){ge.docStyle&&ge.selectProp&&(ge.docStyle[ge.selectProp]=ge.userSelect)}static setTransform(t,n){t.style[ge.transformProp]=n}static addEventListener(t,n,a,l={}){t.addEventListener(n,a,"passive"in l?l:l.capture)}static removeEventListener(t,n,a,l={}){t.removeEventListener(n,a,"passive"in l?l:l.capture)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",ge.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",ge.suppressClickInternal,!0),window.setTimeout((()=>{window.removeEventListener("click",ge.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,a){const l=n.boundingClientRect;return new c.P((a.clientX-l.left)/n.x-t.clientLeft,(a.clientY-l.top)/n.y-t.clientTop)}static mousePos(t,n){const a=ge.getScale(t);return ge.getPoint(t,a,n)}static touchPos(t,n){const a=[],l=ge.getScale(t);for(let p=0;p<n.length;p++)a.push(ge.getPoint(t,l,n[p]));return a}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"),a=n.querySelectorAll("script");for(const l of a)l.remove();return ge.clean(n),n.innerHTML}static isPossiblyDangerous(t,n){const a=n.replace(/\s+/g,"").toLowerCase();return!(!["src","href","xlink:href"].includes(t)||!a.includes("javascript:")&&!a.includes("data:"))||!!t.startsWith("on")||void 0}static clean(t){const n=t.children;for(const a of n)ge.removeAttributes(a),ge.clean(a)}static removeAttributes(t){for(const{name:n,value:a}of t.attributes)ge.isPossiblyDangerous(n,a)&&t.removeAttribute(n)}}ge.docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style,ge.selectProp=ge.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),ge.transformProp=ge.testProp(["transform","WebkitTransform"]);const Xt={supported:!1,testSupport:function(d){!fi&&st&&(Qt?Mi(d):zt=d)}};let zt,st,fi=!1,Qt=!1;function Mi(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,st),d.isContextLost())return;Xt.supported=!0}catch{}d.deleteTexture(t),fi=!0}var dt;typeof document<"u"&&(st=document.createElement("img"),st.onload=()=>{zt&&Mi(zt),zt=null,Qt=!0},st.onerror=()=>{fi=!0,zt=null},st.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),(function(d){let t,n,a,l;d.resetRequestQueue=()=>{t=[],n=0,a=0,l={}},d.addThrottleControl=x=>{const b=a++;return l[b]=x,b},d.removeThrottleControl=x=>{delete l[x],m()},d.getImage=(x,b,T=!0)=>new Promise(((E,I)=>{Xt.supported&&(x.headers||(x.headers={}),x.headers.accept="image/webp,*/*"),c.e(x,{type:"image"}),t.push({abortController:b,requestParameters:x,supportImageRefresh:T,state:"queued",onError:k=>{I(k)},onSuccess:k=>{E(k)}}),m()}));const p=x=>c._(this,void 0,void 0,(function*(){x.state="running";const{requestParameters:b,supportImageRefresh:T,onError:E,onSuccess:I,abortController:k}=x,V=T===!1&&!c.i(self)&&!c.g(b.url)&&(!b.headers||Object.keys(b.headers).reduce(((Z,Y)=>Z&&Y==="accept"),!0));n++;const q=V?_(b,k):c.m(b,k);try{const Z=yield q;delete x.abortController,x.state="completed",Z.data instanceof HTMLImageElement||c.b(Z.data)?I(Z):Z.data&&I({data:yield(W=Z.data,typeof createImageBitmap=="function"?c.f(W):c.h(W)),cacheControl:Z.cacheControl,expires:Z.expires})}catch(Z){delete x.abortController,E(Z)}finally{n--,m()}var W})),m=()=>{const x=(()=>{for(const b of Object.keys(l))if(l[b]())return!0;return!1})()?c.c.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:c.c.MAX_PARALLEL_IMAGE_REQUESTS;for(let b=n;b<x&&t.length>0;b++){const T=t.shift();T.abortController.signal.aborted?b--:p(T)}},_=(x,b)=>new Promise(((T,E)=>{const I=new Image,k=x.url,V=x.credentials;V&&V==="include"?I.crossOrigin="use-credentials":(V&&V==="same-origin"||!c.d(k))&&(I.crossOrigin="anonymous"),b.signal.addEventListener("abort",(()=>{I.src="",E(new c.a(b.signal.reason))})),I.fetchPriority="high",I.onload=()=>{I.onerror=I.onload=null,T({data:I})},I.onerror=()=>{I.onerror=I.onload=null,b.signal.aborted||E(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."))},I.src=k}))})(dt||(dt={})),dt.resetRequestQueue();class he{constructor(t){this._transformRequestFn=t??null}transformRequest(t,n){return this._transformRequestFn&&this._transformRequestFn(t,n)||{url:t}}setTransformRequest(t){this._transformRequestFn=t}}function pe(d){const t=[];if(typeof d=="string")t.push({id:"default",url:d});else if(d&&d.length>0){const n=[];for(const{id:a,url:l}of d){const p=`${a}${l}`;n.indexOf(p)===-1&&(n.push(p),t.push({id:a,url:l}))}}return t}function De(d,t,n){try{const a=new URL(d);return a.pathname+=`${t}${n}`,a.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 Oe(d){const{userImage:t}=d;return!!(t&&t.render&&t.render())&&(d.data.replace(new Uint8Array(t.data.buffer)),!0)}class je 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:a}of this.requestors)a(this._getImagesForIds(n));this.requestors=[]}}getImage(t){const n=this.images[t];if(n&&!n.data&&n.spriteData){const a=n.spriteData;n.data=new c.R({width:a.width,height:a.height},a.context.getImageData(a.x,a.y,a.width,a.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 a=!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`))),a=!1),this._validateStretch(n.stretchY,l&&l.height)||(this.fire(new c.k(new Error(`Image "${t}" has invalid "stretchY" value`))),a=!1),this._validateContent(n.content,n)||(this.fire(new c.k(new Error(`Image "${t}" has invalid "content" value`))),a=!1),a}_validateStretch(t,n){if(!t)return!0;let a=0;for(const l of t){if(l[0]<a||l[1]<l[0]||n<l[1])return!1;a=l[1]}return!0}_validateContent(t,n){if(!t)return!0;if(t.length!==4)return!1;const a=n.spriteData,l=a&&a.width||n.data.width,p=a&&a.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,a=!0){const l=this.getImage(t);if(a&&(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,a)=>{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 a of t){let l=this.getImage(a);l||(this.fire(new c.l("styleimagemissing",{id:a})),l=this.getImage(a)),l?n[a]={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 "${a}" 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],a=this.getImage(t);if(!a)return null;if(n&&n.position.version===a.version)return n.position;if(n)n.position.version=a.version;else{const l={w:a.data.width+2,h:a.data.height+2,x:0,y:0},p=new c.I(l,a);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:a}=c.p(t),l=this.atlasImage;l.resize({width:n||1,height:a||1});for(const p in this.patterns){const{bin:m}=this.patterns[p],_=m.x+1,x=m.y+1,b=this.getImage(p).data,T=b.width,E=b.height;c.R.copy(b,l,{x:0,y:0},{x:_,y:x},{width:T,height:E}),c.R.copy(b,l,{x:0,y:E-1},{x:_,y:x-1},{width:T,height:1}),c.R.copy(b,l,{x:0,y:0},{x:_,y:x+E},{width:T,height:1}),c.R.copy(b,l,{x:T-1,y:0},{x:_-1,y:x},{width:1,height:E}),c.R.copy(b,l,{x:0,y:0},{x:_+T,y:x},{width:1,height:E})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(const n of t){if(this.callbackDispatchedThisFrame[n])continue;this.callbackDispatchedThisFrame[n]=!0;const a=this.getImage(n);a||c.w(`Image with ID: "${n}" was not found`),Oe(a)&&this.updateImage(n,a)}}cloneImages(){const t={};for(const n in this.images){const a=this.images[n];t[n]=Object.assign(Object.assign({},a),{data:a.data?a.data.clone():null})}return t}}const at=1e20;function jt(d,t,n,a,l,p,m,_,x){for(let b=t;b<t+a;b++)$t(d,n*p+b,p,l,m,_,x);for(let b=n;b<n+l;b++)$t(d,b*p+t,1,a,m,_,x)}function $t(d,t,n,a,l,p,m){p[0]=0,m[0]=-at,m[1]=at,l[0]=d[t];for(let _=1,x=0,b=0;_<a;_++){l[_]=d[t+_*n];const T=_*_;do{const E=p[x];b=(l[_]-l[E]+T-E*E)/(_-E)/2}while(b<=m[x]&&--x>-1);x++,p[x]=_,m[x]=b,m[x+1]=at}for(let _=0,x=0;_<a;_++){for(;m[x+1]<_;)x++;const b=p[x],T=_-b;d[t+_*n]=l[b]+T*T}}const ei=c.v.layout_symbol["text-font"].default.join(",");class ot{constructor(t,n,a){this.requestManager=t,this.localIdeographFontFamily=n,this.entries={},this.lang=a}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 a=yield Promise.all(n),l={};for(const{stack:p,id:m,glyph:_}of a)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 a=this.entries[t];a||(a=this.entries[t]={glyphs:{},requests:{},ranges:{}});let l=a.glyphs[n];return l!==void 0?{stack:t,id:n,glyph:l}:!this.url||this._charUsesLocalIdeographFontFamily(n)?(l=a.glyphs[n]=this._drawGlyph(a,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 a=this.entries[t],l=Math.floor(n/256);if(a.ranges[l])return{stack:t,id:n,glyph:null};if(!a.requests[l]){const p=ot.loadGlyphRange(t,l,this.url,this.requestManager);a.requests[l]=p}try{const p=yield a.requests[l];for(const m in p)a.glyphs[+m]=p[+m];return a.ranges[l]=!0,{stack:t,id:n,glyph:p[n]||null}}catch(p){const m=a.glyphs[n]=this._drawGlyph(a,t,n);return this._warnOnMissingGlyphRange(m,l,n,p),{stack:t,id:n,glyph:m}}}))}_warnOnMissingGlyphRange(t,n,a,l){const p=256*n,m=p+255,_=a.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,a){const l=n===ei&&this.localIdeographFontFamily!==""&&this._charUsesLocalIdeographFontFamily(a),p=l?"ideographTinySDF":"tinySDF";t[p]||(t[p]=this._createTinySDF(l?this.localIdeographFontFamily:n));const m=t[p].draw(String.fromCodePoint(a));return{id:a,bitmap:new c.r({width:m.width||60,height:m.height||60},m.data),metrics:{width:m.glyphWidth/2||24,height:m.glyphHeight/2||24,left:m.glyphLeft/2+.5||0,top:m.glyphTop/2-27.5||-8,advance:m.glyphAdvance/2||24,isDoubleResolution:!0}}}_createTinySDF(t){const n=t?t.split(","):[];n.push("sans-serif");const a=n.map((l=>/[-\w]+/.test(l)?l:`'${CSS.escape(l)}'`)).join(",");return new ot.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:a,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 a;for(const[l,p]of Object.entries(n))new RegExp(`\\b${l}\\b`,"i").test(t)&&(a=`${p}`);return a}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={}}}ot.loadGlyphRange=function(d,t,n,a){return c._(this,void 0,void 0,(function*(){const l=256*t,p=l+255,m=a.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 x={};for(const b of c.o(_.data))x[b.id]=b;return x}))},ot.TinySDF=class{constructor({fontSize:d=24,buffer:t=3,radius:n=8,cutoff:a=.25,fontFamily:l="sans-serif",fontWeight:p="normal",fontStyle:m="normal",lang:_=null}={}){this.buffer=t,this.cutoff=a,this.radius=n,this.lang=_;const x=this.size=d+4*t,b=this._createCanvas(x),T=this.ctx=b.getContext("2d",{willReadFrequently:!0});T.font=`${m} ${p} ${d}px ${l}`,T.textBaseline="alphabetic",T.textAlign="left",T.fillStyle="black",this.gridOuter=new Float64Array(x*x),this.gridInner=new Float64Array(x*x),this.f=new Float64Array(x),this.z=new Float64Array(x+1),this.v=new Uint16Array(x)}_createCanvas(d){const t=document.createElement("canvas");return t.width=t.height=d,t}draw(d){const{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:a,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))),x=Math.min(this.size-this.buffer,m+Math.ceil(a)),b=_+2*this.buffer,T=x+2*this.buffer,E=Math.max(b*T,0),I=new Uint8ClampedArray(E),k={data:I,width:b,height:T,glyphWidth:_,glyphHeight:x,glyphTop:m,glyphLeft:0,glyphAdvance:t};if(_===0||x===0)return k;const{ctx:V,buffer:q,gridInner:W,gridOuter:Z}=this;this.lang&&(V.lang=this.lang),V.clearRect(q,q,_,x),V.fillText(d,q,q+m);const Y=V.getImageData(q,q,_,x);Z.fill(at,0,E),W.fill(0,0,E);for(let ie=0;ie<x;ie++)for(let H=0;H<_;H++){const ee=Y.data[4*(ie*_+H)+3]/255;if(ee===0)continue;const se=(ie+q)*b+H+q;if(ee===1)Z[se]=0,W[se]=at;else{const J=.5-ee;Z[se]=J>0?J*J:0,W[se]=J<0?J*J:0}}jt(Z,0,0,b,T,b,this.f,this.v,this.z),jt(W,q,q,_,x,b,this.f,this.v,this.z);for(let ie=0;ie<E;ie++){const H=Math.sqrt(Z[ie])-Math.sqrt(W[ie]);I[ie]=Math.round(255-255*(H/this.radius+this.cutoff))}return k}};class Nt{constructor(){this.specification=c.u.light.position}possiblyEvaluate(t,n){return c.F(t.expression.evaluate(n))}interpolate(t,n,a){return{x:c.G.number(t.x,n.x,a),y:c.G.number(t.y,n.y,a),z:c.G.number(t.z,n.z,a)}}}let Ze;class xi extends c.E{constructor(t){super(),Ze=Ze||new c.t({anchor:new c.D(c.u.light.anchor),position:new Nt,color:new c.D(c.u.light.color),intensity:new c.D(c.u.light.intensity)}),this._transitionable=new c.x(Ze,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 a in t){const l=t[a];a.endsWith(c.z)?this._transitionable.setTransition(a.slice(0,-c.z.length),l):this._transitionable.setValue(a,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,a){return(!a||a.validate!==!1)&&c.B(this,t.call(c.C,{value:n,style:{glyphs:!0,sprite:!0},styleSpec:c.u}))}}const ht=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 _t extends c.E{constructor(t){super(),this._transitionable=new c.x(ht,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 a in t){const l=t[a];a.endsWith(c.z)?this._transitionable.setTransition(a.slice(0,-c.z.length),l):this._transitionable.setValue(a,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,a={}){return(a==null?void 0:a.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 tt{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 a=t.join(",")+String(n);return this.dashEntry[a]||(this.dashEntry[a]=this.addDash(t,n)),this.dashEntry[a]}getDashRanges(t,n,a){const l=[];let p=t.length%2==1?-t[t.length-1]*a:0,m=t[0]*a,_=!0;l.push({left:p,right:m,isDash:_,zeroLength:t[0]===0});let x=t[0];for(let b=1;b<t.length;b++){_=!_;const T=t[b];p=x*a,x+=T,m=x*a,l.push({left:p,right:m,isDash:_,zeroLength:T===0})}return l}addRoundDash(t,n,a){const l=n/2;for(let p=-a;p<=a;p++){const m=this.width*(this.nextRow+a+p);let _=0,x=t[_];for(let b=0;b<this.width;b++){b/x.right>1&&(x=t[++_]);const T=Math.abs(b-x.left),E=Math.abs(b-x.right),I=Math.min(T,E);let k;const V=p/a*(l+1);if(x.isDash){const q=l-Math.abs(V);k=Math.sqrt(I*I+q*q)}else k=l-Math.sqrt(I*I+V*V);this.data[m+b]=Math.max(0,Math.min(255,k+128))}}}addRegularDash(t){for(let _=t.length-1;_>=0;--_){const x=t[_],b=t[_+1];x.zeroLength?t.splice(_,1):b&&b.isDash===x.isDash&&(b.left=x.left,t.splice(_,1))}const n=t[0],a=t[t.length-1];n.isDash===a.isDash&&(n.left=a.left-this.width,a.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 x=Math.abs(_-m.left),b=Math.abs(_-m.right),T=Math.min(x,b);this.data[l+_]=Math.max(0,Math.min(255,(m.isDash?T:-T)+128))}}addDash(t,n){const a=n?7:0,l=2*a+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,x=this.getDashRanges(t,this.width,_);n?this.addRoundDash(x,_,a):this.addRegularDash(x)}const m={y:this.nextRow+a,height:2*a,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 Yt="maplibre_preloaded_worker_pool";class Tt{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<Tt.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[Yt]}numActive(){return Object.keys(this.active).length}}const Ut=Math.floor(rt.hardwareConcurrency/2);let mi,lt;function It(){return mi||(mi=new Tt),mi}Tt.workerCount=c.K(globalThis)?Math.max(Math.min(Ut,3),1):1;class Lt{constructor(t,n){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=n;const a=this.workerPool.acquire(n);for(let l=0;l<a.length;l++){const p=new c.L(a[l],n);p.name=`Worker ${l}`,this.actors.push(p)}if(!this.actors.length)throw new Error("No actors found")}broadcast(t,n){const a=[];for(const l of this.actors)a.push(l.sendAsync({type:t,data:n}));return Promise.all(a)}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 a of this.actors)a.registerMessageHandler(t,n)}unregisterMessageHandler(t){for(const n of this.actors)n.unregisterMessageHandler(t)}}function ct(){return lt||(lt=new Lt(It(),c.M),lt.registerMessageHandler("GR",((d,t,n)=>c.m(t,n)))),lt}function Rt(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 ri(d,t,n,a,l,p,m){var _;const x=(function(I,k,V){if(I)for(const q of I){const W=k[q];if(W&&W.source===V&&W.type==="fill-extrusion")return!0}else for(const q in k){const W=k[q];if(W.source===V&&W.type==="fill-extrusion")return!0}return!1})((_=l==null?void 0:l.layers)!==null&&_!==void 0?_:null,t,d.id),b=p.maxPitchScaleFactor(),T=d.tilesIn(a,b,x);T.sort(yt);const E=[];for(const I of T)E.push({wrappedTileID:I.tileID.wrapped().key,queryResults:I.tile.queryRenderedFeatures(t,n,d.getState(),I.queryGeometry,I.cameraQueryGeometry,I.scale,l,p,b,Rt(p,I.tileID),m?(k,V)=>m(I.tileID,k,V):void 0)});return(function(I,k){for(const V in I)for(const q of I[V])kt(q,k);return I})((function(I){const k={},V={};for(const q of I){const W=q.queryResults,Z=q.wrappedTileID,Y=V[Z]=V[Z]||{};for(const ie in W){const H=W[ie],ee=Y[ie]=Y[ie]||{},se=k[ie]=k[ie]||[];for(const J of H)ee[J.featureIndex]||(ee[J.featureIndex]=!0,se.push(J))}}return k})(E),d)}function yt(d,t){const n=d.tileID,a=t.tileID;return n.overscaledZ-a.overscaledZ||n.canonical.y-a.canonical.y||n.wrap-a.wrap||n.canonical.x-a.canonical.x}function kt(d,t){const n=d.feature,a=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=a}function xt(d,t,n){return c._(this,void 0,void 0,(function*(){let a=d;if(d.url?a=(yield c.j(t.transformRequest(d.url,"Source"),n)).data:yield rt.frameAsync(n),!a)return null;const l=c.U(c.e(a,d),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in a&&a.vector_layers&&(l.vectorLayerIds=a.vector_layers.map((p=>p.id))),l}))}class Vt{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,a=this._ne;let l,p;if(t instanceof c.V)l=t,p=t;else{if(!(t instanceof Vt))return Array.isArray(t)?t.length===4||t.every(Array.isArray)?this.extend(Vt.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||a?(n.lng=Math.min(l.lng,n.lng),n.lat=Math.min(l.lat,n.lat),a.lng=Math.max(p.lng,a.lng),a.lat=Math.max(p.lat,a.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:a}=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<=a&&a<=this._ne.lat&&l}intersects(t){if(!((t=Vt.convert(t)).getNorth()>=this.getSouth()&&t.getSouth()<=this.getNorth()))return!1;const n=Math.abs(this.getEast()-this.getWest()),a=Math.abs(t.getEast()-t.getWest());if(n>=360||a>=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),x=l>=p,b=m>=_;return!(!x||!b)||(x?_>=l||m<=p:b?p>=m||l<=_:m<=p&&_>=l)}static convert(t){return t instanceof Vt?t:t&&new Vt(t)}static fromLngLat(t,n=0){const a=360*n/40075017,l=a/Math.cos(Math.PI/180*t.lat);return new Vt(new c.V(t.lng-l,t.lat-a),new c.V(t.lng+l,t.lat+a))}adjustAntiMeridian(){const t=new c.V(this._sw.lng,this._sw.lat),n=new c.V(this._ne.lng,this._ne.lat);return new Vt(t,t.lng>n.lng?new c.V(n.lng+360,n.lat):n)}}class pt{constructor(t,n,a){this.bounds=Vt.convert(this.validateBounds(t)),this.minzoom=n||0,this.maxzoom=a||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),a=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>=a&&t.x<p&&t.y>=l&&t.y<m}}class Wt extends c.E{constructor(t,n,a,l){if(super(),this.id=t,this.dispatcher=a,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 xt(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,this.map.style.tileManagers[this.id].clearTiles(),t&&(c.e(this,t),t.bounds&&(this.tileBounds=new pt(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),a={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)};a.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:a},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,a=n.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:n,overzoomRequest:this.map._requestManager.transformRequest(a,"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 a=t.reloadPromise;t.reloadPromise=null,this.loadTile(t).then(a.resolve).catch(a.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 mr extends c.E{constructor(t,n,a,l){super(),this.id=t,this.dispatcher=a,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 xt(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,n&&(c.e(this,n),n.bounds&&(this.tileBounds=new pt(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 a=yield dt.getImage(this.map._requestManager.transformRequest(n,"Tile"),t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(a&&a.data){this.map._refreshExpiredTiles&&(a.cacheControl||a.expires)&&t.setExpiryData({cacheControl:a.cacheControl,expires:a.expires});const l=this.map.painter.context,p=l.gl,m=a.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(a){if(delete t.abortController,t.aborted)t.state="unloaded";else if(a)throw t.state="errored",a}}))}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 gr extends mr{constructor(t,n,a,l){super(t,n,a,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),a=this.map._requestManager.transformRequest(n,"Tile");t.neighboringTiles=this._getNeighboringTiles(t.tileID),t.abortController=new AbortController;try{const l=yield dt.getImage(a,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 x=yield t.actor.sendAsync({type:"LDT",data:_});t.dem=x,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,a=t.height+2;try{return new c.R({width:n,height:a},yield c.a1(t,-1,-1,n,a))}catch{}}return rt.getImageData(t,1)}))}_getNeighboringTiles(t){const n=t.canonical,a=Math.pow(2,n.z),l=(n.x-1+a)%a,p=n.x===0?t.wrap-1:t.wrap,m=(n.x+1+a)%a,_=n.x+1===a?t.wrap+1:t.wrap,x={};return x[new c.a2(t.overscaledZ,p,n.z,l,n.y).key]={backfilled:!1},x[new c.a2(t.overscaledZ,_,n.z,m,n.y).key]={backfilled:!1},n.y>0&&(x[new c.a2(t.overscaledZ,p,n.z,l,n.y-1).key]={backfilled:!1},x[new c.a2(t.overscaledZ,t.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},x[new c.a2(t.overscaledZ,_,n.z,m,n.y-1).key]={backfilled:!1}),n.y+1<a&&(x[new c.a2(t.overscaledZ,p,n.z,l,n.y+1).key]={backfilled:!1},x[new c.a2(t.overscaledZ,t.wrap,n.z,n.x,n.y+1).key]={backfilled:!1},x[new c.a2(t.overscaledZ,_,n.z,m,n.y+1).key]={backfilled:!1}),x}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 Oi(d){return d.type==="GeometryCollection"?d.geometries.map((t=>t.coordinates)).flat(1/0):d.coordinates.flat(1/0)}function Or(d){const t=new Vt;let n;switch(d.type){case"FeatureCollection":n=d.features.map((a=>Oi(a.geometry))).flat(1/0);break;case"Feature":n=Oi(d.geometry);break;default:n=Oi(d)}if(n.length==0)return t;for(let a=0;a<n.length-1;a+=2)t.extend([n[a],n[a+1]]);return t}class Di extends c.E{constructor(t,n,a,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=a.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 a=this._updateWorkerData();return n?a:this}updateData(t,n){this._pendingWorkerUpdate.diff=c.a6(this._pendingWorkerUpdate.diff,t);const a=this._updateWorkerData();return n?a: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 Or(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,a){return this.actor.sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:t,limit:n,offset:a}})}_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,a=c.e({type:this.type},this.workerOptions);t!==void 0?(typeof t=="string"?(a.request=this.map._requestManager.transformRequest(rt.resolveURL(t),"Source"),a.request.collectResourceTiming=this._collectResourceTiming):a.data=t,this._pendingWorkerUpdate.data=void 0):n&&(a.dataDiff=n,this._pendingWorkerUpdate.diff=void 0),this._pendingWorkerUpdate.optionsChanged=void 0,this._isUpdatingWorker=!0,this.fire(new c.l("dataloading",{dataType:"source"}));try{const l=yield this.actor.sendAsync({type:"LD",data:a});if(this._isUpdatingWorker=!1,this._removed||l.abandoned)return void this.fire(new c.l("dataabort",{dataType:"source"}));l.data&&(this._data={geojson:l.data});const p=this._applyDiffToSource(n),m=this._getShouldReloadTileOptions(p);let _=null;l.resourceTiming&&l.resourceTiming[this.id]&&(_=l.resourceTiming[this.id].slice(0));const x={dataType:"source"};this._collectResourceTiming&&_&&_.length>0&&c.e(x,{resourceTiming:_}),this.fire(new c.l("data",Object.assign(Object.assign({},x),{sourceDataType:"metadata"}))),this.fire(new c.l("data",Object.assign(Object.assign({},x),{sourceDataType:"content",shouldReloadTileOptions:m})))}catch(l){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new c.l("dataabort",{dataType:"source"}));this.fire(new c.k(l))}finally{this._hasPendingWorkerUpdate()&&this._updateWorkerData()}}))}_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 a=c.a8(this._data.updateable,t,n);return t.removeAll||this._options.cluster?void 0:a}_getShouldReloadTileOptions(t){if(t)return{affectedBounds:t.filter(Boolean).map((n=>Or(n)))}}shouldReloadTile(t,{affectedBounds:n}){if(t.state==="loading")return!0;if(t.state==="unloaded")return!1;const{buffer:a,extent:l}=this.workerOptions.geojsonVtOptions,p=(function({x:m,y:_,z:x},b=0){const T=c.a3((m-b)/Math.pow(2,x)),E=c.a4((_+1+b)/Math.pow(2,x)),I=c.a3((m+1+b)/Math.pow(2,x)),k=c.a4((_-b)/Math.pow(2,x));return new Vt([T,E],[I,k])})(t.tileID.canonical,a/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 a={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:a},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 vi extends c.E{constructor(t,n,a,l){super(),this.flippedWindingOrder=!1,this.id=t,this.dispatcher=a,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 dt.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 a;return this.tileID=(function(l){const p=c.aa.fromPoints(l),m=p.width(),_=p.height(),x=Math.max(m,_),b=Math.max(0,Math.floor(-Math.log(x)/Math.LN2)),T=Math.pow(2,b);return new c.ac(b,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=((a=this.tileCoords)[1].x-a[0].x)*(a[2].y-a[0].y)-(a[1].y-a[0].y)*(a[2].x-a[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 a=!1;for(const l in this.tiles){const p=this.tiles[l];p.state!=="loaded"&&(p.state="loaded",p.texture=this.texture,a=!0)}a&&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:a,maxX:l,maxY:p}=c.aa.fromPoints(t),m={};for(let _=0;_<=c.ab;_++){const x=Math.pow(2,_),b=Math.floor(n*x),T=Math.floor(a*x),E=Math.floor(l*x),I=Math.floor(p*x);m[_]={minTileX:b,minTileY:T,maxTileX:E,maxTileY:I}}return m}}class ce extends vi{constructor(t,n,a,l){super(t,n,a,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 a=!1;for(const l in this.tiles){const p=this.tiles[l];p.state!=="loaded"&&(p.state="loaded",p.texture=this.texture,a=!0)}a&&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 B extends vi{constructor(t,n,a,l){super(t,n,a,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,a=n.gl;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new c.T(n,this.canvas,a.RGBA,{premultiply:!0}),this.texture.bind(a.LINEAR,a.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 O={},U=d=>{switch(d){case"geojson":return Di;case"image":return vi;case"raster":return mr;case"raster-dem":return gr;case"vector":return Wt;case"video":return ce;case"canvas":return B}return O[d]},re="RTLPluginLoaded";class ne extends c.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=ct()}_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,a=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=rt.resolveURL(n),!this.url)throw new Error(`requested url ${n} is invalid`);if(this.status==="unavailable"){if(!a)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(re))}))}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}}let fe=null;function de(){return fe||(fe=new ne),fe}var ae,we;(function(d){d[d.Base=0]="Base",d[d.Parent=1]="Parent"})(ae||(ae={})),(function(d){d[d.Departing=0]="Departing",d[d.Incoming=1]="Incoming"})(we||(we={}));class ke{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.rttCoords={},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:a,fadeEndTime:l}){this.resetFadeLogic(),this.fadingRole=t,this.fadingDirection=n,this.fadingParentID=a,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=Je(),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,a){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 x=_.layerIds.map((b=>p.getLayer(b))).filter(Boolean);if(x.length!==0){_.layers=x,_.stateDependentLayerIds&&(_.stateDependentLayers=_.stateDependentLayerIds.map((b=>x.filter((T=>T.id===b))[0])));for(const b of x)m[b.id]=_}}return m})(t.buckets,n==null?void 0: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,!a)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,de().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 a in this.buckets){const l=this.buckets[a];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,a,l,p,m,_,x,b,T,E){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:l,cameraQueryGeometry:p,scale:m,tileSize:this.tileSize,pixelPosMatrix:T,transform:x,params:_,queryPadding:this.queryPadding*b,getElevation:E},t,n,a):{}}querySourceFeatures(t,n){const a=this.latestFeatureIndex;if(!a||!a.rawTileData)return;const l=a.loadVTLayers(),p=n&&n.sourceLayer?n.sourceLayer:"",m=l[c.ai]||l[p];if(!m)return;const _=c.aj(n==null?void 0:n.filter,n==null?void 0:n.globalState),{z:x,x:b,y:T}=this.tileID.canonical,E={z:x,x:b,y:T};for(let I=0;I<m.length;I++){const k=m.feature(I);if(_.needGeometry){const W=c.ak(k,!0);if(!_.filter(new c.H(this.tileID.overscaledZ),W,this.tileID.canonical))continue}else if(!_.filter(new c.H(this.tileID.overscaledZ),k))continue;const V=a.getId(k,p),q=new c.al(k,x,b,T,V);q.tile=E,t.push(q)}}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 a=c.am(t.cacheControl);a["max-age"]&&(this.expirationTime=Date.now()+1e3*a["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const a=Date.now();let l=!1;if(this.expirationTime>a)l=!1;else if(n)if(this.expirationTime<n)l=!0;else{const p=this.expirationTime-n;p?this.expirationTime=a+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 a=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,_=a[m],x=t[m];if(!_||!x||Object.keys(x).length===0)continue;p.update(x,_,this.imageAtlas&&this.imageAtlas.patternPositions||{},this.dashPositions||{});const b=n&&n.style&&n.style.getLayer(l);b&&(this.queryPadding=Math.max(this.queryPadding,b.queryRadius(p)))}}holdingForSymbolFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<Je()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(t){this.symbolFadeHoldUntil=Je()+t}setDependencies(t,n){const a={};for(const l of n)a[l]=!0;this.dependencies[t]=a}hasDependency(t,n){for(const a of t){const l=this.dependencies[a];if(l){for(const p of n)if(l[p])return!0}}return!1}}class Ee{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,n,a){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],a),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])a[p]||(this.deletedStates[t][l][p]=null)}else for(const p in a)this.deletedStates[t]&&this.deletedStates[t][l]&&this.deletedStates[t][l][p]===null&&delete this.deletedStates[t][l][p]}removeFeatureState(t,n,a){if(this.deletedStates[t]===null)return;const l=String(n);if(this.deletedStates[t]=this.deletedStates[t]||{},a&&n!==void 0)this.deletedStates[t][l]!==null&&(this.deletedStates[t][l]=this.deletedStates[t][l]||{},this.deletedStates[t][l][a]=null);else if(n!==void 0)if(this.stateChanges[t]&&this.stateChanges[t][l])for(a in this.deletedStates[t][l]={},this.stateChanges[t][l])this.deletedStates[t][l][a]=null;else this.deletedStates[t][l]=null;else this.deletedStates[t]=null}getState(t,n){const a=String(n),l=c.e({},(this.state[t]||{})[a],(this.stateChanges[t]||{})[a]);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 a={};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];a[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]}a[l]=a[l]||{},c.e(a[l],p)}this.stateChanges={},this.deletedStates={},Object.keys(a).length!==0&&t.setFeatureState(a,n)}}const We=89.25;function Qe(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 ft(d,t){return new c.a9(t.x/d,t.y/d).toLngLat()}function ti(d){return d.cameraToCenterDistance*Math.min(.85*Math.tan(c.ap(90-d.pitch)),Math.tan(c.ap(We-d.pitch)))}function Gt(d,t){const n=d.canonical,a=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*a,n.y*a,0]),c.Q(p,p,[a/c.a5,a/c.a5,1]),p}function ye(d,t,n,a,l){const p=c.a9.fromLngLat(d,t),m=l*c.as(1,d.lat),{x:_,y:x,z:b}=ni(n,a);return new c.a9(p.x+m*-_,p.y+m*-x,p.z+m*-b)}function ni(d,t){const n=c.ap(d),a=c.ap(t),l=Math.cos(-n),p=Math.sin(n);return{x:p*Math.sin(a),y:-p*Math.cos(a),z:l}}function sr(d,t,n){const a=t.intersectsFrustum(d);if(!n||a===0)return a;const l=t.intersectsPlane(n);return l===0?0:a===2&&l===2?2:1}function mt(d,t,n){let a=0;const l=(n-t)/10;for(let p=0;p<10;p++)a+=l*Math.pow(Math.cos(t+(p+.5)/10*(n-t)),d);return a}function Kt(d,t){return function(n,a,l,p,m){const _=2*((d-1)/c.at(Math.cos(c.ap(We-m))/Math.cos(c.ap(We)))-1),x=Math.acos(l/p),b=2*mt(_-1,0,c.ap(m/2)),T=Math.min(c.ap(We),x+c.ap(m/2)),E=mt(_-1,Math.min(T,x-c.ap(m/2)),T),I=Math.atan(a/l),k=Math.hypot(a,l);let V=n;return V+=c.at(p/k/Math.max(.5,Math.cos(c.ap(m/2)))),V+=_*c.at(Math.cos(I))/2,V-=c.at(Math.max(1,E/b/t))/2,V}}const ar=Kt(9.314,3);function gi(d,t){const n=(t.roundZoom?Math.round:Math.floor)(d.zoom+c.at(d.tileSize/t.tileSize));return Math.max(0,n)}function zi(d,t){const n=d.getCameraFrustum(),a=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),x=gi(d,t),b=t.minzoom||0,T=t.maxzoom!==void 0?t.maxzoom:d.maxZoom,E=Math.min(Math.max(0,x),T),I=Math.pow(2,E),k=[I*l.x,I*l.y,0],V=[I*p.x,I*p.y,0],q=Math.hypot(p.x-l.x,p.y-l.y),W=Math.abs(p.z-l.z),Z=Math.hypot(q,W),Y=ee=>({zoom:0,x:0,y:0,wrap:ee,fullyVisible:!1}),ie=[],H=[];if(d.renderWorldCopies&&m.allowWorldCopies())for(let ee=1;ee<=3;ee++)ie.push(Y(-ee)),ie.push(Y(ee));for(ie.push(Y(0));ie.length>0;){const ee=ie.pop(),se=ee.x,J=ee.y;let oe=ee.fullyVisible;const Te={x:se,y:J,z:ee.zoom},_e=m.getTileBoundingVolume(Te,ee.wrap,d.elevation,t);if(!oe){const Le=sr(n,_e,a);if(Le===0)continue;oe=Le===2}const xe=m.distanceToTile2d(l.x,l.y,Te,_e);let ve=x;_&&(ve=(t.calculateTileZoom||ar)(d.zoom+c.at(d.tileSize/t.tileSize),xe,W,Z,d.fov)),ve=(t.roundZoom?Math.round:Math.floor)(ve),ve=Math.max(0,ve);const Fe=Math.min(ve,T);if(ee.wrap=m.getWrap(p,Te,ee.wrap),ee.zoom>=Fe){if(ee.zoom<b)continue;const Le=E-ee.zoom,Ae=k[0]-.5-(se<<Le),Ue=k[1]-.5-(J<<Le),gt=t.reparseOverscaled?Math.max(ee.zoom,ve):ee.zoom;H.push({tileID:new c.a2(ee.zoom===T?gt:ee.zoom,ee.wrap,ee.zoom,se,J),distanceSq:c.au([V[0]-.5-se,V[1]-.5-J]),tileDistanceToCamera:Math.sqrt(Ae*Ae+Ue*Ue)})}else for(let Le=0;Le<4;Le++)ie.push({zoom:ee.zoom+1,x:(se<<1)+Le%2,y:(J<<1)+(Le>>1),wrap:ee.wrap,fullyVisible:oe})}return H.sort(((ee,se)=>ee.distanceSq-se.distanceSq)).map((ee=>ee.tileID))}const si=c.aa.fromPoints([new c.P(0,0),new c.P(c.a5,c.a5)]);function $i(d){return d==="raster"||d==="image"||d==="video"}function Ns(d,t,n,a,l,p,m){if(!t.hasData())return!1;const{tileID:_,fadingRole:x,fadingDirection:b,fadingParentID:T}=t;if(x===ae.Base&&b===we.Incoming&&T)return n[T.key]=T,!0;const E=Math.max(_.overscaledZ-l,p);for(let I=_.overscaledZ-1;I>=E;I--){const k=_.scaledTo(I),V=d.getLoadedTile(k);if(V)return t.setCrossFadeLogic({fadingRole:ae.Base,fadingDirection:we.Incoming,fadingParentID:V.tileID,fadeEndTime:a+m}),V.setCrossFadeLogic({fadingRole:ae.Parent,fadingDirection:we.Departing,fadeEndTime:a+m}),n[k.key]=k,!0}return!1}function Us(d,t,n,a,l,p){if(!t.hasData())return!1;const m=t.tileID.children(l);let _=Re(d,t,m,n,a,l,p);if(_)return!0;for(const x of m)Re(d,t,x.children(l),n,a,l,p)&&(_=!0);return _}function Re(d,t,n,a,l,p,m){if(n[0].overscaledZ>=p)return!1;let _=!1;for(const x of n){const b=d.getLoadedTile(x);if(!b)continue;const{fadingRole:T,fadingDirection:E,fadingParentID:I}=b;T===ae.Base&&E===we.Departing&&I||(b.setCrossFadeLogic({fadingRole:ae.Base,fadingDirection:we.Departing,fadingParentID:t.tileID,fadeEndTime:l+m}),t.setCrossFadeLogic({fadingRole:ae.Parent,fadingDirection:we.Incoming,fadeEndTime:l+m})),a[x.key]=x,_=!0}return _}function _r(d,t,n,a){const l=d.tileID;return!!d.selfFading||!d.hasData()&&!!t.has(l)&&(d.setSelfFadeLogic(n+a),!0)}function yr(d,t){var n;d.needsHillshadePrepare=!0,d.needsTerrainPrepare=!0;let a=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;a===0&&l===0||Math.abs(l)>1||(Math.abs(a)>1&&(Math.abs(a+p)===1?a+=p:Math.abs(a-p)===1&&(a-=p)),t.dem&&d.dem&&(d.dem.backfillBorder(t.dem,a,l),!((n=d.neighboringTiles)===null||n===void 0)&&n[m]&&(d.neighboringTiles[m].backfilled=!0)))}class ja{constructor(){this._tiles={}}handleWrapJump(t){const n={};for(const a in this._tiles){const l=this._tiles[a];l.tileID=l.tileID.unwrapTo(l.tileID.wrap+t),n[l.tileID.key]=l}this._tiles=n}setFeatureState(t,n){for(const a in this._tiles)this._tiles[a].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!=null&&n.hasData()?n:null}isIdRenderable(t,n=!1){var a;return(a=this.getTileById(t))===null||a===void 0?void 0:a.isRenderable(n)}getRenderableIds(t=0,n){const a=[];for(const l of this.getAllIds())this.isIdRenderable(l,n)&&a.push(this.getTileById(l));return n?a.sort(((l,p)=>{const m=l.tileID,_=p.tileID,x=new c.P(m.canonical.x,m.canonical.y)._rotate(-t),b=new c.P(_.canonical.x,_.canonical.y)._rotate(-t);return m.overscaledZ-_.overscaledZ||b.y-x.y||b.x-x.x})).map((l=>l.tileID.key)):a.map((l=>l.tileID)).sort(c.aw).map((l=>l.key))}}class Vr extends c.E{constructor(t,n,a){super(),this.id=t,this.dispatcher=a,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 x=new(U(p.type))(l,p,m,_);if(x.id!==l)throw new Error(`Expected Source id to be ${l} instead of ${x.id}`);return x})(t,n,a,this),this._inViewTiles=new ja,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 Ee,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 ja}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,a){return c._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(t),this._tileLoaded(t,n,a)}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 a=this.getLoadedTile(t.scaledTo(n));if(a)return this._inViewTiles.isIdRenderable(a.tileID.key)}return!1}reload(t,n=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._outOfViewCache.reset();for(const a of this._inViewTiles.getAllIds()){const l=this._inViewTiles.getTileById(a);n&&!this._source.shouldReloadTile(l,n)||(t?this._reloadTile(a,"expired"):l.state!=="errored"&&this._reloadTile(a,"reloading"))}}}_reloadTile(t,n){return c._(this,void 0,void 0,(function*(){const a=this._inViewTiles.getTileById(t);a&&(a.state!=="loading"&&(a.state=n),yield this._loadTile(a,t,n))}))}_tileLoaded(t,n,a){t.timeAdded=Je(),t.selfFading&&(t.fadeEndTime=t.timeAdded+this._rasterFadeDuration),a==="expired"&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(n,t),this.getSource().type==="raster-dem"&&t.dem&&(function(l,p){var m,_;const x=p.getRenderableIds();for(const b of x){if(!l.neighboringTiles||!l.neighboringTiles[b])continue;const T=p.getTileById(b);l.neighboringTiles[b].backfilled||yr(l,T),!((_=(m=T.neighboringTiles)===null||m===void 0?void 0:m[l.tileID.key])===null||_===void 0)&&_.backfilled||yr(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 a=this._getLoadedDescendents(n),l=new Set;for(const p of n){const m=a[p.key];if(!(m!=null&&m.length)){l.add(p);continue}const _=p.overscaledZ+Vr.maxOverzooming,x=m.filter((E=>E.tileID.overscaledZ<=_));if(!x.length){l.add(p);continue}const b=Math.min(...x.map((E=>E.tileID.overscaledZ))),T=x.filter((E=>E.tileID.overscaledZ===b)).map((E=>E.tileID));for(const E of T)t[E.key]=E;this._areDescendentsComplete(T,b,p.overscaledZ)||l.add(p)}return l}_getLoadedDescendents(t){var n;const a={};for(const l of this._inViewTiles.getAllTiles().filter((p=>p.hasData())))for(const p of t)l.tileID.isChildOf(p)&&(a[n=p.key]||(a[n]=[])).push(l);return a}_areDescendentsComplete(t,n,a){return t.length===1&&t[0].isOverscaled()?t[0].overscaledZ===n:Math.pow(4,n-a)===t.length}getLoadedTile(t){return this._inViewTiles.getLoadedTile(t)}updateCacheSize(t){const n=Math.ceil(t.width/this._source.tileSize)+1,a=Math.ceil(t.height/this._source.tileSize)+1,l=Math.floor(n*a*(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 a;this.transform=t,this.terrain=n,this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?a=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((x=>new c.a2(x.canonical.z,x.wrap,x.canonical.z,x.canonical.x,x.canonical.y))):(a=zi(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&&(a=a.filter((x=>this._source.hasTile(x))))):a=[],this.usedForTerrain&&(a=this._addTerrainIdealTiles(a));const l=a.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=gi(t,this._source),m=this._updateRetainedTiles(a,p),_=$i(this._source.type);_&&this._rasterFadeDuration>0&&!n&&(function(x,b,T,E,I,k,V){const q=Je(),W=c.av(b);for(const Z of b){const Y=x.getTileById(Z.key);Y.fadingDirection!==we.Departing&&Y.fadeOpacity!==0||Y.resetFadeLogic(),Ns(x,Y,T,q,E,I,V)||Us(x,Y,T,q,k,V)||_r(Y,W,q,V)||Y.resetFadeLogic()}})(this._inViewTiles,a,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 a=this._inViewTiles.getTileById(n);t[n]?a.clearSymbolFadeHold():a.hasSymbolBuckets?a.holdingForSymbolFade()?a.symbolFadeFinished()&&this._removeTile(n):a.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(n)}}_addTerrainIdealTiles(t){const n=[];for(const a of t)if(a.canonical.z>this._source.minzoom){const l=a.scaledTo(a.canonical.z-1);n.push(l);const p=a.scaledTo(Math.max(this._source.minzoom,Math.min(a.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 a;const l=new Set;for(const b of t)this._addTile(b).hasData()||l.add(b);const p=t.reduce(((b,T)=>(b[T.key]=T,b)),{}),m=this._retainLoadedChildren(p,l),_={},x=Math.max(n-Vr.maxUnderzooming,this._source.minzoom);for(const b of m){let T=this._inViewTiles.getTileById(b.key),E=T==null?void 0:T.wasRequested();for(let I=b.overscaledZ-1;I>=x;--I){const k=b.scaledTo(I);if(_[k.key])break;if(_[k.key]=!0,T=this.getTile(k),!T&&E&&(T=this._addTile(k)),T){const V=T.hasData();if((V||!(!((a=this.map)===null||a===void 0)&&a.cancelPendingTileRequestsWhileZooming)||E)&&(p[k.key]=k),E=T.wasRequested(),V)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 a=n;return n||(n=new ke(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(n,t.key,n.state)),n.uses++,this._inViewTiles.setTile(t.key,n),a||this._source.fire(new c.l("dataloading",{tile:n,coord:n.tileID,dataType:"source"})),n}_setTileReloadTimer(t,n){this._clearTileReloadTimer(t);const a=n.getExpiryTimeout();a&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),a))}_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 a=this._inViewTiles.getTileById(n);(this._inViewTiles.isIdRenderable(n)||a.state=="errored")&&t.some((l=>l.equals(a.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,a){const l=[],p=this.transform;if(!p)return l;const m=p.getCoveringTilesDetailsProvider().allowWorldCopies(),_=a?p.getCameraQueryGeometry(t):t,x=k=>p.screenPointToMercatorCoordinate(k,this.terrain),b=this.transformBbox(t,x,!m),T=this.transformBbox(_,x,!m),E=this.getIds(),I=c.aa.fromPoints(T);for(let k=0;k<E.length;k++){const V=this._inViewTiles.getTileById(E[k]);if(V.holdingForSymbolFade())continue;const q=m?[V.tileID]:[V.tileID.unwrapTo(-1),V.tileID.unwrapTo(0)],W=Math.pow(2,p.zoom-V.tileID.overscaledZ),Z=n*V.queryPadding*c.a5/V.tileSize/W;for(const Y of q){const ie=I.map((H=>Y.getTilePoint(new c.a9(H.x,H.y))));if(ie.expandBy(Z),ie.intersects(si)){const H=b.map((se=>Y.getTilePoint(se))),ee=T.map((se=>Y.getTilePoint(se)));l.push({tile:V,tileID:m?Y:Y.unwrapTo(0),queryGeometry:H,cameraQueryGeometry:ee,scale:W})}}}return l}transformBbox(t,n,a){let l=t.map(n);if(a){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((a=>this._inViewTiles.getTileById(a).tileID));return this.transform&&this.transform.populateCache(n),n}hasTransition(){return!!this._source.hasTransition()||!(!$i(this._source.type)||!(function(t,n){if(n<=0)return!1;const a=Je();for(const l of t.getAllTiles())if(l.fadeEndTime>=a)return!0;return!1})(this._inViewTiles,this._rasterFadeDuration))}setRasterFadeDuration(t){this._rasterFadeDuration=t}setFeatureState(t,n,a){this._state.updateState(t=t||c.ai,n,a)}removeFeatureState(t,n,a){this._state.removeFeatureState(t=t||c.ai,n,a)}getFeatureState(t,n){return this._state.getState(t=t||c.ai,n)}setDependencies(t,n,a){const l=this._inViewTiles.getTileById(t);l&&l.setDependencies(n,a)}reloadTilesForDependencies(t,n){for(const a of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(a).hasDependency(t,n)&&this._reloadTile(a,"reloading");this._outOfViewCache.filter((a=>!a.hasDependency(t,n)))}areTilesLoaded(){for(const t of this._inViewTiles.getAllTiles())if(t.state!=="loaded"&&t.state!=="errored")return!1;return!0}}Vr.maxUnderzooming=10,Vr.maxOverzooming=3;class qe{constructor(t,n){this.reset(t,n)}reset(t,n){this.points=t||[],this._distances=[0];for(let a=1;a<this.points.length;a++)this._distances[a]=this._distances[a-1]+this.points[a].dist(this.points[a-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,a=this._distances[n];const l=t*this.paddedLength+this.padding;for(;a<l&&n<this._distances.length;)a=this._distances[++n];const p=n-1,m=this._distances[p],_=a-m,x=_>0?(l-m)/_:0;return this.points[p].mult(1-x).add(this.points[n].mult(x))}}function St(d,t){let n=!0;return d==="always"||d!=="never"&&t!=="never"||(n=!1),n}class Pt{constructor(t,n,a){const l=this.boxCells=[],p=this.circleCells=[];this.xCellCount=Math.ceil(t/a),this.yCellCount=Math.ceil(n/a);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,a,l,p){this._forEachCell(n,a,l,p,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(n),this.bboxes.push(a),this.bboxes.push(l),this.bboxes.push(p)}insertCircle(t,n,a,l){this._forEachCell(n-l,a-l,n+l,a+l,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(n),this.circles.push(a),this.circles.push(l)}_insertBoxCell(t,n,a,l,p,m){this.boxCells[p].push(m)}_insertCircleCell(t,n,a,l,p,m){this.circleCells[p].push(m)}_query(t,n,a,l,p,m,_){if(a<0||t>this.width||l<0||n>this.height)return[];const x=[];if(t<=0&&n<=0&&this.width<=a&&this.height<=l){if(p)return[{key:null,x1:t,y1:n,x2:a,y2:l}];for(let b=0;b<this.boxKeys.length;b++)x.push({key:this.boxKeys[b],x1:this.bboxes[4*b],y1:this.bboxes[4*b+1],x2:this.bboxes[4*b+2],y2:this.bboxes[4*b+3]});for(let b=0;b<this.circleKeys.length;b++){const T=this.circles[3*b],E=this.circles[3*b+1],I=this.circles[3*b+2];x.push({key:this.circleKeys[b],x1:T-I,y1:E-I,x2:T+I,y2:E+I})}}else this._forEachCell(t,n,a,l,this._queryCell,x,{hitTest:p,overlapMode:m,seenUids:{box:{},circle:{}}},_);return x}query(t,n,a,l){return this._query(t,n,a,l,!1,null)}hitTest(t,n,a,l,p,m){return this._query(t,n,a,l,!0,p,m).length>0}hitTestCircle(t,n,a,l,p){const m=t-a,_=t+a,x=n-a,b=n+a;if(_<0||m>this.width||b<0||x>this.height)return!1;const T=[];return this._forEachCell(m,x,_,b,this._queryCellCircle,T,{hitTest:!0,overlapMode:l,circle:{x:t,y:n,radius:a},seenUids:{box:{},circle:{}}},p),T.length>0}_queryCell(t,n,a,l,p,m,_,x){const{seenUids:b,hitTest:T,overlapMode:E}=_,I=this.boxCells[p];if(I!==null){const V=this.bboxes;for(const q of I)if(!b.box[q]){b.box[q]=!0;const W=4*q,Z=this.boxKeys[q];if(t<=V[W+2]&&n<=V[W+3]&&a>=V[W+0]&&l>=V[W+1]&&(!x||x(Z))&&(!T||!St(E,Z.overlapMode))&&(m.push({key:Z,x1:V[W],y1:V[W+1],x2:V[W+2],y2:V[W+3]}),T))return!0}}const k=this.circleCells[p];if(k!==null){const V=this.circles;for(const q of k)if(!b.circle[q]){b.circle[q]=!0;const W=3*q,Z=this.circleKeys[q];if(this._circleAndRectCollide(V[W],V[W+1],V[W+2],t,n,a,l)&&(!x||x(Z))&&(!T||!St(E,Z.overlapMode))){const Y=V[W],ie=V[W+1],H=V[W+2];if(m.push({key:Z,x1:Y-H,y1:ie-H,x2:Y+H,y2:ie+H}),T)return!0}}}return!1}_queryCellCircle(t,n,a,l,p,m,_,x){const{circle:b,seenUids:T,overlapMode:E}=_,I=this.boxCells[p];if(I!==null){const V=this.bboxes;for(const q of I)if(!T.box[q]){T.box[q]=!0;const W=4*q,Z=this.boxKeys[q];if(this._circleAndRectCollide(b.x,b.y,b.radius,V[W+0],V[W+1],V[W+2],V[W+3])&&(!x||x(Z))&&!St(E,Z.overlapMode))return m.push(!0),!0}}const k=this.circleCells[p];if(k!==null){const V=this.circles;for(const q of k)if(!T.circle[q]){T.circle[q]=!0;const W=3*q,Z=this.circleKeys[q];if(this._circlesCollide(V[W],V[W+1],V[W+2],b.x,b.y,b.radius)&&(!x||x(Z))&&!St(E,Z.overlapMode))return m.push(!0),!0}}}_forEachCell(t,n,a,l,p,m,_,x){const b=this._convertToXCellCoord(t),T=this._convertToYCellCoord(n),E=this._convertToXCellCoord(a),I=this._convertToYCellCoord(l);for(let k=b;k<=E;k++)for(let V=T;V<=I;V++)if(p.call(this,t,n,a,l,this.xCellCount*V+k,m,_,x))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,a,l,p,m){const _=l-t,x=p-n,b=a+m;return b*b>_*_+x*x}_circleAndRectCollide(t,n,a,l,p,m,_){const x=(m-l)/2,b=Math.abs(t-(l+x));if(b>x+a)return!1;const T=(_-p)/2,E=Math.abs(n-(p+T));if(E>T+a)return!1;if(b<=x||E<=T)return!0;const I=b-x,k=E-T;return I*I+k*k<=a*a}}function Dr(d,t,n){const a=c.N();if(!d){const{vecSouth:E,vecEast:I}=pn(t),k=Pe();k[0]=I[0],k[1]=I[1],k[2]=E[0],k[3]=E[1],l=k,(T=(m=(p=k)[0])*(b=p[3])-(x=p[2])*(_=p[1]))&&(l[0]=b*(T=1/T),l[1]=-_*T,l[2]=-x*T,l[3]=m*T),a[0]=k[0],a[1]=k[1],a[4]=k[2],a[5]=k[3]}var l,p,m,_,x,b,T;return c.Q(a,a,[1/n,1/n,1]),a}function Na(d,t,n,a){if(d){const l=c.N();if(!t){const{vecSouth:p,vecEast:m}=pn(n);l[0]=m[0],l[1]=m[1],l[4]=p[0],l[5]=p[1]}return c.Q(l,l,[a,a,1]),l}return n.pixelsToClipSpaceMatrix}function pn(d){const t=Math.cos(d.rollInRadians),n=Math.sin(d.rollInRadians),a=Math.cos(d.pitchInRadians),l=Math.cos(d.bearingInRadians),p=Math.sin(d.bearingInRadians),m=c.aC();m[0]=-l*a*n-p*t,m[1]=-p*a*n+l*t;const _=c.aD(m);_<1e-9?c.aE(m):c.aF(m,m,1/_);const x=c.aC();x[0]=l*a*t-p*n,x[1]=p*a*t+l*n;const b=c.aD(x);return b<1e-9?c.aE(x):c.aF(x,x,1/b),{vecEast:x,vecSouth:m}}function bt(d,t,n,a){let l;a?(l=[d,t,a(d,t),1],c.aH(l,l,n)):(l=[d,t,0,1],qa(l,l,n));const p=l[3];return{point:new c.P(l[0]/p,l[1]/p),signedDistanceFromCamera:p,isOccluded:!1}}function Gs(d,t){return .5+d/t*.5}function qs(d,t){return d.x>=-t[0]&&d.x<=t[0]&&d.y>=-t[1]&&d.y<=t[1]}function Ua(d,t,n,a,l,p,m,_,x,b,T,E,I){const k=n?d.textSizeData:d.iconSizeData,V=c.ay(k,t.transform.zoom),q=[256/t.width*2+1,256/t.height*2+1],W=n?d.text.dynamicLayoutVertexArray:d.icon.dynamicLayoutVertexArray;W.clear();const Z=d.lineVertexArray,Y=n?d.text.placedSymbolArray:d.icon.placedSymbolArray,ie=t.transform.width/t.transform.height;let H=!1;for(let ee=0;ee<Y.length;ee++){const se=Y.get(ee);if(se.hidden||se.writingMode===c.az.vertical&&!H){On(se.numGlyphs,W);continue}H=!1;const J=new c.P(se.anchorX,se.anchorY),oe={getElevation:I,pitchedLabelPlaneMatrix:a,lineVertexArray:Z,pitchWithMap:p,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:t.transform,tileAnchorPoint:J,unwrappedTileID:x,width:b,height:T,translation:E},Te=hs(se.anchorX,se.anchorY,oe);if(!qs(Te.point,q)){On(se.numGlyphs,W);continue}const _e=Gs(t.transform.cameraToCenterDistance,Te.signedDistanceFromCamera),xe=c.aA(k,V,se),ve=p?xe*t.transform.getPitchedTextCorrection(se.anchorX,se.anchorY,x)/_e:xe*_e,Fe=us({projectionContext:oe,pitchedLabelPlaneMatrixInverse:l,symbol:se,fontSize:ve,flip:!1,keepUpright:m,glyphOffsetArray:d.glyphOffsetArray,dynamicLayoutVertexArray:W,aspectRatio:ie,rotateToLine:_});H=Fe.useVertical,(Fe.notEnoughRoom||H||Fe.needsFlipping&&us({projectionContext:oe,pitchedLabelPlaneMatrixInverse:l,symbol:se,fontSize:ve,flip:!0,keepUpright:m,glyphOffsetArray:d.glyphOffsetArray,dynamicLayoutVertexArray:W,aspectRatio:ie,rotateToLine:_}).notEnoughRoom)&&On(se.numGlyphs,W)}n?d.text.dynamicLayoutVertexBuffer.updateData(W):d.icon.dynamicLayoutVertexBuffer.updateData(W)}function cs(d,t,n,a,l,p,m,_){const x=p.glyphStartIndex+p.numGlyphs,b=p.lineStartIndex,T=p.lineStartIndex+p.lineLength,E=t.getoffsetX(p.glyphStartIndex),I=t.getoffsetX(x-1),k=Hr(d*E,n,a,l,p.segment,b,T,_,m);if(!k)return null;const V=Hr(d*I,n,a,l,p.segment,b,T,_,m);return V?_.projectionCache.anyProjectionOccluded?null:{first:k,last:V}:null}function Zs(d,t,n,a){return d===c.az.horizontal&&Math.abs(n.y-t.y)>Math.abs(n.x-t.x)*a?{useVertical:!0}:(d===c.az.vertical?t.y<n.y:t.x>n.x)?{needsFlipping:!0}:null}function us(d){const{projectionContext:t,pitchedLabelPlaneMatrixInverse:n,symbol:a,fontSize:l,flip:p,keepUpright:m,glyphOffsetArray:_,dynamicLayoutVertexArray:x,aspectRatio:b,rotateToLine:T}=d,E=l/24,I=a.lineOffsetX*E,k=a.lineOffsetY*E;let V;if(a.numGlyphs>1){const q=a.glyphStartIndex+a.numGlyphs,W=a.lineStartIndex,Z=a.lineStartIndex+a.lineLength,Y=cs(E,_,I,k,p,a,T,t);if(!Y)return{notEnoughRoom:!0};const ie=Ga(Y.first.point.x,Y.first.point.y,t,n),H=Ga(Y.last.point.x,Y.last.point.y,t,n);if(m&&!p){const ee=Zs(a.writingMode,ie,H,b);if(ee)return ee}V=[Y.first];for(let ee=a.glyphStartIndex+1;ee<q-1;ee++){const se=Hr(E*_.getoffsetX(ee),I,k,p,a.segment,W,Z,t,T);if(!se)return{notEnoughRoom:!0};V.push(se)}V.push(Y.last)}else{if(m&&!p){const W=Jt(t.tileAnchorPoint.x,t.tileAnchorPoint.y,t).point,Z=a.lineStartIndex+a.segment+1,Y=new c.P(t.lineVertexArray.getx(Z),t.lineVertexArray.gety(Z)),ie=Jt(Y.x,Y.y,t),H=ie.signedDistanceFromCamera>0?ie.point:$s(t.tileAnchorPoint,Y,W,1,t),ee=Ga(W.x,W.y,t,n),se=Ga(H.x,H.y,t,n),J=Zs(a.writingMode,ee,se,b);if(J)return J}const q=Hr(E*_.getoffsetX(a.glyphStartIndex),I,k,p,a.segment,a.lineStartIndex,a.lineStartIndex+a.lineLength,t,T);if(!q||t.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};V=[q]}for(const q of V)c.aG(x,q.point,q.angle);return{}}function $s(d,t,n,a,l){const p=d.add(d.sub(t)._unit()),m=Jt(p.x,p.y,l).point,_=n.sub(m);return n.add(_._mult(a/_.mag()))}function xr(d,t,n){const a=t.projectionCache;if(a.projections[d])return a.projections[d];const l=new c.P(t.lineVertexArray.getx(d),t.lineVertexArray.gety(d)),p=Jt(l.x,l.y,t);if(p.signedDistanceFromCamera>0)return a.projections[d]=p.point,a.anyProjectionOccluded=a.anyProjectionOccluded||p.isOccluded,p.point;const m=d-n.direction;return $s(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 Jt(d,t,n){const a=d+n.translation[0],l=t+n.translation[1];let p;return n.pitchWithMap?(p=bt(a,l,n.pitchedLabelPlaneMatrix,n.getElevation),p.isOccluded=!1):(p=n.transform.projectTileCoordinates(a,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 Ga(d,t,n,a){if(n.pitchWithMap){const l=[d,t,0,1];return c.aH(l,l,a),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 hs(d,t,n){return n.transform.projectTileCoordinates(d,t,n.unwrappedTileID,n.getElevation)}function Ws(d,t,n){return d._unit()._perp()._mult(t*n)}function Bn(d,t,n,a,l,p,m,_,x){if(_.projectionCache.offsets[d])return _.projectionCache.offsets[d];const b=n.add(t);if(d+x.direction<a||d+x.direction>=l)return _.projectionCache.offsets[d]=b,b;const T=xr(d+x.direction,_,x),E=Ws(T.sub(n),m,x.direction),I=n.add(E),k=T.add(E);return _.projectionCache.offsets[d]=c.aI(p,b,I,k)||b,_.projectionCache.offsets[d]}function Hr(d,t,n,a,l,p,m,_,x){const b=a?d-t:d+t;let T=b>0?1:-1,E=0;a&&(T*=-1,E=Math.PI),T<0&&(E+=Math.PI);let I,k=T>0?p+l:p+l+1;_.projectionCache.cachedAnchorPoint?I=_.projectionCache.cachedAnchorPoint:(I=Jt(_.tileAnchorPoint.x,_.tileAnchorPoint.y,_).point,_.projectionCache.cachedAnchorPoint=I);let V,q,W=I,Z=I,Y=0,ie=0;const H=Math.abs(b),ee=[];let se;for(;Y+ie<=H;){if(k+=T,k<p||k>=m)return null;Y+=ie,Z=W,q=V;const Te={absOffsetX:H,direction:T,distanceFromAnchor:Y,previousVertex:Z};if(W=xr(k,_,Te),n===0)ee.push(Z),se=W.sub(Z);else{let _e;const xe=W.sub(Z);_e=xe.mag()===0?Ws(xr(k+T,_,Te).sub(W),n,T):Ws(xe,n,T),q||(q=Z.add(_e)),V=Bn(k,_e,W,p,m,q,n,_,Te),ee.push(q),se=V.sub(q)}ie=se.mag()}const J=se._mult((H-Y)/ie)._add(q||Z),oe=E+Math.atan2(W.y-Z.y,W.x-Z.x);return ee.push(J),{point:J,angle:x?oe:0,path:ee}}const xc=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function On(d,t){for(let n=0;n<d;n++){const a=t.length;t.resize(a+4),t.float32.set(xc,3*a)}}function qa(d,t,n){const a=t[0],l=t[1];return d[0]=n[0]*a+n[4]*l+n[12],d[1]=n[1]*a+n[5]*l+n[13],d[3]=n[3]*a+n[7]*l+n[15],d}const ki=100;class vc{constructor(t,n=new Pt(t.width+200,t.height+200,25),a=new Pt(t.width+200,t.height+200,25)){this.transform=t,this.grid=n,this.ignoredGrid=a,this.pitchFactor=Math.cos(t.pitch*Math.PI/180)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+ki,this.screenBottomBoundary=t.height+ki,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(t,n,a,l,p,m,_,x,b,T,E,I){const k=this.projectAndGetPerspectiveRatio(t.anchorPointX+x[0],t.anchorPointY+x[1],p,T,I),V=a*k.perspectiveRatio;let q;if(m||_)q=this._projectCollisionBox(t,V,l,p,m,_,x,k,T,E,I);else{const se=k.x+(E?E.x*V:0),J=k.y+(E?E.y*V:0);q={allPointsOccluded:!1,box:[se+t.x1*V,J+t.y1*V,se+t.x2*V,J+t.y2*V]}}const[W,Z,Y,ie]=q.box,H=m?q.allPointsOccluded:k.isOccluded;let ee=H;return ee||(ee=k.perspectiveRatio<this.perspectiveRatioCutoff),ee||(ee=!this.isInsideGrid(W,Z,Y,ie)),ee||n!=="always"&&this.grid.hitTest(W,Z,Y,ie,n,b)?{box:[W,Z,Y,ie],placeable:!1,offscreen:!1,occluded:H}:{box:[W,Z,Y,ie],placeable:!0,offscreen:this.isOffscreen(W,Z,Y,ie),occluded:H}}placeCollisionCircles(t,n,a,l,p,m,_,x,b,T,E,I,k,V){const q=[],W=new c.P(n.anchorX,n.anchorY),Z=this.getPerspectiveRatio(W.x,W.y,m,V),Y=(b?p*this.transform.getPitchedTextCorrection(n.anchorX,n.anchorY,m)/Z:p*Z)/c.aM,ie={getElevation:V,pitchedLabelPlaneMatrix:_,lineVertexArray:a,pitchWithMap:b,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:W,unwrappedTileID:m,width:this.transform.width,height:this.transform.height,translation:k},H=cs(Y,l,n.lineOffsetX*Y,n.lineOffsetY*Y,!1,n,!1,ie);let ee=!1,se=!1,J=!0;if(H){const oe=.5*E*Z+I,Te=new c.P(-100,-100),_e=new c.P(this.screenRightBoundary,this.screenBottomBoundary),xe=new qe,ve=H.first,Fe=H.last;let Le=[];for(let gt=ve.path.length-1;gt>=1;gt--)Le.push(ve.path[gt]);for(let gt=1;gt<Fe.path.length;gt++)Le.push(Fe.path[gt]);const Ae=2.5*oe;if(b){const gt=this.projectPathToScreenSpace(Le,ie);Le=gt.some((Ht=>Ht.signedDistanceFromCamera<=0))?[]:gt.map((Ht=>Ht.point))}let Ue=[];if(Le.length>0){const gt=Le[0].clone(),Ht=Le[0].clone();for(let _i=1;_i<Le.length;_i++)gt.x=Math.min(gt.x,Le[_i].x),gt.y=Math.min(gt.y,Le[_i].y),Ht.x=Math.max(Ht.x,Le[_i].x),Ht.y=Math.max(Ht.y,Le[_i].y);Ue=gt.x>=Te.x&&Ht.x<=_e.x&&gt.y>=Te.y&&Ht.y<=_e.y?[Le]:Ht.x<Te.x||gt.x>_e.x||Ht.y<Te.y||gt.y>_e.y?[]:c.aJ([Le],Te.x,Te.y,_e.x,_e.y)}for(const gt of Ue){xe.reset(gt,.25*oe);let Ht=0;Ht=xe.length<=.5*oe?1:Math.ceil(xe.paddedLength/Ae)+1;for(let _i=0;_i<Ht;_i++){const li=_i/Math.max(Ht-1,1),wi=xe.lerp(li),ci=wi.x+ki,Fi=wi.y+ki;q.push(ci,Fi,oe,0);const Ti=ci-oe,Qi=Fi-oe,qi=ci+oe,Ui=Fi+oe;if(J=J&&this.isOffscreen(Ti,Qi,qi,Ui),se=se||this.isInsideGrid(Ti,Qi,qi,Ui),t!=="always"&&this.grid.hitTestCircle(ci,Fi,oe,t,T)&&(ee=!0,!x))return{circles:[],offscreen:!1,collisionDetected:ee}}}}return{circles:!x&&ee||!se||Z<this.perspectiveRatioCutoff?[]:q,offscreen:J,collisionDetected:ee}}projectPathToScreenSpace(t,n){const a=(function(l,p){const m=c.N();return c.aB(m,p.pitchedLabelPlaneMatrix),l.map((_=>{const x=bt(_.x,_.y,m,p.getElevation),b=p.transform.projectTileCoordinates(x.point.x,x.point.y,p.unwrappedTileID,p.getElevation);return b.point.x=(.5*b.point.x+.5)*p.width,b.point.y=(.5*-b.point.y+.5)*p.height,b}))})(t,n);return(function(l){let p=0,m=0,_=0,x=0;for(let b=0;b<l.length;b++)l[b].isOccluded?(_=b+1,x=0):(x++,x>m&&(m=x,p=_));return l.slice(p,p+m)})(a)}queryRenderedSymbols(t){if(t.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const n=[],a=new c.aa;for(const E of t){const I=new c.P(E.x+ki,E.y+ki);a.extend(I),n.push(I)}const{minX:l,minY:p,maxX:m,maxY:_}=a,x=this.grid.query(l,p,m,_).concat(this.ignoredGrid.query(l,p,m,_)),b={},T={};for(const E of x){const I=E.key;if(b[I.bucketInstanceId]===void 0&&(b[I.bucketInstanceId]={}),b[I.bucketInstanceId][I.featureIndex])continue;const k=[new c.P(E.x1,E.y1),new c.P(E.x2,E.y1),new c.P(E.x2,E.y2),new c.P(E.x1,E.y2)];c.aK(n,k)&&(b[I.bucketInstanceId][I.featureIndex]=!0,T[I.bucketInstanceId]===void 0&&(T[I.bucketInstanceId]=[]),T[I.bucketInstanceId].push(I.featureIndex))}return T}insertCollisionBox(t,n,a,l,p,m){(a?this.ignoredGrid:this.grid).insert({bucketInstanceId:l,featureIndex:p,collisionGroupID:m,overlapMode:n},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,n,a,l,p,m){const _=a?this.ignoredGrid:this.grid,x={bucketInstanceId:l,featureIndex:p,collisionGroupID:m,overlapMode:n};for(let b=0;b<t.length;b+=4)_.insertCircle(x,t[b],t[b+1],t[b+2])}projectAndGetPerspectiveRatio(t,n,a,l,p){if(p){let m;l?(m=[t,n,l(t,n),1],c.aH(m,m,p)):(m=[t,n,0,1],qa(m,m,p));const _=m[3];return{x:(m[0]/_+1)/2*this.transform.width+ki,y:(-m[1]/_+1)/2*this.transform.height+ki,perspectiveRatio:.5+this.transform.cameraToCenterDistance/_*.5,isOccluded:!1,signedDistanceFromCamera:_}}{const m=this.transform.projectTileCoordinates(t,n,a,l);return{x:(m.point.x+1)/2*this.transform.width+ki,y:(1-m.point.y)/2*this.transform.height+ki,perspectiveRatio:.5+this.transform.cameraToCenterDistance/m.signedDistanceFromCamera*.5,isOccluded:m.isOccluded,signedDistanceFromCamera:m.signedDistanceFromCamera}}}getPerspectiveRatio(t,n,a,l){const p=this.transform.projectTileCoordinates(t,n,a,l);return .5+this.transform.cameraToCenterDistance/p.signedDistanceFromCamera*.5}isOffscreen(t,n,a,l){return a<ki||t>=this.screenRightBoundary||l<ki||n>this.screenBottomBoundary}isInsideGrid(t,n,a,l){return a>=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,a,l,p,m,_,x,b,T,E){let I=1,k=0,V=0,q=1;const W=t.anchorPointX+_[0],Z=t.anchorPointY+_[1];if(m&&!p){const Le=this.projectAndGetPerspectiveRatio(W+1,Z,l,b,E),Ae=Le.x-x.x,Ue=Math.atan((Le.y-x.y)/Ae)+(Ae<0?Math.PI:0),gt=Math.sin(Ue),Ht=Math.cos(Ue);I=Ht,k=gt,V=-gt,q=Ht}else if(!m&&p){const Le=pn(this.transform);I=Le.vecEast[0],k=Le.vecEast[1],V=Le.vecSouth[0],q=Le.vecSouth[1]}let Y=x.x,ie=x.y,H=n;p&&(Y=W,ie=Z,H=Math.pow(2,-(this.transform.zoom-a.overscaledZ)),H*=this.transform.getPitchedTextCorrection(W,Z,l),T||(H*=c.an(.5+x.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))),T&&(Y+=I*T.x*H+V*T.y*H,ie+=k*T.x*H+q*T.y*H);const ee=t.x1*H,se=t.x2*H,J=(ee+se)/2,oe=t.y1*H,Te=t.y2*H,_e=(oe+Te)/2,xe=[{offsetX:ee,offsetY:oe},{offsetX:J,offsetY:oe},{offsetX:se,offsetY:oe},{offsetX:se,offsetY:_e},{offsetX:se,offsetY:Te},{offsetX:J,offsetY:Te},{offsetX:ee,offsetY:Te},{offsetX:ee,offsetY:_e}];let ve=[];for(const{offsetX:Le,offsetY:Ae}of xe)ve.push(new c.P(Y+I*Le+V*Ae,ie+k*Le+q*Ae));let Fe=!1;if(p){const Le=ve.map((Ae=>this.projectAndGetPerspectiveRatio(Ae.x,Ae.y,l,b,E)));Fe=Le.some((Ae=>!Ae.isOccluded)),ve=Le.map((Ae=>new c.P(Ae.x,Ae.y)))}else Fe=!0;return{box:c.aL(ve),allPointsOccluded:!Fe}}}class bc{constructor(t,n,a,l){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?n:-n))):l&&a?1:0,this.placed=a}isHidden(){return this.opacity===0&&!this.placed}}class Hs{constructor(t,n,a,l,p){this.text=new bc(t?t.text:null,n,a,p),this.icon=new bc(t?t.icon:null,n,l,p)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class wc{constructor(t,n,a){this.text=t,this.icon=n,this.skipFade=a}}class Tc{constructor(t,n,a,l,p){this.bucketInstanceId=t,this.featureIndex=n,this.sourceLayerIndex=a,this.bucketIndex=l,this.tileID=p}}class Sc{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:a=>a.collisionGroupID===n}}return this.collisionGroups[t]}}function Za(d,t,n,a,l){const{horizontalAlign:p,verticalAlign:m}=c.aS(d);return new c.P(-(p-.5)*t+a[0]*l,-(m-.5)*n+a[1]*l)}class Jo{constructor(t,n,a,l,p){this.transform=t.clone(),this.terrain=n,this.collisionIndex=new vc(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=a,this.retainedQueryData={},this.collisionGroups=new Sc(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?(a,l)=>n.getElevation(t,a,l):null}getBucketParts(t,n,a,l){const p=a.getBucket(n),m=a.latestFeatureIndex;if(!p||!m||n.id!==p.layerIds[0])return;const _=a.collisionBoxArray,x=p.layers[0].layout,b=p.layers[0].paint,T=Math.pow(2,this.transform.zoom-a.tileID.overscaledZ),E=a.tileSize/c.a5,I=a.tileID.toUnwrapped(),k=x.get("text-rotation-alignment")==="map",V=c.aN(a,1,this.transform.zoom),q=c.aO(this.collisionIndex.transform,a,b.get("text-translate"),b.get("text-translate-anchor")),W=c.aO(this.collisionIndex.transform,a,b.get("icon-translate"),b.get("icon-translate-anchor")),Z=Dr(k,this.transform,V);this.retainedQueryData[p.bucketInstanceId]=new Tc(p.bucketInstanceId,m,p.sourceLayerIndex,p.index,a.tileID);const Y={bucket:p,layout:x,translationText:q,translationIcon:W,unwrappedTileID:I,pitchedLabelPlaneMatrix:Z,scale:T,textPixelRatio:E,holdingForFade:a.holdingForSymbolFade(),collisionBoxArray:_,partiallyEvaluatedTextSize:c.ay(p.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(p.sourceID)};if(l)for(const ie of p.sortKeyRanges){const{sortKey:H,symbolInstanceStart:ee,symbolInstanceEnd:se}=ie;t.push({sortKey:H,symbolInstanceStart:ee,symbolInstanceEnd:se,parameters:Y})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:p.symbolInstances.length,parameters:Y})}attemptAnchorPlacement(t,n,a,l,p,m,_,x,b,T,E,I,k,V,q,W,Z,Y,ie,H){const ee=c.aP[t.textAnchor],se=[t.textOffset0,t.textOffset1],J=Za(ee,a,l,se,p),oe=this.collisionIndex.placeCollisionBox(n,I,x,b,T,_,m,W,E.predicate,ie,J,H);if((!Y||this.collisionIndex.placeCollisionBox(Y,I,x,b,T,_,m,Z,E.predicate,ie,J,H).placeable)&&oe.placeable){let Te;if(this.prevPlacement&&this.prevPlacement.variableOffsets[k.crossTileID]&&this.prevPlacement.placements[k.crossTileID]&&this.prevPlacement.placements[k.crossTileID].text&&(Te=this.prevPlacement.variableOffsets[k.crossTileID].anchor),k.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[k.crossTileID]={textOffset:se,width:a,height:l,anchor:ee,textBoxScale:p,prevAnchor:Te},this.markUsedJustification(V,ee,k,q),V.allowVerticalPlacement&&(this.markUsedOrientation(V,q,k),this.placedOrientations[k.crossTileID]=q),{shift:J,placedGlyphBoxes:oe}}}placeLayerBucketPart(t,n,a){const{bucket:l,layout:p,translationText:m,translationIcon:_,unwrappedTileID:x,pitchedLabelPlaneMatrix:b,textPixelRatio:T,holdingForFade:E,collisionBoxArray:I,partiallyEvaluatedTextSize:k,collisionGroup:V}=t.parameters,q=p.get("text-optional"),W=p.get("icon-optional"),Z=c.aQ(p,"text-overlap","text-allow-overlap"),Y=Z==="always",ie=c.aQ(p,"icon-overlap","icon-allow-overlap"),H=ie==="always",ee=p.get("text-rotation-alignment")==="map",se=p.get("text-pitch-alignment")==="map",J=p.get("icon-text-fit")!=="none",oe=p.get("symbol-z-order")==="viewport-y",Te=Y&&(H||!l.hasIconData()||W),_e=H&&(Y||!l.hasTextData()||q);!l.collisionArrays&&I&&l.deserializeCollisionBoxes(I);const xe=this.retainedQueryData[l.bucketInstanceId].tileID,ve=this._getTerrainElevationFunc(xe),Fe=this.transform.getFastPathSimpleProjectionMatrix(xe),Le=(Ae,Ue,gt)=>{var Ht,_i;if(n[Ae.crossTileID])return;if(E)return void(this.placements[Ae.crossTileID]=new wc(!1,!1,!1));let li=!1,wi=!1,ci=!0,Fi=null,Ti={box:null,placeable:!1,offscreen:null,occluded:!1},Qi={placeable:!1},qi=null,Ui=null,or=null,Dn=0,gn=0,cn=0;Ue.textFeatureIndex?Dn=Ue.textFeatureIndex:Ae.useRuntimeCollisionCircles&&(Dn=Ae.featureIndex),Ue.verticalTextFeatureIndex&&(gn=Ue.verticalTextFeatureIndex);const Ir=Ue.textBox;if(Ir){const qr=hi=>{let ui=c.az.horizontal;if(l.allowVerticalPlacement&&!hi&&this.prevPlacement){const Yi=this.prevPlacement.placedOrientations[Ae.crossTileID];Yi&&(this.placedOrientations[Ae.crossTileID]=Yi,ui=Yi,this.markUsedOrientation(l,ui,Ae))}return ui},un=(hi,ui)=>{if(l.allowVerticalPlacement&&Ae.numVerticalGlyphVertices>0&&Ue.verticalTextBox){for(const Yi of l.writingModes)if(Yi===c.az.vertical?(Ti=ui(),Qi=Ti):Ti=hi(),Ti&&Ti.placeable)break}else Ti=hi()},en=Ae.textAnchorOffsetStartIndex,tn=Ae.textAnchorOffsetEndIndex;if(tn===en){const hi=(ui,Yi)=>{const Ki=this.collisionIndex.placeCollisionBox(ui,Z,T,xe,x,se,ee,m,V.predicate,ve,void 0,Fe);return Ki&&Ki.placeable&&(this.markUsedOrientation(l,Yi,Ae),this.placedOrientations[Ae.crossTileID]=Yi),Ki};un((()=>hi(Ir,c.az.horizontal)),(()=>{const ui=Ue.verticalTextBox;return l.allowVerticalPlacement&&Ae.numVerticalGlyphVertices>0&&ui?hi(ui,c.az.vertical):{box:null,offscreen:null}})),qr(Ti&&Ti.placeable)}else{let hi=c.aP[(_i=(Ht=this.prevPlacement)===null||Ht===void 0?void 0:Ht.variableOffsets[Ae.crossTileID])===null||_i===void 0?void 0:_i.anchor];const ui=(Ki,xu,vu)=>{const is=Ki.x2-Ki.x1,Dh=Ki.y2-Ki.y1,bu=Ae.textBoxScale,$l=J&&ie==="never"?xu:null;let zn=null,kn=Z==="never"?1:2,Rn="never";hi&&kn++;for(let Wl=0;Wl<kn;Wl++){for(let Hl=en;Hl<tn;Hl++){const Co=l.textAnchorOffsets.get(Hl);if(hi&&Co.textAnchor!==hi)continue;const Ao=this.attemptAnchorPlacement(Co,Ki,is,Dh,bu,ee,se,T,xe,x,V,Rn,Ae,l,vu,m,_,$l,ve);if(Ao&&(zn=Ao.placedGlyphBoxes,zn&&zn.placeable))return li=!0,Fi=Ao.shift,zn}hi?hi=null:Rn=Z}return a&&!zn&&(zn={box:this.collisionIndex.placeCollisionBox(Ir,"always",T,xe,x,se,ee,m,V.predicate,ve,void 0,Fe).box,offscreen:!1,placeable:!1,occluded:!1}),zn};un((()=>ui(Ir,Ue.iconBox,c.az.horizontal)),(()=>{const Ki=Ue.verticalTextBox;return l.allowVerticalPlacement&&(!Ti||!Ti.placeable)&&Ae.numVerticalGlyphVertices>0&&Ki?ui(Ki,Ue.verticalIconBox,c.az.vertical):{box:null,occluded:!0,offscreen:null}})),Ti&&(li=Ti.placeable,ci=Ti.offscreen);const Yi=qr(Ti&&Ti.placeable);if(!li&&this.prevPlacement){const Ki=this.prevPlacement.variableOffsets[Ae.crossTileID];Ki&&(this.variableOffsets[Ae.crossTileID]=Ki,this.markUsedJustification(l,Ki.anchor,Ae,Yi))}}}if(qi=Ti,li=qi&&qi.placeable,ci=qi&&qi.offscreen,Ae.useRuntimeCollisionCircles&&Ae.centerJustifiedTextSymbolIndex>=0){const qr=l.text.placedSymbolArray.get(Ae.centerJustifiedTextSymbolIndex),un=c.aA(l.textSizeData,k,qr),en=p.get("text-padding");Ui=this.collisionIndex.placeCollisionCircles(Z,qr,l.lineVertexArray,l.glyphOffsetArray,un,x,b,a,se,V.predicate,Ae.collisionCircleDiameter,en,m,ve),Ui.circles.length&&Ui.collisionDetected&&!a&&c.w("Collisions detected, but collision boxes are not shown"),li=Y||Ui.circles.length>0&&!Ui.collisionDetected,ci=ci&&Ui.offscreen}if(Ue.iconFeatureIndex&&(cn=Ue.iconFeatureIndex),Ue.iconBox){const qr=un=>this.collisionIndex.placeCollisionBox(un,ie,T,xe,x,se,ee,_,V.predicate,ve,J&&Fi?Fi:void 0,Fe);Qi&&Qi.placeable&&Ue.verticalIconBox?(or=qr(Ue.verticalIconBox),wi=or.placeable):(or=qr(Ue.iconBox),wi=or.placeable),ci=ci&&or.offscreen}const es=q||Ae.numHorizontalGlyphVertices===0&&Ae.numVerticalGlyphVertices===0,Ea=W||Ae.numIconVertices===0;es||Ea?Ea?es||(wi=wi&&li):li=wi&&li:wi=li=wi&&li;const ts=wi&&or.placeable;if(li&&qi.placeable&&this.collisionIndex.insertCollisionBox(qi.box,Z,p.get("text-ignore-placement"),l.bucketInstanceId,Qi&&Qi.placeable&&gn?gn:Dn,V.ID),ts&&this.collisionIndex.insertCollisionBox(or.box,ie,p.get("icon-ignore-placement"),l.bucketInstanceId,cn,V.ID),Ui&&li&&this.collisionIndex.insertCollisionCircles(Ui.circles,Z,p.get("text-ignore-placement"),l.bucketInstanceId,Dn,V.ID),a&&this.storeCollisionData(l.bucketInstanceId,gt,Ue,qi,or,Ui),Ae.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[Ae.crossTileID]=new wc((li||Te)&&!(qi!=null&&qi.occluded),(wi||_e)&&!(or!=null&&or.occluded),ci||l.justReloaded),n[Ae.crossTileID]=!0};if(oe){if(t.symbolInstanceStart!==0)throw new Error("bucket.bucketInstanceId should be 0");const Ae=l.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let Ue=Ae.length-1;Ue>=0;--Ue){const gt=Ae[Ue];Le(l.symbolInstances.get(gt),l.collisionArrays[gt],gt)}}else for(let Ae=t.symbolInstanceStart;Ae<t.symbolInstanceEnd;Ae++)Le(l.symbolInstances.get(Ae),l.collisionArrays[Ae],Ae);l.justReloaded=!1}storeCollisionData(t,n,a,l,p,m){if(a.textBox||a.iconBox){let _,x;this.collisionBoxArrays.has(t)?_=this.collisionBoxArrays.get(t):(_=new Map,this.collisionBoxArrays.set(t,_)),_.has(n)?x=_.get(n):(x={text:null,icon:null},_.set(n,x)),a.textBox&&(x.text=l.box),a.iconBox&&(x.icon=p.box)}if(m){let _=this.collisionCircleArrays[t];_===void 0&&(_=this.collisionCircleArrays[t]=[]);for(let x=0;x<m.circles.length;x+=4)_.push(m.circles[x+0]-ki),_.push(m.circles[x+1]-ki),_.push(m.circles[x+2]),_.push(m.collisionDetected?1:0)}}markUsedJustification(t,n,a,l){let p;p=l===c.az.vertical?a.verticalPlacedTextSymbolIndex:{left:a.leftJustifiedTextSymbolIndex,center:a.centerJustifiedTextSymbolIndex,right:a.rightJustifiedTextSymbolIndex}[c.aR(n)];const m=[a.leftJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.rightJustifiedTextSymbolIndex,a.verticalPlacedTextSymbolIndex];for(const _ of m)_>=0&&(t.text.placedSymbolArray.get(_).crossTileID=p>=0&&_!==p?0:a.crossTileID)}markUsedOrientation(t,n,a){const l=n===c.az.horizontal||n===c.az.horizontalOnly?n:0,p=n===c.az.vertical?n:0,m=[a.leftJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.rightJustifiedTextSymbolIndex];for(const _ of m)t.text.placedSymbolArray.get(_).placedOrientation=l;a.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(a.verticalPlacedTextSymbolIndex).placedOrientation=p)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const n=this.prevPlacement;let a=!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 x in this.placements){const b=this.placements[x],T=p[x];T?(this.opacities[x]=new Hs(T,l,b.text,b.icon),a=a||b.text!==T.text.placed||b.icon!==T.icon.placed):(this.opacities[x]=new Hs(null,l,b.text,b.icon,b.skipFade),a=a||b.text||b.icon)}for(const x in p){const b=p[x];if(!this.opacities[x]){const T=new Hs(b,l,!1,!1);T.isHidden()||(this.opacities[x]=T,a=a||b.text.placed||b.icon.placed)}}for(const x in m)this.variableOffsets[x]||!this.opacities[x]||this.opacities[x].isHidden()||(this.variableOffsets[x]=m[x]);for(const x in _)this.placedOrientations[x]||!this.opacities[x]||this.opacities[x].isHidden()||(this.placedOrientations[x]=_[x]);if(n&&n.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");a?this.lastPlacementChangeTime=t:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=n?n.lastPlacementChangeTime:t)}updateLayerOpacities(t,n){const a={};for(const l of n){const p=l.getBucket(t);p&&l.latestFeatureIndex&&t.id===p.layerIds[0]&&this.updateBucketOpacities(p,l.tileID,a,l.collisionBoxArray)}}updateBucketOpacities(t,n,a,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 Hs(null,0,!1,!1,!0),x=m.get("text-allow-overlap"),b=m.get("icon-allow-overlap"),T=p._unevaluatedLayout.hasValue("text-variable-anchor")||p._unevaluatedLayout.hasValue("text-variable-anchor-offset"),E=m.get("text-rotation-alignment")==="map",I=m.get("text-pitch-alignment")==="map",k=m.get("icon-text-fit")!=="none",V=new Hs(null,0,x&&(b||!t.hasIconData()||m.get("icon-optional")),b&&(x||!t.hasTextData()||m.get("text-optional")),!0);!t.collisionArrays&&l&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(l);const q=(Z,Y,ie)=>{for(let H=0;H<Y/4;H++)Z.opacityVertexArray.emplaceBack(ie);Z.hasVisibleVertices=Z.hasVisibleVertices||ie!==Ys},W=this.collisionBoxArrays.get(t.bucketInstanceId);for(let Z=0;Z<t.symbolInstances.length;Z++){const Y=t.symbolInstances.get(Z),{numHorizontalGlyphVertices:ie,numVerticalGlyphVertices:H,crossTileID:ee}=Y;let se=this.opacities[ee];a[ee]?se=_:se||(se=V,this.opacities[ee]=se),a[ee]=!0;const J=Y.numIconVertices>0,oe=this.placedOrientations[Y.crossTileID],Te=oe===c.az.vertical,_e=oe===c.az.horizontal||oe===c.az.horizontalOnly;if(ie>0||H>0){const ve=il(se.text);q(t.text,ie,Te?Ys:ve),q(t.text,H,_e?Ys:ve);const Fe=se.text.isHidden();[Y.rightJustifiedTextSymbolIndex,Y.centerJustifiedTextSymbolIndex,Y.leftJustifiedTextSymbolIndex].forEach((Ue=>{Ue>=0&&(t.text.placedSymbolArray.get(Ue).hidden=Fe||Te?1:0)})),Y.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(Y.verticalPlacedTextSymbolIndex).hidden=Fe||_e?1:0);const Le=this.variableOffsets[Y.crossTileID];Le&&this.markUsedJustification(t,Le.anchor,Y,oe);const Ae=this.placedOrientations[Y.crossTileID];Ae&&(this.markUsedJustification(t,"left",Y,Ae),this.markUsedOrientation(t,Ae,Y))}if(J){const ve=il(se.icon),Fe=!(k&&Y.verticalPlacedIconSymbolIndex&&Te);Y.placedIconSymbolIndex>=0&&(q(t.icon,Y.numIconVertices,Fe?ve:Ys),t.icon.placedSymbolArray.get(Y.placedIconSymbolIndex).hidden=se.icon.isHidden()),Y.verticalPlacedIconSymbolIndex>=0&&(q(t.icon,Y.numVerticalIconVertices,Fe?Ys:ve),t.icon.placedSymbolArray.get(Y.verticalPlacedIconSymbolIndex).hidden=se.icon.isHidden())}const xe=W&&W.has(Z)?W.get(Z):{text:null,icon:null};if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const ve=t.collisionArrays[Z];if(ve){let Fe=new c.P(0,0);if(ve.textBox||ve.verticalTextBox){let Le=!0;if(T){const Ae=this.variableOffsets[ee];Ae?(Fe=Za(Ae.anchor,Ae.width,Ae.height,Ae.textOffset,Ae.textBoxScale),E&&Fe._rotate(I?-this.transform.bearingInRadians:this.transform.bearingInRadians)):Le=!1}if(ve.textBox||ve.verticalTextBox){let Ae;ve.textBox&&(Ae=Te),ve.verticalTextBox&&(Ae=_e),Qo(t.textCollisionBox.collisionVertexArray,se.text.placed,!Le||Ae,xe.text,Fe.x,Fe.y)}}if(ve.iconBox||ve.verticalIconBox){const Le=!!(!_e&&ve.verticalIconBox);let Ae;ve.iconBox&&(Ae=Le),ve.verticalIconBox&&(Ae=!Le),Qo(t.iconCollisionBox.collisionVertexArray,se.icon.placed,Ae,xe.icon,k?Fe.x:0,k?Fe.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 a=this.zoomAtLastRecencyCheck===n?1-this.zoomAdjustment(n):1;return this.zoomAtLastRecencyCheck=n,this.commitTime+this.fadeDuration*a>t}setStale(){this.stale=!0}}function Qo(d,t,n,a,l,p){a&&a.length!==0||(a=[0,0,0,0]);const m=a[0]-ki,_=a[1]-ki,x=a[2]-ki,b=a[3]-ki;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,x,_),d.emplaceBack(t?1:0,n?1:0,l||0,p||0,x,b),d.emplaceBack(t?1:0,n?1:0,l||0,p||0,m,b)}const el=Math.pow(2,25),tl=Math.pow(2,24),ah=Math.pow(2,17),Xs=Math.pow(2,16),$a=Math.pow(2,9),Pc=Math.pow(2,8),ds=Math.pow(2,1);function il(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*el+t*tl+n*ah+t*Xs+n*$a+t*Pc+n*ds+t}const Ys=0;class wn{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,a,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(((_,x)=>_.sortKey-x.sortKey)));this._currentPartIndex<m.length;)if(n.placeLayerBucketPart(m[this._currentPartIndex],this._seenCrossTileIDs,a),this._currentPartIndex++,p())return!0;return!1}}class ps{constructor(t,n,a,l,p,m,_,x){this.placement=new Jo(t,n,m,_,x),this._currentPlacementIndex=a.length-1,this._forceFullPlacement=l,this._showCollisionBoxes=p,this._done=!1}isDone(){return this._done}continuePlacement(t,n,a){const l=Je(),p=()=>!this._forceFullPlacement&&Je()-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 wn(m)),this._inProgressLayer.continuePlacement(a[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 Mt=512/c.a5/2;class rl{constructor(t,n,a){this.tileID=t,this.bucketInstanceId=a,this._symbolsByKey={};const l=new Map;for(let p=0;p<n.length;p++){const m=n.get(p),_=m.key,x=l.get(_);x?x.push(m):l.set(_,[m])}for(const[p,m]of l){const _={positions:m.map((x=>({x:Math.floor(x.anchorX*Mt),y:Math.floor(x.anchorY*Mt)}))),crossTileIDs:m.map((x=>x.crossTileID))};if(_.positions.length>128){const x=new c.aT(_.positions.length,16,Uint16Array);for(const{x:b,y:T}of _.positions)x.add(b,T);x.finish(),delete _.positions,_.index=x}this._symbolsByKey[p]=_}}getScaledCoordinates(t,n){const{x:a,y:l,z:p}=this.tileID.canonical,{x:m,y:_,z:x}=n.canonical,b=Mt/Math.pow(2,x-p),T=(_*c.a5+t.anchorY)*b,E=l*c.a5*Mt;return{x:Math.floor((m*c.a5+t.anchorX)*b-a*c.a5*Mt),y:Math.floor(T-E)}}findMatches(t,n,a){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 x=this.getScaledCoordinates(m,n);if(_.index){const b=_.index.range(x.x-l,x.y-l,x.x+l,x.y+l).sort();for(const T of b){const E=_.crossTileIDs[T];if(!a[E]){a[E]=!0,m.crossTileID=E;break}}}else if(_.positions)for(let b=0;b<_.positions.length;b++){const T=_.positions[b],E=_.crossTileIDs[b];if(Math.abs(T.x-x.x)<=l&&Math.abs(T.y-x.y)<=l&&!a[E]){a[E]=!0,m.crossTileID=E;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map((({crossTileIDs:t})=>t))}}class oh{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class nl{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const n=Math.round((t-this.lng)/360);if(n!==0)for(const a in this.indexes){const l=this.indexes[a],p={};for(const m in l){const _=l[m];_.tileID=_.tileID.unwrapTo(_.tileID.wrap+n),p[_.tileID.key]=_}this.indexes[a]=p}this.lng=t}addBucket(t,n,a){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 x=m[_];x.tileID.isChildOf(t)&&x.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=a.generate(),l[m.crossTileID]=!0)}return this.indexes[t.overscaledZ]===void 0&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new rl(t,n.symbolInstances,n.bucketInstanceId),!0}removeBucketCrossTileIDs(t,n){for(const a of n.getCrossTileIDsLists())for(const l of a)delete this.usedCrossTileIDs[t][l]}removeStaleBuckets(t){let n=!1;for(const a in this.indexes){const l=this.indexes[a];for(const p in l)t[l[p].bucketInstanceId]||(this.removeBucketCrossTileIDs(a,l[p]),delete l[p],n=!0)}return n}}class Pr{constructor(){this.layerIndexes={},this.crossTileIDs=new oh,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,n,a){let l=this.layerIndexes[t.id];l===void 0&&(l=this.layerIndexes[t.id]=new nl);let p=!1;const m={};l.handleWrapJump(a);for(const _ of n){const x=_.getBucket(t);x&&t.id===x.layerIds[0]&&(x.bucketInstanceId||(x.bucketInstanceId=++this.maxBucketInstanceId),l.addBucket(_.tileID,x,this.crossTileIDs)&&(p=!0),m[x.bucketInstanceId]=!0)}return l.removeStaleBuckets(m)&&(p=!0),p}pruneUnusedLayers(t){const n={};t.forEach((a=>{n[a]=!0}));for(const a in this.layerIndexes)n[a]||delete this.layerIndexes[a]}}var ur="void main() {fragColor=vec4(1.0);}";const Ii={prelude:ut(`#ifdef GL_ES
6
+ precision mediump float;
7
+ #else
8
+ #if !defined(lowp)
9
+ #define lowp
10
+ #endif
11
+ #if !defined(mediump)
12
+ #define mediump
13
+ #endif
14
+ #if !defined(highp)
15
+ #define highp
16
+ #endif
17
+ #endif
18
+ out highp vec4 fragColor;`,`#ifdef GL_ES
19
+ precision highp float;
20
+ #else
21
+ #if !defined(lowp)
22
+ #define lowp
23
+ #endif
24
+ #if !defined(mediump)
25
+ #define mediump
26
+ #endif
27
+ #if !defined(highp)
28
+ #define highp
29
+ #endif
30
+ #endif
31
+ 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
32
+ );}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
33
+ );}
34
+ #ifdef TERRAIN3D
35
+ 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;
36
+ #endif
37
+ 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) {
38
+ #ifdef TERRAIN3D
39
+ 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));
40
+ #else
41
+ return 1.0;
42
+ #endif
43
+ }float calculate_visibility(vec4 pos) {
44
+ #ifdef TERRAIN3D
45
+ 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;
46
+ #else
47
+ return 1.0;
48
+ #endif
49
+ }float ele(vec2 pos) {
50
+ #ifdef TERRAIN3D
51
+ vec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;
52
+ #else
53
+ return 0.0;
54
+ #endif
55
+ }float get_elevation(vec2 pos) {
56
+ #ifdef TERRAIN3D
57
+ #ifdef GLOBE
58
+ if ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}
59
+ #endif
60
+ 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;
61
+ #else
62
+ return 0.0;
63
+ #endif
64
+ }const float PI=3.141592653589793;uniform mat4 u_projection_matrix;`),projectionMercator:ut("","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:ut("",`#define GLOBE_RADIUS 6371008.8
65
+ 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
66
+ );}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);
67
+ 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
68
+ );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:ut(`uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;
69
+ #ifdef OVERDRAW_INSPECTOR
70
+ fragColor=vec4(1.0);
71
+ #endif
72
+ }`,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:ut(`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;
73
+ #ifdef OVERDRAW_INSPECTOR
74
+ fragColor=vec4(1.0);
75
+ #endif
76
+ }`,"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:ut(`in vec3 v_data;in float v_visibility;
77
+ #pragma mapbox: define highp vec4 color
78
+ #pragma mapbox: define mediump float radius
79
+ #pragma mapbox: define lowp float blur
80
+ #pragma mapbox: define lowp float opacity
81
+ #pragma mapbox: define highp vec4 stroke_color
82
+ #pragma mapbox: define mediump float stroke_width
83
+ #pragma mapbox: define lowp float stroke_opacity
84
+ void main() {
85
+ #pragma mapbox: initialize highp vec4 color
86
+ #pragma mapbox: initialize mediump float radius
87
+ #pragma mapbox: initialize lowp float blur
88
+ #pragma mapbox: initialize lowp float opacity
89
+ #pragma mapbox: initialize highp vec4 stroke_color
90
+ #pragma mapbox: initialize mediump float stroke_width
91
+ #pragma mapbox: initialize lowp float stroke_opacity
92
+ 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;}
93
+ #ifdef OVERDRAW_INSPECTOR
94
+ fragColor=vec4(1.0);
95
+ #endif
96
+ }`,`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;
97
+ #pragma mapbox: define highp vec4 color
98
+ #pragma mapbox: define mediump float radius
99
+ #pragma mapbox: define lowp float blur
100
+ #pragma mapbox: define lowp float opacity
101
+ #pragma mapbox: define highp vec4 stroke_color
102
+ #pragma mapbox: define mediump float stroke_width
103
+ #pragma mapbox: define lowp float stroke_opacity
104
+ void main(void) {
105
+ #pragma mapbox: initialize highp vec4 color
106
+ #pragma mapbox: initialize mediump float radius
107
+ #pragma mapbox: initialize lowp float blur
108
+ #pragma mapbox: initialize lowp float opacity
109
+ #pragma mapbox: initialize highp vec4 stroke_color
110
+ #pragma mapbox: initialize mediump float stroke_width
111
+ #pragma mapbox: initialize lowp float stroke_opacity
112
+ 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) {
113
+ #ifdef GLOBE
114
+ vec3 center_vector=projectToSphere(circle_center);
115
+ #endif
116
+ 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 {
117
+ #ifdef GLOBE
118
+ vec4 projected_center=interpolateProjection(circle_center,center_vector,ele);
119
+ #else
120
+ vec4 projected_center=projectTileWithElevation(circle_center,ele);
121
+ #endif
122
+ 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);}
123
+ #ifdef GLOBE
124
+ vec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);
125
+ #else
126
+ gl_Position=projectTileWithElevation(corner_position,ele);
127
+ #endif
128
+ } 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:ut(ur,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:ut(`uniform highp float u_intensity;in vec2 v_extrude;
129
+ #pragma mapbox: define highp float weight
130
+ #define GAUSS_COEF 0.3989422804014327
131
+ void main() {
132
+ #pragma mapbox: initialize highp float weight
133
+ 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);
134
+ #ifdef OVERDRAW_INSPECTOR
135
+ fragColor=vec4(1.0);
136
+ #endif
137
+ }`,`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;
138
+ #pragma mapbox: define highp float weight
139
+ #pragma mapbox: define mediump float radius
140
+ const highp float ZERO=1.0/255.0/16.0;
141
+ #define GAUSS_COEF 0.3989422804014327
142
+ void main(void) {
143
+ #pragma mapbox: initialize highp float weight
144
+ #pragma mapbox: initialize mediump float radius
145
+ 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);
146
+ #ifdef GLOBE
147
+ 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);
148
+ #else
149
+ gl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));
150
+ #endif
151
+ }`),heatmapTexture:ut(`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;
152
+ #ifdef OVERDRAW_INSPECTOR
153
+ fragColor=vec4(0.0);
154
+ #endif
155
+ }`,"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:ut("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:ut("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:ut(`#ifdef GL_ES
156
+ precision highp float;
157
+ #endif
158
+ 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
159
+ {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));
160
+ #ifdef OVERDRAW_INSPECTOR
161
+ fragColor=vec4(1.0);
162
+ #endif
163
+ }`,"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:ut("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:ut(ur,`in vec2 a_pos;void main() {
164
+ #ifdef GLOBE
165
+ gl_Position=projectTileFor3D(a_pos,0.0);
166
+ #else
167
+ gl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);
168
+ #endif
169
+ }`),fill:ut(`#pragma mapbox: define highp vec4 color
170
+ #pragma mapbox: define lowp float opacity
171
+ void main() {
172
+ #pragma mapbox: initialize highp vec4 color
173
+ #pragma mapbox: initialize lowp float opacity
174
+ fragColor=color*opacity;
175
+ #ifdef OVERDRAW_INSPECTOR
176
+ fragColor=vec4(1.0);
177
+ #endif
178
+ }`,`uniform vec2 u_fill_translate;in vec2 a_pos;
179
+ #pragma mapbox: define highp vec4 color
180
+ #pragma mapbox: define lowp float opacity
181
+ void main() {
182
+ #pragma mapbox: initialize highp vec4 color
183
+ #pragma mapbox: initialize lowp float opacity
184
+ gl_Position=projectTile(a_pos+u_fill_translate,a_pos);}`),fillOutline:ut(`in vec2 v_pos;
185
+ #ifdef GLOBE
186
+ in float v_depth;
187
+ #endif
188
+ #pragma mapbox: define highp vec4 outline_color
189
+ #pragma mapbox: define lowp float opacity
190
+ void main() {
191
+ #pragma mapbox: initialize highp vec4 outline_color
192
+ #pragma mapbox: initialize lowp float opacity
193
+ float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);
194
+ #ifdef GLOBE
195
+ if (v_depth > 1.0) {discard;}
196
+ #endif
197
+ #ifdef OVERDRAW_INSPECTOR
198
+ fragColor=vec4(1.0);
199
+ #endif
200
+ }`,`uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;
201
+ #ifdef GLOBE
202
+ out float v_depth;
203
+ #endif
204
+ #pragma mapbox: define highp vec4 outline_color
205
+ #pragma mapbox: define lowp float opacity
206
+ void main() {
207
+ #pragma mapbox: initialize highp vec4 outline_color
208
+ #pragma mapbox: initialize lowp float opacity
209
+ gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
210
+ #ifdef GLOBE
211
+ v_depth=gl_Position.z/gl_Position.w;
212
+ #endif
213
+ }`),fillOutlinePattern:ut(`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;
214
+ #ifdef GLOBE
215
+ in float v_depth;
216
+ #endif
217
+ #pragma mapbox: define lowp float opacity
218
+ #pragma mapbox: define lowp vec4 pattern_from
219
+ #pragma mapbox: define lowp vec4 pattern_to
220
+ void main() {
221
+ #pragma mapbox: initialize lowp float opacity
222
+ #pragma mapbox: initialize mediump vec4 pattern_from
223
+ #pragma mapbox: initialize mediump vec4 pattern_to
224
+ 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;
225
+ #ifdef GLOBE
226
+ if (v_depth > 1.0) {discard;}
227
+ #endif
228
+ #ifdef OVERDRAW_INSPECTOR
229
+ fragColor=vec4(1.0);
230
+ #endif
231
+ }`,`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;
232
+ #ifdef GLOBE
233
+ out float v_depth;
234
+ #endif
235
+ #pragma mapbox: define lowp float opacity
236
+ #pragma mapbox: define lowp vec4 pattern_from
237
+ #pragma mapbox: define lowp vec4 pattern_to
238
+ #pragma mapbox: define lowp float pixel_ratio_from
239
+ #pragma mapbox: define lowp float pixel_ratio_to
240
+ void main() {
241
+ #pragma mapbox: initialize lowp float opacity
242
+ #pragma mapbox: initialize mediump vec4 pattern_from
243
+ #pragma mapbox: initialize mediump vec4 pattern_to
244
+ #pragma mapbox: initialize lowp float pixel_ratio_from
245
+ #pragma mapbox: initialize lowp float pixel_ratio_to
246
+ 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;
247
+ #ifdef GLOBE
248
+ v_depth=gl_Position.z/gl_Position.w;
249
+ #endif
250
+ }`),fillPattern:ut(`#ifdef GL_ES
251
+ precision highp float;
252
+ #endif
253
+ uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;
254
+ #pragma mapbox: define lowp float opacity
255
+ #pragma mapbox: define lowp vec4 pattern_from
256
+ #pragma mapbox: define lowp vec4 pattern_to
257
+ void main() {
258
+ #pragma mapbox: initialize lowp float opacity
259
+ #pragma mapbox: initialize mediump vec4 pattern_from
260
+ #pragma mapbox: initialize mediump vec4 pattern_to
261
+ 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;
262
+ #ifdef OVERDRAW_INSPECTOR
263
+ fragColor=vec4(1.0);
264
+ #endif
265
+ }`,`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;
266
+ #pragma mapbox: define lowp float opacity
267
+ #pragma mapbox: define lowp vec4 pattern_from
268
+ #pragma mapbox: define lowp vec4 pattern_to
269
+ #pragma mapbox: define lowp float pixel_ratio_from
270
+ #pragma mapbox: define lowp float pixel_ratio_to
271
+ void main() {
272
+ #pragma mapbox: initialize lowp float opacity
273
+ #pragma mapbox: initialize mediump vec4 pattern_from
274
+ #pragma mapbox: initialize mediump vec4 pattern_to
275
+ #pragma mapbox: initialize lowp float pixel_ratio_from
276
+ #pragma mapbox: initialize lowp float pixel_ratio_to
277
+ 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:ut(`in vec4 v_color;void main() {fragColor=v_color;
278
+ #ifdef OVERDRAW_INSPECTOR
279
+ fragColor=vec4(1.0);
280
+ #endif
281
+ }`,`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;
282
+ #ifdef TERRAIN3D
283
+ in vec2 a_centroid;
284
+ #endif
285
+ out vec4 v_color;
286
+ #pragma mapbox: define highp float base
287
+ #pragma mapbox: define highp float height
288
+ #pragma mapbox: define highp vec4 color
289
+ void main() {
290
+ #pragma mapbox: initialize highp float base
291
+ #pragma mapbox: initialize highp float height
292
+ #pragma mapbox: initialize highp vec4 color
293
+ vec3 normal=a_normal_ed.xyz;
294
+ #ifdef TERRAIN3D
295
+ float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
296
+ #else
297
+ float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
298
+ #endif
299
+ 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;
300
+ #ifdef GLOBE
301
+ vec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);
302
+ #else
303
+ gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);
304
+ #endif
305
+ 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);
306
+ #ifdef GLOBE
307
+ mat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);
308
+ #endif
309
+ 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:ut(`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;
310
+ #pragma mapbox: define lowp float base
311
+ #pragma mapbox: define lowp float height
312
+ #pragma mapbox: define lowp vec4 pattern_from
313
+ #pragma mapbox: define lowp vec4 pattern_to
314
+ #pragma mapbox: define lowp float pixel_ratio_from
315
+ #pragma mapbox: define lowp float pixel_ratio_to
316
+ void main() {
317
+ #pragma mapbox: initialize lowp float base
318
+ #pragma mapbox: initialize lowp float height
319
+ #pragma mapbox: initialize mediump vec4 pattern_from
320
+ #pragma mapbox: initialize mediump vec4 pattern_to
321
+ #pragma mapbox: initialize lowp float pixel_ratio_from
322
+ #pragma mapbox: initialize lowp float pixel_ratio_to
323
+ 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;
324
+ #ifdef OVERDRAW_INSPECTOR
325
+ fragColor=vec4(1.0);
326
+ #endif
327
+ }`,`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;
328
+ #ifdef TERRAIN3D
329
+ in vec2 a_centroid;
330
+ #endif
331
+ #ifdef GLOBE
332
+ out vec3 v_sphere_pos;
333
+ #endif
334
+ out vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;
335
+ #pragma mapbox: define lowp float base
336
+ #pragma mapbox: define lowp float height
337
+ #pragma mapbox: define lowp vec4 pattern_from
338
+ #pragma mapbox: define lowp vec4 pattern_to
339
+ #pragma mapbox: define lowp float pixel_ratio_from
340
+ #pragma mapbox: define lowp float pixel_ratio_to
341
+ void main() {
342
+ #pragma mapbox: initialize lowp float base
343
+ #pragma mapbox: initialize lowp float height
344
+ #pragma mapbox: initialize mediump vec4 pattern_from
345
+ #pragma mapbox: initialize mediump vec4 pattern_to
346
+ #pragma mapbox: initialize lowp float pixel_ratio_from
347
+ #pragma mapbox: initialize lowp float pixel_ratio_to
348
+ 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;
349
+ #ifdef TERRAIN3D
350
+ float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
351
+ #else
352
+ float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
353
+ #endif
354
+ 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;
355
+ #ifdef GLOBE
356
+ vec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);
357
+ #else
358
+ gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);
359
+ #endif
360
+ vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0
361
+ ? a_pos
362
+ : 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:ut(`#ifdef GL_ES
363
+ precision highp float;
364
+ #endif
365
+ 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);
366
+ #ifdef OVERDRAW_INSPECTOR
367
+ fragColor=vec4(1.0);
368
+ #endif
369
+ }`,"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:ut(`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];
370
+ #define PI 3.141592653589793
371
+ #define STANDARD 0
372
+ #define COMBINED 1
373
+ #define IGOR 2
374
+ #define MULTIDIRECTIONAL 3
375
+ #define BASIC 4
376
+ 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
377
+ {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
378
+ {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);}
379
+ #ifdef OVERDRAW_INSPECTOR
380
+ fragColor=vec4(1.0);
381
+ #endif
382
+ }`,"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:ut(`uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;
383
+ #ifdef GLOBE
384
+ in float v_depth;
385
+ #endif
386
+ #pragma mapbox: define highp vec4 color
387
+ #pragma mapbox: define lowp float blur
388
+ #pragma mapbox: define lowp float opacity
389
+ void main() {
390
+ #pragma mapbox: initialize highp vec4 color
391
+ #pragma mapbox: initialize lowp float blur
392
+ #pragma mapbox: initialize lowp float opacity
393
+ 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);
394
+ #ifdef GLOBE
395
+ if (v_depth > 1.0) {discard;}
396
+ #endif
397
+ #ifdef OVERDRAW_INSPECTOR
398
+ fragColor=vec4(1.0);
399
+ #endif
400
+ }`,`
401
+ #define scale 0.015873016
402
+ 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;
403
+ #ifdef GLOBE
404
+ out float v_depth;
405
+ #endif
406
+ #pragma mapbox: define highp vec4 color
407
+ #pragma mapbox: define lowp float blur
408
+ #pragma mapbox: define lowp float opacity
409
+ #pragma mapbox: define mediump float gapwidth
410
+ #pragma mapbox: define lowp float offset
411
+ #pragma mapbox: define mediump float width
412
+ void main() {
413
+ #pragma mapbox: initialize highp vec4 color
414
+ #pragma mapbox: initialize lowp float blur
415
+ #pragma mapbox: initialize lowp float opacity
416
+ #pragma mapbox: initialize mediump float gapwidth
417
+ #pragma mapbox: initialize lowp float offset
418
+ #pragma mapbox: initialize mediump float width
419
+ 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;
420
+ #ifdef GLOBE
421
+ v_depth=gl_Position.z/gl_Position.w;
422
+ #endif
423
+ #ifdef TERRAIN3D
424
+ v_gamma_scale=1.0;
425
+ #else
426
+ 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;
427
+ #endif
428
+ v_width2=vec2(outset,inset);}`),lineGradient:ut(`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;
429
+ #ifdef GLOBE
430
+ in float v_depth;
431
+ #endif
432
+ #pragma mapbox: define lowp float blur
433
+ #pragma mapbox: define lowp float opacity
434
+ void main() {
435
+ #pragma mapbox: initialize lowp float blur
436
+ #pragma mapbox: initialize lowp float opacity
437
+ 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);
438
+ #ifdef GLOBE
439
+ if (v_depth > 1.0) {discard;}
440
+ #endif
441
+ #ifdef OVERDRAW_INSPECTOR
442
+ fragColor=vec4(1.0);
443
+ #endif
444
+ }`,`
445
+ #define scale 0.015873016
446
+ 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;
447
+ #ifdef GLOBE
448
+ out float v_depth;
449
+ #endif
450
+ #pragma mapbox: define lowp float blur
451
+ #pragma mapbox: define lowp float opacity
452
+ #pragma mapbox: define mediump float gapwidth
453
+ #pragma mapbox: define lowp float offset
454
+ #pragma mapbox: define mediump float width
455
+ void main() {
456
+ #pragma mapbox: initialize lowp float blur
457
+ #pragma mapbox: initialize lowp float opacity
458
+ #pragma mapbox: initialize mediump float gapwidth
459
+ #pragma mapbox: initialize lowp float offset
460
+ #pragma mapbox: initialize mediump float width
461
+ 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;
462
+ #ifdef GLOBE
463
+ v_depth=gl_Position.z/gl_Position.w;
464
+ #endif
465
+ #ifdef TERRAIN3D
466
+ v_gamma_scale=1.0;
467
+ #else
468
+ 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;
469
+ #endif
470
+ v_width2=vec2(outset,inset);}`),linePattern:ut(`#ifdef GL_ES
471
+ precision highp float;
472
+ #endif
473
+ 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;
474
+ #ifdef GLOBE
475
+ in float v_depth;
476
+ #endif
477
+ #pragma mapbox: define lowp vec4 pattern_from
478
+ #pragma mapbox: define lowp vec4 pattern_to
479
+ #pragma mapbox: define lowp float pixel_ratio_from
480
+ #pragma mapbox: define lowp float pixel_ratio_to
481
+ #pragma mapbox: define lowp float blur
482
+ #pragma mapbox: define lowp float opacity
483
+ void main() {
484
+ #pragma mapbox: initialize mediump vec4 pattern_from
485
+ #pragma mapbox: initialize mediump vec4 pattern_to
486
+ #pragma mapbox: initialize lowp float pixel_ratio_from
487
+ #pragma mapbox: initialize lowp float pixel_ratio_to
488
+ #pragma mapbox: initialize lowp float blur
489
+ #pragma mapbox: initialize lowp float opacity
490
+ 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;
491
+ #ifdef GLOBE
492
+ if (v_depth > 1.0) {discard;}
493
+ #endif
494
+ #ifdef OVERDRAW_INSPECTOR
495
+ fragColor=vec4(1.0);
496
+ #endif
497
+ }`,`
498
+ #define scale 0.015873016
499
+ #define LINE_DISTANCE_SCALE 2.0
500
+ 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;
501
+ #ifdef GLOBE
502
+ out float v_depth;
503
+ #endif
504
+ #pragma mapbox: define lowp float blur
505
+ #pragma mapbox: define lowp float opacity
506
+ #pragma mapbox: define lowp float offset
507
+ #pragma mapbox: define mediump float gapwidth
508
+ #pragma mapbox: define mediump float width
509
+ #pragma mapbox: define lowp float floorwidth
510
+ #pragma mapbox: define lowp vec4 pattern_from
511
+ #pragma mapbox: define lowp vec4 pattern_to
512
+ #pragma mapbox: define lowp float pixel_ratio_from
513
+ #pragma mapbox: define lowp float pixel_ratio_to
514
+ void main() {
515
+ #pragma mapbox: initialize lowp float blur
516
+ #pragma mapbox: initialize lowp float opacity
517
+ #pragma mapbox: initialize lowp float offset
518
+ #pragma mapbox: initialize mediump float gapwidth
519
+ #pragma mapbox: initialize mediump float width
520
+ #pragma mapbox: initialize lowp float floorwidth
521
+ #pragma mapbox: initialize mediump vec4 pattern_from
522
+ #pragma mapbox: initialize mediump vec4 pattern_to
523
+ #pragma mapbox: initialize lowp float pixel_ratio_from
524
+ #pragma mapbox: initialize lowp float pixel_ratio_to
525
+ 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;
526
+ #ifdef GLOBE
527
+ v_depth=gl_Position.z/gl_Position.w;
528
+ #endif
529
+ #ifdef TERRAIN3D
530
+ v_gamma_scale=1.0;
531
+ #else
532
+ 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;
533
+ #endif
534
+ v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:ut(`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;
535
+ #ifdef GLOBE
536
+ in float v_depth;
537
+ #endif
538
+ #pragma mapbox: define highp vec4 color
539
+ #pragma mapbox: define lowp float blur
540
+ #pragma mapbox: define lowp float opacity
541
+ #pragma mapbox: define mediump float width
542
+ #pragma mapbox: define lowp float floorwidth
543
+ #pragma mapbox: define mediump vec4 dasharray_from
544
+ #pragma mapbox: define mediump vec4 dasharray_to
545
+ void main() {
546
+ #pragma mapbox: initialize highp vec4 color
547
+ #pragma mapbox: initialize lowp float blur
548
+ #pragma mapbox: initialize lowp float opacity
549
+ #pragma mapbox: initialize mediump float width
550
+ #pragma mapbox: initialize lowp float floorwidth
551
+ #pragma mapbox: initialize mediump vec4 dasharray_from
552
+ #pragma mapbox: initialize mediump vec4 dasharray_to
553
+ 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);
554
+ #ifdef GLOBE
555
+ if (v_depth > 1.0) {discard;}
556
+ #endif
557
+ #ifdef OVERDRAW_INSPECTOR
558
+ fragColor=vec4(1.0);
559
+ #endif
560
+ }`,`
561
+ #define scale 0.015873016
562
+ #define LINE_DISTANCE_SCALE 2.0
563
+ 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;
564
+ #ifdef GLOBE
565
+ out float v_depth;
566
+ #endif
567
+ #pragma mapbox: define highp vec4 color
568
+ #pragma mapbox: define lowp float blur
569
+ #pragma mapbox: define lowp float opacity
570
+ #pragma mapbox: define mediump float gapwidth
571
+ #pragma mapbox: define lowp float offset
572
+ #pragma mapbox: define mediump float width
573
+ #pragma mapbox: define lowp float floorwidth
574
+ #pragma mapbox: define mediump vec4 dasharray_from
575
+ #pragma mapbox: define mediump vec4 dasharray_to
576
+ void main() {
577
+ #pragma mapbox: initialize highp vec4 color
578
+ #pragma mapbox: initialize lowp float blur
579
+ #pragma mapbox: initialize lowp float opacity
580
+ #pragma mapbox: initialize mediump float gapwidth
581
+ #pragma mapbox: initialize lowp float offset
582
+ #pragma mapbox: initialize mediump float width
583
+ #pragma mapbox: initialize lowp float floorwidth
584
+ #pragma mapbox: initialize mediump vec4 dasharray_from
585
+ #pragma mapbox: initialize mediump vec4 dasharray_to
586
+ 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;
587
+ #ifdef GLOBE
588
+ v_depth=gl_Position.z/gl_Position.w;
589
+ #endif
590
+ #ifdef TERRAIN3D
591
+ v_gamma_scale=1.0;
592
+ #else
593
+ 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;
594
+ #endif
595
+ 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:ut(`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;
596
+ #ifdef GLOBE
597
+ in float v_depth;
598
+ #endif
599
+ #pragma mapbox: define lowp float blur
600
+ #pragma mapbox: define lowp float opacity
601
+ #pragma mapbox: define mediump float width
602
+ #pragma mapbox: define lowp float floorwidth
603
+ #pragma mapbox: define mediump vec4 dasharray_from
604
+ #pragma mapbox: define mediump vec4 dasharray_to
605
+ void main() {
606
+ #pragma mapbox: initialize lowp float blur
607
+ #pragma mapbox: initialize lowp float opacity
608
+ #pragma mapbox: initialize mediump float width
609
+ #pragma mapbox: initialize lowp float floorwidth
610
+ #pragma mapbox: initialize mediump vec4 dasharray_from
611
+ #pragma mapbox: initialize mediump vec4 dasharray_to
612
+ 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);
613
+ #ifdef GLOBE
614
+ if (v_depth > 1.0) {discard;}
615
+ #endif
616
+ #ifdef OVERDRAW_INSPECTOR
617
+ fragColor=vec4(1.0);
618
+ #endif
619
+ }`,`
620
+ #define scale 0.015873016
621
+ #define LINE_DISTANCE_SCALE 2.0
622
+ 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;
623
+ #ifdef GLOBE
624
+ out float v_depth;
625
+ #endif
626
+ #pragma mapbox: define lowp float blur
627
+ #pragma mapbox: define lowp float opacity
628
+ #pragma mapbox: define mediump float gapwidth
629
+ #pragma mapbox: define lowp float offset
630
+ #pragma mapbox: define mediump float width
631
+ #pragma mapbox: define lowp float floorwidth
632
+ #pragma mapbox: define mediump vec4 dasharray_from
633
+ #pragma mapbox: define mediump vec4 dasharray_to
634
+ void main() {
635
+ #pragma mapbox: initialize lowp float blur
636
+ #pragma mapbox: initialize lowp float opacity
637
+ #pragma mapbox: initialize mediump float gapwidth
638
+ #pragma mapbox: initialize lowp float offset
639
+ #pragma mapbox: initialize mediump float width
640
+ #pragma mapbox: initialize lowp float floorwidth
641
+ #pragma mapbox: initialize mediump vec4 dasharray_from
642
+ #pragma mapbox: initialize mediump vec4 dasharray_to
643
+ 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;
644
+ #ifdef GLOBE
645
+ v_depth=gl_Position.z/gl_Position.w;
646
+ #endif
647
+ #ifdef TERRAIN3D
648
+ v_gamma_scale=1.0;
649
+ #else
650
+ 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;
651
+ #endif
652
+ 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:ut(`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);
653
+ #ifdef OVERDRAW_INSPECTOR
654
+ fragColor=vec4(1.0);
655
+ #endif
656
+ }`,`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;
657
+ #ifdef GLOBE
658
+ if (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}
659
+ #endif
660
+ v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}`),symbolIcon:ut(`uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity;
661
+ #pragma mapbox: define lowp float opacity
662
+ void main() {
663
+ #pragma mapbox: initialize lowp float opacity
664
+ lowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha;
665
+ #ifdef OVERDRAW_INSPECTOR
666
+ fragColor=vec4(1.0);
667
+ #endif
668
+ }`,`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;
669
+ #pragma mapbox: define lowp float opacity
670
+ void main() {
671
+ #pragma mapbox: initialize lowp float opacity
672
+ 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 ?
673
+ camera_to_anchor_distance/u_camera_to_center_distance :
674
+ 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;
675
+ #ifdef GLOBE
676
+ 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);}
677
+ #endif
678
+ 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:ut(`#define SDF_PX 8.0
679
+ 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;
680
+ #pragma mapbox: define highp vec4 fill_color
681
+ #pragma mapbox: define highp vec4 halo_color
682
+ #pragma mapbox: define lowp float opacity
683
+ #pragma mapbox: define lowp float halo_width
684
+ #pragma mapbox: define lowp float halo_blur
685
+ void main() {
686
+ #pragma mapbox: initialize highp vec4 fill_color
687
+ #pragma mapbox: initialize highp vec4 halo_color
688
+ #pragma mapbox: initialize lowp float opacity
689
+ #pragma mapbox: initialize lowp float halo_width
690
+ #pragma mapbox: initialize lowp float halo_blur
691
+ 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);
692
+ #ifdef OVERDRAW_INSPECTOR
693
+ fragColor=vec4(1.0);
694
+ #endif
695
+ }`,`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;
696
+ #pragma mapbox: define highp vec4 fill_color
697
+ #pragma mapbox: define highp vec4 halo_color
698
+ #pragma mapbox: define lowp float opacity
699
+ #pragma mapbox: define lowp float halo_width
700
+ #pragma mapbox: define lowp float halo_blur
701
+ void main() {
702
+ #pragma mapbox: initialize highp vec4 fill_color
703
+ #pragma mapbox: initialize highp vec4 halo_color
704
+ #pragma mapbox: initialize lowp float opacity
705
+ #pragma mapbox: initialize lowp float halo_width
706
+ #pragma mapbox: initialize lowp float halo_blur
707
+ 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;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 ?
708
+ camera_to_anchor_distance/u_camera_to_center_distance :
709
+ 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;
710
+ #ifdef GLOBE
711
+ 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);}
712
+ #endif
713
+ vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}`),symbolTextAndIcon:ut(`#define SDF_PX 8.0
714
+ #define SDF 1.0
715
+ #define ICON 0.0
716
+ 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;
717
+ #pragma mapbox: define highp vec4 fill_color
718
+ #pragma mapbox: define highp vec4 halo_color
719
+ #pragma mapbox: define lowp float opacity
720
+ #pragma mapbox: define lowp float halo_width
721
+ #pragma mapbox: define lowp float halo_blur
722
+ void main() {
723
+ #pragma mapbox: initialize highp vec4 fill_color
724
+ #pragma mapbox: initialize highp vec4 halo_color
725
+ #pragma mapbox: initialize lowp float opacity
726
+ #pragma mapbox: initialize lowp float halo_width
727
+ #pragma mapbox: initialize lowp float halo_blur
728
+ 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;
729
+ #ifdef OVERDRAW_INSPECTOR
730
+ fragColor=vec4(1.0);
731
+ #endif
732
+ 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);
733
+ #ifdef OVERDRAW_INSPECTOR
734
+ fragColor=vec4(1.0);
735
+ #endif
736
+ }`,`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;
737
+ #pragma mapbox: define highp vec4 fill_color
738
+ #pragma mapbox: define highp vec4 halo_color
739
+ #pragma mapbox: define lowp float opacity
740
+ #pragma mapbox: define lowp float halo_width
741
+ #pragma mapbox: define lowp float halo_blur
742
+ void main() {
743
+ #pragma mapbox: initialize highp vec4 fill_color
744
+ #pragma mapbox: initialize highp vec4 halo_color
745
+ #pragma mapbox: initialize lowp float opacity
746
+ #pragma mapbox: initialize lowp float halo_width
747
+ #pragma mapbox: initialize lowp float halo_blur
748
+ 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 ?
749
+ camera_to_anchor_distance/u_camera_to_center_distance :
750
+ 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;
751
+ #ifdef GLOBE
752
+ 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);}
753
+ #endif
754
+ 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:ut("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:ut("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:ut("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:ut("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:ut(`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
755
+ );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:ut("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 ut(d,t){const n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,a=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,((x,b,T,E,I)=>(_[I]=!0,b==="define"?`
756
+ #ifndef HAS_UNIFORM_u_${I}
757
+ in ${T} ${E} ${I};
758
+ #else
759
+ uniform ${T} ${E} u_${I};
760
+ #endif
761
+ `:`
762
+ #ifdef HAS_UNIFORM_u_${I}
763
+ ${T} ${E} ${I} = u_${I};
764
+ #endif
765
+ `))),vertexSource:t=t.replace(n,((x,b,T,E,I)=>{const k=E==="float"?"vec2":"vec4",V=I.match(/color/)?"color":k;return _[I]?b==="define"?`
766
+ #ifndef HAS_UNIFORM_u_${I}
767
+ uniform lowp float u_${I}_t;
768
+ in ${T} ${k} a_${I};
769
+ out ${T} ${E} ${I};
770
+ #else
771
+ uniform ${T} ${E} u_${I};
772
+ #endif
773
+ `:V==="vec4"?`
774
+ #ifndef HAS_UNIFORM_u_${I}
775
+ ${I} = a_${I};
776
+ #else
777
+ ${T} ${E} ${I} = u_${I};
778
+ #endif
779
+ `:`
780
+ #ifndef HAS_UNIFORM_u_${I}
781
+ ${I} = unpack_mix_${V}(a_${I}, u_${I}_t);
782
+ #else
783
+ ${T} ${E} ${I} = u_${I};
784
+ #endif
785
+ `:b==="define"?`
786
+ #ifndef HAS_UNIFORM_u_${I}
787
+ uniform lowp float u_${I}_t;
788
+ in ${T} ${k} a_${I};
789
+ #else
790
+ uniform ${T} ${E} u_${I};
791
+ #endif
792
+ `:V==="vec4"?`
793
+ #ifndef HAS_UNIFORM_u_${I}
794
+ ${T} ${E} ${I} = a_${I};
795
+ #else
796
+ ${T} ${E} ${I} = u_${I};
797
+ #endif
798
+ `:`
799
+ #ifndef HAS_UNIFORM_u_${I}
800
+ ${T} ${E} ${I} = unpack_mix_${V}(a_${I}, u_${I}_t);
801
+ #else
802
+ ${T} ${E} ${I} = u_${I};
803
+ #endif
804
+ `})),staticAttributes:a,staticUniforms:m}}class ai{constructor(t,n,a){this.vertexBuffer=t,this.indexBuffer=n,this.segments=a}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Tn=c.aU([{name:"a_pos",type:"Int16",components:2}]);const vr="#define PROJECTION_MERCATOR",zr="mercator";class br{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return zr}get shaderDefine(){return vr}get shaderPreludeCode(){return Ii.projectionMercator}get vertexShaderPreludeCode(){return Ii.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,a,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,Tn.members),x=c.aX.simpleSegment(0,0,4,2),b=new c.aY;b.emplaceBack(1,0,2),b.emplaceBack(1,2,3);const T=t.createIndexBuffer(b);return this._cachedMesh=new ai(_,T,x),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(t){}}class fs{constructor(t=0,n=0,a=0,l=0){if(isNaN(t)||t<0||isNaN(n)||n<0||isNaN(a)||a<0||isNaN(l)||l<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=n,this.left=a,this.right=l}interpolate(t,n,a){return n.top!=null&&t.top!=null&&(this.top=c.G.number(t.top,n.top,a)),n.bottom!=null&&t.bottom!=null&&(this.bottom=c.G.number(t.bottom,n.bottom,a)),n.left!=null&&t.left!=null&&(this.left=c.G.number(t.left,n.left,a)),n.right!=null&&t.right!=null&&(this.right=c.G.number(t.right,n.right,a)),this}getCenter(t,n){const a=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(a,l)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new fs(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Sn(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 Vi(d){return Math.max(0,Math.floor(d))}class Vn{constructor(t,n){var a;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==null?void 0:n.renderWorldCopies)===void 0||!!(n!=null&&n.renderWorldCopies),this._minZoom=(n==null?void 0:n.minZoom)||0,this._maxZoom=(n==null?void 0:n.maxZoom)||22,this._minPitch=(n==null?void 0:n.minPitch)==null?0:n==null?void 0:n.minPitch,this._maxPitch=(n==null?void 0:n.maxPitch)==null?60:n==null?void 0:n.maxPitch,this._constrainOverride=(a=n==null?void 0:n.constrainOverride)!==null&&a!==void 0?a:null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new c.V(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Vi(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 fs,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(t,n,a){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=Vi(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 fs(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=!a&&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 a,l,p,m,_,x,b,T,E;this._bearingInRadians!==n&&(this._unmodified=!1,this._bearingInRadians=n,this._calcMatrices(),this._rotationMatrix=Pe(),a=this._rotationMatrix,p=-this._bearingInRadians,m=(l=this._rotationMatrix)[0],_=l[1],x=l[2],b=l[3],T=Math.sin(p),E=Math.cos(p),a[0]=m*E+x*T,a[1]=_*E+b*T,a[2]=m*-T+x*E,a[3]=_*-T+b*E)}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,a){this._unmodified=!1,this._edgeInsets.interpolate(t,n,a),this.constrainInternal(),this._calcMatrices()}resize(t,n,a=!0){this._width=t,this._height=n,a&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return this._latRange&&this._latRange.length===2&&this._lngRange&&this._lngRange.length===2?new Vt([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:a,minY:l,maxX:p,maxY:m}=c.aa.fromPoints(n).extend(t);return[new c.P(a,l),new c.P(p,l),new c.P(p,m),new c.P(a,m),new c.P(a,l)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const t=this._unmodified,{center:n,zoom:a}=this.applyConstrain(this.center,this.zoom);this.setCenter(n),this.setZoom(a),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,a,l){const p=a!==void 0?a:this.bearing,m=l=l!==void 0?l:this.pitch,{distanceToCenter:_,clampedElevation:x}=this._distanceToCenterFromAltElevationPitch(n,this.elevation,m),{x:b,y:T}=ni(m,p),E=c.a9.fromLngLat(t,n);let I,k,V=c.a_(1,E.y),q=0;do{if(q+=1,q>10)break;k=_/V,I=new c.a9(E.x+b*k,E.y+T*k),V=1/I.meterInMercatorCoordinateUnits()}while(Math.abs(_-k*V)>1e-12);return{center:I.toLngLat(),elevation:x,zoom:c.at(this.height/2/Math.tan(this.fovInRadians/2)/k/this.tileSize)}}recalculateZoomAndCenter(t){if(this.elevation-t==0)return;const n=1/this.worldSize,a=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,x=this.pitch,b=this.bearing,{x:T,y:E,z:I}=ni(x,b),k=this.cameraToCenterDistance,V=p+k*-T,q=m+k*-E,W=_+k*I,{distanceToCenter:Z,clampedElevation:Y}=this._distanceToCenterFromAltElevationPitch(W/a,t,x),ie=Z*a,H=new c.a9((V+T*ie)*n,(q+E*ie)*n,0).toLngLat(),ee=c.as(1,H.lat),se=c.at(this.height/2/Math.tan(this.fovInRadians/2)/Z/ee/this.tileSize);this._elevation=Y,this._center=H,this.setZoom(se)}_distanceToCenterFromAltElevationPitch(t,n,a){const l=-Math.cos(c.ap(a)),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 ye(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 on{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],a=c.b1(this.min),l=c.b1(this.max);for(let p=0;p<n.length;p++)a[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 on(a,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 a=0;a<t.planes.length;a++){const l=this.intersectsPlane(t.planes[a]);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],a=t[3];for(let l=0;l<3;l++)t[l]>0?(n+=t[l]*this.min[l],a+=t[l]*this.max[l]):(a+=t[l]*this.min[l],n+=t[l]*this.max[l]);return n>=0?2:a<0?0:1}}class Wa{distanceToTile2d(t,n,a,l){const p=l.distanceX([t,n]),m=l.distanceY([t,n]);return Math.hypot(p,m)}getWrap(t,n,a){return a}getTileBoundingVolume(t,n,a,l){var p,m;let _=0,x=0;if(l!=null&&l.terrain){const T=new c.a2(t.z,n,t.z,t.x,t.y),E=l.terrain.getMinMaxElevation(T);_=(p=E.minElevation)!==null&&p!==void 0?p:Math.min(0,a),x=(m=E.maxElevation)!==null&&m!==void 0?m:Math.max(0,a)}const b=1<<t.z;return new on([n+t.x/b,t.y/b,_],[n+(t.x+1)/b,(t.y+1)/b,x])}allowVariableZoom(t,n){const a=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-a/2,0,60);return!!n.terrain||t.pitch>l}allowWorldCopies(){return!0}prepareNextFrame(){}}class Mr{constructor(t,n,a){this.points=t,this.planes=n,this.aabb=a}static fromInvProjectionMatrix(t,n=1,a=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,a),x=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((I=>(function(k,V,q,W){const Z=c.aH([],k,V),Y=1/Z[3]/q*W;return c.b6(Z,Z,[Y,Y,1/Z[3],Y])})(I,t,n,_)));l&&(function(I,k,V,q){const W=q?4:0,Z=q?0:4;let Y=0;const ie=[],H=[];for(let J=0;J<4;J++){const oe=c.b2([],I[J+Z],I[J+W]),Te=c.b7(oe);c.a$(oe,oe,1/Te),ie.push(Te),H.push(oe)}for(let J=0;J<4;J++){const oe=c.b8(I[J+W],H[J],V);Y=oe!==null&&oe>=0?Math.max(Y,oe):Math.max(Y,ie[J])}const ee=(function(J,oe){const Te=c.b2([],J[oe[0]],J[oe[1]]),_e=c.b2([],J[oe[2]],J[oe[1]]),xe=[0,0,0,0];return c.b3(xe,c.b4([],Te,_e)),xe[3]=-c.b5(xe,J[oe[0]]),xe})(I,k),se=(function(J,oe){const Te=c.b9(J),_e=c.ba([],J,1/Te),xe=c.b2([],oe,c.a$([],_e,c.b5(oe,_e))),ve=c.b9(xe);if(ve>0){const Fe=Math.sqrt(1-_e[3]*_e[3]),Le=c.a$([],_e,-_e[3]),Ae=c.b0([],Le,c.a$([],xe,Fe/ve));return c.bb(oe,Ae)}return null})(V,ee);if(se!==null){const J=se/c.b5(H[0],ee);Y=Math.min(Y,J)}for(let J=0;J<4;J++){const oe=Math.min(Y,ie[J]);I[J+Z]=[I[J+W][0]+H[J][0]*oe,I[J+W][1]+H[J][1]*oe,I[J+W][2]+H[J][2]*oe,1]}})(x,m[0],l,p);const b=m.map((I=>{const k=c.b2([],x[I[0]],x[I[1]]),V=c.b2([],x[I[2]],x[I[1]]),q=c.b3([],c.b4([],k,V)),W=-c.b5(q,x[I[1]]);return q.concat(W)})),T=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],E=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const I of x)for(let k=0;k<3;k++)T[k]=Math.min(T[k],I[k]),E[k]=Math.max(E[k],I[k]);return new Mr(x,b,new on(T,E))}}class jn{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,a){return this._helper.interpolatePadding(t,n,a)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,n,a=!0){this._helper.resize(t,n,a)}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,a)=>{a=c.an(+a,this.minZoom,this.maxZoom);const l={center:new c.V(n.lng,n.lat),zoom:a};let p=this._helper._lngRange;if(!this._helper._renderWorldCopies&&p===null){const H=179.9999999999;p=[-H,H]}const m=this.tileSize*c.aq(l.zoom);let _=0,x=m,b=0,T=m,E=0,I=0;const{x:k,y:V}=this.size;if(this._helper._latRange){const H=this._helper._latRange;_=c.X(H[1])*m,x=c.X(H[0])*m,x-_<V&&(E=V/(x-_))}p&&(b=c.W(c.Y(p[0])*m,0,m),T=c.W(c.Y(p[1])*m,0,m),T<b&&(T+=m),T-b<k&&(I=k/(T-b)));const{x:q,y:W}=Qe(m,n);let Z,Y;const ie=Math.max(I||0,E||0);if(ie){const H=new c.P(I?(T+b)/2:q,E?(x+_)/2:W);return l.center=ft(m,H).wrap(),l.zoom+=c.at(ie),l}if(this._helper._latRange){const H=V/2;W-H<_&&(Y=_+H),W+H>x&&(Y=x-H)}if(p){const H=(b+T)/2;let ee=q;this._helper._renderWorldCopies&&(ee=c.W(q,H-m/2,H+m/2));const se=k/2;ee-se<b&&(Z=b+se),ee+se>T&&(Z=T-se)}if(Z!==void 0||Y!==void 0){const H=new c.P(Z??q,Y??W);l.center=ft(m,H).wrap()}return l},this.applyConstrain=(n,a)=>this._helper.applyConstrain(n,a),this._helper=new Vn({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(n,a)=>this.defaultConstrain(n,a)},t),this._coveringTilesDetailsProvider=new Wa}clone(){const t=new jn;return t.apply(this),t}apply(t,n,a){this._helper.apply(t,n,a)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(t){const n=[new c.bc(0,t)];if(this._helper._renderWorldCopies){const a=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(a.x,l.x,p.x,m.x)),x=Math.floor(Math.max(a.x,l.x,p.x,m.x)),b=1;for(let T=_-b;T<=x+b;T++)T!==0&&n.push(new c.bc(T,t))}return n}getCameraFrustum(){return Mr.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){const n=this.screenPointToLocation(this.centerPoint,t),a=t?t.getElevationForLngLatZoom(n,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(a)}setLocationAtPoint(t,n){const a=c.as(this.elevation,this.center.lat),l=this.screenPointToMercatorCoordinateAtZ(n,a),p=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,a),m=c.a9.fromLngLat(t),_=new c.a9(m.x-(l.x-p.x),m.y-(l.y-p.y));this.setCenter(_==null?void 0:_.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 a;return(a=this.screenPointToMercatorCoordinate(t,n))===null||a===void 0?void 0:a.toLngLat()}screenPointToMercatorCoordinate(t,n){if(n){const a=n.pointCoordinate(t);if(a!=null)return a}return this.screenPointToMercatorCoordinateAtZ(t)}screenPointToMercatorCoordinateAtZ(t,n){const a=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],x=l[1]/m,b=p[1]/_,T=l[2]/m,E=p[2]/_,I=T===E?0:(a-T)/(E-T);return new c.a9(c.G.number(l[0]/m,p[0]/_,I)/this.worldSize,c.G.number(x,b,I)/this.worldSize,a)}coordinatePoint(t,n=0,a=this._pixelMatrix){const l=[t.x*this.worldSize,t.y*this.worldSize,n,1];return c.aH(l,l,a),new c.P(l[0]/l[3],l[1]/l[3])}getBounds(){const t=Math.max(0,this._helper._height/2-ti(this));return new Vt().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-ti(this)}calculatePosMatrix(t,n=!1,a){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 b=m.get(p);return a?b.f32:b.f64}const _=Gt(t,this.worldSize);c.S(_,n?this._alignedProjMatrix:this._viewProjMatrix,_);const x={f64:_,f32:new Float32Array(_)};return m.set(p,x),a?x.f32:x.f64}calculateFogMatrix(t){const n=t.key,a=this._fogMatrixCacheF32;if(a.has(n))return a.get(n);const l=Gt(t,this.worldSize);return c.S(l,this._fogMatrix,l),a.set(n,new Float32Array(l)),a.get(n)}calculateCenterFromCameraLngLatAlt(t,n,a,l){return this._helper.calculateCenterFromCameraLngLatAlt(t,n,a,l)}_calculateNearFarZIfNeeded(t,n,a){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,x=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+a.y/this.height),b=Math.sin(x)*m/Math.sin(c.an(Math.PI-_-x,.01,Math.PI-.01)),T=ti(this),E=Math.atan(T/this._helper.cameraToCenterDistance),I=c.ap(.75),k=E>I?2*E*(.5+a.y/(2*T)):I,V=Math.sin(k)*m/Math.sin(c.an(Math.PI-_-k,.01,Math.PI-.01)),q=Math.min(b,V);this._helper._farZ=1.01*(Math.cos(Math.PI/2-n)*q+m),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const t=this.centerOffset,n=Qe(this.worldSize,this.center),a=n.x,l=n.y;this._helper._pixelPerMeter=c.as(1,this.center.lat)*this.worldSize;const p=c.ap(Math.min(this.pitch,We)),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(_,_,[-a,-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 x=[0,0,-1,1];c.aH(x,x,this._invViewProjMatrix),this._cameraPosition=[x[0]/x[3],x[1]/x[3],x[2]/x[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,[-a,-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 b=this._helper._width%2/2,T=this._helper._height%2/2,E=Math.cos(this.bearingInRadians),I=Math.sin(-this.bearingInRadians),k=a-Math.round(a)+E*b+I*T,V=l-Math.round(l)+E*T+I*b,q=new Float64Array(_);if(c.O(q,q,[k>.5?k-1:k,V>.5?V-1:V,0]),this._alignedProjMatrix=q,_=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 ye(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/t).toLngLat()}lngLatToCameraDepth(t,n){const a=c.a9.fromLngLat(t),l=[a.x*this.worldSize,a.y*this.worldSize,n,1];return c.aH(l,l,this._viewProjMatrix),l[2]/l[3]}getProjectionData(t){const{overscaledTileID:n,aligned:a,applyTerrainMatrix:l}=t,p=this._helper.getMercatorTileCoordinates(n),m=n?this.calculatePosMatrix(n,a,!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,a){return 1}transformLightDirection(t){return c.b1(t)}getRayDirectionFromPixel(t){throw new Error("Not implemented.")}projectTileCoordinates(t,n,a,l){const p=this.calculatePosMatrix(a);let m;l?(m=[t,n,l(t,n),1],c.aH(m,m,p)):(m=[t,n,0,1],qa(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 a=c.a9.fromLngLat(t,n),l=a.meterInMercatorCoordinateUnits(),p=c.bj();return c.O(p,p,[a.x,a.y,a.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),a=this.getProjectionData({overscaledTileID:n,applyGlobeMatrix:t}),l=Gt(n,this.worldSize);c.S(l,this._viewProjMatrix,l),a.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),a.fallbackMatrix=m,a.mainMatrix=m,a}getFastPathSimpleProjectionMatrix(t){return this.calculatePosMatrix(t)}}function fn(){c.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Mc(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),a=new Float64Array(4);c.bm(a,t,n,d.k);const l=c.bn(a);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 sl(d,t,n,a,l){const p=l.padding,m=Qe(l.worldSize,n.getNorthWest()),_=Qe(l.worldSize,n.getNorthEast()),x=Qe(l.worldSize,n.getSouthEast()),b=Qe(l.worldSize,n.getSouthWest()),T=c.ap(-a),E=m.rotate(T),I=_.rotate(T),k=x.rotate(T),V=b.rotate(T),q=new c.P(Math.max(E.x,I.x,V.x,k.x),Math.max(E.y,I.y,V.y,k.y)),W=new c.P(Math.min(E.x,I.x,V.x,k.x),Math.min(E.y,I.y,V.y,k.y)),Z=q.sub(W),Y=(l.width-(p.left+p.right+t.left+t.right))/Z.x,ie=(l.height-(p.top+p.bottom+t.top+t.bottom))/Z.y;if(ie<0||Y<0)return void fn();const H=Math.min(c.at(l.scale*Math.min(Y,ie)),d.maxZoom),ee=c.P.convert(d.offset),se=new c.P((t.left-t.right)/2,(t.top-t.bottom)/2).rotate(c.ap(a)),J=ee.add(se).mult(l.scale/c.aq(H));return{center:ft(l.worldSize,m.add(x).div(2).sub(J)),zoom:H,bearing:a}}class Nn{get useGlobeControls(){return!1}handlePanInertia(t,n){const a=t.mag(),l=Math.abs(ti(n));return{easingOffset:t.mult(Math.min(.75*l/a,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,a){t.around.distSqr(n.centerPoint)<.01||n.setLocationAtPoint(a,t.around)}cameraForBoxAndBearing(t,n,a,l,p){return sl(t,n,a,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 a=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,x=!t.isPaddingEqual(n.padding);let b=!1;const T=_?+n.zoom:t.zoom;let E=t.centerPoint.add(n.offsetAsPoint);const I=t.screenPointToLocation(E),{center:k,zoom:V}=t.applyConstrain(c.V.convert(n.center||I),T??a);Sn(t,k);const q=Qe(t.worldSize,I),W=Qe(t.worldSize,k).sub(q),Z=c.aq(V-a);return b=V!==a,{easeFunc:Y=>{if(b&&t.setZoom(c.G.number(a,V,Y)),c.bo(p,m)||Mc({startEulerAngles:p,endEulerAngles:m,tr:t,k:Y,useSlerp:p.roll!=m.roll}),x&&(t.interpolatePadding(l,n.padding,Y),E=t.centerPoint.add(n.offsetAsPoint)),n.around)t.setLocationAtPoint(n.around,n.aroundPoint);else{const ie=c.aq(t.zoom-a),H=V>a?Math.min(2,Z):Math.max(.5,Z),ee=Math.pow(H,1-Y),se=ft(t.worldSize,q.add(W.mult(Y*ee)).mult(ie));t.setLocationAtPoint(t.renderWorldCopies?se.wrap():se,E)}},isZooming:b,elevationCenter:k}}handleFlyTo(t,n){const a=n.zoom!==void 0,l=t.zoom,p=t.applyConstrain(c.V.convert(n.center||n.locationAtOffset),a?+n.zoom:l),m=p.center,_=p.zoom;Sn(t,m);const x=Qe(t.worldSize,n.locationAtOffset),b=Qe(t.worldSize,m).sub(x),T=b.mag(),E=c.aq(_-l);let I;if(n.minZoom!==void 0){const k=Math.min(+n.minZoom,l,_),V=t.applyConstrain(m,k).zoom;I=c.aq(V-l)}return{easeFunc:(k,V,q,W)=>{t.setZoom(k===1?_:l+c.at(V));const Z=k===1?m:ft(t.worldSize,x.add(b.mult(q)).mult(V));t.setLocationAtPoint(t.renderWorldCopies?Z.wrap():Z,W)},scaleOfZoom:E,targetCenter:m,scaleOfMinZoom:I,pixelPathLength:T}}}class oi{constructor(t,n,a){this.blendFunction=t,this.blendColor=n,this.mask=a}}oi.Replace=[1,0],oi.disabled=new oi(oi.Replace,c.bp.transparent,[!1,!1,!1,!1]),oi.unblended=new oi(oi.Replace,c.bp.transparent,[!0,!0,!0,!0]),oi.alphaBlended=new oi([1,771],c.bp.transparent,[!0,!0,!0,!0]);const ms=2305;class Ft{constructor(t,n,a){this.enable=t,this.mode=n,this.frontFace=a}}Ft.disabled=new Ft(!1,1029,ms),Ft.backCCW=new Ft(!0,1029,ms),Ft.frontCCW=new Ft(!0,1028,ms);class wt{constructor(t,n,a){this.func=t,this.mask=n,this.range=a}}wt.ReadOnly=!1,wt.ReadWrite=!0,wt.disabled=new wt(519,wt.ReadOnly,[0,1]);const gs=7680;class Bt{constructor(t,n,a,l,p,m){this.test=t,this.ref=n,this.mask=a,this.fail=l,this.depthFail=p,this.pass=m}}Bt.disabled=new Bt({func:519,mask:0},0,0,gs,gs,gs);const Ks=new WeakMap;function jr(d){var t;if(Ks.has(d))return Ks.get(d);{const n=(t=d.getParameter(d.VERSION))===null||t===void 0?void 0:t.startsWith("WebGL 2.0");return Ks.set(d,n),n}}class _s{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,a=n.gl;this._texFormat=a.RGBA,this._texType=a.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 ai(n.createVertexBuffer(l,Tn.members),n.createIndexBuffer(p),c.aX.simpleSegment(0,0,l.length,p.length)),this._resultBuffer=new Uint8Array(4),n.activeTexture.set(a.TEXTURE1);const m=a.createTexture();a.bindTexture(a.TEXTURE_2D,m),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.NEAREST),a.texImage2D(a.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),jr(a)&&(this._pbo=a.createBuffer(),a.bindBuffer(a.PIXEL_PACK_BUFFER,this._pbo),a.bufferData(a.PIXEL_PACK_BUFFER,4,a.STREAM_READ),a.bindBuffer(a.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 a=this._updateCount;return this._readbackQueue?a>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():a>=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 a=this._cachedRenderContext.context,l=a.gl;if(this._bindFramebuffer(),a.viewport.set([0,0,this._texWidth,this._texHeight]),a.clear({color:c.bp.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(a,l.TRIANGLES,wt.disabled,Bt.disabled,oi.unblended,Ft.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&&jr(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&&jr(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=_s._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 Pn=c.a5/128;function Ic(d,t){const n=d.granularity!==void 0?Math.max(d.granularity,1):1,a=n+(d.generateBorders?2:0),l=n+(d.extendToNorthPole||d.generateBorders?1:0)+(d.extendToSouthPole||d.generateBorders?1:0),p=a+1,m=l+1,_=d.generateBorders?-1:0,x=d.generateBorders||d.extendToNorthPole?-1:0,b=n+(d.generateBorders?1:0),T=n+(d.generateBorders||d.extendToSouthPole?1:0),E=p*m,I=a*l*6,k=p*m>65536;if(k&&t==="16bit")throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const V=k||t==="32bit",q=new Int16Array(2*E);let W=0;for(let ie=x;ie<=T;ie++)for(let H=_;H<=b;H++){let ee=H/n*c.a5;H===-1&&(ee=-Pn),H===n+1&&(ee=c.a5+Pn);let se=ie/n*c.a5;ie===-1&&(se=d.extendToNorthPole?c.br:-Pn),ie===n+1&&(se=d.extendToSouthPole?c.bs:c.a5+Pn),q[W++]=ee,q[W++]=se}const Z=V?new Uint32Array(I):new Uint16Array(I);let Y=0;for(let ie=0;ie<l;ie++)for(let H=0;H<a;H++){const ee=H+1+ie*p,se=H+(ie+1)*p,J=H+1+(ie+1)*p;Z[Y++]=H+ie*p,Z[Y++]=se,Z[Y++]=ee,Z[Y++]=ee,Z[Y++]=se,Z[Y++]=J}return{vertices:q.buffer.slice(0),indices:Z.buffer.slice(0),uses32bitIndices:V}}const Js=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 al{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 Ii.projectionGlobe}get vertexShaderPreludeCode(){return Ii.projectionMercator.vertexSource}get subdivisionGranularity(){return Js}get useGlobeControls(){return!0}get latitudeErrorCorrectionRadians(){return this._errorCorrectionUsable}destroy(){this._errorMeasurement&&this._errorMeasurement.destroy()}updateGPUdependent(t){this._errorMeasurement||(this._errorMeasurement=new _s(t));const n=c.X(this._errorQueryLatitudeDegrees),a=2*Math.atan(Math.exp(Math.PI-n*Math.PI*2))-.5*Math.PI,l=this._errorMeasurement.updateErrorLoop(n,a),p=Je();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,a,l,p){const m=(p==="stencil"?Js.stencil:Js.tile).getGranularityForZoomLevel(n.z);return this._getMesh(t,{granularity:m,generateBorders:a,extendToNorthPole:n.y===0&&l,extendToSouthPole:n.y===(1<<n.z)-1&&l})}_getMesh(t,n){const a=this._getMeshKey(n);if(a in this._tileMeshCache)return this._tileMeshCache[a];const l=(function(p,m){const _=Ic(m,"16bit"),x=c.aW.deserialize({arrayBuffer:_.vertices,length:_.vertices.byteLength/2/2}),b=c.aY.deserialize({arrayBuffer:_.indices,length:_.indices.byteLength/2/3});return new ai(p.createVertexBuffer(x,Tn.members),p.createIndexBuffer(b),c.aX.simpleSegment(0,0,x.length,b.length))})(t,n);return this._tileMeshCache[a]=l,l}recalculate(t){}hasTransition(){const t=Je();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 lh=new c.t({type:new c.D(c.u.projection.type)});class Ec extends c.E{constructor(t){super(),this._transitionable=new c.x(lh,void 0),this.setProjection(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new c.H(0)),this._mercatorProjection=new br,this._verticalPerspectiveProjection=new al}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,a,l,p){return this.currentProjection.getMeshFromTileID(t,n,a,l,p)}setProjection(t){this._transitionable.setValue("type",(t==null?void 0: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 wr(d){const t=Un(d.worldSize,d.center.lat);return 2*Math.PI*t}function ln(d,t,n,a,l){const p=1/(1<<l),m=t/c.a5*p+a*p,_=c.by((d/c.a5*p+n*p)*Math.PI*2+Math.PI,2*Math.PI),x=2*Math.atan(Math.exp(Math.PI-m*Math.PI*2))-.5*Math.PI,b=Math.cos(x),T=new Float64Array(3);return T[0]=Math.sin(_)*b,T[1]=Math.sin(x),T[2]=Math.cos(_)*b,T}function bi(d){return(function(t,n){const a=Math.cos(n),l=new Float64Array(3);return l[0]=Math.sin(t)*a,l[1]=Math.sin(n),l[2]=Math.cos(t)*a,l})(d.lng*Math.PI/180,d.lat*Math.PI/180)}function Un(d,t){return d/(2*Math.PI)/Math.cos(t*Math.PI/180)}function ol(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 a=d[0]/n,l=Math.acos(d[2]/n),p=(a>0?l:-l)/Math.PI*180;return new c.V(c.W(p,-180,180),t)}return new c.V(0,t)}function Qs(d){return Math.cos(d*Math.PI/180)}function Ri(d,t){const n=Qs(d),a=Qs(t);return c.at(a/n)}function Cc(d,t){const n=d.rotate(t.bearingInRadians),a=t.zoom+Ri(t.center.lat,0),l=c.bu(1/Qs(t.center.lat),1/Qs(Math.min(Math.abs(t.center.lat),60)),c.bx(a,7,3,0,1)),p=360/wr({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 ll(d){const t=.5*d,n=Math.sin(t),a=Math.cos(t);return Math.log(n+a)-Math.log(a-n)}function Ac(d,t,n,a){const l=d.lat+n*a;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,_=ll(p+a*(m-p)),x=ll(p),b=ll(m);return new c.V(d.lng+t*((_-x)/(b-x)),l)}return new c.V(d.lng+t*a,l)}class ch{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,a,l){const p=`${t.z}_${t.x}_${t.y}_${l!=null&&l.terrain?"t":""}`,m=this._cache.get(p);if(m)return m;const _=this._cachePrevious.get(p);if(_)return this._cache.set(p,_),_;const x=this._boundingVolumeFactory(t,n,a,l);return this._cache.set(p,x),this._hadAnyChanges=!0,x}}class ys{constructor(t,n,a,l){this.min=a,this.max=l,this.points=t,this.planes=n}static fromAabb(t,n){const a=[];for(let l=0;l<8;l++)a.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 ys(a,[[-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,a){const l=c.bB([],a[0],a[1],a[2]),p=c.bC([],[n[0],0,0],l),m=c.bC([],[0,n[1],0],l),_=c.bC([],[0,0,n[2]],l),x=[...t],b=[...t];for(let E=0;E<8;E++)for(let I=0;I<3;I++){const k=t[I]+p[I]*(1&~E?-1:1)+m[I]*((E>>1&1)==1?1:-1)+_[I]*((E>>2&1)==1?1:-1);x[I]=Math.min(x[I],k),b[I]=Math.max(b[I],k)}const T=[];for(let E=0;E<8;E++){const I=[...t];c.b0(I,I,c.a$([],p,1&~E?-1:1)),c.b0(I,I,c.a$([],m,(E>>1&1)==1?1:-1)),c.b0(I,I,c.a$([],_,(E>>2&1)==1?1:-1)),T.push(I)}return new ys(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])]],x,b)}intersectsFrustum(t){let n=!0;const a=this.points.length,l=this.planes.length,p=t.planes.length,m=t.points.length;for(let _=0;_<p;_++){const x=t.planes[_];let b=0;for(let T=0;T<a;T++){const E=this.points[T];x[0]*E[0]+x[1]*E[1]+x[2]*E[2]+x[3]>=0&&b++}if(b===0)return 0;b<a&&(n=!1)}if(n)return 2;for(let _=0;_<l;_++){const x=this.planes[_];let b=0;for(let T=0;T<m;T++){const E=t.points[T];x[0]*E[0]+x[1]*E[1]+x[2]*E[2]+x[3]>=0&&b++}if(b===0)return 0}return 1}intersectsPlane(t){const n=this.points.length;let a=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&&a++}return a===n?2:a===0?0:1}}function Ha(d,t,n){const a=d-t;return a<0?-a:Math.max(0,a-n)}function xs(d,t,n,a,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,Ha(t,a,l))}class cl{constructor(){this._boundingVolumeCache=new ch(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(t,n,a,l){const p=1<<a.z,m=1/p,_=a.x/p,x=a.y/p;let b=2;return b=Math.min(b,xs(t,n,_,x,m)),b=Math.min(b,xs(t,n,_+.5,-x-m,m)),b=Math.min(b,xs(t,n,_+.5,2-x-m,m)),b}getWrap(t,n,a){const l=1<<n.z,p=1/l,m=n.x/l,_=Ha(t.x,m,p),x=Ha(t.x,m-1,p),b=Ha(t.x,m+1,p),T=Math.min(_,x,b);return T===b?1:T===x?-1:0}allowVariableZoom(t,n){return gi(t,n)>4}allowWorldCopies(){return!1}getTileBoundingVolume(t,n,a,l){return this._boundingVolumeCache.getTileBoundingVolume(t,n,a,l)}_computeTileBoundingVolume(t,n,a,l){var p,m;let _=0,x=0;if(l!=null&&l.terrain){const b=new c.a2(t.z,n,t.z,t.x,t.y),T=l.terrain.getMinMaxElevation(b);_=(p=T.minElevation)!==null&&p!==void 0?p:Math.min(0,a),x=(m=T.maxElevation)!==null&&m!==void 0?m:Math.max(0,a)}if(_/=c.bE,x/=c.bE,_+=1,x+=1,t.z<=0)return ys.fromAabb([-x,-x,-x],[x,x,x]);if(t.z===1)return ys.fromAabb([t.x===0?-x:0,t.y===0?0:-x,-x],[t.x===0?0:x,t.y===0?x:0,x]);{const b=[ln(0,0,t.x,t.y,t.z),ln(c.a5,0,t.x,t.y,t.z),ln(c.a5,c.a5,t.x,t.y,t.z),ln(0,c.a5,t.x,t.y,t.z)],T=[];for(const xe of b)T.push(c.a$([],xe,x));if(x!==_)for(const xe of b)T.push(c.a$([],xe,_));t.y===0&&T.push([0,1,0]),t.y===(1<<t.z)-1&&T.push([0,-1,0]);const E=[1,1,1],I=[-1,-1,-1];for(const xe of T)for(let ve=0;ve<3;ve++)E[ve]=Math.min(E[ve],xe[ve]),I[ve]=Math.max(I[ve],xe[ve]);const k=ln(c.a5/2,c.a5/2,t.x,t.y,t.z),V=c.b4([],[0,1,0],k);c.b3(V,V);const q=c.b4([],k,V);c.b3(q,q);const W=c.b4([],b[2],b[1]);c.b3(W,W);const Z=c.b4([],b[0],b[3]);c.b3(Z,Z),T.push(c.a$([],k,x)),t.y>=(1<<t.z)/2&&T.push(c.a$([],ln(c.a5/2,0,t.x,t.y,t.z),x)),t.y<(1<<t.z)/2&&T.push(c.a$([],ln(c.a5/2,c.a5,t.x,t.y,t.z),x));const Y=ea(k,T),ie=ea(q,T),H=[-k[0],-k[1],-k[2],Y.max],ee=[k[0],k[1],k[2],-Y.min],se=[-q[0],-q[1],-q[2],ie.max],J=[q[0],q[1],q[2],-ie.min],oe=[...W,0],Te=[...Z,0],_e=[];return t.y===0?_e.push(c.bD(Te,oe,H),c.bD(Te,oe,ee)):_e.push(c.bD(se,oe,H),c.bD(se,oe,ee),c.bD(se,Te,H),c.bD(se,Te,ee)),t.y===(1<<t.z)-1?_e.push(c.bD(Te,oe,H),c.bD(Te,oe,ee)):_e.push(c.bD(J,oe,H),c.bD(J,oe,ee),c.bD(J,Te,H),c.bD(J,Te,ee)),new ys(_e,[H,ee,se,J,oe,Te],E,I)}}}function ea(d,t){let n=1/0,a=-1/0;for(const l of t){const p=c.b5(d,l);n=Math.min(n,p),a=Math.max(a,p)}return{min:n,max:a}}class vs{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,a){return this._helper.interpolatePadding(t,n,a)}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.bz(),this._globeLatitudeErrorCorrectionRadians=0,this.defaultConstrain=(n,a)=>{const l=c.an(n.lat,-c.ao,c.ao),p=c.an(+a,this.minZoom+Ri(0,l),this.maxZoom);return{center:new c.V(n.lng,l),zoom:p}},this.applyConstrain=(n,a)=>this._helper.applyConstrain(n,a),this._helper=new Vn({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(n,a)=>this.defaultConstrain(n,a)},t),this._coveringTilesDetailsProvider=new cl}clone(){const t=new vs;return t.apply(this),t}apply(t,n){this._globeLatitudeErrorCorrectionRadians=n||0,this._helper.apply(t)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const t=c.bz();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:a}=t,l=this._helper.getMercatorTileCoordinates(n);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:l,clippingPlane:this._cachedClippingPlane,projectionTransition:a?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(t){const n=this.pitchInRadians,a=this.cameraToCenterDistance/t,l=Math.sin(n)*a,p=Math.cos(n)*a+1,m=1/Math.sqrt(l*l+p*p)*1;let _=-l,x=p;const b=Math.sqrt(_*_+x*x);_/=b,x/=b;const T=[0,_,x];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 E=1/c.b7(T);return c.a$(T,T,E),[...T,-m*E]}isLocationOccluded(t){return!this.isSurfacePointVisible(bi(t))}transformLightDirection(t){const n=this._helper._center.lng*Math.PI/180,a=this._helper._center.lat*Math.PI/180,l=Math.cos(a),p=[Math.sin(n)*l,Math.sin(a),Math.cos(n)*l],m=[p[2],0,-p[0]],_=[0,0,0];c.b4(_,m,p),c.b3(m,m),c.b3(_,_);const x=[0,0,0];return c.b3(x,[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]]),x}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,a){const l=(function(_,x,b){const T=1/(1<<b.z);return new c.a9(_/c.a5*T+b.x*T,x/c.a5*T+b.y*T)})(t,n,a.canonical),p=(m=l.y,[c.by(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,a,l){const p=a.canonical,m=ln(t,n,p.x,p.y,p.z),_=1+(l?l(t,n):0)/c.bE,x=[m[0]*_,m[1]*_,m[2]*_,1];c.aH(x,x,this._globeViewProjMatrixNoCorrection);const b=this._cachedClippingPlane,T=b[0]*m[0]+b[1]*m[1]+b[2]*m[2]+b[3]<0;return{point:new c.P(x[0]/x[3],x[1]/x[3]),signedDistanceFromCamera:x[3],isOccluded:T}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;const t=Un(this.worldSize,this.center.lat),n=c.bk(),a=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.bz();p[0]=t,p[1]=t,p[2]=t,c.bh(a,n,this.center.lat*Math.PI/180),c.bJ(a,a,-this.center.lng*Math.PI/180),c.Q(a,a,p),this._globeViewProjMatrixNoCorrection=a,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,a);const m=c.bz();this._cameraPosition=c.bz(),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=Mr.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 a=bi(t);c.a$(a,a,1+n/c.bE);const l=c.bF();return c.aH(l,[a[0],a[1],a[2],1],this._globeViewProjMatrixNoCorrection),l[2]/l[3]}populateCache(t){}getBounds(){const t=.5*this.width,n=.5*this.height,a=[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 E of a)l.push(this.unprojectScreenPoint(E));let p=0,m=0,_=0,x=0;const b=this.center;for(const E of l){const I=c.bK(b.lng,E.lng),k=c.bK(b.lat,E.lat);I<m&&(m=I),I>p&&(p=I),k<x&&(x=k),k>_&&(_=k)}const T=[b.lng+m,b.lat+x,b.lng+p,b.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 Vt(T)}calculateCenterFromCameraLngLatAlt(t,n,a,l){return this._helper.calculateCenterFromCameraLngLatAlt(t,n,a,l)}setLocationAtPoint(t,n){const a=bi(this.unprojectScreenPoint(n)),l=bi(t),p=c.bz();c.bL(p);const m=c.bz();c.bI(m,a,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],x=m[0]*m[0];if(_<x)return;const b=Math.sqrt(_-x),T=-b,E=c.bM(l[0],l[2],m[0],b),I=c.bM(l[0],l[2],m[0],T),k=c.bz();c.bI(k,l,p,-E);const V=c.bM(k[1],k[2],m[1],m[2]),q=c.bz();c.bI(q,l,p,-I);const W=c.bM(q[1],q[2],m[1],m[2]),Z=.5*Math.PI,Y=V>=-Z&&V<=Z,ie=W>=-Z&&W<=Z;let H,ee;if(Y&&ie){const Te=this.center.lng*Math.PI/180,_e=this.center.lat*Math.PI/180;c.bN(E,Te)+c.bN(V,_e)<c.bN(I,Te)+c.bN(W,_e)?(H=E,ee=V):(H=I,ee=W)}else if(Y)H=E,ee=V;else{if(!ie)return;H=I,ee=W}const se=H/Math.PI*180,J=ee/Math.PI*180,oe=this.center.lat;this.setCenter(new c.V(se,c.an(J,-90,90))),this.setZoom(this.zoom+Ri(oe,this.center.lat))}locationToScreenPoint(t,n){const a=bi(t);if(n){const l=n.getElevationForLngLatZoom(t,this._helper._tileZoom);c.a$(a,a,1+l/c.bE)}return this._projectSurfacePointToScreen(a)}_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 a=n.pointCoordinate(t);if(a)return a}return c.a9.fromLngLat(this.unprojectScreenPoint(t))}screenPointToLocation(t,n){var a;return(a=this.screenPointToMercatorCoordinate(t,n))===null||a===void 0?void 0:a.toLngLat()}isPointOnMapSurface(t,n){const a=this._cameraPosition,l=this.getRayDirectionFromPixel(t);return!!this.rayPlanetIntersection(a,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 a=c.bz();a[0]=n[0]-this._cameraPosition[0],a[1]=n[1]-this._cameraPosition[1],a[2]=n[2]-this._cameraPosition[2];const l=c.bz();return c.b3(l,a),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 a=c.b5(t,n),l=c.bz(),p=c.bz();c.a$(p,n,a),c.b2(l,t,p);const m=1-c.b5(l,l);if(m<0)return null;const _=c.b5(t,t)-1,x=-a+(a<0?1:-1)*Math.sqrt(m),b=_/x,T=x;return{tMin:Math.min(b,T),tMax:Math.max(b,T)}}unprojectScreenPoint(t){const n=this._cameraPosition,a=this.getRayDirectionFromPixel(t),l=this.rayPlanetIntersection(n,a);if(l){const T=c.bz();c.b0(T,n,[a[0]*l.tMin,a[1]*l.tMin,a[2]*l.tMin]);const E=c.bz();return c.b3(E,T),ol(E)}const p=this._cachedClippingPlane,m=p[0]*a[0]+p[1]*a[1]+p[2]*a[2],_=-c.bb(p,n)/m,x=c.bz();if(_>0)c.b0(x,n,[a[0]*_,a[1]*_,a[2]*_]);else{const T=c.bz();c.b0(T,n,[2*a[0],2*a[1],2*a[2]]);const E=c.bb(this._cachedClippingPlane,T);c.b2(x,T,[this._cachedClippingPlane[0]*E,this._cachedClippingPlane[1]*E,this._cachedClippingPlane[2]*E])}const b=(function(T){const E=c.bz();return E[0]=T[0]*-T[3],E[1]=T[1]*-T[3],E[2]=T[2]*-T[3],{center:E,radius:Math.sqrt(1-T[3]*T[3])}})(p);return ol((function(T,E,I){const k=c.bz();c.b2(k,I,T);const V=c.bz();return c.bA(V,T,k,E/c.b9(k)),V})(b.center,b.radius,x))}getMatrixForModel(t,n){const a=c.V.convert(t),l=1/c.bE,p=c.bj();return c.bJ(p,p,a.lng/180*Math.PI),c.bh(p,p,-a.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 bs{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,a){return this._helper.interpolatePadding(t,n,a)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,n,a=!0){this._helper.resize(t,n,a)}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,a)=>this.currentTransform.defaultConstrain(n,a),this.applyConstrain=(n,a)=>this._helper.applyConstrain(n,a),this._helper=new Vn({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(n,a)=>this.defaultConstrain(n,a)},t),this._globeness=1,this._mercatorTransform=new jn,this._verticalPerspectiveTransform=new vs}clone(){const t=new bs;return t._globeness=this._globeness,t._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,t.apply(this),t}apply(t){this._helper.apply(t),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(t){const n=this._mercatorTransform.getProjectionData(t),a=this._verticalPerspectiveTransform.getProjectionData(t);return{mainMatrix:this.isGlobeRendering?a.mainMatrix:n.mainMatrix,clippingPlane:a.clippingPlane,tileMercatorCoords:a.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,a){const l=this._mercatorTransform.getPitchedTextCorrection(t,n,a),p=this._verticalPerspectiveTransform.getPitchedTextCorrection(t,n,a);return c.bu(l,p,this._globeness)}projectTileCoordinates(t,n,a,l){return this.currentTransform.projectTileCoordinates(t,n,a,l)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(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,a,l){return this._helper.calculateCenterFromCameraLngLatAlt(t,n,a,l)}setLocationAtPoint(t,n){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(t,n),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(t,n),this.apply(this._verticalPerspectiveTransform)}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 a=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(t);return a.fallbackMatrix=n.mainMatrix,a}getFastPathSimpleProjectionMatrix(t){return this.currentTransform.getFastPathSimpleProjectionMatrix(t)}}class Wi{get useGlobeControls(){return!0}handlePanInertia(t,n){const a=Cc(t,n);return Math.abs(a.lng-n.center.lng)>180&&(a.lng=n.center.lng+179.5*Math.sign(a.lng-n.center.lng)),{easingCenter:a,easingOffset:new c.P(0,0)}}handleMapControlsRollPitchBearingZoom(t,n){const a=t.around,l=n.screenPointToLocation(a);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),x=_/(Math.abs(_/180)+1),b=c.bK(n.center.lat,l.lat),T=n.getRayDirectionFromPixel(a),E=n.cameraPosition,I=-1*c.b5(E,T),k=c.bz();c.b0(k,E,[T[0]*I,T[1]*I,T[2]*I]);const V=c.b7(k)-1,q=Math.exp(.5*-Math.max(V-.3,0)),W=Un(n.worldSize,n.center.lat)/Math.min(n.width,n.height),Z=c.bx(W,.9,.5,1,.25),Y=(1-c.aq(-m))*Math.min(q,Z),ie=n.center.lat,H=n.zoom,ee=new c.V(n.center.lng+x*Y,c.an(n.center.lat+b*Y,-c.ao,c.ao));n.setLocationAtPoint(l,a);const se=n.center,J=c.bx(Math.abs(_),45,85,0,1),oe=c.bx(W,.75,.35,0,1),Te=Math.pow(Math.max(J,oe),.25),_e=c.bK(se.lng,ee.lng),xe=c.bK(se.lat,ee.lat);n.setCenter(new c.V(se.lng+_e*Te,se.lat+xe*Te).wrap()),n.setZoom(H+Ri(ie,n.center.lat))}handleMapControlsPan(t,n,a){if(!t.panDelta)return;const l=n.center.lat,p=n.zoom;n.setCenter(Cc(t.panDelta,n).wrap()),n.setZoom(p+Ri(l,n.center.lat))}cameraForBoxAndBearing(t,n,a,l,p){const m=sl(t,n,a,l,p),_=n.left/p.width*2-1,x=(p.width-n.right)/p.width*2-1,b=n.top/p.height*-2+1,T=(p.height-n.bottom)/p.height*-2+1,E=c.bK(a.getWest(),a.getEast())<0,I=E?a.getEast():a.getWest(),k=E?a.getWest():a.getEast(),V=Math.max(a.getNorth(),a.getSouth()),q=Math.min(a.getNorth(),a.getSouth()),W=I+.5*c.bK(I,k),Z=V+.5*c.bK(V,q),Y=p.clone();Y.setCenter(m.center),Y.setBearing(m.bearing),Y.setPitch(0),Y.setRoll(0),Y.setZoom(m.zoom);const ie=Y.modelViewProjectionMatrix,H=[bi(a.getNorthWest()),bi(a.getNorthEast()),bi(a.getSouthWest()),bi(a.getSouthEast()),bi(new c.V(k,Z)),bi(new c.V(I,Z)),bi(new c.V(W,V)),bi(new c.V(W,q))],ee=bi(m.center);let se=Number.POSITIVE_INFINITY;for(const J of H)_<0&&(se=Wi.getLesserNonNegativeNonNull(se,Wi.solveVectorScale(J,ee,ie,"x",_))),x>0&&(se=Wi.getLesserNonNegativeNonNull(se,Wi.solveVectorScale(J,ee,ie,"x",x))),b>0&&(se=Wi.getLesserNonNegativeNonNull(se,Wi.solveVectorScale(J,ee,ie,"y",b))),T<0&&(se=Wi.getLesserNonNegativeNonNull(se,Wi.solveVectorScale(J,ee,ie,"y",T)));if(Number.isFinite(se)&&se!==0)return m.zoom=Y.zoom+c.at(se),m;fn()}handleJumpToCenterZoom(t,n){const a=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+Ri(a,l.lat);t.zoom!==p&&t.setZoom(p)}handleEaseTo(t,n){const a=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},x=n.zoom!==void 0,b=!t.isPaddingEqual(n.padding);let T=!1;const E=n.center?c.V.convert(n.center):l,I=t.applyConstrain(E,a).center;Sn(t,I);const k=t.clone();k.setCenter(I),k.setZoom(x?+n.zoom:a+Ri(l.lat,E.lat)),k.setBearing(n.bearing);const V=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));k.setLocationAtPoint(I,V);const q=(n.offset&&n.offsetAsPoint.mag())>0?k.center:I,W=x?+n.zoom:a+Ri(l.lat,q.lat),Z=a+Ri(l.lat,0),Y=W+Ri(q.lat,0),ie=c.bK(l.lng,q.lng),H=c.bK(l.lat,q.lat),ee=c.aq(Y-Z);return T=W!==a,{easeFunc:se=>{if(c.bo(m,_)||Mc({startEulerAngles:m,endEulerAngles:_,tr:t,k:se,useSlerp:m.roll!=_.roll}),b&&t.interpolatePadding(p,n.padding,se),n.around)c.w("Easing around a point is not supported under globe projection."),t.setLocationAtPoint(n.around,n.aroundPoint);else{const J=Y>Z?Math.min(2,ee):Math.max(.5,ee),oe=Math.pow(J,1-se),Te=Ac(l,ie,H,se*oe);t.setCenter(Te.wrap())}if(T){const J=c.G.number(Z,Y,se)+Ri(0,t.center.lat);t.setZoom(J)}},isZooming:T,elevationCenter:q}}handleFlyTo(t,n){const a=n.zoom!==void 0,l=t.center,p=t.zoom,m=t.padding,_=!t.isPaddingEqual(n.padding),x=t.applyConstrain(c.V.convert(n.center||n.locationAtOffset),p).center,b=a?+n.zoom:t.zoom+Ri(t.center.lat,x.lat),T=t.clone();T.setCenter(x),T.setZoom(b),T.setBearing(n.bearing);const E=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(x,E);const I=T.center;Sn(t,I);const k=(function(H,ee,se){const J=bi(ee),oe=bi(se),Te=c.b5(J,oe),_e=Math.acos(Te),xe=wr(H);return _e/(2*Math.PI)*xe})(t,l,I),V=p+Ri(l.lat,0),q=b+Ri(I.lat,0),W=c.aq(q-V);let Z;if(typeof n.minZoom=="number"){const H=+n.minZoom+Ri(I.lat,0),ee=Math.min(H,V,q)+Ri(0,I.lat),se=t.applyConstrain(I,ee).zoom+Ri(I.lat,0);Z=c.aq(se-V)}const Y=c.bK(l.lng,I.lng),ie=c.bK(l.lat,I.lat);return{easeFunc:(H,ee,se,J)=>{const oe=Ac(l,Y,ie,se);_&&t.interpolatePadding(m,n.padding,H);const Te=H===1?I:oe;t.setCenter(Te.wrap());const _e=V+c.at(ee);t.setZoom(H===1?b:_e+Ri(0,Te.lat))},scaleOfZoom:W,targetCenter:I,scaleOfMinZoom:Z,pixelPathLength:k}}static solveVectorScale(t,n,a,l,p){const m=l==="x"?[a[0],a[4],a[8],a[12]]:[a[1],a[5],a[9],a[13]],_=[a[3],a[7],a[11],a[15]],x=t[0]*m[0]+t[1]*m[1]+t[2]*m[2],b=t[0]*_[0]+t[1]*_[1]+t[2]*_[2],T=n[0]*m[0]+n[1]*m[1]+n[2]*m[2],E=n[0]*_[0]+n[1]*_[1]+n[2]*_[2];return T+p*b===x+p*E||_[3]*(x-T)+m[3]*(E-b)+x*E==T*b?null:(T+m[3]-p*E-p*_[3])/(T-x-p*E+p*b)}static getLesserNonNegativeNonNull(t,n){return n!==null&&n>=0&&n<t?n:t}}class Dc{constructor(t){this._globe=t,this._mercatorCameraHelper=new Nn,this._verticalPerspectiveCameraHelper=new Wi}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,a){this.currentHelper.handleMapControlsPan(t,n,a)}cameraForBoxAndBearing(t,n,a,l,p){return this.currentHelper.cameraForBoxAndBearing(t,n,a,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 ws=(d,t)=>c.B(d,t&&t.filter((n=>n.identifier!=="source.canvas"))),ta=c.bO();class Gn extends c.E{constructor(t,n={}){var a,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 Lt(It(),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 je,this.imageManager.setEventedParent(this);const p=((a=t._container)===null||a===void 0?void 0:a.lang)||typeof document<"u"&&((l=document.documentElement)===null||l===void 0?void 0:l.lang)||void 0;this.glyphManager=new ot(t._requestManager,n.localIdeographFontFamily,p),this.lineAtlas=new tt(256,512),this.crossTileSymbolIndex=new Pr,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",c.bP()),de().on(re,this._rtlPluginLoaded),this.on("data",(m=>{if(m.dataType!=="source"||m.sourceDataType!=="metadata")return;const _=this.tileManagers[m.sourceId];if(!_)return;const x=_.getSource();if(x&&x.vectorLayerIds)for(const b in this._layers){const T=this._layers[b];T.source===x.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 a,l,p;this._checkLoaded();const m=n===null?(p=(l=(a=this.stylesheet.state)===null||a===void 0?void 0:a[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 a in t)!c.bR(this._globalState[a],t[a].default)&&(n.push(a),this._globalState[a]=t[a].default);this._applyGlobalStateChanges(n)}_applyGlobalStateChanges(t){if(t.length===0)return;const n=new Set,a={};for(const l of t){a[l]=this._globalState[l];for(const p in this._layers){const m=this._layers[p],_=m.getLayoutAffectingGlobalStateRefs(),x=m.getPaintAffectingGlobalStateRefs(),b=m.getVisibilityAffectingGlobalStateRefs();if(_.has(l)&&n.add(m.source),x.has(l))for(const{name:T,value:E}of x.get(l))this._updatePaintProperty(m,T,E);b!=null&&b.has(l)&&(m.recalculateVisibility(),this._updateLayer(m))}}this.dispatcher.broadcast("UGS",a);for(const l in this.tileManagers)n.has(l)&&(this._reloadSource(l),this._changed=!0)}loadURL(t,n={},a){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,a)})).catch((m=>{this._loadStyleRequest=null,m&&!p.signal.aborted&&this.fire(new c.k(m))}))}loadJSON(t,n={},a){this.fire(new c.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,rt.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,n.validate=n.validate!==!1,this._load(t,n,a)})).catch((()=>{}))}loadEmpty(){this.fire(new c.l("dataloading",{dataType:"style"})),this._load(ta,{validate:!1})}_load(t,n,a){var l,p;let m=n.transformStyle?n.transformStyle(a,t):t;if(!n.validate||!ws(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 xi(this.stylesheet.light),this._setProjectionInternal(((l=this.stylesheet.projection)===null||l===void 0?void 0:l.type)||"mercator"),this.sky=new _t(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,a;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 _=(a=(n=p.paint)===null||n===void 0?void 0:n["raster-fade-duration"])!==null&&a!==void 0?a:m.paint.get("raster-fade-duration");this.tileManagers[m.source].setRasterFadeDuration(_)}}}_loadSprite(t,n=!1,a=void 0){this.imageManager.setLoaded(!1);const l=new AbortController;let p;this._spriteRequest=l,(function(m,_,x,b){return c._(this,void 0,void 0,(function*(){const T=pe(m),E=x>1?"@2x":"",I={},k={};for(const{id:V,url:q}of T){const W=_.transformRequest(De(q,E,".json"),"SpriteJSON");I[V]=c.j(W,b);const Z=_.transformRequest(De(q,E,".png"),"SpriteImage");k[V]=dt.getImage(Z,b)}return yield Promise.all([...Object.values(I),...Object.values(k)]),(function(V,q){return c._(this,void 0,void 0,(function*(){const W={};for(const Z in V){W[Z]={};const Y=rt.getImageCanvasContext((yield q[Z]).data),ie=(yield V[Z]).data;for(const H in ie){const{width:ee,height:se,x:J,y:oe,sdf:Te,pixelRatio:_e,stretchX:xe,stretchY:ve,content:Fe,textFitWidth:Le,textFitHeight:Ae}=ie[H];W[Z][H]={data:null,pixelRatio:_e,sdf:Te,stretchX:xe,stretchY:ve,content:Fe,textFitWidth:Le,textFitHeight:Ae,spriteData:{width:ee,height:se,x:J,y:oe,context:Y}}}}return W}))})(I,k)}))})(t,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((m=>{if(this._spriteRequest=null,m)for(const _ in m){this._spritesImagesIds[_]=[];const x=this._spritesImagesIds[_]?this._spritesImagesIds[_].filter((b=>!(b in m))):[];for(const b of x)this.imageManager.removeImage(b),this._changedImages[b]=!0;for(const b in m[_]){const T=_==="default"?b:`${_}:${b}`;this._spritesImagesIds[_].push(T),T in this.imageManager.images?this.imageManager.updateImage(T,m[_][b],!1):this.imageManager.addImage(T,m[_][b]),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"})),a&&a(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 a=t.sourceLayer;if(!a)return;const l=n.getSource();(l.type==="geojson"||l.vectorLayerIds&&l.vectorLayerIds.indexOf(a)===-1)&&this.fire(new c.k(new Error(`Source layer "${a}" 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 a=this._serializedAllLayers();if(!t||t.length===0)return Object.values(n?c.bV(a):a);const l=[];for(const p of t)if(a[p]){const m=n?c.bV(a[p]):a[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 a of n){const l=this._layers[a];l.type!=="custom"&&(t[a]=l.serialize())}return t}hasTransitions(){var t,n,a;if(!((t=this.light)===null||t===void 0)&&t.hasTransition()||!((n=this.sky)===null||n===void 0)&&n.hasTransition()||!((a=this.projection)===null||a===void 0)&&a.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 a={};for(const l in this.tileManagers){const p=this.tileManagers[l];a[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 a){const p=this.tileManagers[l];!!a[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 a;this._checkLoaded();const l=this.serialize();if(t=n.transformStyle?n.transformStyle(l,t):t,((a=n.validate)===null||a===void 0||a)&&ws(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,!0}_getOperationsToPerform(t){const n=[],a=[];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:a.push(l.command)}return{operations:n,unimplemented:a}}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,a={}){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,a))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const l=this.tileManagers[t]=new Vr(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");for(const a in this._layers)if(this._layers[a].source===t)return this.fire(new c.k(new Error(`Source "${t}" cannot be removed while layer "${a}" 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 a=this.tileManagers[t].getSource();if(a.type!=="geojson")throw new Error(`geojsonSource.type is ${a.type}, which is !== 'geojson`);a.setData(n),this._changed=!0}getSource(t){return this.tileManagers[t]&&this.tileManagers[t].getSource()}addLayer(t,n,a={}){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(ws(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},a))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 a=this._order.indexOf(t);this._order.splice(a,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 a=this._order.indexOf(t);this._order.splice(a,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,a){this._checkLoaded();const l=this.getLayer(t);l?l.minzoom===n&&l.maxzoom===a||(n!=null&&(l.minzoom=n),a!=null&&(l.maxzoom=a),this._updateLayer(l)):this.fire(new c.k(new Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,n,a={}){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,a)||(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,a,l={}){this._checkLoaded();const p=this.getLayer(t);p?c.bR(p.getLayoutProperty(n),a)||(p.setLayoutProperty(n,a,l),this._updateLayer(p)):this.fire(new c.k(new Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,n){const a=this.getLayer(t);if(a)return a.getLayoutProperty(n);this.fire(new c.k(new Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,n,a,l={}){this._checkLoaded();const p=this.getLayer(t);p?c.bR(p.getPaintProperty(n),a)||this._updatePaintProperty(p,n,a,l):this.fire(new c.k(new Error(`Cannot style non-existing layer "${t}".`)))}_updatePaintProperty(t,n,a,l={}){t.setPaintProperty(n,a,l)&&this._updateLayer(t),c.bU(t)&&n==="raster-fade-duration"&&this.tileManagers[t.source].setRasterFadeDuration(a),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 a=t.source,l=t.sourceLayer,p=this.tileManagers[a];if(p===void 0)return void this.fire(new c.k(new Error(`The source '${a}' 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 a=t.source,l=this.tileManagers[a];if(l===void 0)return void this.fire(new c.k(new Error(`The source '${a}' 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,a=t.sourceLayer,l=this.tileManagers[n];if(l!==void 0)return l.getSource().type!=="vector"||a?(t.id===void 0&&this.fire(new c.k(new Error("The feature id parameter must be provided."))),l.getFeatureState(a,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),a=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:a},(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",a={},l=[];for(let m=this._order.length-1;m>=0;m--){const _=this._order[m];if(n(_)){a[_]=m;for(const x of t){const b=x[_];if(b)for(const T of b)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 x=l.length-1;x>=0;x--){const b=l[x].feature;if(a[b.layer.id]<m)break;p.push(b),l.pop()}else for(const x of t){const b=x[_];if(b)for(const T of b)p.push(T.feature)}}return p}queryRenderedFeatures(t,n,a){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 b of n.layers){const T=this._layers[b];if(!T)return this.fire(new c.k(new Error(`The layer '${b}' 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,x=Object.assign(Object.assign({},n),{layers:_,globalState:this._globalState});for(const b in this.tileManagers)n.layers&&!l[b]||p.push(ri(this.tileManagers[b],this._layers,m,t,x,a,this.map.terrain?(T,E,I)=>this.map.terrain.getElevation(T,E,I):void 0));return this.placement&&p.push((function(b,T,E,I,k,V,q){const W={},Z=V.queryRenderedSymbols(I),Y=[];for(const ie of Object.keys(Z).map(Number))Y.push(q[ie]);Y.sort(yt);for(const ie of Y){const H=ie.featureIndex.lookupSymbolFeatures(Z[ie.bucketInstanceId],T,ie.bucketIndex,ie.sourceLayerIndex,{filterSpec:k.filter,globalState:k.globalState},k.layers,k.availableImages,b);for(const ee in H){const se=W[ee]=W[ee]||[],J=H[ee];J.sort(((oe,Te)=>{const _e=ie.featureSortOrder;if(_e){const xe=_e.indexOf(oe.featureIndex);return _e.indexOf(Te.featureIndex)-xe}return Te.featureIndex-oe.featureIndex}));for(const oe of J)se.push(oe)}}return(function(ie,H,ee){for(const se in ie)for(const J of ie[se])kt(J,ee[H[se].source]);return ie})(W,b,E)})(this._layers,m,this.tileManagers,t,x,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(p)}querySourceFeatures(t,n){n!=null&&n.filter&&this._validate(c.C.filter,"querySourceFeatures.filter",n.filter,null,n);const a=this.tileManagers[t];return a?(function(l,p){const m=l.getRenderableIds().map((b=>l.getTileByID(b))),_=[],x={};for(let b=0;b<m.length;b++){const T=m[b],E=T.tileID.canonical.key;x[E]||(x[E]=!0,T.querySourceFeatures(_,p))}return _})(a,n?Object.assign(Object.assign({},n),{globalState:this._globalState}):{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(t,n={}){this._checkLoaded();const a=this.light.getLight();let l=!1;for(const m in t)if(!c.bR(t[m],a[m])){l=!0;break}if(!l)return;const p={now:Je(),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.projection){if(this.projection.name===t.type)return;this.projection.destroy(),delete this.projection}this.stylesheet.projection=t,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 a=this.getSky();let l=!1;if(!t&&!a)return;if(t&&!a)l=!0;else if(!t&&a)l=!0;else for(const m in t)if(!c.bR(t[m],a[m])){l=!0;break}if(!l)return;const p={now:Je(),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(a,l){const p={constrainOverride:l};if(Array.isArray(a)){const m=new Ec({type:a});return{projection:m,transform:new bs(p),cameraHelper:new Dc(m)}}switch(a){case"mercator":return{projection:new br,transform:new jn(p),cameraHelper:new Nn};case"globe":{const m=new Ec({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]});return{projection:m,transform:new bs(p),cameraHelper:new Dc(m)}}case"vertical-perspective":return{projection:new al,transform:new vs(p),cameraHelper:new Wi};default:return c.w(`Unknown projection name: ${a}. Falling back to mercator projection.`),{projection:new br,transform:new jn(p),cameraHelper:new Nn}}})(t,this.map.transformConstrain);this.projection=n.projection,this.map.migrateProjection(n.transform,n.cameraHelper);for(const a in this.tileManagers)this.tileManagers[a].reload()}_validate(t,n,a,l,p={}){return(!p||p.validate!==!1)&&ws(this,t.call(c.C,c.e({key:n,style:this.serialize(),value:a,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),de().off(re,this._rtlPluginLoaded);for(const n in this._layers)this._layers[n].setEventedParent(null);for(const n in this.tileManagers){const a=this.tileManagers[n];a.setEventedParent(null),a.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,a,l,p=!1){let m=!1,_=!1;const x={};for(const b of this._order){const T=this._layers[b];if(T.type!=="symbol")continue;if(!x[T.source]){const I=this.tileManagers[T.source];x[T.source]=I.getRenderableIds(!0).map((k=>I.getTileByID(k))).sort(((k,V)=>V.tileID.overscaledZ-k.tileID.overscaledZ||(k.tileID.isLessThan(V.tileID)?-1:1)))}const E=this.crossTileSymbolIndex.addLayer(T,x[T.source],t.center.lng);m=m||E}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((p=p||this._layerOrderChanged||a===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(Je(),t.zoom))&&(this.pauseablePlacement=new ps(t,this.map.terrain,this._order,p,n,a,l,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,x),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(Je()),_=!0),m&&this.pauseablePlacement.placement.setStale()),_||m)for(const b of this._order){const T=this._layers[b];T.type==="symbol"&&this.placement.updateLayerOpacities(T,x[T.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(Je())}_releaseSymbolFadeTiles(){for(const t in this.tileManagers)this.tileManagers[t].releaseSymbolFadeTiles()}getImages(t,n){return c._(this,void 0,void 0,(function*(){const a=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),a}))}getGlyphs(t,n){return c._(this,void 0,void 0,(function*(){const a=yield this.glyphManager.getGlyphs(n.stacks),l=this.tileManagers[n.source];return l&&l.setDependencies(n.tileID.key,n.type,[""]),a}))}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 a={};for(const[l,p]of Object.entries(n.dashes))a[l]=this.lineAtlas.getDash(p.dasharray,p.round);return a}))}addSprite(t,n,a={},l){this._checkLoaded();const p=[{id:t,url:n}],m=[...pe(this.stylesheet.sprite),...p];this._validate(c.C.sprite,"sprite",m,null,a)||(this.stylesheet.sprite=m,this._loadSprite(p,!0,l))}removeSprite(t){this._checkLoaded();const n=pe(this.stylesheet.sprite);if(n.find((a=>a.id===t))){if(this._spritesImagesIds[t])for(const a of this._spritesImagesIds[t])this.imageManager.removeImage(a),this._changedImages[a]=!0;n.splice(n.findIndex((a=>a.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 pe(this.stylesheet.sprite)}setSprite(t,n={},a){this._checkLoaded(),t&&this._validate(c.C.sprite,"sprite",t,null,n)||(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,a):(this._unloadSprite(),a&&a(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 uh=c.aU([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Xa{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,n,a,l,p,m,_,x,b){this.context=t;let T=this.boundPaintVertexBuffers.length!==l.length;for(let E=0;!T&&E<l.length;E++)this.boundPaintVertexBuffers[E]!==l[E]&&(T=!0);!this.vao||this.boundProgram!==n||this.boundLayoutVertexBuffer!==a||T||this.boundIndexBuffer!==p||this.boundVertexOffset!==m||this.boundDynamicVertexBuffer!==_||this.boundDynamicVertexBuffer2!==x||this.boundDynamicVertexBuffer3!==b?this.freshBind(n,a,l,p,m,_,x,b):(t.bindVertexArray.set(this.vao),_&&_.bind(),p&&p.dynamicDraw&&p.bind(),x&&x.bind(),b&&b.bind())}freshBind(t,n,a,l,p,m,_,x){const b=t.numAttributes,T=this.context,E=T.gl;this.vao&&this.destroy(),this.vao=T.createVertexArray(),T.bindVertexArray.set(this.vao),this.boundProgram=t,this.boundLayoutVertexBuffer=n,this.boundPaintVertexBuffers=a,this.boundIndexBuffer=l,this.boundVertexOffset=p,this.boundDynamicVertexBuffer=m,this.boundDynamicVertexBuffer2=_,this.boundDynamicVertexBuffer3=x,n.enableAttributes(E,t);for(const I of a)I.enableAttributes(E,t);m&&m.enableAttributes(E,t),_&&_.enableAttributes(E,t),x&&x.enableAttributes(E,t),n.bind(),n.setVertexAttribPointers(E,t,p);for(const I of a)I.bind(),I.setVertexAttribPointers(E,t,p);m&&(m.bind(),m.setVertexAttribPointers(E,t,p)),l&&l.bind(),_&&(_.bind(),_.setVertexAttribPointers(E,t,p)),x&&(x.bind(),x.setVertexAttribPointers(E,t,p)),T.currentNumAttributes=b}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const hh=(d,t,n,a,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(a):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}),Ts={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 Ya(d){const t=[];for(let n=0;n<d.length;n++){if(d[n]===null)continue;const a=d[n].split(" ");t.push(a.pop())}return t}class zc{constructor(t,n,a,l,p,m,_,x,b=[]){const T=t.gl;this.program=T.createProgram();const E=Ya(n.staticAttributes),I=a?a.getBinderAttributes():[],k=E.concat(I),V=Ii.prelude.staticUniforms?Ya(Ii.prelude.staticUniforms):[],q=_.staticUniforms?Ya(_.staticUniforms):[],W=n.staticUniforms?Ya(n.staticUniforms):[],Z=a?a.getBinderUniforms():[],Y=V.concat(q).concat(W).concat(Z),ie=[];for(const _e of Y)ie.indexOf(_e)<0&&ie.push(_e);const H=a?a.defines():[];jr(T)&&H.unshift("#version 300 es"),p&&H.push("#define OVERDRAW_INSPECTOR;"),m&&H.push("#define TERRAIN3D;"),x&&H.push(x),b&&H.push(...b);let ee=H.concat(Ii.prelude.fragmentSource,_.fragmentSource,n.fragmentSource).join(`
805
+ `),se=H.concat(Ii.prelude.vertexSource,_.vertexSource,n.vertexSource).join(`
806
+ `);jr(T)||(ee=(function(_e){return _e.replace(/\bin\s/g,"varying ").replace("out highp vec4 fragColor;","").replace(/fragColor/g,"gl_FragColor").replace(/texture\(/g,"texture2D(")})(ee),se=(function(_e){return _e.replace(/\bin\s/g,"attribute ").replace(/\bout\s/g,"varying ").replace(/texture\(/g,"texture2D(")})(se));const J=T.createShader(T.FRAGMENT_SHADER);if(T.isContextLost())return void(this.failedToCreate=!0);if(T.shaderSource(J,ee),T.compileShader(J),!T.getShaderParameter(J,T.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${T.getShaderInfoLog(J)}`);T.attachShader(this.program,J);const oe=T.createShader(T.VERTEX_SHADER);if(T.isContextLost())return void(this.failedToCreate=!0);if(T.shaderSource(oe,se),T.compileShader(oe),!T.getShaderParameter(oe,T.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${T.getShaderInfoLog(oe)}`);T.attachShader(this.program,oe),this.attributes={};const Te={};this.numAttributes=k.length;for(let _e=0;_e<this.numAttributes;_e++)k[_e]&&(T.bindAttribLocation(this.program,_e,k[_e]),this.attributes[k[_e]]=_e);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(oe),T.deleteShader(J);for(let _e=0;_e<ie.length;_e++){const xe=ie[_e];if(xe&&!Te[xe]){const ve=T.getUniformLocation(this.program,xe);ve&&(Te[xe]=ve)}}this.fixedUniforms=l(t,Te),this.terrainUniforms=((_e,xe)=>({u_depth:new c.b_(_e,xe.u_depth),u_terrain:new c.b_(_e,xe.u_terrain),u_terrain_dim:new c.bq(_e,xe.u_terrain_dim),u_terrain_matrix:new c.c0(_e,xe.u_terrain_matrix),u_terrain_unpack:new c.c1(_e,xe.u_terrain_unpack),u_terrain_exaggeration:new c.bq(_e,xe.u_terrain_exaggeration)}))(t,Te),this.projectionUniforms=((_e,xe)=>({u_projection_matrix:new c.c0(_e,xe.u_projection_matrix),u_projection_tile_mercator_coords:new c.c1(_e,xe.u_projection_tile_mercator_coords),u_projection_clipping_plane:new c.c1(_e,xe.u_projection_clipping_plane),u_projection_transition:new c.bq(_e,xe.u_projection_transition),u_projection_fallback_matrix:new c.c0(_e,xe.u_projection_fallback_matrix)}))(t,Te),this.binderUniforms=a?a.getUniforms(t,Te):[]}draw(t,n,a,l,p,m,_,x,b,T,E,I,k,V,q,W,Z,Y,ie){const H=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(a),t.setStencilMode(l),t.setColorMode(p),t.setCullFace(m),x){t.activeTexture.set(H.TEXTURE2),H.bindTexture(H.TEXTURE_2D,x.depthTexture),t.activeTexture.set(H.TEXTURE3),H.bindTexture(H.TEXTURE_2D,x.texture);for(const se in this.terrainUniforms)this.terrainUniforms[se].set(x[se])}if(b)for(const se in b)this.projectionUniforms[Ts[se]].set(b[se]);if(_)for(const se in this.fixedUniforms)this.fixedUniforms[se].set(_[se]);W&&W.setUniforms(t,this.binderUniforms,V,{zoom:q});let ee=0;switch(n){case H.LINES:ee=2;break;case H.TRIANGLES:ee=3;break;case H.LINE_STRIP:ee=1}for(const se of k.get()){const J=se.vaos||(se.vaos={});(J[T]||(J[T]=new Xa)).bind(t,this,E,W?W.getPaintVertexBuffers():[],I,se.vertexOffset,Z,Y,ie),H.drawElements(n,se.primitiveLength*ee,H.UNSIGNED_SHORT,se.primitiveOffset*ee*2)}}}function kc(d,t,n){const a=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:[a,d.fromScale,d.toScale],u_fade:d.t,u_pixel_coord_upper:[m>>16,_>>16],u_pixel_coord_lower:[65535&m,65535&_]}}const ul=(d,t,n,a)=>{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 x=d.transform.transformLightDirection(m),b=l.properties.get("color");return{u_lightpos:m,u_lightpos_globe:x,u_lightintensity:l.properties.get("intensity"),u_lightcolor:[b.r,b.g,b.b],u_vertical_gradient:+t,u_opacity:n,u_fill_translate:a}},hl=(d,t,n,a,l,p,m)=>c.e(ul(d,t,n,a),kc(p,d,m),{u_height_factor:-Math.pow(2,l.overscaledZ)/m.tileSize/8}),dl=(d,t,n,a)=>c.e(kc(t,d,n),{u_fill_translate:a}),Rc=(d,t)=>({u_world:d,u_fill_translate:t}),Fc=(d,t,n,a,l)=>c.e(dl(d,t,n,l),{u_world:a}),Lc=(d,t,n,a,l)=>{const p=d.transform;let m,_,x=0;if(n.paint.get("circle-pitch-alignment")==="map"){const b=c.aN(t,1,p.zoom);m=!0,_=[b,b],x=b/(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:x,u_translate:a}},qn=d=>({u_pixel_extrude_scale:[1/d.width,1/d.height]}),Bc=d=>({u_viewport_size:[d.width,d.height]}),pl=(d,t=1)=>({u_color:d,u_overlay:0,u_overlay_scale:t}),Ss=(d,t,n,a)=>{const l=c.aN(d,1,t)/(c.a5*Math.pow(2,d.tileID.overscaledZ))*2*Math.PI*a;return{u_extrude_scale:c.aN(d,1,t),u_intensity:n,u_globe_extrude_scale:l}},Oc=(d,t,n,a)=>{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:a,u_opacity:t.paint.get("heatmap-opacity")}},Ka=(d,t,n)=>{const a=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:ph(0,t.tileID),u_exaggeration:n.paint.get("hillshade-exaggeration"),u_altitudes:p.altitudeRadians,u_azimuths:p.directionRadians,u_accent:a,u_method:l,u_highlights:p.highlightColor,u_shadows:p.shadowColor}},dh=(d,t)=>{const n=t.stride,a=c.N();return c.c7(a,0,c.a5,-c.a5,0,0,1),c.O(a,a,[0,-c.a5,0]),{u_matrix:a,u_image:1,u_dimension:[n,n],u_zoom:d.overscaledZ,u_unpack:t.getUnpackVector()}};function ph(d,t){const n=Math.pow(2,t.canonical.z),a=t.canonical.y;return[new c.a9(0,a/n).toLngLat().lat,new c.a9(0,(a+1)/n).toLngLat().lat]}const Vc=(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")}),ia=(d,t,n,a)=>{const l=d.transform;return{u_translation:Qa(d,t,n),u_ratio:a/c.aN(t,1,l.zoom),u_device_pixel_ratio:d.pixelRatio,u_units_to_pixels:[1/l.pixelsToGLUnits[0],1/l.pixelsToGLUnits[1]]}},jc=(d,t,n,a,l)=>c.e(ia(d,t,n,a),{u_image:0,u_image_height:l}),fl=(d,t,n,a,l)=>{const p=d.transform,m=Xr(t,p);return{u_translation:Qa(d,t,n),u_texsize:t.imageAtlasTexture.size,u_ratio:a/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]]}},Nc=(d,t,n,a,l)=>{const p=Xr(t,d.transform);return c.e(ia(d,t,n,a),{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})},Ja=(d,t,n,a,l,p)=>{const m=Xr(t,d.transform);return c.e(ia(d,t,n,a),{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 Xr(d,t){return 1/c.aN(d,1,t.tileZoom)}function Qa(d,t,n){return c.aO(d.transform,t,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const ml=(d,t,n,a,l)=>{return{u_tl_parent:d,u_scale_parent:t,u_buffer_scale:1,u_fade_t:n.mix,u_opacity:n.opacity*a.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:a.paint.get("raster-brightness-min"),u_brightness_high:a.paint.get("raster-brightness-max"),u_saturation_factor:(m=a.paint.get("raster-saturation"),m>0?1-1/(1.001-m):-m),u_contrast_factor:(p=a.paint.get("raster-contrast"),p>0?1/(1-p):1+p),u_spin_weights:gl(a.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 gl(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 _l=(d,t,n,a,l,p,m,_,x,b,T,E,I)=>{const k=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:k.cameraToCenterDistance,u_pitch:k.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:k.width/k.height,u_fade_change:m.options.fadeDuration?m.symbolFadeChange:1,u_label_plane_matrix:_,u_coord_matrix:x,u_is_text:+T,u_pitch_with_map:+a,u_is_along_line:l,u_is_variable_anchor:p,u_texsize:E,u_texture:0,u_translation:b,u_pitched_scale:I}},eo=(d,t,n,a,l,p,m,_,x,b,T,E,I,k)=>{const V=m.transform;return c.e(_l(d,t,n,a,l,p,m,_,x,b,T,E,k),{u_gamma_scale:a?Math.cos(V.pitch*Math.PI/180)*V.cameraToCenterDistance:1,u_device_pixel_ratio:m.pixelRatio,u_is_halo:1})},Zn=(d,t,n,a,l,p,m,_,x,b,T,E,I)=>c.e(eo(d,t,n,a,l,p,m,_,x,b,!0,T,0,I),{u_texsize_icon:E,u_texture_icon:1}),yl=(d,t)=>({u_opacity:d,u_color:t}),fh=(d,t,n,a,l)=>c.e((function(p,m,_,x){const b=_.imageManager.getPattern(p.from.toString()),T=_.imageManager.getPattern(p.to.toString()),{width:E,height:I}=_.imageManager.getPixelSize(),k=Math.pow(2,x.tileID.overscaledZ),V=x.tileSize*Math.pow(2,_.transform.tileZoom)/k,q=V*(x.tileID.canonical.x+x.tileID.wrap*k),W=V*x.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:b.tl,u_pattern_br_a:b.br,u_pattern_tl_b:T.tl,u_pattern_br_b:T.br,u_texsize:[E,I],u_mix:m.t,u_pattern_size_a:b.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(x,1,_.transform.tileZoom),u_pixel_coord_upper:[q>>16,W>>16],u_pixel_coord_lower:[65535&q,65535&W]}})(n,l,t,a),{u_opacity:d}),Uc=(d,t)=>{},mh={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:Uc,clippingMask:Uc,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 gh{constructor(t,n,a){this.context=t;const l=t.gl;this.buffer=l.createBuffer(),this.dynamicDraw=!!a,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 Gc={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class _h{constructor(t,n,a,l){this.length=n.length,this.attributes=a,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 a=0;a<this.attributes.length;a++){const l=n.attributes[this.attributes[a].name];l!==void 0&&t.enableVertexAttribArray(l)}}setVertexAttribPointers(t,n,a){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[Gc[p.type]],!1,this.itemSize,p.offset+this.itemSize*(a||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class qt{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 to extends qt{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 io extends qt{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class ro extends qt{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class xl extends qt{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 $n extends qt{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class ra extends qt{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class Ps extends qt{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 Nr extends qt{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 qc extends qt{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 Zc extends qt{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 vl extends qt{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 Wn extends qt{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class no extends qt{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 so extends qt{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 na extends qt{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 ao extends qt{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class $c extends qt{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 Ms extends qt{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class Is extends qt{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class Wc extends qt{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class bl extends qt{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class Et extends qt{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 oo extends qt{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 yh extends qt{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 Hc extends qt{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 sa extends qt{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 xh extends qt{getDefault(){return null}set(t){const n=this.gl;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class vh extends qt{getDefault(){return null}set(t){var n;if(t===this.current&&!this.dirty)return;const a=this.gl;jr(a)?a.bindVertexArray(t):(n=a.getExtension("OES_vertex_array_object"))===null||n===void 0||n.bindVertexArrayOES(t),this.current=t,this.dirty=!1}}class Xc extends qt{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 bh extends qt{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 wl extends qt{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 Es extends qt{constructor(t,n){super(t),this.context=t,this.parent=n}getDefault(){return null}}class aa extends Es{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 lo extends Es{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 Tl extends Es{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 Sl="Framebuffer is not complete";class co{constructor(t,n,a,l,p){this.context=t,this.width=n,this.height=a;const m=t.gl,_=this.framebuffer=m.createFramebuffer();if(this.colorAttachment=new aa(t,_),l)this.depthAttachment=p?new Tl(t,_):new lo(t,_);else if(p)throw new Error("Stencil cannot be set without depth");if(m.checkFramebufferStatus(m.FRAMEBUFFER)!==m.FRAMEBUFFER_COMPLETE)throw new Error(Sl)}destroy(){const t=this.context.gl,n=this.colorAttachment.get();if(n&&t.deleteTexture(n),this.depthAttachment){const a=this.depthAttachment.get();a&&t.deleteRenderbuffer(a)}t.deleteFramebuffer(this.framebuffer)}}class uo{constructor(t){var n,a;if(this.gl=t,this.clearColor=new to(this),this.clearDepth=new io(this),this.clearStencil=new ro(this),this.colorMask=new xl(this),this.depthMask=new $n(this),this.stencilMask=new ra(this),this.stencilFunc=new Ps(this),this.stencilOp=new Nr(this),this.stencilTest=new qc(this),this.depthRange=new Zc(this),this.depthTest=new vl(this),this.depthFunc=new Wn(this),this.blend=new no(this),this.blendFunc=new so(this),this.blendColor=new na(this),this.blendEquation=new ao(this),this.cullFace=new $c(this),this.cullFaceSide=new Ms(this),this.frontFace=new Is(this),this.program=new Wc(this),this.activeTexture=new bl(this),this.viewport=new Et(this),this.bindFramebuffer=new oo(this),this.bindRenderbuffer=new yh(this),this.bindTexture=new Hc(this),this.bindVertexBuffer=new sa(this),this.bindElementBuffer=new xh(this),this.bindVertexArray=new vh(this),this.pixelStoreUnpack=new Xc(this),this.pixelStoreUnpackPremultiplyAlpha=new bh(this),this.pixelStoreUnpackFlipY=new wl(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),jr(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==null?void 0:l.RGBA16F_EXT,this.RGB16F=(a=t.RGB16F)!==null&&a!==void 0?a:l==null?void 0: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==null?void 0: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 gh(this,t,n)}createVertexBuffer(t,n,a){return new _h(this,t,n,a)}createRenderbuffer(t,n,a){const l=this.gl,p=l.createRenderbuffer();return this.bindRenderbuffer.set(p),l.renderbufferStorage(l.RENDERBUFFER,t,n,a),this.bindRenderbuffer.set(null),p}createFramebuffer(t,n,a,l){return new co(this,t,n,a,l)}clear({color:t,depth:n,stencil:a}){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)),a!==void 0&&(p|=l.STENCIL_BUFFER_BIT,this.clearStencil.set(a),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,oi.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 jr(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 jr(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 Mn;function Hn(d,t,n,a,l){const p=d.context,m=d.transform,_=p.gl,x=d.useProgram("collisionBox"),b=[];let T=0,E=0;for(let Z=0;Z<a.length;Z++){const Y=a[Z],ie=t.getTile(Y).getBucket(n);if(!ie)continue;const H=l?ie.textCollisionBox:ie.iconCollisionBox,ee=ie.collisionCircleArray;ee.length>0&&(b.push({circleArray:ee,circleOffset:E,coord:Y}),T+=ee.length/4,E=T),H&&x.draw(p,_.LINES,wt.disabled,Bt.disabled,d.colorModeForRenderPass(),Ft.disabled,qn(d.transform),d.style.map.terrain&&d.style.map.terrain.getTerrainData(Y),m.getProjectionData({overscaledTileID:Y,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),n.id,H.layoutVertexBuffer,H.indexBuffer,H.segments,null,d.transform.zoom,null,null,H.collisionVertexBuffer)}if(!l||!b.length)return;const I=d.useProgram("collisionCircle"),k=new c.ca;k.resize(4*T),k._trim();let V=0;for(const Z of b)for(let Y=0;Y<Z.circleArray.length/4;Y++){const ie=4*Y,H=Z.circleArray[ie+0],ee=Z.circleArray[ie+1],se=Z.circleArray[ie+2],J=Z.circleArray[ie+3];k.emplace(V++,H,ee,se,J,0),k.emplace(V++,H,ee,se,J,1),k.emplace(V++,H,ee,se,J,2),k.emplace(V++,H,ee,se,J,3)}(!Mn||Mn.length<2*T)&&(Mn=(function(Z){const Y=2*Z,ie=new c.cc;ie.resize(Y),ie._trim();for(let H=0;H<Y;H++){const ee=6*H;ie.uint16[ee+0]=4*H+0,ie.uint16[ee+1]=4*H+1,ie.uint16[ee+2]=4*H+2,ie.uint16[ee+3]=4*H+2,ie.uint16[ee+4]=4*H+3,ie.uint16[ee+5]=4*H+0}return ie})(T));const q=p.createIndexBuffer(Mn,!0),W=p.createVertexBuffer(k,c.cb.members,!0);for(const Z of b){const Y=Bc(d.transform);I.draw(p,_.TRIANGLES,wt.disabled,Bt.disabled,d.colorModeForRenderPass(),Ft.disabled,Y,d.style.map.terrain&&d.style.map.terrain.getTerrainData(Z.coord),null,n.id,W,q,c.aX.simpleSegment(0,2*Z.circleOffset,Z.circleArray.length,Z.circleArray.length/2),null,d.transform.zoom,null,null,null)}W.destroy(),q.destroy()}const Pl=c.ar(new Float32Array(16));function wh(d,t,n,a,l,p){const{horizontalAlign:m,verticalAlign:_}=c.aS(d);return new c.P((-(m-.5)*t/l+a[0])*p,(-(_-.5)*n/l+a[1])*p)}function oa(d,t,n,a,l,p){const m=t.tileAnchorPoint.add(new c.P(t.translation[0],t.translation[1]));if(t.pitchWithMap){let _=a.mult(p);n||(_=_.rotate(-l));const x=m.add(_);return bt(x.x,x.y,t.pitchedLabelPlaneMatrix,t.getElevation).point}if(n){const _=Jt(t.tileAnchorPoint.x+1,t.tileAnchorPoint.y,t).point.sub(d),x=Math.atan(_.y/_.x)+(_.x<0?Math.PI:0);return d.add(a.rotate(x))}return d.add(a)}function Th(d,t,n,a,l,p,m,_,x,b,T,E){const I=d.text.placedSymbolArray,k=d.text.dynamicLayoutVertexArray,V=d.icon.dynamicLayoutVertexArray,q={};k.clear();for(let W=0;W<I.length;W++){const Z=I.get(W),Y=Z.hidden||!Z.crossTileID||d.allowVerticalPlacement&&!Z.placedOrientation?null:a[Z.crossTileID];if(Y){const ie=new c.P(Z.anchorX,Z.anchorY),H={getElevation:E,width:l.width,height:l.height,pitchedLabelPlaneMatrix:p,pitchWithMap:n,transform:l,tileAnchorPoint:ie,translation:b,unwrappedTileID:T},ee=n?hs(ie.x,ie.y,H):Jt(ie.x,ie.y,H),se=Gs(l.cameraToCenterDistance,ee.signedDistanceFromCamera);let J=c.aA(d.textSizeData,_,Z)*se/c.aM;n&&(J*=d.tilePixelRatio/m);const{width:oe,height:Te,anchor:_e,textOffset:xe,textBoxScale:ve}=Y,Fe=wh(_e,oe,Te,xe,ve,J),Le=l.getPitchedTextCorrection(ie.x+b[0],ie.y+b[1],T),Ae=oa(ee.point,H,t,Fe,-l.bearingInRadians,Le),Ue=d.allowVerticalPlacement&&Z.placedOrientation===c.az.vertical?Math.PI/2:0;for(let gt=0;gt<Z.numGlyphs;gt++)c.aG(k,Ae,Ue);x&&Z.associatedIconIndex>=0&&(q[Z.associatedIconIndex]={shiftedAnchor:Ae,angle:Ue})}else On(Z.numGlyphs,k)}if(x){V.clear();const W=d.icon.placedSymbolArray;for(let Z=0;Z<W.length;Z++){const Y=W.get(Z);if(Y.hidden)On(Y.numGlyphs,V);else{const ie=q[Z];if(ie)for(let H=0;H<Y.numGlyphs;H++)c.aG(V,ie.shiftedAnchor,ie.angle);else On(Y.numGlyphs,V)}}d.icon.dynamicLayoutVertexBuffer.updateData(V)}d.text.dynamicLayoutVertexBuffer.updateData(k)}function Yc(d,t,n){return n.iconsInText&&t?"symbolTextAndIcon":d?"symbolSDF":"symbolIcon"}function la(d,t,n,a,l,p,m,_,x,b,T,E,I){const k=d.context,V=k.gl,q=d.transform,W=_==="map",Z=x==="map",Y=_!=="viewport"&&n.layout.get("symbol-placement")!=="point",ie=W&&!Z&&!Y,H=!n.layout.get("symbol-sort-key").isConstant();let ee=!1;const se=d.getDepthModeForSublayer(0,wt.ReadOnly),J=n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"),oe=[],Te=q.getCircleRadiusCorrection();for(const _e of a){const xe=t.getTile(_e),ve=xe.getBucket(n);if(!ve)continue;const Fe=l?ve.text:ve.icon;if(!Fe||!Fe.segments.get().length||!Fe.hasVisibleVertices)continue;const Le=Fe.programConfigurations.get(n.id),Ae=l||ve.sdfIcons,Ue=l?ve.textSizeData:ve.iconSizeData,gt=Z||q.pitch!==0,Ht=d.useProgram(Yc(Ae,l,ve),Le),_i=c.ay(Ue,q.zoom),li=d.style.map.terrain&&d.style.map.terrain.getTerrainData(_e);let wi,ci,Fi,Ti,Qi=[0,0],qi=null;if(l)ci=xe.glyphAtlasTexture,Fi=V.LINEAR,wi=xe.glyphAtlasTexture.size,ve.iconsInText&&(Qi=xe.imageAtlasTexture.size,qi=xe.imageAtlasTexture,Ti=gt||d.options.rotating||d.options.zooming||Ue.kind==="composite"||Ue.kind==="camera"?V.LINEAR:V.NEAREST);else{const hi=n.layout.get("icon-size").constantOr(0)!==1||ve.iconsNeedLinear;ci=xe.imageAtlasTexture,Fi=Ae||d.options.rotating||d.options.zooming||hi||gt?V.LINEAR:V.NEAREST,wi=xe.imageAtlasTexture.size}const Ui=c.aN(xe,1,d.transform.zoom),or=Dr(W,d.transform,Ui),Dn=c.N();c.aB(Dn,or);const gn=Na(Z,W,d.transform,Ui),cn=c.aO(q,xe,p,m),Ir=q.getProjectionData({overscaledTileID:_e,applyGlobeMatrix:!I,applyTerrainMatrix:!0}),es=J&&ve.hasTextData(),Ea=n.layout.get("icon-text-fit")!=="none"&&es&&ve.hasIconData();if(Y){const hi=d.style.map.terrain?(Yi,Ki)=>d.style.map.terrain.getElevation(_e,Yi,Ki):null,ui=n.layout.get("text-rotation-alignment")==="map";Ua(ve,d,l,or,Dn,Z,b,ui,_e.toUnwrapped(),q.width,q.height,cn,hi)}const ts=l&&J||Ea,qr=Y||ts?Pl:Z?or:d.transform.clipSpaceToPixelsMatrix,un=Ae&&n.paint.get(l?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let en;en=Ae?ve.iconsInText?Zn(Ue.kind,_i,ie,Z,Y,ts,d,qr,gn,cn,wi,Qi,Te):eo(Ue.kind,_i,ie,Z,Y,ts,d,qr,gn,cn,l,wi,0,Te):_l(Ue.kind,_i,ie,Z,Y,ts,d,qr,gn,cn,l,wi,Te);const tn={program:Ht,buffers:Fe,uniformValues:en,projectionData:Ir,atlasTexture:ci,atlasTextureIcon:qi,atlasInterpolation:Fi,atlasInterpolationIcon:Ti,isSDF:Ae,hasHalo:un};if(H&&ve.canOverlap){ee=!0;const hi=Fe.segments.get();for(const ui of hi)oe.push({segments:new c.aX([ui]),sortKey:ui.sortKey,state:tn,terrainData:li})}else oe.push({segments:Fe.segments,sortKey:0,state:tn,terrainData:li})}ee&&oe.sort(((_e,xe)=>_e.sortKey-xe.sortKey));for(const _e of oe){const xe=_e.state;if(k.activeTexture.set(V.TEXTURE0),xe.atlasTexture.bind(xe.atlasInterpolation,V.CLAMP_TO_EDGE),xe.atlasTextureIcon&&(k.activeTexture.set(V.TEXTURE1),xe.atlasTextureIcon&&xe.atlasTextureIcon.bind(xe.atlasInterpolationIcon,V.CLAMP_TO_EDGE)),xe.isSDF){const ve=xe.uniformValues;xe.hasHalo&&(ve.u_is_halo=1,ho(xe.buffers,_e.segments,n,d,xe.program,se,T,E,ve,xe.projectionData,_e.terrainData)),ve.u_is_halo=0}ho(xe.buffers,_e.segments,n,d,xe.program,se,T,E,xe.uniformValues,xe.projectionData,_e.terrainData)}}function ho(d,t,n,a,l,p,m,_,x,b,T){const E=a.context;l.draw(E,E.gl.TRIANGLES,p,m,_,Ft.backCCW,x,T,b,n.id,d.layoutVertexBuffer,d.indexBuffer,t,n.paint,a.transform.zoom,d.programConfigurations.get(n.id),d.dynamicLayoutVertexBuffer,d.opacityVertexBuffer)}function Kc(d,t,n,a,l){const p=d.context,m=p.gl,_=Bt.disabled,x=new oi([m.ONE,m.ONE],c.bp.transparent,[!0,!0,!0,!0]),b=t.getBucket(n);if(!b)return;const T=a.key;let E=n.heatmapFbos.get(T);E||(E=ca(p,t.tileSize,t.tileSize),n.heatmapFbos.set(T,E)),p.bindFramebuffer.set(E.framebuffer),p.viewport.set([0,0,t.tileSize,t.tileSize]),p.clear({color:c.bp.transparent});const I=b.programConfigurations.get(n.id),k=d.useProgram("heatmap",I,!l),V=d.transform.getProjectionData({overscaledTileID:t.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),q=d.style.map.terrain.getTerrainData(a);k.draw(p,m.TRIANGLES,wt.disabled,_,x,Ft.disabled,Ss(t,d.transform.zoom,n.paint.get("heatmap-intensity"),1),q,V,n.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,n.paint,d.transform.zoom,I)}function Jc(d,t,n,a,l){const p=d.context,m=p.gl,_=d.transform;p.setColorMode(d.colorModeForRenderPass());const x=po(p,t),b=n.key,T=t.heatmapFbos.get(b);if(!T)return;p.activeTexture.set(m.TEXTURE0),m.bindTexture(m.TEXTURE_2D,T.colorAttachment.get()),p.activeTexture.set(m.TEXTURE1),x.bind(m.LINEAR,m.CLAMP_TO_EDGE);const E=_.getProjectionData({overscaledTileID:n,applyTerrainMatrix:l,applyGlobeMatrix:!a});d.useProgram("heatmapTexture").draw(p,m.TRIANGLES,wt.disabled,Bt.disabled,d.colorModeForRenderPass(),Ft.disabled,Oc(d,t,0,1),null,E,t.id,d.rasterBoundsBuffer,d.quadTriangleIndexBuffer,d.rasterBoundsSegments,t.paint,_.zoom),T.destroy(),t.heatmapFbos.delete(b)}function ca(d,t,n){var a,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 _=(a=d.HALF_FLOAT)!==null&&a!==void 0?a:p.UNSIGNED_BYTE,x=(l=d.RGBA16F)!==null&&l!==void 0?l:p.RGBA;p.texImage2D(p.TEXTURE_2D,0,x,t,n,0,p.RGBA,_,null);const b=d.createFramebuffer(t,n,!1,!1);return b.colorAttachment.set(m),b}function po(d,t){return t.colorRampTexture||(t.colorRampTexture=new c.T(d,t.colorRamp,d.gl.RGBA)),t.colorRampTexture}function Qc(d,t,n,a,l,p,m,_){let x=256;if(l.stepInterpolant){const b=t.getSource().maxzoom,T=m.canonical.z===b?Math.ceil(1<<d.transform.maxZoom-m.canonical.z):1;x=c.an(c.ce(p.maxLineLength/c.a5*1024*T),256,n.maxTextureSize)}return _.gradient=c.cf({expression:l.gradientExpression(),evaluationKey:"lineProgress",resolution:x,image:_.gradient||void 0,clips:p.lineClipsArray}),_.texture?_.texture.update(_.gradient):_.texture=new c.T(n,_.gradient,a.RGBA),_.version=l.gradientVersion,_.texture}function eu(d,t,n,a,l){d.activeTexture.set(t.TEXTURE0),n.imageAtlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE),a.updatePaintBuffers(l)}function ji(d,t,n,a,l,p){(l||d.lineAtlas.dirty)&&(t.activeTexture.set(n.TEXTURE0),d.lineAtlas.bind(t)),a.updatePaintBuffers(p)}function Xn(d,t,n,a,l,p,m){const _=p.gradients[l.id];let x=_.texture;l.gradientVersion!==_.version&&(x=Qc(d,t,n,a,l,p,m,_)),n.activeTexture.set(a.TEXTURE0),x.bind(l.stepInterpolant?a.NEAREST:a.LINEAR,a.CLAMP_TO_EDGE)}function kr(d,t,n,a,l,p,m,_,x){const b=p.gradients[l.id];let T=b.texture;l.gradientVersion!==b.version&&(T=Qc(d,t,n,a,l,p,m,b)),n.activeTexture.set(a.TEXTURE0),T.bind(l.stepInterpolant?a.NEAREST:a.LINEAR,a.CLAMP_TO_EDGE),n.activeTexture.set(a.TEXTURE1),d.lineAtlas.bind(n),_.updatePaintBuffers(x)}function fo(d,t,n,a,l){if(!n||!a||!a.imageAtlas)return;const p=a.imageAtlas.patternPositions;let m=p[n.to.toString()],_=p[n.from.toString()];if(!m&&_&&(m=_),!_&&m&&(_=m),!m||!_){const x=l.getPaintProperty(t);m=p[x],_=p[x]}m&&_&&d.setConstantPatternPositions(m,_)}function ua(d,t,n,a,l,p,m,_){const x=d.context.gl,b="fill-pattern",T=n.paint.get(b),E=T&&T.constantOr(1),I=n.getCrossfadeParameters();let k,V,q,W,Z;const Y=d.transform,ie=n.paint.get("fill-translate"),H=n.paint.get("fill-translate-anchor");m?(V=E&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",k=x.LINES):(V=E?"fillPattern":"fill",k=x.TRIANGLES);const ee=T.constantOr(null);for(const se of a){const J=t.getTile(se);if(E&&!J.patternsLoaded())continue;const oe=J.getBucket(n);if(!oe)continue;const Te=oe.programConfigurations.get(n.id),_e=d.useProgram(V,Te),xe=d.style.map.terrain&&d.style.map.terrain.getTerrainData(se);E&&(d.context.activeTexture.set(x.TEXTURE0),J.imageAtlasTexture.bind(x.LINEAR,x.CLAMP_TO_EDGE),Te.updatePaintBuffers(I)),fo(Te,b,ee,J,n);const ve=Y.getProjectionData({overscaledTileID:se,applyGlobeMatrix:!_,applyTerrainMatrix:!0}),Fe=c.aO(Y,J,ie,H);if(m){W=oe.indexBuffer2,Z=oe.segments2;const Ae=[x.drawingBufferWidth,x.drawingBufferHeight];q=V==="fillOutlinePattern"&&E?Fc(d,I,J,Ae,Fe):Rc(Ae,Fe)}else W=oe.indexBuffer,Z=oe.segments,q=E?dl(d,I,J,Fe):{u_fill_translate:Fe};const Le=d.stencilModeForClipping(se);_e.draw(d.context,k,l,Le,p,Ft.backCCW,q,xe,ve,n.id,oe.layoutVertexBuffer,W,Z,n.paint,d.transform.zoom,Te)}}function mo(d,t,n,a,l,p,m,_){const x=d.context,b=x.gl,T="fill-extrusion-pattern",E=n.paint.get(T),I=E.constantOr(1),k=n.getCrossfadeParameters(),V=n.paint.get("fill-extrusion-opacity"),q=E.constantOr(null),W=d.transform;for(const Z of a){const Y=t.getTile(Z),ie=Y.getBucket(n);if(!ie)continue;const H=d.style.map.terrain&&d.style.map.terrain.getTerrainData(Z),ee=ie.programConfigurations.get(n.id),se=d.useProgram(I?"fillExtrusionPattern":"fillExtrusion",ee);I&&(d.context.activeTexture.set(b.TEXTURE0),Y.imageAtlasTexture.bind(b.LINEAR,b.CLAMP_TO_EDGE),ee.updatePaintBuffers(k));const J=W.getProjectionData({overscaledTileID:Z,applyGlobeMatrix:!_,applyTerrainMatrix:!0});fo(ee,T,q,Y,n);const oe=c.aO(W,Y,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),Te=n.paint.get("fill-extrusion-vertical-gradient"),_e=I?hl(d,Te,V,oe,Z,k,Y):ul(d,Te,V,oe);se.draw(x,x.gl.TRIANGLES,l,p,m,Ft.backCCW,_e,H,J,n.id,ie.layoutVertexBuffer,ie.indexBuffer,ie.segments,n.paint,d.transform.zoom,ee,d.style.map.terrain&&ie.centroidVertexBuffer)}}function In(d,t,n,a,l,p,m,_,x){var b;const T=d.style.projection,E=d.context,I=d.transform,k=E.gl,V=[`#define NUM_ILLUMINATION_SOURCES ${n.paint.get("hillshade-highlight-color").values.length}`],q=d.useProgram("hillshade",null,!1,V),W=!d.options.moving;for(const Z of a){const Y=t.getTile(Z),ie=Y.fbo;if(!ie)continue;const H=T.getMeshFromTileID(E,Z.canonical,_,!0,"raster"),ee=(b=d.style.map.terrain)===null||b===void 0?void 0:b.getTerrainData(Z);E.activeTexture.set(k.TEXTURE0),k.bindTexture(k.TEXTURE_2D,ie.colorAttachment.get());const se=I.getProjectionData({overscaledTileID:Z,aligned:W,applyGlobeMatrix:!x,applyTerrainMatrix:!0});q.draw(E,k.TRIANGLES,p,l[Z.overscaledZ],m,Ft.backCCW,Ka(d,Y,n),ee,se,n.id,H.vertexBuffer,H.indexBuffer,H.segments)}}function ha(d,t,n,a,l,p,m,_,x){var b;const T=d.style.projection,E=d.context,I=d.transform,k=E.gl,V=d.useProgram("colorRelief"),q=!d.options.moving;let W=!0,Z=0;for(const Y of a){const ie=t.getTile(Y),H=ie.dem;if(W){const _e=k.getParameter(k.MAX_TEXTURE_SIZE),{elevationTexture:xe,colorTexture:ve}=n.getColorRampTextures(E,_e,H.getUnpackVector());E.activeTexture.set(k.TEXTURE1),xe.bind(k.NEAREST,k.CLAMP_TO_EDGE),E.activeTexture.set(k.TEXTURE4),ve.bind(k.LINEAR,k.CLAMP_TO_EDGE),W=!1,Z=xe.size[0]}if(!H||!H.data)continue;const ee=H.stride,se=H.getPixels();if(E.activeTexture.set(k.TEXTURE0),E.pixelStoreUnpackPremultiplyAlpha.set(!1),ie.demTexture=ie.demTexture||d.getTileTexture(ee),ie.demTexture){const _e=ie.demTexture;_e.update(se,{premultiply:!1}),_e.bind(k.LINEAR,k.CLAMP_TO_EDGE)}else ie.demTexture=new c.T(E,se,k.RGBA,{premultiply:!1}),ie.demTexture.bind(k.LINEAR,k.CLAMP_TO_EDGE);const J=T.getMeshFromTileID(E,Y.canonical,_,!0,"raster"),oe=(b=d.style.map.terrain)===null||b===void 0?void 0:b.getTerrainData(Y),Te=I.getProjectionData({overscaledTileID:Y,aligned:q,applyGlobeMatrix:!x,applyTerrainMatrix:!0});V.draw(E,k.TRIANGLES,p,l[Y.overscaledZ],m,Ft.backCCW,Vc(n,ie.dem,Z),oe,Te,n.id,J.vertexBuffer,J.indexBuffer,J.segments)}}const Yn=[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 Cs(d,t,n,a,l,p,m,_,x=!1,b=!1){const T=a[a.length-1].overscaledZ,E=d.context,I=E.gl,k=d.useProgram("raster"),V=d.transform,q=d.style.projection,W=d.colorModeForRenderPass(),Z=!d.options.moving,Y=n.paint.get("raster-opacity"),ie=n.paint.get("raster-resampling"),H=n.paint.get("raster-fade-duration"),ee=!!d.style.map.terrain;for(const se of a){const J=d.getDepthModeForSublayer(se.overscaledZ-T,Y===1?wt.ReadWrite:wt.ReadOnly,I.LESS),oe=t.getTile(se),Te=ie==="nearest"?I.NEAREST:I.LINEAR;E.activeTexture.set(I.TEXTURE0),oe.texture.bind(Te,I.CLAMP_TO_EDGE,I.LINEAR_MIPMAP_NEAREST),E.activeTexture.set(I.TEXTURE1);const{parentTile:_e,parentScaleBy:xe,parentTopLeft:ve,fadeValues:Fe}=tu(oe,t,H,ee);oe.fadeOpacity=Fe.tileOpacity,_e?(_e.fadeOpacity=Fe.parentTileOpacity,_e.texture.bind(Te,I.CLAMP_TO_EDGE,I.LINEAR_MIPMAP_NEAREST)):oe.texture.bind(Te,I.CLAMP_TO_EDGE,I.LINEAR_MIPMAP_NEAREST),oe.texture.useMipmap&&E.extTextureFilterAnisotropic&&d.transform.pitch>20&&I.texParameterf(I.TEXTURE_2D,E.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,E.extTextureFilterAnisotropicMax);const Le=d.style.map.terrain&&d.style.map.terrain.getTerrainData(se),Ae=V.getProjectionData({overscaledTileID:se,aligned:Z,applyGlobeMatrix:!b,applyTerrainMatrix:!0}),Ue=ml(ve,xe,Fe.fadeMix,n,_),gt=q.getMeshFromTileID(E,se.canonical,p,m,"raster");k.draw(E,I.TRIANGLES,J,l?l[se.overscaledZ]:Bt.disabled,W,x?Ft.frontCCW:Ft.backCCW,Ue,Le,Ae,n.id,gt.vertexBuffer,gt.indexBuffer,gt.segments)}}function tu(d,t,n,a){const l={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(n===0||a)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],x=(function(b,T,E){const I=Je(),k=(I-T.timeAdded)/E,V=b.fadingDirection===we.Incoming,q=c.an((I-b.timeAdded)/E,0,1),W=c.an(1-k,0,1),Z=V?q:W;return{tileOpacity:Z,parentTileOpacity:V?W:q,fadeMix:{opacity:1,mix:1-Z}}})(d,p,n);return{parentTile:p,parentScaleBy:m,parentTopLeft:_,fadeValues:x}}if(d.selfFading){const p=(function(m,_){const x=(Je()-m.timeAdded)/_,b=c.an(x,0,1);return{tileOpacity:b,fadeMix:{opacity:b,mix:0}}})(d,n);return{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:p}}return l}const iu=new c.bp(1,0,0,1),ru=new c.bp(0,1,0,1),nu=new c.bp(0,0,1,1),su=new c.bp(1,0,1,1),En=new c.bp(0,1,1,1);function Ml(d,t,n,a){da(d,0,t+n/2,d.transform.width,n,a)}function Il(d,t,n,a){da(d,t-n/2,0,n,d.transform.height,a)}function da(d,t,n,a,l,p){const m=d.context,_=m.gl;_.enable(_.SCISSOR_TEST),_.scissor(t*d.pixelRatio,n*d.pixelRatio,a*d.pixelRatio,l*d.pixelRatio),m.clear({color:p}),_.disable(_.SCISSOR_TEST)}function au(d,t,n){const a=d.context,l=a.gl,p=d.useProgram("debug"),m=wt.disabled,_=Bt.disabled,x=d.colorModeForRenderPass(),b="$debug",T=d.style.map.terrain&&d.style.map.terrain.getTerrainData(n);a.activeTexture.set(l.TEXTURE0);const E=t.getTileByID(n.key).latestRawTileData,I=Math.floor((E&&E.byteLength||0)/1024),k=t.getTile(n).tileSize,V=512/Math.min(k,512)*(n.overscaledZ/d.transform.zoom)*.5;let q=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(q+=` => ${n.overscaledZ}`),(function(Z,Y){Z.initDebugOverlayCanvas();const ie=Z.debugOverlayCanvas,H=Z.context.gl,ee=Z.debugOverlayCanvas.getContext("2d");ee.clearRect(0,0,ie.width,ie.height),ee.shadowColor="white",ee.shadowBlur=2,ee.lineWidth=1.5,ee.strokeStyle="white",ee.textBaseline="top",ee.font="bold 36px Open Sans, sans-serif",ee.fillText(Y,5,5),ee.strokeText(Y,5,5),Z.debugOverlayTexture.update(ie),Z.debugOverlayTexture.bind(H.LINEAR,H.CLAMP_TO_EDGE)})(d,`${q} ${I}kB`);const W=d.transform.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!0,applyTerrainMatrix:!0});p.draw(a,l.TRIANGLES,m,_,oi.alphaBlended,Ft.disabled,pl(c.bp.transparent,V),null,W,b,d.debugBuffer,d.quadTriangleIndexBuffer,d.debugSegments),p.draw(a,l.LINE_STRIP,m,_,x,Ft.disabled,pl(c.bp.red),T,W,b,d.debugBuffer,d.tileBorderIndexBuffer,d.debugSegments)}function El(d,t,n,a){const{isRenderingGlobe:l}=a,p=d.context,m=p.gl,_=d.transform,x=d.colorModeForRenderPass(),b=d.getDepthModeFor3D(),T=d.useProgram("terrain");p.bindFramebuffer.set(null),p.viewport.set([0,0,d.width,d.height]);for(const E of n){const I=t.getTerrainMesh(E.tileID),k=d.renderToTexture.getTexture(E),V=t.getTerrainData(E.tileID);p.activeTexture.set(m.TEXTURE0),m.bindTexture(m.TEXTURE_2D,k.texture);const q=t.getMeshFrameDelta(_.zoom),W=_.calculateFogMatrix(E.tileID.toUnwrapped()),Z=hh(q,W,d.style.sky,_.pitch,l),Y=_.getProjectionData({overscaledTileID:E.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});T.draw(p,m.TRIANGLES,b,Bt.disabled,x,Ft.backCCW,Z,V,Y,"terrain",I.vertexBuffer,I.indexBuffer,I.segments)}}function Cl(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 a=new c.aY;a.emplaceBack(0,1,2),a.emplaceBack(0,2,3),t.mesh=new ai(d.createVertexBuffer(n,Tn.members),d.createIndexBuffer(a),c.aX.simpleSegment(0,0,n.length,a.length))}return t.mesh}class ou{constructor(t,n){this.context=new uo(t),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:c.ar(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Vr.maxOverzooming+Vr.maxUnderzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Pr}resize(t,n,a){if(this.width=Math.floor(t*a),this.height=Math.floor(n*a),this.pixelRatio=a,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,Tn.members),this.tileExtentSegments=c.aX.simpleSegment(0,0,4,2);const a=new c.aW;a.emplaceBack(0,0),a.emplaceBack(c.a5,0),a.emplaceBack(0,c.a5),a.emplaceBack(c.a5,c.a5),this.debugBuffer=t.createVertexBuffer(a,Tn.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,uh.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,Tn.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,Tn.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 x=new c.aY;x.emplaceBack(1,0,2),x.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(x);const b=this.context.gl;this.stencilClearMode=new Bt({func:b.ALWAYS,mask:0},0,255,b.ZERO,b.ZERO,b.ZERO),this.tileExtentMesh=new ai(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const t=this.context,n=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const a=c.N();c.c7(a,0,this.width,this.height,0,0,1),c.Q(a,a,[n.drawingBufferWidth,n.drawingBufferHeight,0]);const l={mainMatrix:a,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:a};this.useProgram("clippingMask",null,!0).draw(t,n.TRIANGLES,wt.disabled,this.stencilClearMode,oi.disabled,Ft.disabled,null,null,l,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,n,a){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(oi.disabled),l.setDepthMode(wt.disabled);const p={};for(const m of n)p[m.key]=this.nextStencilID++;this._renderTileMasks(p,n,a,!0),this._renderTileMasks(p,n,a,!1),this._tileClippingMaskIDs=p}_renderTileMasks(t,n,a,l){const p=this.context,m=p.gl,_=this.style.projection,x=this.transform,b=this.useProgram("clippingMask");for(const T of n){const E=t[T.key],I=this.style.map.terrain&&this.style.map.terrain.getTerrainData(T),k=_.getMeshFromTileID(this.context,T.canonical,l,!0,"stencil"),V=x.getProjectionData({overscaledTileID:T,applyGlobeMatrix:!a,applyTerrainMatrix:!0});b.draw(p,m.TRIANGLES,wt.disabled,new Bt({func:m.ALWAYS,mask:0},E,255,m.KEEP,m.KEEP,m.REPLACE),oi.disabled,a?Ft.disabled:Ft.backCCW,null,I,V,"$clipping",k.vertexBuffer,k.indexBuffer,k.segments)}}_renderTilesDepthBuffer(){const t=this.context,n=t.gl,a=this.style.projection,l=this.transform,p=this.useProgram("depth"),m=this.getDepthModeFor3D(),_=zi(l,{tileSize:l.tileSize});for(const x of _){const b=this.style.map.terrain&&this.style.map.terrain.getTerrainData(x),T=a.getMeshFromTileID(this.context,x.canonical,!0,!0,"raster"),E=l.getProjectionData({overscaledTileID:x,applyGlobeMatrix:!0,applyTerrainMatrix:!0});p.draw(t,n.TRIANGLES,m,Bt.disabled,oi.disabled,Ft.backCCW,null,b,E,"$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 Bt({func:n.NOTEQUAL,mask:255},t,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(t){const n=this.context.gl;return new Bt({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,n.KEEP,n.KEEP,n.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(t){const n=this.context.gl,a=t.sort(((m,_)=>_.overscaledZ-m.overscaledZ)),l=a[a.length-1].overscaledZ,p=a[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 Bt({func:n.GEQUAL,mask:255},_+this.nextStencilID,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID+=p,[m,a]}return[{[l]:Bt.disabled},a]}stencilConfigForOverlapTwoPass(t){const n=this.context.gl,a=t.sort(((m,_)=>_.overscaledZ-m.overscaledZ)),l=a[a.length-1].overscaledZ,p=a[0].overscaledZ-l+1;if(this.clearStencil(),p>1){const m={},_={};for(let x=0;x<p;x++)m[x+l]=new Bt({func:n.GREATER,mask:255},p+1+x,255,n.KEEP,n.KEEP,n.REPLACE),_[x+l]=new Bt({func:n.GREATER,mask:255},1+x,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID=2*p+1,[m,_,a]}return this.nextStencilID=3,[{[l]:new Bt({func:n.GREATER,mask:255},2,255,n.KEEP,n.KEEP,n.REPLACE)},{[l]:new Bt({func:n.GREATER,mask:255},1,255,n.KEEP,n.KEEP,n.REPLACE)},a]}colorModeForRenderPass(){const t=this.context.gl;return this._showOverdrawInspector?new oi([t.CONSTANT_COLOR,t.ONE],new c.bp(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?oi.unblended:oi.alphaBlended}getDepthModeForSublayer(t,n,a){if(!this.opaquePassEnabledForLayer())return wt.disabled;const l=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new wt(a||this.context.gl.LEQUAL,n,[l,l])}getDepthModeFor3D(){return new wt(this.context.gl.LEQUAL,wt.ReadWrite,this.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,n){var a,l;this.style=t,this.options=n,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(Je()),this.imageManager.beginFrame();const p=this.style._order,m=this.style.tileManagers,_={},x={},b={},T={isRenderingToTexture:!1,isRenderingGlobe:((a=t.projection)===null||a===void 0?void 0:a.transitionState)>0};for(const I in m){const k=m[I];k.used&&k.prepare(this.context),_[I]=k.getVisibleCoordinates(!1),x[I]=_[I].slice().reverse(),b[I]=k.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let I=0;I<p.length;I++)if(this.style._layers[p[I]].is3D()){this.opaquePassCutoff=I;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const I of p){const k=this.style._layers[I];if(!k.hasOffscreenPass()||k.isHidden(this.transform.zoom))continue;const V=x[k.source];(k.type==="custom"||V.length)&&this.renderLayer(this,m[k.source],k,V,T)}if((l=this.style.projection)===null||l===void 0||l.updateGPUdependent({context:this.context,useProgram:I=>this.useProgram(I)}),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(I,k){const V=I.context,q=V.gl,W=((se,J,oe)=>{const Te=Math.cos(J.rollInRadians),_e=Math.sin(J.rollInRadians),xe=ti(J),ve=J.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:se.properties.get("sky-color"),u_horizon_color:se.properties.get("horizon-color"),u_horizon:[(J.width/2-xe*_e)*oe,(J.height/2+xe*Te)*oe],u_horizon_normal:[-_e,Te],u_sky_horizon_blend:se.properties.get("sky-horizon-blend")*J.height/2*oe,u_sky_blend:ve}})(k,I.style.map.transform,I.pixelRatio),Z=new wt(q.LEQUAL,wt.ReadWrite,[0,1]),Y=Bt.disabled,ie=I.colorModeForRenderPass(),H=I.useProgram("sky"),ee=Cl(V,k);H.draw(V,q.TRIANGLES,Z,Y,ie,Ft.disabled,W,null,void 0,"sky",ee.vertexBuffer,ee.indexBuffer,ee.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 I=this.style._layers[p[this.currentLayer]],k=m[I.source],V=_[I.source];this._renderTileClippingMasks(I,V,!1),this.renderLayer(this,k,I,V,T)}this.renderPass="translucent";let E=!1;for(this.currentLayer=0;this.currentLayer<p.length;this.currentLayer++){const I=this.style._layers[p[this.currentLayer]],k=m[I.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(I,T))continue;this.opaquePassEnabledForLayer()||E||(E=!0,T.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());const V=(I.type==="symbol"?b:x)[I.source];this._renderTileClippingMasks(I,_[I.source],!!this.renderToTexture),this.renderLayer(this,k,I,V,T)}if(T.isRenderingGlobe&&(function(I,k,V){const q=I.context,W=q.gl,Z=I.useProgram("atmosphere"),Y=new wt(W.LEQUAL,wt.ReadOnly,[0,1]),ie=I.transform,H=(function(ve,Fe){const Le=ve.properties.get("position"),Ae=[-Le.x,-Le.y,-Le.z],Ue=c.ar(new Float64Array(16));return ve.properties.get("anchor")==="map"&&(c.bg(Ue,Ue,Fe.rollInRadians),c.bh(Ue,Ue,-Fe.pitchInRadians),c.bg(Ue,Ue,Fe.bearingInRadians),c.bh(Ue,Ue,Fe.center.lat*Math.PI/180),c.bJ(Ue,Ue,-Fe.center.lng*Math.PI/180)),c.cg(Ae,Ae,Ue),Ae})(V,I.transform),ee=ie.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),se=k.properties.get("atmosphere-blend")*ee.projectionTransition;if(se===0)return;const J=Un(ie.worldSize,ie.center.lat),oe=ie.inverseProjectionMatrix,Te=new Float64Array(4);Te[3]=1,c.aH(Te,Te,ie.modelViewProjectionMatrix),Te[0]/=Te[3],Te[1]/=Te[3],Te[2]/=Te[3],Te[3]=1,c.aH(Te,Te,oe),Te[0]/=Te[3],Te[1]/=Te[3],Te[2]/=Te[3],Te[3]=1;const _e=((ve,Fe,Le,Ae,Ue)=>({u_sun_pos:ve,u_atmosphere_blend:Fe,u_globe_position:Le,u_globe_radius:Ae,u_inv_proj_matrix:Ue}))(H,se,[Te[0],Te[1],Te[2]],J,oe),xe=Cl(q,k);Z.draw(q,W.TRIANGLES,Y,Bt.disabled,oi.alphaBlended,Ft.disabled,_e,null,null,"atmosphere",xe.vertexBuffer,xe.indexBuffer,xe.segments)})(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const I=(function(k,V){let q=null;const W=Object.values(k._layers).flatMap((H=>H.source&&!H.isHidden(V)?[k.tileManagers[H.source]]:[])),Z=W.filter((H=>H.getSource().type==="vector")),Y=W.filter((H=>H.getSource().type!=="vector")),ie=H=>{(!q||q.getSource().maxzoom<H.getSource().maxzoom)&&(q=H)};return Z.forEach((H=>ie(H))),q||Y.forEach((H=>ie(H))),q})(this.style,this.transform.zoom);I&&(function(k,V,q){for(let W=0;W<q.length;W++)au(k,V,q[W])})(this,I,I.getVisibleCoordinates())}this.options.showPadding&&(function(I){const k=I.transform.padding;Ml(I,I.transform.height-(k.top||0),3,iu),Ml(I,k.bottom||0,3,ru),Il(I,k.left||0,3,nu),Il(I,I.transform.width-(k.right||0),3,su);const V=I.transform.centerPoint;(function(q,W,Z,Y){da(q,W-1,Z-10,2,20,Y),da(q,W-10,Z-1,20,2,Y)})(I,V.x,I.transform.height-V.y,En)})(this),this.context.setDefault()}maybeDrawDepthAndCoords(t){if(!this.style||!this.style.map||!this.style.map.terrain)return;const n=this.terrainFacilitator.matrix,a=this.transform.modelViewProjectionMatrix;let l=this.terrainFacilitator.dirty;l||(l=t?!c.cj(n,a):!c.ck(n,a)),l||(l=this.style.map.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime)),l&&(c.cl(n,a),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,(function(p,m){const _=p.context,x=_.gl,b=p.transform,T=oi.unblended,E=new wt(x.LEQUAL,wt.ReadWrite,[0,1]),I=m.tileManager.getRenderableTiles(),k=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 V of I){const q=m.getTerrainMesh(V.tileID),W=m.getTerrainData(V.tileID),Z=b.getProjectionData({overscaledTileID:V.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),Y={u_ele_delta:m.getMeshFrameDelta(b.zoom)};k.draw(_,x.TRIANGLES,E,Bt.disabled,T,Ft.backCCW,Y,W,Z,"terrain",q.vertexBuffer,q.indexBuffer,q.segments)}_.bindFramebuffer.set(null),_.viewport.set([0,0,p.width,p.height])})(this,this.style.map.terrain),(function(p,m){const _=p.context,x=_.gl,b=p.transform,T=oi.unblended,E=new wt(x.LEQUAL,wt.ReadWrite,[0,1]),I=m.getCoordsTexture(),k=m.tileManager.getRenderableTiles(),V=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 q of k){const W=m.getTerrainMesh(q.tileID),Z=m.getTerrainData(q.tileID);_.activeTexture.set(x.TEXTURE0),x.bindTexture(x.TEXTURE_2D,I.texture);const Y={u_terrain_coords_id:(255-m.coordsIndex.length)/255,u_texture:0,u_ele_delta:m.getMeshFrameDelta(b.zoom)},ie=b.getProjectionData({overscaledTileID:q.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});V.draw(_,x.TRIANGLES,E,Bt.disabled,T,Ft.backCCW,Y,Z,ie,"terrain",W.vertexBuffer,W.indexBuffer,W.segments),m.coordsIndex.push(q.tileID.key)}_.bindFramebuffer.set(null),_.viewport.set([0,0,p.width,p.height])})(this,this.style.map.terrain))}renderLayer(t,n,a,l,p){a.isHidden(this.transform.zoom)||(a.type==="background"||a.type==="custom"||(l||[]).length)&&(this.id=a.id,c.cm(a)?(function(m,_,x,b,T,E){if(m.renderPass!=="translucent")return;const{isRenderingToTexture:I}=E,k=Bt.disabled,V=m.colorModeForRenderPass();(x._unevaluatedLayout.hasValue("text-variable-anchor")||x._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&(function(q,W,Z,Y,ie,H,ee,se,J){const oe=W.transform,Te=W.style.map.terrain,_e=ie==="map",xe=H==="map";for(const ve of q){const Fe=Y.getTile(ve),Le=Fe.getBucket(Z);if(!Le||!Le.text||!Le.text.segments.get().length)continue;const Ae=c.ay(Le.textSizeData,oe.zoom),Ue=c.aN(Fe,1,W.transform.zoom),gt=Dr(_e,W.transform,Ue),Ht=Z.layout.get("icon-text-fit")!=="none"&&Le.hasIconData();if(Ae){const _i=Math.pow(2,oe.zoom-Fe.tileID.overscaledZ),li=Te?(wi,ci)=>Te.getElevation(ve,wi,ci):null;Th(Le,_e,xe,J,oe,gt,_i,Ae,Ht,c.aO(oe,Fe,ee,se),ve.toUnwrapped(),li)}}})(b,m,x,_,x.layout.get("text-rotation-alignment"),x.layout.get("text-pitch-alignment"),x.paint.get("text-translate"),x.paint.get("text-translate-anchor"),T),x.paint.get("icon-opacity").constantOr(1)!==0&&la(m,_,x,b,!1,x.paint.get("icon-translate"),x.paint.get("icon-translate-anchor"),x.layout.get("icon-rotation-alignment"),x.layout.get("icon-pitch-alignment"),x.layout.get("icon-keep-upright"),k,V,I),x.paint.get("text-opacity").constantOr(1)!==0&&la(m,_,x,b,!0,x.paint.get("text-translate"),x.paint.get("text-translate-anchor"),x.layout.get("text-rotation-alignment"),x.layout.get("text-pitch-alignment"),x.layout.get("text-keep-upright"),k,V,I),_.map.showCollisionBoxes&&(Hn(m,_,x,b,!0),Hn(m,_,x,b,!1))})(t,n,a,l,this.style.placement.variableOffsets,p):c.cn(a)?(function(m,_,x,b,T){if(m.renderPass!=="translucent")return;const{isRenderingToTexture:E}=T,I=x.paint.get("circle-opacity"),k=x.paint.get("circle-stroke-width"),V=x.paint.get("circle-stroke-opacity"),q=!x.layout.get("circle-sort-key").isConstant();if(I.constantOr(1)===0&&(k.constantOr(1)===0||V.constantOr(1)===0))return;const W=m.context,Z=W.gl,Y=m.transform,ie=m.getDepthModeForSublayer(0,wt.ReadOnly),H=Bt.disabled,ee=m.colorModeForRenderPass(),se=[],J=Y.getCircleRadiusCorrection();for(let oe=0;oe<b.length;oe++){const Te=b[oe],_e=_.getTile(Te),xe=_e.getBucket(x);if(!xe)continue;const ve=x.paint.get("circle-translate"),Fe=x.paint.get("circle-translate-anchor"),Le=c.aO(Y,_e,ve,Fe),Ae=xe.programConfigurations.get(x.id),Ue=m.useProgram("circle",Ae),gt=xe.layoutVertexBuffer,Ht=xe.indexBuffer,_i=m.style.map.terrain&&m.style.map.terrain.getTerrainData(Te),li={programConfiguration:Ae,program:Ue,layoutVertexBuffer:gt,indexBuffer:Ht,uniformValues:Lc(m,_e,x,Le,J),terrainData:_i,projectionData:Y.getProjectionData({overscaledTileID:Te,applyGlobeMatrix:!E,applyTerrainMatrix:!0})};if(q){const wi=xe.segments.get();for(const ci of wi)se.push({segments:new c.aX([ci]),sortKey:ci.sortKey,state:li})}else se.push({segments:xe.segments,sortKey:0,state:li})}q&&se.sort(((oe,Te)=>oe.sortKey-Te.sortKey));for(const oe of se){const{programConfiguration:Te,program:_e,layoutVertexBuffer:xe,indexBuffer:ve,uniformValues:Fe,terrainData:Le,projectionData:Ae}=oe.state;_e.draw(W,Z.TRIANGLES,ie,H,ee,Ft.backCCW,Fe,Le,Ae,x.id,xe,ve,oe.segments,x.paint,m.transform.zoom,Te)}})(t,n,a,l,p):c.co(a)?(function(m,_,x,b,T){if(x.paint.get("heatmap-opacity")===0)return;const E=m.context,{isRenderingToTexture:I,isRenderingGlobe:k}=T;if(m.style.map.terrain){for(const V of b){const q=_.getTile(V);_.hasRenderableParent(V)||(m.renderPass==="offscreen"?Kc(m,q,x,V,k):m.renderPass==="translucent"&&Jc(m,x,V,I,k))}E.viewport.set([0,0,m.width,m.height])}else m.renderPass==="offscreen"?(function(V,q,W,Z){const Y=V.context,ie=Y.gl,H=V.transform,ee=Bt.disabled,se=new oi([ie.ONE,ie.ONE],c.bp.transparent,[!0,!0,!0,!0]);(function(J,oe,Te){const _e=J.gl;J.activeTexture.set(_e.TEXTURE1),J.viewport.set([0,0,oe.width/4,oe.height/4]);let xe=Te.heatmapFbos.get(c.cd);xe?(_e.bindTexture(_e.TEXTURE_2D,xe.colorAttachment.get()),J.bindFramebuffer.set(xe.framebuffer)):(xe=ca(J,oe.width/4,oe.height/4),Te.heatmapFbos.set(c.cd,xe))})(Y,V,W),Y.clear({color:c.bp.transparent});for(let J=0;J<Z.length;J++){const oe=Z[J];if(q.hasRenderableParent(oe))continue;const Te=q.getTile(oe),_e=Te.getBucket(W);if(!_e)continue;const xe=_e.programConfigurations.get(W.id),ve=V.useProgram("heatmap",xe),Fe=H.getProjectionData({overscaledTileID:oe,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),Le=H.getCircleRadiusCorrection();ve.draw(Y,ie.TRIANGLES,wt.disabled,ee,se,Ft.backCCW,Ss(Te,H.zoom,W.paint.get("heatmap-intensity"),Le),null,Fe,W.id,_e.layoutVertexBuffer,_e.indexBuffer,_e.segments,W.paint,H.zoom,xe)}Y.viewport.set([0,0,V.width,V.height])})(m,_,x,b):m.renderPass==="translucent"&&(function(V,q){const W=V.context,Z=W.gl;W.setColorMode(V.colorModeForRenderPass());const Y=q.heatmapFbos.get(c.cd);Y&&(W.activeTexture.set(Z.TEXTURE0),Z.bindTexture(Z.TEXTURE_2D,Y.colorAttachment.get()),W.activeTexture.set(Z.TEXTURE1),po(W,q).bind(Z.LINEAR,Z.CLAMP_TO_EDGE),V.useProgram("heatmapTexture").draw(W,Z.TRIANGLES,wt.disabled,Bt.disabled,V.colorModeForRenderPass(),Ft.disabled,Oc(V,q,0,1),null,null,q.id,V.viewportBuffer,V.quadTriangleIndexBuffer,V.viewportSegments,q.paint,V.transform.zoom))})(m,x)})(t,n,a,l,p):c.cp(a)?(function(m,_,x,b,T){if(m.renderPass!=="translucent")return;const{isRenderingToTexture:E}=T,I=x.paint.get("line-opacity"),k=x.paint.get("line-width");if(I.constantOr(1)===0||k.constantOr(1)===0)return;const V=m.getDepthModeForSublayer(0,wt.ReadOnly),q=m.colorModeForRenderPass(),W=x.paint.get("line-dasharray"),Z=W.constantOr(1),Y=x.paint.get("line-pattern"),ie=Y.constantOr(1),H=x.paint.get("line-gradient"),ee=x.getCrossfadeParameters();let se;se=ie?"linePattern":Z&&H?"lineGradientSDF":Z?"lineSDF":H?"lineGradient":"line";const J=m.context,oe=J.gl,Te=m.transform;let _e=!0;for(const xe of b){const ve=_.getTile(xe);if(ie&&!ve.patternsLoaded())continue;const Fe=ve.getBucket(x);if(!Fe)continue;const Le=Fe.programConfigurations.get(x.id),Ae=m.context.program.get(),Ue=m.useProgram(se,Le),gt=_e||Ue.program!==Ae,Ht=m.style.map.terrain&&m.style.map.terrain.getTerrainData(xe),_i=Y.constantOr(null),li=W&&W.constantOr(null);if(_i&&ve.imageAtlas){const Qi=ve.imageAtlas,qi=Qi.patternPositions[_i.to.toString()],Ui=Qi.patternPositions[_i.from.toString()];qi&&Ui&&Le.setConstantPatternPositions(qi,Ui)}else if(li){const Qi=x.layout.get("line-cap")==="round",qi=m.lineAtlas.getDash(li.to,Qi),Ui=m.lineAtlas.getDash(li.from,Qi);Le.setConstantDashPositions(qi,Ui)}const wi=Te.getProjectionData({overscaledTileID:xe,applyGlobeMatrix:!E,applyTerrainMatrix:!0}),ci=Te.getPixelScale();let Fi;ie?(Fi=fl(m,ve,x,ci,ee),eu(J,oe,ve,Le,ee)):Z&&H?(Fi=Ja(m,ve,x,ci,ee,Fe.lineClipsArray.length),kr(m,_,J,oe,x,Fe,xe,Le,ee)):Z?(Fi=Nc(m,ve,x,ci,ee),ji(m,J,oe,Le,gt,ee)):H?(Fi=jc(m,ve,x,ci,Fe.lineClipsArray.length),Xn(m,_,J,oe,x,Fe,xe)):Fi=ia(m,ve,x,ci);const Ti=m.stencilModeForClipping(xe);Ue.draw(J,oe.TRIANGLES,V,Ti,q,Ft.disabled,Fi,Ht,wi,x.id,Fe.layoutVertexBuffer,Fe.indexBuffer,Fe.segments,x.paint,m.transform.zoom,Le,Fe.layoutVertexBuffer2),_e=!1}})(t,n,a,l,p):c.cq(a)?(function(m,_,x,b,T){const E=x.paint.get("fill-color"),I=x.paint.get("fill-opacity");if(I.constantOr(1)===0)return;const{isRenderingToTexture:k}=T,V=m.colorModeForRenderPass(),q=x.paint.get("fill-pattern"),W=m.opaquePassEnabledForLayer()&&!q.constantOr(1)&&E.constantOr(c.bp.transparent).a===1&&I.constantOr(0)===1?"opaque":"translucent";if(m.renderPass===W){const Z=m.getDepthModeForSublayer(1,m.renderPass==="opaque"?wt.ReadWrite:wt.ReadOnly);ua(m,_,x,b,Z,V,!1,k)}if(m.renderPass==="translucent"&&x.paint.get("fill-antialias")){const Z=m.getDepthModeForSublayer(x.getPaintProperty("fill-outline-color")?2:0,wt.ReadOnly);ua(m,_,x,b,Z,V,!0,k)}})(t,n,a,l,p):c.cr(a)?(function(m,_,x,b,T){const E=x.paint.get("fill-extrusion-opacity");if(E===0)return;const{isRenderingToTexture:I}=T;if(m.renderPass==="translucent"){const k=new wt(m.context.gl.LEQUAL,wt.ReadWrite,m.depthRangeFor3D);if(E!==1||x.paint.get("fill-extrusion-pattern").constantOr(1))mo(m,_,x,b,k,Bt.disabled,oi.disabled,I),mo(m,_,x,b,k,m.stencilModeFor3D(),m.colorModeForRenderPass(),I);else{const V=m.colorModeForRenderPass();mo(m,_,x,b,k,Bt.disabled,V,I)}}})(t,n,a,l,p):c.cs(a)?(function(m,_,x,b,T){if(m.renderPass!=="offscreen"&&m.renderPass!=="translucent")return;const{isRenderingToTexture:E}=T,I=m.context,k=m.style.projection.useSubdivision,V=m.getDepthModeForSublayer(0,wt.ReadOnly),q=m.colorModeForRenderPass();if(m.renderPass==="offscreen")(function(W,Z,Y,ie,H,ee,se){const J=W.context,oe=J.gl;for(const Te of Y){const _e=Z.getTile(Te),xe=_e.dem;if(!xe||!xe.data||!_e.needsHillshadePrepare)continue;const ve=xe.dim,Fe=xe.stride,Le=xe.getPixels();if(J.activeTexture.set(oe.TEXTURE1),J.pixelStoreUnpackPremultiplyAlpha.set(!1),_e.demTexture=_e.demTexture||W.getTileTexture(Fe),_e.demTexture){const Ue=_e.demTexture;Ue.update(Le,{premultiply:!1}),Ue.bind(oe.NEAREST,oe.CLAMP_TO_EDGE)}else _e.demTexture=new c.T(J,Le,oe.RGBA,{premultiply:!1}),_e.demTexture.bind(oe.NEAREST,oe.CLAMP_TO_EDGE);J.activeTexture.set(oe.TEXTURE0);let Ae=_e.fbo;if(!Ae){const Ue=new c.T(J,{width:ve,height:ve,data:null},oe.RGBA);Ue.bind(oe.LINEAR,oe.CLAMP_TO_EDGE),Ae=_e.fbo=J.createFramebuffer(ve,ve,!0,!1),Ae.colorAttachment.set(Ue.texture)}J.bindFramebuffer.set(Ae.framebuffer),J.viewport.set([0,0,ve,ve]),W.useProgram("hillshadePrepare").draw(J,oe.TRIANGLES,H,ee,se,Ft.disabled,dh(_e.tileID,xe),null,null,ie.id,W.rasterBoundsBuffer,W.quadTriangleIndexBuffer,W.rasterBoundsSegments),_e.needsHillshadePrepare=!1}})(m,_,b,x,V,Bt.disabled,q),I.viewport.set([0,0,m.width,m.height]);else if(m.renderPass==="translucent")if(k){const[W,Z,Y]=m.stencilConfigForOverlapTwoPass(b);In(m,_,x,Y,W,V,q,!1,E),In(m,_,x,Y,Z,V,q,!0,E)}else{const[W,Z]=m.getStencilConfigForOverlapAndUpdateStencilID(b);In(m,_,x,Z,W,V,q,!1,E)}})(t,n,a,l,p):c.ct(a)?(function(m,_,x,b,T){if(m.renderPass!=="translucent"||!b.length)return;const{isRenderingToTexture:E}=T,I=m.style.projection.useSubdivision,k=m.getDepthModeForSublayer(0,wt.ReadOnly),V=m.colorModeForRenderPass();if(I){const[q,W,Z]=m.stencilConfigForOverlapTwoPass(b);ha(m,_,x,Z,q,k,V,!1,E),ha(m,_,x,Z,W,k,V,!0,E)}else{const[q,W]=m.getStencilConfigForOverlapAndUpdateStencilID(b);ha(m,_,x,W,q,k,V,!1,E)}})(t,n,a,l,p):c.bU(a)?(function(m,_,x,b,T){if(m.renderPass!=="translucent"||x.paint.get("raster-opacity")===0||!b.length)return;const{isRenderingToTexture:E}=T,I=_.getSource(),k=m.style.projection.useSubdivision;if(I instanceof vi)Cs(m,_,x,b,null,!1,!1,I.tileCoords,I.flippedWindingOrder,E);else if(k){const[V,q,W]=m.stencilConfigForOverlapTwoPass(b);Cs(m,_,x,W,V,!1,!0,Yn,!1,E),Cs(m,_,x,W,q,!0,!0,Yn,!1,E)}else{const[V,q]=m.getStencilConfigForOverlapAndUpdateStencilID(b);Cs(m,_,x,q,V,!1,!0,Yn,!1,E)}})(t,n,a,l,p):c.cu(a)?(function(m,_,x,b,T){const E=x.paint.get("background-color"),I=x.paint.get("background-opacity");if(I===0)return;const{isRenderingToTexture:k}=T,V=m.context,q=V.gl,W=m.style.projection,Z=m.transform,Y=Z.tileSize,ie=x.paint.get("background-pattern");if(m.isPatternMissing(ie))return;const H=!ie&&E.a===1&&I===1&&m.opaquePassEnabledForLayer()?"opaque":"translucent";if(m.renderPass!==H)return;const ee=Bt.disabled,se=m.getDepthModeForSublayer(0,H==="opaque"?wt.ReadWrite:wt.ReadOnly),J=m.colorModeForRenderPass(),oe=m.useProgram(ie?"backgroundPattern":"background"),Te=b||zi(Z,{tileSize:Y,terrain:m.style.map.terrain});ie&&(V.activeTexture.set(q.TEXTURE0),m.imageManager.bind(m.context));const _e=x.getCrossfadeParameters();for(const xe of Te){const ve=Z.getProjectionData({overscaledTileID:xe,applyGlobeMatrix:!k,applyTerrainMatrix:!0}),Fe=ie?fh(I,m,ie,{tileID:xe,tileSize:Y},_e):yl(I,E),Le=m.style.map.terrain&&m.style.map.terrain.getTerrainData(xe),Ae=W.getMeshFromTileID(V,xe.canonical,!1,!0,"raster");oe.draw(V,q.TRIANGLES,se,ee,J,Ft.backCCW,Fe,Le,ve,x.id,Ae.vertexBuffer,Ae.indexBuffer,Ae.segments)}})(t,0,a,l,p):c.cv(a)&&(function(m,_,x,b){const{isRenderingGlobe:T}=b,E=m.context,I=x.implementation,k=m.style.projection,V=m.transform,q=V.getProjectionDataForCustomLayer(T),W={farZ:V.farZ,nearZ:V.nearZ,fov:V.fov*Math.PI/180,modelViewProjectionMatrix:V.modelViewProjectionMatrix,projectionMatrix:V.projectionMatrix,shaderData:{variantName:k.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;
807
+ uniform mat4 u_projection_matrix;
808
+ ${k.shaderPreludeCode.vertexSource}`,define:k.shaderDefine},defaultProjectionData:q},Z=I.renderingMode?I.renderingMode:"2d";if(m.renderPass==="offscreen"){const Y=I.prerender;Y&&(m.setCustomLayerDefaults(),E.setColorMode(m.colorModeForRenderPass()),Y.call(I,E.gl,W),E.setDirty(),m.setBaseState())}else if(m.renderPass==="translucent"){m.setCustomLayerDefaults(),E.setColorMode(m.colorModeForRenderPass()),E.setStencilMode(Bt.disabled);const Y=Z==="3d"?m.getDepthModeFor3D():m.getDepthModeForSublayer(0,wt.ReadOnly);E.setDepthMode(Y),I.render(E.gl,W),E.setDirty(),m.setBaseState(),E.bindFramebuffer.set(null)}})(t,0,a,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()),a=this.imageManager.getPattern(t.to.toString());return!n||!a}useProgram(t,n,a=!1,l=[]){this.cache=this.cache||{};const p=!!this.style.map.terrain,m=this.style.projection,_=a?Ii.projectionMercator:m.shaderPreludeCode,x=a?vr:m.shaderDefine,b=t+(n?n.cacheKey:"")+`/${a?zr:m.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(p?"/terrain":"")+(l?`/${l.join("/")}`:"");return this.cache[b]||(this.cache[b]=new zc(this.context,Ii[t],n,mh[t],this._showOverdrawInspector,p,_,x,l)),this.cache[b]}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 a in this._tileTextures){const l=this._tileTextures[a];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 a in this.cache){const l=this.cache[a];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 Al(d,t){let n,a=!1,l=null,p=null;const m=()=>{l=null,a&&(d.apply(p,n),l=setTimeout(m,t),a=!1)};return(..._)=>(a=!0,p=this,n=_,l||m(),l)}class Dl{constructor(t){this._getCurrentHash=()=>{const n=window.location.hash.replace("#","");if(this._hashName){let a;return n.split("&").map((l=>l.split("="))).forEach((l=>{l[0]===this._hashName&&(a=l)})),(a&&a[1]||"").split("/")}return n.split("/")},this._onHashChange=()=>{const n=this._getCurrentHash();if(!this._isValidHash(n))return!1;const a=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:a,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 a=n.join("/");let l=a;l.split("&").length>0&&(l=l.split("&")[0]),this._hashName&&(l=`${this._hashName}=${a}`);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=Al(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(),a=Math.round(100*this._map.getZoom())/100,l=Math.ceil((a*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,x=this._map.getBearing(),b=this._map.getPitch();let T="";if(T+=t?`/${m}/${_}/${a}`:`${a}/${_}/${m}`,(x||b)&&(T+="/"+Math.round(10*x)/10),b&&(T+=`/${Math.round(b)}`),this._hashName){const E=this._hashName;let I=!1;const k=window.location.hash.slice(1).split("&").map((V=>{const q=V.split("=")[0];return q===E?(I=!0,`${q}=${T}`):V})).filter((V=>V));return I||k.push(`${E}=${T}`),`#${k.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],a=+(t[3]||0),l=+(t[4]||0);return n>=this._map.getMinZoom()&&n<=this._map.getMaxZoom()&&a>=-180&&a<=180&&l>=this._map.getMinPitch()&&l<=this._map.getMaxPitch()}}const Cn={linearity:.3,easing:c.cw(0,0,.3,1)},lu=c.e({deceleration:2500,maxSpeed:1400},Cn),Ur=c.e({deceleration:20,maxSpeed:1400},Cn),Yr=c.e({deceleration:1e3,maxSpeed:360},Cn),cu=c.e({deceleration:1e3,maxSpeed:90},Cn),Kr=c.e({deceleration:1e3,maxSpeed:360},Cn);class Sh{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:Je(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,n=Je();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 a=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,l={};if(n.pan.mag()){const p=fa(n.pan.mag(),a,c.e({},lu,t||{})),m=n.pan.mult(p.amount/n.pan.mag()),_=this._map.cameraHelper.handlePanInertia(m,this._map.transform);l.center=_.easingCenter,l.offset=_.easingOffset,pa(l,p)}if(n.zoom){const p=fa(n.zoom,a,Ur);l.zoom=this._map.transform.zoom+p.amount,pa(l,p)}if(n.bearing){const p=fa(n.bearing,a,Yr);l.bearing=this._map.transform.bearing+c.an(p.amount,-179,179),pa(l,p)}if(n.pitch){const p=fa(n.pitch,a,cu);l.pitch=this._map.transform.pitch+p.amount,pa(l,p)}if(n.roll){const p=fa(n.roll,a,Kr);l.roll=this._map.transform.roll+c.an(p.amount,-179,179),pa(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 pa(d,t){(!d.duration||d.duration<t.duration)&&(d.duration=t.duration,d.easing=t.easing)}function fa(d,t,n){const{maxSpeed:a,linearity:l,deceleration:p}=n,m=c.an(d*l/(t/1e3),-a,a),_=Math.abs(m)/(p*l);return{easing:n.easing,duration:1e3*_,amount:m*(_/2)}}class Ji extends c.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,a,l={}){a=a instanceof MouseEvent?a:new MouseEvent(t,a);const p=ge.mousePos(n.getCanvas(),a),m=n.unproject(p);super(t,c.e({point:p,lngLat:m,originalEvent:a},l)),this._defaultPrevented=!1,this.target=n}}class ma extends c.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,a){const l=t==="touchend"?a.changedTouches:a.touches,p=ge.touchPos(n.getCanvasContainer(),l),m=p.map((x=>n.unproject(x))),_=p.reduce(((x,b,T,E)=>x.add(b.div(E.length))),new c.P(0,0));super(t,{points:p,point:_,lngLats:m,lngLat:n.unproject(_),originalEvent:a}),this._defaultPrevented=!1}}class uu extends c.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,a){super(t,{originalEvent:a}),this._defaultPrevented=!1}}class Ph{constructor(t,n){this._map=t,this._clickTolerance=n.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new uu(t.type,this._map,t))}mousedown(t,n){return this._mousedownPos=n,this._firePreventable(new Ji(t.type,this._map,t))}mouseup(t){this._map.fire(new Ji(t.type,this._map,t))}click(t,n){this._mousedownPos&&this._mousedownPos.dist(n)>=this._clickTolerance||this._map.fire(new Ji(t.type,this._map,t))}dblclick(t){return this._firePreventable(new Ji(t.type,this._map,t))}mouseover(t){this._map.fire(new Ji(t.type,this._map,t))}mouseout(t){this._map.fire(new Ji(t.type,this._map,t))}touchstart(t){return this._firePreventable(new ma(t.type,this._map,t))}touchmove(t){this._map.fire(new ma(t.type,this._map,t))}touchend(t){this._map.fire(new ma(t.type,this._map,t))}touchcancel(t){this._map.fire(new ma(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Mh{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new Ji(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Ji("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new Ji(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class As{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 Ds{constructor(t,n){this._map=t,this._tr=new As(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&&(ge.disableDrag(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(t,n){if(!this._active)return;const a=n;if(this._lastPos.equals(a)||!this._box&&a.dist(this._startPos)<this._clickTolerance)return;const l=this._startPos;this._lastPos=a,this._box||(this._box=ge.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",t));const p=Math.min(l.x,a.x),m=Math.max(l.x,a.x),_=Math.min(l.y,a.y),x=Math.max(l.y,a.y);ge.setTransform(this._box,`translate(${p}px,${_}px)`),this._box.style.width=m-p+"px",this._box.style.height=x-_+"px"}mouseupWindow(t,n){if(!this._active||t.button!==0)return;const a=this._startPos,l=n;if(this.reset(),ge.suppressClick(),a.x!==l.x||a.y!==l.y)return this._map.fire(new c.l("boxzoomend",{originalEvent:t})),{cameraAnimation:p=>p.fitScreenCoordinates(a,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&&(ge.remove(this._box),this._box=null),ge.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,n){return this._map.fire(new c.l(t,{originalEvent:n}))}}function Jr(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 a=0;a<d.length;a++)n[d[a].identifier]=t[a];return n}class Xe{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,n,a){(this.centroid||a.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=t.timeStamp),a.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=Jr(a,n)))}touchmove(t,n,a){if(this.aborted||!this.centroid)return;const l=Jr(a,n);for(const p in this.touches){const m=l[p];(!m||m.dist(this.touches[p])>30)&&(this.aborted=!0)}}touchend(t,n,a){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),a.length===0){const l=!this.aborted&&this.centroid;if(this.reset(),l)return l}}}class go{constructor(t){this.singleTap=new Xe(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,n,a){this.singleTap.touchstart(t,n,a)}touchmove(t,n,a){this.singleTap.touchmove(t,n,a)}touchend(t,n,a){const l=this.singleTap.touchend(t,n,a);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 zl{constructor(t){this._tr=new As(t),this._zoomIn=new go({numTouches:1,numTaps:2}),this._zoomOut=new go({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,n,a){this._zoomIn.touchstart(t,n,a),this._zoomOut.touchstart(t,n,a)}touchmove(t,n,a){this._zoomIn.touchmove(t,n,a),this._zoomOut.touchmove(t,n,a)}touchend(t,n,a){const l=this._zoomIn.touchend(t,n,a),p=this._zoomOut.touchend(t,n,a),m=this._tr;return l?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:m.zoom+1,around:m.unproject(l)},{originalEvent:t})}):p?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:m.zoom-1,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 zs{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 a=this._lastPoint;if(!a)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(a)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=l,this._move(a,l))}dragEnd(t){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(t)&&(this._moved&&ge.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 ga=0,_a=2,kl={[ga]:1,[_a]:2};class ya{constructor(t){this._correctEvent=t.checkCorrectEvent}startMove(t){const n=ge.mouseButton(t);this._eventButton=n}endMove(t){delete this._eventButton}isValidStartEvent(t){return this._correctEvent(t)}isValidMoveEvent(t){return!(function(n,a){const l=kl[a];return n.buttons===void 0||(n.buttons&l)!==l})(t,this._eventButton)}isValidEndEvent(t){return ge.mouseButton(t)===this._eventButton}}class Rl{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 hu{constructor(t=new ya({checkCorrectEvent:()=>!0}),n=new Rl){this.mouseMoveStateManager=t,this.oneFingerTouchMoveStateManager=n}_executeRelevantHandler(t,n,a){return t instanceof MouseEvent?n(t):typeof TouchEvent<"u"&&t instanceof TouchEvent?a(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 ks=d=>{d.mousedown=d.dragStart,d.mousemoveWindow=d.dragMove,d.mouseup=d.dragEnd,d.contextmenu=t=>{t.preventDefault()}};class Ih{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,a){return this._calculateTransform(t,n,a)}touchmove(t,n,a){if(this._active){if(!this._shouldBePrevented(a.length))return t.preventDefault(),this._calculateTransform(t,n,a);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",t)}}touchend(t,n,a){this._calculateTransform(t,n,a),this._active&&this._shouldBePrevented(a.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,n,a){a.length>0&&(this._active=!0);const l=Jr(a,n),p=new c.P(0,0),m=new c.P(0,0);let _=0;for(const b in l){const T=l[b],E=this._touches[b];E&&(p._add(T),m._add(T.sub(E)),_++,l[b]=T)}if(this._touches=l,this._shouldBePrevented(_)||!m.mag())return;const x=m.div(_);return this._sum._add(x),this._sum.mag()<this._clickTolerance?void 0:{around:p.div(_),panDelta:x}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class _o{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(t,n,a){this._firstTwoTouches||a.length<2||(this._firstTwoTouches=[a[0].identifier,a[1].identifier],this._start([n[0],n[1]]))}touchmove(t,n,a){if(!this._firstTwoTouches)return;t.preventDefault();const[l,p]=this._firstTwoTouches,m=yo(a,n,l),_=yo(a,n,p);if(!m||!_)return;const x=this._aroundCenter?null:m.add(_).div(2);return this._move([m,_],x,t)}touchend(t,n,a){if(!this._firstTwoTouches)return;const[l,p]=this._firstTwoTouches,m=yo(a,n,l),_=yo(a,n,p);m&&_||(this._active&&ge.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 yo(d,t,n){for(let a=0;a<d.length;a++)if(d[a].identifier===n)return t[a]}function du(d,t){return Math.log(d/t)/Math.LN2}class Fl extends _o{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,n){const a=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(du(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:du(this._distance,a),pinchAround:n}}}function pu(d,t){return 180*d.angleWith(t)/Math.PI}class Ll extends _o{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,a){const l=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:pu(this._vector,l),pinchAround:n}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());const n=25/(Math.PI*this._minDiameter)*360,a=pu(t,this._startVector);return Math.abs(a)<n}}function Bl(d){return Math.abs(d.y)>Math.abs(d.x)}class fu extends _o{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,a){super.touchstart(t,n,a),this._currentTouchCount=a.length}_start(t){this._lastPoints=t,Bl(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,n,a){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,a.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(l.y+p.y)/2*-.5}):void 0}gestureBeginsVertically(t,n,a){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=a),a-this._firstMove<100&&void 0;const m=t.y>0==n.y>0;return Bl(t)&&Bl(n)&&m}}const An={panStep:100,bearingStep:15,pitchStep:10};class ii{constructor(t){this._tr=new As(t);const n=An;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,a=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?a=-1:(t.preventDefault(),p=-1);break;case 39:t.shiftKey?a=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&&(a=0,l=0),{cameraAnimation:_=>{const x=this._tr;_.easeTo({duration:300,easeId:"keyboardHandler",easing:Eh,zoom:n?Math.round(x.zoom)+n*(t.shiftKey?2:1):x.zoom,bearing:x.bearing+a*this._bearingStep,pitch:x.pitch+l*this._pitchStep,offset:[-p*this._panStep,-m*this._panStep],center:x.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 Eh(d){return d*(2-d)}const xa=4.000244140625,xo=1/450;class vo{constructor(t,n){this._onTimeout=a=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(a)},this._map=t,this._tr=new As(t),this._triggerRenderFrame=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=xo}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 a=Je(),l=a-(this._lastWheelEventTime||0);this._lastWheelEventTime=a,n!==0&&n%xa==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=ge.mousePos(this._map.getCanvas(),t),a=this._tr;this._aroundPoint=this._aroundCenter?a.transform.locationToScreenPoint(c.V.convert(a.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)>xa?this._wheelZoomRate:this._defaultZoomRate;let x=2/(1+Math.exp(-Math.abs(this._delta*_)));this._delta<0&&x!==0&&(x=1/x);const b=typeof this._targetZoom!="number"?t.scale:c.aq(this._targetZoom);this._targetZoom=t.applyConstrain(t.getCameraLngLat(),c.at(b*x)).zoom,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,a=this._startZoom,l=this._easing;let p,m=!1;if(this._type==="wheel"&&a&&l){const _=Je()-this._lastWheelEventTime,x=Math.min((_+5)/200,1),b=l(x);p=c.G.number(a,n,b),x<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.cy;if(this._prevEase){const a=this._prevEase,l=(Je()-a.start)/a.duration,p=a.easing(l+.01)-a.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:Je(),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 Ol{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 mu{constructor(t){this._tr=new As(t),this.reset()}reset(){this._active=!1}dblclick(t,n){return t.preventDefault(),{cameraAnimation:a=>{a.easeTo({duration:300,zoom:this._tr.zoom+(t.shiftKey?-1:1),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 gu{constructor(){this._tap=new go({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,a){if(!this._swipePoint)if(this._tapTime){const l=n[0],p=t.timeStamp-this._tapTime<500,m=this._tapPoint.dist(l)<30;p&&m?a.length>0&&(this._swipePoint=l,this._swipeTouch=a[0].identifier):this.reset()}else this._tap.touchstart(t,n,a)}touchmove(t,n,a){if(this._tapTime){if(this._swipePoint){if(a[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,a)}touchend(t,n,a){if(this._tapTime)this._swipePoint&&a.length===0&&this.reset();else{const l=this._tap.touchend(t,n,a);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 _u{constructor(t,n,a){this._el=t,this._mousePan=n,this._touchPan=a}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 Qr{constructor(t,n,a,l){this._pitchWithRotate=t.pitchWithRotate,this._rollEnabled=t.rollEnabled,this._mouseRotate=n,this._mousePitch=a,this._mouseRoll=l}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class va{constructor(t,n,a,l){this._el=t,this._touchZoom=n,this._touchRotate=a,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 et{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=ge.create("div","maplibregl-cooperative-gesture-screen",t);let n=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(n=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const a=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=a,this._container.appendChild(p),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(ge.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 nt=d=>d.zoom||d.drag||d.roll||d.pitch||d.rotate;class ba extends c.l{}function bo(d){return d.panDelta&&d.panDelta.mag()||d.zoomDelta||d.bearingDelta||d.pitchDelta||d.rollDelta}class wo{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},x={},b={};for(const{handlerName:I,handler:k,allowed:V}of this._handlers){if(!k.isEnabled())continue;let q;if(this._blockedByActive(b,V,I))k.reset();else if(k[p||l.type]){if(c.cz(l,p||l.type)){const W=ge.mousePos(this._map.getCanvas(),l);q=k[p||l.type](l,W)}else if(c.cA(l,p||l.type)){const W=this._getMapTouches(l.touches),Z=ge.touchPos(this._map.getCanvas(),W);q=k[p||l.type](l,Z,W)}else c.cB(p||l.type)||(q=k[p||l.type](l));this.mergeHandlerResult(_,x,q,I,m),q&&q.needsRenderFrame&&this._triggerRenderFrame()}(q||k.isActive())&&(b[I]=k)}const T={};for(const I in this._previousActiveHandlers)b[I]||(T[I]=m);this._previousActiveHandlers=b,(Object.keys(T).length||bo(_))&&(this._changes.push([_,x,T]),this._triggerRenderFrame()),(Object.keys(b).length||bo(_))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:E}=_;E&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],E(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Sh(t),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n);const a=this._el;this._listeners=[[a,"touchstart",{passive:!0}],[a,"touchmove",{passive:!1}],[a,"touchend",void 0],[a,"touchcancel",void 0],[a,"mousedown",void 0],[a,"mousemove",void 0],[a,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[a,"mouseover",void 0],[a,"mouseout",void 0],[a,"dblclick",void 0],[a,"click",void 0],[a,"keydown",{capture:!1}],[a,"keyup",void 0],[a,"wheel",{passive:!1}],[a,"contextmenu",void 0],[window,"blur",void 0]];for(const[l,p,m]of this._listeners)ge.addEventListener(l,p,l===document?this.handleWindowEvent:this.handleEvent,m)}destroy(){for(const[t,n,a]of this._listeners)ge.removeEventListener(t,n,t===document?this.handleWindowEvent:this.handleEvent,a)}_addDefaultHandlers(t){const n=this._map,a=n.getCanvasContainer();this._add("mapEvent",new Ph(n,t));const l=n.boxZoom=new Ds(n,t);this._add("boxZoom",l),t.interactive&&t.boxZoom&&l.enable();const p=n.cooperativeGestures=new et(n,t.cooperativeGestures);this._add("cooperativeGestures",p),t.cooperativeGestures&&p.enable();const m=new zl(n),_=new mu(n);n.doubleClickZoom=new Ol(_,m),this._add("tapZoom",m),this._add("clickZoom",_),t.interactive&&t.doubleClickZoom&&n.doubleClickZoom.enable();const x=new gu;this._add("tapDragZoom",x);const b=n.touchPitch=new fu(n);this._add("touchPitch",b),t.interactive&&t.touchPitch&&n.touchPitch.enable(t.touchPitch);const T=()=>n.project(n.getCenter()),E=(function({enable:H,clickTolerance:ee,aroundCenter:se=!0,minPixelCenterThreshold:J=100,rotateDegreesPerPixelMoved:oe=.8},Te){const _e=new ya({checkCorrectEvent:xe=>ge.mouseButton(xe)===0&&xe.ctrlKey||ge.mouseButton(xe)===2&&!xe.ctrlKey});return new zs({clickTolerance:ee,move:(xe,ve)=>{const Fe=Te();if(se&&Math.abs(Fe.y-xe.y)>J)return{bearingDelta:c.cx(new c.P(xe.x,ve.y),ve,Fe)};let Le=(ve.x-xe.x)*oe;return se&&ve.y<Fe.y&&(Le=-Le),{bearingDelta:Le}},moveStateManager:_e,enable:H,assignEvents:ks})})(t,T),I=(function({enable:H,clickTolerance:ee,pitchDegreesPerPixelMoved:se=-.5}){const J=new ya({checkCorrectEvent:oe=>ge.mouseButton(oe)===0&&oe.ctrlKey||ge.mouseButton(oe)===2});return new zs({clickTolerance:ee,move:(oe,Te)=>({pitchDelta:(Te.y-oe.y)*se}),moveStateManager:J,enable:H,assignEvents:ks})})(t),k=(function({enable:H,clickTolerance:ee,rollDegreesPerPixelMoved:se=.3},J){const oe=new ya({checkCorrectEvent:Te=>ge.mouseButton(Te)===2&&Te.ctrlKey});return new zs({clickTolerance:ee,move:(Te,_e)=>{const xe=J();let ve=(_e.x-Te.x)*se;return _e.y<xe.y&&(ve=-ve),{rollDelta:ve}},moveStateManager:oe,enable:H,assignEvents:ks})})(t,T);n.dragRotate=new Qr(t,E,I,k),this._add("mouseRotate",E,["mousePitch"]),this._add("mousePitch",I,["mouseRotate","mouseRoll"]),this._add("mouseRoll",k,["mousePitch"]),t.interactive&&t.dragRotate&&n.dragRotate.enable();const V=(function({enable:H,clickTolerance:ee}){const se=new ya({checkCorrectEvent:J=>ge.mouseButton(J)===0&&!J.ctrlKey});return new zs({clickTolerance:ee,move:(J,oe)=>({around:oe,panDelta:oe.sub(J)}),activateOnStart:!0,moveStateManager:se,enable:H,assignEvents:ks})})(t),q=new Ih(t,n);n.dragPan=new _u(a,V,q),this._add("mousePan",V),this._add("touchPan",q,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&n.dragPan.enable(t.dragPan);const W=new Ll,Z=new Fl;n.touchZoomRotate=new va(a,Z,W,x),this._add("touchRotate",W,["touchPan","touchZoom"]),this._add("touchZoom",Z,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&n.touchZoomRotate.enable(t.touchZoomRotate),this._add("blockableMapEvent",new Mh(n));const Y=n.scrollZoom=new vo(n,(()=>this._triggerRenderFrame()));this._add("scrollZoom",Y,["mousePan"]),t.interactive&&t.scrollZoom&&n.scrollZoom.enable(t.scrollZoom);const ie=n.keyboard=new ii(n);this._add("keyboard",ie),t.interactive&&t.keyboard&&n.keyboard.enable()}_add(t,n,a){this._handlers.push({handlerName:t,handler:n,allowed:a}),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!!nt(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,n,a){for(const l in t)if(l!==a&&(!n||n.indexOf(l)<0))return!0;return!1}_getMapTouches(t){const n=[];for(const a of t)this._el.contains(a.target)&&n.push(a);return n}mergeHandlerResult(t,n,a,l,p){if(!a)return;c.e(t,a);const m={handlerName:l,originalEvent:a.originalEvent||p};a.zoomDelta!==void 0&&(n.zoom=m),a.panDelta!==void 0&&(n.drag=m),a.rollDelta!==void 0&&(n.roll=m),a.pitchDelta!==void 0&&(n.pitch=m),a.bearingDelta!==void 0&&(n.rotate=m)}_applyChanges(){const t={},n={},a={};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(a,m);this._updateMapTransform(t,n,a),this._changes=[]}_updateMapTransform(t,n,a){const l=this._map,p=l._getTransformForUpdate(),m=l.terrain;if(!(bo(t)||m&&this._terrainMovement))return this._fireEvents(n,a,!0);l._stop(!0);let{panDelta:_,zoomDelta:x,bearingDelta:b,pitchDelta:T,rollDelta:E,around:I,pinchAround:k}=t;k!==void 0&&(I=k),I=I||l.transform.centerPoint,m&&!p.isPointOnMapSurface(I)&&(I=p.centerPoint);const V={panDelta:_,zoomDelta:x,rollDelta:E,pitchDelta:T,bearingDelta:b,around:I};this._map.cameraHelper.useGlobeControls&&!p.isPointOnMapSurface(I)&&(I=p.centerPoint);const q=I.distSqr(p.centerPoint)<.01?p.center:p.screenPointToLocation(_?I.sub(_):I);this._handleMapControls({terrain:m,tr:p,deltasForHelper:V,preZoomAroundLoc:q,combinedEventsInProgress:n,panDelta:_}),l._applyUpdatedTransform(p),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(n,a,!0)}_handleMapControls({terrain:t,tr:n,deltasForHelper:a,preZoomAroundLoc:l,combinedEventsInProgress:p,panDelta:m}){const _=this._map.cameraHelper;if(_.handleMapControlsRollPitchBearingZoom(a,n),t)return _.useGlobeControls?(this._terrainMovement||!p.drag&&!p.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void _.handleMapControlsPan(a,n,l)):this._terrainMovement||!p.drag&&!p.zoom?void(p.drag&&this._terrainMovement&&m?n.setCenter(n.screenPointToLocation(n.centerPoint.sub(m))):_.handleMapControlsPan(a,n,l)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void _.handleMapControlsPan(a,n,l));_.handleMapControlsPan(a,n,l)}_fireEvents(t,n,a){const l=nt(this._eventsInProgress),p=nt(t),m={};for(const E in t){const{originalEvent:I}=t[E];this._eventsInProgress[E]||(m[`${E}start`]=I),this._eventsInProgress[E]=t[E]}!l&&p&&this._fireEvent("movestart",p.originalEvent);for(const E in m)this._fireEvent(E,m[E]);p&&this._fireEvent("move",p.originalEvent);for(const E in t){const{originalEvent:I}=t[E];this._fireEvent(E,I)}const _={};let x;for(const E in this._eventsInProgress){const{handlerName:I,originalEvent:k}=this._eventsInProgress[E];this._handlersById[I].isActive()||(delete this._eventsInProgress[E],x=n[I]||k,_[`${E}end`]=x)}for(const E in _)this._fireEvent(E,_[E]);const b=nt(this._eventsInProgress),T=(l||p)&&!b;if(T&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const E=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&E.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(E)}if(a&&T){this._updatingCamera=!0;const E=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),I=k=>k!==0&&-this._bearingSnap<k&&k<this._bearingSnap;!E||!E.essential&&rt.prefersReducedMotion?(this._map.fire(new c.l("moveend",{originalEvent:x})),I(this._map.getBearing())&&this._map.resetNorth()):(I(E.bearing||this._map.getBearing())&&(E.bearing=0),E.freezeElevation=!0,this._map.easeTo(E,{originalEvent:x})),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 ba("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Tr extends c.E{constructor(t,n,a){super(),this._renderFrameCallback=()=>{const l=Math.min((Je()-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=a.bearingSnap,this.cameraHelper=n,this.on("moveend",(()=>{delete this._requestedCameraState}))}migrateProjection(t,n){t.apply(this.transform),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,a){return t=c.P.convert(t).mult(-1),this.panTo(this.transform.center,c.e({offset:t},n),a)}panTo(t,n,a){return this.easeTo(c.e({center:t},n),a)}getZoom(){return this.transform.zoom}setZoom(t,n){return this.jumpTo({zoom:t},n),this}zoomTo(t,n,a){return this.easeTo(c.e({zoom:t},n),a)}zoomIn(t,n){return this.zoomTo(this.getZoom()+1,t,n),this}zoomOut(t,n){return this.zoomTo(this.getZoom()-1,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}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,a){return this.easeTo(c.e({bearing:t},n),a)}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=Vt.convert(t).adjustAntiMeridian();const a=n&&n.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),a,n)}_cameraForBoxAndBearing(t,n,a,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 b=l.padding;l.padding={top:b,bottom:b,right:b,left:b}}const m=c.e(p,l.padding);l.padding=m;const _=this.transform,x=new Vt(t,n);return this.cameraHelper.cameraForBoxAndBearing(l,m,x,a,_)}fitBounds(t,n,a){return this._fitInternal(this.cameraForBounds(t,n),n,a)}fitScreenCoordinates(t,n,a,l,p){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(c.P.convert(t)),this.transform.screenPointToLocation(c.P.convert(n)),a,l),l,p)}_fitInternal(t,n,a){return t?(delete(n=c.e(t,n)).padding,n.linear?this.easeTo(n,a):this.flyTo(n,a)):this}jumpTo(t,n){this.stop();const a=this._getTransformForUpdate();let l=!1,p=!1,m=!1;const _=a.zoom;this.cameraHelper.handleJumpToCenterZoom(a,t);const x=a.zoom!==_;return"elevation"in t&&a.elevation!==+t.elevation&&a.setElevation(+t.elevation),"bearing"in t&&a.bearing!==+t.bearing&&(l=!0,a.setBearing(+t.bearing)),"pitch"in t&&a.pitch!==+t.pitch&&(p=!0,a.setPitch(+t.pitch)),"roll"in t&&a.roll!==+t.roll&&(m=!0,a.setRoll(+t.roll)),t.padding==null||a.isPaddingEqual(t.padding)||a.setPadding(t.padding),this._applyUpdatedTransform(a),this.fire(new c.l("movestart",n)).fire(new c.l("move",n)),x&&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,a,l=0){const p=c.a9.fromLngLat(t,n),m=c.a9.fromLngLat(a,l),_=m.x-p.x,x=m.y-p.y,b=m.z-p.z,T=Math.hypot(_,x,b);if(T===0)throw new Error("Can't calculate camera options with same From and To");const E=Math.hypot(_,x),I=c.at(this.transform.cameraToCenterDistance/T/this.transform.tileSize),k=180*Math.atan2(_,-x)/Math.PI;let V=180*Math.acos(E/T)/Math.PI;return V=b<0?90-V:90+V,{center:m.toLngLat(),elevation:l,zoom:I,pitch:V,bearing:k}}calculateCameraOptionsFromCameraLngLatAltRotation(t,n,a,l,p){const m=this.transform.calculateCenterFromCameraLngLatAlt(t,n,a,l);return{center:m.center,elevation:m.elevation,zoom:m.zoom,bearing:a,pitch:l,roll:p}}easeTo(t,n){this._stop(!1,t.easeId),((t=c.e({offset:[0,0],duration:500,easing:c.cy},t)).animate===!1||!t.essential&&rt.prefersReducedMotion)&&(t.duration=0);const a=this._getTransformForUpdate(),l=this.getBearing(),p=a.pitch,m=a.roll,_="bearing"in t?this._normalizeBearing(t.bearing,l):l,x="pitch"in t?+t.pitch:p,b="roll"in t?this._normalizeBearing(t.roll,m):m,T="padding"in t?t.padding:a.padding,E=c.P.convert(t.offset);let I,k;t.around&&(I=c.V.convert(t.around),k=a.locationToScreenPoint(I));const V={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},q=this.cameraHelper.handleEaseTo(a,{bearing:_,pitch:x,roll:b,padding:T,around:I,aroundPoint:k,offsetAsPoint:E,offset:t.offset,zoom:t.zoom,center:t.center});return this._rotating=this._rotating||l!==_,this._pitching=this._pitching||x!==p,this._rolling=this._rolling||b!==m,this._padding=!a.isPaddingEqual(T),this._zooming=this._zooming||q.isZooming,this._easeId=t.easeId,this._prepareEase(n,t.noMoveStart,V),this.terrain&&this._prepareElevation(q.elevationCenter),this._ease((W=>{q.easeFunc(W),this.terrain&&!t.freezeElevation&&this._updateElevation(W),this._applyUpdatedTransform(a),this._fireMoveEvents(n)}),(W=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(n,W)}),t),this}_prepareEase(t,n,a={}){this._moving=!0,n||a.moving||this.fire(new c.l("movestart",t)),this._zooming&&!a.zooming&&this.fire(new c.l("zoomstart",t)),this._rotating&&!a.rotating&&this.fire(new c.l("rotatestart",t)),this._pitching&&!a.pitching&&this.fire(new c.l("pitchstart",t)),this._rolling&&!a.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 a=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(a-(n-(a*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(),a=t.getCameraAltitude(),l=this.terrain?this.terrain.getElevationForLngLatZoom(n,t.zoom):0;if(a<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 a=t.clone();for(const l of n){const p=a.clone(),{center:m,zoom:_,roll:x,pitch:b,bearing:T,elevation:E}=l(p);m&&p.setCenter(m),E!==void 0&&p.setElevation(E),_!==void 0&&p.setZoom(_),x!==void 0&&p.setRoll(x),b!==void 0&&p.setPitch(b),T!==void 0&&p.setBearing(T),a.apply(p)}this.transform.apply(a)}_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 a=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,a&&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&&rt.prefersReducedMotion){const ve=c.U(t,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(ve,n)}this.stop(),t=c.e({offset:[0,0],speed:1.2,curve:1.42,easing:c.cy},t);const a=this._getTransformForUpdate(),l=a.bearing,p=a.pitch,m=a.roll,_=a.padding,x="bearing"in t?this._normalizeBearing(t.bearing,l):l,b="pitch"in t?+t.pitch:p,T="roll"in t?this._normalizeBearing(t.roll,m):m,E="padding"in t?t.padding:a.padding,I=c.P.convert(t.offset);let k=a.centerPoint.add(I);const V=a.screenPointToLocation(k),q=this.cameraHelper.handleFlyTo(a,{bearing:x,pitch:b,roll:T,padding:E,locationAtOffset:V,offsetAsPoint:I,center:t.center,minZoom:t.minZoom,zoom:t.zoom});let W=t.curve;const Z=Math.max(a.width,a.height),Y=Z/q.scaleOfZoom,ie=q.pixelPathLength;typeof q.scaleOfMinZoom=="number"&&(W=Math.sqrt(Z/q.scaleOfMinZoom/ie*2));const H=W*W;function ee(ve){const Fe=(Y*Y-Z*Z+(ve?-1:1)*H*H*ie*ie)/(2*(ve?Y:Z)*H*ie);return Math.log(Math.sqrt(Fe*Fe+1)-Fe)}function se(ve){return(Math.exp(ve)-Math.exp(-ve))/2}function J(ve){return(Math.exp(ve)+Math.exp(-ve))/2}const oe=ee(!1);let Te=function(ve){return J(oe)/J(oe+W*ve)},_e=function(ve){return Z*((J(oe)*(se(Fe=oe+W*ve)/J(Fe))-se(oe))/H)/ie;var Fe},xe=(ee(!0)-oe)/W;if(Math.abs(ie)<2e-6||!isFinite(xe)){if(Math.abs(Z-Y)<1e-6)return this.easeTo(t,n);const ve=Y<Z?-1:1;xe=Math.abs(Math.log(Y/Z))/W,_e=()=>0,Te=Fe=>Math.exp(ve*W*Fe)}return t.duration="duration"in t?+t.duration:1e3*xe/("screenSpeed"in t?+t.screenSpeed/W:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=l!==x,this._pitching=b!==p,this._rolling=T!==m,this._padding=!a.isPaddingEqual(E),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(q.targetCenter),this._ease((ve=>{const Fe=ve*xe,Le=1/Te(Fe),Ae=_e(Fe);this._rotating&&a.setBearing(c.G.number(l,x,ve)),this._pitching&&a.setPitch(c.G.number(p,b,ve)),this._rolling&&a.setRoll(c.G.number(m,T,ve)),this._padding&&(a.interpolatePadding(_,E,ve),k=a.centerPoint.add(I)),q.easeFunc(ve,Le,Ae,k),this.terrain&&!t.freezeElevation&&this._updateElevation(ve),this._applyUpdatedTransform(a),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 a;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||(a=this.handlers)===null||a===void 0||a.stop(!1),this}_ease(t,n,a){a.animate===!1||a.duration===0?(t(1),n()):(this._easeStart=Je(),this._easeOptions=a,this._onEaseFrame=t,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,n){t=c.W(t,-180,180);const a=Math.abs(t-n);return Math.abs(t-360-n)<a&&(t-=360),Math.abs(t+360-n)<a&&(t+=360),t}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLat(c.V.convert(t),this.transform):null}}const Gr={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class Vl{constructor(t=Gr){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=ge.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=ge.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=ge.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(){ge.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 a=this._map._getUIString(`AttributionControl.${n}`);t.title=a,t.setAttribute("aria-label",a)}_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 a=t.join(" | ");a!==this._attribHTML&&(this._attribHTML=a,t.length?(this._innerContainer.innerHTML=ge.sanitize(a),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class yu{constructor(t={}){this._updateCompact=()=>{const n=this._container.children;if(n.length){const a=n[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&a.classList.add("maplibregl-compact"):a.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=ge.create("div","maplibregl-ctrl");const n=ge.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(){ge.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Ch{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,a=n?this._queue.concat(n):this._queue;for(const l of a)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 a of n)if(!a.cancelled&&(a.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Ah=c.aU([{name:"a_pos3d",type:"Int16",components:3}]);class wa extends c.E{constructor(t){super(),this._lastTilesetChange=Je(),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 a={};for(const l of zi(t,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n,calculateTileZoom:this.tileManager._source.calculateTileZoom}))a[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 ke(l,this.tileSize),this._lastTilesetChange=Je());for(const l in this._tiles)a[l]||delete this._tiles[l]}freeRtt(t){for(const n in this._tiles){const a=this._tiles[n];(!t||a.tileID.equals(t)||a.tileID.isChildOf(t)||t.isChildOf(a.tileID))&&(a.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 a of this._renderableTilesKeys){const l=this._tiles[a].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,x=l.canonical.x-(l.canonical.x>>_<<_),b=l.canonical.y-(l.canonical.y>>_<<_),T=c.a5>>_;c.c7(m,0,T,T,0,0,1),c.O(m,m,[-x*T,-b*T,0])}else{if(!t.canonical.isChildOf(l.canonical))continue;{const _=t.canonical.z-l.canonical.z,x=t.canonical.x-(t.canonical.x>>_<<_),b=t.canonical.y-(t.canonical.y>>_<<_),T=c.a5>>_;c.c7(m,0,c.a5,c.a5,0,0,1),c.O(m,m,[x*T,b*T,0]),c.Q(m,m,[1/2**_,1/2**_,0])}}p.terrainRttPosMatrix32f=new Float32Array(m),n[a]=p}return n}_getTerrainCoordsForTileRanges(t,n){const a={};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 x=t.canonical.x-p.canonical.x,b=t.canonical.y-p.canonical.y;c.c7(_,0,c.a5,c.a5,0,0,1),c.O(_,_,[x*c.a5,b*c.a5,0])}else if(p.canonical.z>t.canonical.z){const x=p.canonical.z-t.canonical.z,b=p.canonical.x-(p.canonical.x>>x<<x),T=p.canonical.y-(p.canonical.y>>x<<x),E=t.canonical.x-(p.canonical.x>>x),I=t.canonical.y-(p.canonical.y>>x),k=c.a5>>x;c.c7(_,0,k,k,0,0,1),c.O(_,_,[-b*k+E*c.a5,-T*k+I*c.a5,0])}else{const x=t.canonical.z-p.canonical.z,b=t.canonical.x-(t.canonical.x>>x<<x),T=t.canonical.y-(t.canonical.y>>x<<x),E=(t.canonical.x>>x)-p.canonical.x,I=(t.canonical.y>>x)-p.canonical.y,k=c.a5<<x;c.c7(_,0,k,k,0,0,1),c.O(_,_,[b*c.a5+E*k,T*c.a5+I*k,0])}m.terrainRttPosMatrix32f=new Float32Array(_),a[l]=m}return a}getSourceTile(t,n){const a=this.tileManager._source;let l=t.overscaledZ-this.deltaZoom;if(l>a.maxzoom&&(l=a.maxzoom),l<a.minzoom)return;this._sourceTileCache[t.key]||(this._sourceTileCache[t.key]=t.scaledTo(l).key);let p=this.findTileInCaches(this._sourceTileCache[t.key]);if(!(p!=null&&p.dem)&&n)for(;l>=a.minzoom&&!(p!=null&&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){return n[t.canonical.z]&&t.canonical.x>=n[t.canonical.z].minTileX&&t.canonical.x<=n[t.canonical.z].maxTileX&&t.canonical.y>=n[t.canonical.z].minTileY&&t.canonical.y<=n[t.canonical.z].maxTileY}}class Ei{constructor(t,n,a){this._meshCache={},this.painter=t,this.tileManager=new wa(n),this.options=a,this.exaggeration=typeof a.exaggeration=="number"?a.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,n,a,l=c.a5){var p;if(!(n>=0&&n<l&&a>=0&&a<l))return 0;const m=this.getTerrainData(t),_=(p=m.tile)===null||p===void 0?void 0:p.dem;if(!_)return 0;const x=c.cC([],[n/l*c.a5,a/l*c.a5],m.u_terrain_matrix),b=[x[0]*_.dim,x[1]*_.dim],T=Math.floor(b[0]),E=Math.floor(b[1]),I=b[0]-T,k=b[1]-E;return _.get(T,E)*(1-I)*(1-k)+_.get(T+1,E)*I*(1-k)+_.get(T,E+1)*(1-I)*k+_.get(T+1,E+1)*I*k}getElevationForLngLatZoom(t,n){if(!c.cD(n,t.wrap()))return 0;const{tileID:a,mercatorX:l,mercatorY:p}=this._getOverscaledTileIDFromLngLatZoom(t,n);return this.getElevation(a,l%c.a5,p%c.a5,c.a5)}getElevationForLngLat(t,n){const a=zi(n,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this});let l=0;for(const p of a)p.canonical.z>l&&(l=Math.min(p.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(t,l)}getElevation(t,n,a,l=c.a5){return this.getDEMElevation(t,n,a,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 a=n&&n.toString()+n.tileID.key+t.key;if(a&&!this._demMatrixCache[a]){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),x=c.cE(new Float64Array(16),[1/(c.a5<<p),1/(c.a5<<p),0]);c.O(x,x,[m*c.a5,_*c.a5,0]),this._demMatrixCache[t.key]={matrix:x,coord:t}}return{u_depth:2,u_terrain:3,u_terrain_dim:n&&n.dem&&n.dem.dim||1,u_terrain_matrix:a?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,a=n.width/devicePixelRatio,l=n.height/devicePixelRatio;return!this._fbo||this._fbo.width===a&&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:a,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:a,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(a,l,!0,!1),this._fbo.depthAttachment.set(n.context.createRenderbuffer(n.context.gl.DEPTH_COMPONENT16,a,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 a=new c.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),l=new c.T(t,a,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),a=this.painter.context,l=a.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);a.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),l.readPixels(p,_-m-1,1,1,l.RGBA,l.UNSIGNED_BYTE,n),a.bindFramebuffer.set(null);const x=n[0]+(n[2]>>4<<8),b=n[1]+((15&n[2])<<8),T=this.coordsIndex[255-n[3]],E=T&&this.tileManager.getTileByID(T);if(!E)return null;const I=this._coordsTextureSize,k=(1<<E.tileID.canonical.z)*I;return new c.a9((E.tileID.canonical.x*I+x)/k+E.tileID.wrap,(E.tileID.canonical.y*I+b)/k,this.getElevation(E.tileID,x,b,I))}depthAtPoint(t){const n=new Uint8Array(4),a=this.painter.context,l=a.gl;return a.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),a.bindFramebuffer.set(null),(n[0]/16777216+n[1]/65536+n[2]/256+n[3])/256}getTerrainMesh(t){var n;const a=((n=this.painter.style.projection)===null||n===void 0?void 0:n.transitionState)>0,l=a&&t.canonical.y===0,p=a&&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,x=new c.cF,b=new c.aY,T=this.meshSize,E=c.a5/T,I=T*T;for(let J=0;J<=T;J++)for(let oe=0;oe<=T;oe++)x.emplaceBack(oe*E,J*E,0);for(let J=0;J<I;J+=T+1)for(let oe=0;oe<T;oe++)b.emplaceBack(oe+J,T+oe+J+1,T+oe+J+2),b.emplaceBack(oe+J,T+oe+J+2,oe+J+1);const k=x.length,V=k+(T+1),q=(T+1)*T,W=l?c.br:0,Z=l?0:1,Y=p?c.bs:c.a5,ie=p?0:1;for(let J=0;J<=T;J++)x.emplaceBack(J*E,W,Z);for(let J=0;J<=T;J++)x.emplaceBack(J*E,Y,ie);for(let J=0;J<T;J++)b.emplaceBack(q+J,V+J,V+J+1),b.emplaceBack(q+J,V+J+1,q+J+1),b.emplaceBack(0+J,k+J+1,k+J),b.emplaceBack(0+J,0+J+1,k+J+1);const H=x.length,ee=H+2*(T+1);for(const J of[0,1])for(let oe=0;oe<=T;oe++)for(const Te of[0,1])x.emplaceBack(J*c.a5,oe*E,Te);for(let J=0;J<2*T;J+=2)b.emplaceBack(H+J,H+J+1,H+J+3),b.emplaceBack(H+J,H+J+3,H+J+2),b.emplaceBack(ee+J,ee+J+3,ee+J+1),b.emplaceBack(ee+J,ee+J+2,ee+J+3);const se=new ai(_.createVertexBuffer(x,Ah.members),_.createIndexBuffer(b),c.aX.simpleSegment(0,0,x.length,b.length));return this._meshCache[m]=se,se}getMeshFrameDelta(t){return 2*Math.PI*c.bE/Math.pow(2,Math.max(t,0))/5}getMinTileElevationForLngLatZoom(t,n){var a;if(!c.cD(n,t.wrap()))return 0;const{tileID:l}=this._getOverscaledTileIDFromLngLatZoom(t,n);return(a=this.getMinMaxElevation(l).minElevation)!==null&&a!==void 0?a:0}getMinMaxElevation(t){const n=this.getTerrainData(t).tile,a={minElevation:null,maxElevation:null};return n&&n.dem&&(a.minElevation=n.dem.min*this.exaggeration,a.maxElevation=n.dem.max*this.exaggeration),a}_getOverscaledTileIDFromLngLatZoom(t,n){const a=c.a9.fromLngLat(t.wrap()),l=(1<<n)*c.a5,p=a.x*l,m=a.y*l,_=Math.floor(p/c.a5),x=Math.floor(m/c.a5);return{tileID:new c.a2(n,0,n,_,x),mercatorX:p,mercatorY:m}}}class Ni{constructor(t,n,a){this._context=t,this._size=n,this._tileSize=a,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),a=new c.T(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return a.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(a.texture),{id:t,fbo:n,texture:a,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 Kn={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class Ta{constructor(t,n){this.painter=t,this.terrain=n,this.pool=new Ni(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){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=t._order.filter((a=>!t._layers[a].isHidden(n))),this._coordsAscending={};for(const a in t.tileManagers){this._coordsAscending[a]={};const l=t.tileManagers[a].getVisibleCoordinates(),p=t.tileManagers[a].getSource(),m=p instanceof vi?p.terrainTileRanges:null;for(const _ of l){const x=this.terrain.tileManager.getTerrainCoords(_,m);for(const b in x)this._coordsAscending[a][b]||(this._coordsAscending[a][b]=[]),this._coordsAscending[a][b].push(x[b])}}this._coordsAscendingStr={};for(const a of t._order){const l=t._layers[a],p=l.source;if(Kn[l.type]&&!this._coordsAscendingStr[p]){this._coordsAscendingStr[p]={};for(const m in this._coordsAscending[p])this._coordsAscendingStr[p][m]=this._coordsAscending[p][m].map((_=>_.key)).sort().join()}}for(const a of this._renderableTiles)for(const l in this._coordsAscendingStr){const p=this._coordsAscendingStr[l][a.tileID.key];p&&p!==a.rttCoords[l]&&(a.rtt=[])}}renderLayer(t,n){if(t.isHidden(this.painter.transform.zoom))return!1;const a=Object.assign(Object.assign({},n),{isRenderingToTexture:!0}),l=t.type,p=this.painter,m=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(Kn[l]&&(this._prevType&&Kn[this._prevType]||this._stacks.push([]),this._prevType=l,this._stacks[this._stacks.length-1].push(t.id),!m))return!0;if(Kn[this._prevType]||Kn[l]&&m){this._prevType=l;const _=this._stacks.length-1,x=this._stacks[_]||[];for(const b of this._renderableTiles){if(this.pool.isFull()&&(El(this.painter,this.terrain,this._rttTiles,a),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(b),b.rtt[_]){const E=this.pool.getObjectForId(b.rtt[_].id);if(E.stamp===b.rtt[_].stamp){this.pool.useObject(E);continue}}const T=this.pool.getOrCreateFreeObject();this.pool.useObject(T),this.pool.stampObject(T),b.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 E=0;E<x.length;E++){const I=p.style._layers[x[E]],k=I.source?this._coordsAscending[I.source][b.tileID.key]:[b.tileID];p.context.viewport.set([0,0,T.fbo.width,T.fbo.height]),p._renderTileClippingMasks(I,k,!0),p.renderLayer(p,p.style.tileManagers[I.source],I,k,a),I.source&&(b.rttCoords[I.source]=this._coordsAscendingStr[I.source][b.tileID.key])}}return El(this.painter,this.terrain,this._rttTiles,a),this._rttTiles=[],this.pool.freeAllObjects(),Kn[l]}return!1}}const To={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"MapLibre logo","Map.Title":"Map","Marker.Title":"Map marker","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","Popup.Close":"Close popup","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","GlobeControl.Enable":"Enable globe","GlobeControl.Disable":"Disable globe","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":"Use ⌘ + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},jl=le,So={hash:!1,interactive:!0,bearingSnap:7,attributionControl:Gr,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},Nl={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};class Sa{constructor(t,n,a=!1){this.mousedown=p=>{this.startMove(p,ge.mousePos(this.element,p)),ge.addEventListener(window,"mousemove",this.mousemove),ge.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=p=>{this.move(p,ge.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=ge.touchPos(this.element,p.targetTouches)[0],this.startMove(p,this._startPos),ge.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),ge.addEventListener(window,"touchend",this.touchend))},this.touchmove=p=>{p.targetTouches.length!==1?this.reset():(this._lastPos=ge.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 hu;this._rotatePitchHandler=new zs({clickTolerance:3,move:(p,m)=>{const _=n.getBoundingClientRect(),x=new c.P((_.bottom-_.top)/2,(_.right-_.left)/2);return{bearingDelta:c.cx(new c.P(p.x,m.y),m,x),pitchDelta:a?-.5*(m.y-p.y):void 0}},moveStateManager:l,enable:!0,assignEvents:()=>{}}),this.map=t,ge.addEventListener(n,"mousedown",this.mousedown),ge.addEventListener(n,"touchstart",this.touchstart,{passive:!1}),ge.addEventListener(n,"touchcancel",this.reset)}startMove(t,n){this._rotatePitchHandler.dragStart(t,n),ge.disableDrag()}move(t,n){const a=this.map,{bearingDelta:l,pitchDelta:p}=this._rotatePitchHandler.dragMove(t,n)||{};l&&a.setBearing(a.getBearing()+l),p&&a.setPitch(a.getPitch()+p)}off(){const t=this.element;ge.removeEventListener(t,"mousedown",this.mousedown),ge.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),ge.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),ge.removeEventListener(window,"touchend",this.touchend),ge.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){ge.enableDrag(),ge.removeEventListener(window,"mousemove",this.mousemove),ge.removeEventListener(window,"mouseup",this.mouseup),ge.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),ge.removeEventListener(window,"touchend",this.touchend)}}let mn;function Po(d,t,n,a=!1){if(a||!n.getCoveringTilesDetailsProvider().allowWorldCopies())return d==null?void 0: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 Pa={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 Mo(d,t,n){const a=d.classList;for(const l in Pa)a.remove(`maplibregl-${n}-anchor-${l}`);a.add(`maplibregl-${n}-anchor-${t}`)}class Ma extends c.E{constructor(t){if(super(),this._onKeyPress=n=>{const a=n.code,l=n.charCode||n.keyCode;a!=="Space"&&a!=="Enter"&&l!==32&&l!==13||this.togglePopup()},this._onMapClick=n=>{const a=n.originalEvent.target,l=this._element;this._popup&&(a===l||l.contains(a))&&this.togglePopup()},this._update=n=>{if(!this._map)return;const a=this._map.loaded()&&!this._map.isMoving();((n==null?void 0:n.type)==="terrain"||(n==null?void 0:n.type)==="render"&&!a)&&this._map.once("render",this._update),this._lngLat=Po(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()),ge.setTransform(this._element,`${Pa[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${p} ${l}`),rt.frameAsync(new AbortController).then((()=>{this._updateOpacity(n&&n.type==="moveend")})).catch((()=>{}))},this._onMove=n=>{if(!this._isDragging){const a=this._clickTolerance||this._map._clickTolerance;this._isDragging=n.point.dist(this._pointerdownPos)>=a}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==null?void 0:t.opacity,t==null?void 0: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=ge.create("div");const n=ge.createNS("http://www.w3.org/2000/svg","svg"),a=41,l=27;n.setAttributeNS(null,"display","block"),n.setAttributeNS(null,"height",`${a}px`),n.setAttributeNS(null,"width",`${l}px`),n.setAttributeNS(null,"viewBox",`0 0 ${l} ${a}`);const p=ge.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=ge.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"fill-rule","nonzero");const _=ge.createNS("http://www.w3.org/2000/svg","g");_.setAttributeNS(null,"transform","translate(3.0, 29.0)"),_.setAttributeNS(null,"fill","#000000");const x=[{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 Z of x){const Y=ge.createNS("http://www.w3.org/2000/svg","ellipse");Y.setAttributeNS(null,"opacity","0.04"),Y.setAttributeNS(null,"cx","10.5"),Y.setAttributeNS(null,"cy","5.80029008"),Y.setAttributeNS(null,"rx",Z.rx),Y.setAttributeNS(null,"ry",Z.ry),_.appendChild(Y)}const b=ge.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"fill",this._color);const T=ge.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"),b.appendChild(T);const E=ge.createNS("http://www.w3.org/2000/svg","g");E.setAttributeNS(null,"opacity","0.25"),E.setAttributeNS(null,"fill","#000000");const I=ge.createNS("http://www.w3.org/2000/svg","path");I.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"),E.appendChild(I);const k=ge.createNS("http://www.w3.org/2000/svg","g");k.setAttributeNS(null,"transform","translate(6.0, 7.0)"),k.setAttributeNS(null,"fill","#FFFFFF");const V=ge.createNS("http://www.w3.org/2000/svg","g");V.setAttributeNS(null,"transform","translate(8.0, 8.0)");const q=ge.createNS("http://www.w3.org/2000/svg","circle");q.setAttributeNS(null,"fill","#000000"),q.setAttributeNS(null,"opacity","0.25"),q.setAttributeNS(null,"cx","5.5"),q.setAttributeNS(null,"cy","5.5"),q.setAttributeNS(null,"r","5.4999962");const W=ge.createNS("http://www.w3.org/2000/svg","circle");W.setAttributeNS(null,"fill","#FFFFFF"),W.setAttributeNS(null,"cx","5.5"),W.setAttributeNS(null,"cy","5.5"),W.setAttributeNS(null,"r","5.4999962"),V.appendChild(q),V.appendChild(W),m.appendChild(_),m.appendChild(b),m.appendChild(E),m.appendChild(k),m.appendChild(V),n.appendChild(m),n.setAttributeNS(null,"height",a*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()})),Mo(this._element,this._anchor,"marker"),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),ge.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,a;const l=(n=this._map)===null||n===void 0?void 0:n.terrain,p=this._map.transform.isLocationOccluded(this._lngLat);if(!l||p){const k=p?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==k&&(this._element.style.opacity=k))}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),x=m.terrain.getElevationForLngLat(this._lngLat,m.transform);if(m.transform.lngLatToCameraDepth(this._lngLat,x)-_<.006)return void(this._element.style.opacity=this._opacity);const b=-this._offset.y/m.transform.pixelsPerMeter,T=Math.sin(m.getPitch()*Math.PI/180)*b,E=m.terrain.depthAtPoint(new c.P(this._pos.x,this._pos.y-this._offset.y)),I=m.transform.lngLatToCameraDepth(this._lngLat,x+T)-E>.006;!((a=this._popup)===null||a===void 0)&&a.isOpen()&&I&&this._popup.remove(),this._element.style.opacity=I?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 Ul={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Rs=0,Jn=!1;const Gl={maxWidth:100,unit:"metric"};function Ia(d,t,n){const a=n&&n.maxWidth||100,l=d._container.clientHeight/2,p=d._container.clientWidth/2,m=d.unproject([p-a/2,l]),_=d.unproject([p+a/2,l]),x=Math.round(d.project(_).x-d.project(m).x),b=Math.min(a,x,d._container.clientWidth),T=m.distanceTo(_);if(n&&n.unit==="imperial"){const E=3.2808*T;E>5280?Qn(t,b,E/5280,d._getUIString("ScaleControl.Miles")):Qn(t,b,E,d._getUIString("ScaleControl.Feet"))}else n&&n.unit==="nautical"?Qn(t,b,T/1852,d._getUIString("ScaleControl.NauticalMiles")):T>=1e3?Qn(t,b,T/1e3,d._getUIString("ScaleControl.Kilometers")):Qn(t,b,T,d._getUIString("ScaleControl.Meters"))}function Qn(d,t,n,a){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(x){const b=Math.pow(10,Math.ceil(-Math.log(x)/Math.LN10));return Math.round(x*b)/b})(_),m*_})(n);d.style.width=t*(l/n)+"px",d.innerHTML=`${l}&nbsp;${a}`}const ql={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0},Io=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Eo(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 Eo(new c.P(0,0))}const Zl=le;P.AJAXError=c.cI,P.Event=c.l,P.Evented=c.E,P.LngLat=c.V,P.MercatorCoordinate=c.a9,P.Point=c.P,P.addProtocol=c.cJ,P.config=c.c,P.removeProtocol=c.cK,P.AttributionControl=Vl,P.BoxZoomHandler=Ds,P.CanvasSource=B,P.CooperativeGesturesHandler=et,P.DoubleClickZoomHandler=Ol,P.DragPanHandler=_u,P.DragRotateHandler=Qr,P.EdgeInsets=fs,P.FullscreenControl=class extends c.E{constructor(d={}){super(),this._onFullscreenChange=()=>{var t;let n=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((t=n==null?void 0:n.shadowRoot)===null||t===void 0)&&t.fullscreenElement;)n=n.shadowRoot.fullscreenElement;n===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,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=ge.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){ge.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const d=this._fullscreenButton=ge.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);ge.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(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},P.GeoJSONSource=Di,P.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),a=t.coords.accuracy,l=this._map.getBearing(),p=c.e({bearing:l},this.options.fitBoundsOptions),m=Vt.fromLngLat(n,a);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&&Jn)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=ge.create("button","maplibregl-ctrl-geolocate",this._container),ge.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=ge.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Ma({element:this._dotElement}),this._circleElement=ge.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ma({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 a=(n==null?void 0:n[0])instanceof ResizeObserverEntry;n.geolocateSource||this._watchState!=="ACTIVE_LOCK"||a||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({},Ul,d)}onAdd(d){return this._map=d,this._container=ge.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),(function(){return c._(this,arguments,void 0,(function*(t=!1){if(mn!==void 0&&!t)return mn;if(window.navigator.permissions===void 0)return mn=!!window.navigator.geolocation,mn;try{mn=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{mn=!!window.navigator.geolocation}return mn}))})().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(),ge.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,Rs=0,Jn=!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]),a=d.distanceTo(n)/100,l=2*this._accuracy/a;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":Rs--,Jn=!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"),Rs++,Rs>1?(d={maximumAge:6e5,timeout:0},Jn=!0):(d=this.options.positionOptions,Jn=!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)}},P.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=ge.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=ge.create("button","maplibregl-ctrl-globe",this._container),ge.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){ge.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},P.Hash=Dl,P.ImageSource=vi,P.KeyboardHandler=ii,P.LngLatBounds=Vt,P.LogoControl=yu,P.Map=class extends Tr{constructor(d){var t,n;c.cG.mark(c.cH.create);const a=Object.assign(Object.assign(Object.assign({},So),d),{canvasContextAttributes:Object.assign(Object.assign({},So.canvasContextAttributes),d.canvasContextAttributes)});if(a.minZoom!=null&&a.maxZoom!=null&&a.minZoom>a.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(a.minPitch!=null&&a.maxPitch!=null&&a.minPitch>a.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(a.minPitch!=null&&a.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(a.maxPitch!=null&&a.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const l=new jn,p=new Nn;if(a.minZoom!==void 0&&l.setMinZoom(a.minZoom),a.maxZoom!==void 0&&l.setMaxZoom(a.maxZoom),a.minPitch!==void 0&&l.setMinPitch(a.minPitch),a.maxPitch!==void 0&&l.setMaxPitch(a.maxPitch),a.renderWorldCopies!==void 0&&l.setRenderWorldCopies(a.renderWorldCopies),a.transformConstrain!==null&&l.setConstrainOverride(a.transformConstrain),super(l,p,{bearingSnap:a.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Ch,this._controls=[],this._mapId=c.af(),this._lostContextStyle={style:null,images:null},this._contextLost=_=>{_.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.painter.destroy();for(const x of Object.values(this.style._layers))if(x.type==="custom"&&console.warn(`Custom layer with id '${x.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),x._listeners)for(const[b]of Object.entries(x._listeners))console.warn(`Custom layer with id '${x.id}' had event listeners for event '${b}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this._lostContextStyle=this._getStyleAndImages(),this.style.destroy(),this.style=null,this.fire(new 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._setupPainter(),this.resize(),this._update(),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=a.interactive,this._maxTileCacheSize=a.maxTileCacheSize,this._maxTileCacheZoomLevels=a.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},a.canvasContextAttributes),this._trackResize=a.trackResize===!0,this._bearingSnap=a.bearingSnap,this._centerClampedToGround=a.centerClampedToGround,this._refreshExpiredTiles=a.refreshExpiredTiles===!0,this._fadeDuration=a.fadeDuration,this._crossSourceCollisions=a.crossSourceCollisions===!0,this._collectResourceTiming=a.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},To),a.locale),this._clickTolerance=a.clickTolerance,this._overridePixelRatio=a.pixelRatio,this._maxCanvasSize=a.maxCanvasSize,this._zoomLevelsToOverscale=a.experimentalZoomLevelsToOverscale,this.transformCameraUpdate=a.transformCameraUpdate,this.transformConstrain=a.transformConstrain,this.cancelPendingTileRequestsWhileZooming=a.cancelPendingTileRequestsWhileZooming===!0,a.reduceMotion!==void 0&&(rt.prefersReducedMotion=a.reduceMotion),this._imageQueueHandle=dt.addThrottleControl((()=>this.isMoving())),this._requestManager=new he(a.transformRequest),typeof a.container=="string"){if(this._container=document.getElementById(a.container),!this._container)throw new Error(`Container '${a.container}' not found.`)}else{if(!(a.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=a.container}if(a.maxBounds&&this.setMaxBounds(a.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"){addEventListener("online",this._onWindowOnline,!1);let _=!1;const x=Al((b=>{this._trackResize&&!this._removed&&(this.resize(b),this.redraw())}),50);this._resizeObserver=new ResizeObserver((b=>{_?x(b):_=!0})),this._resizeObserver.observe(this._container)}this.handlers=new wo(this,a),this._hash=a.hash&&new Dl(typeof a.hash=="string"&&a.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:a.center,elevation:a.elevation,zoom:a.zoom,bearing:a.bearing,pitch:a.pitch,roll:a.roll}),a.bounds&&(this.resize(),this.fitBounds(a.bounds,c.e({},a.fitBoundsOptions,{duration:0}))));const m=typeof a.style=="string"||((n=(t=a.style)===null||t===void 0?void 0:t.projection)===null||n===void 0?void 0:n.type)!=="globe";this.resize(null,m),this._localIdeographFontFamily=a.localIdeographFontFamily,this._validateStyle=a.validateStyle,a.style&&this.setStyle(a.style,{localIdeographFontFamily:a.localIdeographFontFamily}),a.attributionControl&&this.addControl(new Vl(typeof a.attributionControl=="boolean"?void 0:a.attributionControl)),a.maplibreLogo&&this.addControl(new yu,a.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 a=this._controlPositions[t];return t.indexOf("bottom")!==-1?a.insertBefore(n,a.firstChild):a.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 zi(this.transform,d)}calculateCameraOptionsFromTo(d,t,n,a){return a==null&&this.terrain&&(a=this.terrain.getElevationForLngLat(n,this.transform)),super.calculateCameraOptionsFromTo(d,t,n,a)}resize(d,t=!0){const[n,a]=this._containerDimensions(),l=this._getClampedPixelRatio(n,a);if(this._resizeCanvas(n,a,l),this.painter.resize(n,a,l),this.painter.overLimit()){const m=this.painter.context.gl;this._maxCanvasSize=[m.drawingBufferWidth,m.drawingBufferHeight];const _=this._getClampedPixelRatio(n,a);this._resizeCanvas(n,a,_),this.painter.resize(n,a,_)}this._resizeTransform(t);const p=!this._moving;return p&&(this.stop(),this.fire(new c.l("movestart",d)).fire(new c.l("move",d))),this.fire(new c.l("resize",d)),p&&this.fire(new c.l("moveend",d)),this}_resizeTransform(d=!0){var t;const[n,a]=this._containerDimensions();this.transform.resize(n,a,d),(t=this._requestedCameraState)===null||t===void 0||t.resize(n,a,d)}_getClampedPixelRatio(d,t){const{0:n,1:a}=this._maxCanvasSize,l=this.getPixelRatio(),p=d*l,m=t*l;return Math.min(p>n?n/p:1,m>a?a/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(Vt.convert(d)),this._update()}setMinZoom(d){if((d=d??-2)>=-2&&d<=this.transform.maxZoom){const t=this._getTransformForUpdate();return t.setMinZoom(d),this._applyUpdatedTransform(t),this._update(),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._getTransformForUpdate();return t.setMaxZoom(d),this._applyUpdatedTransform(t),this._update(),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)return this.transform.setMinPitch(d),this._update(),this.getPitch()<d&&this.setPitch(d),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)return this.transform.setMaxPitch(d),this._update(),this.getPitch()>d&&this.setPitch(d),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}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 a=!1;return{layers:t,listener:n,delegates:{mousemove:p=>{const m=t.filter((x=>this.getLayer(x))),_=m.length!==0?this.queryRenderedFeatures(p.point,{layers:m}):[];_.length?a||(a=!0,n.call(this,new Ji(d,this,p.originalEvent,{features:_}))):a=!1},mouseout:()=>{a=!1}}}}if(d==="mouseleave"||d==="mouseout"){let a=!1;return{layers:t,listener:n,delegates:{mousemove:m=>{const _=t.filter((x=>this.getLayer(x)));(_.length!==0?this.queryRenderedFeatures(m.point,{layers:_}):[]).length?a=!0:a&&(a=!1,n.call(this,new Ji(d,this,m.originalEvent)))},mouseout:m=>{a&&(a=!1,n.call(this,new Ji(d,this,m.originalEvent)))}}}}{const a=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]:a}}}}_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 a=this._delegatedListeners[d];for(let l=0;l<a.length;l++){const p=a[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 a.splice(l,1)}}}on(d,t,n){if(n===void 0)return super.on(d,t);const a=typeof t=="string"?[t]:t,l=this._createDelegatedListener(d,a,n);this._saveDelegatedListener(d,l);for(const p in l.delegates)this.on(p,l.delegates[p]);return{unsubscribe:()=>{this._removeDelegatedListener(d,a,n)}}}once(d,t,n){if(n===void 0)return super.once(d,t);const a=typeof t=="string"?[t]:t,l=this._createDelegatedListener(d,a,n);for(const p in l.delegates){const m=l.delegates[p];l.delegates[p]=(..._)=>{this._removeDelegatedListener(d,a,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 a=d instanceof c.P||Array.isArray(d),l=a?d:[[0,0],[this.transform.width,this.transform.height]];if(t=t||(a?{}: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,a;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 Gn(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):((a=(n=this.style)===null||n===void 0?void 0:n.projection)===null||a===void 0||a.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Gn(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((a=>{this._updateDiff(a.data,t)})).catch((a=>{a&&this.fire(new c.k(a))}))}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 a=this.style._layers[n];a.type==="hillshade"&&a.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."),a.type==="color-relief"&&a.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 Ei(this.painter,t,d),this.painter.renderToTexture=new Ta(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 a;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))),((a=n.source)===null||a===void 0?void 0:a.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 a=this.getSource(n);if(!a)throw new Error(`There is no source with ID "${n}", cannot set LOD parameters`);a.calculateTileZoom=Kt(Math.max(1,d),Math.max(1,t))}else for(const a in this.style.tileManagers)this.style.tileManagers[a].getSource().calculateTileZoom=Kt(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((a=>new c.ac(a.z,a.x,a.y))))}addImage(d,t,n={}){const{pixelRatio:a=1,sdf:l=!1,stretchX:p,stretchY:m,content:_,textFitWidth:x,textFitHeight:b}=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:E,data:I}=t,k=t;return this.style.addImage(d,{data:new c.R({width:T,height:E},new Uint8Array(I)),pixelRatio:a,stretchX:p,stretchY:m,content:_,textFitWidth:x,textFitHeight:b,sdf:l,version:0,userImage:k}),k.onAdd&&k.onAdd(this,d),this}}{const{width:T,height:E,data:I}=rt.getImageData(t);this.style.addImage(d,{data:new c.R({width:T,height:E},I),pixelRatio:a,stretchX:p,stretchY:m,content:_,textFitWidth:x,textFitHeight:b,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 a=t instanceof HTMLImageElement||c.b(t)?rt.getImageData(t):t,{width:l,height:p,data:m}=a;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 dt.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,a={}){return this.style.setPaintProperty(d,t,n,a),this._update(!0)}getPaintProperty(d,t){return this.style.getPaintProperty(d,t)}setLayoutProperty(d,t,n,a={}){return this.style.setLayoutProperty(d,t,n,a),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,(a=>{a||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]}_setupContainer(){const d=this._container;d.classList.add("maplibregl-map");const t=this._canvasContainer=ge.create("div","maplibregl-canvas-container",d);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=ge.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(),a=this._getClampedPixelRatio(n[0],n[1]);this._resizeCanvas(n[0],n[1],a);const l=this._controlContainer=ge.create("div","maplibregl-control-container",d),p=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((m=>{p[m]=ge.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",(a=>{t={requestedAttributes:d},a&&(t.statusMessage=a.statusMessage,t.type=a.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 a="Failed to initialize WebGL";throw t?(t.message=a,new Error(JSON.stringify(t))):new Error(a)}this.painter=new ou(n,this.transform),Xt.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,a,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 x=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const E=this.transform.zoom,I=Je();this.style.zoomHistory.update(E,I);const k=new c.H(E,{now:I,fadeDuration:m,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),V=k.crossFadingFactor();V===1&&V===this._crossFadingFactor||(x=!0,this._crossFadingFactor=V),this.style.update(k)}const b=((n=this.style.projection)===null||n===void 0?void 0:n.transitionState)>0!==_;(a=this.style.projection)===null||a===void 0||a.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||b)&&(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,b),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}),this.fire(new c.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,c.cG.mark(c.cH.load),this.fire(new c.l("load"))),this.style&&(this.style.hasTransitions()||x)&&(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.cG.mark(c.cH.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"&&removeEventListener("online",this._onWindowOnline,!1),dt.removeThrottleControl(this._imageQueueHandle),(d=this._resizeObserver)===null||d===void 0||d.disconnect();const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t!=null&&t.loseContext&&t.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),ge.remove(this._canvasContainer),ge.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),c.cG.clearMetrics(),this._removed=!0,this.fire(new c.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,rt.frame(this._frameRequest,(d=>{c.cG.frame(d),this._frameRequest=null;try{this._render(d)}catch(t){if(!c.Z(t)&&!(function(n){return n.message===Sl})(t))throw t}}),(()=>{})))}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 jl}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(d){return this._lazyInitEmptyStyle(),this.style.setProjection(d),this._update(!0)}},P.MapMouseEvent=Ji,P.MapTouchEvent=ma,P.MapWheelEvent=uu,P.Marker=Ma,P.NavigationControl=class{constructor(d){this._updateZoomButtons=()=>{const t=this._map.getZoom(),n=t===this._map.getMaxZoom(),a=t===this._map.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=a,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",a.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(t,n)=>{const a=this._map._getUIString(`NavigationControl.${n}`);t.title=a,t.setAttribute("aria-label",a)},this.options=c.e({},Nl,d),this._container=ge.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}))),ge.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}))),ge.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=ge.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 Sa(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){ge.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=ge.create("button",d,this._container);return n.type="button",n.addEventListener("click",t),n}},P.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&&ge.remove(this._content),this._container&&(ge.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=ge.create("div","maplibregl-popup",this._map.getContainer()),this._tip=ge.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=Po(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 a=this.options.anchor;const l=Eo(this.options.offset);if(!a){const m=this._container.offsetWidth,_=this._container.offsetHeight;let x;x=n.y+l.bottom.y<_?["top"]:n.y>this._map.transform.height-_?["bottom"]:[],n.x<m/2?x.push("left"):n.x>this._map.transform.width-m/2&&x.push("right"),a=x.length===0?"bottom":x.join("-")}let p=n.add(l[a]);this.options.subpixelPositioning||(p=p.round()),ge.setTransform(this._container,`${Pa[a]} translate(${p.x}px,${p.y}px)`),Mo(this._container,a,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=c.e(Object.create(ql),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 a;for(n.innerHTML=d;a=n.firstChild,a;)t.appendChild(a);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=ge.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}_createCloseButton(){this.options.closeButton&&(this._closeButton=ge.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const d=this._container.querySelector(Io);d&&d.focus()}},P.RasterDEMTileSource=gr,P.RasterTileSource=mr,P.ScaleControl=class{constructor(d){this._onMove=()=>{Ia(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,Ia(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},Gl),d)}getDefaultPosition(){return"bottom-left"}onAdd(d){return this._map=d,this._container=ge.create("div","maplibregl-ctrl maplibregl-ctrl-scale",d.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){ge.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},P.ScrollZoomHandler=vo,P.Style=Gn,P.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=ge.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=ge.create("button","maplibregl-ctrl-terrain",this._container),ge.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(){ge.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},P.TwoFingersTouchPitchHandler=fu,P.TwoFingersTouchRotateHandler=Ll,P.TwoFingersTouchZoomHandler=Fl,P.TwoFingersTouchZoomRotateHandler=va,P.VectorTileSource=Wt,P.VideoSource=ce,P.addSourceType=(d,t)=>c._(void 0,void 0,void 0,(function*(){if(U(d))throw new Error(`A source type called "${d}" already exists.`);((n,a)=>{O[n]=a})(d,t)})),P.clearPrewarmedResources=function(){const d=mi;d&&(d.isPreloaded()&&d.numActive()===1?(d.release(Yt),mi=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()"))},P.createTileMesh=Ic,P.getMaxParallelImageRequests=function(){return c.c.MAX_PARALLEL_IMAGE_REQUESTS},P.getRTLTextPluginStatus=function(){return de().getRTLTextPluginStatus()},P.getVersion=function(){return Zl},P.getWorkerCount=function(){return Tt.workerCount},P.getWorkerUrl=function(){return c.c.WORKER_URL},P.importScriptInWorkers=function(d){return ct().broadcast("IS",d)},P.isTimeFrozen=function(){return Ct.isFrozen()},P.now=Je,P.prewarm=function(){It().acquire(Yt)},P.restoreNow=function(){Ct.restoreNow()},P.setMaxParallelImageRequests=function(d){c.c.MAX_PARALLEL_IMAGE_REQUESTS=d},P.setNow=function(d){Ct.setNow(d)},P.setRTLTextPlugin=function(d,t){return de().setRTLTextPlugin(d,t)},P.setWorkerCount=function(d){Tt.workerCount=d},P.setWorkerUrl=function(d){c.c.WORKER_URL=d}}));var ue=D;return ue}))})(pc)),pc.exports}var zd=xm();const kd=Ad(zd);var $r=Uint8Array,Ba=Uint16Array,vm=Int32Array,Rd=new $r([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Fd=new $r([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),bm=new $r([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ld=function(F,C){for(var D=new Ba(31),$=0;$<31;++$)D[$]=C+=1<<F[$-1];for(var Q=new vm(D[30]),$=1;$<30;++$)for(var ue=D[$];ue<D[$+1];++ue)Q[ue]=ue-D[$]<<5|$;return{b:D,r:Q}},Bd=Ld(Rd,2),Od=Bd.b,wm=Bd.r;Od[28]=258,wm[258]=28;for(var Tm=Ld(Fd,0),Sm=Tm.b,Hu=new Ba(32768),Ai=0;Ai<32768;++Ai){var os=(Ai&43690)>>1|(Ai&21845)<<1;os=(os&52428)>>2|(os&13107)<<2,os=(os&61680)>>4|(os&3855)<<4,Hu[Ai]=((os&65280)>>8|(os&255)<<8)>>1}for(var Ho=(function(F,C,D){for(var $=F.length,Q=0,ue=new Ba(C);Q<$;++Q)F[Q]&&++ue[F[Q]-1];var P=new Ba(C);for(Q=1;Q<C;++Q)P[Q]=P[Q-1]+ue[Q-1]<<1;var c;if(D){c=new Ba(1<<C);var le=15-C;for(Q=0;Q<$;++Q)if(F[Q])for(var Pe=Q<<4|F[Q],Be=C-F[Q],Ne=P[F[Q]-1]++<<Be,Ye=Ne|(1<<Be)-1;Ne<=Ye;++Ne)c[Hu[Ne]>>le]=Pe}else for(c=new Ba($),Q=0;Q<$;++Q)F[Q]&&(c[Q]=Hu[P[F[Q]-1]++]>>15-F[Q]);return c}),Xo=new $r(288),Ai=0;Ai<144;++Ai)Xo[Ai]=8;for(var Ai=144;Ai<256;++Ai)Xo[Ai]=9;for(var Ai=256;Ai<280;++Ai)Xo[Ai]=7;for(var Ai=280;Ai<288;++Ai)Xo[Ai]=8;for(var Vd=new $r(32),Ai=0;Ai<32;++Ai)Vd[Ai]=5;var Pm=Ho(Xo,9,1),Mm=Ho(Vd,5,1),Xu=function(F){for(var C=F[0],D=1;D<F.length;++D)F[D]>C&&(C=F[D]);return C},dn=function(F,C,D){var $=C/8|0;return(F[$]|F[$+1]<<8)>>(C&7)&D},Yu=function(F,C){var D=C/8|0;return(F[D]|F[D+1]<<8|F[D+2]<<16)>>(C&7)},Im=function(F){return(F+7)/8|0},Em=function(F,C,D){return(D==null||D>F.length)&&(D=F.length),new $r(F.subarray(C,D))},Cm=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Wr=function(F,C,D){var $=new Error(C||Cm[F]);if($.code=F,Error.captureStackTrace&&Error.captureStackTrace($,Wr),!D)throw $;return $},Ku=function(F,C,D,$){var Q=F.length,ue=0;if(!Q||C.f&&!C.l)return D||new $r(0);var P=!D,c=P||C.i!=2,le=C.i;P&&(D=new $r(Q*3));var Pe=function(ct){var Rt=D.length;if(ct>Rt){var ri=new $r(Math.max(Rt*2,ct));ri.set(D),D=ri}},Be=C.f||0,Ne=C.p||0,Ye=C.b||0,rt=C.l,Ct=C.d,Je=C.m,ge=C.n,Xt=Q*8;do{if(!rt){Be=dn(F,Ne,1);var zt=dn(F,Ne+1,3);if(Ne+=3,zt)if(zt==1)rt=Pm,Ct=Mm,Je=9,ge=5;else if(zt==2){var Mi=dn(F,Ne,31)+257,dt=dn(F,Ne+10,15)+4,he=Mi+dn(F,Ne+5,31)+1;Ne+=14;for(var pe=new $r(he),De=new $r(19),Oe=0;Oe<dt;++Oe)De[bm[Oe]]=dn(F,Ne+Oe*3,7);Ne+=dt*3;for(var je=Xu(De),at=(1<<je)-1,jt=Ho(De,je,1),Oe=0;Oe<he;){var $t=jt[dn(F,Ne,at)];Ne+=$t&15;var st=$t>>4;if(st<16)pe[Oe++]=st;else{var ei=0,ot=0;for(st==16?(ot=3+dn(F,Ne,3),Ne+=2,ei=pe[Oe-1]):st==17?(ot=3+dn(F,Ne,7),Ne+=3):st==18&&(ot=11+dn(F,Ne,127),Ne+=7);ot--;)pe[Oe++]=ei}}var Nt=pe.subarray(0,Mi),Ze=pe.subarray(Mi);Je=Xu(Nt),ge=Xu(Ze),rt=Ho(Nt,Je,1),Ct=Ho(Ze,ge,1)}else Wr(1);else{var st=Im(Ne)+4,fi=F[st-4]|F[st-3]<<8,Qt=st+fi;if(Qt>Q){le&&Wr(0);break}c&&Pe(Ye+fi),D.set(F.subarray(st,Qt),Ye),C.b=Ye+=fi,C.p=Ne=Qt*8,C.f=Be;continue}if(Ne>Xt){le&&Wr(0);break}}c&&Pe(Ye+131072);for(var xi=(1<<Je)-1,ht=(1<<ge)-1,_t=Ne;;_t=Ne){var ei=rt[Yu(F,Ne)&xi],tt=ei>>4;if(Ne+=ei&15,Ne>Xt){le&&Wr(0);break}if(ei||Wr(2),tt<256)D[Ye++]=tt;else if(tt==256){_t=Ne,rt=null;break}else{var Yt=tt-254;if(tt>264){var Oe=tt-257,Tt=Rd[Oe];Yt=dn(F,Ne,(1<<Tt)-1)+Od[Oe],Ne+=Tt}var Ut=Ct[Yu(F,Ne)&ht],mi=Ut>>4;Ut||Wr(3),Ne+=Ut&15;var Ze=Sm[mi];if(mi>3){var Tt=Fd[mi];Ze+=Yu(F,Ne)&(1<<Tt)-1,Ne+=Tt}if(Ne>Xt){le&&Wr(0);break}c&&Pe(Ye+131072);var lt=Ye+Yt;if(Ye<Ze){var It=ue-Ze,Lt=Math.min(Ze,lt);for(It+Ye<0&&Wr(3);Ye<Lt;++Ye)D[Ye]=$[It+Ye]}for(;Ye<lt;++Ye)D[Ye]=D[Ye-Ze]}}C.l=rt,C.p=_t,C.b=Ye,C.f=Be,rt&&(Be=1,C.m=Je,C.d=Ct,C.n=ge)}while(!Be);return Ye!=D.length&&P?Em(D,0,Ye):D.subarray(0,Ye)},Am=new $r(0),Dm=function(F){(F[0]!=31||F[1]!=139||F[2]!=8)&&Wr(6,"invalid gzip data");var C=F[3],D=10;C&4&&(D+=(F[10]|F[11]<<8)+2);for(var $=(C>>3&1)+(C>>4&1);$>0;$-=!F[D++]);return D+(C&2)},zm=function(F){var C=F.length;return(F[C-4]|F[C-3]<<8|F[C-2]<<16|F[C-1]<<24)>>>0},km=function(F,C){return((F[0]&15)!=8||F[0]>>4>7||(F[0]<<8|F[1])%31)&&Wr(6,"invalid zlib data"),(F[1]>>5&1)==1&&Wr(6,"invalid zlib data: "+(F[1]&32?"need":"unexpected")+" dictionary"),(F[1]>>3&4)+2};function Rm(F,C){return Ku(F,{i:2},C,C)}function Fm(F,C){var D=Dm(F);return D+8>F.length&&Wr(6,"invalid gzip data"),Ku(F.subarray(D,-8),{i:2},new $r(zm(F)),C)}function Lm(F,C){return Ku(F.subarray(km(F),-4),{i:2},C,C)}function Bm(F,C){return F[0]==31&&F[1]==139&&F[2]==8?Fm(F,C):(F[0]&15)!=8||F[0]>>4>7||(F[0]<<8|F[1])%31?Rm(F,C):Lm(F,C)}var Om=typeof TextDecoder<"u"&&new TextDecoder,Vm=0;try{Om.decode(Am,{stream:!0}),Vm=1}catch{}var jm=Object.defineProperty,Yo=Math.pow,pi=(F,C)=>jm(F,"name",{value:C,configurable:!0}),cr=(F,C,D)=>new Promise(($,Q)=>{var ue=le=>{try{c(D.next(le))}catch(Pe){Q(Pe)}},P=le=>{try{c(D.throw(le))}catch(Pe){Q(Pe)}},c=le=>le.done?$(le.value):Promise.resolve(le.value).then(ue,P);c((D=D.apply(F,C)).next())});pi((F,C)=>{let D=!1,$="",Q=L.GridLayer.extend({createTile:pi((ue,P)=>{let c=document.createElement("img"),le=new AbortController,Pe=le.signal;return c.cancel=()=>{le.abort()},D||(F.getHeader().then(Be=>{Be.tileType===1?console.error("Error: archive contains MVT vector tiles, but leafletRasterLayer is for displaying raster tiles. See https://github.com/protomaps/PMTiles/tree/main/js for details."):Be.tileType===2?$="image/png":Be.tileType===3?$="image/jpeg":Be.tileType===4?$="image/webp":Be.tileType===5&&($="image/avif")}),D=!0),F.getZxy(ue.z,ue.x,ue.y,Pe).then(Be=>{if(Be){let Ne=new Blob([Be.data],{type:$}),Ye=window.URL.createObjectURL(Ne);c.src=Ye,c.cancel=void 0,P(void 0,c)}}).catch(Be=>{if(Be.name!=="AbortError")throw Be}),c},"createTile"),_removeTile:pi(function(ue){let P=this._tiles[ue];P&&(P.el.cancel&&P.el.cancel(),P.el.width=0,P.el.height=0,P.el.deleted=!0,L.DomUtil.remove(P.el),delete this._tiles[ue],this.fire("tileunload",{tile:P.el,coords:this._keyToTileCoords(ue)}))},"_removeTile")});return new Q(C)},"leafletRasterLayer");var Nm=pi(F=>(C,D)=>{if(D instanceof AbortController)return F(C,D);let $=new AbortController;return F(C,$).then(Q=>D(void 0,Q.data,Q.cacheControl||"",Q.expires||""),Q=>D(Q)).catch(Q=>D(Q)),{cancel:pi(()=>$.abort(),"cancel")}},"v3compat"),jd=class{constructor(C){this.tilev4=pi((D,$)=>cr(this,null,function*(){if(D.type==="json"){let rt=D.url.substr(10),Ct=this.tiles.get(rt);if(Ct||(Ct=new rh(rt),this.tiles.set(rt,Ct)),this.metadata)return{data:yield Ct.getTileJson(D.url)};let Je=yield Ct.getHeader();return(Je.minLon>=Je.maxLon||Je.minLat>=Je.maxLat)&&console.error(`Bounds of PMTiles archive ${Je.minLon},${Je.minLat},${Je.maxLon},${Je.maxLat} are not valid.`),{data:{tiles:[`${D.url}/{z}/{x}/{y}`],minzoom:Je.minZoom,maxzoom:Je.maxZoom,bounds:[Je.minLon,Je.minLat,Je.maxLon,Je.maxLat]}}}let Q=new RegExp(/pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)/),ue=D.url.match(Q);if(!ue)throw new Error("Invalid PMTiles protocol URL");let P=ue[1],c=this.tiles.get(P);c||(c=new rh(P),this.tiles.set(P,c));let le=ue[2],Pe=ue[3],Be=ue[4],Ne=yield c.getHeader(),Ye=yield c==null?void 0:c.getZxy(+le,+Pe,+Be,$.signal);if(Ye)return{data:new Uint8Array(Ye.data),cacheControl:Ye.cacheControl,expires:Ye.expires};if(Ne.tileType===1){if(this.errorOnMissingTile)throw new Error("Tile not found.");return{data:new Uint8Array}}return{data:null}}),"tilev4"),this.tile=Nm(this.tilev4),this.tiles=new Map,this.metadata=(C==null?void 0:C.metadata)||!1,this.errorOnMissingTile=(C==null?void 0:C.errorOnMissingTile)||!1}add(C){this.tiles.set(C.source.getKey(),C)}get(C){return this.tiles.get(C)}};pi(jd,"Protocol");var Um=jd;function Nd(F,C){return(C>>>0)*4294967296+(F>>>0)}pi(Nd,"toNum");function Ud(F,C){let D=C.buf,$=D[C.pos++],Q=($&112)>>4;if($<128||($=D[C.pos++],Q|=($&127)<<3,$<128)||($=D[C.pos++],Q|=($&127)<<10,$<128)||($=D[C.pos++],Q|=($&127)<<17,$<128)||($=D[C.pos++],Q|=($&127)<<24,$<128)||($=D[C.pos++],Q|=($&1)<<31,$<128))return Nd(F,Q);throw new Error("Expected varint not more than 10 bytes")}pi(Ud,"readVarintRemainder");function Oa(F){let C=F.buf,D=C[F.pos++],$=D&127;return D<128||(D=C[F.pos++],$|=(D&127)<<7,D<128)||(D=C[F.pos++],$|=(D&127)<<14,D<128)||(D=C[F.pos++],$|=(D&127)<<21,D<128)?$:(D=C[F.pos],$|=(D&15)<<28,Ud($,F))}pi(Oa,"readVarint");function Ju(F,C,D,$){if($===0){D===1&&(C[0]=F-1-C[0],C[1]=F-1-C[1]);let Q=C[0];C[0]=C[1],C[1]=Q}}pi(Ju,"rotate");function Gd(F,C){let D=Yo(2,F),$=C,Q=C,ue=C,P=[0,0],c=1;for(;c<D;)$=1&ue/2,Q=1&(ue^$),Ju(c,P,$,Q),P[0]+=c*$,P[1]+=c*Q,ue=ue/4,c*=2;return[F,P[0],P[1]]}pi(Gd,"idOnLevel");var Gm=[0,1,5,21,85,341,1365,5461,21845,87381,349525,1398101,5592405,22369621,89478485,357913941,1431655765,5726623061,22906492245,91625968981,366503875925,1466015503701,5864062014805,23456248059221,93824992236885,375299968947541,0x5555555555555];function qd(F,C,D){if(F>26)throw new Error("Tile zoom level exceeds max safe number limit (26)");if(C>Yo(2,F)-1||D>Yo(2,F)-1)throw new Error("tile x/y outside zoom level bounds");let $=Gm[F],Q=Yo(2,F),ue=0,P=0,c=0,le=[C,D],Pe=Q/2;for(;Pe>0;)ue=(le[0]&Pe)>0?1:0,P=(le[1]&Pe)>0?1:0,c+=Pe*Pe*(3*ue^P),Ju(Pe,le,ue,P),Pe=Pe/2;return $+c}pi(qd,"zxyToTileId");function qm(F){let C=0;for(let D=0;D<27;D++){let $=(1<<D)*(1<<D);if(C+$>F)return Gd(D,F-C);C+=$}throw new Error("Tile zoom level exceeds max safe number limit (26)")}pi(qm,"tileIdToZxy");var Zm=(F=>(F[F.Unknown=0]="Unknown",F[F.None=1]="None",F[F.Gzip=2]="Gzip",F[F.Brotli=3]="Brotli",F[F.Zstd=4]="Zstd",F))(Zm||{});function fc(F,C){return cr(this,null,function*(){if(C===1||C===0)return F;if(C===2){if(typeof globalThis.DecompressionStream>"u")return Bm(new Uint8Array(F));let D=new Response(F).body;if(!D)throw new Error("Failed to read response stream");let $=D.pipeThrough(new globalThis.DecompressionStream("gzip"));return new Response($).arrayBuffer()}throw new Error("Compression method not supported")})}pi(fc,"defaultDecompress");var $m=(F=>(F[F.Unknown=0]="Unknown",F[F.Mvt=1]="Mvt",F[F.Png=2]="Png",F[F.Jpeg=3]="Jpeg",F[F.Webp=4]="Webp",F[F.Avif=5]="Avif",F))($m||{});function Zd(F){return F===1?".mvt":F===2?".png":F===3?".jpg":F===4?".webp":F===5?".avif":""}pi(Zd,"tileTypeExt");var Wm=127;function $d(F,C){let D=0,$=F.length-1;for(;D<=$;){let Q=$+D>>1,ue=C-F[Q].tileId;if(ue>0)D=Q+1;else if(ue<0)$=Q-1;else return F[Q]}return $>=0&&(F[$].runLength===0||C-F[$].tileId<F[$].runLength)?F[$]:null}pi($d,"findTile");var Hm=class{constructor(C){this.file=C}getKey(){return this.file.name}getBytes(C,D){return cr(this,null,function*(){return{data:yield this.file.slice(C,C+D).arrayBuffer()}})}};pi(Hm,"FileSource");var Wd=class{constructor(C,D=new Headers){this.url=C,this.customHeaders=D,this.mustReload=!1;let $="";"navigator"in globalThis&&($=globalThis.navigator.userAgent||"");let Q=$.indexOf("Windows")>-1,ue=/Chrome|Chromium|Edg|OPR|Brave/.test($);this.chromeWindowsNoCache=!1,Q&&ue&&(this.chromeWindowsNoCache=!0)}getKey(){return this.url}setHeaders(C){this.customHeaders=C}getBytes(C,D,$,Q){return cr(this,null,function*(){let ue,P;$?P=$:(ue=new AbortController,P=ue.signal);let c=new Headers(this.customHeaders);c.set("range",`bytes=${C}-${C+D-1}`);let le;this.mustReload?le="reload":this.chromeWindowsNoCache&&(le="no-store");let Pe=yield fetch(this.url,{signal:P,cache:le,headers:c});if(C===0&&Pe.status===416){let Ye=Pe.headers.get("Content-Range");if(!Ye||!Ye.startsWith("bytes */"))throw new Error("Missing content-length on 416 response");let rt=+Ye.substr(8);Pe=yield fetch(this.url,{signal:P,cache:"reload",headers:{range:`bytes=0-${rt-1}`}})}let Be=Pe.headers.get("Etag");if(Be!=null&&Be.startsWith("W/")&&(Be=null),Pe.status===416||Q&&Be&&Be!==Q)throw this.mustReload=!0,new eh(`Server returned non-matching ETag ${Q} after one retry. Check browser extensions and servers for issues that may affect correct ETag headers.`);if(Pe.status>=300)throw new Error(`Bad response code: ${Pe.status}`);let Ne=Pe.headers.get("Content-Length");if(Pe.status===200&&(!Ne||+Ne>D))throw ue&&ue.abort(),new Error("Server returned no content-length header or content-length exceeding request. Check that your storage backend supports HTTP Byte Serving.");return{data:yield Pe.arrayBuffer(),etag:Be||void 0,cacheControl:Pe.headers.get("Cache-Control")||void 0,expires:Pe.headers.get("Expires")||void 0}})}};pi(Wd,"FetchSource");var Xm=Wd;function an(F,C){let D=F.getUint32(C+4,!0),$=F.getUint32(C+0,!0);return D*Yo(2,32)+$}pi(an,"getUint64");function Hd(F,C){let D=new DataView(F),$=D.getUint8(7);if($>3)throw new Error(`Archive is spec version ${$} but this library supports up to spec version 3`);return{specVersion:$,rootDirectoryOffset:an(D,8),rootDirectoryLength:an(D,16),jsonMetadataOffset:an(D,24),jsonMetadataLength:an(D,32),leafDirectoryOffset:an(D,40),leafDirectoryLength:an(D,48),tileDataOffset:an(D,56),tileDataLength:an(D,64),numAddressedTiles:an(D,72),numTileEntries:an(D,80),numTileContents:an(D,88),clustered:D.getUint8(96)===1,internalCompression:D.getUint8(97),tileCompression:D.getUint8(98),tileType:D.getUint8(99),minZoom:D.getUint8(100),maxZoom:D.getUint8(101),minLon:D.getInt32(102,!0)/1e7,minLat:D.getInt32(106,!0)/1e7,maxLon:D.getInt32(110,!0)/1e7,maxLat:D.getInt32(114,!0)/1e7,centerZoom:D.getUint8(118),centerLon:D.getInt32(119,!0)/1e7,centerLat:D.getInt32(123,!0)/1e7,etag:C}}pi(Hd,"bytesToHeader");function Qu(F){let C={buf:new Uint8Array(F),pos:0},D=Oa(C),$=[],Q=0;for(let ue=0;ue<D;ue++){let P=Oa(C);$.push({tileId:Q+P,offset:0,length:0,runLength:1}),Q+=P}for(let ue=0;ue<D;ue++)$[ue].runLength=Oa(C);for(let ue=0;ue<D;ue++)$[ue].length=Oa(C);for(let ue=0;ue<D;ue++){let P=Oa(C);P===0&&ue>0?$[ue].offset=$[ue-1].offset+$[ue-1].length:$[ue].offset=P-1}return $}pi(Qu,"deserializeIndex");var Xd=class extends Error{};pi(Xd,"EtagMismatch");var eh=Xd;function th(F,C){return cr(this,null,function*(){let D=yield F.getBytes(0,16384);if(new DataView(D.data).getUint16(0,!0)!==19792)throw new Error("Wrong magic number for PMTiles archive");let $=D.data.slice(0,Wm),Q=Hd($,D.etag),ue=D.data.slice(Q.rootDirectoryOffset,Q.rootDirectoryOffset+Q.rootDirectoryLength),P=`${F.getKey()}|${Q.etag||""}|${Q.rootDirectoryOffset}|${Q.rootDirectoryLength}`,c=Qu(yield C(ue,Q.internalCompression));return[Q,[P,c.length,c]]})}pi(th,"getHeaderAndRoot");function ih(F,C,D,$,Q){return cr(this,null,function*(){let ue=yield F.getBytes(D,$,void 0,Q.etag),P=yield C(ue.data,Q.internalCompression),c=Qu(P);if(c.length===0)throw new Error("Empty directory is invalid");return c})}pi(ih,"getDirectory");var Ym=class{constructor(C=100,D=!0,$=fc){this.cache=new Map,this.maxCacheEntries=C,this.counter=1,this.decompress=$}getHeader(C){return cr(this,null,function*(){let D=C.getKey(),$=this.cache.get(D);if($)return $.lastUsed=this.counter++,$.data;let Q=yield th(C,this.decompress);return Q[1]&&this.cache.set(Q[1][0],{lastUsed:this.counter++,data:Q[1][2]}),this.cache.set(D,{lastUsed:this.counter++,data:Q[0]}),this.prune(),Q[0]})}getDirectory(C,D,$,Q){return cr(this,null,function*(){let ue=`${C.getKey()}|${Q.etag||""}|${D}|${$}`,P=this.cache.get(ue);if(P)return P.lastUsed=this.counter++,P.data;let c=yield ih(C,this.decompress,D,$,Q);return this.cache.set(ue,{lastUsed:this.counter++,data:c}),this.prune(),c})}prune(){if(this.cache.size>this.maxCacheEntries){let C=1/0,D;this.cache.forEach(($,Q)=>{$.lastUsed<C&&(C=$.lastUsed,D=Q)}),D&&this.cache.delete(D)}}invalidate(C){return cr(this,null,function*(){this.cache.delete(C.getKey())})}};pi(Ym,"ResolvedValueCache");var Yd=class{constructor(C=100,D=!0,$=fc){this.cache=new Map,this.invalidations=new Map,this.maxCacheEntries=C,this.counter=1,this.decompress=$}getHeader(C){return cr(this,null,function*(){let D=C.getKey(),$=this.cache.get(D);if($)return $.lastUsed=this.counter++,yield $.data;let Q=new Promise((ue,P)=>{th(C,this.decompress).then(c=>{c[1]&&this.cache.set(c[1][0],{lastUsed:this.counter++,data:Promise.resolve(c[1][2])}),ue(c[0]),this.prune()}).catch(c=>{P(c)})});return this.cache.set(D,{lastUsed:this.counter++,data:Q}),Q})}getDirectory(C,D,$,Q){return cr(this,null,function*(){let ue=`${C.getKey()}|${Q.etag||""}|${D}|${$}`,P=this.cache.get(ue);if(P)return P.lastUsed=this.counter++,yield P.data;let c=new Promise((le,Pe)=>{ih(C,this.decompress,D,$,Q).then(Be=>{le(Be),this.prune()}).catch(Be=>{Pe(Be)})});return this.cache.set(ue,{lastUsed:this.counter++,data:c}),c})}prune(){if(this.cache.size>=this.maxCacheEntries){let C=1/0,D;this.cache.forEach(($,Q)=>{$.lastUsed<C&&(C=$.lastUsed,D=Q)}),D&&this.cache.delete(D)}}invalidate(C){return cr(this,null,function*(){let D=C.getKey();if(this.invalidations.get(D))return yield this.invalidations.get(D);this.cache.delete(C.getKey());let $=new Promise((Q,ue)=>{this.getHeader(C).then(P=>{Q(),this.invalidations.delete(D)}).catch(P=>{ue(P)})});this.invalidations.set(D,$)})}};pi(Yd,"SharedPromiseCache");var Km=Yd,Kd=class{constructor(C,D,$){typeof C=="string"?this.source=new Xm(C):this.source=C,$?this.decompress=$:this.decompress=fc,D?this.cache=D:this.cache=new Km}getHeader(){return cr(this,null,function*(){return yield this.cache.getHeader(this.source)})}getZxyAttempt(C,D,$,Q){return cr(this,null,function*(){let ue=qd(C,D,$),P=yield this.cache.getHeader(this.source);if(C<P.minZoom||C>P.maxZoom)return;let c=P.rootDirectoryOffset,le=P.rootDirectoryLength;for(let Pe=0;Pe<=3;Pe++){let Be=yield this.cache.getDirectory(this.source,c,le,P),Ne=$d(Be,ue);if(Ne){if(Ne.runLength>0){let Ye=yield this.source.getBytes(P.tileDataOffset+Ne.offset,Ne.length,Q,P.etag);return{data:yield this.decompress(Ye.data,P.tileCompression),cacheControl:Ye.cacheControl,expires:Ye.expires}}c=P.leafDirectoryOffset+Ne.offset,le=Ne.length}else return}throw new Error("Maximum directory depth exceeded")})}getZxy(C,D,$,Q){return cr(this,null,function*(){try{return yield this.getZxyAttempt(C,D,$,Q)}catch(ue){if(ue instanceof eh)return this.cache.invalidate(this.source),yield this.getZxyAttempt(C,D,$,Q);throw ue}})}getMetadataAttempt(){return cr(this,null,function*(){let C=yield this.cache.getHeader(this.source),D=yield this.source.getBytes(C.jsonMetadataOffset,C.jsonMetadataLength,void 0,C.etag),$=yield this.decompress(D.data,C.internalCompression),Q=new TextDecoder("utf-8");return JSON.parse(Q.decode($))})}getMetadata(){return cr(this,null,function*(){try{return yield this.getMetadataAttempt()}catch(C){if(C instanceof eh)return this.cache.invalidate(this.source),yield this.getMetadataAttempt();throw C}})}getTileJson(C){return cr(this,null,function*(){let D=yield this.getHeader(),$=yield this.getMetadata(),Q=Zd(D.tileType);return{tilejson:"3.0.0",scheme:"xyz",tiles:[`${C}/{z}/{x}/{y}${Q}`],vector_layers:$.vector_layers,attribution:$.attribution,description:$.description,name:$.name,version:$.version,bounds:[D.minLon,D.minLat,D.maxLon,D.maxLat],center:[D.centerLon,D.centerLat,D.centerZoom],minzoom:D.minZoom,maxzoom:D.maxZoom}})}};pi(Kd,"PMTiles");var rh=Kd,mc={exports:{}};/* @license
809
+ Papa Parse
810
+ v5.5.3
811
+ https://github.com/mholt/PapaParse
812
+ License: MIT
813
+ */var Jm=mc.exports,Jd;function Qm(){return Jd||(Jd=1,(function(F,C){((D,$)=>{F.exports=$()})(Jm,function D(){var $=typeof self<"u"?self:typeof window<"u"?window:$!==void 0?$:{},Q,ue=!$.document&&!!$.postMessage,P=$.IS_PAPA_WORKER||!1,c={},le=0,Pe={};function Be(he){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},(function(pe){var De=Qt(pe);De.chunkSize=parseInt(De.chunkSize),pe.step||pe.chunk||(De.chunkSize=null),this._handle=new Je(De),(this._handle.streamer=this)._config=De}).call(this,he),this.parseChunk=function(pe,De){var Oe=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0<Oe){let at=this._config.newline;at||(je=this._config.quoteChar||'"',at=this._handle.guessLineEndings(pe,je)),pe=[...pe.split(at).slice(Oe)].join(at)}this.isFirstChunk&&dt(this._config.beforeFirstChunk)&&(je=this._config.beforeFirstChunk(pe))!==void 0&&(pe=je),this.isFirstChunk=!1,this._halted=!1;var Oe=this._partialLine+pe,je=(this._partialLine="",this._handle.parse(Oe,this._baseIndex,!this._finished));if(!this._handle.paused()&&!this._handle.aborted()){if(pe=je.meta.cursor,Oe=(this._finished||(this._partialLine=Oe.substring(pe-this._baseIndex),this._baseIndex=pe),je&&je.data&&(this._rowCount+=je.data.length),this._finished||this._config.preview&&this._rowCount>=this._config.preview),P)$.postMessage({results:je,workerId:Pe.WORKER_ID,finished:Oe});else if(dt(this._config.chunk)&&!De){if(this._config.chunk(je,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=je=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(je.data),this._completeResults.errors=this._completeResults.errors.concat(je.errors),this._completeResults.meta=je.meta),this._completed||!Oe||!dt(this._config.complete)||je&&je.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),Oe||je&&je.meta.paused||this._nextChunk(),je}this._halted=!0},this._sendError=function(pe){dt(this._config.error)?this._config.error(pe):P&&this._config.error&&$.postMessage({workerId:Pe.WORKER_ID,error:pe,finished:!1})}}function Ne(he){var pe;(he=he||{}).chunkSize||(he.chunkSize=Pe.RemoteChunkSize),Be.call(this,he),this._nextChunk=ue?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(De){this._input=De,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(pe=new XMLHttpRequest,this._config.withCredentials&&(pe.withCredentials=this._config.withCredentials),ue||(pe.onload=Mi(this._chunkLoaded,this),pe.onerror=Mi(this._chunkError,this)),pe.open(this._config.downloadRequestBody?"POST":"GET",this._input,!ue),this._config.downloadRequestHeaders){var De,Oe=this._config.downloadRequestHeaders;for(De in Oe)pe.setRequestHeader(De,Oe[De])}var je;this._config.chunkSize&&(je=this._start+this._config.chunkSize-1,pe.setRequestHeader("Range","bytes="+this._start+"-"+je));try{pe.send(this._config.downloadRequestBody)}catch(at){this._chunkError(at.message)}ue&&pe.status===0&&this._chunkError()}},this._chunkLoaded=function(){pe.readyState===4&&(pe.status<200||400<=pe.status?this._chunkError():(this._start+=this._config.chunkSize||pe.responseText.length,this._finished=!this._config.chunkSize||this._start>=(De=>(De=De.getResponseHeader("Content-Range"))!==null?parseInt(De.substring(De.lastIndexOf("/")+1)):-1)(pe),this.parseChunk(pe.responseText)))},this._chunkError=function(De){De=pe.statusText||De,this._sendError(new Error(De))}}function Ye(he){(he=he||{}).chunkSize||(he.chunkSize=Pe.LocalChunkSize),Be.call(this,he);var pe,De,Oe=typeof FileReader<"u";this.stream=function(je){this._input=je,De=je.slice||je.webkitSlice||je.mozSlice,Oe?((pe=new FileReader).onload=Mi(this._chunkLoaded,this),pe.onerror=Mi(this._chunkError,this)):pe=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount<this._config.preview)||this._readChunk()},this._readChunk=function(){var je=this._input,at=(this._config.chunkSize&&(at=Math.min(this._start+this._config.chunkSize,this._input.size),je=De.call(je,this._start,at)),pe.readAsText(je,this._config.encoding));Oe||this._chunkLoaded({target:{result:at}})},this._chunkLoaded=function(je){this._start+=this._config.chunkSize,this._finished=!this._config.chunkSize||this._start>=this._input.size,this.parseChunk(je.target.result)},this._chunkError=function(){this._sendError(pe.error)}}function rt(he){var pe;Be.call(this,he=he||{}),this.stream=function(De){return pe=De,this._nextChunk()},this._nextChunk=function(){var De,Oe;if(!this._finished)return De=this._config.chunkSize,pe=De?(Oe=pe.substring(0,De),pe.substring(De)):(Oe=pe,""),this._finished=!pe,this.parseChunk(Oe)}}function Ct(he){Be.call(this,he=he||{});var pe=[],De=!0,Oe=!1;this.pause=function(){Be.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){Be.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(je){this._input=je,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){Oe&&pe.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),pe.length?this.parseChunk(pe.shift()):De=!0},this._streamData=Mi(function(je){try{pe.push(typeof je=="string"?je:je.toString(this._config.encoding)),De&&(De=!1,this._checkIsFinished(),this.parseChunk(pe.shift()))}catch(at){this._streamError(at)}},this),this._streamError=Mi(function(je){this._streamCleanUp(),this._sendError(je)},this),this._streamEnd=Mi(function(){this._streamCleanUp(),Oe=!0,this._streamData("")},this),this._streamCleanUp=Mi(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function Je(he){var pe,De,Oe,je,at=Math.pow(2,53),jt=-at,$t=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,ei=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,ot=this,Nt=0,Ze=0,xi=!1,ht=!1,_t=[],tt={data:[],errors:[],meta:{}};function Yt(lt){return he.skipEmptyLines==="greedy"?lt.join("").trim()==="":lt.length===1&&lt[0].length===0}function Tt(){if(tt&&Oe&&(mi("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+Pe.DefaultDelimiter+"'"),Oe=!1),he.skipEmptyLines&&(tt.data=tt.data.filter(function(ct){return!Yt(ct)})),Ut()){let ct=function(Rt,ri){dt(he.transformHeader)&&(Rt=he.transformHeader(Rt,ri)),_t.push(Rt)};if(tt)if(Array.isArray(tt.data[0])){for(var lt=0;Ut()&&lt<tt.data.length;lt++)tt.data[lt].forEach(ct);tt.data.splice(0,1)}else tt.data.forEach(ct)}function It(ct,Rt){for(var ri=he.header?{}:[],yt=0;yt<ct.length;yt++){var kt=yt,xt=ct[yt],xt=((Vt,pt)=>(Wt=>(he.dynamicTypingFunction&&he.dynamicTyping[Wt]===void 0&&(he.dynamicTyping[Wt]=he.dynamicTypingFunction(Wt)),(he.dynamicTyping[Wt]||he.dynamicTyping)===!0))(Vt)?pt==="true"||pt==="TRUE"||pt!=="false"&&pt!=="FALSE"&&((Wt=>{if($t.test(Wt)&&(Wt=parseFloat(Wt),jt<Wt&&Wt<at))return 1})(pt)?parseFloat(pt):ei.test(pt)?new Date(pt):pt===""?null:pt):pt)(kt=he.header?yt>=_t.length?"__parsed_extra":_t[yt]:kt,xt=he.transform?he.transform(xt,kt):xt);kt==="__parsed_extra"?(ri[kt]=ri[kt]||[],ri[kt].push(xt)):ri[kt]=xt}return he.header&&(yt>_t.length?mi("FieldMismatch","TooManyFields","Too many fields: expected "+_t.length+" fields but parsed "+yt,Ze+Rt):yt<_t.length&&mi("FieldMismatch","TooFewFields","Too few fields: expected "+_t.length+" fields but parsed "+yt,Ze+Rt)),ri}var Lt;tt&&(he.header||he.dynamicTyping||he.transform)&&(Lt=1,!tt.data.length||Array.isArray(tt.data[0])?(tt.data=tt.data.map(It),Lt=tt.data.length):tt.data=It(tt.data,0),he.header&&tt.meta&&(tt.meta.fields=_t),Ze+=Lt)}function Ut(){return he.header&&_t.length===0}function mi(lt,It,Lt,ct){lt={type:lt,code:It,message:Lt},ct!==void 0&&(lt.row=ct),tt.errors.push(lt)}dt(he.step)&&(je=he.step,he.step=function(lt){tt=lt,Ut()?Tt():(Tt(),tt.data.length!==0&&(Nt+=lt.data.length,he.preview&&Nt>he.preview?De.abort():(tt.data=tt.data[0],je(tt,ot))))}),this.parse=function(lt,It,Lt){var ct=he.quoteChar||'"',ct=(he.newline||(he.newline=this.guessLineEndings(lt,ct)),Oe=!1,he.delimiter?dt(he.delimiter)&&(he.delimiter=he.delimiter(lt),tt.meta.delimiter=he.delimiter):((ct=((Rt,ri,yt,kt,xt)=>{var Vt,pt,Wt,mr;xt=xt||[","," ","|",";",Pe.RECORD_SEP,Pe.UNIT_SEP];for(var gr=0;gr<xt.length;gr++){for(var Oi,Or=xt[gr],Di=0,vi=0,ce=0,B=(Wt=void 0,new Xt({comments:kt,delimiter:Or,newline:ri,preview:10}).parse(Rt)),O=0;O<B.data.length;O++)yt&&Yt(B.data[O])?ce++:(Oi=B.data[O].length,vi+=Oi,Wt===void 0?Wt=Oi:0<Oi&&(Di+=Math.abs(Oi-Wt),Wt=Oi));0<B.data.length&&(vi/=B.data.length-ce),(pt===void 0||Di<=pt)&&(mr===void 0||mr<vi)&&1.99<vi&&(pt=Di,Vt=Or,mr=vi)}return{successful:!!(he.delimiter=Vt),bestDelimiter:Vt}})(lt,he.newline,he.skipEmptyLines,he.comments,he.delimitersToGuess)).successful?he.delimiter=ct.bestDelimiter:(Oe=!0,he.delimiter=Pe.DefaultDelimiter),tt.meta.delimiter=he.delimiter),Qt(he));return he.preview&&he.header&&ct.preview++,pe=lt,De=new Xt(ct),tt=De.parse(pe,It,Lt),Tt(),xi?{meta:{paused:!0}}:tt||{meta:{paused:!1}}},this.paused=function(){return xi},this.pause=function(){xi=!0,De.abort(),pe=dt(he.chunk)?"":pe.substring(De.getCharIndex())},this.resume=function(){ot.streamer._halted?(xi=!1,ot.streamer.parseChunk(pe,!0)):setTimeout(ot.resume,3)},this.aborted=function(){return ht},this.abort=function(){ht=!0,De.abort(),tt.meta.aborted=!0,dt(he.complete)&&he.complete(tt),pe=""},this.guessLineEndings=function(Rt,ct){Rt=Rt.substring(0,1048576);var ct=new RegExp(ge(ct)+"([^]*?)"+ge(ct),"gm"),Lt=(Rt=Rt.replace(ct,"")).split("\r"),ct=Rt.split(`
814
+ `),Rt=1<ct.length&&ct[0].length<Lt[0].length;if(Lt.length===1||Rt)return`
815
+ `;for(var ri=0,yt=0;yt<Lt.length;yt++)Lt[yt][0]===`
816
+ `&&ri++;return ri>=Lt.length/2?`\r
817
+ `:"\r"}}function ge(he){return he.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Xt(he){var pe=(he=he||{}).delimiter,De=he.newline,Oe=he.comments,je=he.step,at=he.preview,jt=he.fastMode,$t=null,ei=!1,ot=he.quoteChar==null?'"':he.quoteChar,Nt=ot;if(he.escapeChar!==void 0&&(Nt=he.escapeChar),(typeof pe!="string"||-1<Pe.BAD_DELIMITERS.indexOf(pe))&&(pe=","),Oe===pe)throw new Error("Comment character same as delimiter");Oe===!0?Oe="#":(typeof Oe!="string"||-1<Pe.BAD_DELIMITERS.indexOf(Oe))&&(Oe=!1),De!==`
818
+ `&&De!=="\r"&&De!==`\r
819
+ `&&(De=`
820
+ `);var Ze=0,xi=!1;this.parse=function(ht,_t,tt){if(typeof ht!="string")throw new Error("Input must be a string");var Yt=ht.length,Tt=pe.length,Ut=De.length,mi=Oe.length,lt=dt(je),It=[],Lt=[],ct=[],Rt=Ze=0;if(!ht)return Di();if(jt||jt!==!1&&ht.indexOf(ot)===-1){for(var ri=ht.split(De),yt=0;yt<ri.length;yt++){if(ct=ri[yt],Ze+=ct.length,yt!==ri.length-1)Ze+=De.length;else if(tt)return Di();if(!Oe||ct.substring(0,mi)!==Oe){if(lt){if(It=[],mr(ct.split(pe)),vi(),xi)return Di()}else mr(ct.split(pe));if(at&&at<=yt)return It=It.slice(0,at),Di(!0)}}return Di()}for(var kt=ht.indexOf(pe,Ze),xt=ht.indexOf(De,Ze),Vt=new RegExp(ge(Nt)+ge(ot),"g"),pt=ht.indexOf(ot,Ze);;)if(ht[Ze]===ot)for(pt=Ze,Ze++;;){if((pt=ht.indexOf(ot,pt+1))===-1)return tt||Lt.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:It.length,index:Ze}),Oi();if(pt===Yt-1)return Oi(ht.substring(Ze,pt).replace(Vt,ot));if(ot===Nt&&ht[pt+1]===Nt)pt++;else if(ot===Nt||pt===0||ht[pt-1]!==Nt){kt!==-1&&kt<pt+1&&(kt=ht.indexOf(pe,pt+1));var Wt=gr((xt=xt!==-1&&xt<pt+1?ht.indexOf(De,pt+1):xt)===-1?kt:Math.min(kt,xt));if(ht.substr(pt+1+Wt,Tt)===pe){ct.push(ht.substring(Ze,pt).replace(Vt,ot)),ht[Ze=pt+1+Wt+Tt]!==ot&&(pt=ht.indexOf(ot,Ze)),kt=ht.indexOf(pe,Ze),xt=ht.indexOf(De,Ze);break}if(Wt=gr(xt),ht.substring(pt+1+Wt,pt+1+Wt+Ut)===De){if(ct.push(ht.substring(Ze,pt).replace(Vt,ot)),Or(pt+1+Wt+Ut),kt=ht.indexOf(pe,Ze),pt=ht.indexOf(ot,Ze),lt&&(vi(),xi))return Di();if(at&&It.length>=at)return Di(!0);break}Lt.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:It.length,index:Ze}),pt++}}else if(Oe&&ct.length===0&&ht.substring(Ze,Ze+mi)===Oe){if(xt===-1)return Di();Ze=xt+Ut,xt=ht.indexOf(De,Ze),kt=ht.indexOf(pe,Ze)}else if(kt!==-1&&(kt<xt||xt===-1))ct.push(ht.substring(Ze,kt)),Ze=kt+Tt,kt=ht.indexOf(pe,Ze);else{if(xt===-1)break;if(ct.push(ht.substring(Ze,xt)),Or(xt+Ut),lt&&(vi(),xi))return Di();if(at&&It.length>=at)return Di(!0)}return Oi();function mr(ce){It.push(ce),Rt=Ze}function gr(ce){var B=0;return B=ce!==-1&&(ce=ht.substring(pt+1,ce))&&ce.trim()===""?ce.length:B}function Oi(ce){return tt||(ce===void 0&&(ce=ht.substring(Ze)),ct.push(ce),Ze=Yt,mr(ct),lt&&vi()),Di()}function Or(ce){Ze=ce,mr(ct),ct=[],xt=ht.indexOf(De,Ze)}function Di(ce){if(he.header&&!_t&&It.length&&!ei){var B=It[0],O=Object.create(null),U=new Set(B);let re=!1;for(let ne=0;ne<B.length;ne++){let fe=B[ne];if(O[fe=dt(he.transformHeader)?he.transformHeader(fe,ne):fe]){let de,ae=O[fe];for(;de=fe+"_"+ae,ae++,U.has(de););U.add(de),B[ne]=de,O[fe]++,re=!0,($t=$t===null?{}:$t)[de]=fe}else O[fe]=1,B[ne]=fe;U.add(fe)}re&&console.warn("Duplicate headers found and renamed."),ei=!0}return{data:It,errors:Lt,meta:{delimiter:pe,linebreak:De,aborted:xi,truncated:!!ce,cursor:Rt+(_t||0),renamedHeaders:$t}}}function vi(){je(Di()),It=[],Lt=[]}},this.abort=function(){xi=!0},this.getCharIndex=function(){return Ze}}function zt(he){var pe=he.data,De=c[pe.workerId],Oe=!1;if(pe.error)De.userError(pe.error,pe.file);else if(pe.results&&pe.results.data){var je={abort:function(){Oe=!0,st(pe.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:fi,resume:fi};if(dt(De.userStep)){for(var at=0;at<pe.results.data.length&&(De.userStep({data:pe.results.data[at],errors:pe.results.errors,meta:pe.results.meta},je),!Oe);at++);delete pe.results}else dt(De.userChunk)&&(De.userChunk(pe.results,je,pe.file),delete pe.results)}pe.finished&&!Oe&&st(pe.workerId,pe.results)}function st(he,pe){var De=c[he];dt(De.userComplete)&&De.userComplete(pe),De.terminate(),delete c[he]}function fi(){throw new Error("Not implemented.")}function Qt(he){if(typeof he!="object"||he===null)return he;var pe,De=Array.isArray(he)?[]:{};for(pe in he)De[pe]=Qt(he[pe]);return De}function Mi(he,pe){return function(){he.apply(pe,arguments)}}function dt(he){return typeof he=="function"}return Pe.parse=function(he,pe){var De=(pe=pe||{}).dynamicTyping||!1;if(dt(De)&&(pe.dynamicTypingFunction=De,De={}),pe.dynamicTyping=De,pe.transform=!!dt(pe.transform)&&pe.transform,!pe.worker||!Pe.WORKERS_SUPPORTED)return De=null,Pe.NODE_STREAM_INPUT,typeof he=="string"?(he=(Oe=>Oe.charCodeAt(0)!==65279?Oe:Oe.slice(1))(he),De=new(pe.download?Ne:rt)(pe)):he.readable===!0&&dt(he.read)&&dt(he.on)?De=new Ct(pe):($.File&&he instanceof File||he instanceof Object)&&(De=new Ye(pe)),De.stream(he);(De=(()=>{var Oe;return!!Pe.WORKERS_SUPPORTED&&(Oe=(()=>{var je=$.URL||$.webkitURL||null,at=D.toString();return Pe.BLOB_URL||(Pe.BLOB_URL=je.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",at,")();"],{type:"text/javascript"})))})(),(Oe=new $.Worker(Oe)).onmessage=zt,Oe.id=le++,c[Oe.id]=Oe)})()).userStep=pe.step,De.userChunk=pe.chunk,De.userComplete=pe.complete,De.userError=pe.error,pe.step=dt(pe.step),pe.chunk=dt(pe.chunk),pe.complete=dt(pe.complete),pe.error=dt(pe.error),delete pe.worker,De.postMessage({input:he,config:pe,workerId:De.id})},Pe.unparse=function(he,pe){var De=!1,Oe=!0,je=",",at=`\r
821
+ `,jt='"',$t=jt+jt,ei=!1,ot=null,Nt=!1,Ze=((()=>{if(typeof pe=="object"){if(typeof pe.delimiter!="string"||Pe.BAD_DELIMITERS.filter(function(_t){return pe.delimiter.indexOf(_t)!==-1}).length||(je=pe.delimiter),typeof pe.quotes!="boolean"&&typeof pe.quotes!="function"&&!Array.isArray(pe.quotes)||(De=pe.quotes),typeof pe.skipEmptyLines!="boolean"&&typeof pe.skipEmptyLines!="string"||(ei=pe.skipEmptyLines),typeof pe.newline=="string"&&(at=pe.newline),typeof pe.quoteChar=="string"&&(jt=pe.quoteChar),typeof pe.header=="boolean"&&(Oe=pe.header),Array.isArray(pe.columns)){if(pe.columns.length===0)throw new Error("Option columns is empty");ot=pe.columns}pe.escapeChar!==void 0&&($t=pe.escapeChar+jt),pe.escapeFormulae instanceof RegExp?Nt=pe.escapeFormulae:typeof pe.escapeFormulae=="boolean"&&pe.escapeFormulae&&(Nt=/^[=+\-@\t\r].*$/)}})(),new RegExp(ge(jt),"g"));if(typeof he=="string"&&(he=JSON.parse(he)),Array.isArray(he)){if(!he.length||Array.isArray(he[0]))return xi(null,he,ei);if(typeof he[0]=="object")return xi(ot||Object.keys(he[0]),he,ei)}else if(typeof he=="object")return typeof he.data=="string"&&(he.data=JSON.parse(he.data)),Array.isArray(he.data)&&(he.fields||(he.fields=he.meta&&he.meta.fields||ot),he.fields||(he.fields=Array.isArray(he.data[0])?he.fields:typeof he.data[0]=="object"?Object.keys(he.data[0]):[]),Array.isArray(he.data[0])||typeof he.data[0]=="object"||(he.data=[he.data])),xi(he.fields||[],he.data||[],ei);throw new Error("Unable to serialize unrecognized input");function xi(_t,tt,Yt){var Tt="",Ut=(typeof _t=="string"&&(_t=JSON.parse(_t)),typeof tt=="string"&&(tt=JSON.parse(tt)),Array.isArray(_t)&&0<_t.length),mi=!Array.isArray(tt[0]);if(Ut&&Oe){for(var lt=0;lt<_t.length;lt++)0<lt&&(Tt+=je),Tt+=ht(_t[lt],lt);0<tt.length&&(Tt+=at)}for(var It=0;It<tt.length;It++){var Lt=(Ut?_t:tt[It]).length,ct=!1,Rt=Ut?Object.keys(tt[It]).length===0:tt[It].length===0;if(Yt&&!Ut&&(ct=Yt==="greedy"?tt[It].join("").trim()==="":tt[It].length===1&&tt[It][0].length===0),Yt==="greedy"&&Ut){for(var ri=[],yt=0;yt<Lt;yt++){var kt=mi?_t[yt]:yt;ri.push(tt[It][kt])}ct=ri.join("").trim()===""}if(!ct){for(var xt=0;xt<Lt;xt++){0<xt&&!Rt&&(Tt+=je);var Vt=Ut&&mi?_t[xt]:xt;Tt+=ht(tt[It][Vt],xt)}It<tt.length-1&&(!Yt||0<Lt&&!Rt)&&(Tt+=at)}}return Tt}function ht(_t,tt){var Yt,Tt;return _t==null?"":_t.constructor===Date?JSON.stringify(_t).slice(1,25):(Tt=!1,Nt&&typeof _t=="string"&&Nt.test(_t)&&(_t="'"+_t,Tt=!0),Yt=_t.toString().replace(Ze,$t),(Tt=Tt||De===!0||typeof De=="function"&&De(_t,tt)||Array.isArray(De)&&De[tt]||((Ut,mi)=>{for(var lt=0;lt<mi.length;lt++)if(-1<Ut.indexOf(mi[lt]))return!0;return!1})(Yt,Pe.BAD_DELIMITERS)||-1<Yt.indexOf(je)||Yt.charAt(0)===" "||Yt.charAt(Yt.length-1)===" ")?jt+Yt+jt:Yt)}},Pe.RECORD_SEP="",Pe.UNIT_SEP="",Pe.BYTE_ORDER_MARK="\uFEFF",Pe.BAD_DELIMITERS=["\r",`
822
+ `,'"',Pe.BYTE_ORDER_MARK],Pe.WORKERS_SUPPORTED=!ue&&!!$.Worker,Pe.NODE_STREAM_INPUT=1,Pe.LocalChunkSize=10485760,Pe.RemoteChunkSize=5242880,Pe.DefaultDelimiter=",",Pe.Parser=Xt,Pe.ParserHandle=Je,Pe.NetworkStreamer=Ne,Pe.FileStreamer=Ye,Pe.StringStreamer=rt,Pe.ReadableStreamStreamer=Ct,$.jQuery&&((Q=$.jQuery).fn.parse=function(he){var pe=he.config||{},De=[];return this.each(function(at){if(!(Q(this).prop("tagName").toUpperCase()==="INPUT"&&Q(this).attr("type").toLowerCase()==="file"&&$.FileReader)||!this.files||this.files.length===0)return!0;for(var jt=0;jt<this.files.length;jt++)De.push({file:this.files[jt],inputElem:this,instanceConfig:Q.extend({},pe)})}),Oe(),this;function Oe(){if(De.length===0)dt(he.complete)&&he.complete();else{var at,jt,$t,ei,ot=De[0];if(dt(he.before)){var Nt=he.before(ot.file,ot.inputElem);if(typeof Nt=="object"){if(Nt.action==="abort")return at="AbortError",jt=ot.file,$t=ot.inputElem,ei=Nt.reason,void(dt(he.error)&&he.error({name:at},jt,$t,ei));if(Nt.action==="skip")return void je();typeof Nt.config=="object"&&(ot.instanceConfig=Q.extend(ot.instanceConfig,Nt.config))}else if(Nt==="skip")return void je()}var Ze=ot.instanceConfig.complete;ot.instanceConfig.complete=function(xi){dt(Ze)&&Ze(xi,ot.file,ot.inputElem),je()},Pe.parse(ot.file,ot.instanceConfig)}}function je(){De.splice(0,1),Oe()}}),P&&($.onmessage=function(he){he=he.data,Pe.WORKER_ID===void 0&&he&&(Pe.WORKER_ID=he.workerId),typeof he.input=="string"?$.postMessage({workerId:Pe.WORKER_ID,results:Pe.parse(he.input,he.config),finished:!0}):($.File&&he.input instanceof File||he.input instanceof Object)&&(he=Pe.parse(he.input,he.config))&&$.postMessage({workerId:Pe.WORKER_ID,results:he,finished:!0})}),(Ne.prototype=Object.create(Be.prototype)).constructor=Ne,(Ye.prototype=Object.create(Be.prototype)).constructor=Ye,(rt.prototype=Object.create(rt.prototype)).constructor=rt,(Ct.prototype=Object.create(Be.prototype)).constructor=Ct,Pe})})(mc)),mc.exports}var eg=Qm();const Qd=Ad(eg);async function tg(F,C,D){return new Promise(($,Q)=>{Qd.parse(F,{download:!0,header:!0,skipEmptyLines:!0,complete:ue=>{try{const P=ue.data,c=ue.meta.fields||[],le=new Map;P.forEach(Pe=>{const Be=Pe[C],Ne=Pe[D];if(Be!=null){const Ye=parseFloat(Ne),rt=isNaN(Ye)?Ne:Ye;le.set(String(Be),rt)}}),$({headers:c,rows:P,joinMap:le})}catch(P){Q(P)}},error:ue=>{Q(ue)}})})}async function ig(F,C,D){return new Promise(($,Q)=>{Qd.parse(F,{header:!0,skipEmptyLines:!0,complete:ue=>{try{const P=ue.data,c=ue.meta.fields||[],le=new Map;P.forEach(Pe=>{const Be=Pe[C],Ne=Pe[D];if(Be!=null){const Ye=parseFloat(Ne),rt=isNaN(Ye)?Ne:Ye;le.set(String(Be),rt)}}),$({headers:c,rows:P,joinMap:le})}catch(P){Q(P)}},error:ue=>{Q(ue)}})})}function rg(F,C){if(F.length===0)return[];if(C>=F.length)return[...new Set(F)].sort((le,Pe)=>le-Pe);const D=[...F].sort((le,Pe)=>le-Pe);let $=D.length;const Q=Array($+1).fill(0).map(()=>Array(C+1).fill(0)),ue=Array($+1).fill(0).map(()=>Array(C+1).fill(0));for(let le=1;le<=C;le++){Q[1][le]=1,ue[1][le]=0;for(let Pe=2;Pe<=$;Pe++)ue[Pe][le]=1/0}for(let le=2;le<=$;le++){let Pe=0,Be=0,Ne=0;for(let Ye=1;Ye<=le;Ye++){const rt=le-Ye+1,Ct=D[rt-1];Be+=Ct*Ct,Pe+=Ct,Ne++;const Je=Be-Pe*Pe/Ne,ge=rt-1;if(ge!==0)for(let Xt=2;Xt<=C;Xt++)ue[le][Xt]>=Je+ue[ge][Xt-1]&&(Q[le][Xt]=rt,ue[le][Xt]=Je+ue[ge][Xt-1])}Q[le][1]=1,ue[le][1]=ue[le-1][1]+(le-1)*(D[le-1]-D[le-2])**2}const P=[];let c=C;for(;c>=2;){const le=Q[$][c]-1;P.push(D[le]),$=Q[$][c]-1,c--}return P.push(D[0]),P.reverse(),P.push(D[D.length-1]),[...new Set(P)].sort((le,Pe)=>le-Pe)}function ng(F,C,D){const $=[],Q=c=>{const le=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(c);return le?{r:parseInt(le[1],16),g:parseInt(le[2],16),b:parseInt(le[3],16)}:{r:0,g:0,b:0}},ue=Q(F),P=Q(C);for(let c=0;c<D;c++){const le=c/(D-1),Pe=Math.round(ue.r+le*(P.r-ue.r)),Be=Math.round(ue.g+le*(P.g-ue.g)),Ne=Math.round(ue.b+le*(P.b-ue.b));$.push(`rgb(${Pe}, ${Be}, ${Ne})`)}return $}function ls(F,C){this.x=F,this.y=C}ls.prototype={clone(){return new ls(this.x,this.y)},add(F){return this.clone()._add(F)},sub(F){return this.clone()._sub(F)},multByPoint(F){return this.clone()._multByPoint(F)},divByPoint(F){return this.clone()._divByPoint(F)},mult(F){return this.clone()._mult(F)},div(F){return this.clone()._div(F)},rotate(F){return this.clone()._rotate(F)},rotateAround(F,C){return this.clone()._rotateAround(F,C)},matMult(F){return this.clone()._matMult(F)},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(F){return this.x===F.x&&this.y===F.y},dist(F){return Math.sqrt(this.distSqr(F))},distSqr(F){const C=F.x-this.x,D=F.y-this.y;return C*C+D*D},angle(){return Math.atan2(this.y,this.x)},angleTo(F){return Math.atan2(this.y-F.y,this.x-F.x)},angleWith(F){return this.angleWithSep(F.x,F.y)},angleWithSep(F,C){return Math.atan2(this.x*C-this.y*F,this.x*F+this.y*C)},_matMult(F){const C=F[0]*this.x+F[1]*this.y,D=F[2]*this.x+F[3]*this.y;return this.x=C,this.y=D,this},_add(F){return this.x+=F.x,this.y+=F.y,this},_sub(F){return this.x-=F.x,this.y-=F.y,this},_mult(F){return this.x*=F,this.y*=F,this},_div(F){return this.x/=F,this.y/=F,this},_multByPoint(F){return this.x*=F.x,this.y*=F.y,this},_divByPoint(F){return this.x/=F.x,this.y/=F.y,this},_unit(){return this._div(this.mag()),this},_perp(){const F=this.y;return this.y=this.x,this.x=-F,this},_rotate(F){const C=Math.cos(F),D=Math.sin(F),$=C*this.x-D*this.y,Q=D*this.x+C*this.y;return this.x=$,this.y=Q,this},_rotateAround(F,C){const D=Math.cos(F),$=Math.sin(F),Q=C.x+D*(this.x-C.x)-$*(this.y-C.y),ue=C.y+$*(this.x-C.x)+D*(this.y-C.y);return this.x=Q,this.y=ue,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:ls},ls.convert=function(F){if(F instanceof ls)return F;if(Array.isArray(F))return new ls(+F[0],+F[1]);if(F.x!==void 0&&F.y!==void 0)return new ls(+F.x,+F.y);throw new Error("Expected [x, y] or {x, y} point format")};class ep{constructor(C,D,$,Q,ue){this.properties={},this.extent=$,this.type=0,this.id=void 0,this._pbf=C,this._geometry=-1,this._keys=Q,this._values=ue,C.readFields(sg,this,D)}loadGeometry(){const C=this._pbf;C.pos=this._geometry;const D=C.readVarint()+C.pos,$=[];let Q,ue=1,P=0,c=0,le=0;for(;C.pos<D;){if(P<=0){const Pe=C.readVarint();ue=Pe&7,P=Pe>>3}if(P--,ue===1||ue===2)c+=C.readSVarint(),le+=C.readSVarint(),ue===1&&(Q&&$.push(Q),Q=[]),Q&&Q.push(new ls(c,le));else if(ue===7)Q&&Q.push(Q[0].clone());else throw new Error(`unknown command ${ue}`)}return Q&&$.push(Q),$}bbox(){const C=this._pbf;C.pos=this._geometry;const D=C.readVarint()+C.pos;let $=1,Q=0,ue=0,P=0,c=1/0,le=-1/0,Pe=1/0,Be=-1/0;for(;C.pos<D;){if(Q<=0){const Ne=C.readVarint();$=Ne&7,Q=Ne>>3}if(Q--,$===1||$===2)ue+=C.readSVarint(),P+=C.readSVarint(),ue<c&&(c=ue),ue>le&&(le=ue),P<Pe&&(Pe=P),P>Be&&(Be=P);else if($!==7)throw new Error(`unknown command ${$}`)}return[c,Pe,le,Be]}toGeoJSON(C,D,$){const Q=this.extent*Math.pow(2,$),ue=this.extent*C,P=this.extent*D,c=this.loadGeometry();function le(Ye){return[(Ye.x+ue)*360/Q-180,360/Math.PI*Math.atan(Math.exp((1-(Ye.y+P)*2/Q)*Math.PI))-90]}function Pe(Ye){return Ye.map(le)}let Be;if(this.type===1){const Ye=[];for(const Ct of c)Ye.push(Ct[0]);const rt=Pe(Ye);Be=Ye.length===1?{type:"Point",coordinates:rt[0]}:{type:"MultiPoint",coordinates:rt}}else if(this.type===2){const Ye=c.map(Pe);Be=Ye.length===1?{type:"LineString",coordinates:Ye[0]}:{type:"MultiLineString",coordinates:Ye}}else if(this.type===3){const Ye=og(c),rt=[];for(const Ct of Ye)rt.push(Ct.map(Pe));Be=rt.length===1?{type:"Polygon",coordinates:rt[0]}:{type:"MultiPolygon",coordinates:rt}}else throw new Error("unknown feature type");const Ne={type:"Feature",geometry:Be,properties:this.properties};return this.id!=null&&(Ne.id=this.id),Ne}}ep.types=["Unknown","Point","LineString","Polygon"];function sg(F,C,D){F===1?C.id=D.readVarint():F===2?ag(D,C):F===3?C.type=D.readVarint():F===4&&(C._geometry=D.pos)}function ag(F,C){const D=F.readVarint()+F.pos;for(;F.pos<D;){const $=C._keys[F.readVarint()],Q=C._values[F.readVarint()];C.properties[$]=Q}}function og(F){const C=F.length;if(C<=1)return[F];const D=[];let $,Q;for(let ue=0;ue<C;ue++){const P=lg(F[ue]);P!==0&&(Q===void 0&&(Q=P<0),Q===P<0?($&&D.push($),$=[F[ue]]):$&&$.push(F[ue]))}return $&&D.push($),D}function lg(F){let C=0;for(let D=0,$=F.length,Q=$-1,ue,P;D<$;Q=D++)ue=F[D],P=F[Q],C+=(P.x-ue.x)*(ue.y+P.y);return C}class cg{constructor(C,D){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=C,this._keys=[],this._values=[],this._features=[],C.readFields(ug,this,D),this.length=this._features.length}feature(C){if(C<0||C>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[C];const D=this._pbf.readVarint()+this._pbf.pos;return new ep(this._pbf,D,this.extent,this._keys,this._values)}}function ug(F,C,D){F===15?C.version=D.readVarint():F===1?C.name=D.readString():F===5?C.extent=D.readVarint():F===2?C._features.push(D.pos):F===3?C._keys.push(D.readString()):F===4&&C._values.push(hg(D))}function hg(F){let C=null;const D=F.readVarint()+F.pos;for(;F.pos<D;){const $=F.readVarint()>>3;C=$===1?F.readString():$===2?F.readFloat():$===3?F.readDouble():$===4?F.readVarint64():$===5?F.readVarint():$===6?F.readSVarint():$===7?F.readBoolean():null}if(C==null)throw new Error("unknown feature value");return C}class dg{constructor(C,D){this.layers=C.readFields(pg,{},D)}}function pg(F,C,D){if(F===3){const $=new cg(D,D.readVarint()+D.pos);$.length&&(C[$.name]=$)}}const nh=65536*65536,tp=1/nh,fg=12,ip=typeof TextDecoder>"u"?null:new TextDecoder("utf-8"),sh=0,gc=1,Ko=2,_c=5;class mg{constructor(C=new Uint8Array(16)){this.buf=ArrayBuffer.isView(C)?C:new Uint8Array(C),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(C,D,$=this.length){for(;this.pos<$;){const Q=this.readVarint(),ue=Q>>3,P=this.pos;this.type=Q&7,C(ue,D,this),this.pos===P&&this.skip(Q)}return D}readMessage(C,D){return this.readFields(C,D,this.readVarint()+this.pos)}readFixed32(){const C=this.dataView.getUint32(this.pos,!0);return this.pos+=4,C}readSFixed32(){const C=this.dataView.getInt32(this.pos,!0);return this.pos+=4,C}readFixed64(){const C=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*nh;return this.pos+=8,C}readSFixed64(){const C=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*nh;return this.pos+=8,C}readFloat(){const C=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,C}readDouble(){const C=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,C}readVarint(C){const D=this.buf;let $,Q;return Q=D[this.pos++],$=Q&127,Q<128||(Q=D[this.pos++],$|=(Q&127)<<7,Q<128)||(Q=D[this.pos++],$|=(Q&127)<<14,Q<128)||(Q=D[this.pos++],$|=(Q&127)<<21,Q<128)?$:(Q=D[this.pos],$|=(Q&15)<<28,gg($,C,this))}readVarint64(){return this.readVarint(!0)}readSVarint(){const C=this.readVarint();return C%2===1?(C+1)/-2:C/2}readBoolean(){return!!this.readVarint()}readString(){const C=this.readVarint()+this.pos,D=this.pos;return this.pos=C,C-D>=fg&&ip?ip.decode(this.buf.subarray(D,C)):Cg(this.buf,D,C)}readBytes(){const C=this.readVarint()+this.pos,D=this.buf.subarray(this.pos,C);return this.pos=C,D}readPackedVarint(C=[],D){const $=this.readPackedEnd();for(;this.pos<$;)C.push(this.readVarint(D));return C}readPackedSVarint(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readSVarint());return C}readPackedBoolean(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readBoolean());return C}readPackedFloat(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readFloat());return C}readPackedDouble(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readDouble());return C}readPackedFixed32(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readFixed32());return C}readPackedSFixed32(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readSFixed32());return C}readPackedFixed64(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readFixed64());return C}readPackedSFixed64(C=[]){const D=this.readPackedEnd();for(;this.pos<D;)C.push(this.readSFixed64());return C}readPackedEnd(){return this.type===Ko?this.readVarint()+this.pos:this.pos+1}skip(C){const D=C&7;if(D===sh)for(;this.buf[this.pos++]>127;);else if(D===Ko)this.pos=this.readVarint()+this.pos;else if(D===_c)this.pos+=4;else if(D===gc)this.pos+=8;else throw new Error(`Unimplemented type: ${D}`)}writeTag(C,D){this.writeVarint(C<<3|D)}realloc(C){let D=this.length||16;for(;D<this.pos+C;)D*=2;if(D!==this.length){const $=new Uint8Array(D);$.set(this.buf),this.buf=$,this.dataView=new DataView($.buffer),this.length=D}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(C){this.realloc(4),this.dataView.setInt32(this.pos,C,!0),this.pos+=4}writeSFixed32(C){this.realloc(4),this.dataView.setInt32(this.pos,C,!0),this.pos+=4}writeFixed64(C){this.realloc(8),this.dataView.setInt32(this.pos,C&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(C*tp),!0),this.pos+=8}writeSFixed64(C){this.realloc(8),this.dataView.setInt32(this.pos,C&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(C*tp),!0),this.pos+=8}writeVarint(C){if(C=+C||0,C>268435455||C<0){_g(C,this);return}this.realloc(4),this.buf[this.pos++]=C&127|(C>127?128:0),!(C<=127)&&(this.buf[this.pos++]=(C>>>=7)&127|(C>127?128:0),!(C<=127)&&(this.buf[this.pos++]=(C>>>=7)&127|(C>127?128:0),!(C<=127)&&(this.buf[this.pos++]=C>>>7&127)))}writeSVarint(C){this.writeVarint(C<0?-C*2-1:C*2)}writeBoolean(C){this.writeVarint(+C)}writeString(C){C=String(C),this.realloc(C.length*4),this.pos++;const D=this.pos;this.pos=Ag(this.buf,C,this.pos);const $=this.pos-D;$>=128&&rp(D,$,this),this.pos=D-1,this.writeVarint($),this.pos+=$}writeFloat(C){this.realloc(4),this.dataView.setFloat32(this.pos,C,!0),this.pos+=4}writeDouble(C){this.realloc(8),this.dataView.setFloat64(this.pos,C,!0),this.pos+=8}writeBytes(C){const D=C.length;this.writeVarint(D),this.realloc(D);for(let $=0;$<D;$++)this.buf[this.pos++]=C[$]}writeRawMessage(C,D){this.pos++;const $=this.pos;C(D,this);const Q=this.pos-$;Q>=128&&rp($,Q,this),this.pos=$-1,this.writeVarint(Q),this.pos+=Q}writeMessage(C,D,$){this.writeTag(C,Ko),this.writeRawMessage(D,$)}writePackedVarint(C,D){D.length&&this.writeMessage(C,vg,D)}writePackedSVarint(C,D){D.length&&this.writeMessage(C,bg,D)}writePackedBoolean(C,D){D.length&&this.writeMessage(C,Sg,D)}writePackedFloat(C,D){D.length&&this.writeMessage(C,wg,D)}writePackedDouble(C,D){D.length&&this.writeMessage(C,Tg,D)}writePackedFixed32(C,D){D.length&&this.writeMessage(C,Pg,D)}writePackedSFixed32(C,D){D.length&&this.writeMessage(C,Mg,D)}writePackedFixed64(C,D){D.length&&this.writeMessage(C,Ig,D)}writePackedSFixed64(C,D){D.length&&this.writeMessage(C,Eg,D)}writeBytesField(C,D){this.writeTag(C,Ko),this.writeBytes(D)}writeFixed32Field(C,D){this.writeTag(C,_c),this.writeFixed32(D)}writeSFixed32Field(C,D){this.writeTag(C,_c),this.writeSFixed32(D)}writeFixed64Field(C,D){this.writeTag(C,gc),this.writeFixed64(D)}writeSFixed64Field(C,D){this.writeTag(C,gc),this.writeSFixed64(D)}writeVarintField(C,D){this.writeTag(C,sh),this.writeVarint(D)}writeSVarintField(C,D){this.writeTag(C,sh),this.writeSVarint(D)}writeStringField(C,D){this.writeTag(C,Ko),this.writeString(D)}writeFloatField(C,D){this.writeTag(C,_c),this.writeFloat(D)}writeDoubleField(C,D){this.writeTag(C,gc),this.writeDouble(D)}writeBooleanField(C,D){this.writeVarintField(C,+D)}}function gg(F,C,D){const $=D.buf;let Q,ue;if(ue=$[D.pos++],Q=(ue&112)>>4,ue<128||(ue=$[D.pos++],Q|=(ue&127)<<3,ue<128)||(ue=$[D.pos++],Q|=(ue&127)<<10,ue<128)||(ue=$[D.pos++],Q|=(ue&127)<<17,ue<128)||(ue=$[D.pos++],Q|=(ue&127)<<24,ue<128)||(ue=$[D.pos++],Q|=(ue&1)<<31,ue<128))return Va(F,Q,C);throw new Error("Expected varint not more than 10 bytes")}function Va(F,C,D){return D?C*4294967296+(F>>>0):(C>>>0)*4294967296+(F>>>0)}function _g(F,C){let D,$;if(F>=0?(D=F%4294967296|0,$=F/4294967296|0):(D=~(-F%4294967296),$=~(-F/4294967296),D^4294967295?D=D+1|0:(D=0,$=$+1|0)),F>=18446744073709552e3||F<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");C.realloc(10),yg(D,$,C),xg($,C)}function yg(F,C,D){D.buf[D.pos++]=F&127|128,F>>>=7,D.buf[D.pos++]=F&127|128,F>>>=7,D.buf[D.pos++]=F&127|128,F>>>=7,D.buf[D.pos++]=F&127|128,F>>>=7,D.buf[D.pos]=F&127}function xg(F,C){const D=(F&7)<<4;C.buf[C.pos++]|=D|((F>>>=3)?128:0),F&&(C.buf[C.pos++]=F&127|((F>>>=7)?128:0),F&&(C.buf[C.pos++]=F&127|((F>>>=7)?128:0),F&&(C.buf[C.pos++]=F&127|((F>>>=7)?128:0),F&&(C.buf[C.pos++]=F&127|((F>>>=7)?128:0),F&&(C.buf[C.pos++]=F&127)))))}function rp(F,C,D){const $=C<=16383?1:C<=2097151?2:C<=268435455?3:Math.floor(Math.log(C)/(Math.LN2*7));D.realloc($);for(let Q=D.pos-1;Q>=F;Q--)D.buf[Q+$]=D.buf[Q]}function vg(F,C){for(let D=0;D<F.length;D++)C.writeVarint(F[D])}function bg(F,C){for(let D=0;D<F.length;D++)C.writeSVarint(F[D])}function wg(F,C){for(let D=0;D<F.length;D++)C.writeFloat(F[D])}function Tg(F,C){for(let D=0;D<F.length;D++)C.writeDouble(F[D])}function Sg(F,C){for(let D=0;D<F.length;D++)C.writeBoolean(F[D])}function Pg(F,C){for(let D=0;D<F.length;D++)C.writeFixed32(F[D])}function Mg(F,C){for(let D=0;D<F.length;D++)C.writeSFixed32(F[D])}function Ig(F,C){for(let D=0;D<F.length;D++)C.writeFixed64(F[D])}function Eg(F,C){for(let D=0;D<F.length;D++)C.writeSFixed64(F[D])}function Cg(F,C,D){let $="",Q=C;for(;Q<D;){const ue=F[Q];let P=null,c=ue>239?4:ue>223?3:ue>191?2:1;if(Q+c>D)break;let le,Pe,Be;c===1?ue<128&&(P=ue):c===2?(le=F[Q+1],(le&192)===128&&(P=(ue&31)<<6|le&63,P<=127&&(P=null))):c===3?(le=F[Q+1],Pe=F[Q+2],(le&192)===128&&(Pe&192)===128&&(P=(ue&15)<<12|(le&63)<<6|Pe&63,(P<=2047||P>=55296&&P<=57343)&&(P=null))):c===4&&(le=F[Q+1],Pe=F[Q+2],Be=F[Q+3],(le&192)===128&&(Pe&192)===128&&(Be&192)===128&&(P=(ue&15)<<18|(le&63)<<12|(Pe&63)<<6|Be&63,(P<=65535||P>=1114112)&&(P=null))),P===null?(P=65533,c=1):P>65535&&(P-=65536,$+=String.fromCharCode(P>>>10&1023|55296),P=56320|P&1023),$+=String.fromCharCode(P),Q+=c}return $}function Ag(F,C,D){for(let $=0,Q,ue;$<C.length;$++){if(Q=C.charCodeAt($),Q>55295&&Q<57344)if(ue)if(Q<56320){F[D++]=239,F[D++]=191,F[D++]=189,ue=Q;continue}else Q=ue-55296<<10|Q-56320|65536,ue=null;else{Q>56319||$+1===C.length?(F[D++]=239,F[D++]=191,F[D++]=189):ue=Q;continue}else ue&&(F[D++]=239,F[D++]=191,F[D++]=189,ue=null);Q<128?F[D++]=Q:(Q<2048?F[D++]=Q>>6|192:(Q<65536?F[D++]=Q>>12|224:(F[D++]=Q>>18|240,F[D++]=Q>>12&63|128),F[D++]=Q>>6&63|128),F[D++]=Q&63|128)}return D}async function Dg(F,C,D,$="bbox",Q){try{const ue=new rh(F),P=await ue.getHeader(),c=Math.min(Math.floor((P.minZoom+P.maxZoom)/2),8),le=Math.pow(2,c);for(let Pe=0;Pe<le;Pe++)for(let Be=0;Be<le;Be++)try{const Ne=await ue.getZxy(c,Pe,Be);if(!Ne||!Ne.data)continue;const rt=new dg(new mg(Ne.data)).layers[C];if(!rt)continue;for(let Ct=0;Ct<rt.length;Ct++){const Je=rt.feature(Ct),ge=Je.properties,Xt=String(Q?ge[Q]:Je.id);if(Xt===String(D)){let zt=null;if(ge[$]){const st=ge[$];if(typeof st=="string")try{const fi=JSON.parse(st);Array.isArray(fi)&&fi.length===4&&(zt=fi)}catch{const fi=st.split(",").map(Qt=>parseFloat(Qt.trim()));fi.length===4&&fi.every(Qt=>!isNaN(Qt))&&(zt=fi)}else Array.isArray(st)&&st.length===4&&(zt=st)}if(!zt){const st=Je.loadGeometry();let fi=1/0,Qt=1/0,Mi=-1/0,dt=-1/0;st.forEach($t=>{$t.forEach(ei=>{fi=Math.min(fi,ei.x),Qt=Math.min(Qt,ei.y),Mi=Math.max(Mi,ei.x),dt=Math.max(dt,ei.y)})});const he=4096,pe=(Pe+fi/he)/le*360-180,De=(Pe+Mi/he)/le*360-180,Oe=Math.PI-2*Math.PI*(Be+Qt/he)/le,je=Math.PI-2*Math.PI*(Be+dt/he)/le,at=180/Math.PI*Math.atan(.5*(Math.exp(Oe)-Math.exp(-Oe))),jt=180/Math.PI*Math.atan(.5*(Math.exp(je)-Math.exp(-je)));zt=[Math.min(pe,De),Math.min(at,jt),Math.max(pe,De),Math.max(at,jt)]}return{id:Xt,bbox:zt,properties:ge}}}}catch{continue}return console.warn(`Feature con id "${D}" no encontrada en PMTiles`),null}catch(ue){return console.error("Error buscando feature en PMTiles:",ue),null}}const yc="pmtiles-source",np="pmtiles-fill",zg=({pmtilesUrl:F,sourceLayer:C,joinGeomKey:D,csvUrl:$,csvFile:Q,joinCsvKey:ue,field:P="valor",mode:c="boolean",width:le="100%",height:Pe=520,initialView:Be,fitToId:Ne,bboxField:Ye="bbox",jenksK:rt=5})=>{const Ct=Ln.useRef(null),Je=Ln.useRef(null),[ge,Xt]=Ln.useState(null);Ln.useEffect(()=>{if(!Ct.current)return;if(!$&&!Q){Xt("Debe proporcionar csvUrl o csvFile"),console.error("MapaPMTiles: Debe proporcionar csvUrl o csvFile");return}let st=null;return(async()=>{try{const Qt=new Um;kd.addProtocol("pmtiles",Qt.tile);const Mi=(Be==null?void 0:Be.center)||[-102,23],dt=(Be==null?void 0:Be.zoom)||4;st=new zd.Map({container:Ct.current,style:{version:8,sources:{},layers:[]},center:Mi,zoom:dt,boxZoom:!1,doubleClickZoom:!1,dragRotate:!1,keyboard:!1,scrollZoom:!1,touchPitch:!1,touchZoomRotate:!0,dragPan:!1,maxBounds:void 0}),Je.current=st,st.on("load",async()=>{if(st)try{st.addSource(yc,{type:"vector",url:`pmtiles://${F}`,promoteId:D});const he=ue||D,pe=Q?await ig(Q,he,P):await tg($,he,P);pe.joinMap.forEach((Oe,je)=>{try{st.setFeatureState({source:yc,sourceLayer:C,id:je},{value:Oe})}catch(at){console.warn(`Error setting feature state for key ${je}:`,at)}});let De;if(c==="boolean")De=["case",["==",["feature-state","value"],1],"#66827f","#f3f3f3"];else{const Oe=Array.from(pe.joinMap.values()).filter(je=>typeof je=="number").map(je=>je);if(Oe.length===0)console.warn("No hay valores numéricos para clasificación Jenks"),De=["case",["!=",["feature-state","value"],null],"#66827f","#f3f3f3"];else{const je=rg(Oe,rt),at=ng("#f3f3f3","#66827f",je.length-1),jt=["step",["feature-state","value"]];for(let $t=0;$t<je.length-1;$t++)jt.push(at[$t]),$t<je.length-1&&jt.push(je[$t+1]);De=jt}}if(st.addLayer({id:np,type:"fill",source:yc,"source-layer":C,paint:{"fill-color":De,"fill-opacity":.75}}),st.addLayer({id:`${np}-outline`,type:"line",source:yc,"source-layer":C,paint:{"line-color":"#2c3e50","line-width":.5}}),Ne){const Oe=await Dg(F,C,Ne,Ye,D);if(Oe&&Oe.bbox){const je=[[Oe.bbox[0],Oe.bbox[1]],[Oe.bbox[2],Oe.bbox[3]]];st.fitBounds(je,{padding:50,duration:1e3})}else console.warn(`No se pudo encontrar bbox para fitToId: ${Ne}`)}}catch(he){console.error("Error cargando datos en el mapa:",he),Xt(`Error cargando datos: ${he instanceof Error?he.message:String(he)}`)}}),st.on("error",he=>{var pe;console.error("Error del mapa:",he),Xt(`Error del mapa: ${((pe=he.error)==null?void 0:pe.message)||"Error desconocido"}`)})}catch(Qt){console.error("Error inicializando mapa:",Qt),Xt(`Error inicializando: ${Qt instanceof Error?Qt.message:String(Qt)}`)}})(),()=>{Je.current&&(Je.current.remove(),Je.current=null),kd.removeProtocol("pmtiles")}},[F,C,D,$,Q,ue,P,c,rt,Ne,Ye,Be]);const zt={width:typeof le=="number"?`${le}px`:le,height:typeof Pe=="number"?`${Pe}px`:Pe,position:"relative"};return Ar.jsxs("div",{style:zt,children:[Ar.jsx("div",{ref:Ct,style:{width:"100%",height:"100%"}}),ge&&Ar.jsx("div",{style:{position:"absolute",top:10,left:10,right:10,background:"rgba(231, 76, 60, 0.9)",color:"white",padding:"10px",borderRadius:"4px",fontSize:"12px",zIndex:1e3},children:ge})]})};Br.MapaPMTiles=zg,Object.defineProperty(Br,Symbol.toStringTag,{value:"Module"})}));
823
+ //# sourceMappingURL=geo-ui.umd.cjs.map