import{b as Cp}from"./chunk-ZWRDP37E.js";var kp=Cp((Kc,Jc)=>{(function(an,Br){typeof Kc=="object"&&typeof Jc<"u"?Jc.exports=Br():typeof define=="function"&&define.amd?define(Br):(an=typeof globalThis<"u"?globalThis:an||self,an.maplibregl=Br())})(Kc,function(){"use strict";var an={},Br={};function Ll(L,p,ki){if(Br[L]=ki,L==="index"){var Hi="var sharedModule = {}; ("+Br.shared+")(sharedModule); ("+Br.worker+")(sharedModule);",Gt={};return Br.shared(Gt),Br.index(an,Gt),typeof window<"u"&&an.setWorkerUrl(window.URL.createObjectURL(new Blob([Hi],{type:"text/javascript"}))),an}}Ll("shared",["exports"],function(L){"use strict";function p(i,t,r,s){return new(r||(r=Promise))(function(l,u){function d(x){try{_(s.next(x))}catch(v){u(v)}}function f(x){try{_(s.throw(x))}catch(v){u(v)}}function _(x){var v;x.done?l(x.value):(v=x.value,v instanceof r?v:new r(function(w){w(v)})).then(d,f)}_((s=s.apply(i,t||[])).next())})}function ki(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}typeof SuppressedError=="function"&&SuppressedError;var Hi=Gt;function Gt(i,t){this.x=i,this.y=t}Gt.prototype={clone:function(){return new Gt(this.x,this.y)},add:function(i){return this.clone()._add(i)},sub:function(i){return this.clone()._sub(i)},multByPoint:function(i){return this.clone()._multByPoint(i)},divByPoint:function(i){return this.clone()._divByPoint(i)},mult:function(i){return this.clone()._mult(i)},div:function(i){return this.clone()._div(i)},rotate:function(i){return this.clone()._rotate(i)},rotateAround:function(i,t){return this.clone()._rotateAround(i,t)},matMult:function(i){return this.clone()._matMult(i)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(i){return this.x===i.x&&this.y===i.y},dist:function(i){return Math.sqrt(this.distSqr(i))},distSqr:function(i){var t=i.x-this.x,r=i.y-this.y;return t*t+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(i){return Math.atan2(this.y-i.y,this.x-i.x)},angleWith:function(i){return this.angleWithSep(i.x,i.y)},angleWithSep:function(i,t){return Math.atan2(this.x*t-this.y*i,this.x*i+this.y*t)},_matMult:function(i){var t=i[2]*this.x+i[3]*this.y;return this.x=i[0]*this.x+i[1]*this.y,this.y=t,this},_add:function(i){return this.x+=i.x,this.y+=i.y,this},_sub:function(i){return this.x-=i.x,this.y-=i.y,this},_mult:function(i){return this.x*=i,this.y*=i,this},_div:function(i){return this.x/=i,this.y/=i,this},_multByPoint:function(i){return this.x*=i.x,this.y*=i.y,this},_divByPoint:function(i){return this.x/=i.x,this.y/=i.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var i=this.y;return this.y=this.x,this.x=-i,this},_rotate:function(i){var t=Math.cos(i),r=Math.sin(i),s=r*this.x+t*this.y;return this.x=t*this.x-r*this.y,this.y=s,this},_rotateAround:function(i,t){var r=Math.cos(i),s=Math.sin(i),l=t.y+s*(this.x-t.x)+r*(this.y-t.y);return this.x=t.x+r*(this.x-t.x)-s*(this.y-t.y),this.y=l,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},Gt.convert=function(i){return i instanceof Gt?i:Array.isArray(i)?new Gt(i[0],i[1]):i};var me=ki(Hi),se=Fr;function Fr(i,t,r,s){this.cx=3*i,this.bx=3*(r-i)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(s-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=i,this.p1y=t,this.p2x=r,this.p2y=s}Fr.prototype={sampleCurveX:function(i){return((this.ax*i+this.bx)*i+this.cx)*i},sampleCurveY:function(i){return((this.ay*i+this.by)*i+this.cy)*i},sampleCurveDerivativeX:function(i){return(3*this.ax*i+2*this.bx)*i+this.cx},solveCurveX:function(i,t){if(t===void 0&&(t=1e-6),i<0)return 0;if(i>1)return 1;for(var r=i,s=0;s<8;s++){var l=this.sampleCurveX(r)-i;if(Math.abs(l)l?d=r:f=r,r=.5*(f-d)+d;return r},solve:function(i,t){return this.sampleCurveY(this.solveCurveX(i,t))}};var vr=ki(se);let Xi,br;function cr(){return Xi==null&&(Xi=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),Xi}function Gn(){if(br==null&&(br=!1,cr())){let t=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(t){for(let s=0;s<5*5;s++){let l=4*s;t.fillStyle=`rgb(${l},${l+1},${l+2})`,t.fillRect(s%5,Math.floor(s/5),1,1)}let r=t.getImageData(0,0,5,5).data;for(let s=0;s<5*5*4;s++)if(s%4!=3&&r[s]!==s){br=!0;break}}}return br||!1}function hi(i,t,r,s){let l=new vr(i,t,r,s);return u=>l.solve(u)}let wa=hi(.25,.1,.25,1);function zi(i,t,r){return Math.min(r,Math.max(t,i))}function Wi(i,t,r){let s=r-t,l=((i-t)%s+s)%s+t;return l===t?r:l}function vi(i,...t){for(let r of t)for(let s in r)i[s]=r[s];return i}let Is=1;function Ki(i,t,r){let s={};for(let l in i)s[l]=t.call(this,i[l],l,i);return s}function Hn(i,t,r){let s={};for(let l in i)t.call(this,i[l],l,i)&&(s[l]=i[l]);return s}function st(i){return Array.isArray(i)?i.map(st):typeof i=="object"&&i?Ki(i,st):i}let Ps={};function Ft(i){Ps[i]||(typeof console<"u"&&console.warn(i),Ps[i]=!0)}function Ht(i,t,r){return(r.y-i.y)*(t.x-i.x)>(t.y-i.y)*(r.x-i.x)}function hr(i){return typeof WorkerGlobalScope<"u"&&i!==void 0&&i instanceof WorkerGlobalScope}let on=null;function Ji(i){return typeof ImageBitmap<"u"&&i instanceof ImageBitmap}let As="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function Or(i,t,r,s,l){return p(this,void 0,void 0,function*(){if(typeof VideoFrame>"u")throw new Error("VideoFrame not supported");let u=new VideoFrame(i,{timestamp:0});try{let d=u?.format;if(!d||!d.startsWith("BGR")&&!d.startsWith("RGB"))throw new Error(`Unrecognized format ${d}`);let f=d.startsWith("BGR"),_=new Uint8ClampedArray(s*l*4);if(yield u.copyTo(_,function(x,v,w,I,M){let k=4*Math.max(-v,0),z=(Math.max(0,w)-w)*I*4+k,F=4*I,j=Math.max(0,v),Q=Math.max(0,w);return{rect:{x:j,y:Q,width:Math.min(x.width,v+I)-j,height:Math.min(x.height,w+M)-Q},layout:[{offset:z,stride:F}]}}(i,t,r,s,l)),f)for(let x=0;x<_.length;x+=4){let v=_[x];_[x]=_[x+2],_[x+2]=v}return _}finally{u.close()}})}let ur,ei,Ei="AbortError";function ln(){return new Error(Ei)}let wr={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function Yi(i){return wr.REGISTERED_PROTOCOLS[i.substring(0,i.indexOf("://"))]}let cn="global-dispatcher";class ui extends Error{constructor(t,r,s,l){super(`AJAXError: ${r} (${t}): ${s}`),this.status=t,this.statusText=r,this.url=s,this.body=l}}let Di=()=>hr(self)?self.worker&&self.worker.referrer:(window.location.protocol==="blob:"?window.parent:window).location.href,Vr=function(i,t){if(/:\/\//.test(i.url)&&!/^https?:|^file:/.test(i.url)){let s=Yi(i.url);if(s)return s(i,t);if(hr(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:i,targetMapId:cn},t)}if(!(/^file:/.test(r=i.url)||/^file:/.test(Di())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(s,l){return p(this,void 0,void 0,function*(){let u=new Request(s.url,{method:s.method||"GET",body:s.body,credentials:s.credentials,headers:s.headers,cache:s.cache,referrer:Di(),signal:l.signal});s.type!=="json"||u.headers.has("Accept")||u.headers.set("Accept","application/json");let d=yield fetch(u);if(!d.ok){let x=yield d.blob();throw new ui(d.status,d.statusText,s.url,x)}let f;f=s.type==="arrayBuffer"||s.type==="image"?d.arrayBuffer():s.type==="json"?d.json():d.text();let _=yield f;if(l.signal.aborted)throw ln();return{data:_,cacheControl:d.headers.get("Cache-Control"),expires:d.headers.get("Expires")}})}(i,t);if(hr(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:i,mustQueue:!0,targetMapId:cn},t)}var r;return function(s,l){return new Promise((u,d)=>{var f;let _=new XMLHttpRequest;_.open(s.method||"GET",s.url,!0),s.type!=="arrayBuffer"&&s.type!=="image"||(_.responseType="arraybuffer");for(let x in s.headers)_.setRequestHeader(x,s.headers[x]);s.type==="json"&&(_.responseType="text",!((f=s.headers)===null||f===void 0)&&f.Accept||_.setRequestHeader("Accept","application/json")),_.withCredentials=s.credentials==="include",_.onerror=()=>{d(new Error(_.statusText))},_.onload=()=>{if(!l.signal.aborted)if((_.status>=200&&_.status<300||_.status===0)&&_.response!==null){let x=_.response;if(s.type==="json")try{x=JSON.parse(_.response)}catch(v){return void d(v)}u({data:x,cacheControl:_.getResponseHeader("Cache-Control"),expires:_.getResponseHeader("Expires")})}else{let x=new Blob([_.response],{type:_.getResponseHeader("Content-Type")});d(new ui(_.status,_.statusText,s.url,x))}},l.signal.addEventListener("abort",()=>{_.abort(),d(ln())}),_.send(s.body)})}(i,t)};function Nr(i){if(!i||i.indexOf("://")<=0||i.indexOf("data:image/")===0||i.indexOf("blob:")===0)return!0;let t=new URL(i),r=window.location;return t.protocol===r.protocol&&t.host===r.host}function Xn(i,t,r){r[i]&&r[i].indexOf(t)!==-1||(r[i]=r[i]||[],r[i].push(t))}function dr(i,t,r){if(r&&r[i]){let s=r[i].indexOf(t);s!==-1&&r[i].splice(s,1)}}class Tr{constructor(t,r={}){vi(this,r),this.type=t}}class Sr extends Tr{constructor(t,r={}){super("error",vi({error:t},r))}}class hn{on(t,r){return this._listeners=this._listeners||{},Xn(t,r,this._listeners),this}off(t,r){return dr(t,r,this._listeners),dr(t,r,this._oneTimeListeners),this}once(t,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},Xn(t,r,this._oneTimeListeners),this):new Promise(s=>this.once(t,s))}fire(t,r){typeof t=="string"&&(t=new Tr(t,r||{}));let s=t.type;if(this.listens(s)){t.target=this;let l=this._listeners&&this._listeners[s]?this._listeners[s].slice():[];for(let f of l)f.call(this,t);let u=this._oneTimeListeners&&this._oneTimeListeners[s]?this._oneTimeListeners[s].slice():[];for(let f of u)dr(s,f,this._oneTimeListeners),f.call(this,t);let d=this._eventedParent;d&&(vi(t,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),d.fire(t))}else t instanceof Sr&&console.error(t.error);return this}listens(t){return this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)}setEventedParent(t,r){return this._eventedParent=t,this._eventedParentData=r,this}}var ie={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},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},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},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_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"enum",default:"mercator",values:{mercator:{},globe:{}}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","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"]},"property-type":"cross-faded"},"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:"number",default:335,minimum:0,maximum:359,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:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",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"}},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"}}};let jr=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function Wn(i,t){let r={};for(let s in i)s!=="ref"&&(r[s]=i[s]);return jr.forEach(s=>{s in t&&(r[s]=t[s])}),r}function et(i,t){if(Array.isArray(i)){if(!Array.isArray(t)||i.length!==t.length)return!1;for(let r=0;r`:i.itemType.kind==="value"?"array":`array<${t}>`}return i.kind}let D=[Pr,_e,$e,Be,ti,fr,Li,A(Ne),Ar,ir,N];function O(i,t){if(t.kind==="error")return null;if(i.kind==="array"){if(t.kind==="array"&&(t.N===0&&t.itemType.kind==="value"||!O(i.itemType,t.itemType))&&(typeof i.N!="number"||i.N===t.N))return null}else{if(i.kind===t.kind)return null;if(i.kind==="value"){for(let r of D)if(!O(r,t))return null}}return`Expected ${P(i)} but found ${P(t)} instead.`}function H(i,t){return t.some(r=>r.kind===i.kind)}function W(i,t){return t.some(r=>r==="null"?i===null:r==="array"?Array.isArray(i):r==="object"?i&&!Array.isArray(i)&&typeof i=="object":r===typeof i)}function Y(i,t){return i.kind==="array"&&t.kind==="array"?i.itemType.kind===t.itemType.kind&&typeof i.N=="number":i.kind===t.kind}let q=.96422,ne=.82521,le=4/29,te=6/29,de=3*te*te,Ee=te*te*te,De=Math.PI/180,Ke=180/Math.PI;function je(i){return(i%=360)<0&&(i+=360),i}function Je([i,t,r,s]){let l,u,d=Pt((.2225045*(i=Ge(i))+.7168786*(t=Ge(t))+.0606169*(r=Ge(r)))/1);i===t&&t===r?l=u=d:(l=Pt((.4360747*i+.3850649*t+.1430804*r)/q),u=Pt((.0139322*i+.0971045*t+.7141733*r)/ne));let f=116*d-16;return[f<0?0:f,500*(l-d),200*(d-u),s]}function Ge(i){return i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4)}function Pt(i){return i>Ee?Math.pow(i,1/3):i/de+le}function xt([i,t,r,s]){let l=(i+16)/116,u=isNaN(t)?l:l+t/500,d=isNaN(r)?l:l-r/200;return l=1*rt(l),u=q*rt(u),d=ne*rt(d),[qe(3.1338561*u-1.6168667*l-.4906146*d),qe(-.9787684*u+1.9161415*l+.033454*d),qe(.0719453*u-.2289914*l+1.4052427*d),s]}function qe(i){return(i=i<=.00304?12.92*i:1.055*Math.pow(i,1/2.4)-.055)<0?0:i>1?1:i}function rt(i){return i>te?i*i*i:de*(i-le)}function gt(i){return parseInt(i.padEnd(2,i),16)/255}function kt(i,t){return Lt(t?i/100:i,0,1)}function Lt(i,t,r){return Math.min(Math.max(t,i),r)}function Wt(i){return!i.some(Number.isNaN)}let dn={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]};class nt{constructor(t,r,s,l=1,u=!0){this.r=t,this.g=r,this.b=s,this.a=l,u||(this.r*=l,this.g*=l,this.b*=l,l||this.overwriteGetter("rgb",[t,r,s,l]))}static parse(t){if(t instanceof nt)return t;if(typeof t!="string")return;let r=function(s){if((s=s.toLowerCase().trim())==="transparent")return[0,0,0,0];let l=dn[s];if(l){let[d,f,_]=l;return[d/255,f/255,_/255,1]}if(s.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(s)){let d=s.length<6?1:2,f=1;return[gt(s.slice(f,f+=d)),gt(s.slice(f,f+=d)),gt(s.slice(f,f+=d)),gt(s.slice(f,f+d)||"ff")]}if(s.startsWith("rgb")){let d=s.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(d){let[f,_,x,v,w,I,M,k,z,F,j,Q]=d,G=[v||" ",M||" ",F].join("");if(G===" "||G===" /"||G===",,"||G===",,,"){let J=[x,I,z].join(""),re=J==="%%%"?100:J===""?255:0;if(re){let ce=[Lt(+_/re,0,1),Lt(+w/re,0,1),Lt(+k/re,0,1),j?kt(+j,Q):1];if(Wt(ce))return ce}}return}}let u=s.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(u){let[d,f,_,x,v,w,I,M,k]=u,z=[_||" ",v||" ",I].join("");if(z===" "||z===" /"||z===",,"||z===",,,"){let F=[+f,Lt(+x,0,100),Lt(+w,0,100),M?kt(+M,k):1];if(Wt(F))return function([j,Q,G,J]){function re(ce){let we=(ce+j/30)%12,Le=Q*Math.min(G,1-G);return G-Le*Math.max(-1,Math.min(we-3,9-we,1))}return j=je(j),Q/=100,G/=100,[re(0),re(8),re(4),J]}(F)}}}(t);return r?new nt(...r,!1):void 0}get rgb(){let{r:t,g:r,b:s,a:l}=this,u=l||1/0;return this.overwriteGetter("rgb",[t/u,r/u,s/u,l])}get hcl(){return this.overwriteGetter("hcl",function(t){let[r,s,l,u]=Je(t),d=Math.sqrt(s*s+l*l);return[Math.round(1e4*d)?je(Math.atan2(l,s)*Ke):NaN,d,r,u]}(this.rgb))}get lab(){return this.overwriteGetter("lab",Je(this.rgb))}overwriteGetter(t,r){return Object.defineProperty(this,t,{value:r}),r}toString(){let[t,r,s,l]=this.rgb;return`rgba(${[t,r,s].map(u=>Math.round(255*u)).join(",")},${l})`}}nt.black=new nt(0,0,0,1),nt.white=new nt(1,1,1,1),nt.transparent=new nt(0,0,0,0),nt.red=new nt(1,0,0,1);class Ta{constructor(t,r,s){this.sensitivity=t?r?"variant":"case":r?"accent":"base",this.locale=s,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,r){return this.collator.compare(t,r)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Sa{constructor(t,r,s,l,u){this.text=t,this.image=r,this.scale=s,this.fontStack=l,this.textColor=u}}class di{constructor(t){this.sections=t}static fromString(t){return new di([new Sa(t,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(t=>t.text.length!==0||t.image&&t.image.name.length!==0)}static factory(t){return t instanceof di?t:di.fromString(t)}toString(){return this.sections.length===0?"":this.sections.map(t=>t.text).join("")}}class pi{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof pi)return t;if(typeof t=="number")return new pi([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(let r of t)if(typeof r!="number")return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]]}return new pi(t)}}toString(){return JSON.stringify(this.values)}}let Rl=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class wi{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof wi)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let r=0;r=0&&i<=255&&typeof t=="number"&&t>=0&&t<=255&&typeof r=="number"&&r>=0&&r<=255?s===void 0||typeof s=="number"&&s>=0&&s<=1?null:`Invalid rgba value [${[i,t,r,s].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof s=="number"?[i,t,r,s]:[i,t,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Ur(i){if(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"||i instanceof nt||i instanceof Ta||i instanceof di||i instanceof pi||i instanceof wi||i instanceof fi)return!0;if(Array.isArray(i)){for(let t of i)if(!Ur(t))return!1;return!0}if(typeof i=="object"){for(let t in i)if(!Ur(i[t]))return!1;return!0}return!1}function At(i){if(i===null)return Pr;if(typeof i=="string")return $e;if(typeof i=="boolean")return Be;if(typeof i=="number")return _e;if(i instanceof nt)return ti;if(i instanceof Ta)return tr;if(i instanceof di)return fr;if(i instanceof pi)return Ar;if(i instanceof wi)return N;if(i instanceof fi)return ir;if(Array.isArray(i)){let t=i.length,r;for(let s of i){let l=At(s);if(r){if(r===l)continue;r=Ne;break}r=l}return A(r||Ne,t)}return Li}function Qn(i){let t=typeof i;return i===null?"":t==="string"||t==="number"||t==="boolean"?String(i):i instanceof nt||i instanceof di||i instanceof pi||i instanceof wi||i instanceof fi?i.toString():JSON.stringify(i)}class Ri{constructor(t,r){this.type=t,this.value=r}static parse(t,r){if(t.length!==2)return r.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Ur(t[1]))return r.error("invalid value");let s=t[1],l=At(s),u=r.expectedType;return l.kind!=="array"||l.N!==0||!u||u.kind!=="array"||typeof u.N=="number"&&u.N!==0||(l=u),new Ri(l,s)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class St{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}}let Ms={string:$e,number:_e,boolean:Be,object:Li};class Bi{constructor(t,r){this.type=t,this.args=r}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");let s,l=1,u=t[0];if(u==="array"){let f,_;if(t.length>2){let x=t[1];if(typeof x!="string"||!(x in Ms)||x==="object")return r.error('The item type argument of "array" must be one of string, number, boolean',1);f=Ms[x],l++}else f=Ne;if(t.length>3){if(t[2]!==null&&(typeof t[2]!="number"||t[2]<0||t[2]!==Math.floor(t[2])))return r.error('The length argument to "array" must be a positive integer literal',2);_=t[2],l++}s=A(f,_)}else{if(!Ms[u])throw new Error(`Types doesn't contain name = ${u}`);s=Ms[u]}let d=[];for(;lt.outputDefined())}}let Ia={"to-boolean":Be,"to-color":ti,"to-number":_e,"to-string":$e};class Fi{constructor(t,r){this.type=t,this.args=r}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");let s=t[0];if(!Ia[s])throw new Error(`Can't parse ${s} as it is not part of the known types`);if((s==="to-boolean"||s==="to-string")&&t.length!==2)return r.error("Expected one argument.");let l=Ia[s],u=[];for(let d=1;d4?`Invalid rbga value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:pn(r[0],r[1],r[2],r[3]),!s))return new nt(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new St(s||`Could not parse color from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"padding":{let r;for(let s of this.args){r=s.evaluate(t);let l=pi.parse(r);if(l)return l}throw new St(`Could not parse padding from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"variableAnchorOffsetCollection":{let r;for(let s of this.args){r=s.evaluate(t);let l=wi.parse(r);if(l)return l}throw new St(`Could not parse variableAnchorOffsetCollection from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"number":{let r=null;for(let s of this.args){if(r=s.evaluate(t),r===null)return 0;let l=Number(r);if(!isNaN(l))return l}throw new St(`Could not convert ${JSON.stringify(r)} to number.`)}case"formatted":return di.fromString(Qn(this.args[0].evaluate(t)));case"resolvedImage":return fi.fromString(Qn(this.args[0].evaluate(t)));default:return Qn(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}}let Bl=["Unknown","Point","LineString","Polygon"];class Cs{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},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"?Bl[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(t){let r=this._parseColorCache[t];return r||(r=this._parseColorCache[t]=nt.parse(t)),r}}class $r{constructor(t,r,s=[],l,u=new er,d=[]){this.registry=t,this.path=s,this.key=s.map(f=>`[${f}]`).join(""),this.scope=u,this.errors=d,this.expectedType=l,this._isConstant=r}parse(t,r,s,l,u={}){return r?this.concat(r,s,l)._parse(t,u):this._parse(t,u)}_parse(t,r){function s(l,u,d){return d==="assert"?new Bi(u,[l]):d==="coerce"?new Fi(u,[l]):l}if(t!==null&&typeof t!="string"&&typeof t!="boolean"&&typeof t!="number"||(t=["literal",t]),Array.isArray(t)){if(t.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');let l=t[0];if(typeof l!="string")return this.error(`Expression name must be a string, but found ${typeof l} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;let u=this.registry[l];if(u){let d=u.parse(t,this);if(!d)return null;if(this.expectedType){let f=this.expectedType,_=d.type;if(f.kind!=="string"&&f.kind!=="number"&&f.kind!=="boolean"&&f.kind!=="object"&&f.kind!=="array"||_.kind!=="value")if(f.kind!=="color"&&f.kind!=="formatted"&&f.kind!=="resolvedImage"||_.kind!=="value"&&_.kind!=="string")if(f.kind!=="padding"||_.kind!=="value"&&_.kind!=="number"&&_.kind!=="array")if(f.kind!=="variableAnchorOffsetCollection"||_.kind!=="value"&&_.kind!=="array"){if(this.checkSubtype(f,_))return null}else d=s(d,f,r.typeAnnotation||"coerce");else d=s(d,f,r.typeAnnotation||"coerce");else d=s(d,f,r.typeAnnotation||"coerce");else d=s(d,f,r.typeAnnotation||"assert")}if(!(d instanceof Ri)&&d.type.kind!=="resolvedImage"&&this._isConstant(d)){let f=new Cs;try{d=new Ri(d.type,d.evaluate(f))}catch(_){return this.error(_.message),null}}return d}return this.error(`Unknown expression "${l}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(t===void 0?"'undefined' value invalid. Use null instead.":typeof t=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,r,s){let l=typeof t=="number"?this.path.concat(t):this.path,u=s?this.scope.concat(s):this.scope;return new $r(this.registry,this._isConstant,l,r||null,u,this.errors)}error(t,...r){let s=`${this.key}${r.map(l=>`[${l}]`).join("")}`;this.errors.push(new Xt(s,t))}checkSubtype(t,r){let s=O(t,r);return s&&this.error(s),s}}class Mr{constructor(t,r){this.type=r.type,this.bindings=[].concat(t),this.result=r}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(let r of this.bindings)t(r[1]);t(this.result)}static parse(t,r){if(t.length<4)return r.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);let s=[];for(let u=1;u=s.length)throw new St(`Array index out of bounds: ${r} > ${s.length-1}.`);if(r!==Math.floor(r))throw new St(`Array index must be an integer, but found ${r} instead.`);return s[r]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}}class Aa{constructor(t,r){this.type=Be,this.needle=t,this.haystack=r}static parse(t,r){if(t.length!==3)return r.error(`Expected 2 arguments, but found ${t.length-1} instead.`);let s=r.parse(t[1],1,Ne),l=r.parse(t[2],2,Ne);return s&&l?H(s.type,[Be,$e,_e,Pr,Ne])?new Aa(s,l):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${P(s.type)} instead`):null}evaluate(t){let r=this.needle.evaluate(t),s=this.haystack.evaluate(t);if(!s)return!1;if(!W(r,["boolean","string","number","null"]))throw new St(`Expected first argument to be of type boolean, string, number or null, but found ${P(At(r))} instead.`);if(!W(s,["string","array"]))throw new St(`Expected second argument to be of type array or string, but found ${P(At(s))} instead.`);return s.indexOf(r)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}}class fn{constructor(t,r,s){this.type=_e,this.needle=t,this.haystack=r,this.fromIndex=s}static parse(t,r){if(t.length<=2||t.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);let s=r.parse(t[1],1,Ne),l=r.parse(t[2],2,Ne);if(!s||!l)return null;if(!H(s.type,[Be,$e,_e,Pr,Ne]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${P(s.type)} instead`);if(t.length===4){let u=r.parse(t[3],3,_e);return u?new fn(s,l,u):null}return new fn(s,l)}evaluate(t){let r=this.needle.evaluate(t),s=this.haystack.evaluate(t);if(!W(r,["boolean","string","number","null"]))throw new St(`Expected first argument to be of type boolean, string, number or null, but found ${P(At(r))} instead.`);let l;if(this.fromIndex&&(l=this.fromIndex.evaluate(t)),W(s,["string"])){let u=s.indexOf(r,l);return u===-1?-1:[...s.slice(0,u)].length}if(W(s,["array"]))return s.indexOf(r,l);throw new St(`Expected second argument to be of type array or string, but found ${P(At(s))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}}class Ma{constructor(t,r,s,l,u,d){this.inputType=t,this.type=r,this.input=s,this.cases=l,this.outputs=u,this.otherwise=d}static parse(t,r){if(t.length<5)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return r.error("Expected an even number of arguments.");let s,l;r.expectedType&&r.expectedType.kind!=="value"&&(l=r.expectedType);let u={},d=[];for(let x=2;xNumber.MAX_SAFE_INTEGER)return I.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof k=="number"&&Math.floor(k)!==k)return I.error("Numeric branch labels must be integer values.");if(s){if(I.checkSubtype(s,At(k)))return null}else s=At(k);if(u[String(k)]!==void 0)return I.error("Branch labels must be unique.");u[String(k)]=d.length}let M=r.parse(w,x,l);if(!M)return null;l=l||M.type,d.push(M)}let f=r.parse(t[1],1,Ne);if(!f)return null;let _=r.parse(t[t.length-1],t.length-1,l);return _?f.type.kind!=="value"&&r.concat(1).checkSubtype(s,f.type)?null:new Ma(s,l,f,u,d,_):null}evaluate(t){let r=this.input.evaluate(t);return(At(r)===this.inputType&&this.outputs[this.cases[r]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every(t=>t.outputDefined())&&this.otherwise.outputDefined()}}class ks{constructor(t,r,s){this.type=t,this.branches=r,this.otherwise=s}static parse(t,r){if(t.length<4)return r.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return r.error("Expected an odd number of arguments.");let s;r.expectedType&&r.expectedType.kind!=="value"&&(s=r.expectedType);let l=[];for(let d=1;dr.outputDefined())&&this.otherwise.outputDefined()}}class es{constructor(t,r,s,l){this.type=t,this.input=r,this.beginIndex=s,this.endIndex=l}static parse(t,r){if(t.length<=2||t.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);let s=r.parse(t[1],1,Ne),l=r.parse(t[2],2,_e);if(!s||!l)return null;if(!H(s.type,[A(Ne),$e,Ne]))return r.error(`Expected first argument to be of type array or string, but found ${P(s.type)} instead`);if(t.length===4){let u=r.parse(t[3],3,_e);return u?new es(s.type,s,l,u):null}return new es(s.type,s,l)}evaluate(t){let r=this.input.evaluate(t),s=this.beginIndex.evaluate(t),l;if(this.endIndex&&(l=this.endIndex.evaluate(t)),W(r,["string"]))return[...r].slice(s,l).join("");if(W(r,["array"]))return r.slice(s,l);throw new St(`Expected first argument to be of type array or string, but found ${P(At(r))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}}function zs(i,t){let r=i.length-1,s,l,u=0,d=r,f=0;for(;u<=d;)if(f=Math.floor((u+d)/2),s=i[f],l=i[f+1],s<=t){if(f===r||tt))throw new St("Input is not a number.");d=f-1}return 0}class mn{constructor(t,r,s){this.type=t,this.input=r,this.labels=[],this.outputs=[];for(let[l,u]of s)this.labels.push(l),this.outputs.push(u)}static parse(t,r){if(t.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return r.error("Expected an even number of arguments.");let s=r.parse(t[1],1,_e);if(!s)return null;let l=[],u=null;r.expectedType&&r.expectedType.kind!=="value"&&(u=r.expectedType);for(let d=1;d=f)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',x);let w=r.parse(_,v,u);if(!w)return null;u=u||w.type,l.push([f,w])}return new mn(u,s,l)}evaluate(t){let r=this.labels,s=this.outputs;if(r.length===1)return s[0].evaluate(t);let l=this.input.evaluate(t);if(l<=r[0])return s[0].evaluate(t);let u=r.length;return l>=r[u-1]?s[u-1].evaluate(t):s[zs(r,l)].evaluate(t)}eachChild(t){t(this.input);for(let r of this.outputs)t(r)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}}function Eo(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Fl=Do;function Do(i,t,r,s){this.cx=3*i,this.bx=3*(r-i)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(s-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=i,this.p1y=t,this.p2x=r,this.p2y=s}Do.prototype={sampleCurveX:function(i){return((this.ax*i+this.bx)*i+this.cx)*i},sampleCurveY:function(i){return((this.ay*i+this.by)*i+this.cy)*i},sampleCurveDerivativeX:function(i){return(3*this.ax*i+2*this.bx)*i+this.cx},solveCurveX:function(i,t){if(t===void 0&&(t=1e-6),i<0)return 0;if(i>1)return 1;for(var r=i,s=0;s<8;s++){var l=this.sampleCurveX(r)-i;if(Math.abs(l)l?d=r:f=r,r=.5*(f-d)+d;return r},solve:function(i,t){return this.sampleCurveY(this.solveCurveX(i,t))}};var Ol=Eo(Fl);function qr(i,t,r){return i+r*(t-i)}function ts(i,t,r){return i.map((s,l)=>qr(s,t[l],r))}let ii={number:qr,color:function(i,t,r,s="rgb"){switch(s){case"rgb":{let[l,u,d,f]=ts(i.rgb,t.rgb,r);return new nt(l,u,d,f,!1)}case"hcl":{let[l,u,d,f]=i.hcl,[_,x,v,w]=t.hcl,I,M;if(isNaN(l)||isNaN(_))isNaN(l)?isNaN(_)?I=NaN:(I=_,d!==1&&d!==0||(M=x)):(I=l,v!==1&&v!==0||(M=u));else{let Q=_-l;_>l&&Q>180?Q-=360:_180&&(Q+=360),I=l+r*Q}let[k,z,F,j]=function([Q,G,J,re]){return Q=isNaN(Q)?0:Q*De,xt([J,Math.cos(Q)*G,Math.sin(Q)*G,re])}([I,M??qr(u,x,r),qr(d,v,r),qr(f,w,r)]);return new nt(k,z,F,j,!1)}case"lab":{let[l,u,d,f]=xt(ts(i.lab,t.lab,r));return new nt(l,u,d,f,!1)}}},array:ts,padding:function(i,t,r){return new pi(ts(i.values,t.values,r))},variableAnchorOffsetCollection:function(i,t,r){let s=i.values,l=t.values;if(s.length!==l.length)throw new St(`Cannot interpolate values of different length. from: ${i.toString()}, to: ${t.toString()}`);let u=[];for(let d=0;dtypeof v!="number"||v<0||v>1))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);l={name:"cubic-bezier",controlPoints:x}}}if(t.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(u=r.parse(u,2,_e),!u)return null;let f=[],_=null;s==="interpolate-hcl"||s==="interpolate-lab"?_=ti:r.expectedType&&r.expectedType.kind!=="value"&&(_=r.expectedType);for(let x=0;x=v)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',I);let k=r.parse(w,M,_);if(!k)return null;_=_||k.type,f.push([v,k])}return Y(_,_e)||Y(_,ti)||Y(_,Ar)||Y(_,N)||Y(_,A(_e))?new ri(_,s,l,u,f):r.error(`Type ${P(_)} is not interpolatable.`)}evaluate(t){let r=this.labels,s=this.outputs;if(r.length===1)return s[0].evaluate(t);let l=this.input.evaluate(t);if(l<=r[0])return s[0].evaluate(t);let u=r.length;if(l>=r[u-1])return s[u-1].evaluate(t);let d=zs(r,l),f=ri.interpolationFactor(this.interpolation,l,r[d],r[d+1]),_=s[d].evaluate(t),x=s[d+1].evaluate(t);switch(this.operator){case"interpolate":return ii[this.type.kind](_,x,f);case"interpolate-hcl":return ii.color(_,x,f,"hcl");case"interpolate-lab":return ii.color(_,x,f,"lab")}}eachChild(t){t(this.input);for(let r of this.outputs)t(r)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}}function Es(i,t,r,s){let l=s-r,u=i-r;return l===0?0:t===1?u/l:(Math.pow(t,u)-1)/(Math.pow(t,l)-1)}class Ds{constructor(t,r){this.type=t,this.args=r}static parse(t,r){if(t.length<2)return r.error("Expectected at least one argument.");let s=null,l=r.expectedType;l&&l.kind!=="value"&&(s=l);let u=[];for(let f of t.slice(1)){let _=r.parse(f,1+u.length,s,void 0,{typeAnnotation:"omit"});if(!_)return null;s=s||_.type,u.push(_)}if(!s)throw new Error("No output type");let d=l&&u.some(f=>O(l,f.type));return new Ds(d?Ne:s,u)}evaluate(t){let r,s=null,l=0;for(let u of this.args)if(l++,s=u.evaluate(t),s&&s instanceof fi&&!s.available&&(r||(r=s.name),s=null,l===this.args.length&&(s=r)),s!==null)break;return s}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}}function Ls(i,t){return i==="=="||i==="!="?t.kind==="boolean"||t.kind==="string"||t.kind==="number"||t.kind==="null"||t.kind==="value":t.kind==="string"||t.kind==="number"||t.kind==="value"}function Lo(i,t,r,s){return s.compare(t,r)===0}function _n(i,t,r){let s=i!=="=="&&i!=="!=";return class Ru{constructor(u,d,f){this.type=Be,this.lhs=u,this.rhs=d,this.collator=f,this.hasUntypedArgument=u.type.kind==="value"||d.type.kind==="value"}static parse(u,d){if(u.length!==3&&u.length!==4)return d.error("Expected two or three arguments.");let f=u[0],_=d.parse(u[1],1,Ne);if(!_)return null;if(!Ls(f,_.type))return d.concat(1).error(`"${f}" comparisons are not supported for type '${P(_.type)}'.`);let x=d.parse(u[2],2,Ne);if(!x)return null;if(!Ls(f,x.type))return d.concat(2).error(`"${f}" comparisons are not supported for type '${P(x.type)}'.`);if(_.type.kind!==x.type.kind&&_.type.kind!=="value"&&x.type.kind!=="value")return d.error(`Cannot compare types '${P(_.type)}' and '${P(x.type)}'.`);s&&(_.type.kind==="value"&&x.type.kind!=="value"?_=new Bi(x.type,[_]):_.type.kind!=="value"&&x.type.kind==="value"&&(x=new Bi(_.type,[x])));let v=null;if(u.length===4){if(_.type.kind!=="string"&&x.type.kind!=="string"&&_.type.kind!=="value"&&x.type.kind!=="value")return d.error("Cannot use collator to compare non-string types.");if(v=d.parse(u[3],3,tr),!v)return null}return new Ru(_,x,v)}evaluate(u){let d=this.lhs.evaluate(u),f=this.rhs.evaluate(u);if(s&&this.hasUntypedArgument){let _=At(d),x=At(f);if(_.kind!==x.kind||_.kind!=="string"&&_.kind!=="number")throw new St(`Expected arguments for "${i}" to be (string, string) or (number, number), but found (${_.kind}, ${x.kind}) instead.`)}if(this.collator&&!s&&this.hasUntypedArgument){let _=At(d),x=At(f);if(_.kind!=="string"||x.kind!=="string")return t(u,d,f)}return this.collator?r(u,d,f,this.collator.evaluate(u)):t(u,d,f)}eachChild(u){u(this.lhs),u(this.rhs),this.collator&&u(this.collator)}outputDefined(){return!0}}}let Vl=_n("==",function(i,t,r){return t===r},Lo),Ro=_n("!=",function(i,t,r){return t!==r},function(i,t,r,s){return!Lo(0,t,r,s)}),Bo=_n("<",function(i,t,r){return t",function(i,t,r){return t>r},function(i,t,r,s){return s.compare(t,r)>0}),jl=_n("<=",function(i,t,r){return t<=r},function(i,t,r,s){return s.compare(t,r)<=0}),Fo=_n(">=",function(i,t,r){return t>=r},function(i,t,r,s){return s.compare(t,r)>=0});class is{constructor(t,r,s){this.type=tr,this.locale=s,this.caseSensitive=t,this.diacriticSensitive=r}static parse(t,r){if(t.length!==2)return r.error("Expected one argument.");let s=t[1];if(typeof s!="object"||Array.isArray(s))return r.error("Collator options argument must be an object.");let l=r.parse(s["case-sensitive"]!==void 0&&s["case-sensitive"],1,Be);if(!l)return null;let u=r.parse(s["diacritic-sensitive"]!==void 0&&s["diacritic-sensitive"],1,Be);if(!u)return null;let d=null;return s.locale&&(d=r.parse(s.locale,1,$e),!d)?null:new is(l,u,d)}evaluate(t){return new Ta(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}}class Ca{constructor(t,r,s,l,u){this.type=$e,this.number=t,this.locale=r,this.currency=s,this.minFractionDigits=l,this.maxFractionDigits=u}static parse(t,r){if(t.length!==3)return r.error("Expected two arguments.");let s=r.parse(t[1],1,_e);if(!s)return null;let l=t[2];if(typeof l!="object"||Array.isArray(l))return r.error("NumberFormat options argument must be an object.");let u=null;if(l.locale&&(u=r.parse(l.locale,1,$e),!u))return null;let d=null;if(l.currency&&(d=r.parse(l.currency,1,$e),!d))return null;let f=null;if(l["min-fraction-digits"]&&(f=r.parse(l["min-fraction-digits"],1,_e),!f))return null;let _=null;return l["max-fraction-digits"]&&(_=r.parse(l["max-fraction-digits"],1,_e),!_)?null:new Ca(s,u,d,f,_)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}}class Rs{constructor(t){this.type=fr,this.sections=t}static parse(t,r){if(t.length<2)return r.error("Expected at least one argument.");let s=t[1];if(!Array.isArray(s)&&typeof s=="object")return r.error("First argument must be an image or text section.");let l=[],u=!1;for(let d=1;d<=t.length-1;++d){let f=t[d];if(u&&typeof f=="object"&&!Array.isArray(f)){u=!1;let _=null;if(f["font-scale"]&&(_=r.parse(f["font-scale"],1,_e),!_))return null;let x=null;if(f["text-font"]&&(x=r.parse(f["text-font"],1,A($e)),!x))return null;let v=null;if(f["text-color"]&&(v=r.parse(f["text-color"],1,ti),!v))return null;let w=l[l.length-1];w.scale=_,w.font=x,w.textColor=v}else{let _=r.parse(t[d],1,Ne);if(!_)return null;let x=_.type.kind;if(x!=="string"&&x!=="value"&&x!=="null"&&x!=="resolvedImage")return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");u=!0,l.push({content:_,scale:null,font:null,textColor:null})}}return new Rs(l)}evaluate(t){return new di(this.sections.map(r=>{let s=r.content.evaluate(t);return At(s)===ir?new Sa("",s,null,null,null):new Sa(Qn(s),null,r.scale?r.scale.evaluate(t):null,r.font?r.font.evaluate(t).join(","):null,r.textColor?r.textColor.evaluate(t):null)}))}eachChild(t){for(let r of this.sections)t(r.content),r.scale&&t(r.scale),r.font&&t(r.font),r.textColor&&t(r.textColor)}outputDefined(){return!1}}class ka{constructor(t){this.type=ir,this.input=t}static parse(t,r){if(t.length!==2)return r.error("Expected two arguments.");let s=r.parse(t[1],1,$e);return s?new ka(s):r.error("No image name provided.")}evaluate(t){let r=this.input.evaluate(t),s=fi.fromString(r);return s&&t.availableImages&&(s.available=t.availableImages.indexOf(r)>-1),s}eachChild(t){t(this.input)}outputDefined(){return!1}}class za{constructor(t){this.type=_e,this.input=t}static parse(t,r){if(t.length!==2)return r.error(`Expected 1 argument, but found ${t.length-1} instead.`);let s=r.parse(t[1],1);return s?s.type.kind!=="array"&&s.type.kind!=="string"&&s.type.kind!=="value"?r.error(`Expected argument of type string or array, but found ${P(s.type)} instead.`):new za(s):null}evaluate(t){let r=this.input.evaluate(t);if(typeof r=="string")return[...r].length;if(Array.isArray(r))return r.length;throw new St(`Expected value to be of type string or array, but found ${P(At(r))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}}let rr=8192;function Ul(i,t){let r=(180+i[0])/360,s=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i[1]*Math.PI/360)))/360,l=Math.pow(2,t.z);return[Math.round(r*l*rr),Math.round(s*l*rr)]}function Ea(i,t){let r=Math.pow(2,t.z);return[(l=(i[0]/rr+t.x)/r,360*l-180),(s=(i[1]/rr+t.y)/r,360/Math.PI*Math.atan(Math.exp((180-360*s)*Math.PI/180))-90)];var s,l}function Zr(i,t){i[0]=Math.min(i[0],t[0]),i[1]=Math.min(i[1],t[1]),i[2]=Math.max(i[2],t[0]),i[3]=Math.max(i[3],t[1])}function Cr(i,t){return!(i[0]<=t[0]||i[2]>=t[2]||i[1]<=t[1]||i[3]>=t[3])}function it(i,t,r){let s=i[0]-t[0],l=i[1]-t[1],u=i[0]-r[0],d=i[1]-r[1];return s*d-u*l==0&&s*u<=0&&l*d<=0}function Bs(i,t,r,s){return(l=[s[0]-r[0],s[1]-r[1]])[0]*(u=[t[0]-i[0],t[1]-i[1]])[1]-l[1]*u[0]!=0&&!(!Vo(i,t,r,s)||!Vo(r,s,i,t));var l,u}function $l(i,t,r){for(let s of r)for(let l=0;l(l=i)[1]!=(d=f[_+1])[1]>l[1]&&l[0]<(d[0]-u[0])*(l[1]-u[1])/(d[1]-u[1])+u[0]&&(s=!s)}var l,u,d;return s}function ql(i,t){for(let r of t)if(gn(i,r))return!0;return!1}function Oo(i,t){for(let r of i)if(!gn(r,t))return!1;for(let r=0;r0&&f<0||d<0&&f>0}function Da(i,t,r){let s=[];for(let l=0;lr[2]){let l=.5*s,u=i[0]-r[0]>l?-s:r[0]-i[0]>l?s:0;u===0&&(u=i[0]-r[2]>l?-s:r[2]-i[0]>l?s:0),i[0]+=u}Zr(t,i)}function Uo(i,t,r,s){let l=Math.pow(2,s.z)*rr,u=[s.x*rr,s.y*rr],d=[];for(let f of i)for(let _ of f){let x=[_.x+u[0],_.y+u[1]];jo(x,t,r,l),d.push(x)}return d}function $o(i,t,r,s){let l=Math.pow(2,s.z)*rr,u=[s.x*rr,s.y*rr],d=[];for(let _ of i){let x=[];for(let v of _){let w=[v.x+u[0],v.y+u[1]];Zr(t,w),x.push(w)}d.push(x)}if(t[2]-t[0]<=l/2){(f=t)[0]=f[1]=1/0,f[2]=f[3]=-1/0;for(let _ of d)for(let x of _)jo(x,t,r,l)}var f;return d}class Gr{constructor(t,r){this.type=Be,this.geojson=t,this.geometries=r}static parse(t,r){if(t.length!==2)return r.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Ur(t[1])){let s=t[1];if(s.type==="FeatureCollection"){let l=[];for(let u of s.features){let{type:d,coordinates:f}=u.geometry;d==="Polygon"&&l.push(f),d==="MultiPolygon"&&l.push(...f)}if(l.length)return new Gr(s,{type:"MultiPolygon",coordinates:l})}else if(s.type==="Feature"){let l=s.geometry.type;if(l==="Polygon"||l==="MultiPolygon")return new Gr(s,s.geometry)}else if(s.type==="Polygon"||s.type==="MultiPolygon")return new Gr(s,s)}return r.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return function(r,s){let l=[1/0,1/0,-1/0,-1/0],u=[1/0,1/0,-1/0,-1/0],d=r.canonicalID();if(s.type==="Polygon"){let f=Da(s.coordinates,u,d),_=Uo(r.geometry(),l,u,d);if(!Cr(l,u))return!1;for(let x of _)if(!gn(x,f))return!1}if(s.type==="MultiPolygon"){let f=No(s.coordinates,u,d),_=Uo(r.geometry(),l,u,d);if(!Cr(l,u))return!1;for(let x of _)if(!ql(x,f))return!1}return!0}(t,this.geometries);if(t.geometryType()==="LineString")return function(r,s){let l=[1/0,1/0,-1/0,-1/0],u=[1/0,1/0,-1/0,-1/0],d=r.canonicalID();if(s.type==="Polygon"){let f=Da(s.coordinates,u,d),_=$o(r.geometry(),l,u,d);if(!Cr(l,u))return!1;for(let x of _)if(!Oo(x,f))return!1}if(s.type==="MultiPolygon"){let f=No(s.coordinates,u,d),_=$o(r.geometry(),l,u,d);if(!Cr(l,u))return!1;for(let x of _)if(!Zl(x,f))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let qo=class{constructor(i=[],t=(r,s)=>rs?1:0){if(this.data=i,this.length=this.data.length,this.compare=t,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(i){this.data.push(i),this._up(this.length++)}pop(){if(this.length===0)return;let i=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),i}peek(){return this.data[0]}_up(i){let{data:t,compare:r}=this,s=t[i];for(;i>0;){let l=i-1>>1,u=t[l];if(r(s,u)>=0)break;t[i]=u,i=l}t[i]=s}_down(i){let{data:t,compare:r}=this,s=this.length>>1,l=t[i];for(;i=0)break;t[i]=t[u],i=u}t[i]=l}};function Gl(i,t,r,s,l){Zo(i,t,r,s||i.length-1,l||Hl)}function Zo(i,t,r,s,l){for(;s>r;){if(s-r>600){var u=s-r+1,d=t-r+1,f=Math.log(u),_=.5*Math.exp(2*f/3),x=.5*Math.sqrt(f*_*(u-_)/u)*(d-u/2<0?-1:1);Zo(i,t,Math.max(r,Math.floor(t-d*_/u+x)),Math.min(s,Math.floor(t+(u-d)*_/u+x)),l)}var v=i[t],w=r,I=s;for(rs(i,r,t),l(i[s],v)>0&&rs(i,r,s);w0;)I--}l(i[r],v)===0?rs(i,r,I):rs(i,++I,s),I<=t&&(r=I+1),t<=I&&(s=I-1)}}function rs(i,t,r){var s=i[t];i[t]=i[r],i[r]=s}function Hl(i,t){return it?1:0}function Fs(i,t){if(i.length<=1)return[i];let r=[],s,l;for(let u of i){let d=Wl(u);d!==0&&(u.area=Math.abs(d),l===void 0&&(l=d<0),l===d<0?(s&&r.push(s),s=[u]):s.push(u))}if(s&&r.push(s),t>1)for(let u=0;u1?(x=t[_+1][0],v=t[_+1][1]):M>0&&(x+=w/this.kx*M,v+=I/this.ky*M)),w=this.wrap(r[0]-x)*this.kx,I=(r[1]-v)*this.ky;let k=w*w+I*I;k180;)t-=360;return t}}function Wo(i,t){return t[0]-i[0]}function Os(i){return i[1]-i[0]+1}function mr(i,t){return i[1]>=i[0]&&i[1]i[1])return[null,null];let r=Os(i);if(t){if(r===2)return[i,null];let l=Math.floor(r/2);return[[i[0],i[0]+l],[i[0]+l,i[1]]]}if(r===1)return[i,null];let s=Math.floor(r/2)-1;return[[i[0],i[0]+s],[i[0]+s+1,i[1]]]}function Ba(i,t){if(!mr(t,i.length))return[1/0,1/0,-1/0,-1/0];let r=[1/0,1/0,-1/0,-1/0];for(let s=t[0];s<=t[1];++s)Zr(r,i[s]);return r}function Fa(i){let t=[1/0,1/0,-1/0,-1/0];for(let r of i)for(let s of r)Zr(t,s);return t}function Vs(i){return i[0]!==-1/0&&i[1]!==-1/0&&i[2]!==1/0&&i[3]!==1/0}function Oa(i,t,r){if(!Vs(i)||!Vs(t))return NaN;let s=0,l=0;return i[2]t[2]&&(s=i[0]-t[2]),i[1]>t[3]&&(l=i[1]-t[3]),i[3]=s)return s;if(Cr(l,u)){if(Ns(i,t))return 0}else if(Ns(t,i))return 0;let d=1/0;for(let f of i)for(let _=0,x=f.length,v=x-1;_0;){let _=d.pop();if(_[0]>=u)continue;let x=_[1],v=t?50:100;if(Os(x)<=v){if(!mr(x,i.length))return NaN;if(t){let w=Ze(i,x,r,s);if(isNaN(w)||w===0)return w;u=Math.min(u,w)}else for(let w=x[0];w<=x[1];++w){let I=Jl(i[w],r,s);if(u=Math.min(u,I),u===0)return 0}}else{let w=Ra(x,t);at(d,u,s,i,f,w[0]),at(d,u,s,i,f,w[1])}}return u}function ss(i,t,r,s,l,u=1/0){let d=Math.min(u,l.distance(i[0],r[0]));if(d===0)return d;let f=new qo([[0,[0,i.length-1],[0,r.length-1]]],Wo);for(;f.length>0;){let _=f.pop();if(_[0]>=d)continue;let x=_[1],v=_[2],w=t?50:100,I=s?50:100;if(Os(x)<=w&&Os(v)<=I){if(!mr(x,i.length)&&mr(v,r.length))return NaN;let M;if(t&&s)M=Kl(i,x,r,v,l),d=Math.min(d,M);else if(t&&!s){let k=i.slice(x[0],x[1]+1);for(let z=v[0];z<=v[1];++z)if(M=Hr(r[z],k,l),d=Math.min(d,M),d===0)return d}else if(!t&&s){let k=r.slice(v[0],v[1]+1);for(let z=x[0];z<=x[1];++z)if(M=Hr(i[z],k,l),d=Math.min(d,M),d===0)return d}else M=bt(i,x,r,v,l),d=Math.min(d,M)}else{let M=Ra(x,t),k=Ra(v,s);Xr(f,d,l,i,r,M[0],k[0]),Xr(f,d,l,i,r,M[0],k[1]),Xr(f,d,l,i,r,M[1],k[0]),Xr(f,d,l,i,r,M[1],k[1])}}return d}function Na(i){return i.type==="MultiPolygon"?i.coordinates.map(t=>({type:"Polygon",coordinates:t})):i.type==="MultiLineString"?i.coordinates.map(t=>({type:"LineString",coordinates:t})):i.type==="MultiPoint"?i.coordinates.map(t=>({type:"Point",coordinates:t})):[i]}class Wr{constructor(t,r){this.type=_e,this.geojson=t,this.geometries=r}static parse(t,r){if(t.length!==2)return r.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Ur(t[1])){let s=t[1];if(s.type==="FeatureCollection")return new Wr(s,s.features.map(l=>Na(l.geometry)).flat());if(s.type==="Feature")return new Wr(s,Na(s.geometry));if("type"in s&&"coordinates"in s)return new Wr(s,Na(s))}return r.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return function(r,s){let l=r.geometry(),u=l.flat().map(_=>Ea([_.x,_.y],r.canonical));if(l.length===0)return NaN;let d=new La(u[0][1]),f=1/0;for(let _ of s){switch(_.type){case"Point":f=Math.min(f,ss(u,!1,[_.coordinates],!1,d,f));break;case"LineString":f=Math.min(f,ss(u,!1,_.coordinates,!0,d,f));break;case"Polygon":f=Math.min(f,ns(u,!1,_.coordinates,d,f))}if(f===0)return f}return f}(t,this.geometries);if(t.geometryType()==="LineString")return function(r,s){let l=r.geometry(),u=l.flat().map(_=>Ea([_.x,_.y],r.canonical));if(l.length===0)return NaN;let d=new La(u[0][1]),f=1/0;for(let _ of s){switch(_.type){case"Point":f=Math.min(f,ss(u,!0,[_.coordinates],!1,d,f));break;case"LineString":f=Math.min(f,ss(u,!0,_.coordinates,!0,d,f));break;case"Polygon":f=Math.min(f,ns(u,!0,_.coordinates,d,f))}if(f===0)return f}return f}(t,this.geometries);if(t.geometryType()==="Polygon")return function(r,s){let l=r.geometry();if(l.length===0||l[0].length===0)return NaN;let u=Fs(l,0).map(_=>_.map(x=>x.map(v=>Ea([v.x,v.y],r.canonical)))),d=new La(u[0][0][0][1]),f=1/0;for(let _ of s)for(let x of u){switch(_.type){case"Point":f=Math.min(f,ns([_.coordinates],!1,x,d,f));break;case"LineString":f=Math.min(f,ns(_.coordinates,!0,x,d,f));break;case"Polygon":f=Math.min(f,ht(x,_.coordinates,d,f))}if(f===0)return f}return f}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}let yn={"==":Vl,"!=":Ro,">":Nl,"<":Bo,">=":Fo,"<=":jl,array:Bi,at:Pa,boolean:Bi,case:ks,coalesce:Ds,collator:is,format:Rs,image:ka,in:Aa,"index-of":fn,interpolate:ri,"interpolate-hcl":ri,"interpolate-lab":ri,length:za,let:Mr,literal:Ri,match:Ma,number:Bi,"number-format":Ca,object:Bi,slice:es,step:mn,string:Bi,"to-boolean":Fi,"to-color":Fi,"to-number":Fi,"to-string":Fi,var:tt,within:Gr,distance:Wr};class Ti{constructor(t,r,s,l){this.name=t,this.type=r,this._evaluate=s,this.args=l}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(t,r){let s=t[0],l=Ti.definitions[s];if(!l)return r.error(`Unknown expression "${s}". If you wanted a literal array, use ["literal", [...]].`,0);let u=Array.isArray(l)?l[0]:l.type,d=Array.isArray(l)?[[l[1],l[2]]]:l.overloads,f=d.filter(([x])=>!Array.isArray(x)||x.length===t.length-1),_=null;for(let[x,v]of f){_=new $r(r.registry,as,r.path,null,r.scope);let w=[],I=!1;for(let M=1;M{return I=w,Array.isArray(I)?`(${I.map(P).join(", ")})`:`(${P(I.type)}...)`;var I}).join(" | "),v=[];for(let w=1;w{r=t?r&&as(s):r&&s instanceof Ri}),!!r&&os(i)&&ls(i,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function os(i){if(i instanceof Ti&&(i.name==="get"&&i.args.length===1||i.name==="feature-state"||i.name==="has"&&i.args.length===1||i.name==="properties"||i.name==="geometry-type"||i.name==="id"||/^filter-/.test(i.name))||i instanceof Gr||i instanceof Wr)return!1;let t=!0;return i.eachChild(r=>{t&&!os(r)&&(t=!1)}),t}function xn(i){if(i instanceof Ti&&i.name==="feature-state")return!1;let t=!0;return i.eachChild(r=>{t&&!xn(r)&&(t=!1)}),t}function ls(i,t){if(i instanceof Ti&&t.indexOf(i.name)>=0)return!1;let r=!0;return i.eachChild(s=>{r&&!ls(s,t)&&(r=!1)}),r}function js(i){return{result:"success",value:i}}function vn(i){return{result:"error",value:i}}function bn(i){return i["property-type"]==="data-driven"||i["property-type"]==="cross-faded-data-driven"}function Ko(i){return!!i.expression&&i.expression.parameters.indexOf("zoom")>-1}function qa(i){return!!i.expression&&i.expression.interpolated}function Ye(i){return i instanceof Number?"number":i instanceof String?"string":i instanceof Boolean?"boolean":Array.isArray(i)?"array":i===null?"null":typeof i}function Us(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function Yl(i){return i}function Jo(i,t){let r=t.type==="color",s=i.stops&&typeof i.stops[0][0]=="object",l=s||!(s||i.property!==void 0),u=i.type||(qa(t)?"exponential":"interval");if(r||t.type==="padding"){let v=r?nt.parse:pi.parse;(i=Qi({},i)).stops&&(i.stops=i.stops.map(w=>[w[0],v(w[1])])),i.default=v(i.default?i.default:t.default)}if(i.colorSpace&&(d=i.colorSpace)!=="rgb"&&d!=="hcl"&&d!=="lab")throw new Error(`Unknown color space: "${i.colorSpace}"`);var d;let f,_,x;if(u==="exponential")f=Qo;else if(u==="interval")f=$s;else if(u==="categorical"){f=Yo,_=Object.create(null);for(let v of i.stops)_[v[0]]=v[1];x=typeof i.stops[0][0]}else{if(u!=="identity")throw new Error(`Unknown function type "${u}"`);f=el}if(s){let v={},w=[];for(let k=0;kk[0]),evaluate:({zoom:k},z)=>Qo({stops:I,base:i.base},t,k).evaluate(k,z)}}if(l){let v=u==="exponential"?{name:"exponential",base:i.base!==void 0?i.base:1}:null;return{kind:"camera",interpolationType:v,interpolationFactor:ri.interpolationFactor.bind(void 0,v),zoomStops:i.stops.map(w=>w[0]),evaluate:({zoom:w})=>f(i,t,w,_,x)}}return{kind:"source",evaluate(v,w){let I=w&&w.properties?w.properties[i.property]:void 0;return I===void 0?wn(i.default,t.default):f(i,t,I,_,x)}}}function wn(i,t,r){return i!==void 0?i:t!==void 0?t:r!==void 0?r:void 0}function Yo(i,t,r,s,l){return wn(typeof r===l?s[r]:void 0,i.default,t.default)}function $s(i,t,r){if(Ye(r)!=="number")return wn(i.default,t.default);let s=i.stops.length;if(s===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[s-1][0])return i.stops[s-1][1];let l=zs(i.stops.map(u=>u[0]),r);return i.stops[l][1]}function Qo(i,t,r){let s=i.base!==void 0?i.base:1;if(Ye(r)!=="number")return wn(i.default,t.default);let l=i.stops.length;if(l===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[l-1][0])return i.stops[l-1][1];let u=zs(i.stops.map(v=>v[0]),r),d=function(v,w,I,M){let k=M-I,z=v-I;return k===0?0:w===1?z/k:(Math.pow(w,z)-1)/(Math.pow(w,k)-1)}(r,s,i.stops[u][0],i.stops[u+1][0]),f=i.stops[u][1],_=i.stops[u+1][1],x=ii[t.type]||Yl;return typeof f.evaluate=="function"?{evaluate(...v){let w=f.evaluate.apply(void 0,v),I=_.evaluate.apply(void 0,v);if(w!==void 0&&I!==void 0)return x(w,I,d,i.colorSpace)}}:x(f,_,d,i.colorSpace)}function el(i,t,r){switch(t.type){case"color":r=nt.parse(r);break;case"formatted":r=di.fromString(r.toString());break;case"resolvedImage":r=fi.fromString(r.toString());break;case"padding":r=pi.parse(r);break;default:Ye(r)===t.type||t.type==="enum"&&t.values[r]||(r=void 0)}return wn(r,i.default,t.default)}Ti.register(yn,{error:[{kind:"error"},[$e],(i,[t])=>{throw new St(t.evaluate(i))}],typeof:[$e,[Ne],(i,[t])=>P(At(t.evaluate(i)))],"to-rgba":[A(_e,4),[ti],(i,[t])=>{let[r,s,l,u]=t.evaluate(i).rgb;return[255*r,255*s,255*l,u]}],rgb:[ti,[_e,_e,_e],ja],rgba:[ti,[_e,_e,_e,_e],ja],has:{type:Be,overloads:[[[$e],(i,[t])=>Ua(t.evaluate(i),i.properties())],[[$e,Li],(i,[t,r])=>Ua(t.evaluate(i),r.evaluate(i))]]},get:{type:Ne,overloads:[[[$e],(i,[t])=>$a(t.evaluate(i),i.properties())],[[$e,Li],(i,[t,r])=>$a(t.evaluate(i),r.evaluate(i))]]},"feature-state":[Ne,[$e],(i,[t])=>$a(t.evaluate(i),i.featureState||{})],properties:[Li,[],i=>i.properties()],"geometry-type":[$e,[],i=>i.geometryType()],id:[Ne,[],i=>i.id()],zoom:[_e,[],i=>i.globals.zoom],"heatmap-density":[_e,[],i=>i.globals.heatmapDensity||0],"line-progress":[_e,[],i=>i.globals.lineProgress||0],accumulated:[Ne,[],i=>i.globals.accumulated===void 0?null:i.globals.accumulated],"+":[_e,Kr(_e),(i,t)=>{let r=0;for(let s of t)r+=s.evaluate(i);return r}],"*":[_e,Kr(_e),(i,t)=>{let r=1;for(let s of t)r*=s.evaluate(i);return r}],"-":{type:_e,overloads:[[[_e,_e],(i,[t,r])=>t.evaluate(i)-r.evaluate(i)],[[_e],(i,[t])=>-t.evaluate(i)]]},"/":[_e,[_e,_e],(i,[t,r])=>t.evaluate(i)/r.evaluate(i)],"%":[_e,[_e,_e],(i,[t,r])=>t.evaluate(i)%r.evaluate(i)],ln2:[_e,[],()=>Math.LN2],pi:[_e,[],()=>Math.PI],e:[_e,[],()=>Math.E],"^":[_e,[_e,_e],(i,[t,r])=>Math.pow(t.evaluate(i),r.evaluate(i))],sqrt:[_e,[_e],(i,[t])=>Math.sqrt(t.evaluate(i))],log10:[_e,[_e],(i,[t])=>Math.log(t.evaluate(i))/Math.LN10],ln:[_e,[_e],(i,[t])=>Math.log(t.evaluate(i))],log2:[_e,[_e],(i,[t])=>Math.log(t.evaluate(i))/Math.LN2],sin:[_e,[_e],(i,[t])=>Math.sin(t.evaluate(i))],cos:[_e,[_e],(i,[t])=>Math.cos(t.evaluate(i))],tan:[_e,[_e],(i,[t])=>Math.tan(t.evaluate(i))],asin:[_e,[_e],(i,[t])=>Math.asin(t.evaluate(i))],acos:[_e,[_e],(i,[t])=>Math.acos(t.evaluate(i))],atan:[_e,[_e],(i,[t])=>Math.atan(t.evaluate(i))],min:[_e,Kr(_e),(i,t)=>Math.min(...t.map(r=>r.evaluate(i)))],max:[_e,Kr(_e),(i,t)=>Math.max(...t.map(r=>r.evaluate(i)))],abs:[_e,[_e],(i,[t])=>Math.abs(t.evaluate(i))],round:[_e,[_e],(i,[t])=>{let r=t.evaluate(i);return r<0?-Math.round(-r):Math.round(r)}],floor:[_e,[_e],(i,[t])=>Math.floor(t.evaluate(i))],ceil:[_e,[_e],(i,[t])=>Math.ceil(t.evaluate(i))],"filter-==":[Be,[$e,Ne],(i,[t,r])=>i.properties()[t.value]===r.value],"filter-id-==":[Be,[Ne],(i,[t])=>i.id()===t.value],"filter-type-==":[Be,[$e],(i,[t])=>i.geometryType()===t.value],"filter-<":[Be,[$e,Ne],(i,[t,r])=>{let s=i.properties()[t.value],l=r.value;return typeof s==typeof l&&s{let r=i.id(),s=t.value;return typeof r==typeof s&&r":[Be,[$e,Ne],(i,[t,r])=>{let s=i.properties()[t.value],l=r.value;return typeof s==typeof l&&s>l}],"filter-id->":[Be,[Ne],(i,[t])=>{let r=i.id(),s=t.value;return typeof r==typeof s&&r>s}],"filter-<=":[Be,[$e,Ne],(i,[t,r])=>{let s=i.properties()[t.value],l=r.value;return typeof s==typeof l&&s<=l}],"filter-id-<=":[Be,[Ne],(i,[t])=>{let r=i.id(),s=t.value;return typeof r==typeof s&&r<=s}],"filter->=":[Be,[$e,Ne],(i,[t,r])=>{let s=i.properties()[t.value],l=r.value;return typeof s==typeof l&&s>=l}],"filter-id->=":[Be,[Ne],(i,[t])=>{let r=i.id(),s=t.value;return typeof r==typeof s&&r>=s}],"filter-has":[Be,[Ne],(i,[t])=>t.value in i.properties()],"filter-has-id":[Be,[],i=>i.id()!==null&&i.id()!==void 0],"filter-type-in":[Be,[A($e)],(i,[t])=>t.value.indexOf(i.geometryType())>=0],"filter-id-in":[Be,[A(Ne)],(i,[t])=>t.value.indexOf(i.id())>=0],"filter-in-small":[Be,[$e,A(Ne)],(i,[t,r])=>r.value.indexOf(i.properties()[t.value])>=0],"filter-in-large":[Be,[$e,A(Ne)],(i,[t,r])=>function(s,l,u,d){for(;u<=d;){let f=u+d>>1;if(l[f]===s)return!0;l[f]>s?d=f-1:u=f+1}return!1}(i.properties()[t.value],r.value,0,r.value.length-1)],all:{type:Be,overloads:[[[Be,Be],(i,[t,r])=>t.evaluate(i)&&r.evaluate(i)],[Kr(Be),(i,t)=>{for(let r of t)if(!r.evaluate(i))return!1;return!0}]]},any:{type:Be,overloads:[[[Be,Be],(i,[t,r])=>t.evaluate(i)||r.evaluate(i)],[Kr(Be),(i,t)=>{for(let r of t)if(r.evaluate(i))return!0;return!1}]]},"!":[Be,[Be],(i,[t])=>!t.evaluate(i)],"is-supported-script":[Be,[$e],(i,[t])=>{let r=i.globals&&i.globals.isSupportedScript;return!r||r(t.evaluate(i))}],upcase:[$e,[$e],(i,[t])=>t.evaluate(i).toUpperCase()],downcase:[$e,[$e],(i,[t])=>t.evaluate(i).toLowerCase()],concat:[$e,Kr(Ne),(i,t)=>t.map(r=>Qn(r.evaluate(i))).join("")],"resolved-locale":[$e,[tr],(i,[t])=>t.evaluate(i).resolvedLocale()]});class qs{constructor(t,r){var s;this.expression=t,this._warningHistory={},this._evaluator=new Cs,this._defaultValue=r?(s=r).type==="color"&&Us(s.default)?new nt(0,0,0,0):s.type==="color"?nt.parse(s.default)||null:s.type==="padding"?pi.parse(s.default)||null:s.type==="variableAnchorOffsetCollection"?wi.parse(s.default)||null:s.default===void 0?null:s.default:null,this._enumValues=r&&r.type==="enum"?r.values:null}evaluateWithoutErrorHandling(t,r,s,l,u,d){return this._evaluator.globals=t,this._evaluator.feature=r,this._evaluator.featureState=s,this._evaluator.canonical=l,this._evaluator.availableImages=u||null,this._evaluator.formattedSection=d,this.expression.evaluate(this._evaluator)}evaluate(t,r,s,l,u,d){this._evaluator.globals=t,this._evaluator.feature=r||null,this._evaluator.featureState=s||null,this._evaluator.canonical=l,this._evaluator.availableImages=u||null,this._evaluator.formattedSection=d||null;try{let 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 St(`Expected value to be one of ${Object.keys(this._enumValues).map(_=>JSON.stringify(_)).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 Zs(i){return Array.isArray(i)&&i.length>0&&typeof i[0]=="string"&&i[0]in yn}function Tn(i,t){let r=new $r(yn,as,[],t?function(l){let u={color:ti,string:$e,number:_e,enum:$e,boolean:Be,formatted:fr,padding:Ar,resolvedImage:ir,variableAnchorOffsetCollection:N};return l.type==="array"?A(u[l.value]||Ne,l.length):u[l.type]}(t):void 0),s=r.parse(i,void 0,void 0,void 0,t&&t.type==="string"?{typeAnnotation:"coerce"}:void 0);return s?js(new qs(s,t)):vn(r.errors)}class Sn{constructor(t,r){this.kind=t,this._styleExpression=r,this.isStateDependent=t!=="constant"&&!xn(r.expression)}evaluateWithoutErrorHandling(t,r,s,l,u,d){return this._styleExpression.evaluateWithoutErrorHandling(t,r,s,l,u,d)}evaluate(t,r,s,l,u,d){return this._styleExpression.evaluate(t,r,s,l,u,d)}}class In{constructor(t,r,s,l){this.kind=t,this.zoomStops=s,this._styleExpression=r,this.isStateDependent=t!=="camera"&&!xn(r.expression),this.interpolationType=l}evaluateWithoutErrorHandling(t,r,s,l,u,d){return this._styleExpression.evaluateWithoutErrorHandling(t,r,s,l,u,d)}evaluate(t,r,s,l,u,d){return this._styleExpression.evaluate(t,r,s,l,u,d)}interpolationFactor(t,r,s){return this.interpolationType?ri.interpolationFactor(this.interpolationType,t,r,s):0}}function Za(i,t){let r=Tn(i,t);if(r.result==="error")return r;let s=r.value.expression,l=os(s);if(!l&&!bn(t))return vn([new Xt("","data expressions not supported")]);let u=ls(s,["zoom"]);if(!u&&!Ko(t))return vn([new Xt("","zoom expressions not supported")]);let d=cs(s);return d||u?d instanceof Xt?vn([d]):d instanceof ri&&!qa(t)?vn([new Xt("",'"interpolate" expressions cannot be used with this property')]):js(d?new In(l?"camera":"composite",r.value,d.labels,d instanceof ri?d.interpolation:void 0):new Sn(l?"constant":"source",r.value)):vn([new Xt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Pn{constructor(t,r){this._parameters=t,this._specification=r,Qi(this,Jo(this._parameters,this._specification))}static deserialize(t){return new Pn(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function cs(i){let t=null;if(i instanceof Mr)t=cs(i.result);else if(i instanceof Ds){for(let r of i.args)if(t=cs(r),t)break}else(i instanceof mn||i instanceof ri)&&i.input instanceof Ti&&i.input.name==="zoom"&&(t=i);return t instanceof Xt||i.eachChild(r=>{let s=cs(r);s instanceof Xt?t=s:!t&&s?t=new Xt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&s&&t!==s&&(t=new Xt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function Gs(i){if(i===!0||i===!1)return!0;if(!Array.isArray(i)||i.length===0)return!1;switch(i[0]){case"has":return i.length>=2&&i[1]!=="$id"&&i[1]!=="$type";case"in":return i.length>=3&&(typeof i[1]!="string"||Array.isArray(i[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return i.length!==3||Array.isArray(i[1])||Array.isArray(i[2]);case"any":case"all":for(let t of i.slice(1))if(!Gs(t)&&typeof t!="boolean")return!1;return!0;default:return!0}}let Hs={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Ga(i){if(i==null)return{filter:()=>!0,needGeometry:!1};Gs(i)||(i=Xs(i));let t=Tn(i,Hs);if(t.result==="error")throw new Error(t.value.map(r=>`${r.key}: ${r.message}`).join(", "));return{filter:(r,s,l)=>t.value.evaluate(r,s,{},l),needGeometry:tl(i)}}function Ql(i,t){return it?1:0}function tl(i){if(!Array.isArray(i))return!1;if(i[0]==="within"||i[0]==="distance")return!0;for(let t=1;t"||t==="<="||t===">="?Ha(i[1],i[2],t):t==="any"?(r=i.slice(1),["any"].concat(r.map(Xs))):t==="all"?["all"].concat(i.slice(1).map(Xs)):t==="none"?["all"].concat(i.slice(1).map(Xs).map(Ot)):t==="in"?hs(i[1],i.slice(2)):t==="!in"?Ot(hs(i[1],i.slice(2))):t==="has"?us(i[1]):t!=="!has"||Ot(us(i[1]));var r}function Ha(i,t,r){switch(i){case"$type":return[`filter-type-${r}`,t];case"$id":return[`filter-id-${r}`,t];default:return[`filter-${r}`,i,t]}}function hs(i,t){if(t.length===0)return!1;switch(i){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some(r=>typeof r!=typeof t[0])?["filter-in-large",i,["literal",t.sort(Ql)]]:["filter-in-small",i,["literal",t]]}}function us(i){switch(i){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",i]}}function Ot(i){return["!",i]}function Jr(i){let t=typeof i;if(t==="number"||t==="boolean"||t==="string"||i==null)return JSON.stringify(i);if(Array.isArray(i)){let l="[";for(let u of i)l+=`${Jr(u)},`;return`${l}]`}let r=Object.keys(i).sort(),s="{";for(let l=0;ls.maximum?[new ue(t,r,`${r} is greater than the maximum value ${s.maximum}`)]:[]}function Ws(i){let t=i.valueSpec,r=wt(i.value.type),s,l,u,d={},f=r!=="categorical"&&i.value.property===void 0,_=!f,x=Ye(i.value.stops)==="array"&&Ye(i.value.stops[0])==="array"&&Ye(i.value.stops[0][0])==="object",v=mi({key:i.key,value:i.value,valueSpec:i.styleSpec.function,validateSpec:i.validateSpec,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{stops:function(M){if(r==="identity")return[new ue(M.key,M.value,'identity function may not have a "stops" property')];let k=[],z=M.value;return k=k.concat(ds({key:M.key,value:z,valueSpec:M.valueSpec,validateSpec:M.validateSpec,style:M.style,styleSpec:M.styleSpec,arrayElementValidator:w})),Ye(z)==="array"&&z.length===0&&k.push(new ue(M.key,z,"array must have at least one stop")),k},default:function(M){return M.validateSpec({key:M.key,value:M.value,valueSpec:t,validateSpec:M.validateSpec,style:M.style,styleSpec:M.styleSpec})}}});return r==="identity"&&f&&v.push(new ue(i.key,i.value,'missing required property "property"')),r==="identity"||i.value.stops||v.push(new ue(i.key,i.value,'missing required property "stops"')),r==="exponential"&&i.valueSpec.expression&&!qa(i.valueSpec)&&v.push(new ue(i.key,i.value,"exponential functions not supported")),i.styleSpec.$version>=8&&(_&&!bn(i.valueSpec)?v.push(new ue(i.key,i.value,"property functions not supported")):f&&!Ko(i.valueSpec)&&v.push(new ue(i.key,i.value,"zoom functions not supported"))),r!=="categorical"&&!x||i.value.property!==void 0||v.push(new ue(i.key,i.value,'"property" property is required')),v;function w(M){let k=[],z=M.value,F=M.key;if(Ye(z)!=="array")return[new ue(F,z,`array expected, ${Ye(z)} found`)];if(z.length!==2)return[new ue(F,z,`array length 2 expected, length ${z.length} found`)];if(x){if(Ye(z[0])!=="object")return[new ue(F,z,`object expected, ${Ye(z[0])} found`)];if(z[0].zoom===void 0)return[new ue(F,z,"object stop key must have zoom")];if(z[0].value===void 0)return[new ue(F,z,"object stop key must have value")];if(u&&u>wt(z[0].zoom))return[new ue(F,z[0].zoom,"stop zoom values must appear in ascending order")];wt(z[0].zoom)!==u&&(u=wt(z[0].zoom),l=void 0,d={}),k=k.concat(mi({key:`${F}[0]`,value:z[0],valueSpec:{zoom:{}},validateSpec:M.validateSpec,style:M.style,styleSpec:M.styleSpec,objectElementValidators:{zoom:Xa,value:I}}))}else k=k.concat(I({key:`${F}[0]`,value:z[0],valueSpec:{},validateSpec:M.validateSpec,style:M.style,styleSpec:M.styleSpec},z));return Zs(Oi(z[1]))?k.concat([new ue(`${F}[1]`,z[1],"expressions are not allowed in function stops.")]):k.concat(M.validateSpec({key:`${F}[1]`,value:z[1],valueSpec:t,validateSpec:M.validateSpec,style:M.style,styleSpec:M.styleSpec}))}function I(M,k){let z=Ye(M.value),F=wt(M.value),j=M.value!==null?M.value:k;if(s){if(z!==s)return[new ue(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 ue(M.key,j,"stop domain value must be a number, string, or boolean")];if(z!=="number"&&r!=="categorical"){let Q=`number expected, ${z} found`;return bn(t)&&r===void 0&&(Q+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new ue(M.key,j,Q)]}return r!=="categorical"||z!=="number"||isFinite(F)&&Math.floor(F)===F?r!=="categorical"&&z==="number"&&l!==void 0&&Fnew ue(`${i.key}${s.key}`,i.value,s.message));let r=t.value.expression||t.value._styleExpression.expression;if(i.expressionContext==="property"&&i.propertyKey==="text-font"&&!r.outputDefined())return[new ue(i.key,i.value,`Invalid data expression for "${i.propertyKey}". Output values must be contained as literals within the expression.`)];if(i.expressionContext==="property"&&i.propertyType==="layout"&&!xn(r))return[new ue(i.key,i.value,'"feature-state" data expressions are not supported with layout properties.')];if(i.expressionContext==="filter"&&!xn(r))return[new ue(i.key,i.value,'"feature-state" data expressions are not supported with filters.')];if(i.expressionContext&&i.expressionContext.indexOf("cluster")===0){if(!ls(r,["zoom","feature-state"]))return[new ue(i.key,i.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(i.expressionContext==="cluster-initial"&&!os(r))return[new ue(i.key,i.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function _r(i){let t=i.key,r=i.value,s=i.valueSpec,l=[];return Array.isArray(s.values)?s.values.indexOf(wt(r))===-1&&l.push(new ue(t,r,`expected one of [${s.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(s.values).indexOf(wt(r))===-1&&l.push(new ue(t,r,`expected one of [${Object.keys(s.values).join(", ")}], ${JSON.stringify(r)} found`)),l}function Wa(i){return Gs(Oi(i.value))?An(Qi({},i,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Ks(i)}function Ks(i){let t=i.value,r=i.key;if(Ye(t)!=="array")return[new ue(r,t,`array expected, ${Ye(t)} found`)];let s=i.styleSpec,l,u=[];if(t.length<1)return[new ue(r,t,"filter array must have at least 1 element")];switch(u=u.concat(_r({key:`${r}[0]`,value:t[0],valueSpec:s.filter_operator,style:i.style,styleSpec:i.styleSpec})),wt(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&wt(t[1])==="$type"&&u.push(new ue(r,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":t.length!==3&&u.push(new ue(r,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(l=Ye(t[1]),l!=="string"&&u.push(new ue(`${r}[1]`,t[1],`string expected, ${l} found`)));for(let d=2;d{x in r&&t.push(new ue(s,r[x],`"${x}" is prohibited for ref layers`))}),l.layers.forEach(x=>{wt(x.id)===f&&(_=x)}),_?_.ref?t.push(new ue(s,r.ref,"ref cannot reference another ref layer")):d=wt(_.type):t.push(new ue(s,r.ref,`ref layer "${f}" not found`))}else if(d!=="background")if(r.source){let _=l.sources&&l.sources[r.source],x=_&&wt(_.type);_?x==="vector"&&d==="raster"?t.push(new ue(s,r.source,`layer "${r.id}" requires a raster source`)):x!=="raster-dem"&&d==="hillshade"?t.push(new ue(s,r.source,`layer "${r.id}" requires a raster-dem source`)):x==="raster"&&d!=="raster"?t.push(new ue(s,r.source,`layer "${r.id}" requires a vector source`)):x!=="vector"||r["source-layer"]?x==="raster-dem"&&d!=="hillshade"?t.push(new ue(s,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):d!=="line"||!r.paint||!r.paint["line-gradient"]||x==="geojson"&&_.lineMetrics||t.push(new ue(s,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new ue(s,r,`layer "${r.id}" must specify a "source-layer"`)):t.push(new ue(s,r.source,`source "${r.source}" not found`))}else t.push(new ue(s,r,'missing required property "source"'));return t=t.concat(mi({key:s,value:r,valueSpec:u.layer,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,objectElementValidators:{"*":()=>[],type:()=>i.validateSpec({key:`${s}.type`,value:r.type,valueSpec:u.layer.type,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,object:r,objectKey:"type"}),filter:Wa,layout:_=>mi({layer:r,key:_.key,value:_.value,style:_.style,styleSpec:_.styleSpec,validateSpec:_.validateSpec,objectElementValidators:{"*":x=>Ja(Qi({layerType:d},x))}}),paint:_=>mi({layer:r,key:_.key,value:_.value,style:_.style,styleSpec:_.styleSpec,validateSpec:_.validateSpec,objectElementValidators:{"*":x=>Js(Qi({layerType:d},x))}})}})),t}function Yr(i){let t=i.value,r=i.key,s=Ye(t);return s!=="string"?[new ue(r,t,`string expected, ${s} found`)]:[]}let Ys={promoteId:function({key:i,value:t}){if(Ye(t)==="string")return Yr({key:i,value:t});{let r=[];for(let s in t)r.push(...Yr({key:`${i}.${s}`,value:t[s]}));return r}}};function ps(i){let t=i.value,r=i.key,s=i.styleSpec,l=i.style,u=i.validateSpec;if(!t.type)return[new ue(r,t,'"type" is required')];let d=wt(t.type),f;switch(d){case"vector":case"raster":return f=mi({key:r,value:t,valueSpec:s[`source_${d.replace("-","_")}`],style:i.style,styleSpec:s,objectElementValidators:Ys,validateSpec:u}),f;case"raster-dem":return f=function(_){var x;let v=(x=_.sourceName)!==null&&x!==void 0?x:"",w=_.value,I=_.styleSpec,M=I.source_raster_dem,k=_.style,z=[],F=Ye(w);if(w===void 0)return z;if(F!=="object")return z.push(new ue("source_raster_dem",w,`object expected, ${F} found`)),z;let j=wt(w.encoding)==="custom",Q=["redFactor","greenFactor","blueFactor","baseShift"],G=_.value.encoding?`"${_.value.encoding}"`:"Default";for(let J in w)!j&&Q.includes(J)?z.push(new ue(J,w[J],`In "${v}": "${J}" is only valid when "encoding" is set to "custom". ${G} encoding found`)):M[J]?z=z.concat(_.validateSpec({key:J,value:w[J],valueSpec:M[J],validateSpec:_.validateSpec,style:k,styleSpec:I})):z.push(new ue(J,w[J],`unknown property "${J}"`));return z}({sourceName:r,value:t,style:i.style,styleSpec:s,validateSpec:u}),f;case"geojson":if(f=mi({key:r,value:t,valueSpec:s.source_geojson,style:l,styleSpec:s,validateSpec:u,objectElementValidators:Ys}),t.cluster)for(let _ in t.clusterProperties){let[x,v]=t.clusterProperties[_],w=typeof x=="string"?[x,["accumulated"],["get",_]]:x;f.push(...An({key:`${r}.${_}.map`,value:v,validateSpec:u,expressionContext:"cluster-map"})),f.push(...An({key:`${r}.${_}.reduce`,value:w,validateSpec:u,expressionContext:"cluster-reduce"}))}return f;case"video":return mi({key:r,value:t,valueSpec:s.source_video,style:l,validateSpec:u,styleSpec:s});case"image":return mi({key:r,value:t,valueSpec:s.source_image,style:l,validateSpec:u,styleSpec:s});case"canvas":return[new ue(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return _r({key:`${r}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:l,validateSpec:u,styleSpec:s})}}function Qa(i){let t=i.value,r=i.styleSpec,s=r.light,l=i.style,u=[],d=Ye(t);if(t===void 0)return u;if(d!=="object")return u=u.concat([new ue("light",t,`object expected, ${d} found`)]),u;for(let f in t){let _=f.match(/^(.*)-transition$/);u=u.concat(_&&s[_[1]]&&s[_[1]].transition?i.validateSpec({key:f,value:t[f],valueSpec:r.transition,validateSpec:i.validateSpec,style:l,styleSpec:r}):s[f]?i.validateSpec({key:f,value:t[f],valueSpec:s[f],validateSpec:i.validateSpec,style:l,styleSpec:r}):[new ue(f,t[f],`unknown property "${f}"`)])}return u}function eo(i){let t=i.value,r=i.styleSpec,s=r.sky,l=i.style,u=Ye(t);if(t===void 0)return[];if(u!=="object")return[new ue("sky",t,`object expected, ${u} found`)];let d=[];for(let f in t)d=d.concat(s[f]?i.validateSpec({key:f,value:t[f],valueSpec:s[f],style:l,styleSpec:r}):[new ue(f,t[f],`unknown property "${f}"`)]);return d}function to(i){let t=i.value,r=i.styleSpec,s=r.terrain,l=i.style,u=[],d=Ye(t);if(t===void 0)return u;if(d!=="object")return u=u.concat([new ue("terrain",t,`object expected, ${d} found`)]),u;for(let f in t)u=u.concat(s[f]?i.validateSpec({key:f,value:t[f],valueSpec:s[f],validateSpec:i.validateSpec,style:l,styleSpec:r}):[new ue(f,t[f],`unknown property "${f}"`)]);return u}function io(i){let t=[],r=i.value,s=i.key;if(Array.isArray(r)){let l=[],u=[];for(let d in r)r[d].id&&l.includes(r[d].id)&&t.push(new ue(s,r,`all the sprites' ids must be unique, but ${r[d].id} is duplicated`)),l.push(r[d].id),r[d].url&&u.includes(r[d].url)&&t.push(new ue(s,r,`all the sprites' URLs must be unique, but ${r[d].url} is duplicated`)),u.push(r[d].url),t=t.concat(mi({key:`${s}[${d}]`,value:r[d],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:i.validateSpec}));return t}return Yr({key:s,value:r})}let Qs={"*":()=>[],array:ds,boolean:function(i){let t=i.value,r=i.key,s=Ye(t);return s!=="boolean"?[new ue(r,t,`boolean expected, ${s} found`)]:[]},number:Xa,color:function(i){let t=i.key,r=i.value,s=Ye(r);return s!=="string"?[new ue(t,r,`color expected, ${s} found`)]:nt.parse(String(r))?[]:[new ue(t,r,`color expected, "${r}" found`)]},constants:rl,enum:_r,filter:Wa,function:Ws,layer:Ya,object:mi,source:ps,light:Qa,sky:eo,terrain:to,projection:function(i){let t=i.value,r=i.styleSpec,s=r.projection,l=i.style,u=Ye(t);if(t===void 0)return[];if(u!=="object")return[new ue("projection",t,`object expected, ${u} found`)];let d=[];for(let f in t)d=d.concat(s[f]?i.validateSpec({key:f,value:t[f],valueSpec:s[f],style:l,styleSpec:r}):[new ue(f,t[f],`unknown property "${f}"`)]);return d},string:Yr,formatted:function(i){return Yr(i).length===0?[]:An(i)},resolvedImage:function(i){return Yr(i).length===0?[]:An(i)},padding:function(i){let t=i.key,r=i.value;if(Ye(r)==="array"){if(r.length<1||r.length>4)return[new ue(t,r,`padding requires 1 to 4 values; ${r.length} values found`)];let s={type:"number"},l=[];for(let u=0;u[]}})),i.constants&&(r=r.concat(rl({key:"constants",value:i.constants,style:i,styleSpec:t,validateSpec:Mn}))),ro(r)}function nr(i){return function(t){return i({...t,validateSpec:Mn})}}function ro(i){return[].concat(i).sort((t,r)=>t.line-r.line)}function Vi(i){return function(...t){return ro(i.apply(this,t))}}Si.source=Vi(nr(ps)),Si.sprite=Vi(nr(io)),Si.glyphs=Vi(nr(nl)),Si.light=Vi(nr(Qa)),Si.sky=Vi(nr(eo)),Si.terrain=Vi(nr(to)),Si.layer=Vi(nr(Ya)),Si.filter=Vi(nr(Wa)),Si.paintProperty=Vi(nr(Js)),Si.layoutProperty=Vi(nr(Ja));let Qr=Si,ec=Qr.light,tc=Qr.sky,sl=Qr.paintProperty,al=Qr.layoutProperty;function no(i,t){let r=!1;if(t&&t.length)for(let s of t)i.fire(new Sr(new Error(s.message))),r=!0;return r}class Cn{constructor(t,r,s){let l=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;let d=new Int32Array(this.arrayBuffer);t=d[0],this.d=(r=d[1])+2*(s=d[2]);for(let _=0;_=w[k+0]&&l>=w[k+1])?(f[M]=!0,d.push(v[M])):f[M]=!1}}}}_forEachCell(t,r,s,l,u,d,f,_){let x=this._convertToCellCoord(t),v=this._convertToCellCoord(r),w=this._convertToCellCoord(s),I=this._convertToCellCoord(l);for(let M=x;M<=w;M++)for(let k=v;k<=I;k++){let z=this.d*k+M;if((!_||_(this._convertFromCellCoord(M),this._convertFromCellCoord(k),this._convertFromCellCoord(M+1),this._convertFromCellCoord(k+1)))&&u.call(this,t,r,s,l,z,d,f,_))return}}_convertFromCellCoord(t){return(t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;let t=this.cells,r=3+this.cells.length+1+1,s=0;for(let d=0;d=0)continue;let d=i[u];l[u]=Ii[r].shallow.indexOf(u)>=0?d:kn(d,t)}i instanceof Error&&(l.message=i.message)}if(l.$name)throw new Error("$name property is reserved for worker serialization logic.");return r!=="Object"&&(l.$name=r),l}function zn(i){if(ol(i))return i;if(Array.isArray(i))return i.map(zn);if(typeof i!="object")throw new Error("can't deserialize object of type "+typeof i);let t=so(i)||"Object";if(!Ii[t])throw new Error(`can't deserialize unregistered class ${t}`);let{klass:r}=Ii[t];if(!r)throw new Error(`can't deserialize unregistered class ${t}`);if(r.deserialize)return r.deserialize(i);let s=Object.create(r.prototype);for(let l of Object.keys(i)){if(l==="$name")continue;let u=i[l];s[l]=Ii[t].shallow.indexOf(l)>=0?u:zn(u)}return s}class ao{constructor(){this.first=!0}update(t,r){let s=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=s,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=s,!0):(this.lastFloorZoom>s?(this.lastIntegerZoom=s+1,this.lastIntegerZoomTime=r):this.lastFloorZoomi>=128&&i<=255,"Hangul Jamo":i=>i>=4352&&i<=4607,Khmer:i=>i>=6016&&i<=6143,"General Punctuation":i=>i>=8192&&i<=8303,"Letterlike Symbols":i=>i>=8448&&i<=8527,"Number Forms":i=>i>=8528&&i<=8591,"Miscellaneous Technical":i=>i>=8960&&i<=9215,"Control Pictures":i=>i>=9216&&i<=9279,"Optical Character Recognition":i=>i>=9280&&i<=9311,"Enclosed Alphanumerics":i=>i>=9312&&i<=9471,"Geometric Shapes":i=>i>=9632&&i<=9727,"Miscellaneous Symbols":i=>i>=9728&&i<=9983,"Miscellaneous Symbols and Arrows":i=>i>=11008&&i<=11263,"Ideographic Description Characters":i=>i>=12272&&i<=12287,"CJK Symbols and Punctuation":i=>i>=12288&&i<=12351,Katakana:i=>i>=12448&&i<=12543,Kanbun:i=>i>=12688&&i<=12703,"CJK Strokes":i=>i>=12736&&i<=12783,"Enclosed CJK Letters and Months":i=>i>=12800&&i<=13055,"CJK Compatibility":i=>i>=13056&&i<=13311,"Yijing Hexagram Symbols":i=>i>=19904&&i<=19967,"Private Use Area":i=>i>=57344&&i<=63743,"Vertical Forms":i=>i>=65040&&i<=65055,"CJK Compatibility Forms":i=>i>=65072&&i<=65103,"Small Form Variants":i=>i>=65104&&i<=65135,"Halfwidth and Fullwidth Forms":i=>i>=65280&&i<=65519};function oo(i){for(let t of i)if(co(t.charCodeAt(0)))return!0;return!1}function ic(i){for(let t of i)if(!En(t.charCodeAt(0)))return!1;return!0}function lo(i){let t=i.map(r=>{try{return new RegExp(`\\p{sc=${r}}`,"u").source}catch{return null}}).filter(r=>r);return new RegExp(t.join("|"),"u")}let rc=lo(["Arab","Dupl","Mong","Ougr","Syrc"]);function En(i){return!rc.test(String.fromCodePoint(i))}let ll=lo(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function co(i){return!(i!==746&&i!==747&&(i<4352||!(Xe["CJK Compatibility Forms"](i)&&!(i>=65097&&i<=65103)||Xe["CJK Compatibility"](i)||Xe["CJK Strokes"](i)||!(!Xe["CJK Symbols and Punctuation"](i)||i>=12296&&i<=12305||i>=12308&&i<=12319||i===12336)||Xe["Enclosed CJK Letters and Months"](i)||Xe["Ideographic Description Characters"](i)||Xe.Kanbun(i)||Xe.Katakana(i)&&i!==12540||!(!Xe["Halfwidth and Fullwidth Forms"](i)||i===65288||i===65289||i===65293||i>=65306&&i<=65310||i===65339||i===65341||i===65343||i>=65371&&i<=65503||i===65507||i>=65512&&i<=65519)||!(!Xe["Small Form Variants"](i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||Xe["Vertical Forms"](i)||Xe["Yijing Hexagram Symbols"](i)||/\p{sc=Cans}/u.test(String.fromCodePoint(i))||/\p{sc=Hang}/u.test(String.fromCodePoint(i))||ll.test(String.fromCodePoint(i)))))}function cl(i){return!(co(i)||function(t){return!!(Xe["Latin-1 Supplement"](t)&&(t===167||t===169||t===174||t===177||t===188||t===189||t===190||t===215||t===247)||Xe["General Punctuation"](t)&&(t===8214||t===8224||t===8225||t===8240||t===8241||t===8251||t===8252||t===8258||t===8263||t===8264||t===8265||t===8273)||Xe["Letterlike Symbols"](t)||Xe["Number Forms"](t)||Xe["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||t===9003||t>=9085&&t<=9114||t>=9150&&t<=9165||t===9167||t>=9169&&t<=9179||t>=9186&&t<=9215)||Xe["Control Pictures"](t)&&t!==9251||Xe["Optical Character Recognition"](t)||Xe["Enclosed Alphanumerics"](t)||Xe["Geometric Shapes"](t)||Xe["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||Xe["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||Xe["CJK Symbols and Punctuation"](t)||Xe.Katakana(t)||Xe["Private Use Area"](t)||Xe["CJK Compatibility Forms"](t)||Xe["Small Form Variants"](t)||Xe["Halfwidth and Fullwidth Forms"](t)||t===8734||t===8756||t===8757||t>=9984&&t<=10087||t>=10102&&t<=10131||t===65532||t===65533)}(i))}let nc=lo(["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 ho(i){return nc.test(String.fromCodePoint(i))}function sc(i,t){return!(!t&&ho(i)||i>=2304&&i<=3583||i>=3840&&i<=4255||Xe.Khmer(i))}function ac(i){for(let t of i)if(ho(t.charCodeAt(0)))return!0;return!1}let _i=new class{constructor(){this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null}setState(i){this.pluginStatus=i.pluginStatus,this.pluginURL=i.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(i){this.applyArabicShaping=i.applyArabicShaping,this.processBidirectionalText=i.processBidirectionalText,this.processStyledBidirectionalText=i.processStyledBidirectionalText}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getPluginURL(){return this.pluginURL}getRTLTextPluginStatus(){return this.pluginStatus}};class dt{constructor(t,r){this.zoom=t,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new ao,this.transition={})}isSupportedScript(t){return function(r,s){for(let l of r)if(!sc(l.charCodeAt(0),s))return!1;return!0}(t,_i.getRTLTextPluginStatus()==="loaded")}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){let t=this.zoom,r=t-Math.floor(t),s=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*s}:{fromScale:.5,toScale:1,t:1-(1-s)*r}}}class Dn{constructor(t,r){this.property=t,this.value=r,this.expression=function(s,l){if(Us(s))return new Pn(s,l);if(Zs(s)){let u=Za(s,l);if(u.result==="error")throw new Error(u.value.map(d=>`${d.key}: ${d.message}`).join(", "));return u.value}{let u=s;return l.type==="color"&&typeof s=="string"?u=nt.parse(s):l.type!=="padding"||typeof s!="number"&&!Array.isArray(s)?l.type==="variableAnchorOffsetCollection"&&Array.isArray(s)&&(u=wi.parse(s)):u=pi.parse(s),{kind:"constant",evaluate:()=>u}}}(r===void 0?t.specification.default:r,t.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(t,r,s){return this.property.possiblyEvaluate(this,t,r,s)}}class ta{constructor(t){this.property=t,this.value=new Dn(t,void 0)}transitioned(t,r){return new hl(this.property,this.value,r,vi({},t.transition,this.transition),t.now)}untransitioned(){return new hl(this.property,this.value,null,{},0)}}class ia{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return st(this._values[t].value.value)}setValue(t,r){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new ta(this._values[t].property)),this._values[t].value=new Dn(this._values[t].property,r===null?void 0:st(r))}getTransition(t){return st(this._values[t].transition)}setTransition(t,r){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new ta(this._values[t].property)),this._values[t].transition=st(r)||void 0}serialize(){let t={};for(let r of Object.keys(this._values)){let s=this.getValue(r);s!==void 0&&(t[r]=s);let l=this.getTransition(r);l!==void 0&&(t[`${r}-transition`]=l)}return t}transitioned(t,r){let s=new fs(this._properties);for(let l of Object.keys(this._values))s._values[l]=this._values[l].transitioned(t,r._values[l]);return s}untransitioned(){let t=new fs(this._properties);for(let r of Object.keys(this._values))t._values[r]=this._values[r].untransitioned();return t}}class hl{constructor(t,r,s,l,u){this.property=t,this.value=r,this.begin=u+l.delay||0,this.end=this.begin+l.duration||0,t.specification.transition&&(l.delay||l.duration)&&(this.prior=s)}possiblyEvaluate(t,r,s){let l=t.now||0,u=this.value.possiblyEvaluate(t,r,s),d=this.prior;if(d){if(l>this.end)return this.prior=null,u;if(this.value.isDataDriven())return this.prior=null,u;if(l=1)return 1;let x=_*_,v=x*_;return 4*(_<.5?v:3*(_-x)+v-.75)}(f))}}return u}}class fs{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,r,s){let l=new _s(this._properties);for(let u of Object.keys(this._values))l._values[u]=this._values[u].possiblyEvaluate(t,r,s);return l}hasTransition(){for(let t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class ms{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues)}hasValue(t){return this._values[t].value!==void 0}getValue(t){return st(this._values[t].value)}setValue(t,r){this._values[t]=new Dn(this._values[t].property,r===null?void 0:st(r))}serialize(){let t={};for(let r of Object.keys(this._values)){let s=this.getValue(r);s!==void 0&&(t[r]=s)}return t}possiblyEvaluate(t,r,s){let l=new _s(this._properties);for(let u of Object.keys(this._values))l._values[u]=this._values[u].possiblyEvaluate(t,r,s);return l}}class sr{constructor(t,r,s){this.property=t,this.value=r,this.parameters=s}isConstant(){return this.value.kind==="constant"}constantOr(t){return this.value.kind==="constant"?this.value.value:t}evaluate(t,r,s,l){return this.property.evaluate(this.value,this.parameters,t,r,s,l)}}class _s{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class Ae{constructor(t){this.specification=t}possiblyEvaluate(t,r){if(t.isDataDriven())throw new Error("Value should not be data driven");return t.expression.evaluate(r)}interpolate(t,r,s){let l=ii[this.specification.type];return l?l(t,r,s):t}}class Re{constructor(t,r){this.specification=t,this.overrides=r}possiblyEvaluate(t,r,s,l){return new sr(this,t.expression.kind==="constant"||t.expression.kind==="camera"?{kind:"constant",value:t.expression.evaluate(r,null,{},s,l)}:t.expression,r)}interpolate(t,r,s){if(t.value.kind!=="constant"||r.value.kind!=="constant")return t;if(t.value.value===void 0||r.value.value===void 0)return new sr(this,{kind:"constant",value:void 0},t.parameters);let l=ii[this.specification.type];if(l){let u=l(t.value.value,r.value.value,s);return new sr(this,{kind:"constant",value:u},t.parameters)}return t}evaluate(t,r,s,l,u,d){return t.kind==="constant"?t.value:t.evaluate(r,s,l,u,d)}}class ra extends Re{possiblyEvaluate(t,r,s,l){if(t.value===void 0)return new sr(this,{kind:"constant",value:void 0},r);if(t.expression.kind==="constant"){let u=t.expression.evaluate(r,null,{},s,l),d=t.property.specification.type==="resolvedImage"&&typeof u!="string"?u.name:u,f=this._calculate(d,d,d,r);return new sr(this,{kind:"constant",value:f},r)}if(t.expression.kind==="camera"){let u=this._calculate(t.expression.evaluate({zoom:r.zoom-1}),t.expression.evaluate({zoom:r.zoom}),t.expression.evaluate({zoom:r.zoom+1}),r);return new sr(this,{kind:"constant",value:u},r)}return new sr(this,t.expression,r)}evaluate(t,r,s,l,u,d){if(t.kind==="source"){let f=t.evaluate(r,s,l,u,d);return this._calculate(f,f,f,r)}return t.kind==="composite"?this._calculate(t.evaluate({zoom:Math.floor(r.zoom)-1},s,l),t.evaluate({zoom:Math.floor(r.zoom)},s,l),t.evaluate({zoom:Math.floor(r.zoom)+1},s,l),r):t.value}_calculate(t,r,s,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:t,to:r}:{from:s,to:r}}interpolate(t){return t}}class na{constructor(t){this.specification=t}possiblyEvaluate(t,r,s,l){if(t.value!==void 0){if(t.expression.kind==="constant"){let u=t.expression.evaluate(r,null,{},s,l);return this._calculate(u,u,u,r)}return this._calculate(t.expression.evaluate(new dt(Math.floor(r.zoom-1),r)),t.expression.evaluate(new dt(Math.floor(r.zoom),r)),t.expression.evaluate(new dt(Math.floor(r.zoom+1),r)),r)}}_calculate(t,r,s,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:t,to:r}:{from:s,to:r}}interpolate(t){return t}}class uo{constructor(t){this.specification=t}possiblyEvaluate(t,r,s,l){return!!t.expression.evaluate(r,null,{},s,l)}interpolate(){return!1}}class h{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(let r in t){let s=t[r];s.specification.overridable&&this.overridableProperties.push(r);let l=this.defaultPropertyValues[r]=new Dn(s,void 0),u=this.defaultTransitionablePropertyValues[r]=new ta(s);this.defaultTransitioningPropertyValues[r]=u.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=l.possiblyEvaluate({})}}}Ie("DataDrivenProperty",Re),Ie("DataConstantProperty",Ae),Ie("CrossFadedDataDrivenProperty",ra),Ie("CrossFadedProperty",na),Ie("ColorRampProperty",uo);let e="-transition";class n extends hn{constructor(t,r){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1},t.type!=="custom"&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,t.type!=="background"&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),r.layout&&(this._unevaluatedLayout=new ms(r.layout)),r.paint)){this._transitionablePaint=new ia(r.paint);for(let s in t.paint)this.setPaintProperty(s,t.paint[s],{validate:!1});for(let s in t.layout)this.setLayoutProperty(s,t.layout[s],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new _s(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return t==="visibility"?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,r,s={}){r!=null&&this._validate(al,`layers.${this.id}.layout.${t}`,t,r,s)||(t!=="visibility"?this._unevaluatedLayout.setValue(t,r):this.visibility=r)}getPaintProperty(t){return t.endsWith(e)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,r,s={}){if(r!=null&&this._validate(sl,`layers.${this.id}.paint.${t}`,t,r,s))return!1;if(t.endsWith(e))return this._transitionablePaint.setTransition(t.slice(0,-11),r||void 0),!1;{let l=this._transitionablePaint._values[t],u=l.property.specification["property-type"]==="cross-faded-data-driven",d=l.value.isDataDriven(),f=l.value;this._transitionablePaint.setValue(t,r),this._handleSpecialPaintPropertyUpdate(t);let _=this._transitionablePaint._values[t].value;return _.isDataDriven()||d||u||this._handleOverridablePaintPropertyUpdate(t,f,_)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,r,s){return!1}isHidden(t){return!!(this.minzoom&&t=this.maxzoom)||this.visibility==="none"}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,r){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,r)}serialize(){let t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),Hn(t,(r,s)=>!(r===void 0||s==="layout"&&!Object.keys(r).length||s==="paint"&&!Object.keys(r).length))}_validate(t,r,s,l,u={}){return(!u||u.validate!==!1)&&no(this,t.call(Qr,{key:r,layerType:this.type,objectKey:s,value:l,styleSpec:ie,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(let t in this.paint._values){let r=this.paint.get(t);if(r instanceof sr&&bn(r.property.specification)&&(r.value.kind==="source"||r.value.kind==="composite")&&r.value.isStateDependent)return!0}return!1}}let a={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class o{constructor(t,r){this._structArray=t,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class c{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,r){return t._trim(),r&&(t.isTransferred=!0,r.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){let r=Object.create(this.prototype);return r.arrayBuffer=t.arrayBuffer,r.length=t.length,r.capacity=t.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);let r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function m(i,t=1){let r=0,s=0;return{members:i.map(l=>{let u=a[l.type].BYTES_PER_ELEMENT,d=r=g(r,Math.max(t,u)),f=l.components||1;return s=Math.max(s,u),r+=u*f,{name:l.name,type:l.type,components:f,offset:d}}),size:g(r,Math.max(s,t)),alignment:t}}function g(i,t){return Math.ceil(i/t)*t}class y extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r){let s=this.length;return this.resize(s+1),this.emplace(s,t,r)}emplace(t,r,s){let l=2*t;return this.int16[l+0]=r,this.int16[l+1]=s,t}}y.prototype.bytesPerElement=4,Ie("StructArrayLayout2i4",y);class b extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s){let l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){let u=3*t;return this.int16[u+0]=r,this.int16[u+1]=s,this.int16[u+2]=l,t}}b.prototype.bytesPerElement=6,Ie("StructArrayLayout3i6",b);class T extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l){let u=this.length;return this.resize(u+1),this.emplace(u,t,r,s,l)}emplace(t,r,s,l,u){let d=4*t;return this.int16[d+0]=r,this.int16[d+1]=s,this.int16[d+2]=l,this.int16[d+3]=u,t}}T.prototype.bytesPerElement=8,Ie("StructArrayLayout4i8",T);class S extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d){let f=this.length;return this.resize(f+1),this.emplace(f,t,r,s,l,u,d)}emplace(t,r,s,l,u,d,f){let _=6*t;return this.int16[_+0]=r,this.int16[_+1]=s,this.int16[_+2]=l,this.int16[_+3]=u,this.int16[_+4]=d,this.int16[_+5]=f,t}}S.prototype.bytesPerElement=12,Ie("StructArrayLayout2i4i12",S);class C extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d){let f=this.length;return this.resize(f+1),this.emplace(f,t,r,s,l,u,d)}emplace(t,r,s,l,u,d,f){let _=4*t,x=8*t;return this.int16[_+0]=r,this.int16[_+1]=s,this.uint8[x+4]=l,this.uint8[x+5]=u,this.uint8[x+6]=d,this.uint8[x+7]=f,t}}C.prototype.bytesPerElement=8,Ie("StructArrayLayout2i4ub8",C);class E extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r){let s=this.length;return this.resize(s+1),this.emplace(s,t,r)}emplace(t,r,s){let l=2*t;return this.float32[l+0]=r,this.float32[l+1]=s,t}}E.prototype.bytesPerElement=8,Ie("StructArrayLayout2f8",E);class R extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d,f,_,x,v){let w=this.length;return this.resize(w+1),this.emplace(w,t,r,s,l,u,d,f,_,x,v)}emplace(t,r,s,l,u,d,f,_,x,v,w){let I=10*t;return this.uint16[I+0]=r,this.uint16[I+1]=s,this.uint16[I+2]=l,this.uint16[I+3]=u,this.uint16[I+4]=d,this.uint16[I+5]=f,this.uint16[I+6]=_,this.uint16[I+7]=x,this.uint16[I+8]=v,this.uint16[I+9]=w,t}}R.prototype.bytesPerElement=20,Ie("StructArrayLayout10ui20",R);class V extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d,f,_,x,v,w,I){let M=this.length;return this.resize(M+1),this.emplace(M,t,r,s,l,u,d,f,_,x,v,w,I)}emplace(t,r,s,l,u,d,f,_,x,v,w,I,M){let k=12*t;return this.int16[k+0]=r,this.int16[k+1]=s,this.int16[k+2]=l,this.int16[k+3]=u,this.uint16[k+4]=d,this.uint16[k+5]=f,this.uint16[k+6]=_,this.uint16[k+7]=x,this.int16[k+8]=v,this.int16[k+9]=w,this.int16[k+10]=I,this.int16[k+11]=M,t}}V.prototype.bytesPerElement=24,Ie("StructArrayLayout4i4ui4i24",V);class U extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,s){let l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){let u=3*t;return this.float32[u+0]=r,this.float32[u+1]=s,this.float32[u+2]=l,t}}U.prototype.bytesPerElement=12,Ie("StructArrayLayout3f12",U);class $ extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){let r=this.length;return this.resize(r+1),this.emplace(r,t)}emplace(t,r){return this.uint32[1*t+0]=r,t}}$.prototype.bytesPerElement=4,Ie("StructArrayLayout1ul4",$);class Z extends c{_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(t,r,s,l,u,d,f,_,x){let v=this.length;return this.resize(v+1),this.emplace(v,t,r,s,l,u,d,f,_,x)}emplace(t,r,s,l,u,d,f,_,x,v){let w=10*t,I=5*t;return this.int16[w+0]=r,this.int16[w+1]=s,this.int16[w+2]=l,this.int16[w+3]=u,this.int16[w+4]=d,this.int16[w+5]=f,this.uint32[I+3]=_,this.uint16[w+8]=x,this.uint16[w+9]=v,t}}Z.prototype.bytesPerElement=20,Ie("StructArrayLayout6i1ul2ui20",Z);class B extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d){let f=this.length;return this.resize(f+1),this.emplace(f,t,r,s,l,u,d)}emplace(t,r,s,l,u,d,f){let _=6*t;return this.int16[_+0]=r,this.int16[_+1]=s,this.int16[_+2]=l,this.int16[_+3]=u,this.int16[_+4]=d,this.int16[_+5]=f,t}}B.prototype.bytesPerElement=12,Ie("StructArrayLayout2i2i2i12",B);class X extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u){let d=this.length;return this.resize(d+1),this.emplace(d,t,r,s,l,u)}emplace(t,r,s,l,u,d){let f=4*t,_=8*t;return this.float32[f+0]=r,this.float32[f+1]=s,this.float32[f+2]=l,this.int16[_+6]=u,this.int16[_+7]=d,t}}X.prototype.bytesPerElement=16,Ie("StructArrayLayout2f1f2i16",X);class K extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,r,s,l,u,d){let f=this.length;return this.resize(f+1),this.emplace(f,t,r,s,l,u,d)}emplace(t,r,s,l,u,d,f){let _=16*t,x=4*t,v=8*t;return this.uint8[_+0]=r,this.uint8[_+1]=s,this.float32[x+1]=l,this.float32[x+2]=u,this.int16[v+6]=d,this.int16[v+7]=f,t}}K.prototype.bytesPerElement=16,Ie("StructArrayLayout2ub2f2i16",K);class ee extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s){let l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){let u=3*t;return this.uint16[u+0]=r,this.uint16[u+1]=s,this.uint16[u+2]=l,t}}ee.prototype.bytesPerElement=6,Ie("StructArrayLayout3ui6",ee);class oe extends c{_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(t,r,s,l,u,d,f,_,x,v,w,I,M,k,z,F,j){let Q=this.length;return this.resize(Q+1),this.emplace(Q,t,r,s,l,u,d,f,_,x,v,w,I,M,k,z,F,j)}emplace(t,r,s,l,u,d,f,_,x,v,w,I,M,k,z,F,j,Q){let G=24*t,J=12*t,re=48*t;return this.int16[G+0]=r,this.int16[G+1]=s,this.uint16[G+2]=l,this.uint16[G+3]=u,this.uint32[J+2]=d,this.uint32[J+3]=f,this.uint32[J+4]=_,this.uint16[G+10]=x,this.uint16[G+11]=v,this.uint16[G+12]=w,this.float32[J+7]=I,this.float32[J+8]=M,this.uint8[re+36]=k,this.uint8[re+37]=z,this.uint8[re+38]=F,this.uint32[J+10]=j,this.int16[G+22]=Q,t}}oe.prototype.bytesPerElement=48,Ie("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",oe);class he extends c{_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(t,r,s,l,u,d,f,_,x,v,w,I,M,k,z,F,j,Q,G,J,re,ce,we,Le,ve,ye,ke,Pe){let Se=this.length;return this.resize(Se+1),this.emplace(Se,t,r,s,l,u,d,f,_,x,v,w,I,M,k,z,F,j,Q,G,J,re,ce,we,Le,ve,ye,ke,Pe)}emplace(t,r,s,l,u,d,f,_,x,v,w,I,M,k,z,F,j,Q,G,J,re,ce,we,Le,ve,ye,ke,Pe,Se){let ae=32*t,ze=16*t;return this.int16[ae+0]=r,this.int16[ae+1]=s,this.int16[ae+2]=l,this.int16[ae+3]=u,this.int16[ae+4]=d,this.int16[ae+5]=f,this.int16[ae+6]=_,this.int16[ae+7]=x,this.uint16[ae+8]=v,this.uint16[ae+9]=w,this.uint16[ae+10]=I,this.uint16[ae+11]=M,this.uint16[ae+12]=k,this.uint16[ae+13]=z,this.uint16[ae+14]=F,this.uint16[ae+15]=j,this.uint16[ae+16]=Q,this.uint16[ae+17]=G,this.uint16[ae+18]=J,this.uint16[ae+19]=re,this.uint16[ae+20]=ce,this.uint16[ae+21]=we,this.uint16[ae+22]=Le,this.uint32[ze+12]=ve,this.float32[ze+13]=ye,this.float32[ze+14]=ke,this.uint16[ae+30]=Pe,this.uint16[ae+31]=Se,t}}he.prototype.bytesPerElement=64,Ie("StructArrayLayout8i15ui1ul2f2ui64",he);class xe extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){let r=this.length;return this.resize(r+1),this.emplace(r,t)}emplace(t,r){return this.float32[1*t+0]=r,t}}xe.prototype.bytesPerElement=4,Ie("StructArrayLayout1f4",xe);class Te extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,s){let l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){let u=3*t;return this.uint16[6*t+0]=r,this.float32[u+1]=s,this.float32[u+2]=l,t}}Te.prototype.bytesPerElement=12,Ie("StructArrayLayout1ui2f12",Te);class fe extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r,s){let l=this.length;return this.resize(l+1),this.emplace(l,t,r,s)}emplace(t,r,s,l){let u=4*t;return this.uint32[2*t+0]=r,this.uint16[u+2]=s,this.uint16[u+3]=l,t}}fe.prototype.bytesPerElement=8,Ie("StructArrayLayout1ul2ui8",fe);class pe extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,r){let s=this.length;return this.resize(s+1),this.emplace(s,t,r)}emplace(t,r,s){let l=2*t;return this.uint16[l+0]=r,this.uint16[l+1]=s,t}}pe.prototype.bytesPerElement=4,Ie("StructArrayLayout2ui4",pe);class Me extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){let r=this.length;return this.resize(r+1),this.emplace(r,t)}emplace(t,r){return this.uint16[1*t+0]=r,t}}Me.prototype.bytesPerElement=2,Ie("StructArrayLayout1ui2",Me);class Ve extends c{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,r,s,l){let u=this.length;return this.resize(u+1),this.emplace(u,t,r,s,l)}emplace(t,r,s,l,u){let d=4*t;return this.float32[d+0]=r,this.float32[d+1]=s,this.float32[d+2]=l,this.float32[d+3]=u,t}}Ve.prototype.bytesPerElement=16,Ie("StructArrayLayout4f16",Ve);class ge extends o{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 me(this.anchorPointX,this.anchorPointY)}}ge.prototype.size=20;class be extends Z{get(t){return new ge(this,t)}}Ie("CollisionBoxArray",be);class Fe extends o{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(t){this._structArray.uint8[this._pos1+37]=t}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}Fe.prototype.size=48;class pt extends oe{get(t){return new Fe(this,t)}}Ie("PlacedSymbolArray",pt);class Ue extends o{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(t){this._structArray.uint32[this._pos4+12]=t}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]}}Ue.prototype.size=64;class He extends he{get(t){return new Ue(this,t)}}Ie("SymbolInstanceArray",He);class ft extends xe{getoffsetX(t){return this.float32[1*t+0]}}Ie("GlyphOffsetArray",ft);class Vt extends b{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}Ie("SymbolLineVertexArray",Vt);class Ni extends o{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]}}Ni.prototype.size=12;class mt extends Te{get(t){return new Ni(this,t)}}Ie("TextAnchorOffsetArray",mt);class ni extends o{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]}}ni.prototype.size=8;class Kt extends fe{get(t){return new ni(this,t)}}Ie("FeatureIndexArray",Kt);class Nt extends y{}class Jt extends y{}class ar extends y{}class Ln extends S{}class sa extends C{}class Rn extends E{}class Pi extends R{}class aa extends V{}class po extends U{}class Ai extends ${}class Mi extends B{}class kr extends K{}class ji extends ee{}class Rt extends pe{}let jt=m([{name:"a_pos",components:2,type:"Int16"}],4),{members:gi}=jt;class We{constructor(t=[]){this.segments=t}prepareSegment(t,r,s,l){let u=this.segments[this.segments.length-1];return t>We.MAX_VERTEX_ARRAY_LENGTH&&Ft(`Max vertices per segment is ${We.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!u||u.vertexLength+t>We.MAX_VERTEX_ARRAY_LENGTH||u.sortKey!==l)&&(u={vertexOffset:r.length,primitiveOffset:s.length,vertexLength:0,primitiveLength:0},l!==void 0&&(u.sortKey=l),this.segments.push(u)),u}get(){return this.segments}destroy(){for(let t of this.segments)for(let r in t.vaos)t.vaos[r].destroy()}static simpleSegment(t,r,s,l){return new We([{vertexOffset:t,primitiveOffset:r,vertexLength:s,primitiveLength:l,vaos:{},sortKey:0}])}}function en(i,t){return 256*(i=zi(Math.floor(i),0,255))+zi(Math.floor(t),0,255)}We.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Ie("SegmentVector",We);let Bn=m([{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"}]);var Fn={exports:{}},ul={exports:{}};ul.exports=function(i,t){var r,s,l,u,d,f,_,x;for(s=i.length-(r=3&i.length),l=t,d=3432918353,f=461845907,x=0;x>>16)*d&65535)<<16)&4294967295)<<15|_>>>17))*f+(((_>>>16)*f&65535)<<16)&4294967295)<<13|l>>>19))+((5*(l>>>16)&65535)<<16)&4294967295))+((58964+(u>>>16)&65535)<<16);switch(_=0,r){case 3:_^=(255&i.charCodeAt(x+2))<<16;case 2:_^=(255&i.charCodeAt(x+1))<<8;case 1:l^=_=(65535&(_=(_=(65535&(_^=255&i.charCodeAt(x)))*d+(((_>>>16)*d&65535)<<16)&4294967295)<<15|_>>>17))*f+(((_>>>16)*f&65535)<<16)&4294967295}return l^=i.length,l=2246822507*(65535&(l^=l>>>16))+((2246822507*(l>>>16)&65535)<<16)&4294967295,l=3266489909*(65535&(l^=l>>>13))+((3266489909*(l>>>16)&65535)<<16)&4294967295,(l^=l>>>16)>>>0};var oc=ul.exports,dl={exports:{}};dl.exports=function(i,t){for(var r,s=i.length,l=t^s,u=0;s>=4;)r=1540483477*(65535&(r=255&i.charCodeAt(u)|(255&i.charCodeAt(++u))<<8|(255&i.charCodeAt(++u))<<16|(255&i.charCodeAt(++u))<<24))+((1540483477*(r>>>16)&65535)<<16),l=1540483477*(65535&l)+((1540483477*(l>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),s-=4,++u;switch(s){case 3:l^=(255&i.charCodeAt(u+2))<<16;case 2:l^=(255&i.charCodeAt(u+1))<<8;case 1:l=1540483477*(65535&(l^=255&i.charCodeAt(u)))+((1540483477*(l>>>16)&65535)<<16)}return l=1540483477*(65535&(l^=l>>>13))+((1540483477*(l>>>16)&65535)<<16),(l^=l>>>15)>>>0};var zr=oc,pl=dl.exports;Fn.exports=zr,Fn.exports.murmur3=zr,Fn.exports.murmur2=pl;var oa=ki(Fn.exports);class gs{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,r,s,l){this.ids.push(la(t)),this.positions.push(r,s,l)}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");let r=la(t),s=0,l=this.ids.length-1;for(;s>1;this.ids[d]>=r?l=d:s=d+1}let u=[];for(;this.ids[s]===r;)u.push({index:this.positions[3*s],start:this.positions[3*s+1],end:this.positions[3*s+2]}),s++;return u}static serialize(t,r){let s=new Float64Array(t.ids),l=new Uint32Array(t.positions);return ca(s,l,0,s.length-1),r&&r.push(s.buffer,l.buffer),{ids:s,positions:l}}static deserialize(t){let r=new gs;return r.ids=t.ids,r.positions=t.positions,r.indexed=!0,r}}function la(i){let t=+i;return!isNaN(t)&&t<=Number.MAX_SAFE_INTEGER?t:oa(String(i))}function ca(i,t,r,s){for(;r>1],u=r-1,d=s+1;for(;;){do u++;while(i[u]l);if(u>=d)break;On(i,u,d),On(t,3*u,3*d),On(t,3*u+1,3*d+1),On(t,3*u+2,3*d+2)}d-r`u_${l}`),this.type=s}setUniform(t,r,s){t.set(s.constantOr(this.value))}getBinding(t,r,s){return this.type==="color"?new Qc(t,r):new fl(t,r)}}class ha{constructor(t,r){this.uniformNames=r.map(s=>`u_${s}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=r.tlbr,this.patternTo=t.tlbr}setUniform(t,r,s,l){let u=l==="u_pattern_to"?this.patternTo:l==="u_pattern_from"?this.patternFrom:l==="u_pixel_ratio_to"?this.pixelRatioTo:l==="u_pixel_ratio_from"?this.pixelRatioFrom:null;u&&t.set(u)}getBinding(t,r,s){return s.substr(0,9)==="u_pattern"?new Yc(t,r):new fl(t,r)}}class tn{constructor(t,r,s,l){this.expression=t,this.type=s,this.maxValue=0,this.paintVertexAttributes=r.map(u=>({name:`a_${u}`,type:"Float32",components:s==="color"?2:1,offset:0})),this.paintVertexArray=new l}populatePaintArray(t,r,s,l,u){let d=this.paintVertexArray.length,f=this.expression.evaluate(new dt(0),r,{},l,[],u);this.paintVertexArray.resize(t),this._setPaintValue(d,t,f)}updatePaintArray(t,r,s,l){let u=this.expression.evaluate({zoom:0},s,l);this._setPaintValue(t,r,u)}_setPaintValue(t,r,s){if(this.type==="color"){let l=lc(s);for(let u=t;u`u_${f}_t`),this.type=s,this.useIntegerZoom=l,this.zoom=u,this.maxValue=0,this.paintVertexAttributes=r.map(f=>({name:`a_${f}`,type:"Float32",components:s==="color"?4:2,offset:0})),this.paintVertexArray=new d}populatePaintArray(t,r,s,l,u){let d=this.expression.evaluate(new dt(this.zoom),r,{},l,[],u),f=this.expression.evaluate(new dt(this.zoom+1),r,{},l,[],u),_=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(_,t,d,f)}updatePaintArray(t,r,s,l){let u=this.expression.evaluate({zoom:this.zoom},s,l),d=this.expression.evaluate({zoom:this.zoom+1},s,l);this._setPaintValue(t,r,u,d)}_setPaintValue(t,r,s,l){if(this.type==="color"){let u=lc(s),d=lc(l);for(let f=t;f`#define HAS_UNIFORM_${l}`))}return t}getBinderAttributes(){let t=[];for(let r in this.binders){let s=this.binders[r];if(s instanceof tn||s instanceof gr)for(let l=0;l!0){this.programConfigurations={};for(let l of t)this.programConfigurations[l.id]=new eh(l,r,s);this.needsUpload=!1,this._featureMap=new gs,this._bufferOffset=0}populatePaintArrays(t,r,s,l,u,d){for(let f in this.programConfigurations)this.programConfigurations[f].populatePaintArrays(t,r,l,u,d);r.id!==void 0&&this._featureMap.add(r.id,s,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,r,s,l){for(let u of s)this.needsUpload=this.programConfigurations[u.id].updatePaintArrays(t,this._featureMap,r,u,l)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(let r in this.programConfigurations)this.programConfigurations[r].upload(t);this.needsUpload=!1}}destroy(){for(let t in this.programConfigurations)this.programConfigurations[t].destroy()}}function Ou(i,t){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-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"]}[i]||[i.replace(`${t}-`,"").replace(/-/g,"_")]}function th(i,t,r){let s={color:{source:E,composite:Ve},number:{source:xe,composite:E}},l=function(u){return{"line-pattern":{source:Pi,composite:Pi},"fill-pattern":{source:Pi,composite:Pi},"fill-extrusion-pattern":{source:Pi,composite:Pi}}[u]}(i);return l&&l[r]||s[t][r]}Ie("ConstantBinder",fo),Ie("CrossFadedConstantBinder",ha),Ie("SourceExpressionBinder",tn),Ie("CrossFadedCompositeBinder",Vn),Ie("CompositeExpressionBinder",gr),Ie("ProgramConfiguration",eh,{omit:["_buffers"]}),Ie("ProgramConfigurationSet",xs);let Mt=8192,cc=Math.pow(2,14)-1,ih=-cc-1;function vs(i){let t=Mt/i.extent,r=i.loadGeometry();for(let s=0;sd.x+1||_d.y+1)&&Ft("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return r}function bs(i,t){return{type:i.type,id:i.id,properties:i.properties,geometry:t?vs(i):[]}}function ml(i,t,r,s,l){i.emplaceBack(2*t+(s+1)/2,2*r+(l+1)/2)}class hc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(r=>r.id),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Jt,this.indexArray=new ji,this.segments=new We,this.programConfigurations=new xs(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(t,r,s){let l=this.layers[0],u=[],d=null,f=!1;l.type==="circle"&&(d=l.layout.get("circle-sort-key"),f=!d.isConstant());for(let{feature:_,id:x,index:v,sourceLayerIndex:w}of t){let I=this.layers[0]._featureFilter.needGeometry,M=bs(_,I);if(!this.layers[0]._featureFilter.filter(new dt(this.zoom),M,s))continue;let k=f?d.evaluate(M,{},s):void 0,z={id:x,properties:_.properties,type:_.type,sourceLayerIndex:w,index:v,geometry:I?M.geometry:vs(_),patterns:{},sortKey:k};u.push(z)}f&&u.sort((_,x)=>_.sortKey-x.sortKey);for(let _ of u){let{geometry:x,index:v,sourceLayerIndex:w}=_,I=t[v].feature;this.addFeature(_,x,v,s),r.featureIndex.insert(I,x,v,w,this.index)}}update(t,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,gi),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,r,s,l){for(let u of r)for(let d of u){let f=d.x,_=d.y;if(f<0||f>=Mt||_<0||_>=Mt)continue;let x=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),v=x.vertexLength;ml(this.layoutVertexArray,f,_,-1,-1),ml(this.layoutVertexArray,f,_,1,-1),ml(this.layoutVertexArray,f,_,1,1),ml(this.layoutVertexArray,f,_,-1,1),this.indexArray.emplaceBack(v,v+1,v+2),this.indexArray.emplaceBack(v,v+3,v+2),x.vertexLength+=4,x.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,{},l)}}function rh(i,t){for(let r=0;r1){if(uc(i,t))return!0;for(let s=0;s1?r:r.sub(t)._mult(l)._add(t))}function ah(i,t){let r,s,l,u=!1;for(let d=0;dt.y!=l.y>t.y&&t.x<(l.x-s.x)*(t.y-s.y)/(l.y-s.y)+s.x&&(u=!u)}return u}function ua(i,t){let r=!1;for(let s=0,l=i.length-1;st.y!=d.y>t.y&&t.x<(d.x-u.x)*(t.y-u.y)/(d.y-u.y)+u.x&&(r=!r)}return r}function Uu(i,t,r){let s=r[0],l=r[2];if(i.xl.x&&t.x>l.x||i.yl.y&&t.y>l.y)return!1;let u=Ht(i,t,r[0]);return u!==Ht(i,t,r[1])||u!==Ht(i,t,r[2])||u!==Ht(i,t,r[3])}function mo(i,t,r){let s=t.paint.get(i).value;return s.kind==="constant"?s.value:r.programConfigurations.get(t.id).getMaxValue(i)}function _l(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function gl(i,t,r,s,l){if(!t[0]&&!t[1])return i;let u=me.convert(t)._mult(l);r==="viewport"&&u._rotate(-s);let d=[];for(let f=0;fhh(F,z))}(x,_),M=w?v*f:v;for(let k of l)for(let z of k){let F=w?z:hh(z,_),j=M,Q=yl([],[z.x,z.y,0,1],_);if(this.paint.get("circle-pitch-scale")==="viewport"&&this.paint.get("circle-pitch-alignment")==="map"?j*=Q[3]/d.cameraToCenterDistance:this.paint.get("circle-pitch-scale")==="map"&&this.paint.get("circle-pitch-alignment")==="viewport"&&(j*=d.cameraToCenterDistance/Q[3]),Vu(I,F,j))return!0}return!1}}function hh(i,t){let r=yl([],[i.x,i.y,0,1],t);return new me(r[0]/r[3],r[1]/r[3])}class uh extends hc{}let dh;Ie("HeatmapBucket",uh,{omit:["layers"]});var Gu={get paint(){return dh=dh||new h({"heatmap-radius":new Re(ie.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Re(ie.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Ae(ie.paint_heatmap["heatmap-intensity"]),"heatmap-color":new uo(ie.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Ae(ie.paint_heatmap["heatmap-opacity"])})}};function fc(i,{width:t,height:r},s,l){if(l){if(l instanceof Uint8ClampedArray)l=new Uint8Array(l.buffer);else if(l.length!==t*r*s)throw new RangeError(`mismatched image size. expected: ${l.length} but got: ${t*r*s}`)}else l=new Uint8Array(t*r*s);return i.width=t,i.height=r,i.data=l,i}function ph(i,{width:t,height:r},s){if(t===i.width&&r===i.height)return;let l=fc({},{width:t,height:r},s);mc(i,l,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,t),height:Math.min(i.height,r)},s),i.width=t,i.height=r,i.data=l.data}function mc(i,t,r,s,l,u){if(l.width===0||l.height===0)return t;if(l.width>i.width||l.height>i.height||r.x>i.width-l.width||r.y>i.height-l.height)throw new RangeError("out of range source coordinates for image copy");if(l.width>t.width||l.height>t.height||s.x>t.width-l.width||s.y>t.height-l.height)throw new RangeError("out of range destination coordinates for image copy");let d=i.data,f=t.data;if(d===f)throw new Error("srcData equals dstData, so image is already copied");for(let _=0;_{t[i.evaluationKey]=_;let x=i.expression.evaluate(t);l.data[d+f+0]=Math.floor(255*x.r/x.a),l.data[d+f+1]=Math.floor(255*x.g/x.a),l.data[d+f+2]=Math.floor(255*x.b/x.a),l.data[d+f+3]=Math.floor(255*x.a)};if(i.clips)for(let d=0,f=0;d80*r){f=1/0,_=1/0;let v=-1/0,w=-1/0;for(let I=r;Iv&&(v=M),k>w&&(w=k)}x=Math.max(v-f,w-_),x=x!==0?32767/x:0}return yo(u,d,r,f,_,x,0),d}function gh(i,t,r,s,l){let u;if(l===function(d,f,_,x){let v=0;for(let w=f,I=_-x;w<_;w+=x)v+=(d[I]-d[w])*(d[w+1]+d[I+1]),I=w;return v}(i,t,r,s)>0)for(let d=t;d=t;d-=s)u=vh(d/s|0,i[d],i[d+1],u);return u&&xl(u,u.next)&&(vo(u),u=u.next),u}function ws(i,t){if(!i)return i;t||(t=i);let r,s=i;do if(r=!1,s.steiner||!xl(s,s.next)&&It(s.prev,s,s.next)!==0)s=s.next;else{if(vo(s),s=t=s.prev,s===s.next)break;r=!0}while(r||s!==t);return t}function yo(i,t,r,s,l,u,d){if(!i)return;!d&&u&&function(_,x,v,w){let I=_;do I.z===0&&(I.z=gc(I.x,I.y,x,v,w)),I.prevZ=I.prev,I.nextZ=I.next,I=I.next;while(I!==_);I.prevZ.nextZ=null,I.prevZ=null,function(M){let k,z=1;do{let F,j=M;M=null;let Q=null;for(k=0;j;){k++;let G=j,J=0;for(let ce=0;ce0||re>0&&G;)J!==0&&(re===0||!G||j.z<=G.z)?(F=j,j=j.nextZ,J--):(F=G,G=G.nextZ,re--),Q?Q.nextZ=F:M=F,F.prevZ=Q,Q=F;j=G}Q.nextZ=null,z*=2}while(k>1)}(I)}(i,s,l,u);let f=i;for(;i.prev!==i.next;){let _=i.prev,x=i.next;if(u?Qu(i,s,l,u):Yu(i))t.push(_.i,i.i,x.i),vo(i),i=x.next,f=x.next;else if((i=x)===f){d?d===1?yo(i=ed(ws(i),t),t,r,s,l,u,2):d===2&&td(i,t,r,s,l,u):yo(ws(i),t,r,s,l,u,1);break}}}function Yu(i){let t=i.prev,r=i,s=i.next;if(It(t,r,s)>=0)return!1;let l=t.x,u=r.x,d=s.x,f=t.y,_=r.y,x=s.y,v=lu?l>d?l:d:u>d?u:d,M=f>_?f>x?f:x:_>x?_:x,k=s.next;for(;k!==t;){if(k.x>=v&&k.x<=I&&k.y>=w&&k.y<=M&&pa(l,f,u,_,d,x,k.x,k.y)&&It(k.prev,k,k.next)>=0)return!1;k=k.next}return!0}function Qu(i,t,r,s){let l=i.prev,u=i,d=i.next;if(It(l,u,d)>=0)return!1;let f=l.x,_=u.x,x=d.x,v=l.y,w=u.y,I=d.y,M=f<_?f_?f>x?f:x:_>x?_:x,F=v>w?v>I?v:I:w>I?w:I,j=gc(M,k,t,r,s),Q=gc(z,F,t,r,s),G=i.prevZ,J=i.nextZ;for(;G&&G.z>=j&&J&&J.z<=Q;){if(G.x>=M&&G.x<=z&&G.y>=k&&G.y<=F&&G!==l&&G!==d&&pa(f,v,_,w,x,I,G.x,G.y)&&It(G.prev,G,G.next)>=0||(G=G.prevZ,J.x>=M&&J.x<=z&&J.y>=k&&J.y<=F&&J!==l&&J!==d&&pa(f,v,_,w,x,I,J.x,J.y)&&It(J.prev,J,J.next)>=0))return!1;J=J.nextZ}for(;G&&G.z>=j;){if(G.x>=M&&G.x<=z&&G.y>=k&&G.y<=F&&G!==l&&G!==d&&pa(f,v,_,w,x,I,G.x,G.y)&&It(G.prev,G,G.next)>=0)return!1;G=G.prevZ}for(;J&&J.z<=Q;){if(J.x>=M&&J.x<=z&&J.y>=k&&J.y<=F&&J!==l&&J!==d&&pa(f,v,_,w,x,I,J.x,J.y)&&It(J.prev,J,J.next)>=0)return!1;J=J.nextZ}return!0}function ed(i,t){let r=i;do{let s=r.prev,l=r.next.next;!xl(s,l)&&yh(s,r,r.next,l)&&xo(s,l)&&xo(l,s)&&(t.push(s.i,r.i,l.i),vo(r),vo(r.next),r=i=l),r=r.next}while(r!==i);return ws(r)}function td(i,t,r,s,l,u){let d=i;do{let f=d.next.next;for(;f!==d.prev;){if(d.i!==f.i&&ad(d,f)){let _=xh(d,f);return d=ws(d,d.next),_=ws(_,_.next),yo(d,t,r,s,l,u,0),void yo(_,t,r,s,l,u,0)}f=f.next}d=d.next}while(d!==i)}function id(i,t){return i.x-t.x}function rd(i,t){let r=function(l,u){let d=u,f=l.x,_=l.y,x,v=-1/0;do{if(_<=d.y&&_>=d.next.y&&d.next.y!==d.y){let z=d.x+(_-d.y)*(d.next.x-d.x)/(d.next.y-d.y);if(z<=f&&z>v&&(v=z,x=d.x=d.x&&d.x>=I&&f!==d.x&&pa(_x.x||d.x===x.x&&nd(x,d)))&&(x=d,k=z)}d=d.next}while(d!==w);return x}(i,t);if(!r)return t;let s=xh(r,i);return ws(s,s.next),ws(r,r.next)}function nd(i,t){return It(i.prev,i,t.prev)<0&&It(t.next,i,i.next)<0}function gc(i,t,r,s,l){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=(i-r)*l|0)|i<<8))|i<<4))|i<<2))|i<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-s)*l|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function sd(i){let t=i,r=i;do(t.x=(i-d)*(u-f)&&(i-d)*(s-f)>=(r-d)*(t-f)&&(r-d)*(u-f)>=(l-d)*(s-f)}function ad(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!function(r,s){let l=r;do{if(l.i!==r.i&&l.next.i!==r.i&&l.i!==s.i&&l.next.i!==s.i&&yh(l,l.next,r,s))return!0;l=l.next}while(l!==r);return!1}(i,t)&&(xo(i,t)&&xo(t,i)&&function(r,s){let l=r,u=!1,d=(r.x+s.x)/2,f=(r.y+s.y)/2;do l.y>f!=l.next.y>f&&l.next.y!==l.y&&d<(l.next.x-l.x)*(f-l.y)/(l.next.y-l.y)+l.x&&(u=!u),l=l.next;while(l!==r);return u}(i,t)&&(It(i.prev,i,t.prev)||It(i,t.prev,t))||xl(i,t)&&It(i.prev,i,i.next)>0&&It(t.prev,t,t.next)>0)}function It(i,t,r){return(t.y-i.y)*(r.x-t.x)-(t.x-i.x)*(r.y-t.y)}function xl(i,t){return i.x===t.x&&i.y===t.y}function yh(i,t,r,s){let l=bl(It(i,t,r)),u=bl(It(i,t,s)),d=bl(It(r,s,i)),f=bl(It(r,s,t));return l!==u&&d!==f||!(l!==0||!vl(i,r,t))||!(u!==0||!vl(i,s,t))||!(d!==0||!vl(r,i,s))||!(f!==0||!vl(r,t,s))}function vl(i,t,r){return t.x<=Math.max(i.x,r.x)&&t.x>=Math.min(i.x,r.x)&&t.y<=Math.max(i.y,r.y)&&t.y>=Math.min(i.y,r.y)}function bl(i){return i>0?1:i<0?-1:0}function xo(i,t){return It(i.prev,i,i.next)<0?It(i,t,i.next)>=0&&It(i,i.prev,t)>=0:It(i,t,i.prev)<0||It(i,i.next,t)<0}function xh(i,t){let r=yc(i.i,i.x,i.y),s=yc(t.i,t.x,t.y),l=i.next,u=t.prev;return i.next=t,t.prev=i,r.next=l,l.prev=r,s.next=r,r.prev=s,u.next=s,s.prev=u,s}function vh(i,t,r,s){let l=yc(i,t,r);return s?(l.next=s.next,l.prev=s,s.next.prev=l,s.next=l):(l.prev=l,l.next=l),l}function vo(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function yc(i,t,r){return{i,x:t,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function xc(i,t,r){let s=r.patternDependencies,l=!1;for(let u of t){let d=u.paint.get(`${i}-pattern`);d.isConstant()||(l=!0);let f=d.constantOr(null);f&&(l=!0,s[f.to]=!0,s[f.from]=!0)}return l}function vc(i,t,r,s,l){let u=l.patternDependencies;for(let d of t){let f=d.paint.get(`${i}-pattern`).value;if(f.kind!=="constant"){let _=f.evaluate({zoom:s-1},r,{},l.availableImages),x=f.evaluate({zoom:s},r,{},l.availableImages),v=f.evaluate({zoom:s+1},r,{},l.availableImages);_=_&&_.name?_.name:_,x=x&&x.name?x.name:x,v=v&&v.name?v.name:v,u[_]=!0,u[x]=!0,u[v]=!0,r.patterns[d.id]={min:_,mid:x,max:v}}}return r}class bc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(r=>r.id),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new ar,this.indexArray=new ji,this.indexArray2=new Rt,this.programConfigurations=new xs(t.layers,t.zoom),this.segments=new We,this.segments2=new We,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(t,r,s){this.hasPattern=xc("fill",this.layers,r);let l=this.layers[0].layout.get("fill-sort-key"),u=!l.isConstant(),d=[];for(let{feature:f,id:_,index:x,sourceLayerIndex:v}of t){let w=this.layers[0]._featureFilter.needGeometry,I=bs(f,w);if(!this.layers[0]._featureFilter.filter(new dt(this.zoom),I,s))continue;let M=u?l.evaluate(I,{},s,r.availableImages):void 0,k={id:_,properties:f.properties,type:f.type,sourceLayerIndex:v,index:x,geometry:w?I.geometry:vs(f),patterns:{},sortKey:M};d.push(k)}u&&d.sort((f,_)=>f.sortKey-_.sortKey);for(let f of d){let{geometry:_,index:x,sourceLayerIndex:v}=f;if(this.hasPattern){let w=vc("fill",this.layers,f,this.zoom,r);this.patternFeatures.push(w)}else this.addFeature(f,_,x,s,{});r.featureIndex.insert(t[x].feature,_,x,v,this.index)}}update(t,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,s)}addFeatures(t,r,s){for(let l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,r,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ju),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,r,s,l,u){for(let d of Fs(r,500)){let f=0;for(let M of d)f+=M.length;let _=this.segments.prepareSegment(f,this.layoutVertexArray,this.indexArray),x=_.vertexLength,v=[],w=[];for(let M of d){if(M.length===0)continue;M!==d[0]&&w.push(v.length/2);let k=this.segments2.prepareSegment(M.length,this.layoutVertexArray,this.indexArray2),z=k.vertexLength;this.layoutVertexArray.emplaceBack(M[0].x,M[0].y),this.indexArray2.emplaceBack(z+M.length-1,z),v.push(M[0].x),v.push(M[0].y);for(let F=1;F>3}if(l--,s===1||s===2)u+=i.readSVarint(),d+=i.readSVarint(),s===1&&(t&&f.push(t),t=[]),t.push(new dd(u,d));else{if(s!==7)throw new Error("unknown command "+s);t&&t.push(t[0].clone())}}return t&&f.push(t),f},fa.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var t=i.readVarint()+i.pos,r=1,s=0,l=0,u=0,d=1/0,f=-1/0,_=1/0,x=-1/0;i.pos>3}if(s--,r===1||r===2)(l+=i.readSVarint())f&&(f=l),(u+=i.readSVarint())<_&&(_=u),u>x&&(x=u);else if(r!==7)throw new Error("unknown command "+r)}return[d,_,f,x]},fa.prototype.toGeoJSON=function(i,t,r){var s,l,u=this.extent*Math.pow(2,r),d=this.extent*i,f=this.extent*t,_=this.loadGeometry(),x=fa.types[this.type];function v(M){for(var k=0;k>3;l=d===1?s.readString():d===2?s.readFloat():d===3?s.readDouble():d===4?s.readVarint64():d===5?s.readVarint():d===6?s.readSVarint():d===7?s.readBoolean():null}return l}(r))}Ih.prototype.feature=function(i){if(i<0||i>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[i];var t=this._pbf.readVarint()+this._pbf.pos;return new md(this._pbf,t,this.extent,this._keys,this._values)};var gd=Sh;function yd(i,t,r){if(i===3){var s=new gd(r,r.readVarint()+r.pos);s.length&&(t[s.name]=s)}}Nn.VectorTile=function(i,t){this.layers=i.readFields(yd,{},t)},Nn.VectorTileFeature=Th,Nn.VectorTileLayer=Sh;let xd=Nn.VectorTileFeature.types,wc=Math.pow(2,13);function bo(i,t,r,s,l,u,d,f){i.emplaceBack(t,r,2*Math.floor(s*wc)+d,l*wc*2,u*wc*2,Math.round(f))}class Tc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(r=>r.id),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Ln,this.centroidVertexArray=new Nt,this.indexArray=new ji,this.programConfigurations=new xs(t.layers,t.zoom),this.segments=new We,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(t,r,s){this.features=[],this.hasPattern=xc("fill-extrusion",this.layers,r);for(let{feature:l,id:u,index:d,sourceLayerIndex:f}of t){let _=this.layers[0]._featureFilter.needGeometry,x=bs(l,_);if(!this.layers[0]._featureFilter.filter(new dt(this.zoom),x,s))continue;let v={id:u,sourceLayerIndex:f,index:d,geometry:_?x.geometry:vs(l),properties:l.properties,type:l.type,patterns:{}};this.hasPattern?this.features.push(vc("fill-extrusion",this.layers,v,this.zoom,r)):this.addFeature(v,v.geometry,d,s,{}),r.featureIndex.insert(l,v.geometry,d,f,this.index,!0)}}addFeatures(t,r,s){for(let l of this.features){let{geometry:u}=l;this.addFeature(l,u,l.index,r,s)}}update(t,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,s)}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ud),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,hd.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(t,r,s,l,u){for(let d of Fs(r,500)){let f={x:0,y:0,vertexCount:0},_=0;for(let k of d)_+=k.length;let x=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(let k of d){if(k.length===0||bd(k))continue;let z=0;for(let F=0;F=1){let Q=k[F-1];if(!vd(j,Q)){x.vertexLength+4>We.MAX_VERTEX_ARRAY_LENGTH&&(x=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let G=j.sub(Q)._perp()._unit(),J=Q.dist(j);z+J>32768&&(z=0),bo(this.layoutVertexArray,j.x,j.y,G.x,G.y,0,0,z),bo(this.layoutVertexArray,j.x,j.y,G.x,G.y,0,1,z),f.x+=2*j.x,f.y+=2*j.y,f.vertexCount+=2,z+=J,bo(this.layoutVertexArray,Q.x,Q.y,G.x,G.y,0,0,z),bo(this.layoutVertexArray,Q.x,Q.y,G.x,G.y,0,1,z),f.x+=2*Q.x,f.y+=2*Q.y,f.vertexCount+=2;let re=x.vertexLength;this.indexArray.emplaceBack(re,re+2,re+1),this.indexArray.emplaceBack(re+1,re+2,re+3),x.vertexLength+=4,x.primitiveLength+=2}}}}if(x.vertexLength+_>We.MAX_VERTEX_ARRAY_LENGTH&&(x=this.segments.prepareSegment(_,this.layoutVertexArray,this.indexArray)),xd[t.type]!=="Polygon")continue;let v=[],w=[],I=x.vertexLength;for(let k of d)if(k.length!==0){k!==d[0]&&w.push(v.length/2);for(let z=0;zMt)||i.y===t.y&&(i.y<0||i.y>Mt)}function bd(i){return i.every(t=>t.x<0)||i.every(t=>t.x>Mt)||i.every(t=>t.y<0)||i.every(t=>t.y>Mt)}let Ph;Ie("FillExtrusionBucket",Tc,{omit:["layers","features"]});var wd={get paint(){return Ph=Ph||new h({"fill-extrusion-opacity":new Ae(ie["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Re(ie["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Ae(ie["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Ae(ie["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new ra(ie["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Re(ie["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Re(ie["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Ae(ie["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Td extends n{constructor(t){super(t,wd)}createBucket(t){return new Tc(t)}queryRadius(){return _l(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(t,r,s,l,u,d,f,_){let x=gl(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),d.angle,f),v=this.paint.get("fill-extrusion-height").evaluate(r,s),w=this.paint.get("fill-extrusion-base").evaluate(r,s),I=function(k,z,F,j){let Q=[];for(let G of k){let J=[G.x,G.y,0,1];yl(J,J,z),Q.push(new me(J[0]/J[3],J[1]/J[3]))}return Q}(x,_),M=function(k,z,F,j){let Q=[],G=[],J=j[8]*z,re=j[9]*z,ce=j[10]*z,we=j[11]*z,Le=j[8]*F,ve=j[9]*F,ye=j[10]*F,ke=j[11]*F;for(let Pe of k){let Se=[],ae=[];for(let ze of Pe){let Ce=ze.x,Oe=ze.y,ct=j[0]*Ce+j[4]*Oe+j[12],lt=j[1]*Ce+j[5]*Oe+j[13],zt=j[2]*Ce+j[6]*Oe+j[14],or=j[3]*Ce+j[7]*Oe+j[15],$t=zt+ce,Et=or+we,ai=ct+Le,oi=lt+ve,li=zt+ye,Tt=or+ke,Dt=new me((ct+J)/Et,(lt+re)/Et);Dt.z=$t/Et,Se.push(Dt);let Yt=new me(ai/Tt,oi/Tt);Yt.z=li/Tt,ae.push(Yt)}Q.push(Se),G.push(ae)}return[Q,G]}(l,w,v,_);return function(k,z,F){let j=1/0;nh(F,z)&&(j=Ah(F,z[0]));for(let Q=0;Qr.id),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(r=>{this.gradients[r.id]={}}),this.layoutVertexArray=new sa,this.layoutVertexArray2=new Rn,this.indexArray=new ji,this.programConfigurations=new xs(t.layers,t.zoom),this.segments=new We,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(t,r,s){this.hasPattern=xc("line",this.layers,r);let l=this.layers[0].layout.get("line-sort-key"),u=!l.isConstant(),d=[];for(let{feature:f,id:_,index:x,sourceLayerIndex:v}of t){let w=this.layers[0]._featureFilter.needGeometry,I=bs(f,w);if(!this.layers[0]._featureFilter.filter(new dt(this.zoom),I,s))continue;let M=u?l.evaluate(I,{},s):void 0,k={id:_,properties:f.properties,type:f.type,sourceLayerIndex:v,index:x,geometry:w?I.geometry:vs(f),patterns:{},sortKey:M};d.push(k)}u&&d.sort((f,_)=>f.sortKey-_.sortKey);for(let f of d){let{geometry:_,index:x,sourceLayerIndex:v}=f;if(this.hasPattern){let w=vc("line",this.layers,f,this.zoom,r);this.patternFeatures.push(w)}else this.addFeature(f,_,x,s,{});r.featureIndex.insert(t[x].feature,_,x,v,this.index)}}update(t,r,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,r,this.stateDependentLayers,s)}addFeatures(t,r,s){for(let l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,r,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Ad)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Id),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,r,s,l,u){let d=this.layers[0].layout,f=d.get("line-join").evaluate(t,{}),_=d.get("line-cap"),x=d.get("line-miter-limit"),v=d.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(let w of r)this.addLine(w,t,f,_,x,v);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,u,l)}addLine(t,r,s,l,u,d){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let j=0;j=2&&t[_-1].equals(t[_-2]);)_--;let x=0;for(;x<_-1&&t[x].equals(t[x+1]);)x++;if(_<(f?3:2))return;s==="bevel"&&(u=1.05);let v=this.overscaling<=16?15*Mt/(512*this.overscaling):0,w=this.segments.prepareSegment(10*_,this.layoutVertexArray,this.indexArray),I,M,k,z,F;this.e1=this.e2=-1,f&&(I=t[_-2],F=t[x].sub(I)._unit()._perp());for(let j=x;j<_;j++){if(k=j===_-1?f?t[x+1]:void 0:t[j+1],k&&t[j].equals(k))continue;F&&(z=F),I&&(M=I),I=t[j],F=k?k.sub(I)._unit()._perp():z,z=z||F;let Q=z.add(F);Q.x===0&&Q.y===0||Q._unit();let G=z.x*F.x+z.y*F.y,J=Q.x*F.x+Q.y*F.y,re=J!==0?1/J:1/0,ce=2*Math.sqrt(2-2*J),we=J0;if(we&&j>x){let ke=I.dist(M);if(ke>2*v){let Pe=I.sub(I.sub(M)._mult(v/ke)._round());this.updateDistance(M,Pe),this.addCurrentVertex(Pe,z,0,0,w),M=Pe}}let ve=M&&k,ye=ve?s:f?"butt":l;if(ve&&ye==="round"&&(reu&&(ye="bevel"),ye==="bevel"&&(re>2&&(ye="flipbevel"),re100)Q=F.mult(-1);else{let ke=re*z.add(F).mag()/z.sub(F).mag();Q._perp()._mult(ke*(Le?-1:1))}this.addCurrentVertex(I,Q,0,0,w),this.addCurrentVertex(I,Q.mult(-1),0,0,w)}else if(ye==="bevel"||ye==="fakeround"){let ke=-Math.sqrt(re*re-1),Pe=Le?ke:0,Se=Le?0:ke;if(M&&this.addCurrentVertex(I,z,Pe,Se,w),ye==="fakeround"){let ae=Math.round(180*ce/Math.PI/20);for(let ze=1;ze2*v){let Pe=I.add(k.sub(I)._mult(v/ke)._round());this.updateDistance(I,Pe),this.addCurrentVertex(Pe,F,0,0,w),I=Pe}}}}addCurrentVertex(t,r,s,l,u,d=!1){let f=r.y*l-r.x,_=-r.y-r.x*l;this.addHalfVertex(t,r.x+r.y*s,r.y-r.x*s,d,!1,s,u),this.addHalfVertex(t,f,_,d,!0,-l,u),this.distance>Mh/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,r,s,l,u,d))}addHalfVertex({x:t,y:r},s,l,u,d,f,_){let x=.5*(this.lineClips?this.scaledDistance*(Mh-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(u?1:0),(r<<1)+(d?1:0),Math.round(63*s)+128,Math.round(63*l)+128,1+(f===0?0:f<0?-1:1)|(63&x)<<2,x>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);let v=_.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,v),_.primitiveLength++),d?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(t,r){this.distance+=t.dist(r),this.updateScaledDistance()}}let Ch,kh;Ie("LineBucket",Sc,{omit:["layers","patternFeatures"]});var zh={get paint(){return kh=kh||new h({"line-opacity":new Re(ie.paint_line["line-opacity"]),"line-color":new Re(ie.paint_line["line-color"]),"line-translate":new Ae(ie.paint_line["line-translate"]),"line-translate-anchor":new Ae(ie.paint_line["line-translate-anchor"]),"line-width":new Re(ie.paint_line["line-width"]),"line-gap-width":new Re(ie.paint_line["line-gap-width"]),"line-offset":new Re(ie.paint_line["line-offset"]),"line-blur":new Re(ie.paint_line["line-blur"]),"line-dasharray":new na(ie.paint_line["line-dasharray"]),"line-pattern":new ra(ie.paint_line["line-pattern"]),"line-gradient":new uo(ie.paint_line["line-gradient"])})},get layout(){return Ch=Ch||new h({"line-cap":new Ae(ie.layout_line["line-cap"]),"line-join":new Re(ie.layout_line["line-join"]),"line-miter-limit":new Ae(ie.layout_line["line-miter-limit"]),"line-round-limit":new Ae(ie.layout_line["line-round-limit"]),"line-sort-key":new Re(ie.layout_line["line-sort-key"])})}};class kd extends Re{possiblyEvaluate(t,r){return r=new dt(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(t,r)}evaluate(t,r,s,l){return r=vi({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(t,r,s,l)}}let wl;class zd extends n{constructor(t){super(t,zh),this.gradientVersion=0,wl||(wl=new kd(zh.paint.properties["line-width"].specification),wl.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(t){if(t==="line-gradient"){let r=this.gradientExpression();this.stepInterpolant=!!function(s){return s._styleExpression!==void 0}(r)&&r._styleExpression.expression instanceof mn,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,r){super.recalculate(t,r),this.paint._values["line-floorwidth"]=wl.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new Sc(t)}queryRadius(t){let r=t,s=Eh(mo("line-width",this,r),mo("line-gap-width",this,r)),l=mo("line-offset",this,r);return s/2+Math.abs(l)+_l(this.paint.get("line-translate"))}queryIntersectsFeature(t,r,s,l,u,d,f){let _=gl(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),d.angle,f),x=f/2*Eh(this.paint.get("line-width").evaluate(r,s),this.paint.get("line-gap-width").evaluate(r,s)),v=this.paint.get("line-offset").evaluate(r,s);return v&&(l=function(w,I){let M=[];for(let k=0;k=3){for(let F=0;F0?t+2*i:i}let Ed=m([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Dd=m([{name:"a_projected_pos",components:3,type:"Float32"}],4);m([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);let Ld=m([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);m([{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"}]);let Dh=m([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Rd=m([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Bd(i,t,r){return i.sections.forEach(s=>{s.text=function(l,u,d){let f=u.layout.get("text-transform").evaluate(d,{});return f==="uppercase"?l=l.toLocaleUpperCase():f==="lowercase"&&(l=l.toLocaleLowerCase()),_i.applyArabicShaping&&(l=_i.applyArabicShaping(l)),l}(s.text,t,r)}),i}m([{name:"triangle",components:3,type:"Uint16"}]),m([{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"}]),m([{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"}]),m([{type:"Float32",name:"offsetX"}]),m([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),m([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);let To={"!":"\uFE15","#":"\uFF03",$:"\uFF04","%":"\uFF05","&":"\uFF06","(":"\uFE35",")":"\uFE36","*":"\uFF0A","+":"\uFF0B",",":"\uFE10","-":"\uFE32",".":"\u30FB","/":"\uFF0F",":":"\uFE13",";":"\uFE14","<":"\uFE3F","=":"\uFF1D",">":"\uFE40","?":"\uFE16","@":"\uFF20","[":"\uFE47","\\":"\uFF3C","]":"\uFE48","^":"\uFF3E",_:"\uFE33","`":"\uFF40","{":"\uFE37","|":"\u2015","}":"\uFE38","~":"\uFF5E","\xA2":"\uFFE0","\xA3":"\uFFE1","\xA5":"\uFFE5","\xA6":"\uFFE4","\xAC":"\uFFE2","\xAF":"\uFFE3","\u2013":"\uFE32","\u2014":"\uFE31","\u2018":"\uFE43","\u2019":"\uFE44","\u201C":"\uFE41","\u201D":"\uFE42","\u2026":"\uFE19","\u2027":"\u30FB","\u20A9":"\uFFE6","\u3001":"\uFE11","\u3002":"\uFE12","\u3008":"\uFE3F","\u3009":"\uFE40","\u300A":"\uFE3D","\u300B":"\uFE3E","\u300C":"\uFE41","\u300D":"\uFE42","\u300E":"\uFE43","\u300F":"\uFE44","\u3010":"\uFE3B","\u3011":"\uFE3C","\u3014":"\uFE39","\u3015":"\uFE3A","\u3016":"\uFE17","\u3017":"\uFE18","\uFF01":"\uFE15","\uFF08":"\uFE35","\uFF09":"\uFE36","\uFF0C":"\uFE10","\uFF0D":"\uFE32","\uFF0E":"\u30FB","\uFF1A":"\uFE13","\uFF1B":"\uFE14","\uFF1C":"\uFE3F","\uFF1E":"\uFE40","\uFF1F":"\uFE16","\uFF3B":"\uFE47","\uFF3D":"\uFE48","\uFF3F":"\uFE33","\uFF5B":"\uFE37","\uFF5C":"\u2015","\uFF5D":"\uFE38","\uFF5F":"\uFE35","\uFF60":"\uFE36","\uFF61":"\uFE12","\uFF62":"\uFE41","\uFF63":"\uFE42"};var Ct=24,Lh=ot,Rh=function(i,t,r,s,l){var u,d,f=8*l-s-1,_=(1<>1,v=-7,w=r?l-1:0,I=r?-1:1,M=i[t+w];for(w+=I,u=M&(1<<-v)-1,M>>=-v,v+=f;v>0;u=256*u+i[t+w],w+=I,v-=8);for(d=u&(1<<-v)-1,u>>=-v,v+=s;v>0;d=256*d+i[t+w],w+=I,v-=8);if(u===0)u=1-x;else{if(u===_)return d?NaN:1/0*(M?-1:1);d+=Math.pow(2,s),u-=x}return(M?-1:1)*d*Math.pow(2,u-s)},Bh=function(i,t,r,s,l,u){var d,f,_,x=8*u-l-1,v=(1<>1,I=l===23?Math.pow(2,-24)-Math.pow(2,-77):0,M=s?0:u-1,k=s?1:-1,z=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(f=isNaN(t)?1:0,d=v):(d=Math.floor(Math.log(t)/Math.LN2),t*(_=Math.pow(2,-d))<1&&(d--,_*=2),(t+=d+w>=1?I/_:I*Math.pow(2,1-w))*_>=2&&(d++,_/=2),d+w>=v?(f=0,d=v):d+w>=1?(f=(t*_-1)*Math.pow(2,l),d+=w):(f=t*Math.pow(2,w-1)*Math.pow(2,l),d=0));l>=8;i[r+M]=255&f,M+=k,f/=256,l-=8);for(d=d<0;i[r+M]=255&d,M+=k,d/=256,x-=8);i[r+M-k]|=128*z};function ot(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}ot.Varint=0,ot.Fixed64=1,ot.Bytes=2,ot.Fixed32=5;var Ic=4294967296,Fh=1/Ic,Oh=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");function rn(i){return i.type===ot.Bytes?i.readVarint()+i.pos:i.pos+1}function ma(i,t,r){return r?4294967296*t+(i>>>0):4294967296*(t>>>0)+(i>>>0)}function Vh(i,t,r){var s=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));r.realloc(s);for(var l=r.pos-1;l>=i;l--)r.buf[l+s]=r.buf[l]}function Fd(i,t){for(var r=0;r>>8,i[r+2]=t>>>16,i[r+3]=t>>>24}function Nh(i,t){return(i[t]|i[t+1]<<8|i[t+2]<<16)+(i[t+3]<<24)}ot.prototype={destroy:function(){this.buf=null},readFields:function(i,t,r){for(r=r||this.length;this.pos>3,u=this.pos;this.type=7&s,i(l,t,this),this.pos===u&&this.skip(s)}return t},readMessage:function(i,t){return this.readFields(i,t,this.readVarint()+this.pos)},readFixed32:function(){var i=Tl(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=Nh(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=Tl(this.buf,this.pos)+Tl(this.buf,this.pos+4)*Ic;return this.pos+=8,i},readSFixed64:function(){var i=Tl(this.buf,this.pos)+Nh(this.buf,this.pos+4)*Ic;return this.pos+=8,i},readFloat:function(){var i=Rh(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=Rh(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var t,r,s=this.buf;return t=127&(r=s[this.pos++]),r<128?t:(t|=(127&(r=s[this.pos++]))<<7,r<128?t:(t|=(127&(r=s[this.pos++]))<<14,r<128?t:(t|=(127&(r=s[this.pos++]))<<21,r<128?t:function(l,u,d){var f,_,x=d.buf;if(f=(112&(_=x[d.pos++]))>>4,_<128||(f|=(127&(_=x[d.pos++]))<<3,_<128)||(f|=(127&(_=x[d.pos++]))<<10,_<128)||(f|=(127&(_=x[d.pos++]))<<17,_<128)||(f|=(127&(_=x[d.pos++]))<<24,_<128)||(f|=(1&(_=x[d.pos++]))<<31,_<128))return ma(l,f,u);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(r=s[this.pos]))<<28,i,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var i=this.readVarint();return i%2==1?(i+1)/-2:i/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var i=this.readVarint()+this.pos,t=this.pos;return this.pos=i,i-t>=12&&Oh?function(r,s,l){return Oh.decode(r.subarray(s,l))}(this.buf,t,i):function(r,s,l){for(var u="",d=s;d239?4:v>223?3:v>191?2:1;if(d+I>l)break;I===1?v<128&&(w=v):I===2?(192&(f=r[d+1]))==128&&(w=(31&v)<<6|63&f)<=127&&(w=null):I===3?(_=r[d+2],(192&(f=r[d+1]))==128&&(192&_)==128&&((w=(15&v)<<12|(63&f)<<6|63&_)<=2047||w>=55296&&w<=57343)&&(w=null)):I===4&&(_=r[d+2],x=r[d+3],(192&(f=r[d+1]))==128&&(192&_)==128&&(192&x)==128&&((w=(15&v)<<18|(63&f)<<12|(63&_)<<6|63&x)<=65535||w>=1114112)&&(w=null)),w===null?(w=65533,I=1):w>65535&&(w-=65536,u+=String.fromCharCode(w>>>10&1023|55296),w=56320|1023&w),u+=String.fromCharCode(w),d+=I}return u}(this.buf,t,i)},readBytes:function(){var i=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,i);return this.pos=i,t},readPackedVarint:function(i,t){if(this.type!==ot.Bytes)return i.push(this.readVarint(t));var r=rn(this);for(i=i||[];this.pos127;);else if(t===ot.Bytes)this.pos=this.readVarint()+this.pos;else if(t===ot.Fixed32)this.pos+=4;else{if(t!==ot.Fixed64)throw new Error("Unimplemented type: "+t);this.pos+=8}},writeTag:function(i,t){this.writeVarint(i<<3|t)},realloc:function(i){for(var t=this.length||16;t268435455||i<0?function(t,r){var s,l;if(t>=0?(s=t%4294967296|0,l=t/4294967296|0):(l=~(-t/4294967296),4294967295^(s=~(-t%4294967296))?s=s+1|0:(s=0,l=l+1|0)),t>=18446744073709552e3||t<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");r.realloc(10),function(u,d,f){f.buf[f.pos++]=127&u|128,u>>>=7,f.buf[f.pos++]=127&u|128,u>>>=7,f.buf[f.pos++]=127&u|128,u>>>=7,f.buf[f.pos++]=127&u|128,f.buf[f.pos]=127&(u>>>=7)}(s,0,r),function(u,d){var f=(7&u)<<4;d.buf[d.pos++]|=f|((u>>>=3)?128:0),u&&(d.buf[d.pos++]=127&u|((u>>>=7)?128:0),u&&(d.buf[d.pos++]=127&u|((u>>>=7)?128:0),u&&(d.buf[d.pos++]=127&u|((u>>>=7)?128:0),u&&(d.buf[d.pos++]=127&u|((u>>>=7)?128:0),u&&(d.buf[d.pos++]=127&u)))))}(l,r)}(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?2*-i-1:2*i)},writeBoolean:function(i){this.writeVarint(!!i)},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var t=this.pos;this.pos=function(s,l,u){for(var d,f,_=0;_55295&&d<57344){if(!f){d>56319||_+1===l.length?(s[u++]=239,s[u++]=191,s[u++]=189):f=d;continue}if(d<56320){s[u++]=239,s[u++]=191,s[u++]=189,f=d;continue}d=f-55296<<10|d-56320|65536,f=null}else f&&(s[u++]=239,s[u++]=191,s[u++]=189,f=null);d<128?s[u++]=d:(d<2048?s[u++]=d>>6|192:(d<65536?s[u++]=d>>12|224:(s[u++]=d>>18|240,s[u++]=d>>12&63|128),s[u++]=d>>6&63|128),s[u++]=63&d|128)}return u}(this.buf,i,this.pos);var r=this.pos-t;r>=128&&Vh(t,r,this),this.pos=t-1,this.writeVarint(r),this.pos+=r},writeFloat:function(i){this.realloc(4),Bh(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),Bh(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var t=i.length;this.writeVarint(t),this.realloc(t);for(var r=0;r=128&&Vh(r,s,this),this.pos=r-1,this.writeVarint(s),this.pos+=s},writeMessage:function(i,t,r){this.writeTag(i,ot.Bytes),this.writeRawMessage(t,r)},writePackedVarint:function(i,t){t.length&&this.writeMessage(i,Fd,t)},writePackedSVarint:function(i,t){t.length&&this.writeMessage(i,Od,t)},writePackedBoolean:function(i,t){t.length&&this.writeMessage(i,jd,t)},writePackedFloat:function(i,t){t.length&&this.writeMessage(i,Vd,t)},writePackedDouble:function(i,t){t.length&&this.writeMessage(i,Nd,t)},writePackedFixed32:function(i,t){t.length&&this.writeMessage(i,Ud,t)},writePackedSFixed32:function(i,t){t.length&&this.writeMessage(i,$d,t)},writePackedFixed64:function(i,t){t.length&&this.writeMessage(i,qd,t)},writePackedSFixed64:function(i,t){t.length&&this.writeMessage(i,Zd,t)},writeBytesField:function(i,t){this.writeTag(i,ot.Bytes),this.writeBytes(t)},writeFixed32Field:function(i,t){this.writeTag(i,ot.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(i,t){this.writeTag(i,ot.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(i,t){this.writeTag(i,ot.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(i,t){this.writeTag(i,ot.Fixed64),this.writeSFixed64(t)},writeVarintField:function(i,t){this.writeTag(i,ot.Varint),this.writeVarint(t)},writeSVarintField:function(i,t){this.writeTag(i,ot.Varint),this.writeSVarint(t)},writeStringField:function(i,t){this.writeTag(i,ot.Bytes),this.writeString(t)},writeFloatField:function(i,t){this.writeTag(i,ot.Fixed32),this.writeFloat(t)},writeDoubleField:function(i,t){this.writeTag(i,ot.Fixed64),this.writeDouble(t)},writeBooleanField:function(i,t){this.writeVarintField(i,!!t)}};var Pc=ki(Lh);let Ac=3;function Gd(i,t,r){i===1&&r.readMessage(Hd,t)}function Hd(i,t,r){if(i===3){let{id:s,bitmap:l,width:u,height:d,left:f,top:_,advance:x}=r.readMessage(Xd,{});t.push({id:s,bitmap:new go({width:u+2*Ac,height:d+2*Ac},l),metrics:{width:u,height:d,left:f,top:_,advance:x}})}}function Xd(i,t,r){i===1?t.id=r.readVarint():i===2?t.bitmap=r.readBytes():i===3?t.width=r.readVarint():i===4?t.height=r.readVarint():i===5?t.left=r.readSVarint():i===6?t.top=r.readSVarint():i===7&&(t.advance=r.readVarint())}let jh=Ac;function Uh(i){let t=0,r=0;for(let d of i)t+=d.w*d.h,r=Math.max(r,d.w);i.sort((d,f)=>f.h-d.h);let s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),r),h:1/0}],l=0,u=0;for(let d of i)for(let f=s.length-1;f>=0;f--){let _=s[f];if(!(d.w>_.w||d.h>_.h)){if(d.x=_.x,d.y=_.y,u=Math.max(u,d.y+d.h),l=Math.max(l,d.x+d.w),d.w===_.w&&d.h===_.h){let x=s.pop();f=0&&s>=t&&Il[this.text.charCodeAt(s)];s--)r--;this.text=this.text.substring(t,r),this.sectionIndex=this.sectionIndex.slice(t,r)}substring(t,r){let s=new ga;return s.text=this.text.substring(t,r),s.sectionIndex=this.sectionIndex.slice(t,r),s.sections=this.sections,s}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((t,r)=>Math.max(t,this.sections[r].scale),0)}addTextSection(t,r){this.text+=t.text,this.sections.push(Io.forText(t.scale,t.fontStack||r));let s=this.sections.length-1;for(let l=0;l=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Sl(i,t,r,s,l,u,d,f,_,x,v,w,I,M,k){let z=ga.fromFeature(i,l),F;w===L.ah.vertical&&z.verticalizePunctuation();let{processBidirectionalText:j,processStyledBidirectionalText:Q}=_i;if(j&&z.sections.length===1){F=[];let re=j(z.toString(),Cc(z,x,u,t,s,M));for(let ce of re){let we=new ga;we.text=ce,we.sections=z.sections;for(let Le=0;Le0&&nn>Zt&&(Zt=nn)}else{let Zi=we[Qe.fontStack],Bt=Zi&&Zi[_t];if(Bt&&Bt.rect)ba=Bt.rect,vt=Bt.metrics;else{let nn=ce[Qe.fontStack],zo=nn&&nn[_t];if(!zo)continue;vt=zo.metrics}Ci=(Dt-Qe.scale)*Ct}lr?(re.verticalizable=!0,ci.push({glyph:_t,imageName:Dr,x:Oe,y:ct+Ci,vertical:lr,scale:Qe.scale,fontStack:Qe.fontStack,sectionIndex:ut,metrics:vt,rect:ba}),Oe+=Lr*Qe.scale+ae):(ci.push({glyph:_t,imageName:Dr,x:Oe,y:ct+Ci,vertical:lr,scale:Qe.scale,fontStack:Qe.fontStack,sectionIndex:ut,metrics:vt,rect:ba}),Oe+=vt.advance*Qe.scale+ae)}ci.length!==0&&(lt=Math.max(Oe-ae,lt),Yd(ci,0,ci.length-1,or,Zt)),Oe=0;let qi=ye*Dt+Zt;qt.lineOffset=Math.max(Zt,Yt),ct+=qi,zt=Math.max(qi,zt),++$t}var Et;let ai=ct-So,{horizontalAlign:oi,verticalAlign:li}=kc(ke);(function(Tt,Dt,Yt,qt,ci,Zt,qi,xi,Qe){let ut=(Dt-Yt)*ci,_t=0;_t=Zt!==qi?-xi*qt-So:(-qt*Qe+.5)*qi;for(let Ci of Tt)for(let vt of Ci.positionedGlyphs)vt.x+=ut,vt.y+=_t})(re.positionedLines,or,oi,li,lt,zt,ye,ai,ve.length),re.top+=-li*ai,re.bottom=re.top+ai,re.left+=-oi*lt,re.right=re.left+lt}(J,t,r,s,F,d,f,_,w,x,I,k),!function(re){for(let ce of re)if(ce.positionedGlyphs.length!==0)return!1;return!0}(G)&&J}let Il={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Wd={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},Kd={40:!0};function qh(i,t,r,s,l,u){if(t.imageName){let d=s[t.imageName];return d?d.displaySize[0]*t.scale*Ct/u+l:0}{let d=r[t.fontStack],f=d&&d[i];return f?f.metrics.advance*t.scale+l:0}}function Zh(i,t,r,s){let l=Math.pow(i-t,2);return s?i=0,x=0;for(let w=0;wx){let v=Math.ceil(u/x);l*=v/d,d=v}return{x1:s,y1:l,x2:s+u,y2:l+d}}function Wh(i,t,r,s,l,u){let d=i.image,f;if(d.content){let F=d.content,j=d.pixelRatio||1;f=[F[0]/j,F[1]/j,d.displaySize[0]-F[2]/j,d.displaySize[1]-F[3]/j]}let _=t.left*u,x=t.right*u,v,w,I,M;r==="width"||r==="both"?(M=l[0]+_-s[3],w=l[0]+x+s[1]):(M=l[0]+(_+x-d.displaySize[0])/2,w=M+d.displaySize[0]);let k=t.top*u,z=t.bottom*u;return r==="height"||r==="both"?(v=l[1]+k-s[0],I=l[1]+z+s[2]):(v=l[1]+(k+z-d.displaySize[1])/2,I=v+d.displaySize[1]),{image:d,top:v,right:w,bottom:I,left:M,collisionPadding:f}}let Po=255,Er=128,Un=Po*Er;function Kh(i,t){let{expression:r}=t;if(r.kind==="constant")return{kind:"constant",layoutSize:r.evaluate(new dt(i+1))};if(r.kind==="source")return{kind:"source"};{let{zoomStops:s,interpolationType:l}=r,u=0;for(;ud.id),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=pc([]),this.placementViewportMatrix=pc([]);let r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Kh(this.zoom,r["text-size"]),this.iconSizeData=Kh(this.zoom,r["icon-size"]);let s=this.layers[0].layout,l=s.get("symbol-sort-key"),u=s.get("symbol-z-order");this.canOverlap=zc(s,"text-overlap","text-allow-overlap")!=="never"||zc(s,"icon-overlap","icon-allow-overlap")!=="never"||s.get("text-ignore-placement")||s.get("icon-ignore-placement"),this.sortFeaturesByKey=u!=="viewport-y"&&!l.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(d=>L.ah[d])),this.stateDependentLayerIds=this.layers.filter(d=>d.isStateDependent()).map(d=>d.id),this.sourceID=t.sourceID}createArrays(){this.text=new Dc(new xs(this.layers,this.zoom,t=>/^text/.test(t))),this.icon=new Dc(new xs(this.layers,this.zoom,t=>/^icon/.test(t))),this.glyphOffsetArray=new ft,this.lineVertexArray=new Vt,this.symbolInstances=new He,this.textAnchorOffsets=new mt}calculateGlyphDependencies(t,r,s,l,u){for(let d=0;d0)&&(d.value.kind!=="constant"||d.value.value.length>0),v=_.value.kind!=="constant"||!!_.value.value||Object.keys(_.parameters).length>0,w=u.get("symbol-sort-key");if(this.features=[],!x&&!v)return;let I=r.iconDependencies,M=r.glyphDependencies,k=r.availableImages,z=new dt(this.zoom);for(let{feature:F,id:j,index:Q,sourceLayerIndex:G}of t){let J=l._featureFilter.needGeometry,re=bs(F,J);if(!l._featureFilter.filter(z,re,s))continue;let ce,we;if(J||(re.geometry=vs(F)),x){let ve=l.getValueAndResolveTokens("text-field",re,s,k),ye=di.factory(ve),ke=this.hasRTLText=this.hasRTLText||ip(ye);(!ke||_i.getRTLTextPluginStatus()==="unavailable"||ke&&_i.isParsed())&&(ce=Bd(ye,l,re))}if(v){let ve=l.getValueAndResolveTokens("icon-image",re,s,k);we=ve instanceof fi?ve:fi.fromString(ve)}if(!ce&&!we)continue;let Le=this.sortFeaturesByKey?w.evaluate(re,{},s):void 0;if(this.features.push({id:j,text:ce,icon:we,index:Q,sourceLayerIndex:G,geometry:re.geometry,properties:F.properties,type:ep[F.type],sortKey:Le}),we&&(I[we.name]=!0),ce){let ve=d.evaluate(re,{},s).join(","),ye=u.get("text-rotation-alignment")!=="viewport"&&u.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(L.ah.vertical)>=0;for(let ke of ce.sections)if(ke.image)I[ke.image.name]=!0;else{let Pe=oo(ce.toString()),Se=ke.fontStack||ve,ae=M[Se]=M[Se]||{};this.calculateGlyphDependencies(ke.text,ae,ye,this.allowVerticalPlacement,Pe)}}}u.get("symbol-placement")==="line"&&(this.features=function(F){let j={},Q={},G=[],J=0;function re(ve){G.push(F[ve]),J++}function ce(ve,ye,ke){let Pe=Q[ve];return delete Q[ve],Q[ye]=Pe,G[Pe].geometry[0].pop(),G[Pe].geometry[0]=G[Pe].geometry[0].concat(ke[0]),Pe}function we(ve,ye,ke){let Pe=j[ye];return delete j[ye],j[ve]=Pe,G[Pe].geometry[0].shift(),G[Pe].geometry[0]=ke[0].concat(G[Pe].geometry[0]),Pe}function Le(ve,ye,ke){let Pe=ke?ye[0][ye[0].length-1]:ye[0][0];return`${ve}:${Pe.x}:${Pe.y}`}for(let ve=0;veve.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((F,j)=>F.sortKey-j.sortKey)}update(t,r,s){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,r,this.layers,s),this.icon.programConfigurations.updatePaintArrays(t,r,this.layers,s))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,r){let s=this.lineVertexArray.length;if(t.segment!==void 0){let l=t.dist(r[t.segment+1]),u=t.dist(r[t.segment]),d={};for(let f=t.segment+1;f=0;f--)d[f]={x:r[f].x,y:r[f].y,tileUnitDistanceFromAnchor:u},f>0&&(u+=r[f-1].dist(r[f]));for(let f=0;f0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,r){let s=t.placedSymbolArray.get(r),l=s.vertexStartIndex+4*s.numGlyphs;for(let u=s.vertexStartIndex;ul[f]-l[_]||u[_]-u[f]),d}addToSortKeyRanges(t,r){let s=this.sortKeyRanges[this.sortKeyRanges.length-1];s&&s.sortKey===r?s.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(let r of this.symbolInstanceIndexes){let s=this.symbolInstances.get(r);this.featureSortOrder.push(s.featureIndex),[s.rightJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.leftJustifiedTextSymbolIndex].forEach((l,u,d)=>{l>=0&&d.indexOf(l)===u&&this.addIndicesForPlacedSymbol(this.text,l)}),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 Jh,Yh;Ie("SymbolBucket",ya,{omit:["layers","collisionBoxArray","features","compareText"]}),ya.MAX_GLYPHS=65535,ya.addDynamicAttributes=Ec;var Rc={get paint(){return Yh=Yh||new h({"icon-opacity":new Re(ie.paint_symbol["icon-opacity"]),"icon-color":new Re(ie.paint_symbol["icon-color"]),"icon-halo-color":new Re(ie.paint_symbol["icon-halo-color"]),"icon-halo-width":new Re(ie.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Re(ie.paint_symbol["icon-halo-blur"]),"icon-translate":new Ae(ie.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ae(ie.paint_symbol["icon-translate-anchor"]),"text-opacity":new Re(ie.paint_symbol["text-opacity"]),"text-color":new Re(ie.paint_symbol["text-color"],{runtimeType:ti,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new Re(ie.paint_symbol["text-halo-color"]),"text-halo-width":new Re(ie.paint_symbol["text-halo-width"]),"text-halo-blur":new Re(ie.paint_symbol["text-halo-blur"]),"text-translate":new Ae(ie.paint_symbol["text-translate"]),"text-translate-anchor":new Ae(ie.paint_symbol["text-translate-anchor"])})},get layout(){return Jh=Jh||new h({"symbol-placement":new Ae(ie.layout_symbol["symbol-placement"]),"symbol-spacing":new Ae(ie.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ae(ie.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Re(ie.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ae(ie.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Ae(ie.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Ae(ie.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Ae(ie.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ae(ie.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ae(ie.layout_symbol["icon-rotation-alignment"]),"icon-size":new Re(ie.layout_symbol["icon-size"]),"icon-text-fit":new Ae(ie.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Ae(ie.layout_symbol["icon-text-fit-padding"]),"icon-image":new Re(ie.layout_symbol["icon-image"]),"icon-rotate":new Re(ie.layout_symbol["icon-rotate"]),"icon-padding":new Re(ie.layout_symbol["icon-padding"]),"icon-keep-upright":new Ae(ie.layout_symbol["icon-keep-upright"]),"icon-offset":new Re(ie.layout_symbol["icon-offset"]),"icon-anchor":new Re(ie.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ae(ie.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ae(ie.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ae(ie.layout_symbol["text-rotation-alignment"]),"text-field":new Re(ie.layout_symbol["text-field"]),"text-font":new Re(ie.layout_symbol["text-font"]),"text-size":new Re(ie.layout_symbol["text-size"]),"text-max-width":new Re(ie.layout_symbol["text-max-width"]),"text-line-height":new Ae(ie.layout_symbol["text-line-height"]),"text-letter-spacing":new Re(ie.layout_symbol["text-letter-spacing"]),"text-justify":new Re(ie.layout_symbol["text-justify"]),"text-radial-offset":new Re(ie.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ae(ie.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Re(ie.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Re(ie.layout_symbol["text-anchor"]),"text-max-angle":new Ae(ie.layout_symbol["text-max-angle"]),"text-writing-mode":new Ae(ie.layout_symbol["text-writing-mode"]),"text-rotate":new Re(ie.layout_symbol["text-rotate"]),"text-padding":new Ae(ie.layout_symbol["text-padding"]),"text-keep-upright":new Ae(ie.layout_symbol["text-keep-upright"]),"text-transform":new Re(ie.layout_symbol["text-transform"]),"text-offset":new Re(ie.layout_symbol["text-offset"]),"text-allow-overlap":new Ae(ie.layout_symbol["text-allow-overlap"]),"text-overlap":new Ae(ie.layout_symbol["text-overlap"]),"text-ignore-placement":new Ae(ie.layout_symbol["text-ignore-placement"]),"text-optional":new Ae(ie.layout_symbol["text-optional"])})}};class Qh{constructor(t){if(t.property.overrides===void 0)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:Pr,this.defaultValue=t}evaluate(t){if(t.formattedSection){let r=this.defaultValue.property.overrides;if(r&&r.hasOverride(t.formattedSection))return r.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Ie("FormatSectionOverride",Qh,{omit:["defaultValue"]});class Al extends n{constructor(t){super(t,Rc)}recalculate(t,r){if(super.recalculate(t,r),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"){let s=this.layout.get("text-writing-mode");if(s){let l=[];for(let u of s)l.indexOf(u)<0&&l.push(u);this.layout._values["text-writing-mode"]=l}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,r,s,l){let u=this.layout.get(t).evaluate(r,{},s,l),d=this._unevaluatedLayout._values[t];return d.isDataDriven()||Zs(d.value)||!u?u:function(f,_){return _.replace(/{([^{}]+)}/g,(x,v)=>f&&v in f?String(f[v]):"")}(r.properties,u)}createBucket(t){return new ya(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(let t of Rc.paint.overridableProperties){if(!Al.hasPaintOverride(this.layout,t))continue;let r=this.paint.get(t),s=new Qh(r),l=new qs(s,r.property.specification),u=null;u=r.value.kind==="constant"||r.value.kind==="source"?new Sn("source",l):new In("composite",l,r.value.zoomStops),this.paint._values[t]=new sr(r.property,u,r.parameters)}}_handleOverridablePaintPropertyUpdate(t,r,s){return!(!this.layout||r.isDataDriven()||s.isDataDriven())&&Al.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,r){let s=t.get("text-field"),l=Rc.paint.properties[r],u=!1,d=f=>{for(let _ of f)if(l.overrides&&l.overrides.hasOverride(_))return void(u=!0)};if(s.value.kind==="constant"&&s.value.value instanceof di)d(s.value.value.sections);else if(s.value.kind==="source"){let f=x=>{u||(x instanceof Ri&&At(x.value)===fr?d(x.value.sections):x instanceof Rs?d(x.sections):x.eachChild(f))},_=s.value;_._styleExpression&&f(_._styleExpression.expression)}return u}}let eu;var rp={get paint(){return eu=eu||new h({"background-color":new Ae(ie.paint_background["background-color"]),"background-pattern":new na(ie.paint_background["background-pattern"]),"background-opacity":new Ae(ie.paint_background["background-opacity"])})}};class np extends n{constructor(t){super(t,rp)}}let tu;var sp={get paint(){return tu=tu||new h({"raster-opacity":new Ae(ie.paint_raster["raster-opacity"]),"raster-hue-rotate":new Ae(ie.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Ae(ie.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Ae(ie.paint_raster["raster-brightness-max"]),"raster-saturation":new Ae(ie.paint_raster["raster-saturation"]),"raster-contrast":new Ae(ie.paint_raster["raster-contrast"]),"raster-resampling":new Ae(ie.paint_raster["raster-resampling"]),"raster-fade-duration":new Ae(ie.paint_raster["raster-fade-duration"])})}};class ap extends n{constructor(t){super(t,sp)}}class op extends n{constructor(t){super(t,{}),this.onAdd=r=>{this.implementation.onAdd&&this.implementation.onAdd(r,r.painter.context.gl)},this.onRemove=r=>{this.implementation.onRemove&&this.implementation.onRemove(r,r.painter.context.gl)},this.implementation=t}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 lp{constructor(t){this._methodToThrottle=t,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=()=>{}}}let Bc=63710088e-1;class $n{constructor(t,r){if(isNaN(t)||isNaN(r))throw new Error(`Invalid LngLat object: (${t}, ${r})`);if(this.lng=+t,this.lat=+r,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new $n(Wi(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){let r=Math.PI/180,s=this.lat*r,l=t.lat*r,u=Math.sin(s)*Math.sin(l)+Math.cos(s)*Math.cos(l)*Math.cos((t.lng-this.lng)*r);return Bc*Math.acos(Math.min(u,1))}static convert(t){if(t instanceof $n)return t;if(Array.isArray(t)&&(t.length===2||t.length===3))return new $n(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&typeof t=="object"&&t!==null)return new $n(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}let iu=2*Math.PI*Bc;function ru(i){return iu*Math.cos(i*Math.PI/180)}function nu(i){return(180+i)/360}function su(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function au(i,t){return i/ru(t)}function Fc(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class Ao{constructor(t,r,s=0){this.x=+t,this.y=+r,this.z=+s}static fromLngLat(t,r=0){let s=$n.convert(t);return new Ao(nu(s.lng),su(s.lat),au(r,s.lat))}toLngLat(){return new $n(360*this.x-180,Fc(this.y))}toAltitude(){return this.z*ru(Fc(this.y))}meterInMercatorCoordinateUnits(){return 1/iu*(t=Fc(this.y),1/Math.cos(t*Math.PI/180));var t}}function ou(i,t,r){var s=2*Math.PI*6378137/256/Math.pow(2,r);return[i*s-2*Math.PI*6378137/2,t*s-2*Math.PI*6378137/2]}class Oc{constructor(t,r,s){if(!function(l,u,d){return!(l<0||l>25||d<0||d>=Math.pow(2,l)||u<0||u>=Math.pow(2,l))}(t,r,s))throw new Error(`x=${r}, y=${s}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=r,this.y=s,this.key=Mo(0,t,t,r,s)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,r,s){let l=(d=this.y,f=this.z,_=ou(256*(u=this.x),256*(d=Math.pow(2,f)-d-1),f),x=ou(256*(u+1),256*(d+1),f),_[0]+","+_[1]+","+x[0]+","+x[1]);var u,d,f,_,x;let v=function(w,I,M){let k,z="";for(let F=w;F>0;F--)k=1<1?"@2x":"").replace(/{quadkey}/g,v).replace(/{bbox-epsg-3857}/g,l)}isChildOf(t){let r=this.z-t.z;return r>0&&t.x===this.x>>r&&t.y===this.y>>r}getTilePoint(t){let r=Math.pow(2,this.z);return new me((t.x*r-this.x)*Mt,(t.y*r-this.y)*Mt)}toString(){return`${this.z}/${this.x}/${this.y}`}}class lu{constructor(t,r){this.wrap=t,this.canonical=r,this.key=Mo(t,r.z,r.z,r.x,r.y)}}class $i{constructor(t,r,s,l,u){if(t= z; overscaledZ = ${t}; z = ${s}`);this.overscaledZ=t,this.wrap=r,this.canonical=new Oc(s,+l,+u),this.key=Mo(r,t,s,l,u)}clone(){return new $i(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);let r=this.canonical.z-t;return t>this.canonical.z?new $i(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new $i(t,this.wrap,t,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(t,r){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);let s=this.canonical.z-t;return t>this.canonical.z?Mo(this.wrap*+r,t,this.canonical.z,this.canonical.x,this.canonical.y):Mo(this.wrap*+r,t,t,this.canonical.x>>s,this.canonical.y>>s)}isChildOf(t){if(t.wrap!==this.wrap)return!1;let r=this.canonical.z-t.canonical.z;return t.overscaledZ===0||t.overscaledZ>r&&t.canonical.y===this.canonical.y>>r}children(t){if(this.overscaledZ>=t)return[new $i(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let r=this.canonical.z+1,s=2*this.canonical.x,l=2*this.canonical.y;return[new $i(r,this.wrap,r,s,l),new $i(r,this.wrap,r,s+1,l),new $i(r,this.wrap,r,s,l+1),new $i(r,this.wrap,r,s+1,l+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.ythis.max&&(this.max=w),w=this.dim+1||r<-1||r>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(t+1)}unpack(t,r,s){return t*this.redFactor+r*this.greenFactor+s*this.blueFactor-this.baseShift}getPixels(){return new Ui({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,r,s){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let l=r*this.dim,u=r*this.dim+this.dim,d=s*this.dim,f=s*this.dim+this.dim;switch(r){case-1:l=u-1;break;case 1:u=l+1}switch(s){case-1:d=f-1;break;case 1:f=d+1}let _=-r*this.dim,x=-s*this.dim;for(let v=d;v=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class uu{constructor(t,r,s,l,u){this.type="Feature",this._vectorTileFeature=t,t._z=r,t._x=s,t._y=l,this.properties=t.properties,this.id=u}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){let t={geometry:this.geometry};for(let r in this)r!=="_geometry"&&r!=="_vectorTileFeature"&&(t[r]=this[r]);return t}}class du{constructor(t,r){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new Cn(Mt,16,0),this.grid3D=new Cn(Mt,16,0),this.featureIndexArray=new Kt,this.promoteId=r}insert(t,r,s,l,u,d){let f=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(s,l,u);let _=d?this.grid3D:this.grid;for(let x=0;x=0&&w[3]>=0&&_.insert(f,w[0],w[1],w[2],w[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Nn.VectorTile(new Pc(this.rawTileData)).layers,this.sourceLayerCoder=new hu(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,r,s,l){this.loadVTLayers();let u=t.params||{},d=Mt/t.tileSize/t.scale,f=Ga(u.filter),_=t.queryGeometry,x=t.queryPadding*d,v=fu(_),w=this.grid.query(v.minX-x,v.minY-x,v.maxX+x,v.maxY+x),I=fu(t.cameraQueryGeometry),M=this.grid3D.query(I.minX-x,I.minY-x,I.maxX+x,I.maxY+x,(F,j,Q,G)=>function(J,re,ce,we,Le){for(let ye of J)if(re<=ye.x&&ce<=ye.y&&we>=ye.x&&Le>=ye.y)return!0;let ve=[new me(re,ce),new me(re,Le),new me(we,Le),new me(we,ce)];if(J.length>2){for(let ye of ve)if(ua(J,ye))return!0}for(let ye=0;ye(G||(G=vs(J)),re.queryIntersectsFeature(_,J,ce,G,this.z,t.transform,d,t.pixelPosMatrix)))}return k}loadMatchingFeature(t,r,s,l,u,d,f,_,x,v,w){let I=this.bucketLayerIDs[r];if(d&&!function(F,j){for(let Q=0;Q=0)return!0;return!1}(d,I))return;let M=this.sourceLayerCoder.decode(s),k=this.vtLayers[M].feature(l);if(u.needGeometry){let F=bs(k,!0);if(!u.filter(new dt(this.tileID.overscaledZ),F,this.tileID.canonical))return}else if(!u.filter(new dt(this.tileID.overscaledZ),k))return;let z=this.getId(k,M);for(let F=0;F{let f=t instanceof _s?t.get(d):null;return f&&f.evaluate?f.evaluate(r,s,l):f})}function fu(i){let t=1/0,r=1/0,s=-1/0,l=-1/0;for(let u of i)t=Math.min(t,u.x),r=Math.min(r,u.y),s=Math.max(s,u.x),l=Math.max(l,u.y);return{minX:t,minY:r,maxX:s,maxY:l}}function cp(i,t){return t-i}function mu(i,t,r,s,l){let u=[];for(let d=0;d=s&&w.x>=s||(v.x>=s?v=new me(s,v.y+(s-v.x)/(w.x-v.x)*(w.y-v.y))._round():w.x>=s&&(w=new me(s,v.y+(s-v.x)/(w.x-v.x)*(w.y-v.y))._round()),v.y>=l&&w.y>=l||(v.y>=l?v=new me(v.x+(l-v.y)/(w.y-v.y)*(w.x-v.x),l)._round():w.y>=l&&(w=new me(v.x+(l-v.y)/(w.y-v.y)*(w.x-v.x),l)._round()),_&&v.equals(_[_.length-1])||(_=[v],u.push(_)),_.push(w)))))}}return u}Ie("FeatureIndex",du,{omit:["rawTileData","sourceLayerCoder"]});class qn extends me{constructor(t,r,s,l){super(t,r),this.angle=s,l!==void 0&&(this.segment=l)}clone(){return new qn(this.x,this.y,this.angle,this.segment)}}function _u(i,t,r,s,l){if(t.segment===void 0||r===0)return!0;let u=t,d=t.segment+1,f=0;for(;f>-r/2;){if(d--,d<0)return!1;f-=i[d].dist(u),u=i[d]}f+=i[d].dist(i[d+1]),d++;let _=[],x=0;for(;fs;)x-=_.shift().angleDelta;if(x>l)return!1;d++,f+=v.dist(w)}return!0}function gu(i){let t=0;for(let r=0;rx){let k=(x-_)/M,z=ii.number(w.x,I.x,k),F=ii.number(w.y,I.y,k),j=new qn(z,F,I.angleTo(w),v);return j._round(),!d||_u(i,j,f,d,t)?j:void 0}_+=M}}function up(i,t,r,s,l,u,d,f,_){let x=yu(s,u,d),v=xu(s,l),w=v*d,I=i[0].x===0||i[0].x===_||i[0].y===0||i[0].y===_;return t-w=0&&J<_&&re>=0&&re<_&&I-x>=0&&I+x<=v){let ce=new qn(J,re,Q,k);ce._round(),s&&!_u(i,ce,u,s,l)||M.push(ce)}}w+=j}return f||M.length||d||(M=vu(i,w/2,r,s,l,u,d,!0,_)),M}Ie("Anchor",qn);let xa=yi;function bu(i,t,r,s){let l=[],u=i.image,d=u.pixelRatio,f=u.paddedRect.w-2*xa,_=u.paddedRect.h-2*xa,x={x1:i.left,y1:i.top,x2:i.right,y2:i.bottom},v=u.stretchX||[[0,f]],w=u.stretchY||[[0,_]],I=(ae,ze)=>ae+ze[1]-ze[0],M=v.reduce(I,0),k=w.reduce(I,0),z=f-M,F=_-k,j=0,Q=M,G=0,J=k,re=0,ce=z,we=0,Le=F;if(u.content&&s){let ae=u.content,ze=ae[2]-ae[0],Ce=ae[3]-ae[1];(u.textFitWidth||u.textFitHeight)&&(x=Xh(i)),j=Ml(v,0,ae[0]),G=Ml(w,0,ae[1]),Q=Ml(v,ae[0],ae[2]),J=Ml(w,ae[1],ae[3]),re=ae[0]-j,we=ae[1]-G,ce=ze-Q,Le=Ce-J}let ve=x.x1,ye=x.y1,ke=x.x2-ve,Pe=x.y2-ye,Se=(ae,ze,Ce,Oe)=>{let ct=Cl(ae.stretch-j,Q,ke,ve),lt=kl(ae.fixed-re,ce,ae.stretch,M),zt=Cl(ze.stretch-G,J,Pe,ye),or=kl(ze.fixed-we,Le,ze.stretch,k),$t=Cl(Ce.stretch-j,Q,ke,ve),Et=kl(Ce.fixed-re,ce,Ce.stretch,M),ai=Cl(Oe.stretch-G,J,Pe,ye),oi=kl(Oe.fixed-we,Le,Oe.stretch,k),li=new me(ct,zt),Tt=new me($t,zt),Dt=new me($t,ai),Yt=new me(ct,ai),qt=new me(lt/d,or/d),ci=new me(Et/d,oi/d),Zt=t*Math.PI/180;if(Zt){let Qe=Math.sin(Zt),ut=Math.cos(Zt),_t=[ut,-Qe,Qe,ut];li._matMult(_t),Tt._matMult(_t),Yt._matMult(_t),Dt._matMult(_t)}let qi=ae.stretch+ae.fixed,xi=ze.stretch+ze.fixed;return{tl:li,tr:Tt,bl:Yt,br:Dt,tex:{x:u.paddedRect.x+xa+qi,y:u.paddedRect.y+xa+xi,w:Ce.stretch+Ce.fixed-qi,h:Oe.stretch+Oe.fixed-xi},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:qt,pixelOffsetBR:ci,minFontScaleX:ce/d/ke,minFontScaleY:Le/d/Pe,isSDF:r}};if(s&&(u.stretchX||u.stretchY)){let ae=wu(v,z,M),ze=wu(w,F,k);for(let Ce=0;Ce0&&(z=Math.max(10,z),this.circleDiameter=z)}else{let I=!((w=d.image)===null||w===void 0)&&w.content&&(d.image.textFitWidth||d.image.textFitHeight)?Xh(d):{x1:d.left,y1:d.top,x2:d.right,y2:d.bottom};I.y1=I.y1*f-_[0],I.y2=I.y2*f+_[2],I.x1=I.x1*f-_[3],I.x2=I.x2*f+_[1];let M=d.collisionPadding;if(M&&(I.x1-=M[0]*f,I.y1-=M[1]*f,I.x2+=M[2]*f,I.y2+=M[3]*f),v){let k=new me(I.x1,I.y1),z=new me(I.x2,I.y1),F=new me(I.x1,I.y2),j=new me(I.x2,I.y2),Q=v*Math.PI/180;k._rotate(Q),z._rotate(Q),F._rotate(Q),j._rotate(Q),I.x1=Math.min(k.x,z.x,F.x,j.x),I.x2=Math.max(k.x,z.x,F.x,j.x),I.y1=Math.min(k.y,z.y,F.y,j.y),I.y2=Math.max(k.y,z.y,F.y,j.y)}t.emplaceBack(r.x,r.y,I.x1,I.y1,I.x2,I.y2,s,l,u)}this.boxEndIndex=t.length}}class dp{constructor(t=[],r=(s,l)=>sl?1:0){if(this.data=t,this.length=this.data.length,this.compare=r,this.length>0)for(let s=(this.length>>1)-1;s>=0;s--)this._down(s)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;let t=this.data[0],r=this.data.pop();return--this.length>0&&(this.data[0]=r,this._down(0)),t}peek(){return this.data[0]}_up(t){let{data:r,compare:s}=this,l=r[t];for(;t>0;){let u=t-1>>1,d=r[u];if(s(l,d)>=0)break;r[t]=d,t=u}r[t]=l}_down(t){let{data:r,compare:s}=this,l=this.length>>1,u=r[t];for(;t=0)break;r[t]=r[d],t=d}r[t]=u}}function pp(i,t=1,r=!1){let s=1/0,l=1/0,u=-1/0,d=-1/0,f=i[0];for(let M=0;Mu)&&(u=k.x),(!M||k.y>d)&&(d=k.y)}let _=Math.min(u-s,d-l),x=_/2,v=new dp([],fp);if(_===0)return new me(s,l);for(let M=s;Mw.d||!w.d)&&(w=M,r&&console.log("found best %d after %d probes",Math.round(1e4*M.d)/1e4,I)),M.max-w.d<=t||(x=M.h/2,v.push(new va(M.p.x-x,M.p.y-x,x,i)),v.push(new va(M.p.x+x,M.p.y-x,x,i)),v.push(new va(M.p.x-x,M.p.y+x,x,i)),v.push(new va(M.p.x+x,M.p.y+x,x,i)),I+=4)}return r&&(console.log(`num probes: ${I}`),console.log(`best distance: ${w.d}`)),w.p}function fp(i,t){return t.max-i.max}function va(i,t,r,s){this.p=new me(i,t),this.h=r,this.d=function(l,u){let d=!1,f=1/0;for(let _=0;_l.y!=k.y>l.y&&l.x<(k.x-M.x)*(l.y-M.y)/(k.y-M.y)+M.x&&(d=!d),f=Math.min(f,sh(l,M,k))}}return(d?1:-1)*Math.sqrt(f)}(this.p,s),this.max=this.d+this.h*Math.SQRT2}var Ut;L.aq=void 0,(Ut=L.aq||(L.aq={}))[Ut.center=1]="center",Ut[Ut.left=2]="left",Ut[Ut.right=3]="right",Ut[Ut.top=4]="top",Ut[Ut.bottom=5]="bottom",Ut[Ut["top-left"]=6]="top-left",Ut[Ut["top-right"]=7]="top-right",Ut[Ut["bottom-left"]=8]="bottom-left",Ut[Ut["bottom-right"]=9]="bottom-right";let Zn=7,Vc=Number.POSITIVE_INFINITY;function Tu(i,t){return t[1]!==Vc?function(r,s,l){let u=0,d=0;switch(s=Math.abs(s),l=Math.abs(l),r){case"top-right":case"top-left":case"top":d=l-Zn;break;case"bottom-right":case"bottom-left":case"bottom":d=-l+Zn}switch(r){case"top-right":case"bottom-right":case"right":u=-s;break;case"top-left":case"bottom-left":case"left":u=s}return[u,d]}(i,t[0],t[1]):function(r,s){let l=0,u=0;s<0&&(s=0);let d=s/Math.SQRT2;switch(r){case"top-right":case"top-left":u=d-Zn;break;case"bottom-right":case"bottom-left":u=-d+Zn;break;case"bottom":u=-s+Zn;break;case"top":u=s-Zn}switch(r){case"top-right":case"bottom-right":l=-d;break;case"top-left":case"bottom-left":l=d;break;case"left":l=s;break;case"right":l=-s}return[l,u]}(i,t[0])}function Su(i,t,r){var s;let l=i.layout,u=(s=l.get("text-variable-anchor-offset"))===null||s===void 0?void 0:s.evaluate(t,{},r);if(u){let f=u.values,_=[];for(let x=0;xI*Ct);v.startsWith("top")?w[1]-=Zn:v.startsWith("bottom")&&(w[1]+=Zn),_[x+1]=w}return new wi(_)}let d=l.get("text-variable-anchor");if(d){let f;f=i._unevaluatedLayout.getValue("text-radial-offset")!==void 0?[l.get("text-radial-offset").evaluate(t,{},r)*Ct,Vc]:l.get("text-offset").evaluate(t,{},r).map(x=>x*Ct);let _=[];for(let x of d)_.push(x,Tu(x,f));return new wi(_)}return null}function Nc(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function mp(i,t,r,s,l,u,d,f,_,x,v){let w=u.textMaxSize.evaluate(t,{});w===void 0&&(w=d);let I=i.layers[0].layout,M=I.get("icon-offset").evaluate(t,{},v),k=Pu(r.horizontal),z=d/24,F=i.tilePixelRatio*z,j=i.tilePixelRatio*w/24,Q=i.tilePixelRatio*f,G=i.tilePixelRatio*I.get("symbol-spacing"),J=I.get("text-padding")*i.tilePixelRatio,re=function(ae,ze,Ce,Oe=1){let ct=ae.get("icon-padding").evaluate(ze,{},Ce),lt=ct&&ct.values;return[lt[0]*Oe,lt[1]*Oe,lt[2]*Oe,lt[3]*Oe]}(I,t,v,i.tilePixelRatio),ce=I.get("text-max-angle")/180*Math.PI,we=I.get("text-rotation-alignment")!=="viewport"&&I.get("symbol-placement")!=="point",Le=I.get("icon-rotation-alignment")==="map"&&I.get("symbol-placement")!=="point",ve=I.get("symbol-placement"),ye=G/2,ke=I.get("icon-text-fit"),Pe;s&&ke!=="none"&&(i.allowVerticalPlacement&&r.vertical&&(Pe=Wh(s,r.vertical,ke,I.get("icon-text-fit-padding"),M,z)),k&&(s=Wh(s,k,ke,I.get("icon-text-fit-padding"),M,z)));let Se=(ae,ze)=>{ze.x<0||ze.x>=Mt||ze.y<0||ze.y>=Mt||function(Ce,Oe,ct,lt,zt,or,$t,Et,ai,oi,li,Tt,Dt,Yt,qt,ci,Zt,qi,xi,Qe,ut,_t,Ci,vt,ba){let Dr=Ce.addToLineVertexArray(Oe,ct),Lr,lr,Zi,Bt,nn=0,zo=0,ku=0,zu=0,Xc=-1,Wc=-1,sn={},Eu=oa("");if(Ce.allowVerticalPlacement&<.vertical){let Qt=Et.layout.get("text-rotate").evaluate(ut,{},vt)+90;Zi=new zl(ai,Oe,oi,li,Tt,lt.vertical,Dt,Yt,qt,Qt),$t&&(Bt=new zl(ai,Oe,oi,li,Tt,$t,Zt,qi,qt,Qt))}if(zt){let Qt=Et.layout.get("icon-rotate").evaluate(ut,{}),Gi=Et.layout.get("icon-text-fit")!=="none",Ts=bu(zt,Qt,Ci,Gi),xr=$t?bu($t,Qt,Ci,Gi):void 0;lr=new zl(ai,Oe,oi,li,Tt,zt,Zt,qi,!1,Qt),nn=4*Ts.length;let Ss=Ce.iconSizeData,Rr=null;Ss.kind==="source"?(Rr=[Er*Et.layout.get("icon-size").evaluate(ut,{})],Rr[0]>Un&&Ft(`${Ce.layerIds[0]}: Value for "icon-size" is >= ${Po}. Reduce your "icon-size".`)):Ss.kind==="composite"&&(Rr=[Er*_t.compositeIconSizes[0].evaluate(ut,{},vt),Er*_t.compositeIconSizes[1].evaluate(ut,{},vt)],(Rr[0]>Un||Rr[1]>Un)&&Ft(`${Ce.layerIds[0]}: Value for "icon-size" is >= ${Po}. Reduce your "icon-size".`)),Ce.addSymbols(Ce.icon,Ts,Rr,Qe,xi,ut,L.ah.none,Oe,Dr.lineStartIndex,Dr.lineLength,-1,vt),Xc=Ce.icon.placedSymbolArray.length-1,xr&&(zo=4*xr.length,Ce.addSymbols(Ce.icon,xr,Rr,Qe,xi,ut,L.ah.vertical,Oe,Dr.lineStartIndex,Dr.lineLength,-1,vt),Wc=Ce.icon.placedSymbolArray.length-1)}let Du=Object.keys(lt.horizontal);for(let Qt of Du){let Gi=lt.horizontal[Qt];if(!Lr){Eu=oa(Gi.text);let xr=Et.layout.get("text-rotate").evaluate(ut,{},vt);Lr=new zl(ai,Oe,oi,li,Tt,Gi,Dt,Yt,qt,xr)}let Ts=Gi.positionedLines.length===1;if(ku+=Iu(Ce,Oe,Gi,or,Et,qt,ut,ci,Dr,lt.vertical?L.ah.horizontal:L.ah.horizontalOnly,Ts?Du:[Qt],sn,Xc,_t,vt),Ts)break}lt.vertical&&(zu+=Iu(Ce,Oe,lt.vertical,or,Et,qt,ut,ci,Dr,L.ah.vertical,["vertical"],sn,Wc,_t,vt));let yp=Lr?Lr.boxStartIndex:Ce.collisionBoxArray.length,xp=Lr?Lr.boxEndIndex:Ce.collisionBoxArray.length,vp=Zi?Zi.boxStartIndex:Ce.collisionBoxArray.length,bp=Zi?Zi.boxEndIndex:Ce.collisionBoxArray.length,wp=lr?lr.boxStartIndex:Ce.collisionBoxArray.length,Tp=lr?lr.boxEndIndex:Ce.collisionBoxArray.length,Sp=Bt?Bt.boxStartIndex:Ce.collisionBoxArray.length,Ip=Bt?Bt.boxEndIndex:Ce.collisionBoxArray.length,yr=-1,Dl=(Qt,Gi)=>Qt&&Qt.circleDiameter?Math.max(Qt.circleDiameter,Gi):Gi;yr=Dl(Lr,yr),yr=Dl(Zi,yr),yr=Dl(lr,yr),yr=Dl(Bt,yr);let Lu=yr>-1?1:0;Lu&&(yr*=ba/Ct),Ce.glyphOffsetArray.length>=ya.MAX_GLYPHS&&Ft("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),ut.sortKey!==void 0&&Ce.addToSortKeyRanges(Ce.symbolInstances.length,ut.sortKey);let Pp=Su(Et,ut,vt),[Ap,Mp]=function(Qt,Gi){let Ts=Qt.length,xr=Gi?.values;if(xr?.length>0)for(let Ss=0;Ss=0?sn.right:-1,sn.center>=0?sn.center:-1,sn.left>=0?sn.left:-1,sn.vertical||-1,Xc,Wc,Eu,yp,xp,vp,bp,wp,Tp,Sp,Ip,oi,ku,zu,nn,zo,Lu,0,Dt,yr,Ap,Mp)}(i,ze,ae,r,s,l,Pe,i.layers[0],i.collisionBoxArray,t.index,t.sourceLayerIndex,i.index,F,[J,J,J,J],we,_,Q,re,Le,M,t,u,x,v,d)};if(ve==="line")for(let ae of mu(t.geometry,0,0,Mt,Mt)){let ze=up(ae,G,ce,r.vertical||k,s,24,j,i.overscaling,Mt);for(let Ce of ze)k&&_p(i,k.text,ye,Ce)||Se(ae,Ce)}else if(ve==="line-center"){for(let ae of t.geometry)if(ae.length>1){let ze=hp(ae,ce,r.vertical||k,s,24,j);ze&&Se(ae,ze)}}else if(t.type==="Polygon")for(let ae of Fs(t.geometry,0)){let ze=pp(ae,16);Se(ae[0],new qn(ze.x,ze.y,0))}else if(t.type==="LineString")for(let ae of t.geometry)Se(ae,new qn(ae[0].x,ae[0].y,0));else if(t.type==="Point")for(let ae of t.geometry)for(let ze of ae)Se([ze],new qn(ze.x,ze.y,0))}function Iu(i,t,r,s,l,u,d,f,_,x,v,w,I,M,k){let z=function(Q,G,J,re,ce,we,Le,ve){let ye=re.layout.get("text-rotate").evaluate(we,{})*Math.PI/180,ke=[];for(let Pe of G.positionedLines)for(let Se of Pe.positionedGlyphs){if(!Se.rect)continue;let ae=Se.rect||{},ze=jh+1,Ce=!0,Oe=1,ct=0,lt=(ce||ve)&&Se.vertical,zt=Se.metrics.advance*Se.scale/2;if(ve&&G.verticalizable&&(ct=Pe.lineOffset/2-(Se.imageName?-(Ct-Se.metrics.width*Se.scale)/2:(Se.scale-1)*Ct)),Se.imageName){let Qe=Le[Se.imageName];Ce=Qe.sdf,Oe=Qe.pixelRatio,ze=yi/Oe}let or=ce?[Se.x+zt,Se.y]:[0,0],$t=ce?[0,0]:[Se.x+zt+J[0],Se.y+J[1]-ct],Et=[0,0];lt&&(Et=$t,$t=[0,0]);let ai=Se.metrics.isDoubleResolution?2:1,oi=(Se.metrics.left-ze)*Se.scale-zt+$t[0],li=(-Se.metrics.top-ze)*Se.scale+$t[1],Tt=oi+ae.w/ai*Se.scale/Oe,Dt=li+ae.h/ai*Se.scale/Oe,Yt=new me(oi,li),qt=new me(Tt,li),ci=new me(oi,Dt),Zt=new me(Tt,Dt);if(lt){let Qe=new me(-zt,zt-So),ut=-Math.PI/2,_t=Ct/2-zt,Ci=new me(5-So-_t,-(Se.imageName?_t:0)),vt=new me(...Et);Yt._rotateAround(ut,Qe)._add(Ci)._add(vt),qt._rotateAround(ut,Qe)._add(Ci)._add(vt),ci._rotateAround(ut,Qe)._add(Ci)._add(vt),Zt._rotateAround(ut,Qe)._add(Ci)._add(vt)}if(ye){let Qe=Math.sin(ye),ut=Math.cos(ye),_t=[ut,-Qe,Qe,ut];Yt._matMult(_t),qt._matMult(_t),ci._matMult(_t),Zt._matMult(_t)}let qi=new me(0,0),xi=new me(0,0);ke.push({tl:Yt,tr:qt,bl:ci,br:Zt,tex:ae,writingMode:G.writingMode,glyphOffset:or,sectionIndex:Se.sectionIndex,isSDF:Ce,pixelOffsetTL:qi,pixelOffsetBR:xi,minFontScaleX:0,minFontScaleY:0})}return ke}(0,r,f,l,u,d,s,i.allowVerticalPlacement),F=i.textSizeData,j=null;F.kind==="source"?(j=[Er*l.layout.get("text-size").evaluate(d,{})],j[0]>Un&&Ft(`${i.layerIds[0]}: Value for "text-size" is >= ${Po}. Reduce your "text-size".`)):F.kind==="composite"&&(j=[Er*M.compositeTextSizes[0].evaluate(d,{},k),Er*M.compositeTextSizes[1].evaluate(d,{},k)],(j[0]>Un||j[1]>Un)&&Ft(`${i.layerIds[0]}: Value for "text-size" is >= ${Po}. Reduce your "text-size".`)),i.addSymbols(i.text,z,j,f,u,d,x,t,_.lineStartIndex,_.lineLength,I,k);for(let Q of v)w[Q]=i.text.placedSymbolArray.length-1;return 4*z.length}function Pu(i){for(let t in i)return i[t];return null}function _p(i,t,r,s){let l=i.compareText;if(t in l){let u=l[t];for(let d=u.length-1;d>=0;d--)if(s.dist(u[d])>4;if(l!==1)throw new Error(`Got v${l} data when expected v1.`);let u=Au[15&s];if(!u)throw new Error("Unrecognized array type.");let[d]=new Uint16Array(t,2,1),[f]=new Uint32Array(t,4,1);return new jc(f,d,u,t)}constructor(t,r=64,s=Float64Array,l){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+r,2),65535),this.ArrayType=s,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;let u=Au.indexOf(this.ArrayType),d=2*t*this.ArrayType.BYTES_PER_ELEMENT,f=t*this.IndexArrayType.BYTES_PER_ELEMENT,_=(8-f%8)%8;if(u<0)throw new Error(`Unexpected typed array class: ${s}.`);l&&l instanceof ArrayBuffer?(this.data=l,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+f+_,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+d+f+_),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+f+_,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+u]),new Uint16Array(this.data,2,1)[0]=r,new Uint32Array(this.data,4,1)[0]=t)}add(t,r){let s=this._pos>>1;return this.ids[s]=s,this.coords[this._pos++]=t,this.coords[this._pos++]=r,s}finish(){let t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Uc(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,r,s,l){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");let{ids:u,coords:d,nodeSize:f}=this,_=[0,u.length-1,0],x=[];for(;_.length;){let v=_.pop()||0,w=_.pop()||0,I=_.pop()||0;if(w-I<=f){for(let F=I;F<=w;F++){let j=d[2*F],Q=d[2*F+1];j>=t&&j<=s&&Q>=r&&Q<=l&&x.push(u[F])}continue}let M=I+w>>1,k=d[2*M],z=d[2*M+1];k>=t&&k<=s&&z>=r&&z<=l&&x.push(u[M]),(v===0?t<=k:r<=z)&&(_.push(I),_.push(M-1),_.push(1-v)),(v===0?s>=k:l>=z)&&(_.push(M+1),_.push(w),_.push(1-v))}return x}within(t,r,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");let{ids:l,coords:u,nodeSize:d}=this,f=[0,l.length-1,0],_=[],x=s*s;for(;f.length;){let v=f.pop()||0,w=f.pop()||0,I=f.pop()||0;if(w-I<=d){for(let F=I;F<=w;F++)Cu(u[2*F],u[2*F+1],t,r)<=x&&_.push(l[F]);continue}let M=I+w>>1,k=u[2*M],z=u[2*M+1];Cu(k,z,t,r)<=x&&_.push(l[M]),(v===0?t-s<=k:r-s<=z)&&(f.push(I),f.push(M-1),f.push(1-v)),(v===0?t+s>=k:r+s>=z)&&(f.push(M+1),f.push(w),f.push(1-v))}return _}}function Uc(i,t,r,s,l,u){if(l-s<=r)return;let d=s+l>>1;Mu(i,t,d,s,l,u),Uc(i,t,r,s,d-1,1-u),Uc(i,t,r,d+1,l,1-u)}function Mu(i,t,r,s,l,u){for(;l>s;){if(l-s>600){let x=l-s+1,v=r-s+1,w=Math.log(x),I=.5*Math.exp(2*w/3),M=.5*Math.sqrt(w*I*(x-I)/x)*(v-x/2<0?-1:1);Mu(i,t,r,Math.max(s,Math.floor(r-v*I/x+M)),Math.min(l,Math.floor(r+(x-v)*I/x+M)),u)}let d=t[2*r+u],f=s,_=l;for(Co(i,t,s,r),t[2*l+u]>d&&Co(i,t,s,l);f<_;){for(Co(i,t,f,_),f++,_--;t[2*f+u]d;)_--}t[2*s+u]===d?Co(i,t,s,_):(_++,Co(i,t,_,l)),_<=r&&(s=_+1),r<=_&&(l=_-1)}}function Co(i,t,r,s){$c(i,r,s),$c(t,2*r,2*s),$c(t,2*r+1,2*s+1)}function $c(i,t,r){let s=i[t];i[t]=i[r],i[r]=s}function Cu(i,t,r,s){let l=i-r,u=t-s;return l*l+u*u}var qc;L.bg=void 0,(qc=L.bg||(L.bg={})).create="create",qc.load="load",qc.fullLoad="fullLoad";let El=null,ko=[],Zc=1e3/60,Gc="loadTime",Hc="fullLoadTime",gp={mark(i){performance.mark(i)},frame(i){let t=i;El!=null&&ko.push(t-El),El=t},clearMetrics(){El=null,ko=[],performance.clearMeasures(Gc),performance.clearMeasures(Hc);for(let i in L.bg)performance.clearMarks(L.bg[i])},getPerformanceMetrics(){performance.measure(Gc,L.bg.create,L.bg.load),performance.measure(Hc,L.bg.create,L.bg.fullLoad);let i=performance.getEntriesByName(Gc)[0].duration,t=performance.getEntriesByName(Hc)[0].duration,r=ko.length,s=1/(ko.reduce((u,d)=>u+d,0)/r/1e3),l=ko.filter(u=>u>Zc).reduce((u,d)=>u+(d-Zc)/Zc,0);return{loadTime:i,fullLoadTime:t,fps:s,percentDroppedFrames:l/(r+l)*100,totalFrames:r}}};L.$=class extends T{},L.A=da,L.B=tc,L.C=function(i){if(on==null){let t=i.navigator?i.navigator.userAgent:null;on=!!i.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return on},L.D=Ae,L.E=hn,L.F=class{constructor(i,t){this.target=i,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new lp(()=>this.process()),this.subscription=function(r,s,l,u){return r.addEventListener(s,l,!1),{unsubscribe:()=>{r.removeEventListener(s,l,!1)}}}(this.target,"message",r=>this.receive(r)),this.globalScope=hr(self)?i:window}registerMessageHandler(i,t){this.messageHandlers[i]=t}sendAsync(i,t){return new Promise((r,s)=>{let l=Math.round(1e18*Math.random()).toString(36).substring(0,10);this.resolveRejects[l]={resolve:r,reject:s},t&&t.signal.addEventListener("abort",()=>{delete this.resolveRejects[l];let f={id:l,type:"",origin:location.origin,targetMapId:i.targetMapId,sourceMapId:this.mapId};this.target.postMessage(f)},{once:!0});let u=[],d=Object.assign(Object.assign({},i),{id:l,sourceMapId:this.mapId,origin:location.origin,data:kn(i.data,u)});this.target.postMessage(d,{transfer:u})})}receive(i){let t=i.data,r=t.id;if(!(t.origin!=="file://"&&location.origin!=="file://"&&t.origin!=="resource://android"&&location.origin!=="resource://android"&&t.origin!==location.origin||t.targetMapId&&this.mapId!==t.targetMapId)){if(t.type===""){delete this.tasks[r];let s=this.abortControllers[r];return delete this.abortControllers[r],void(s&&s.abort())}if(hr(self)||t.mustQueue)return this.tasks[r]=t,this.taskQueue.push(r),void this.invoker.trigger();this.processTask(r,t)}}process(){if(this.taskQueue.length===0)return;let i=this.taskQueue.shift(),t=this.tasks[i];delete this.tasks[i],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(i,t)}processTask(i,t){return p(this,void 0,void 0,function*(){if(t.type===""){let l=this.resolveRejects[i];return delete this.resolveRejects[i],l?void(t.error?l.reject(zn(t.error)):l.resolve(zn(t.data))):void 0}if(!this.messageHandlers[t.type])return void this.completeTask(i,new Error(`Could not find a registered handler for ${t.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));let r=zn(t.data),s=new AbortController;this.abortControllers[i]=s;try{let l=yield this.messageHandlers[t.type](t.sourceMapId,r,s);this.completeTask(i,null,l)}catch(l){this.completeTask(i,l)}})}completeTask(i,t,r){let s=[];delete this.abortControllers[i];let l={id:i,type:"",sourceMapId:this.mapId,origin:location.origin,error:t?kn(t):null,data:kn(r,s)};this.target.postMessage(l,{transfer:s})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},L.G=cn,L.H=function(){var i=new da(16);return da!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i},L.I=Mc,L.J=function(i,t,r){var s,l,u,d,f,_,x,v,w,I,M,k,z=r[0],F=r[1],j=r[2];return t===i?(i[12]=t[0]*z+t[4]*F+t[8]*j+t[12],i[13]=t[1]*z+t[5]*F+t[9]*j+t[13],i[14]=t[2]*z+t[6]*F+t[10]*j+t[14],i[15]=t[3]*z+t[7]*F+t[11]*j+t[15]):(l=t[1],u=t[2],d=t[3],f=t[4],_=t[5],x=t[6],v=t[7],w=t[8],I=t[9],M=t[10],k=t[11],i[0]=s=t[0],i[1]=l,i[2]=u,i[3]=d,i[4]=f,i[5]=_,i[6]=x,i[7]=v,i[8]=w,i[9]=I,i[10]=M,i[11]=k,i[12]=s*z+f*F+w*j+t[12],i[13]=l*z+_*F+I*j+t[13],i[14]=u*z+x*F+M*j+t[14],i[15]=d*z+v*F+k*j+t[15]),i},L.K=function(i,t,r){var s=r[0],l=r[1],u=r[2];return i[0]=t[0]*s,i[1]=t[1]*s,i[2]=t[2]*s,i[3]=t[3]*s,i[4]=t[4]*l,i[5]=t[5]*l,i[6]=t[6]*l,i[7]=t[7]*l,i[8]=t[8]*u,i[9]=t[9]*u,i[10]=t[10]*u,i[11]=t[11]*u,i[12]=t[12],i[13]=t[13],i[14]=t[14],i[15]=t[15],i},L.L=ch,L.M=function(i,t){let r={};for(let s=0;s{let t=window.document.createElement("video");return t.muted=!0,new Promise(r=>{t.onloadstart=()=>{r(t)};for(let s of i){let l=window.document.createElement("source");Nr(s)||(t.crossOrigin="Anonymous"),l.src=s,t.appendChild(l)}})},L.a4=function(){return Is++},L.a5=be,L.a6=ya,L.a7=Ga,L.a8=bs,L.a9=uu,L.aA=function(i){if(i.type==="custom")return new op(i);switch(i.type){case"background":return new np(i);case"circle":return new Zu(i);case"fill":return new ld(i);case"fill-extrusion":return new Td(i);case"heatmap":return new Hu(i);case"hillshade":return new Wu(i);case"line":return new zd(i);case"raster":return new ap(i);case"symbol":return new Al(i)}},L.aB=st,L.aC=function(i,t){if(!i)return[{command:"setStyle",args:[t]}];let r=[];try{if(!et(i.version,t.version))return[{command:"setStyle",args:[t]}];et(i.center,t.center)||r.push({command:"setCenter",args:[t.center]}),et(i.zoom,t.zoom)||r.push({command:"setZoom",args:[t.zoom]}),et(i.bearing,t.bearing)||r.push({command:"setBearing",args:[t.bearing]}),et(i.pitch,t.pitch)||r.push({command:"setPitch",args:[t.pitch]}),et(i.sprite,t.sprite)||r.push({command:"setSprite",args:[t.sprite]}),et(i.glyphs,t.glyphs)||r.push({command:"setGlyphs",args:[t.glyphs]}),et(i.transition,t.transition)||r.push({command:"setTransition",args:[t.transition]}),et(i.light,t.light)||r.push({command:"setLight",args:[t.light]}),et(i.terrain,t.terrain)||r.push({command:"setTerrain",args:[t.terrain]}),et(i.sky,t.sky)||r.push({command:"setSky",args:[t.sky]}),et(i.projection,t.projection)||r.push({command:"setProjection",args:[t.projection]});let s={},l=[];(function(d,f,_,x){let v;for(v in f=f||{},d=d||{})Object.prototype.hasOwnProperty.call(d,v)&&(Object.prototype.hasOwnProperty.call(f,v)||Ir(v,_,x));for(v in f)Object.prototype.hasOwnProperty.call(f,v)&&(Object.prototype.hasOwnProperty.call(d,v)?et(d[v],f[v])||(d[v].type==="geojson"&&f[v].type==="geojson"&&un(d,f,v)?yt(_,{command:"setGeoJSONSourceData",args:[v,f[v].data]}):pr(v,f,_,x)):Kn(v,f,_))})(i.sources,t.sources,l,s);let u=[];i.layers&&i.layers.forEach(d=>{"source"in d&&s[d.source]?r.push({command:"removeLayer",args:[d.id]}):u.push(d)}),r=r.concat(l),function(d,f,_){f=f||[];let x=(d=d||[]).map(Jn),v=f.map(Jn),w=d.reduce(Yn,{}),I=f.reduce(Yn,{}),M=x.slice(),k=Object.create(null),z,F,j,Q,G;for(let J=0,re=0;J@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(r,s,l,u)=>{let d=l||u;return t[s]=!d||d.toLowerCase(),""}),t["max-age"]){let r=parseInt(t["max-age"],10);isNaN(r)?delete t["max-age"]:t["max-age"]=r}return t},L.ab=function(i,t){let r=[];for(let s in i)s in t||r.push(s);return r},L.ac=zi,L.ad=function(i,t,r){var s=Math.sin(r),l=Math.cos(r),u=t[0],d=t[1],f=t[2],_=t[3],x=t[4],v=t[5],w=t[6],I=t[7];return t!==i&&(i[8]=t[8],i[9]=t[9],i[10]=t[10],i[11]=t[11],i[12]=t[12],i[13]=t[13],i[14]=t[14],i[15]=t[15]),i[0]=u*l+x*s,i[1]=d*l+v*s,i[2]=f*l+w*s,i[3]=_*l+I*s,i[4]=x*l-u*s,i[5]=v*l-d*s,i[6]=w*l-f*s,i[7]=I*l-_*s,i},L.ae=function(i){var t=new da(16);return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],t},L.af=yl,L.ag=function(i,t){let r=0,s=0;if(i.kind==="constant")s=i.layoutSize;else if(i.kind!=="source"){let{interpolationType:l,minZoom:u,maxZoom:d}=i,f=l?zi(ri.interpolationFactor(l,t,u,d),0,1):0;i.kind==="camera"?s=ii.number(i.minSize,i.maxSize,f):r=f}return{uSizeT:r,uSize:s}},L.ai=function(i,{uSize:t,uSizeT:r},{lowerSize:s,upperSize:l}){return i.kind==="source"?s/Er:i.kind==="composite"?ii.number(s/Er,l/Er,r):t},L.aj=Ec,L.ak=function(i,t,r,s){let l=t.y-i.y,u=t.x-i.x,d=s.y-r.y,f=s.x-r.x,_=d*u-f*l;if(_===0)return null;let x=(f*(i.y-r.y)-d*(i.x-r.x))/_;return new me(i.x+x*u,i.y+x*l)},L.al=mu,L.am=rh,L.an=pc,L.ao=function(i){let t=1/0,r=1/0,s=-1/0,l=-1/0;for(let u of i)t=Math.min(t,u.x),r=Math.min(r,u.y),s=Math.max(s,u.x),l=Math.max(l,u.y);return[t,r,s,l]},L.ap=Ct,L.ar=zc,L.as=function(i,t){var r=t[0],s=t[1],l=t[2],u=t[3],d=t[4],f=t[5],_=t[6],x=t[7],v=t[8],w=t[9],I=t[10],M=t[11],k=t[12],z=t[13],F=t[14],j=t[15],Q=r*f-s*d,G=r*_-l*d,J=r*x-u*d,re=s*_-l*f,ce=s*x-u*f,we=l*x-u*_,Le=v*z-w*k,ve=v*F-I*k,ye=v*j-M*k,ke=w*F-I*z,Pe=w*j-M*z,Se=I*j-M*F,ae=Q*Se-G*Pe+J*ke+re*ye-ce*ve+we*Le;return ae?(i[0]=(f*Se-_*Pe+x*ke)*(ae=1/ae),i[1]=(l*Pe-s*Se-u*ke)*ae,i[2]=(z*we-F*ce+j*re)*ae,i[3]=(I*ce-w*we-M*re)*ae,i[4]=(_*ye-d*Se-x*ve)*ae,i[5]=(r*Se-l*ye+u*ve)*ae,i[6]=(F*J-k*we-j*G)*ae,i[7]=(v*we-I*J+M*G)*ae,i[8]=(d*Pe-f*ye+x*Le)*ae,i[9]=(s*ye-r*Pe-u*Le)*ae,i[10]=(k*ce-z*J+j*Q)*ae,i[11]=(w*J-v*ce-M*Q)*ae,i[12]=(f*ve-d*ke-_*Le)*ae,i[13]=(r*ke-s*ve+l*Le)*ae,i[14]=(z*G-k*re-F*Q)*ae,i[15]=(v*re-w*G+I*Q)*ae,i):null},L.at=Nc,L.au=kc,L.av=jc,L.aw=function(){let i={},t=ie.$version;for(let r in ie.$root){let s=ie.$root[r];if(s.required){let l=null;l=r==="version"?t:s.type==="array"?[]:{},l!=null&&(i[r]=l)}}return i},L.ax=ao,L.ay=Di,L.az=function(i){i=i.slice();let t=Object.create(null);for(let r=0;r25||s<0||s>=1||r<0||r>=1)},L.bc=function(i,t){return i[0]=t[0],i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=t[1],i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=t[2],i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i},L.bd=class extends b{},L.be=Bc,L.bf=gp,L.bh=ui,L.bi=function(i,t){wr.REGISTERED_PROTOCOLS[i]=t},L.bj=function(i){delete wr.REGISTERED_PROTOCOLS[i]},L.bk=function(i,t){let r={};for(let l=0;lSe*Ct)}let ve=d?"center":r.get("text-justify").evaluate(x,{},i.canonical),ye=r.get("symbol-placement")==="point"?r.get("text-max-width").evaluate(x,{},i.canonical)*Ct:1/0,ke=()=>{i.bucket.allowVerticalPlacement&&oo(J)&&(k.vertical=Sl(z,i.glyphMap,i.glyphPositions,i.imagePositions,v,ye,u,we,"left",ce,j,L.ah.vertical,!0,I,w))};if(!d&&Le){let Pe=new Set;if(ve==="auto")for(let ae=0;aep(void 0,void 0,void 0,function*(){if(i.byteLength===0)return createImageBitmap(new ImageData(1,1));let t=new Blob([new Uint8Array(i)],{type:"image/png"});try{return createImageBitmap(t)}catch(r){throw new Error(`Could not load image because of ${r.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}}),L.e=vi,L.f=i=>new Promise((t,r)=>{let s=new Image;s.onload=()=>{t(s),URL.revokeObjectURL(s.src),s.onload=null,window.requestAnimationFrame(()=>{s.src=As})},s.onerror=()=>r(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."));let l=new Blob([new Uint8Array(i)],{type:"image/png"});s.src=i.byteLength?URL.createObjectURL(l):As}),L.g=Yi,L.h=(i,t)=>Vr(vi(i,{type:"json"}),t),L.i=hr,L.j=Sr,L.k=Tr,L.l=(i,t)=>Vr(vi(i,{type:"arrayBuffer"}),t),L.m=Vr,L.n=function(i){return new Pc(i).readFields(Gd,[])},L.o=go,L.p=Uh,L.q=h,L.r=ec,L.s=Nr,L.t=no,L.u=Qr,L.v=ie,L.w=Ft,L.x=function([i,t,r]){return t+=90,t*=Math.PI/180,r*=Math.PI/180,{x:i*Math.cos(t)*Math.sin(r),y:i*Math.sin(t)*Math.sin(r),z:i*Math.cos(r)}},L.y=ii,L.z=dt}),Ll("worker",["./shared"],function(L){"use strict";class p{constructor(A){this.keyCache={},A&&this.replace(A)}replace(A){this._layerConfigs={},this._layers={},this.update(A,[])}update(A,P){for(let O of A){this._layerConfigs[O.id]=O;let H=this._layers[O.id]=L.aA(O);H._featureFilter=L.a7(H.filter),this.keyCache[O.id]&&delete this.keyCache[O.id]}for(let O of P)delete this.keyCache[O],delete this._layerConfigs[O],delete this._layers[O];this.familiesBySource={};let D=L.bk(Object.values(this._layerConfigs),this.keyCache);for(let O of D){let H=O.map(te=>this._layers[te.id]),W=H[0];if(W.visibility==="none")continue;let Y=W.source||"",q=this.familiesBySource[Y];q||(q=this.familiesBySource[Y]={});let ne=W.sourceLayer||"_geojsonTileLayer",le=q[ne];le||(le=q[ne]=[]),le.push(H)}}}class ki{constructor(A){let P={},D=[];for(let Y in A){let q=A[Y],ne=P[Y]={};for(let le in q){let te=q[+le];if(!te||te.bitmap.width===0||te.bitmap.height===0)continue;let de={x:0,y:0,w:te.bitmap.width+2,h:te.bitmap.height+2};D.push(de),ne[le]={rect:de,metrics:te.metrics}}}let{w:O,h:H}=L.p(D),W=new L.o({width:O||1,height:H||1});for(let Y in A){let q=A[Y];for(let ne in q){let le=q[+ne];if(!le||le.bitmap.width===0||le.bitmap.height===0)continue;let te=P[Y][ne].rect;L.o.copy(le.bitmap,W,{x:0,y:0},{x:te.x+1,y:te.y+1},le.bitmap)}}this.image=W,this.positions=P}}L.bl("GlyphAtlas",ki);class Hi{constructor(A){this.tileID=new L.S(A.tileID.overscaledZ,A.tileID.wrap,A.tileID.canonical.z,A.tileID.canonical.x,A.tileID.canonical.y),this.uid=A.uid,this.zoom=A.zoom,this.pixelRatio=A.pixelRatio,this.tileSize=A.tileSize,this.source=A.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=A.showCollisionBoxes,this.collectResourceTiming=!!A.collectResourceTiming,this.returnDependencies=!!A.returnDependencies,this.promoteId=A.promoteId,this.inFlightDependencies=[]}parse(A,P,D,O){return L._(this,void 0,void 0,function*(){this.status="parsing",this.data=A,this.collisionBoxArray=new L.a5;let H=new L.bm(Object.keys(A.layers).sort()),W=new L.bn(this.tileID,this.promoteId);W.bucketLayerIDs=[];let Y={},q={featureIndex:W,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:D},ne=P.familiesBySource[this.source];for(let qe in ne){let rt=A.layers[qe];if(!rt)continue;rt.version===1&&L.w(`Vector tile source "${this.source}" layer "${qe}" does not use vector tile spec v2 and therefore may have some rendering errors.`);let gt=H.encode(qe),kt=[];for(let Lt=0;Lt=Wt.maxzoom||Wt.visibility!=="none"&&(Gt(Lt,this.zoom,D),(Y[Wt.id]=Wt.createBucket({index:W.bucketLayerIDs.length,layers:Lt,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:gt,sourceID:this.source})).populate(kt,q,this.tileID.canonical),W.bucketLayerIDs.push(Lt.map(dn=>dn.id)))}}let le=L.aF(q.glyphDependencies,qe=>Object.keys(qe).map(Number));this.inFlightDependencies.forEach(qe=>qe?.abort()),this.inFlightDependencies=[];let te=Promise.resolve({});if(Object.keys(le).length){let qe=new AbortController;this.inFlightDependencies.push(qe),te=O.sendAsync({type:"GG",data:{stacks:le,source:this.source,tileID:this.tileID,type:"glyphs"}},qe)}let de=Object.keys(q.iconDependencies),Ee=Promise.resolve({});if(de.length){let qe=new AbortController;this.inFlightDependencies.push(qe),Ee=O.sendAsync({type:"GI",data:{icons:de,source:this.source,tileID:this.tileID,type:"icons"}},qe)}let De=Object.keys(q.patternDependencies),Ke=Promise.resolve({});if(De.length){let qe=new AbortController;this.inFlightDependencies.push(qe),Ke=O.sendAsync({type:"GI",data:{icons:De,source:this.source,tileID:this.tileID,type:"patterns"}},qe)}let[je,Je,Ge]=yield Promise.all([te,Ee,Ke]),Pt=new ki(je),xt=new L.bo(Je,Ge);for(let qe in Y){let rt=Y[qe];rt instanceof L.a6?(Gt(rt.layers,this.zoom,D),L.bp({bucket:rt,glyphMap:je,glyphPositions:Pt.positions,imageMap:Je,imagePositions:xt.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):rt.hasPattern&&(rt instanceof L.bq||rt instanceof L.br||rt instanceof L.bs)&&(Gt(rt.layers,this.zoom,D),rt.addFeatures(q,this.tileID.canonical,xt.patternPositions))}return this.status="done",{buckets:Object.values(Y).filter(qe=>!qe.isEmpty()),featureIndex:W,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Pt.image,imageAtlas:xt,glyphMap:this.returnDependencies?je:null,iconMap:this.returnDependencies?Je:null,glyphPositions:this.returnDependencies?Pt.positions:null}})}}function Gt(N,A,P){let D=new L.z(A);for(let O of N)O.recalculate(D,P)}class me{constructor(A,P,D){this.actor=A,this.layerIndex=P,this.availableImages=D,this.fetching={},this.loading={},this.loaded={}}loadVectorTile(A,P){return L._(this,void 0,void 0,function*(){let D=yield L.l(A.request,P);try{return{vectorTile:new L.bt.VectorTile(new L.bu(D.data)),rawData:D.data,cacheControl:D.cacheControl,expires:D.expires}}catch(O){let H=new Uint8Array(D.data),W=`Unable to parse the tile at ${A.request.url}, `;throw W+=H[0]===31&&H[1]===139?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${O.message}`,new Error(W)}})}loadTile(A){return L._(this,void 0,void 0,function*(){let P=A.uid,D=!!(A&&A.request&&A.request.collectResourceTiming)&&new L.bv(A.request),O=new Hi(A);this.loading[P]=O;let H=new AbortController;O.abort=H;try{let W=yield this.loadVectorTile(A,H);if(delete this.loading[P],!W)return null;let Y=W.rawData,q={};W.expires&&(q.expires=W.expires),W.cacheControl&&(q.cacheControl=W.cacheControl);let ne={};if(D){let te=D.finish();te&&(ne.resourceTiming=JSON.parse(JSON.stringify(te)))}O.vectorTile=W.vectorTile;let le=O.parse(W.vectorTile,this.layerIndex,this.availableImages,this.actor);this.loaded[P]=O,this.fetching[P]={rawTileData:Y,cacheControl:q,resourceTiming:ne};try{let te=yield le;return L.e({rawTileData:Y.slice(0)},te,q,ne)}finally{delete this.fetching[P]}}catch(W){throw delete this.loading[P],O.status="done",this.loaded[P]=O,W}})}reloadTile(A){return L._(this,void 0,void 0,function*(){let P=A.uid;if(!this.loaded||!this.loaded[P])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");let D=this.loaded[P];if(D.showCollisionBoxes=A.showCollisionBoxes,D.status==="parsing"){let O=yield D.parse(D.vectorTile,this.layerIndex,this.availableImages,this.actor),H;if(this.fetching[P]){let{rawTileData:W,cacheControl:Y,resourceTiming:q}=this.fetching[P];delete this.fetching[P],H=L.e({rawTileData:W.slice(0)},O,Y,q)}else H=O;return H}if(D.status==="done"&&D.vectorTile)return D.parse(D.vectorTile,this.layerIndex,this.availableImages,this.actor)})}abortTile(A){return L._(this,void 0,void 0,function*(){let P=this.loading,D=A.uid;P&&P[D]&&P[D].abort&&(P[D].abort.abort(),delete P[D])})}removeTile(A){return L._(this,void 0,void 0,function*(){this.loaded&&this.loaded[A.uid]&&delete this.loaded[A.uid]})}}class se{constructor(){this.loaded={}}loadTile(A){return L._(this,void 0,void 0,function*(){let{uid:P,encoding:D,rawImageData:O,redFactor:H,greenFactor:W,blueFactor:Y,baseShift:q}=A,ne=O.width+2,le=O.height+2,te=L.b(O)?new L.R({width:ne,height:le},yield L.bw(O,-1,-1,ne,le)):O,de=new L.bx(P,te,D,H,W,Y,q);return this.loaded=this.loaded||{},this.loaded[P]=de,de})}removeTile(A){let P=this.loaded,D=A.uid;P&&P[D]&&delete P[D]}}function Fr(N,A){if(N.length!==0){vr(N[0],A);for(var P=1;P=Math.abs(Y)?P-q+Y:Y-q+P,P=q}P+D>=0!=!!A&&N.reverse()}var Xi=L.by(function N(A,P){var D,O=A&&A.type;if(O==="FeatureCollection")for(D=0;D>31}function hr(N,A){for(var P=N.loadGeometry(),D=N.type,O=0,H=0,W=P.length,Y=0;YN},Or=Math.fround||(ur=new Float32Array(1),N=>(ur[0]=+N,ur[0]));var ur;let ei=3,Ei=5,ln=6;class wr{constructor(A){this.options=Object.assign(Object.create(As),A),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(A){let{log:P,minZoom:D,maxZoom:O}=this.options;P&&console.time("total time");let H=`prepare ${A.length} points`;P&&console.time(H),this.points=A;let W=[];for(let q=0;q=D;q--){let ne=+Date.now();Y=this.trees[q]=this._createTree(this._cluster(Y,q)),P&&console.log("z%d: %d clusters in %dms",q,Y.numItems,+Date.now()-ne)}return P&&console.timeEnd("total time"),this}getClusters(A,P){let D=((A[0]+180)%360+360)%360-180,O=Math.max(-90,Math.min(90,A[1])),H=A[2]===180?180:((A[2]+180)%360+360)%360-180,W=Math.max(-90,Math.min(90,A[3]));if(A[2]-A[0]>=360)D=-180,H=180;else if(D>H){let te=this.getClusters([D,O,180,W],P),de=this.getClusters([-180,O,H,W],P);return te.concat(de)}let Y=this.trees[this._limitZoom(P)],q=Y.range(ui(D),Di(W),ui(H),Di(O)),ne=Y.data,le=[];for(let te of q){let de=this.stride*te;le.push(ne[de+Ei]>1?Yi(ne,de,this.clusterProps):this.points[ne[de+ei]])}return le}getChildren(A){let P=this._getOriginId(A),D=this._getOriginZoom(A),O="No cluster with the specified id.",H=this.trees[D];if(!H)throw new Error(O);let W=H.data;if(P*this.stride>=W.length)throw new Error(O);let Y=this.options.radius/(this.options.extent*Math.pow(2,D-1)),q=H.within(W[P*this.stride],W[P*this.stride+1],Y),ne=[];for(let le of q){let te=le*this.stride;W[te+4]===A&&ne.push(W[te+Ei]>1?Yi(W,te,this.clusterProps):this.points[W[te+ei]])}if(ne.length===0)throw new Error(O);return ne}getLeaves(A,P,D){let O=[];return this._appendLeaves(O,A,P=P||10,D=D||0,0),O}getTile(A,P,D){let O=this.trees[this._limitZoom(A)],H=Math.pow(2,A),{extent:W,radius:Y}=this.options,q=Y/W,ne=(D-q)/H,le=(D+1+q)/H,te={features:[]};return this._addTileFeatures(O.range((P-q)/H,ne,(P+1+q)/H,le),O.data,P,D,H,te),P===0&&this._addTileFeatures(O.range(1-q/H,ne,1,le),O.data,H,D,H,te),P===H-1&&this._addTileFeatures(O.range(0,ne,q/H,le),O.data,-1,D,H,te),te.features.length?te:null}getClusterExpansionZoom(A){let P=this._getOriginZoom(A)-1;for(;P<=this.options.maxZoom;){let D=this.getChildren(A);if(P++,D.length!==1)break;A=D[0].properties.cluster_id}return P}_appendLeaves(A,P,D,O,H){let W=this.getChildren(P);for(let Y of W){let q=Y.properties;if(q&&q.cluster?H+q.point_count<=O?H+=q.point_count:H=this._appendLeaves(A,q.cluster_id,D,O,H):H1,le,te,de;if(ne)le=cn(P,q,this.clusterProps),te=P[q],de=P[q+1];else{let Ke=this.points[P[q+ei]];le=Ke.properties;let[je,Je]=Ke.geometry.coordinates;te=ui(je),de=Di(Je)}let Ee={type:1,geometry:[[Math.round(this.options.extent*(te*H-D)),Math.round(this.options.extent*(de*H-O))]],tags:le},De;De=ne||this.options.generateId?P[q+ei]:this.points[P[q+ei]].id,De!==void 0&&(Ee.id=De),W.features.push(Ee)}}_limitZoom(A){return Math.max(this.options.minZoom,Math.min(Math.floor(+A),this.options.maxZoom+1))}_cluster(A,P){let{radius:D,extent:O,reduce:H,minPoints:W}=this.options,Y=D/(O*Math.pow(2,P)),q=A.data,ne=[],le=this.stride;for(let te=0;teP&&(je+=q[Ge+Ei])}if(je>Ke&&je>=W){let Je,Ge=de*Ke,Pt=Ee*Ke,xt=-1,qe=((te/le|0)<<5)+(P+1)+this.points.length;for(let rt of De){let gt=rt*le;if(q[gt+2]<=P)continue;q[gt+2]=P;let kt=q[gt+Ei];Ge+=q[gt]*kt,Pt+=q[gt+1]*kt,q[gt+4]=qe,H&&(Je||(Je=this._map(q,te,!0),xt=this.clusterProps.length,this.clusterProps.push(Je)),H(Je,this._map(q,gt)))}q[te+4]=qe,ne.push(Ge/je,Pt/je,1/0,qe,-1,je),H&&ne.push(xt)}else{for(let Je=0;Je1)for(let Je of De){let Ge=Je*le;if(!(q[Ge+2]<=P)){q[Ge+2]=P;for(let Pt=0;Pt>5}_getOriginZoom(A){return(A-this.points.length)%32}_map(A,P,D){if(A[P+Ei]>1){let W=this.clusterProps[A[P+ln]];return D?Object.assign({},W):W}let O=this.points[A[P+ei]].properties,H=this.options.map(O);return D&&H===O?Object.assign({},H):H}}function Yi(N,A,P){return{type:"Feature",id:N[A+ei],properties:cn(N,A,P),geometry:{type:"Point",coordinates:[(D=N[A],360*(D-.5)),Vr(N[A+1])]}};var D}function cn(N,A,P){let D=N[A+Ei],O=D>=1e4?`${Math.round(D/1e3)}k`:D>=1e3?Math.round(D/100)/10+"k":D,H=N[A+ln],W=H===-1?{}:Object.assign({},P[H]);return Object.assign(W,{cluster:!0,cluster_id:N[A+ei],point_count:D,point_count_abbreviated:O})}function ui(N){return N/360+.5}function Di(N){let A=Math.sin(N*Math.PI/180),P=.5-.25*Math.log((1+A)/(1-A))/Math.PI;return P<0?0:P>1?1:P}function Vr(N){let A=(180-360*N)*Math.PI/180;return 360*Math.atan(Math.exp(A))/Math.PI-90}function Nr(N,A,P,D){let O=D,H=A+(P-A>>1),W,Y=P-A,q=N[A],ne=N[A+1],le=N[P],te=N[P+1];for(let de=A+3;deO)W=de,O=Ee;else if(Ee===O){let De=Math.abs(de-H);DeD&&(W-A>3&&Nr(N,A,W,D),N[W+2]=O,P-W>3&&Nr(N,W,P,D))}function Xn(N,A,P,D,O,H){let W=O-P,Y=H-D;if(W!==0||Y!==0){let q=((N-P)*W+(A-D)*Y)/(W*W+Y*Y);q>1?(P=O,D=H):q>0&&(P+=W*q,D+=Y*q)}return W=N-P,Y=A-D,W*W+Y*Y}function dr(N,A,P,D){let O={id:N??null,type:A,geometry:P,tags:D,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(A==="Point"||A==="MultiPoint"||A==="LineString")Tr(O,P);else if(A==="Polygon")Tr(O,P[0]);else if(A==="MultiLineString")for(let H of P)Tr(O,H);else if(A==="MultiPolygon")for(let H of P)Tr(O,H[0]);return O}function Tr(N,A){for(let P=0;P0&&(W+=D?(O*le-ne*H)/2:Math.sqrt(Math.pow(ne-O,2)+Math.pow(le-H,2))),O=ne,H=le}let Y=A.length-3;A[2]=1,Nr(A,0,Y,P),A[Y+2]=1,A.size=Math.abs(W),A.start=0,A.end=A.size}function jr(N,A,P,D){for(let O=0;O1?1:P}function yt(N,A,P,D,O,H,W,Y){if(D/=A,H>=(P/=A)&&W=D)return null;let q=[];for(let ne of N){let le=ne.geometry,te=ne.type,de=O===0?ne.minX:ne.minY,Ee=O===0?ne.maxX:ne.maxY;if(de>=P&&Ee=D)continue;let De=[];if(te==="Point"||te==="MultiPoint")Kn(le,De,P,D,O);else if(te==="LineString")Ir(le,De,P,D,O,!1,Y.lineMetrics);else if(te==="MultiLineString")un(le,De,P,D,O,!1);else if(te==="Polygon")un(le,De,P,D,O,!0);else if(te==="MultiPolygon")for(let Ke of le){let je=[];un(Ke,je,P,D,O,!0),je.length&&De.push(je)}if(De.length){if(Y.lineMetrics&&te==="LineString"){for(let Ke of De)q.push(dr(ne.id,te,Ke,ne.tags));continue}te!=="LineString"&&te!=="MultiLineString"||(De.length===1?(te="LineString",De=De[0]):te="MultiLineString"),te!=="Point"&&te!=="MultiPoint"||(te=De.length===3?"Point":"MultiPoint"),q.push(dr(ne.id,te,De,ne.tags))}}return q.length?q:null}function Kn(N,A,P,D,O){for(let H=0;H=P&&W<=D&&bi(A,N[H],N[H+1],N[H+2])}}function Ir(N,A,P,D,O,H,W){let Y=pr(N),q=O===0?Jn:Yn,ne,le,te=N.start;for(let je=0;jeP&&(le=q(Y,Je,Ge,xt,qe,P),W&&(Y.start=te+ne*le)):rt>D?gt=P&&(le=q(Y,Je,Ge,xt,qe,P),kt=!0),gt>D&&rt<=D&&(le=q(Y,Je,Ge,xt,qe,D),kt=!0),!H&&kt&&(W&&(Y.end=te+ne*le),A.push(Y),Y=pr(N)),W&&(te+=ne)}let de=N.length-3,Ee=N[de],De=N[de+1],Ke=O===0?Ee:De;Ke>=P&&Ke<=D&&bi(Y,Ee,De,N[de+2]),de=Y.length-3,H&&de>=3&&(Y[de]!==Y[0]||Y[de+1]!==Y[1])&&bi(Y,Y[0],Y[1],Y[2]),Y.length&&A.push(Y)}function pr(N){let A=[];return A.size=N.size,A.start=N.start,A.end=N.end,A}function un(N,A,P,D,O,H){for(let W of N)Ir(W,A,P,D,O,H,!1)}function bi(N,A,P,D){N.push(A,P,D)}function Jn(N,A,P,D,O,H){let W=(H-A)/(D-A);return bi(N,H,P+(O-P)*W,1),W}function Yn(N,A,P,D,O,H){let W=(H-P)/(O-P);return bi(N,A+(D-A)*W,H,1),W}function ue(N,A){let P=[];for(let D=0;D0&&A.size<(O?W:D))return void(P.numPoints+=A.length/3);let Y=[];for(let q=0;qW)&&(P.numSimplified++,Y.push(A[q],A[q+1])),P.numPoints++;O&&function(q,ne){let le=0;for(let te=0,de=q.length,Ee=de-2;te0===ne)for(let te=0,de=q.length;te24)throw new Error("maxZoom should be in the 0-24 range");if(P.promoteId&&P.generateId)throw new Error("promoteId and generateId cannot be used together.");let O=function(H,W){let Y=[];if(H.type==="FeatureCollection")for(let q=0;q1&&console.time("creation"),Ee=this.tiles[de]=Pr(A,P,D,O,ne),this.tileCoords.push({z:P,x:D,y:O}),le)){le>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",P,D,O,Ee.numFeatures,Ee.numPoints,Ee.numSimplified),console.timeEnd("creation"));let kt=`z${P}`;this.stats[kt]=(this.stats[kt]||0)+1,this.total++}if(Ee.source=A,H==null){if(P===ne.indexMaxZoom||Ee.numPoints<=ne.indexMaxPoints)continue}else{if(P===ne.maxZoom||P===H)continue;if(H!=null){let kt=H-P;if(D!==W>>kt||O!==Y>>kt)continue}}if(Ee.source=null,A.length===0)continue;le>1&&console.time("clipping");let De=.5*ne.buffer/ne.extent,Ke=.5-De,je=.5+De,Je=1+De,Ge=null,Pt=null,xt=null,qe=null,rt=yt(A,te,D-De,D+je,0,Ee.minX,Ee.maxX,ne),gt=yt(A,te,D+Ke,D+Je,0,Ee.minX,Ee.maxX,ne);A=null,rt&&(Ge=yt(rt,te,O-De,O+je,1,Ee.minY,Ee.maxY,ne),Pt=yt(rt,te,O+Ke,O+Je,1,Ee.minY,Ee.maxY,ne),rt=null),gt&&(xt=yt(gt,te,O-De,O+je,1,Ee.minY,Ee.maxY,ne),qe=yt(gt,te,O+Ke,O+Je,1,Ee.minY,Ee.maxY,ne),gt=null),le>1&&console.timeEnd("clipping"),q.push(Ge||[],P+1,2*D,2*O),q.push(Pt||[],P+1,2*D,2*O+1),q.push(xt||[],P+1,2*D+1,2*O),q.push(qe||[],P+1,2*D+1,2*O+1)}}getTile(A,P,D){A=+A,P=+P,D=+D;let O=this.options,{extent:H,debug:W}=O;if(A<0||A>24)return null;let Y=1<1&&console.log("drilling down to z%d-%d-%d",A,P,D);let ne,le=A,te=P,de=D;for(;!ne&&le>0;)le--,te>>=1,de>>=1,ne=this.tiles[Li(le,te,de)];return ne&&ne.source?(W>1&&(console.log("found parent tile z%d-%d-%d",le,te,de),console.time("drilling down")),this.splitTile(ne.source,le,te,de,A,P,D),W>1&&console.timeEnd("drilling down"),this.tiles[q]?Xt(this.tiles[q],H):null):null}}function Li(N,A,P){return 32*((1<{te.properties=Ee;let De={};for(let Ke of de)De[Ke]=q[Ke].evaluate(le,te);return De},W.reduce=(Ee,De)=>{te.properties=De;for(let Ke of de)le.accumulated=Ee[Ke],Ee[Ke]=ne[Ke].evaluate(le,te)},W}(A)).load((yield this._pendingData).features):(O=yield this._pendingData,new ti(O,A.geojsonVtOptions)),this.loaded={};let H={};if(D){let W=D.finish();W&&(H.resourceTiming={},H.resourceTiming[A.source]=JSON.parse(JSON.stringify(W)))}return H}catch(H){if(delete this._pendingRequest,L.bB(H))return{abandoned:!0};throw H}var O})}getData(){return L._(this,void 0,void 0,function*(){return this._pendingData})}reloadTile(A){let P=this.loaded;return P&&P[A.uid]?super.reloadTile(A):this.loadTile(A)}loadAndProcessGeoJSON(A,P){return L._(this,void 0,void 0,function*(){let D=yield this.loadGeoJSON(A,P);if(delete this._pendingRequest,typeof D!="object")throw new Error(`Input data given to '${A.source}' is not a valid GeoJSON object.`);if(Xi(D,!0),A.filter){let O=L.bC(A.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(O.result==="error")throw new Error(O.value.map(W=>`${W.key}: ${W.message}`).join(", "));D={type:"FeatureCollection",features:D.features.filter(W=>O.value.evaluate({zoom:0},W))}}return D})}loadGeoJSON(A,P){return L._(this,void 0,void 0,function*(){let{promoteId:D}=A;if(A.request){let O=yield L.h(A.request,P);return this._dataUpdateable=tr(O.data,D)?fr(O.data,D):void 0,O.data}if(typeof A.data=="string")try{let O=JSON.parse(A.data);return this._dataUpdateable=tr(O,D)?fr(O,D):void 0,O}catch{throw new Error(`Input data given to '${A.source}' is not a valid GeoJSON object.`)}if(!A.dataDiff)throw new Error(`Input data given to '${A.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${A.source}`);return function(O,H,W){var Y,q,ne,le;if(H.removeAll&&O.clear(),H.remove)for(let te of H.remove)O.delete(te);if(H.add)for(let te of H.add){let de=Ne(te,W);de!=null&&O.set(de,te)}if(H.update)for(let te of H.update){let de=O.get(te.id);if(de==null)continue;let Ee=!te.removeAllProperties&&(((Y=te.removeProperties)===null||Y===void 0?void 0:Y.length)>0||((q=te.addOrUpdateProperties)===null||q===void 0?void 0:q.length)>0);if((te.newGeometry||te.removeAllProperties||Ee)&&(de=Object.assign({},de),O.set(te.id,de),Ee&&(de.properties=Object.assign({},de.properties))),te.newGeometry&&(de.geometry=te.newGeometry),te.removeAllProperties)de.properties={};else if(((ne=te.removeProperties)===null||ne===void 0?void 0:ne.length)>0)for(let De of te.removeProperties)Object.prototype.hasOwnProperty.call(de.properties,De)&&delete de.properties[De];if(((le=te.addOrUpdateProperties)===null||le===void 0?void 0:le.length)>0)for(let{key:De,value:Ke}of te.addOrUpdateProperties)de.properties[De]=Ke}}(this._dataUpdateable,A.dataDiff,D),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}})}removeSource(A){return L._(this,void 0,void 0,function*(){this._pendingRequest&&this._pendingRequest.abort()})}getClusterExpansionZoom(A){return this._geoJSONIndex.getClusterExpansionZoom(A.clusterId)}getClusterChildren(A){return this._geoJSONIndex.getChildren(A.clusterId)}getClusterLeaves(A){return this._geoJSONIndex.getLeaves(A.clusterId,A.limit,A.offset)}}class ir{constructor(A){this.self=A,this.actor=new L.F(A),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(P,D)=>{if(this.externalWorkerSourceTypes[P])throw new Error(`Worker source with name "${P}" already registered.`);this.externalWorkerSourceTypes[P]=D},this.self.addProtocol=L.bi,this.self.removeProtocol=L.bj,this.self.registerRTLTextPlugin=P=>{if(L.bD.isParsed())throw new Error("RTL text plugin already registered.");L.bD.setMethods(P)},this.actor.registerMessageHandler("LDT",(P,D)=>this._getDEMWorkerSource(P,D.source).loadTile(D)),this.actor.registerMessageHandler("RDT",(P,D)=>L._(this,void 0,void 0,function*(){this._getDEMWorkerSource(P,D.source).removeTile(D)})),this.actor.registerMessageHandler("GCEZ",(P,D)=>L._(this,void 0,void 0,function*(){return this._getWorkerSource(P,D.type,D.source).getClusterExpansionZoom(D)})),this.actor.registerMessageHandler("GCC",(P,D)=>L._(this,void 0,void 0,function*(){return this._getWorkerSource(P,D.type,D.source).getClusterChildren(D)})),this.actor.registerMessageHandler("GCL",(P,D)=>L._(this,void 0,void 0,function*(){return this._getWorkerSource(P,D.type,D.source).getClusterLeaves(D)})),this.actor.registerMessageHandler("LD",(P,D)=>this._getWorkerSource(P,D.type,D.source).loadData(D)),this.actor.registerMessageHandler("GD",(P,D)=>this._getWorkerSource(P,D.type,D.source).getData()),this.actor.registerMessageHandler("LT",(P,D)=>this._getWorkerSource(P,D.type,D.source).loadTile(D)),this.actor.registerMessageHandler("RT",(P,D)=>this._getWorkerSource(P,D.type,D.source).reloadTile(D)),this.actor.registerMessageHandler("AT",(P,D)=>this._getWorkerSource(P,D.type,D.source).abortTile(D)),this.actor.registerMessageHandler("RMT",(P,D)=>this._getWorkerSource(P,D.type,D.source).removeTile(D)),this.actor.registerMessageHandler("RS",(P,D)=>L._(this,void 0,void 0,function*(){if(!this.workerSources[P]||!this.workerSources[P][D.type]||!this.workerSources[P][D.type][D.source])return;let O=this.workerSources[P][D.type][D.source];delete this.workerSources[P][D.type][D.source],O.removeSource!==void 0&&O.removeSource(D)})),this.actor.registerMessageHandler("RM",P=>L._(this,void 0,void 0,function*(){delete this.layerIndexes[P],delete this.availableImages[P],delete this.workerSources[P],delete this.demWorkerSources[P]})),this.actor.registerMessageHandler("SR",(P,D)=>L._(this,void 0,void 0,function*(){this.referrer=D})),this.actor.registerMessageHandler("SRPS",(P,D)=>this._syncRTLPluginState(P,D)),this.actor.registerMessageHandler("IS",(P,D)=>L._(this,void 0,void 0,function*(){this.self.importScripts(D)})),this.actor.registerMessageHandler("SI",(P,D)=>this._setImages(P,D)),this.actor.registerMessageHandler("UL",(P,D)=>L._(this,void 0,void 0,function*(){this._getLayerIndex(P).update(D.layers,D.removedIds)})),this.actor.registerMessageHandler("SL",(P,D)=>L._(this,void 0,void 0,function*(){this._getLayerIndex(P).replace(D)}))}_setImages(A,P){return L._(this,void 0,void 0,function*(){this.availableImages[A]=P;for(let D in this.workerSources[A]){let O=this.workerSources[A][D];for(let H in O)O[H].availableImages=P}})}_syncRTLPluginState(A,P){return L._(this,void 0,void 0,function*(){if(L.bD.isParsed())return L.bD.getState();if(P.pluginStatus!=="loading")return L.bD.setState(P),P;let D=P.pluginURL;if(this.self.importScripts(D),L.bD.isParsed()){let O={pluginStatus:"loaded",pluginURL:D};return L.bD.setState(O),O}throw L.bD.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${D}`)})}_getAvailableImages(A){let P=this.availableImages[A];return P||(P=[]),P}_getLayerIndex(A){let P=this.layerIndexes[A];return P||(P=this.layerIndexes[A]=new p),P}_getWorkerSource(A,P,D){if(this.workerSources[A]||(this.workerSources[A]={}),this.workerSources[A][P]||(this.workerSources[A][P]={}),!this.workerSources[A][P][D]){let O={sendAsync:(H,W)=>(H.targetMapId=A,this.actor.sendAsync(H,W))};switch(P){case"vector":this.workerSources[A][P][D]=new me(O,this._getLayerIndex(A),this._getAvailableImages(A));break;case"geojson":this.workerSources[A][P][D]=new Ar(O,this._getLayerIndex(A),this._getAvailableImages(A));break;default:this.workerSources[A][P][D]=new this.externalWorkerSourceTypes[P](O,this._getLayerIndex(A),this._getAvailableImages(A))}}return this.workerSources[A][P][D]}_getDEMWorkerSource(A,P){return this.demWorkerSources[A]||(this.demWorkerSources[A]={}),this.demWorkerSources[A][P]||(this.demWorkerSources[A][P]=new se),this.demWorkerSources[A][P]}}return L.i(self)&&(self.worker=new ir(self)),ir}),Ll("index",["exports","./shared"],function(L,p){"use strict";var ki="4.7.1";let Hi,Gt,me={now:typeof performance<"u"&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frameAsync:h=>new Promise((e,n)=>{let a=requestAnimationFrame(e);h.signal.addEventListener("abort",()=>{cancelAnimationFrame(a),n(p.c())})}),getImageData(h,e=0){return this.getImageCanvasContext(h).getImageData(-e,-e,h.width+2*e,h.height+2*e)},getImageCanvasContext(h){let e=window.document.createElement("canvas"),n=e.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("failed to create canvas 2d context");return e.width=h.width,e.height=h.height,n.drawImage(h,0,0,h.width,h.height),n},resolveURL:h=>(Hi||(Hi=document.createElement("a")),Hi.href=h,Hi.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(Gt==null&&(Gt=matchMedia("(prefers-reduced-motion: reduce)")),Gt.matches)}};class se{static testProp(e){if(!se.docStyle)return e[0];for(let n=0;n{window.removeEventListener("click",se.suppressClickInternal,!0)},0)}static getScale(e){let n=e.getBoundingClientRect();return{x:n.width/e.offsetWidth||1,y:n.height/e.offsetHeight||1,boundingClientRect:n}}static getPoint(e,n,a){let o=n.boundingClientRect;return new p.P((a.clientX-o.left)/n.x-e.clientLeft,(a.clientY-o.top)/n.y-e.clientTop)}static mousePos(e,n){let a=se.getScale(e);return se.getPoint(e,a,n)}static touchPos(e,n){let a=[],o=se.getScale(e);for(let c=0;c{vr&&Gn(vr),vr=null,cr=!0},Xi.onerror=()=>{br=!0,vr=null},Xi.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(h){let e,n,a,o;h.resetRequestQueue=()=>{e=[],n=0,a=0,o={}},h.addThrottleControl=y=>{let b=a++;return o[b]=y,b},h.removeThrottleControl=y=>{delete o[y],m()},h.getImage=(y,b,T=!0)=>new Promise((S,C)=>{Fr.supported&&(y.headers||(y.headers={}),y.headers.accept="image/webp,*/*"),p.e(y,{type:"image"}),e.push({abortController:b,requestParameters:y,supportImageRefresh:T,state:"queued",onError:E=>{C(E)},onSuccess:E=>{S(E)}}),m()});let c=y=>p._(this,void 0,void 0,function*(){y.state="running";let{requestParameters:b,supportImageRefresh:T,onError:S,onSuccess:C,abortController:E}=y,R=T===!1&&!p.i(self)&&!p.g(b.url)&&(!b.headers||Object.keys(b.headers).reduce(($,Z)=>$&&Z==="accept",!0));n++;let V=R?g(b,E):p.m(b,E);try{let $=yield V;delete y.abortController,y.state="completed",$.data instanceof HTMLImageElement||p.b($.data)?C($):$.data&&C({data:yield(U=$.data,typeof createImageBitmap=="function"?p.d(U):p.f(U)),cacheControl:$.cacheControl,expires:$.expires})}catch($){delete y.abortController,S($)}finally{n--,m()}var U}),m=()=>{let y=(()=>{for(let b of Object.keys(o))if(o[b]())return!0;return!1})()?p.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:p.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let b=n;b0;b++){let T=e.shift();T.abortController.signal.aborted?b--:c(T)}},g=(y,b)=>new Promise((T,S)=>{let C=new Image,E=y.url,R=y.credentials;R&&R==="include"?C.crossOrigin="use-credentials":(R&&R==="same-origin"||!p.s(E))&&(C.crossOrigin="anonymous"),b.signal.addEventListener("abort",()=>{C.src="",S(p.c())}),C.fetchPriority="high",C.onload=()=>{C.onerror=C.onload=null,T({data:C})},C.onerror=()=>{C.onerror=C.onload=null,b.signal.aborted||S(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."))},C.src=E})}(hi||(hi={})),hi.resetRequestQueue();class wa{constructor(e){this._transformRequestFn=e}transformRequest(e,n){return this._transformRequestFn&&this._transformRequestFn(e,n)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function zi(h){var e=new p.A(3);return e[0]=h[0],e[1]=h[1],e[2]=h[2],e}var Wi,vi=function(h,e,n){return h[0]=e[0]-n[0],h[1]=e[1]-n[1],h[2]=e[2]-n[2],h};Wi=new p.A(3),p.A!=Float32Array&&(Wi[0]=0,Wi[1]=0,Wi[2]=0);var Is=function(h){var e=h[0],n=h[1];return e*e+n*n};function Ki(h){let e=[];if(typeof h=="string")e.push({id:"default",url:h});else if(h&&h.length>0){let n=[];for(let{id:a,url:o}of h){let c=`${a}${o}`;n.indexOf(c)===-1&&(n.push(c),e.push({id:a,url:o}))}}return e}function Hn(h,e,n){let a=h.split("?");return a[0]+=`${e}${n}`,a.join("?")}(function(){var h=new p.A(2);p.A!=Float32Array&&(h[0]=0,h[1]=0)})();class st{constructor(e,n,a,o){this.context=e,this.format=a,this.texture=e.gl.createTexture(),this.update(n,o)}update(e,n,a){let{width:o,height:c}=e,m=!(this.size&&this.size[0]===o&&this.size[1]===c||a),{context:g}=this,{gl:y}=g;if(this.useMipmap=!!(n&&n.useMipmap),y.bindTexture(y.TEXTURE_2D,this.texture),g.pixelStoreUnpackFlipY.set(!1),g.pixelStoreUnpack.set(1),g.pixelStoreUnpackPremultiplyAlpha.set(this.format===y.RGBA&&(!n||n.premultiply!==!1)),m)this.size=[o,c],e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||p.b(e)?y.texImage2D(y.TEXTURE_2D,0,this.format,this.format,y.UNSIGNED_BYTE,e):y.texImage2D(y.TEXTURE_2D,0,this.format,o,c,0,this.format,y.UNSIGNED_BYTE,e.data);else{let{x:b,y:T}=a||{x:0,y:0};e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||p.b(e)?y.texSubImage2D(y.TEXTURE_2D,0,b,T,y.RGBA,y.UNSIGNED_BYTE,e):y.texSubImage2D(y.TEXTURE_2D,0,b,T,o,c,y.RGBA,y.UNSIGNED_BYTE,e.data)}this.useMipmap&&this.isSizePowerOfTwo()&&y.generateMipmap(y.TEXTURE_2D)}bind(e,n,a){let{context:o}=this,{gl:c}=o;c.bindTexture(c.TEXTURE_2D,this.texture),a!==c.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(a=c.LINEAR),e!==this.filter&&(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,e),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,a||e),this.filter=e),n!==this.wrap&&(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,n),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,n),this.wrap=n)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){let{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}function Ps(h){let{userImage:e}=h;return!!(e&&e.render&&e.render())&&(h.data.replace(new Uint8Array(e.data.buffer)),!0)}class Ft extends p.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new p.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(let{ids:n,promiseResolve:a}of this.requestors)a(this._getImagesForIds(n));this.requestors=[]}}getImage(e){let n=this.images[e];if(n&&!n.data&&n.spriteData){let a=n.spriteData;n.data=new p.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(e,n){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,n)&&(this.images[e]=n)}_validate(e,n){let a=!0,o=n.data||n.spriteData;return this._validateStretch(n.stretchX,o&&o.width)||(this.fire(new p.j(new Error(`Image "${e}" has invalid "stretchX" value`))),a=!1),this._validateStretch(n.stretchY,o&&o.height)||(this.fire(new p.j(new Error(`Image "${e}" has invalid "stretchY" value`))),a=!1),this._validateContent(n.content,n)||(this.fire(new p.j(new Error(`Image "${e}" has invalid "content" value`))),a=!1),a}_validateStretch(e,n){if(!e)return!0;let a=0;for(let o of e){if(o[0]{let o=!0;if(!this.isLoaded())for(let c of e)this.images[c]||(o=!1);this.isLoaded()||o?n(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:n})})}_getImagesForIds(e){let n={};for(let a of e){let o=this.getImage(a);o||(this.fire(new p.k("styleimagemissing",{id:a})),o=this.getImage(a)),o?n[a]={data:o.data.clone(),pixelRatio:o.pixelRatio,sdf:o.sdf,version:o.version,stretchX:o.stretchX,stretchY:o.stretchY,content:o.content,textFitWidth:o.textFitWidth,textFitHeight:o.textFitHeight,hasRenderCallback:!!(o.userImage&&o.userImage.render)}:p.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(){let{width:e,height:n}=this.atlasImage;return{width:e,height:n}}getPattern(e){let n=this.patterns[e],a=this.getImage(e);if(!a)return null;if(n&&n.position.version===a.version)return n.position;if(n)n.position.version=a.version;else{let o={w:a.data.width+2,h:a.data.height+2,x:0,y:0},c=new p.I(o,a);this.patterns[e]={bin:o,position:c}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){let n=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new st(e,this.atlasImage,n.RGBA),this.atlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(){let e=[];for(let c in this.patterns)e.push(this.patterns[c].bin);let{w:n,h:a}=p.p(e),o=this.atlasImage;o.resize({width:n||1,height:a||1});for(let c in this.patterns){let{bin:m}=this.patterns[c],g=m.x+1,y=m.y+1,b=this.getImage(c).data,T=b.width,S=b.height;p.R.copy(b,o,{x:0,y:0},{x:g,y},{width:T,height:S}),p.R.copy(b,o,{x:0,y:S-1},{x:g,y:y-1},{width:T,height:1}),p.R.copy(b,o,{x:0,y:0},{x:g,y:y+S},{width:T,height:1}),p.R.copy(b,o,{x:T-1,y:0},{x:g-1,y},{width:1,height:S}),p.R.copy(b,o,{x:0,y:0},{x:g+T,y},{width:1,height:S})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(let n of e){if(this.callbackDispatchedThisFrame[n])continue;this.callbackDispatchedThisFrame[n]=!0;let a=this.getImage(n);a||p.w(`Image with ID: "${n}" was not found`),Ps(a)&&this.updateImage(n,a)}}}let Ht=1e20;function hr(h,e,n,a,o,c,m,g,y){for(let b=e;b-1);y++,c[y]=g,m[y]=b,m[y+1]=Ht}for(let g=0,y=0;g65535)throw new Error("glyphs > 65535 not supported");if(a.ranges[c])return{stack:e,id:n,glyph:o};if(!this.url)throw new Error("glyphsUrl is not set");if(!a.requests[c]){let g=Ji.loadGlyphRange(e,c,this.url,this.requestManager);a.requests[c]=g}let m=yield a.requests[c];for(let g in m)this._doesCharSupportLocalGlyph(+g)||(a.glyphs[+g]=m[+g]);return a.ranges[c]=!0,{stack:e,id:n,glyph:m[n]||null}})}_doesCharSupportLocalGlyph(e){return!!this.localIdeographFontFamily&&/\p{Ideo}|\p{sc=Hang}|\p{sc=Hira}|\p{sc=Kana}/u.test(String.fromCodePoint(e))}_tinySDF(e,n,a){let o=this.localIdeographFontFamily;if(!o||!this._doesCharSupportLocalGlyph(a))return;let c=e.tinySDF;if(!c){let g="400";/bold/i.test(n)?g="900":/medium/i.test(n)?g="500":/light/i.test(n)&&(g="200"),c=e.tinySDF=new Ji.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:o,fontWeight:g})}let m=c.draw(String.fromCharCode(a));return{id:a,bitmap:new p.o({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}}}}Ji.loadGlyphRange=function(h,e,n,a){return p._(this,void 0,void 0,function*(){let o=256*e,c=o+255,m=a.transformRequest(n.replace("{fontstack}",h).replace("{range}",`${o}-${c}`),"Glyphs"),g=yield p.l(m,new AbortController);if(!g||!g.data)throw new Error(`Could not load glyph range. range: ${e}, ${o}-${c}`);let y={};for(let b of p.n(g.data))y[b.id]=b;return y})},Ji.TinySDF=class{constructor({fontSize:h=24,buffer:e=3,radius:n=8,cutoff:a=.25,fontFamily:o="sans-serif",fontWeight:c="normal",fontStyle:m="normal"}={}){this.buffer=e,this.cutoff=a,this.radius=n;let g=this.size=h+4*e,y=this._createCanvas(g),b=this.ctx=y.getContext("2d",{willReadFrequently:!0});b.font=`${m} ${c} ${h}px ${o}`,b.textBaseline="alphabetic",b.textAlign="left",b.fillStyle="black",this.gridOuter=new Float64Array(g*g),this.gridInner=new Float64Array(g*g),this.f=new Float64Array(g),this.z=new Float64Array(g+1),this.v=new Uint16Array(g)}_createCanvas(h){let e=document.createElement("canvas");return e.width=e.height=h,e}draw(h){let{width:e,actualBoundingBoxAscent:n,actualBoundingBoxDescent:a,actualBoundingBoxLeft:o,actualBoundingBoxRight:c}=this.ctx.measureText(h),m=Math.ceil(n),g=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(c-o))),y=Math.min(this.size-this.buffer,m+Math.ceil(a)),b=g+2*this.buffer,T=y+2*this.buffer,S=Math.max(b*T,0),C=new Uint8ClampedArray(S),E={data:C,width:b,height:T,glyphWidth:g,glyphHeight:y,glyphTop:m,glyphLeft:0,glyphAdvance:e};if(g===0||y===0)return E;let{ctx:R,buffer:V,gridInner:U,gridOuter:$}=this;R.clearRect(V,V,g,y),R.fillText(h,V,V+m);let Z=R.getImageData(V,V,g,y);$.fill(Ht,0,S),U.fill(0,0,S);for(let B=0;B0?oe*oe:0,U[ee]=oe<0?oe*oe:0}}hr($,0,0,b,T,b,this.f,this.v,this.z),hr(U,V,V,g,y,b,this.f,this.v,this.z);for(let B=0;B1&&(y=e[++g]);let T=Math.abs(b-y.left),S=Math.abs(b-y.right),C=Math.min(T,S),E,R=c/a*(o+1);if(y.isDash){let V=o-Math.abs(R);E=Math.sqrt(C*C+V*V)}else E=o-Math.sqrt(C*C+R*R);this.data[m+b]=Math.max(0,Math.min(255,E+128))}}}addRegularDash(e){for(let g=e.length-1;g>=0;--g){let y=e[g],b=e[g+1];y.zeroLength?e.splice(g,1):b&&b.isDash===y.isDash&&(b.left=y.left,e.splice(g,1))}let n=e[0],a=e[e.length-1];n.isDash===a.isDash&&(n.left=a.left-this.width,a.right=n.right+this.width);let o=this.width*this.nextRow,c=0,m=e[c];for(let g=0;g1&&(m=e[++c]);let y=Math.abs(g-m.left),b=Math.abs(g-m.right),T=Math.min(y,b);this.data[o+g]=Math.max(0,Math.min(255,(m.isDash?T:-T)+128))}}addDash(e,n){let a=n?7:0,o=2*a+1;if(this.nextRow+o>this.height)return p.w("LineAtlas out of space"),null;let c=0;for(let g=0;g{n.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[wr]}numActive(){return Object.keys(this.active).length}}let cn=Math.floor(me.hardwareConcurrency/2),ui,Di;function Vr(){return ui||(ui=new Yi),ui}Yi.workerCount=p.C(globalThis)?Math.max(Math.min(cn,3),1):1;class Nr{constructor(e,n){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=n;let a=this.workerPool.acquire(n);for(let o=0;o{n.remove()}),this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,n){for(let a of this.actors)a.registerMessageHandler(e,n)}}function Xn(){return Di||(Di=new Nr(Vr(),p.G),Di.registerMessageHandler("GR",(h,e,n)=>p.m(e,n))),Di}function dr(h,e){let n=p.H();return p.J(n,n,[1,1,0]),p.K(n,n,[.5*h.width,.5*h.height,1]),p.L(n,n,h.calculatePosMatrix(e.toUnwrapped()))}function Tr(h,e,n,a,o,c){let m=function(S,C,E){if(S)for(let R of S){let V=C[R];if(V&&V.source===E&&V.type==="fill-extrusion")return!0}else for(let R in C){let V=C[R];if(V.source===E&&V.type==="fill-extrusion")return!0}return!1}(o&&o.layers,e,h.id),g=c.maxPitchScaleFactor(),y=h.tilesIn(a,g,m);y.sort(Sr);let b=[];for(let S of y)b.push({wrappedTileID:S.tileID.wrapped().key,queryResults:S.tile.queryRenderedFeatures(e,n,h._state,S.queryGeometry,S.cameraQueryGeometry,S.scale,o,c,g,dr(h.transform,S.tileID))});let T=function(S){let C={},E={};for(let R of S){let V=R.queryResults,U=R.wrappedTileID,$=E[U]=E[U]||{};for(let Z in V){let B=V[Z],X=$[Z]=$[Z]||{},K=C[Z]=C[Z]||[];for(let ee of B)X[ee.featureIndex]||(X[ee.featureIndex]=!0,K.push(ee))}}return C}(b);for(let S in T)T[S].forEach(C=>{let E=C.feature,R=h.getFeatureState(E.layer["source-layer"],E.id);E.source=E.layer.source,E.layer["source-layer"]&&(E.sourceLayer=E.layer["source-layer"]),E.state=R});return T}function Sr(h,e){let n=h.tileID,a=e.tileID;return n.overscaledZ-a.overscaledZ||n.canonical.y-a.canonical.y||n.wrap-a.wrap||n.canonical.x-a.canonical.x}function hn(h,e,n){return p._(this,void 0,void 0,function*(){let a=h;if(h.url?a=(yield p.h(e.transformRequest(h.url,"Source"),n)).data:yield me.frameAsync(n),!a)return null;let o=p.M(p.e(a,h),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in a&&a.vector_layers&&(o.vectorLayerIds=a.vector_layers.map(c=>c.id)),o})}class ie{constructor(e,n){e&&(n?this.setSouthWest(e).setNorthEast(n):Array.isArray(e)&&(e.length===4?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1])))}setNorthEast(e){return this._ne=e instanceof p.N?new p.N(e.lng,e.lat):p.N.convert(e),this}setSouthWest(e){return this._sw=e instanceof p.N?new p.N(e.lng,e.lat):p.N.convert(e),this}extend(e){let n=this._sw,a=this._ne,o,c;if(e instanceof p.N)o=e,c=e;else{if(!(e instanceof ie))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(ie.convert(e)):this.extend(p.N.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(p.N.convert(e)):this;if(o=e._sw,c=e._ne,!o||!c)return this}return n||a?(n.lng=Math.min(o.lng,n.lng),n.lat=Math.min(o.lat,n.lat),a.lng=Math.max(c.lng,a.lng),a.lat=Math.max(c.lat,a.lat)):(this._sw=new p.N(o.lng,o.lat),this._ne=new p.N(c.lng,c.lat)),this}getCenter(){return new p.N((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 p.N(this.getWest(),this.getNorth())}getSouthEast(){return new p.N(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){let{lng:n,lat:a}=p.N.convert(e),o=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=n&&n>=this._ne.lng),this._sw.lat<=a&&a<=this._ne.lat&&o}static convert(e){return e instanceof ie?e:e&&new ie(e)}static fromLngLat(e,n=0){let a=360*n/40075017,o=a/Math.cos(Math.PI/180*e.lat);return new ie(new p.N(e.lng-o,e.lat-a),new p.N(e.lng+o,e.lat+a))}adjustAntiMeridian(){let e=new p.N(this._sw.lng,this._sw.lat),n=new p.N(this._ne.lng,this._ne.lat);return new ie(e,e.lng>n.lng?new p.N(n.lng+360,n.lat):n)}}class jr{constructor(e,n,a){this.bounds=ie.convert(this.validateBounds(e)),this.minzoom=n||0,this.maxzoom=a||24}validateBounds(e){return Array.isArray(e)&&e.length===4?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){let n=Math.pow(2,e.z),a=Math.floor(p.O(this.bounds.getWest())*n),o=Math.floor(p.Q(this.bounds.getNorth())*n),c=Math.ceil(p.O(this.bounds.getEast())*n),m=Math.ceil(p.Q(this.bounds.getSouth())*n);return e.x>=a&&e.x=o&&e.y{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return p.e({},this._options)}loadTile(e){return p._(this,void 0,void 0,function*(){let n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),a={request:this.map._requestManager.transformRequest(n,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};a.request.collectResourceTiming=this._collectResourceTiming;let o="RT";if(e.actor&&e.state!=="expired"){if(e.state==="loading")return new Promise((c,m)=>{e.reloadPromise={resolve:c,reject:m}})}else e.actor=this.dispatcher.getActor(),o="LT";e.abortController=new AbortController;try{let c=yield e.actor.sendAsync({type:o,data:a},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,c)}catch(c){if(delete e.abortController,e.aborted)return;if(c&&c.status!==404)throw c;this._afterTileLoadWorkerResponse(e,null)}})}_afterTileLoadWorkerResponse(e,n){if(n&&n.resourceTiming&&(e.resourceTiming=n.resourceTiming),n&&this.map._refreshExpiredTiles&&e.setExpiryData(n),e.loadVectorData(n,this.map.painter),e.reloadPromise){let a=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(a.resolve).catch(a.reject)}}abortTile(e){return p._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}}))})}unloadTile(e){return p._(this,void 0,void 0,function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}))})}hasTransition(){return!1}}class et extends p.E{constructor(e,n,a,o){super(),this.id=e,this.dispatcher=a,this.setEventedParent(o),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=p.e({type:"raster"},n),p.e(this,p.M(n,["url","scheme","tileSize"]))}load(){return p._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new p.k("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{let e=yield hn(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,e&&(p.e(this,e),e.bounds&&(this.tileBounds=new jr(e.bounds,this.minzoom,this.maxzoom)),this.fire(new p.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new p.k("data",{dataType:"source",sourceDataType:"content"})))}catch(e){this._tileJSONRequest=null,this.fire(new p.j(e))}})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load()}setTiles(e){return this.setSourceProperty(()=>{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}serialize(){return p.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return p._(this,void 0,void 0,function*(){let n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{let a=yield hi.getImage(this.map._requestManager.transformRequest(n,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(a&&a.data){this.map._refreshExpiredTiles&&a.cacheControl&&a.expires&&e.setExpiryData({cacheControl:a.cacheControl,expires:a.expires});let o=this.map.painter.context,c=o.gl,m=a.data;e.texture=this.map.painter.getTileTexture(m.width),e.texture?e.texture.update(m,{useMipmap:!0}):(e.texture=new st(o,m,c.RGBA,{useMipmap:!0}),e.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE,c.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(a){if(delete e.abortController,e.aborted)e.state="unloaded";else if(a)throw e.state="errored",a}})}abortTile(e){return p._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)})}unloadTile(e){return p._(this,void 0,void 0,function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)})}hasTransition(){return!1}}class yt extends et{constructor(e,n,a,o){super(e,n,a,o),this.type="raster-dem",this.maxzoom=22,this._options=p.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(e){return p._(this,void 0,void 0,function*(){let n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),a=this.map._requestManager.transformRequest(n,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{let o=yield hi.getImage(a,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(o&&o.data){let c=o.data;this.map._refreshExpiredTiles&&o.cacheControl&&o.expires&&e.setExpiryData({cacheControl:o.cacheControl,expires:o.expires});let m=p.b(c)&&p.U()?c:yield this.readImageNow(c),g={type:this.type,uid:e.uid,source:this.id,rawImageData:m,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||e.state==="expired"){e.actor=this.dispatcher.getActor();let y=yield e.actor.sendAsync({type:"LDT",data:g});e.dem=y,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}}catch(o){if(delete e.abortController,e.aborted)e.state="unloaded";else if(o)throw e.state="errored",o}})}readImageNow(e){return p._(this,void 0,void 0,function*(){if(typeof VideoFrame<"u"&&p.V()){let n=e.width+2,a=e.height+2;try{return new p.R({width:n,height:a},yield p.W(e,-1,-1,n,a))}catch{}}return me.getImageData(e,1)})}_getNeighboringTiles(e){let n=e.canonical,a=Math.pow(2,n.z),o=(n.x-1+a)%a,c=n.x===0?e.wrap-1:e.wrap,m=(n.x+1+a)%a,g=n.x+1===a?e.wrap+1:e.wrap,y={};return y[new p.S(e.overscaledZ,c,n.z,o,n.y).key]={backfilled:!1},y[new p.S(e.overscaledZ,g,n.z,m,n.y).key]={backfilled:!1},n.y>0&&(y[new p.S(e.overscaledZ,c,n.z,o,n.y-1).key]={backfilled:!1},y[new p.S(e.overscaledZ,e.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},y[new p.S(e.overscaledZ,g,n.z,m,n.y-1).key]={backfilled:!1}),n.y+10&&p.e(c,{resourceTiming:o}),this.fire(new p.k("data",Object.assign(Object.assign({},c),{sourceDataType:"metadata"}))),this.fire(new p.k("data",Object.assign(Object.assign({},c),{sourceDataType:"content"})))}catch(a){if(this._pendingLoads--,this._removed)return void this.fire(new p.k("dataabort",{dataType:"source"}));this.fire(new p.j(a))}})}loaded(){return this._pendingLoads===0}loadTile(e){return p._(this,void 0,void 0,function*(){let n=e.actor?"RT":"LT";e.actor=this.actor;let a={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};e.abortController=new AbortController;let o=yield this.actor.sendAsync({type:n,data:a},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(o,this.map.painter,n==="RT")})}abortTile(e){return p._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0})}unloadTile(e){return p._(this,void 0,void 0,function*(){e.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}})})}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}})}serialize(){return p.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}var Ir=p.Y([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class pr extends p.E{constructor(e,n,a,o){super(),this.id=e,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(o),this.options=n}load(e){return p._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new p.k("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{let n=yield hi.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,n&&n.data&&(this.image=n.data,e&&(this.coordinates=e),this._finishLoading())}catch(n){this._request=null,this._loaded=!0,this.fire(new p.j(n))}})}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=e.url,this.load(e.coordinates).finally(()=>{this.texture=null}),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new p.k("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(e){this.coordinates=e;let n=e.map(p.Z.fromLngLat);this.tileID=function(o){let c=1/0,m=1/0,g=-1/0,y=-1/0;for(let C of o)c=Math.min(c,C.x),m=Math.min(m,C.y),g=Math.max(g,C.x),y=Math.max(y,C.y);let b=Math.max(g-c,y-m),T=Math.max(0,Math.floor(-Math.log(b)/Math.LN2)),S=Math.pow(2,T);return new p.a1(T,Math.floor((c+g)/2*S),Math.floor((m+y)/2*S))}(n),this.minzoom=this.maxzoom=this.tileID.z;let a=n.map(o=>this.tileID.getTilePoint(o)._round());return this._boundsArray=new p.$,this._boundsArray.emplaceBack(a[0].x,a[0].y,0,0),this._boundsArray.emplaceBack(a[1].x,a[1].y,p.X,0),this._boundsArray.emplaceBack(a[3].x,a[3].y,0,p.X),this._boundsArray.emplaceBack(a[2].x,a[2].y,p.X,p.X),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new p.k("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;let e=this.map.painter.context,n=e.gl;this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,Ir.members)),this.boundsSegments||(this.boundsSegments=p.a0.simpleSegment(0,0,4,2)),this.texture||(this.texture=new st(e,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let a=!1;for(let o in this.tiles){let c=this.tiles[o];c.state!=="loaded"&&(c.state="loaded",c.texture=this.texture,a=!0)}a&&this.fire(new p.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return p._(this,void 0,void 0,function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"})}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}class un extends pr{constructor(e,n,a,o){super(e,n,a,o),this.roundZoom=!0,this.type="video",this.options=n}load(){return p._(this,void 0,void 0,function*(){this._loaded=!1;let e=this.options;this.urls=[];for(let n of e.urls)this.urls.push(this.map._requestManager.transformRequest(n,"Source").url);try{let n=yield p.a3(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 p.j(n))}})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){let n=this.video.seekable;en.end(0)?this.fire(new p.j(new p.a2(`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=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;let e=this.map.painter.context,n=e.gl;this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,Ir.members)),this.boundsSegments||(this.boundsSegments=p.a0.simpleSegment(0,0,4,2)),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 st(e,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let a=!1;for(let o in this.tiles){let c=this.tiles[o];c.state!=="loaded"&&(c.state="loaded",c.texture=this.texture,a=!0)}a&&this.fire(new p.k("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 bi extends pr{constructor(e,n,a,o){super(e,n,a,o),n.coordinates?Array.isArray(n.coordinates)&&n.coordinates.length===4&&!n.coordinates.some(c=>!Array.isArray(c)||c.length!==2||c.some(m=>typeof m!="number"))||this.fire(new p.j(new p.a2(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new p.j(new p.a2(`sources.${e}`,null,'missing required property "coordinates"'))),n.animate&&typeof n.animate!="boolean"&&this.fire(new p.j(new p.a2(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),n.canvas?typeof n.canvas=="string"||n.canvas instanceof HTMLCanvasElement||this.fire(new p.j(new p.a2(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new p.j(new p.a2(`sources.${e}`,null,'missing required property "canvas"'))),this.options=n,this.animate=n.animate===void 0||n.animate}load(){return p._(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 p.j(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())})}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;let n=this.map.painter.context,a=n.gl;this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,Ir.members)),this.boundsSegments||(this.boundsSegments=p.a0.simpleSegment(0,0,4,2)),this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new st(n,this.canvas,a.RGBA,{premultiply:!0});let o=!1;for(let c in this.tiles){let m=this.tiles[c];m.state!=="loaded"&&(m.state="loaded",m.texture=this.texture,o=!0)}o&&this.fire(new p.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(let e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}}let Jn={},Yn=h=>{switch(h){case"geojson":return Kn;case"image":return pr;case"raster":return et;case"raster-dem":return yt;case"vector":return Wn;case"video":return un;case"canvas":return bi}return Jn[h]},ue="RTLPluginLoaded";class Qi extends p.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=Xn()}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch(n=>{throw this.status="error",n})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(e){return p._(this,arguments,void 0,function*(n,a=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=me.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 p._(this,void 0,void 0,function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new p.k(ue))})}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}}let Xt=null;function er(){return Xt||(Xt=new Qi),Xt}class Pr{constructor(e,n){this.timeAdded=0,this.fadeEndTime=0,this.tileID=e,this.uid=p.a4(),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"}registerFadeDuration(e){let n=e+this.timeAdded;nc.getLayer(b)).filter(Boolean);if(y.length!==0){g.layers=y,g.stateDependentLayerIds&&(g.stateDependentLayers=g.stateDependentLayerIds.map(b=>y.filter(T=>T.id===b)[0]));for(let b of y)m[b.id]=g}}return m}(e.buckets,n.style),this.hasSymbolBuckets=!1;for(let o in this.buckets){let c=this.buckets[o];if(c instanceof p.a6){if(this.hasSymbolBuckets=!0,!a)break;c.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let o in this.buckets){let c=this.buckets[o];if(c instanceof p.a6&&c.hasRTLText){this.hasRTLText=!0,er().lazyLoad();break}}this.queryPadding=0;for(let o in this.buckets){let c=this.buckets[o];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(o).queryRadius(c))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage)}else this.collisionBoxArray=new p.a5}unloadVectorData(){for(let e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(let a in this.buckets){let o=this.buckets[a];o.uploadPending()&&o.upload(e)}let n=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new st(e,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new st(e,this.glyphAtlasImage,n.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,n,a,o,c,m,g,y,b,T){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:o,cameraQueryGeometry:c,scale:m,tileSize:this.tileSize,pixelPosMatrix:T,transform:y,params:g,queryPadding:this.queryPadding*b},e,n,a):{}}querySourceFeatures(e,n){let a=this.latestFeatureIndex;if(!a||!a.rawTileData)return;let o=a.loadVTLayers(),c=n&&n.sourceLayer?n.sourceLayer:"",m=o._geojsonTileLayer||o[c];if(!m)return;let g=p.a7(n&&n.filter),{z:y,x:b,y:T}=this.tileID.canonical,S={z:y,x:b,y:T};for(let C=0;Ca)o=!1;else if(n)if(this.expirationTime{this.remove(e,c)},a)),this.data[o].push(c),this.order.push(o),this.order.length>this.max){let m=this._getAndRemoveByKey(this.order[0]);m&&this.onRemove(m)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){let n=this.data[e].shift();return n.timeout&&clearTimeout(n.timeout),this.data[e].length===0&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),n.value}getByKey(e){let n=this.data[e];return n?n[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,n){if(!this.has(e))return this;let a=e.wrapped().key,o=n===void 0?0:this.data[a].indexOf(n),c=this.data[a][o];return this.data[a].splice(o,1),c.timeout&&clearTimeout(c.timeout),this.data[a].length===0&&delete this.data[a],this.onRemove(c.value),this.order.splice(this.order.indexOf(a),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){let n=this._getAndRemoveByKey(this.order[0]);n&&this.onRemove(n)}return this}filter(e){let n=[];for(let a in this.data)for(let o of this.data[a])e(o.value)||n.push(o);for(let a of n)this.remove(a.value.tileID,a)}}class $e{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,n,a){let o=String(n);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][o]=this.stateChanges[e][o]||{},p.e(this.stateChanges[e][o],a),this.deletedStates[e]===null){this.deletedStates[e]={};for(let c in this.state[e])c!==o&&(this.deletedStates[e][c]=null)}else if(this.deletedStates[e]&&this.deletedStates[e][o]===null){this.deletedStates[e][o]={};for(let c in this.state[e][o])a[c]||(this.deletedStates[e][o][c]=null)}else for(let c in a)this.deletedStates[e]&&this.deletedStates[e][o]&&this.deletedStates[e][o][c]===null&&delete this.deletedStates[e][o][c]}removeFeatureState(e,n,a){if(this.deletedStates[e]===null)return;let o=String(n);if(this.deletedStates[e]=this.deletedStates[e]||{},a&&n!==void 0)this.deletedStates[e][o]!==null&&(this.deletedStates[e][o]=this.deletedStates[e][o]||{},this.deletedStates[e][o][a]=null);else if(n!==void 0)if(this.stateChanges[e]&&this.stateChanges[e][o])for(a in this.deletedStates[e][o]={},this.stateChanges[e][o])this.deletedStates[e][o][a]=null;else this.deletedStates[e][o]=null;else this.deletedStates[e]=null}getState(e,n){let a=String(n),o=p.e({},(this.state[e]||{})[a],(this.stateChanges[e]||{})[a]);if(this.deletedStates[e]===null)return{};if(this.deletedStates[e]){let c=this.deletedStates[e][n];if(c===null)return{};for(let m in c)delete o[m]}return o}initializeTileState(e,n){e.setFeatureState(this.state,n)}coalesceChanges(e,n){let a={};for(let o in this.stateChanges){this.state[o]=this.state[o]||{};let c={};for(let m in this.stateChanges[o])this.state[o][m]||(this.state[o][m]={}),p.e(this.state[o][m],this.stateChanges[o][m]),c[m]=this.state[o][m];a[o]=c}for(let o in this.deletedStates){this.state[o]=this.state[o]||{};let c={};if(this.deletedStates[o]===null)for(let m in this.state[o])c[m]={},this.state[o][m]={};else for(let m in this.deletedStates[o]){if(this.deletedStates[o][m]===null)this.state[o][m]={};else for(let g of Object.keys(this.deletedStates[o][m]))delete this.state[o][m][g];c[m]=this.state[o][m]}a[o]=a[o]||{},p.e(a[o],c)}if(this.stateChanges={},this.deletedStates={},Object.keys(a).length!==0)for(let o in e)e[o].setFeatureState(a,n)}}class Be extends p.E{constructor(e,n,a){super(),this.id=e,this.dispatcher=a,this.on("data",o=>this._dataHandler(o)),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((o,c,m,g)=>{let y=new(Yn(c.type))(o,c,m,g);if(y.id!==o)throw new Error(`Expected Source id to be ${o} instead of ${y.id}`);return y})(e,n,a,this),this._tiles={},this._cache=new _e(0,o=>this._unloadTile(o)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new $e,this._didEmitContent=!1,this._updated=!1}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e)}onRemove(e){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!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(let e in this._tiles){let n=this._tiles[e];if(n.state!=="loaded"&&n.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;let e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(e,n,a){return p._(this,void 0,void 0,function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,n,a)}catch(o){e.state="errored",o.status!==404?this._source.fire(new p.j(o,{tile:e})):this.update(this.transform,this.terrain)}})}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new p.k("dataabort",{tile:e,coord:e.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(let n in this._tiles){let a=this._tiles[n];a.upload(e),a.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map(e=>e.tileID).sort(ti).map(e=>e.key)}getRenderableIds(e){let n=[];for(let a in this._tiles)this._isIdRenderable(a,e)&&n.push(this._tiles[a]);return e?n.sort((a,o)=>{let c=a.tileID,m=o.tileID,g=new p.P(c.canonical.x,c.canonical.y)._rotate(this.transform.angle),y=new p.P(m.canonical.x,m.canonical.y)._rotate(this.transform.angle);return c.overscaledZ-m.overscaledZ||y.y-g.y||y.x-g.x}).map(a=>a.tileID.key):n.map(a=>a.tileID).sort(ti).map(a=>a.key)}hasRenderableParent(e){let n=this.findLoadedParent(e,0);return!!n&&this._isIdRenderable(n.tileID.key)}_isIdRenderable(e,n){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(n||!this._tiles[e].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(let e in this._tiles)this._tiles[e].state!=="errored"&&this._reloadTile(e,"reloading")}}_reloadTile(e,n){return p._(this,void 0,void 0,function*(){let a=this._tiles[e];a&&(a.state!=="loading"&&(a.state=n),yield this._loadTile(a,e,n))})}_tileLoaded(e,n,a){e.timeAdded=me.now(),a==="expired"&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(n,e),this.getSource().type==="raster-dem"&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new p.k("data",{dataType:"source",tile:e,coord:e.tileID}))}_backfillDEM(e){let n=this.getRenderableIds();for(let o=0;o1||(Math.abs(m)>1&&(Math.abs(m+y)===1?m+=y:Math.abs(m-y)===1&&(m-=y)),c.dem&&o.dem&&(o.dem.backfillBorder(c.dem,m,g),o.neighboringTiles&&o.neighboringTiles[b]&&(o.neighboringTiles[b].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,n,a,o){for(let c in this._tiles){let m=this._tiles[c];if(o[c]||!m.hasData()||m.tileID.overscaledZ<=n||m.tileID.overscaledZ>a)continue;let g=m.tileID;for(;m&&m.tileID.overscaledZ>n+1;){let b=m.tileID.scaledTo(m.tileID.overscaledZ-1);m=this._tiles[b.key],m&&m.hasData()&&(g=b)}let y=g;for(;y.overscaledZ>n;)if(y=y.scaledTo(y.overscaledZ-1),e[y.key]){o[g.key]=g;break}}}findLoadedParent(e,n){if(e.key in this._loadedParentTiles){let a=this._loadedParentTiles[e.key];return a&&a.tileID.overscaledZ>=n?a:null}for(let a=e.overscaledZ-1;a>=n;a--){let o=e.scaledTo(a),c=this._getLoadedTile(o);if(c)return c}}findLoadedSibling(e){return this._getLoadedTile(e)}_getLoadedTile(e){let n=this._tiles[e.key];return n&&n.hasData()?n:this._cache.getByKey(e.wrapped().key)}updateCacheSize(e){let n=Math.ceil(e.width/this._source.tileSize)+1,a=Math.ceil(e.height/this._source.tileSize)+1,o=Math.floor(n*a*(this._maxTileCacheZoomLevels===null?p.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),c=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(c)}handleWrapJump(e){let n=Math.round((e-(this._prevLng===void 0?e:this._prevLng))/360);if(this._prevLng=e,n){let a={};for(let o in this._tiles){let c=this._tiles[o];c.tileID=c.tileID.unwrapTo(c.tileID.wrap+n),a[c.tileID.key]=c}this._tiles=a;for(let o in this._timers)clearTimeout(this._timers[o]),delete this._timers[o];for(let o in this._tiles)this._setTileReloadTimer(o,this._tiles[o])}}_updateCoveredAndRetainedTiles(e,n,a,o,c,m){let g={},y={},b=Object.keys(e),T=me.now();for(let S of b){let C=e[S],E=this._tiles[S];if(!E||E.fadeEndTime!==0&&E.fadeEndTime<=T)continue;let R=this.findLoadedParent(C,n),V=this.findLoadedSibling(C),U=R||V||null;U&&(this._addTile(U.tileID),g[U.tileID.key]=U.tileID),y[S]=C}this._retainLoadedChildren(y,o,a,e);for(let S in g)e[S]||(this._coveredTiles[S]=!0,e[S]=g[S]);if(m){let S={},C={};for(let E of c)this._tiles[E.key].hasData()?S[E.key]=E:C[E.key]=E;for(let E in C){let R=C[E].children(this._source.maxzoom);this._tiles[R[0].key]&&this._tiles[R[1].key]&&this._tiles[R[2].key]&&this._tiles[R[3].key]&&(S[R[0].key]=e[R[0].key]=R[0],S[R[1].key]=e[R[1].key]=R[1],S[R[2].key]=e[R[2].key]=R[2],S[R[3].key]=e[R[3].key]=R[3],delete C[E])}for(let E in C){let R=C[E],V=this.findLoadedParent(R,this._source.minzoom),U=this.findLoadedSibling(R),$=V||U||null;if($){S[$.tileID.key]=e[$.tileID.key]=$.tileID;for(let Z in S)S[Z].isChildOf($.tileID)&&delete S[Z]}}for(let E in this._tiles)S[E]||(this._coveredTiles[E]=!0)}}update(e,n){if(!this._sourceLoaded||this._paused)return;let a;this.transform=e,this.terrain=n,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?a=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(T=>new p.S(T.canonical.z,T.wrap,T.canonical.z,T.canonical.x,T.canonical.y)):(a=e.coveringTiles({tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:n}),this._source.hasTile&&(a=a.filter(T=>this._source.hasTile(T)))):a=[];let o=e.coveringZoomLevel(this._source),c=Math.max(o-Be.maxOverzooming,this._source.minzoom),m=Math.max(o+Be.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){let T={};for(let S of a)if(S.canonical.z>this._source.minzoom){let C=S.scaledTo(S.canonical.z-1);T[C.key]=C;let E=S.scaledTo(Math.max(this._source.minzoom,Math.min(S.canonical.z,5)));T[E.key]=E}a=a.concat(Object.values(T))}let g=a.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,g&&this.fire(new p.k("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));let y=this._updateRetainedTiles(a,o);Li(this._source.type)&&this._updateCoveredAndRetainedTiles(y,c,m,o,a,n);for(let T in y)this._tiles[T].clearFadeHold();let b=p.ab(this._tiles,y);for(let T of b){let S=this._tiles[T];S.hasSymbolBuckets&&!S.holdingForFade()?S.setHoldDuration(this.map._fadeDuration):S.hasSymbolBuckets&&!S.symbolFadeFinished()||this._removeTile(T)}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache()}releaseSymbolFadeTiles(){for(let e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(e)}_updateRetainedTiles(e,n){var a;let o={},c={},m=Math.max(n-Be.maxOverzooming,this._source.minzoom),g=Math.max(n+Be.maxUnderzooming,this._source.minzoom),y={};for(let b of e){let T=this._addTile(b);o[b.key]=b,T.hasData()||nthis._source.maxzoom){let C=b.children(this._source.maxzoom)[0],E=this.getTile(C);if(E&&E.hasData()){o[C.key]=C;continue}}else{let C=b.children(this._source.maxzoom);if(o[C[0].key]&&o[C[1].key]&&o[C[2].key]&&o[C[3].key])continue}let S=T.wasRequested();for(let C=b.overscaledZ-1;C>=m;--C){let E=b.scaledTo(C);if(c[E.key])break;if(c[E.key]=!0,T=this.getTile(E),!T&&S&&(T=this._addTile(E)),T){let R=T.hasData();if((R||!(!((a=this.map)===null||a===void 0)&&a.cancelPendingTileRequestsWhileZooming)||S)&&(o[E.key]=E),S=T.wasRequested(),R)break}}}return o}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(let e in this._tiles){let n=[],a,o=this._tiles[e].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){a=this._loadedParentTiles[o.key];break}n.push(o.key);let c=o.scaledTo(o.overscaledZ-1);if(a=this._getLoadedTile(c),a)break;o=c}for(let c of n)this._loadedParentTiles[c]=a}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(let e in this._tiles){let n=this._tiles[e].tileID,a=this._getLoadedTile(n);this._loadedSiblingTiles[n.key]=a}}_addTile(e){let n=this._tiles[e.key];if(n)return n;n=this._cache.getAndRemove(e),n&&(this._setTileReloadTimer(e.key,n),n.tileID=e,this._state.initializeTileState(n,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,n)));let a=n;return n||(n=new Pr(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(n,e.key,n.state)),n.uses++,this._tiles[e.key]=n,a||this._source.fire(new p.k("dataloading",{tile:n,coord:n.tileID,dataType:"source"})),n}_setTileReloadTimer(e,n){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);let a=n.getExpiryTimeout();a&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},a))}_removeTile(e){let n=this._tiles[e];n&&(n.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),n.uses>0||(n.hasData()&&n.state!=="reloading"?this._cache.add(n.tileID,n,n.getExpiryTimeout()):(n.aborted=!0,this._abortTile(n),this._unloadTile(n))))}_dataHandler(e){let n=e.sourceDataType;e.dataType==="source"&&n==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&e.dataType==="source"&&n==="content"&&(this.reload(),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(let e in this._tiles)this._removeTile(e);this._cache.reset()}tilesIn(e,n,a){let o=[],c=this.transform;if(!c)return o;let m=a?c.getCameraQueryGeometry(e):e,g=e.map(R=>c.pointCoordinate(R,this.terrain)),y=m.map(R=>c.pointCoordinate(R,this.terrain)),b=this.getIds(),T=1/0,S=1/0,C=-1/0,E=-1/0;for(let R of y)T=Math.min(T,R.x),S=Math.min(S,R.y),C=Math.max(C,R.x),E=Math.max(E,R.y);for(let R=0;R=0&&B[1].y+Z>=0){let X=g.map(ee=>U.getTilePoint(ee)),K=y.map(ee=>U.getTilePoint(ee));o.push({tile:V,tileID:U,queryGeometry:X,cameraQueryGeometry:K,scale:$})}}return o}getVisibleCoordinates(e){let n=this.getRenderableIds(e).map(a=>this._tiles[a].tileID);for(let a of n)a.posMatrix=this.transform.calculatePosMatrix(a.toUnwrapped());return n}hasTransition(){if(this._source.hasTransition())return!0;if(Li(this._source.type)){let e=me.now();for(let n in this._tiles)if(this._tiles[n].fadeEndTime>=e)return!0}return!1}setFeatureState(e,n,a){this._state.updateState(e=e||"_geojsonTileLayer",n,a)}removeFeatureState(e,n,a){this._state.removeFeatureState(e=e||"_geojsonTileLayer",n,a)}getFeatureState(e,n){return this._state.getState(e=e||"_geojsonTileLayer",n)}setDependencies(e,n,a){let o=this._tiles[e];o&&o.setDependencies(n,a)}reloadTilesForDependencies(e,n){for(let a in this._tiles)this._tiles[a].hasDependency(e,n)&&this._reloadTile(a,"reloading");this._cache.filter(a=>!a.hasDependency(e,n))}}function ti(h,e){let n=Math.abs(2*h.wrap)-+(h.wrap<0),a=Math.abs(2*e.wrap)-+(e.wrap<0);return h.overscaledZ-e.overscaledZ||a-n||e.canonical.y-h.canonical.y||e.canonical.x-h.canonical.x}function Li(h){return h==="raster"||h==="image"||h==="video"}Be.maxOverzooming=10,Be.maxUnderzooming=3;class Ne{constructor(e,n){this.reset(e,n)}reset(e,n){this.points=e||[],this._distances=[0];for(let a=1;a0?(o-m)/g:0;return this.points[c].mult(1-y).add(this.points[n].mult(y))}}function tr(h,e){let n=!0;return h==="always"||h!=="never"&&e!=="never"||(n=!1),n}class fr{constructor(e,n,a){let o=this.boxCells=[],c=this.circleCells=[];this.xCellCount=Math.ceil(e/a),this.yCellCount=Math.ceil(n/a);for(let m=0;mthis.width||o<0||n>this.height)return[];let y=[];if(e<=0&&n<=0&&this.width<=a&&this.height<=o){if(c)return[{key:null,x1:e,y1:n,x2:a,y2:o}];for(let b=0;b0}hitTestCircle(e,n,a,o,c){let m=e-a,g=e+a,y=n-a,b=n+a;if(g<0||m>this.width||b<0||y>this.height)return!1;let T=[];return this._forEachCell(m,y,g,b,this._queryCellCircle,T,{hitTest:!0,overlapMode:o,circle:{x:e,y:n,radius:a},seenUids:{box:{},circle:{}}},c),T.length>0}_queryCell(e,n,a,o,c,m,g,y){let{seenUids:b,hitTest:T,overlapMode:S}=g,C=this.boxCells[c];if(C!==null){let R=this.bboxes;for(let V of C)if(!b.box[V]){b.box[V]=!0;let U=4*V,$=this.boxKeys[V];if(e<=R[U+2]&&n<=R[U+3]&&a>=R[U+0]&&o>=R[U+1]&&(!y||y($))&&(!T||!tr(S,$.overlapMode))&&(m.push({key:$,x1:R[U],y1:R[U+1],x2:R[U+2],y2:R[U+3]}),T))return!0}}let E=this.circleCells[c];if(E!==null){let R=this.circles;for(let V of E)if(!b.circle[V]){b.circle[V]=!0;let U=3*V,$=this.circleKeys[V];if(this._circleAndRectCollide(R[U],R[U+1],R[U+2],e,n,a,o)&&(!y||y($))&&(!T||!tr(S,$.overlapMode))){let Z=R[U],B=R[U+1],X=R[U+2];if(m.push({key:$,x1:Z-X,y1:B-X,x2:Z+X,y2:B+X}),T)return!0}}}return!1}_queryCellCircle(e,n,a,o,c,m,g,y){let{circle:b,seenUids:T,overlapMode:S}=g,C=this.boxCells[c];if(C!==null){let R=this.bboxes;for(let V of C)if(!T.box[V]){T.box[V]=!0;let U=4*V,$=this.boxKeys[V];if(this._circleAndRectCollide(b.x,b.y,b.radius,R[U+0],R[U+1],R[U+2],R[U+3])&&(!y||y($))&&!tr(S,$.overlapMode))return m.push(!0),!0}}let E=this.circleCells[c];if(E!==null){let R=this.circles;for(let V of E)if(!T.circle[V]){T.circle[V]=!0;let U=3*V,$=this.circleKeys[V];if(this._circlesCollide(R[U],R[U+1],R[U+2],b.x,b.y,b.radius)&&(!y||y($))&&!tr(S,$.overlapMode))return m.push(!0),!0}}}_forEachCell(e,n,a,o,c,m,g,y){let b=this._convertToXCellCoord(e),T=this._convertToYCellCoord(n),S=this._convertToXCellCoord(a),C=this._convertToYCellCoord(o);for(let E=b;E<=S;E++)for(let R=T;R<=C;R++)if(c.call(this,e,n,a,o,this.xCellCount*R+E,m,g,y))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,n,a,o,c,m){let g=o-e,y=c-n,b=a+m;return b*b>g*g+y*y}_circleAndRectCollide(e,n,a,o,c,m,g){let y=(m-o)/2,b=Math.abs(e-(o+y));if(b>y+a)return!1;let T=(g-c)/2,S=Math.abs(n-(c+T));if(S>T+a)return!1;if(b<=y||S<=T)return!0;let C=b-y,E=S-T;return C*C+E*E<=a*a}}function Ar(h,e,n,a,o){let c=p.H();return e?(p.K(c,c,[1/o,1/o,1]),n||p.ad(c,c,a.angle)):p.L(c,a.labelPlaneMatrix,h),c}function ir(h,e,n,a,o){if(e){let c=p.ae(h);return p.K(c,c,[o,o,1]),n||p.ad(c,c,-a.angle),c}return a.glCoordMatrix}function N(h,e,n,a){let o;a?(o=[h,e,a(h,e),1],p.af(o,o,n)):(o=[h,e,0,1],Ke(o,o,n));let c=o[3];return{point:new p.P(o[0]/c,o[1]/c),signedDistanceFromCamera:c,isOccluded:!1}}function A(h,e){return .5+h/e*.5}function P(h,e){return h.x>=-e[0]&&h.x<=e[0]&&h.y>=-e[1]&&h.y<=e[1]}function D(h,e,n,a,o,c,m,g,y,b,T,S,C,E,R){let V=a?h.textSizeData:h.iconSizeData,U=p.ag(V,n.transform.zoom),$=[256/n.width*2+1,256/n.height*2+1],Z=a?h.text.dynamicLayoutVertexArray:h.icon.dynamicLayoutVertexArray;Z.clear();let B=h.lineVertexArray,X=a?h.text.placedSymbolArray:h.icon.placedSymbolArray,K=n.transform.width/n.transform.height,ee=!1;for(let oe=0;oeMath.abs(n.x-e.x)*a?{useVertical:!0}:(h===p.ah.vertical?e.yn.x)?{needsFlipping:!0}:null}function W(h,e,n,a,o,c,m,g,y,b,T){let S=n/24,C=e.lineOffsetX*S,E=e.lineOffsetY*S,R;if(e.numGlyphs>1){let V=e.glyphStartIndex+e.numGlyphs,U=e.lineStartIndex,$=e.lineStartIndex+e.lineLength,Z=O(S,g,C,E,a,e,T,h);if(!Z)return{notEnoughRoom:!0};let B=N(Z.first.point.x,Z.first.point.y,m,h.getElevation).point,X=N(Z.last.point.x,Z.last.point.y,m,h.getElevation).point;if(o&&!a){let K=H(e.writingMode,B,X,b);if(K)return K}R=[Z.first];for(let K=e.glyphStartIndex+1;K0?B.point:function(ee,oe,he,xe,Te,fe){return Y(ee,oe,he,1,Te,fe)}(h.tileAnchorPoint,Z,U,0,c,h),K=H(e.writingMode,U,X,b);if(K)return K}let V=de(S*g.getoffsetX(e.glyphStartIndex),C,E,a,e.segment,e.lineStartIndex,e.lineStartIndex+e.lineLength,h,T);if(!V||h.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};R=[V]}for(let V of R)p.aj(y,V.point,V.angle);return{}}function Y(h,e,n,a,o,c){let m=h.add(h.sub(e)._unit()),g=o!==void 0?N(m.x,m.y,o,c.getElevation).point:ne(m.x,m.y,c).point,y=n.sub(g);return n.add(y._mult(a/y.mag()))}function q(h,e,n){let a=e.projectionCache;if(a.projections[h])return a.projections[h];let o=new p.P(e.lineVertexArray.getx(h),e.lineVertexArray.gety(h)),c=ne(o.x,o.y,e);if(c.signedDistanceFromCamera>0)return a.projections[h]=c.point,a.anyProjectionOccluded=a.anyProjectionOccluded||c.isOccluded,c.point;let m=h-n.direction;return function(g,y,b,T,S){return Y(g,y,b,T,void 0,S)}(n.distanceFromAnchor===0?e.tileAnchorPoint:new p.P(e.lineVertexArray.getx(m),e.lineVertexArray.gety(m)),o,n.previousVertex,n.absOffsetX-n.distanceFromAnchor+1,e)}function ne(h,e,n){let a=h+n.translation[0],o=e+n.translation[1],c;return!n.pitchWithMap&&n.projection.useSpecialProjectionForSymbols?(c=n.projection.projectTileCoordinates(a,o,n.unwrappedTileID,n.getElevation),c.point.x=(.5*c.point.x+.5)*n.width,c.point.y=(.5*-c.point.y+.5)*n.height):(c=N(a,o,n.labelPlaneMatrix,n.getElevation),c.isOccluded=!1),c}function le(h,e,n){return h._unit()._perp()._mult(e*n)}function te(h,e,n,a,o,c,m,g,y){if(g.projectionCache.offsets[h])return g.projectionCache.offsets[h];let b=n.add(e);if(h+y.direction=o)return g.projectionCache.offsets[h]=b,b;let T=q(h+y.direction,g,y),S=le(T.sub(n),m,y.direction),C=n.add(S),E=T.add(S);return g.projectionCache.offsets[h]=p.ak(c,b,C,E)||b,g.projectionCache.offsets[h]}function de(h,e,n,a,o,c,m,g,y){let b=a?h-e:h+e,T=b>0?1:-1,S=0;a&&(T*=-1,S=Math.PI),T<0&&(S+=Math.PI);let C,E=T>0?c+o:c+o+1;g.projectionCache.cachedAnchorPoint?C=g.projectionCache.cachedAnchorPoint:(C=ne(g.tileAnchorPoint.x,g.tileAnchorPoint.y,g).point,g.projectionCache.cachedAnchorPoint=C);let R,V,U=C,$=C,Z=0,B=0,X=Math.abs(b),K=[],ee;for(;Z+B<=X;){if(E+=T,E=m)return null;Z+=B,$=U,V=R;let xe={absOffsetX:X,direction:T,distanceFromAnchor:Z,previousVertex:$};if(U=q(E,g,xe),n===0)K.push($),ee=U.sub($);else{let Te,fe=U.sub($);Te=fe.mag()===0?le(q(E+T,g,xe).sub(U),n,T):le(fe,n,T),V||(V=$.add(Te)),R=te(E,Te,U,c,m,V,n,g,xe),K.push(V),ee=R.sub(V)}B=ee.mag()}let oe=ee._mult((X-Z)/B)._add(V||$),he=S+Math.atan2(U.y-$.y,U.x-$.x);return K.push(oe),{point:oe,angle:y?he:0,path:K}}let Ee=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function De(h,e){for(let n=0;n=1;Ue--)be.push(Ve.path[Ue]);for(let Ue=1;UeHe.signedDistanceFromCamera<=0)?[]:Ue.map(He=>He.point)}let pt=[];if(be.length>0){let Ue=be[0].clone(),He=be[0].clone();for(let ft=1;ft=fe.x&&He.x<=pe.x&&Ue.y>=fe.y&&He.y<=pe.y?[be]:He.xpe.x||He.ype.y?[]:p.al([be],fe.x,fe.y,pe.x,pe.y)}for(let Ue of pt){Me.reset(Ue,.25*Te);let He=0;He=Me.length<=.5*Te?1:Math.ceil(Me.paddedLength/Fe)+1;for(let ft=0;ftN(o.x,o.y,a,n.getElevation))}queryRenderedSymbols(e){if(e.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};let n=[],a=1/0,o=1/0,c=-1/0,m=-1/0;for(let T of e){let S=new p.P(T.x+je,T.y+je);a=Math.min(a,S.x),o=Math.min(o,S.y),c=Math.max(c,S.x),m=Math.max(m,S.y),n.push(S)}let g=this.grid.query(a,o,c,m).concat(this.ignoredGrid.query(a,o,c,m)),y={},b={};for(let T of g){let S=T.key;if(y[S.bucketInstanceId]===void 0&&(y[S.bucketInstanceId]={}),y[S.bucketInstanceId][S.featureIndex])continue;let C=[new p.P(T.x1,T.y1),new p.P(T.x2,T.y1),new p.P(T.x2,T.y2),new p.P(T.x1,T.y2)];p.am(n,C)&&(y[S.bucketInstanceId][S.featureIndex]=!0,b[S.bucketInstanceId]===void 0&&(b[S.bucketInstanceId]=[]),b[S.bucketInstanceId].push(S.featureIndex))}return b}insertCollisionBox(e,n,a,o,c,m){(a?this.ignoredGrid:this.grid).insert({bucketInstanceId:o,featureIndex:c,collisionGroupID:m,overlapMode:n},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,n,a,o,c,m){let g=a?this.ignoredGrid:this.grid,y={bucketInstanceId:o,featureIndex:c,collisionGroupID:m,overlapMode:n};for(let b=0;b=this.screenRightBoundary||othis.screenBottomBoundary}isInsideGrid(e,n,a,o){return a>=0&&e=0&&nthis.projectAndGetPerspectiveRatio(a,Te.x,Te.y,o,b));he=xe.some(Te=>!Te.isOccluded),oe=xe.map(Te=>Te.point)}else he=!0;return{box:p.ao(oe),allPointsOccluded:!he}}}function Ge(h,e,n){return e*(p.X/(h.tileSize*Math.pow(2,n-h.tileID.overscaledZ)))}class Pt{constructor(e,n,a,o){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?n:-n))):o&&a?1:0,this.placed=a}isHidden(){return this.opacity===0&&!this.placed}}class xt{constructor(e,n,a,o,c){this.text=new Pt(e?e.text:null,n,a,c),this.icon=new Pt(e?e.icon:null,n,o,c)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class qe{constructor(e,n,a){this.text=e,this.icon=n,this.skipFade=a}}class rt{constructor(){this.invProjMatrix=p.H(),this.viewportMatrix=p.H(),this.circles=[]}}class gt{constructor(e,n,a,o,c){this.bucketInstanceId=e,this.featureIndex=n,this.sourceLayerIndex=a,this.bucketIndex=o,this.tileID=c}}class kt{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){let n=++this.maxGroupID;this.collisionGroups[e]={ID:n,predicate:a=>a.collisionGroupID===n}}return this.collisionGroups[e]}}function Lt(h,e,n,a,o){let{horizontalAlign:c,verticalAlign:m}=p.au(h);return new p.P(-(c-.5)*e+a[0]*o,-(m-.5)*n+a[1]*o)}class Wt{constructor(e,n,a,o,c,m){this.transform=e.clone(),this.terrain=a,this.collisionIndex=new Je(this.transform,n),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=o,this.retainedQueryData={},this.collisionGroups=new kt(c),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=m,m&&(m.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){let n=this.terrain;return n?(a,o)=>n.getElevation(e,a,o):null}getBucketParts(e,n,a,o){let c=a.getBucket(n),m=a.latestFeatureIndex;if(!c||!m||n.id!==c.layerIds[0])return;let g=a.collisionBoxArray,y=c.layers[0].layout,b=c.layers[0].paint,T=Math.pow(2,this.transform.zoom-a.tileID.overscaledZ),S=a.tileSize/p.X,C=a.tileID.toUnwrapped(),E=this.transform.calculatePosMatrix(C),R=y.get("text-pitch-alignment")==="map",V=y.get("text-rotation-alignment")==="map",U=Ge(a,1,this.transform.zoom),$=this.collisionIndex.mapProjection.translatePosition(this.transform,a,b.get("text-translate"),b.get("text-translate-anchor")),Z=this.collisionIndex.mapProjection.translatePosition(this.transform,a,b.get("icon-translate"),b.get("icon-translate-anchor")),B=Ar(E,R,V,this.transform,U),X=null;if(R){let ee=ir(E,R,V,this.transform,U);X=p.L([],this.transform.labelPlaneMatrix,ee)}this.retainedQueryData[c.bucketInstanceId]=new gt(c.bucketInstanceId,m,c.sourceLayerIndex,c.index,a.tileID);let K={bucket:c,layout:y,translationText:$,translationIcon:Z,posMatrix:E,unwrappedTileID:C,textLabelPlaneMatrix:B,labelToScreenMatrix:X,scale:T,textPixelRatio:S,holdingForFade:a.holdingForFade(),collisionBoxArray:g,partiallyEvaluatedTextSize:p.ag(c.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(c.sourceID)};if(o)for(let ee of c.sortKeyRanges){let{sortKey:oe,symbolInstanceStart:he,symbolInstanceEnd:xe}=ee;e.push({sortKey:oe,symbolInstanceStart:he,symbolInstanceEnd:xe,parameters:K})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:c.symbolInstances.length,parameters:K})}attemptAnchorPlacement(e,n,a,o,c,m,g,y,b,T,S,C,E,R,V,U,$,Z,B){let X=p.aq[e.textAnchor],K=[e.textOffset0,e.textOffset1],ee=Lt(X,a,o,K,c),oe=this.collisionIndex.placeCollisionBox(n,C,y,b,T,g,m,U,S.predicate,B,ee);if((!Z||this.collisionIndex.placeCollisionBox(Z,C,y,b,T,g,m,$,S.predicate,B,ee).placeable)&&oe.placeable){let he;if(this.prevPlacement&&this.prevPlacement.variableOffsets[E.crossTileID]&&this.prevPlacement.placements[E.crossTileID]&&this.prevPlacement.placements[E.crossTileID].text&&(he=this.prevPlacement.variableOffsets[E.crossTileID].anchor),E.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[E.crossTileID]={textOffset:K,width:a,height:o,anchor:X,textBoxScale:c,prevAnchor:he},this.markUsedJustification(R,X,E,V),R.allowVerticalPlacement&&(this.markUsedOrientation(R,V,E),this.placedOrientations[E.crossTileID]=V),{shift:ee,placedGlyphBoxes:oe}}}placeLayerBucketPart(e,n,a){let{bucket:o,layout:c,translationText:m,translationIcon:g,posMatrix:y,unwrappedTileID:b,textLabelPlaneMatrix:T,labelToScreenMatrix:S,textPixelRatio:C,holdingForFade:E,collisionBoxArray:R,partiallyEvaluatedTextSize:V,collisionGroup:U}=e.parameters,$=c.get("text-optional"),Z=c.get("icon-optional"),B=p.ar(c,"text-overlap","text-allow-overlap"),X=B==="always",K=p.ar(c,"icon-overlap","icon-allow-overlap"),ee=K==="always",oe=c.get("text-rotation-alignment")==="map",he=c.get("text-pitch-alignment")==="map",xe=c.get("icon-text-fit")!=="none",Te=c.get("symbol-z-order")==="viewport-y",fe=X&&(ee||!o.hasIconData()||Z),pe=ee&&(X||!o.hasTextData()||$);!o.collisionArrays&&R&&o.deserializeCollisionBoxes(R);let Me=this._getTerrainElevationFunc(this.retainedQueryData[o.bucketInstanceId].tileID),Ve=(ge,be,Fe)=>{var pt,Ue;if(n[ge.crossTileID])return;if(E)return void(this.placements[ge.crossTileID]=new qe(!1,!1,!1));let He=!1,ft=!1,Vt=!0,Ni=null,mt={box:null,placeable:!1,offscreen:null},ni={box:null,placeable:!1,offscreen:null},Kt=null,Nt=null,Jt=null,ar=0,Ln=0,sa=0;be.textFeatureIndex?ar=be.textFeatureIndex:ge.useRuntimeCollisionCircles&&(ar=ge.featureIndex),be.verticalTextFeatureIndex&&(Ln=be.verticalTextFeatureIndex);let Rn=be.textBox;if(Rn){let Ai=Rt=>{let jt=p.ah.horizontal;if(o.allowVerticalPlacement&&!Rt&&this.prevPlacement){let gi=this.prevPlacement.placedOrientations[ge.crossTileID];gi&&(this.placedOrientations[ge.crossTileID]=gi,jt=gi,this.markUsedOrientation(o,jt,ge))}return jt},Mi=(Rt,jt)=>{if(o.allowVerticalPlacement&&ge.numVerticalGlyphVertices>0&&be.verticalTextBox){for(let gi of o.writingModes)if(gi===p.ah.vertical?(mt=jt(),ni=mt):mt=Rt(),mt&&mt.placeable)break}else mt=Rt()},kr=ge.textAnchorOffsetStartIndex,ji=ge.textAnchorOffsetEndIndex;if(ji===kr){let Rt=(jt,gi)=>{let We=this.collisionIndex.placeCollisionBox(jt,B,C,y,b,he,oe,m,U.predicate,Me);return We&&We.placeable&&(this.markUsedOrientation(o,gi,ge),this.placedOrientations[ge.crossTileID]=gi),We};Mi(()=>Rt(Rn,p.ah.horizontal),()=>{let jt=be.verticalTextBox;return o.allowVerticalPlacement&&ge.numVerticalGlyphVertices>0&&jt?Rt(jt,p.ah.vertical):{box:null,offscreen:null}}),Ai(mt&&mt.placeable)}else{let Rt=p.aq[(Ue=(pt=this.prevPlacement)===null||pt===void 0?void 0:pt.variableOffsets[ge.crossTileID])===null||Ue===void 0?void 0:Ue.anchor],jt=(We,en,Bn)=>{let Fn=We.x2-We.x1,ul=We.y2-We.y1,oc=ge.textBoxScale,dl=xe&&K==="never"?en:null,zr=null,pl=B==="never"?1:2,oa="never";Rt&&pl++;for(let gs=0;gsjt(Rn,be.iconBox,p.ah.horizontal),()=>{let We=be.verticalTextBox;return o.allowVerticalPlacement&&(!mt||!mt.placeable)&&ge.numVerticalGlyphVertices>0&&We?jt(We,be.verticalIconBox,p.ah.vertical):{box:null,occluded:!0,offscreen:null}}),mt&&(He=mt.placeable,Vt=mt.offscreen);let gi=Ai(mt&&mt.placeable);if(!He&&this.prevPlacement){let We=this.prevPlacement.variableOffsets[ge.crossTileID];We&&(this.variableOffsets[ge.crossTileID]=We,this.markUsedJustification(o,We.anchor,ge,gi))}}}if(Kt=mt,He=Kt&&Kt.placeable,Vt=Kt&&Kt.offscreen,ge.useRuntimeCollisionCircles){let Ai=o.text.placedSymbolArray.get(ge.centerJustifiedTextSymbolIndex),Mi=p.ai(o.textSizeData,V,Ai),kr=c.get("text-padding");Nt=this.collisionIndex.placeCollisionCircles(B,Ai,o.lineVertexArray,o.glyphOffsetArray,Mi,y,b,T,S,a,he,U.predicate,ge.collisionCircleDiameter,kr,m,Me),Nt.circles.length&&Nt.collisionDetected&&!a&&p.w("Collisions detected, but collision boxes are not shown"),He=X||Nt.circles.length>0&&!Nt.collisionDetected,Vt=Vt&&Nt.offscreen}if(be.iconFeatureIndex&&(sa=be.iconFeatureIndex),be.iconBox){let Ai=Mi=>this.collisionIndex.placeCollisionBox(Mi,K,C,y,b,he,oe,g,U.predicate,Me,xe&&Ni?Ni:void 0);ni&&ni.placeable&&be.verticalIconBox?(Jt=Ai(be.verticalIconBox),ft=Jt.placeable):(Jt=Ai(be.iconBox),ft=Jt.placeable),Vt=Vt&&Jt.offscreen}let Pi=$||ge.numHorizontalGlyphVertices===0&&ge.numVerticalGlyphVertices===0,aa=Z||ge.numIconVertices===0;Pi||aa?aa?Pi||(ft=ft&&He):He=ft&&He:ft=He=ft&&He;let po=ft&&Jt.placeable;if(He&&Kt.placeable&&this.collisionIndex.insertCollisionBox(Kt.box,B,c.get("text-ignore-placement"),o.bucketInstanceId,ni&&ni.placeable&&Ln?Ln:ar,U.ID),po&&this.collisionIndex.insertCollisionBox(Jt.box,K,c.get("icon-ignore-placement"),o.bucketInstanceId,sa,U.ID),Nt&&He&&this.collisionIndex.insertCollisionCircles(Nt.circles,B,c.get("text-ignore-placement"),o.bucketInstanceId,ar,U.ID),a&&this.storeCollisionData(o.bucketInstanceId,Fe,be,Kt,Jt,Nt),ge.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");if(o.bucketInstanceId===0)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[ge.crossTileID]=new qe(He||fe,ft||pe,Vt||o.justReloaded),n[ge.crossTileID]=!0};if(Te){if(e.symbolInstanceStart!==0)throw new Error("bucket.bucketInstanceId should be 0");let ge=o.getSortedSymbolIndexes(this.transform.angle);for(let be=ge.length-1;be>=0;--be){let Fe=ge[be];Ve(o.symbolInstances.get(Fe),o.collisionArrays[Fe],Fe)}}else for(let ge=e.symbolInstanceStart;ge=0&&(e.text.placedSymbolArray.get(g).crossTileID=c>=0&&g!==c?0:a.crossTileID)}markUsedOrientation(e,n,a){let o=n===p.ah.horizontal||n===p.ah.horizontalOnly?n:0,c=n===p.ah.vertical?n:0,m=[a.leftJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.rightJustifiedTextSymbolIndex];for(let g of m)e.text.placedSymbolArray.get(g).placedOrientation=o;a.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(a.verticalPlacedTextSymbolIndex).placedOrientation=c)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;let n=this.prevPlacement,a=!1;this.prevZoomAdjustment=n?n.zoomAdjustment(this.transform.zoom):0;let o=n?n.symbolFadeChange(e):1,c=n?n.opacities:{},m=n?n.variableOffsets:{},g=n?n.placedOrientations:{};for(let y in this.placements){let b=this.placements[y],T=c[y];T?(this.opacities[y]=new xt(T,o,b.text,b.icon),a=a||b.text!==T.text.placed||b.icon!==T.icon.placed):(this.opacities[y]=new xt(null,o,b.text,b.icon,b.skipFade),a=a||b.text||b.icon)}for(let y in c){let b=c[y];if(!this.opacities[y]){let T=new xt(b,o,!1,!1);T.isHidden()||(this.opacities[y]=T,a=a||b.text.placed||b.icon.placed)}}for(let y in m)this.variableOffsets[y]||!this.opacities[y]||this.opacities[y].isHidden()||(this.variableOffsets[y]=m[y]);for(let y in g)this.placedOrientations[y]||!this.opacities[y]||this.opacities[y].isHidden()||(this.placedOrientations[y]=g[y]);if(n&&n.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");a?this.lastPlacementChangeTime=e:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=n?n.lastPlacementChangeTime:e)}updateLayerOpacities(e,n){let a={};for(let o of n){let c=o.getBucket(e);c&&o.latestFeatureIndex&&e.id===c.layerIds[0]&&this.updateBucketOpacities(c,o.tileID,a,o.collisionBoxArray)}}updateBucketOpacities(e,n,a,o){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();let c=e.layers[0],m=c.layout,g=new xt(null,0,!1,!1,!0),y=m.get("text-allow-overlap"),b=m.get("icon-allow-overlap"),T=c._unevaluatedLayout.hasValue("text-variable-anchor")||c._unevaluatedLayout.hasValue("text-variable-anchor-offset"),S=m.get("text-rotation-alignment")==="map",C=m.get("text-pitch-alignment")==="map",E=m.get("icon-text-fit")!=="none",R=new xt(null,0,y&&(b||!e.hasIconData()||m.get("icon-optional")),b&&(y||!e.hasTextData()||m.get("text-optional")),!0);!e.collisionArrays&&o&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(o);let V=($,Z,B)=>{for(let X=0;X0,he=this.placedOrientations[Z.crossTileID],xe=he===p.ah.vertical,Te=he===p.ah.horizontal||he===p.ah.horizontalOnly;if(B>0||X>0){let pe=fi(ee.text);V(e.text,B,xe?pn:pe),V(e.text,X,Te?pn:pe);let Me=ee.text.isHidden();[Z.rightJustifiedTextSymbolIndex,Z.centerJustifiedTextSymbolIndex,Z.leftJustifiedTextSymbolIndex].forEach(be=>{be>=0&&(e.text.placedSymbolArray.get(be).hidden=Me||xe?1:0)}),Z.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(Z.verticalPlacedTextSymbolIndex).hidden=Me||Te?1:0);let Ve=this.variableOffsets[Z.crossTileID];Ve&&this.markUsedJustification(e,Ve.anchor,Z,he);let ge=this.placedOrientations[Z.crossTileID];ge&&(this.markUsedJustification(e,"left",Z,ge),this.markUsedOrientation(e,ge,Z))}if(oe){let pe=fi(ee.icon),Me=!(E&&Z.verticalPlacedIconSymbolIndex&&xe);Z.placedIconSymbolIndex>=0&&(V(e.icon,Z.numIconVertices,Me?pe:pn),e.icon.placedSymbolArray.get(Z.placedIconSymbolIndex).hidden=ee.icon.isHidden()),Z.verticalPlacedIconSymbolIndex>=0&&(V(e.icon,Z.numVerticalIconVertices,Me?pn:pe),e.icon.placedSymbolArray.get(Z.verticalPlacedIconSymbolIndex).hidden=ee.icon.isHidden())}let fe=U&&U.has($)?U.get($):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){let pe=e.collisionArrays[$];if(pe){let Me=new p.P(0,0);if(pe.textBox||pe.verticalTextBox){let Ve=!0;if(T){let ge=this.variableOffsets[K];ge?(Me=Lt(ge.anchor,ge.width,ge.height,ge.textOffset,ge.textBoxScale),S&&Me._rotate(C?this.transform.angle:-this.transform.angle)):Ve=!1}if(pe.textBox||pe.verticalTextBox){let ge;pe.textBox&&(ge=xe),pe.verticalTextBox&&(ge=Te),dn(e.textCollisionBox.collisionVertexArray,ee.text.placed,!Ve||ge,fe.text,Me.x,Me.y)}}if(pe.iconBox||pe.verticalIconBox){let Ve=!!(!Te&&pe.verticalIconBox),ge;pe.iconBox&&(ge=Ve),pe.verticalIconBox&&(ge=!Ve),dn(e.iconCollisionBox.collisionVertexArray,ee.icon.placed,ge,fe.icon,E?Me.x:0,E?Me.y:0)}}}}if(e.sortFeatures(this.transform.angle),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);if(e.bucketInstanceId in this.collisionCircleArrays){let $=this.collisionCircleArrays[e.bucketInstanceId];e.placementInvProjMatrix=$.invProjMatrix,e.placementViewportMatrix=$.viewportMatrix,e.collisionCircleArray=$.circles,delete this.collisionCircleArrays[e.bucketInstanceId]}}symbolFadeChange(e){return this.fadeDuration===0?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0}}function dn(h,e,n,a,o,c){a&&a.length!==0||(a=[0,0,0,0]);let m=a[0]-je,g=a[1]-je,y=a[2]-je,b=a[3]-je;h.emplaceBack(e?1:0,n?1:0,o||0,c||0,m,g),h.emplaceBack(e?1:0,n?1:0,o||0,c||0,y,g),h.emplaceBack(e?1:0,n?1:0,o||0,c||0,y,b),h.emplaceBack(e?1:0,n?1:0,o||0,c||0,m,b)}let nt=Math.pow(2,25),Ta=Math.pow(2,24),Sa=Math.pow(2,17),di=Math.pow(2,16),pi=Math.pow(2,9),Rl=Math.pow(2,8),wi=Math.pow(2,1);function fi(h){if(h.opacity===0&&!h.placed)return 0;if(h.opacity===1&&h.placed)return 4294967295;let e=h.placed?1:0,n=Math.floor(127*h.opacity);return n*nt+e*Ta+n*Sa+e*di+n*pi+e*Rl+n*wi+e}let pn=0;function Ur(){return{isOccluded:(h,e,n)=>!1,getPitchedTextCorrection:(h,e,n)=>1,get useSpecialProjectionForSymbols(){return!1},projectTileCoordinates(h,e,n,a){throw new Error("Not implemented.")},translatePosition:(h,e,n,a)=>function(o,c,m,g,y=!1){if(!m[0]&&!m[1])return[0,0];let b=y?g==="map"?o.angle:0:g==="viewport"?-o.angle:0;if(b){let T=Math.sin(b),S=Math.cos(b);m=[m[0]*S-m[1]*T,m[0]*T+m[1]*S]}return[y?m[0]:Ge(c,m[0],o.zoom),y?m[1]:Ge(c,m[1],o.zoom)]}(h,e,n,a),getCircleRadiusCorrection:h=>1}}class At{constructor(e){this._sortAcrossTiles=e.layout.get("symbol-z-order")!=="viewport-y"&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,n,a,o,c){let m=this._bucketParts;for(;this._currentTileIndexg.sortKey-y.sortKey));this._currentPartIndex!this._forceFullPlacement&&me.now()-o>2;for(;this._currentPlacementIndex>=0;){let m=n[e[this._currentPlacementIndex]],g=this.placement.collisionIndex.transform.zoom;if(m.type==="symbol"&&(!m.minzoom||m.minzoom<=g)&&(!m.maxzoom||m.maxzoom>g)){if(this._inProgressLayer||(this._inProgressLayer=new At(m)),this._inProgressLayer.continuePlacement(a[m.source],this.placement,this._showCollisionBoxes,m,c))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}let Ri=512/p.X/2;class St{constructor(e,n,a){this.tileID=e,this.bucketInstanceId=a,this._symbolsByKey={};let o=new Map;for(let c=0;c({x:Math.floor(y.anchorX*Ri),y:Math.floor(y.anchorY*Ri)})),crossTileIDs:m.map(y=>y.crossTileID)};if(g.positions.length>128){let y=new p.av(g.positions.length,16,Uint16Array);for(let{x:b,y:T}of g.positions)y.add(b,T);y.finish(),delete g.positions,g.index=y}this._symbolsByKey[c]=g}}getScaledCoordinates(e,n){let{x:a,y:o,z:c}=this.tileID.canonical,{x:m,y:g,z:y}=n.canonical,b=Ri/Math.pow(2,y-c),T=(g*p.X+e.anchorY)*b,S=o*p.X*Ri;return{x:Math.floor((m*p.X+e.anchorX)*b-a*p.X*Ri),y:Math.floor(T-S)}}findMatches(e,n,a){let o=this.tileID.canonical.ze)}}class Ms{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Bi{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){let n=Math.round((e-this.lng)/360);if(n!==0)for(let a in this.indexes){let o=this.indexes[a],c={};for(let m in o){let g=o[m];g.tileID=g.tileID.unwrapTo(g.tileID.wrap+n),c[g.tileID.key]=g}this.indexes[a]=c}this.lng=e}addBucket(e,n,a){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===n.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let c=0;ce.overscaledZ)for(let g in m){let y=m[g];y.tileID.isChildOf(e)&&y.findMatches(n.symbolInstances,e,o)}else{let g=m[e.scaledTo(Number(c)).key];g&&g.findMatches(n.symbolInstances,e,o)}}for(let c=0;c{n[a]=!0});for(let a in this.layerIndexes)n[a]||delete this.layerIndexes[a]}}let Fi=(h,e)=>p.t(h,e&&e.filter(n=>n.identifier!=="source.canvas")),Bl=p.aw();class Cs extends p.E{constructor(e,n={}){super(),this._rtlPluginLoaded=()=>{for(let a in this.sourceCaches){let o=this.sourceCaches[a].getSource().type;o!=="vector"&&o!=="geojson"||this.sourceCaches[a].reload()}},this.map=e,this.dispatcher=new Nr(Vr(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",(a,o)=>this.getGlyphs(a,o)),this.dispatcher.registerMessageHandler("GI",(a,o)=>this.getImages(a,o)),this.imageManager=new Ft,this.imageManager.setEventedParent(this),this.glyphManager=new Ji(e._requestManager,n.localIdeographFontFamily),this.lineAtlas=new ln(256,512),this.crossTileSymbolIndex=new Ia,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new p.ax,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("SR",p.ay()),er().on(ue,this._rtlPluginLoaded),this.on("data",a=>{if(a.dataType!=="source"||a.sourceDataType!=="metadata")return;let o=this.sourceCaches[a.sourceId];if(!o)return;let c=o.getSource();if(c&&c.vectorLayerIds)for(let m in this._layers){let g=this._layers[m];g.source===c.id&&this._validateLayer(g)}})}loadURL(e,n={},a){this.fire(new p.k("dataloading",{dataType:"style"})),n.validate=typeof n.validate!="boolean"||n.validate;let o=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;let c=this._loadStyleRequest;p.h(o,this._loadStyleRequest).then(m=>{this._loadStyleRequest=null,this._load(m.data,n,a)}).catch(m=>{this._loadStyleRequest=null,m&&!c.signal.aborted&&this.fire(new p.j(m))})}loadJSON(e,n={},a){this.fire(new p.k("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,me.frameAsync(this._frameRequest).then(()=>{this._frameRequest=null,n.validate=n.validate!==!1,this._load(e,n,a)}).catch(()=>{})}loadEmpty(){this.fire(new p.k("dataloading",{dataType:"style"})),this._load(Bl,{validate:!1})}_load(e,n,a){var o;let c=n.transformStyle?n.transformStyle(a,e):e;if(!n.validate||!Fi(this,p.u(c))){this._loaded=!0,this.stylesheet=c;for(let m in c.sources)this.addSource(m,c.sources[m],{validate:!1});c.sprite?this._loadSprite(c.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(c.glyphs),this._createLayers(),this.light=new ur(this.stylesheet.light),this.sky=new Ei(this.stylesheet.sky),this.map.setTerrain((o=this.stylesheet.terrain)!==null&&o!==void 0?o:null),this.fire(new p.k("data",{dataType:"style"})),this.fire(new p.k("style.load"))}}_createLayers(){let e=p.az(this.stylesheet.layers);this.dispatcher.broadcast("SL",e),this._order=e.map(n=>n.id),this._layers={},this._serializedLayers=null;for(let n of e){let a=p.aA(n);a.setEventedParent(this,{layer:{id:n.id}}),this._layers[n.id]=a}}_loadSprite(e,n=!1,a=void 0){let o;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(c,m,g,y){return p._(this,void 0,void 0,function*(){let b=Ki(c),T=g>1?"@2x":"",S={},C={};for(let{id:E,url:R}of b){let V=m.transformRequest(Hn(R,T,".json"),"SpriteJSON");S[E]=p.h(V,y);let U=m.transformRequest(Hn(R,T,".png"),"SpriteImage");C[E]=hi.getImage(U,y)}return yield Promise.all([...Object.values(S),...Object.values(C)]),function(E,R){return p._(this,void 0,void 0,function*(){let V={};for(let U in E){V[U]={};let $=me.getImageCanvasContext((yield R[U]).data),Z=(yield E[U]).data;for(let B in Z){let{width:X,height:K,x:ee,y:oe,sdf:he,pixelRatio:xe,stretchX:Te,stretchY:fe,content:pe,textFitWidth:Me,textFitHeight:Ve}=Z[B];V[U][B]={data:null,pixelRatio:xe,sdf:he,stretchX:Te,stretchY:fe,content:pe,textFitWidth:Me,textFitHeight:Ve,spriteData:{width:X,height:K,x:ee,y:oe,context:$}}}}return V})}(S,C)})}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then(c=>{if(this._spriteRequest=null,c)for(let m in c){this._spritesImagesIds[m]=[];let g=this._spritesImagesIds[m]?this._spritesImagesIds[m].filter(y=>!(y in c)):[];for(let y of g)this.imageManager.removeImage(y),this._changedImages[y]=!0;for(let y in c[m]){let b=m==="default"?y:`${m}:${y}`;this._spritesImagesIds[m].push(b),b in this.imageManager.images?this.imageManager.updateImage(b,c[m][y],!1):this.imageManager.addImage(b,c[m][y]),n&&(this._changedImages[b]=!0)}}}).catch(c=>{this._spriteRequest=null,o=c,this.fire(new p.j(o))}).finally(()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new p.k("data",{dataType:"style"})),a&&a(o)})}_unloadSprite(){for(let e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new p.k("data",{dataType:"style"}))}_validateLayer(e){let n=this.sourceCaches[e.source];if(!n)return;let a=e.sourceLayer;if(!a)return;let o=n.getSource();(o.type==="geojson"||o.vectorLayerIds&&o.vectorLayerIds.indexOf(a)===-1)&&this.fire(new p.j(new Error(`Source layer "${a}" does not exist on source "${o.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(let e in this.sourceCaches)if(!this.sourceCaches[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(e,n=!1){let a=this._serializedAllLayers();if(!e||e.length===0)return Object.values(n?p.aB(a):a);let o=[];for(let c of e)if(a[c]){let m=n?p.aB(a[c]):a[c];o.push(m)}return o}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};let n=Object.keys(this._layers);for(let a of n){let o=this._layers[a];o.type!=="custom"&&(e[a]=o.serialize())}return e}hasTransitions(){if(this.light&&this.light.hasTransition()||this.sky&&this.sky.hasTransition())return!0;for(let e in this.sourceCaches)if(this.sourceCaches[e].hasTransition())return!0;for(let e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;let n=this._changed;if(n){let o=Object.keys(this._updatedLayers),c=Object.keys(this._removedLayers);(o.length||c.length)&&this._updateWorkerLayers(o,c);for(let m in this._updatedSources){let g=this._updatedSources[m];if(g==="reload")this._reloadSource(m);else{if(g!=="clear")throw new Error(`Invalid action ${g}`);this._clearSource(m)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(let m in this._updatedPaintProps)this._layers[m].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}let a={};for(let o in this.sourceCaches){let c=this.sourceCaches[o];a[o]=c.used,c.used=!1}for(let o of this._order){let c=this._layers[o];c.recalculate(e,this._availableImages),!c.isHidden(e.zoom)&&c.source&&(this.sourceCaches[c.source].used=!0)}for(let o in a){let c=this.sourceCaches[o];!!a[o]!=!!c.used&&c.fire(new p.k("data",{sourceDataType:"visibility",dataType:"source",sourceId:o}))}this.light.recalculate(e),this.sky.recalculate(e),this.z=e.zoom,n&&this.fire(new p.k("data",{dataType:"style"}))}_updateTilesForChangedImages(){let e=Object.keys(this._changedImages);if(e.length){for(let n in this.sourceCaches)this.sourceCaches[n].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(let e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,n){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:n})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,n={}){var a;this._checkLoaded();let o=this.serialize();if(e=n.transformStyle?n.transformStyle(o,e):e,((a=n.validate)===null||a===void 0||a)&&Fi(this,p.u(e)))return!1;(e=p.aB(e)).layers=p.az(e.layers);let c=p.aC(o,e),m=this._getOperationsToPerform(c);if(m.unimplemented.length>0)throw new Error(`Unimplemented: ${m.unimplemented.join(", ")}.`);if(m.operations.length===0)return!1;for(let g of m.operations)g();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){let n=[],a=[];for(let o of e)switch(o.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":continue;case"addLayer":n.push(()=>this.addLayer.apply(this,o.args));break;case"removeLayer":n.push(()=>this.removeLayer.apply(this,o.args));break;case"setPaintProperty":n.push(()=>this.setPaintProperty.apply(this,o.args));break;case"setLayoutProperty":n.push(()=>this.setLayoutProperty.apply(this,o.args));break;case"setFilter":n.push(()=>this.setFilter.apply(this,o.args));break;case"addSource":n.push(()=>this.addSource.apply(this,o.args));break;case"removeSource":n.push(()=>this.removeSource.apply(this,o.args));break;case"setLayerZoomRange":n.push(()=>this.setLayerZoomRange.apply(this,o.args));break;case"setLight":n.push(()=>this.setLight.apply(this,o.args));break;case"setGeoJSONSourceData":n.push(()=>this.setGeoJSONSourceData.apply(this,o.args));break;case"setGlyphs":n.push(()=>this.setGlyphs.apply(this,o.args));break;case"setSprite":n.push(()=>this.setSprite.apply(this,o.args));break;case"setSky":n.push(()=>this.setSky.apply(this,o.args));break;case"setTerrain":n.push(()=>this.map.setTerrain.apply(this,o.args));break;case"setTransition":n.push(()=>{});break;default:a.push(o.command)}return{operations:n,unimplemented:a}}addImage(e,n){if(this.getImage(e))return this.fire(new p.j(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,n),this._afterImageUpdated(e)}updateImage(e,n){this.imageManager.updateImage(e,n)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new p.j(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new p.k("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,n,a={}){if(this._checkLoaded(),this.sourceCaches[e]!==void 0)throw new Error(`Source "${e}" 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(p.u.source,`sources.${e}`,n,null,a))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);let o=this.sourceCaches[e]=new Be(e,n,this.dispatcher);o.style=this,o.setEventedParent(this,()=>({isSourceLoaded:o.loaded(),source:o.serialize(),sourceId:e})),o.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),this.sourceCaches[e]===void 0)throw new Error("There is no source with this ID");for(let a in this._layers)if(this._layers[a].source===e)return this.fire(new p.j(new Error(`Source "${e}" cannot be removed while layer "${a}" is using it.`)));let n=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],n.fire(new p.k("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),n.setEventedParent(null),n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,n){if(this._checkLoaded(),this.sourceCaches[e]===void 0)throw new Error(`There is no source with this ID=${e}`);let a=this.sourceCaches[e].getSource();if(a.type!=="geojson")throw new Error(`geojsonSource.type is ${a.type}, which is !== 'geojson`);a.setData(n),this._changed=!0}getSource(e){return this.sourceCaches[e]&&this.sourceCaches[e].getSource()}addLayer(e,n,a={}){this._checkLoaded();let o=e.id;if(this.getLayer(o))return void this.fire(new p.j(new Error(`Layer "${o}" already exists on this map.`)));let c;if(e.type==="custom"){if(Fi(this,p.aD(e)))return;c=p.aA(e)}else{if("source"in e&&typeof e.source=="object"&&(this.addSource(o,e.source),e=p.aB(e),e=p.e(e,{source:o})),this._validate(p.u.layer,`layers.${o}`,e,{arrayIndex:-1},a))return;c=p.aA(e),this._validateLayer(c),c.setEventedParent(this,{layer:{id:o}})}let m=n?this._order.indexOf(n):this._order.length;if(n&&m===-1)this.fire(new p.j(new Error(`Cannot add layer "${o}" before non-existing layer "${n}".`)));else{if(this._order.splice(m,0,o),this._layerOrderChanged=!0,this._layers[o]=c,this._removedLayers[o]&&c.source&&c.type!=="custom"){let g=this._removedLayers[o];delete this._removedLayers[o],g.type!==c.type?this._updatedSources[c.source]="clear":(this._updatedSources[c.source]="reload",this.sourceCaches[c.source].pause())}this._updateLayer(c),c.onAdd&&c.onAdd(this.map)}}moveLayer(e,n){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new p.j(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===n)return;let a=this._order.indexOf(e);this._order.splice(a,1);let o=n?this._order.indexOf(n):this._order.length;n&&o===-1?this.fire(new p.j(new Error(`Cannot move layer "${e}" before non-existing layer "${n}".`))):(this._order.splice(o,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();let n=this._layers[e];if(!n)return void this.fire(new p.j(new Error(`Cannot remove non-existing layer "${e}".`)));n.setEventedParent(null);let a=this._order.indexOf(e);this._order.splice(a,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=n,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],n.onRemove&&n.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,n,a){this._checkLoaded();let o=this.getLayer(e);o?o.minzoom===n&&o.maxzoom===a||(n!=null&&(o.minzoom=n),a!=null&&(o.maxzoom=a),this._updateLayer(o)):this.fire(new p.j(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,n,a={}){this._checkLoaded();let o=this.getLayer(e);if(o){if(!p.aE(o.filter,n))return n==null?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(p.u.filter,`layers.${o.id}.filter`,n,null,a)||(o.filter=p.aB(n),this._updateLayer(o)))}else this.fire(new p.j(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return p.aB(this.getLayer(e).filter)}setLayoutProperty(e,n,a,o={}){this._checkLoaded();let c=this.getLayer(e);c?p.aE(c.getLayoutProperty(n),a)||(c.setLayoutProperty(n,a,o),this._updateLayer(c)):this.fire(new p.j(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,n){let a=this.getLayer(e);if(a)return a.getLayoutProperty(n);this.fire(new p.j(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,n,a,o={}){this._checkLoaded();let c=this.getLayer(e);c?p.aE(c.getPaintProperty(n),a)||(c.setPaintProperty(n,a,o)&&this._updateLayer(c),this._changed=!0,this._updatedPaintProps[e]=!0,this._serializedLayers=null):this.fire(new p.j(new Error(`Cannot style non-existing layer "${e}".`)))}getPaintProperty(e,n){return this.getLayer(e).getPaintProperty(n)}setFeatureState(e,n){this._checkLoaded();let a=e.source,o=e.sourceLayer,c=this.sourceCaches[a];if(c===void 0)return void this.fire(new p.j(new Error(`The source '${a}' does not exist in the map's style.`)));let m=c.getSource().type;m==="geojson"&&o?this.fire(new p.j(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):m!=="vector"||o?(e.id===void 0&&this.fire(new p.j(new Error("The feature id parameter must be provided."))),c.setFeatureState(o,e.id,n)):this.fire(new p.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,n){this._checkLoaded();let a=e.source,o=this.sourceCaches[a];if(o===void 0)return void this.fire(new p.j(new Error(`The source '${a}' does not exist in the map's style.`)));let c=o.getSource().type,m=c==="vector"?e.sourceLayer:void 0;c!=="vector"||m?n&&typeof e.id!="string"&&typeof e.id!="number"?this.fire(new p.j(new Error("A feature id is required to remove its specific state property."))):o.removeFeatureState(m,e.id,n):this.fire(new p.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();let n=e.source,a=e.sourceLayer,o=this.sourceCaches[n];if(o!==void 0)return o.getSource().type!=="vector"||a?(e.id===void 0&&this.fire(new p.j(new Error("The feature id parameter must be provided."))),o.getFeatureState(a,e.id)):void this.fire(new p.j(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new p.j(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return p.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;let e=p.aF(this.sourceCaches,c=>c.serialize()),n=this._serializeByIds(this._order,!0),a=this.map.getTerrain()||void 0,o=this.stylesheet;return p.aG({version:o.version,name:o.name,metadata:o.metadata,light:o.light,sky:o.sky,center:o.center,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch,sprite:o.sprite,glyphs:o.glyphs,transition:o.transition,sources:e,layers:n,terrain:a},c=>c!==void 0)}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&this.sourceCaches[e.source].getSource().type!=="raster"&&(this._updatedSources[e.source]="reload",this.sourceCaches[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){let n=m=>this._layers[m].type==="fill-extrusion",a={},o=[];for(let m=this._order.length-1;m>=0;m--){let g=this._order[m];if(n(g)){a[g]=m;for(let y of e){let b=y[g];if(b)for(let T of b)o.push(T)}}}o.sort((m,g)=>g.intersectionZ-m.intersectionZ);let c=[];for(let m=this._order.length-1;m>=0;m--){let g=this._order[m];if(n(g))for(let y=o.length-1;y>=0;y--){let b=o[y].feature;if(a[b.layer.id]{let he=$.featureSortOrder;if(he){let xe=he.indexOf(ee.featureIndex);return he.indexOf(oe.featureIndex)-xe}return oe.featureIndex-ee.featureIndex});for(let ee of K)X.push(ee)}}for(let $ in R)R[$].forEach(Z=>{let B=Z.feature,X=b[g[$].source].getFeatureState(B.layer["source-layer"],B.id);B.source=B.layer.source,B.layer["source-layer"]&&(B.sourceLayer=B.layer["source-layer"]),B.state=X});return R}(this._layers,m,this.sourceCaches,e,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(c)}querySourceFeatures(e,n){n&&n.filter&&this._validate(p.u.filter,"querySourceFeatures.filter",n.filter,null,n);let a=this.sourceCaches[e];return a?function(o,c){let m=o.getRenderableIds().map(b=>o.getTileByID(b)),g=[],y={};for(let b=0;bC.getTileByID(E)).sort((E,R)=>R.tileID.overscaledZ-E.tileID.overscaledZ||(E.tileID.isLessThan(R.tileID)?-1:1))}let S=this.crossTileSymbolIndex.addLayer(T,y[T.source],e.center.lng);m=m||S}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((c=c||this._layerOrderChanged||a===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(me.now(),e.zoom))&&(this.pauseablePlacement=new Qn(e,this.map.terrain,this._order,c,n,a,o,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,y),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(me.now()),g=!0),m&&this.pauseablePlacement.placement.setStale()),g||m)for(let b of this._order){let T=this._layers[b];T.type==="symbol"&&this.placement.updateLayerOpacities(T,y[T.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(me.now())}_releaseSymbolFadeTiles(){for(let e in this.sourceCaches)this.sourceCaches[e].releaseSymbolFadeTiles()}getImages(e,n){return p._(this,void 0,void 0,function*(){let a=yield this.imageManager.getImages(n.icons);this._updateTilesForChangedImages();let o=this.sourceCaches[n.source];return o&&o.setDependencies(n.tileID.key,n.type,n.icons),a})}getGlyphs(e,n){return p._(this,void 0,void 0,function*(){let a=yield this.glyphManager.getGlyphs(n.stacks),o=this.sourceCaches[n.source];return o&&o.setDependencies(n.tileID.key,n.type,[""]),a})}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,n={}){this._checkLoaded(),e&&this._validate(p.u.glyphs,"glyphs",e,null,n)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}addSprite(e,n,a={},o){this._checkLoaded();let c=[{id:e,url:n}],m=[...Ki(this.stylesheet.sprite),...c];this._validate(p.u.sprite,"sprite",m,null,a)||(this.stylesheet.sprite=m,this._loadSprite(c,!0,o))}removeSprite(e){this._checkLoaded();let n=Ki(this.stylesheet.sprite);if(n.find(a=>a.id===e)){if(this._spritesImagesIds[e])for(let a of this._spritesImagesIds[e])this.imageManager.removeImage(a),this._changedImages[a]=!0;n.splice(n.findIndex(a=>a.id===e),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new p.k("data",{dataType:"style"}))}else this.fire(new p.j(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return Ki(this.stylesheet.sprite)}setSprite(e,n={},a){this._checkLoaded(),e&&this._validate(p.u.sprite,"sprite",e,null,n)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,a):(this._unloadSprite(),a&&a(null)))}}var $r=p.Y([{name:"a_pos",type:"Int16",components:2}]);let Mr={prelude:tt(`#ifdef GL_ES precision mediump float; #else #if !defined(lowp) #define lowp #endif #if !defined(mediump) #define mediump #endif #if !defined(highp) #define highp #endif #endif `,`#ifdef GL_ES precision highp float; #else #if !defined(lowp) #define lowp #endif #if !defined(mediump) #define mediump #endif #if !defined(highp) #define highp #endif #endif 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 );}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;} #ifdef TERRAIN3D 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; #endif 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) { #ifdef TERRAIN3D highp float d=unpack(texture2D(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0)); #else return 1.0; #endif }float calculate_visibility(vec4 pos) { #ifdef TERRAIN3D 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; #else return 1.0; #endif }float ele(vec2 pos) { #ifdef TERRAIN3D vec4 rgb=(texture2D(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a; #else return 0.0; #endif }float get_elevation(vec2 pos) { #ifdef TERRAIN3D 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; #else return 0.0; #endif }`),background:tt(`uniform vec4 u_color;uniform float u_opacity;void main() {gl_FragColor=u_color*u_opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),backgroundPattern:tt(`uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_mix)*u_opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:tt(`varying vec3 v_data;varying float v_visibility; #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define highp vec4 stroke_color #pragma mapbox: define mediump float stroke_width #pragma mapbox: define lowp float stroke_opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump float radius #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp vec4 stroke_color #pragma mapbox: initialize mediump float stroke_width #pragma mapbox: initialize lowp float stroke_opacity 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));gl_FragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;varying vec3 v_data;varying float v_visibility; #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define highp vec4 stroke_color #pragma mapbox: define mediump float stroke_width #pragma mapbox: define lowp float stroke_opacity void main(void) { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump float radius #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp vec4 stroke_color #pragma mapbox: initialize mediump float stroke_width #pragma mapbox: initialize lowp float stroke_opacity vec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);float ele=get_elevation(circle_center);v_visibility=calculate_visibility(u_matrix*vec4(circle_center,ele,1.0));if (u_pitch_with_map) {vec2 corner_position=circle_center;if (u_scale_with_map) {corner_position+=extrude*(radius+stroke_width)*u_extrude_scale;} else {vec4 projected_center=u_matrix*vec4(circle_center,0,1);corner_position+=extrude*(radius+stroke_width)*u_extrude_scale*(projected_center.w/u_camera_to_center_distance);}gl_Position=u_matrix*vec4(corner_position,ele,1);} else {gl_Position=u_matrix*vec4(circle_center,ele,1);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:tt("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:tt(`uniform highp float u_intensity;varying vec2 v_extrude; #pragma mapbox: define highp float weight #define GAUSS_COEF 0.3989422804014327 void main() { #pragma mapbox: initialize highp float weight float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;varying vec2 v_extrude; #pragma mapbox: define highp float weight #pragma mapbox: define mediump float radius const highp float ZERO=1.0/255.0/16.0; #define GAUSS_COEF 0.3989422804014327 void main(void) { #pragma mapbox: initialize highp float weight #pragma mapbox: initialize mediump float radius vec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec4 pos=vec4(floor(a_pos*0.5)+extrude,get_elevation(floor(a_pos*0.5)),1);gl_Position=u_matrix*pos;}`),heatmapTexture:tt(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(0.0); #endif }`,"uniform mat4 u_matrix;uniform vec2 u_world;attribute vec2 a_pos;varying 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:tt("varying float v_placed;varying float v_notUsed;void main() {float alpha=0.5;gl_FragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {gl_FragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {gl_FragColor*=.1;}}","attribute vec2 a_anchor_pos;attribute vec2 a_placed;attribute vec2 a_box_real;uniform mat4 u_matrix;uniform vec2 u_pixel_extrude_scale;varying float v_placed;varying float v_notUsed;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}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:tt("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos;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;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:tt("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,get_elevation(a_pos),1);}"),fill:tt(`#pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float opacity gl_FragColor=color*opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec2 a_pos;uniform mat4 u_matrix; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float opacity gl_Position=u_matrix*vec4(a_pos,0,1);}`),fillOutline:tt(`varying vec2 v_pos; #pragma mapbox: define highp vec4 outline_color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 outline_color #pragma mapbox: initialize lowp float opacity float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=outline_color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos; #pragma mapbox: define highp vec4 outline_color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 outline_color #pragma mapbox: initialize lowp float opacity gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}`),fillOutlinePattern:tt(`uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to 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=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=mix(color1,color2,u_fade)*alpha*opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to 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=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}`),fillPattern:tt(`#ifdef GL_ES precision highp float; #endif uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to 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=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_fade)*opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to 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=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}`),fillExtrusion:tt(`varying vec4 v_color;void main() {gl_FragColor=v_color; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec2 a_pos;attribute vec4 a_normal_ed; #ifdef TERRAIN3D attribute vec2 a_centroid; #endif varying vec4 v_color; #pragma mapbox: define highp float base #pragma mapbox: define highp float height #pragma mapbox: define highp vec4 color void main() { #pragma mapbox: initialize highp float base #pragma mapbox: initialize highp float height #pragma mapbox: initialize highp vec4 color vec3 normal=a_normal_ed.xyz; #ifdef TERRAIN3D float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0); #else float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0; #endif base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);gl_Position=u_matrix*vec4(a_pos,t > 0.0 ? height : base,1);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal/16384.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((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:tt(`uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting; #pragma mapbox: define lowp float base #pragma mapbox: define lowp float height #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float base #pragma mapbox: initialize lowp float height #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to 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=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);gl_FragColor=mixedColor*v_lighting; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec2 a_pos;attribute vec4 a_normal_ed; #ifdef TERRAIN3D attribute vec2 a_centroid; #endif varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting; #pragma mapbox: define lowp float base #pragma mapbox: define lowp float height #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float base #pragma mapbox: initialize lowp float height #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to 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; #ifdef TERRAIN3D float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0); #else float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0; #endif base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float z=t > 0.0 ? height : base;gl_Position=u_matrix*vec4(a_pos,z,1);vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0 ? a_pos : vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/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:tt(`#ifdef GL_ES precision highp float; #endif uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;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))/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:tt(`uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent; #define PI 3.141592653589793 void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;}"),line:tt(`uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity 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);gl_FragColor=color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 attribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp float v_linesofar; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float gapwidth #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float width void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float width 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);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude; #ifdef TERRAIN3D v_gamma_scale=1.0; #else float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #endif v_width2=vec2(outset,inset);}`),lineGradient:tt(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec2 v_uv; #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity 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=texture2D(u_image,v_uv);gl_FragColor=color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 attribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_uv_x;attribute float a_split_index;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec2 v_uv; #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float gapwidth #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float width void main() { #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float width 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);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude; #ifdef TERRAIN3D v_gamma_scale=1.0; #else float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #endif v_width2=vec2(outset,inset);}`),linePattern:tt(`#ifdef GL_ES precision highp float; #endif uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width; #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity 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(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);gl_FragColor=color*alpha*opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 #define LINE_DISTANCE_SCALE 2.0 attribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width; #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float gapwidth #pragma mapbox: define mediump float width #pragma mapbox: define lowp float floorwidth #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize mediump float width #pragma mapbox: initialize lowp float floorwidth #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to 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);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude; #ifdef TERRAIN3D v_gamma_scale=1.0; #else float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #endif v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:tt(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float width #pragma mapbox: define lowp float floorwidth void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float width #pragma mapbox: initialize lowp float floorwidth 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=texture2D(u_image,v_tex_a).a;float sdfdist_b=texture2D(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);gl_FragColor=color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 #define LINE_DISTANCE_SCALE 2.0 attribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float gapwidth #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float width #pragma mapbox: define lowp float floorwidth void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float width #pragma mapbox: initialize lowp float floorwidth 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);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude; #ifdef TERRAIN3D v_gamma_scale=1.0; #else float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #endif v_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}`),raster:tt(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(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);gl_FragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.0)-0.5)/u_buffer_scale )+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:tt(`uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity; #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize lowp float opacity lowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;varying vec2 v_tex;varying float v_fade_opacity;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);} #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize lowp float opacity 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 ? camera_to_anchor_distance/u_camera_to_center_distance : 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;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:tt(`#define SDF_PX 8.0 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;varying vec2 v_data0;varying vec3 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur 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=texture2D(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);}gl_FragColor=color*(alpha*opacity*fade_opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_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;varying vec2 v_data0;varying vec3 v_data1;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);} #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur 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 ? camera_to_anchor_distance/u_camera_to_center_distance : 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;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:tt(`#define SDF_PX 8.0 #define SDF 1.0 #define ICON 0.0 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;varying vec4 v_data0;varying vec4 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur float fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif 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=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform 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;varying vec4 v_data0;varying vec4 v_data1;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);} #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur 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 ? camera_to_anchor_distance/u_camera_to_center_distance : 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;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:tt("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;varying vec2 v_texture_pos;varying 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=texture2D(u_texture,v_texture_pos);if (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);gl_FragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {gl_FragColor=surface_color;}}","attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform mat4 u_fog_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;varying 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=u_matrix*vec4(a_pos3d.xy,ele-ele_delta,1.0);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:tt("varying 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() {gl_FragColor=pack(v_depth);}","attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying 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=u_matrix*vec4(a_pos3d.xy,ele-ele_delta,1.0);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:tt("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;varying vec2 v_texture_pos;void main() {vec4 rgba=texture2D(u_texture,v_texture_pos);gl_FragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying 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=u_matrix*vec4(a_pos3d.xy,ele-ele_delta,1.0);}"),sky:tt("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform float u_horizon;uniform float u_sky_horizon_blend;void main() {float y=gl_FragCoord.y;if (y > u_horizon) {float blend=y-u_horizon;if (blend < u_sky_horizon_blend) {gl_FragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {gl_FragColor=u_sky_color;}}}","attribute vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function tt(h,e){let n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,a=e.match(/attribute ([\w]+) ([\w]+)/g),o=h.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),c=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),m=c?c.concat(o):o,g={};return{fragmentSource:h=h.replace(n,(y,b,T,S,C)=>(g[C]=!0,b==="define"?` #ifndef HAS_UNIFORM_u_${C} varying ${T} ${S} ${C}; #else uniform ${T} ${S} u_${C}; #endif `:` #ifdef HAS_UNIFORM_u_${C} ${T} ${S} ${C} = u_${C}; #endif `)),vertexSource:e=e.replace(n,(y,b,T,S,C)=>{let E=S==="float"?"vec2":"vec4",R=C.match(/color/)?"color":E;return g[C]?b==="define"?` #ifndef HAS_UNIFORM_u_${C} uniform lowp float u_${C}_t; attribute ${T} ${E} a_${C}; varying ${T} ${S} ${C}; #else uniform ${T} ${S} u_${C}; #endif `:R==="vec4"?` #ifndef HAS_UNIFORM_u_${C} ${C} = a_${C}; #else ${T} ${S} ${C} = u_${C}; #endif `:` #ifndef HAS_UNIFORM_u_${C} ${C} = unpack_mix_${R}(a_${C}, u_${C}_t); #else ${T} ${S} ${C} = u_${C}; #endif `:b==="define"?` #ifndef HAS_UNIFORM_u_${C} uniform lowp float u_${C}_t; attribute ${T} ${E} a_${C}; #else uniform ${T} ${S} u_${C}; #endif `:R==="vec4"?` #ifndef HAS_UNIFORM_u_${C} ${T} ${S} ${C} = a_${C}; #else ${T} ${S} ${C} = u_${C}; #endif `:` #ifndef HAS_UNIFORM_u_${C} ${T} ${S} ${C} = unpack_mix_${R}(a_${C}, u_${C}_t); #else ${T} ${S} ${C} = u_${C}; #endif `}),staticAttributes:a,staticUniforms:m}}class Pa{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,n,a,o,c,m,g,y,b){this.context=e;let T=this.boundPaintVertexBuffers.length!==o.length;for(let S=0;!T&&S({u_matrix:h,u_texture:0,u_ele_delta:e,u_fog_matrix:n,u_fog_color:a?a.properties.get("fog-color"):p.aM.white,u_fog_ground_blend:a?a.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:a?a.calculateFogBlendOpacity(o):0,u_horizon_color:a?a.properties.get("horizon-color"):p.aM.white,u_horizon_fog_blend:a?a.properties.get("horizon-fog-blend"):1});function fn(h){let e=[];for(let n=0;n({u_depth:new p.aH(ee,oe.u_depth),u_terrain:new p.aH(ee,oe.u_terrain),u_terrain_dim:new p.aI(ee,oe.u_terrain_dim),u_terrain_matrix:new p.aJ(ee,oe.u_terrain_matrix),u_terrain_unpack:new p.aK(ee,oe.u_terrain_unpack),u_terrain_exaggeration:new p.aI(ee,oe.u_terrain_exaggeration)}))(e,K),this.binderUniforms=a?a.getUniforms(e,K):[]}draw(e,n,a,o,c,m,g,y,b,T,S,C,E,R,V,U,$,Z){let B=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(a),e.setStencilMode(o),e.setColorMode(c),e.setCullFace(m),y){e.activeTexture.set(B.TEXTURE2),B.bindTexture(B.TEXTURE_2D,y.depthTexture),e.activeTexture.set(B.TEXTURE3),B.bindTexture(B.TEXTURE_2D,y.texture);for(let K in this.terrainUniforms)this.terrainUniforms[K].set(y[K])}for(let K in this.fixedUniforms)this.fixedUniforms[K].set(g[K]);V&&V.setUniforms(e,this.binderUniforms,E,{zoom:R});let X=0;switch(n){case B.LINES:X=2;break;case B.TRIANGLES:X=3;break;case B.LINE_STRIP:X=1}for(let K of C.get()){let ee=K.vaos||(K.vaos={});(ee[b]||(ee[b]=new Pa)).bind(e,this,T,V?V.getPaintVertexBuffers():[],S,K.vertexOffset,U,$,Z),B.drawElements(n,K.primitiveLength*X,B.UNSIGNED_SHORT,K.primitiveOffset*X*2)}}}function ks(h,e,n){let a=1/Ge(n,1,e.transform.tileZoom),o=Math.pow(2,n.tileID.overscaledZ),c=n.tileSize*Math.pow(2,e.transform.tileZoom)/o,m=c*(n.tileID.canonical.x+n.tileID.wrap*o),g=c*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[a,h.fromScale,h.toScale],u_fade:h.t,u_pixel_coord_upper:[m>>16,g>>16],u_pixel_coord_lower:[65535&m,65535&g]}}let es=(h,e,n,a)=>{let o=e.style.light,c=o.properties.get("position"),m=[c.x,c.y,c.z],g=function(){var b=new p.A(9);return p.A!=Float32Array&&(b[1]=0,b[2]=0,b[3]=0,b[5]=0,b[6]=0,b[7]=0),b[0]=1,b[4]=1,b[8]=1,b}();o.properties.get("anchor")==="viewport"&&function(b,T){var S=Math.sin(T),C=Math.cos(T);b[0]=C,b[1]=S,b[2]=0,b[3]=-S,b[4]=C,b[5]=0,b[6]=0,b[7]=0,b[8]=1}(g,-e.transform.angle),function(b,T,S){var C=T[0],E=T[1],R=T[2];b[0]=C*S[0]+E*S[3]+R*S[6],b[1]=C*S[1]+E*S[4]+R*S[7],b[2]=C*S[2]+E*S[5]+R*S[8]}(m,m,g);let y=o.properties.get("color");return{u_matrix:h,u_lightpos:m,u_lightintensity:o.properties.get("intensity"),u_lightcolor:[y.r,y.g,y.b],u_vertical_gradient:+n,u_opacity:a}},zs=(h,e,n,a,o,c,m)=>p.e(es(h,e,n,a),ks(c,e,m),{u_height_factor:-Math.pow(2,o.overscaledZ)/m.tileSize/8}),mn=h=>({u_matrix:h}),Eo=(h,e,n,a)=>p.e(mn(h),ks(n,e,a)),Fl=(h,e)=>({u_matrix:h,u_world:e}),Do=(h,e,n,a,o)=>p.e(Eo(h,e,n,a),{u_world:o}),Ol=(h,e,n,a)=>{let o=h.transform,c,m;if(a.paint.get("circle-pitch-alignment")==="map"){let g=Ge(n,1,o.zoom);c=!0,m=[g,g]}else c=!1,m=o.pixelsToGLUnits;return{u_camera_to_center_distance:o.cameraToCenterDistance,u_scale_with_map:+(a.paint.get("circle-pitch-scale")==="map"),u_matrix:h.translatePosMatrix(e.posMatrix,n,a.paint.get("circle-translate"),a.paint.get("circle-translate-anchor")),u_pitch_with_map:+c,u_device_pixel_ratio:h.pixelRatio,u_extrude_scale:m}},qr=(h,e,n)=>({u_matrix:h,u_inv_matrix:e,u_camera_to_center_distance:n.cameraToCenterDistance,u_viewport_size:[n.width,n.height]}),ts=(h,e,n=1)=>({u_matrix:h,u_color:e,u_overlay:0,u_overlay_scale:n}),ii=h=>({u_matrix:h}),ri=(h,e,n,a)=>({u_matrix:h,u_extrude_scale:Ge(e,1,n),u_intensity:a}),Es=(h,e,n,a)=>{let o=p.H();p.aP(o,0,h.width,h.height,0,0,1);let c=h.context.gl;return{u_matrix:o,u_world:[c.drawingBufferWidth,c.drawingBufferHeight],u_image:n,u_color_ramp:a,u_opacity:e.paint.get("heatmap-opacity")}};function Ds(h,e){let n=Math.pow(2,e.canonical.z),a=e.canonical.y;return[new p.Z(0,a/n).toLngLat().lat,new p.Z(0,(a+1)/n).toLngLat().lat]}let Ls=(h,e,n,a)=>{let o=h.transform;return{u_matrix:Bo(h,e,n,a),u_ratio:1/Ge(e,1,o.zoom),u_device_pixel_ratio:h.pixelRatio,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},Lo=(h,e,n,a,o)=>p.e(Ls(h,e,n,o),{u_image:0,u_image_height:a}),_n=(h,e,n,a,o)=>{let c=h.transform,m=Ro(e,c);return{u_matrix:Bo(h,e,n,o),u_texsize:e.imageAtlasTexture.size,u_ratio:1/Ge(e,1,c.zoom),u_device_pixel_ratio:h.pixelRatio,u_image:0,u_scale:[m,a.fromScale,a.toScale],u_fade:a.t,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]]}},Vl=(h,e,n,a,o,c)=>{let m=h.lineAtlas,g=Ro(e,h.transform),y=n.layout.get("line-cap")==="round",b=m.getDash(a.from,y),T=m.getDash(a.to,y),S=b.width*o.fromScale,C=T.width*o.toScale;return p.e(Ls(h,e,n,c),{u_patternscale_a:[g/S,-b.height/2],u_patternscale_b:[g/C,-T.height/2],u_sdfgamma:m.width/(256*Math.min(S,C)*h.pixelRatio)/2,u_image:0,u_tex_y_a:b.y,u_tex_y_b:T.y,u_mix:o.t})};function Ro(h,e){return 1/Ge(h,1,e.tileZoom)}function Bo(h,e,n,a){return h.translatePosMatrix(a?a.posMatrix:e.tileID.posMatrix,e,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}let Nl=(h,e,n,a,o)=>{return{u_matrix:h,u_tl_parent:e,u_scale_parent:n,u_buffer_scale:1,u_fade_t:a.mix,u_opacity:a.opacity*o.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:o.paint.get("raster-brightness-min"),u_brightness_high:o.paint.get("raster-brightness-max"),u_saturation_factor:(m=o.paint.get("raster-saturation"),m>0?1-1/(1.001-m):-m),u_contrast_factor:(c=o.paint.get("raster-contrast"),c>0?1/(1-c):1+c),u_spin_weights:jl(o.paint.get("raster-hue-rotate"))};var c,m};function jl(h){h*=Math.PI/180;let e=Math.sin(h),n=Math.cos(h);return[(2*n+1)/3,(-Math.sqrt(3)*e-n+1)/3,(Math.sqrt(3)*e-n+1)/3]}let Fo=(h,e,n,a,o,c,m,g,y,b,T,S,C,E)=>{let R=m.transform;return{u_is_size_zoom_constant:+(h==="constant"||h==="source"),u_is_size_feature_constant:+(h==="constant"||h==="camera"),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:R.cameraToCenterDistance,u_pitch:R.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:R.width/R.height,u_fade_change:m.options.fadeDuration?m.symbolFadeChange:1,u_matrix:g,u_label_plane_matrix:y,u_coord_matrix:b,u_is_text:+S,u_pitch_with_map:+a,u_is_along_line:o,u_is_variable_anchor:c,u_texsize:C,u_texture:0,u_translation:T,u_pitched_scale:E}},is=(h,e,n,a,o,c,m,g,y,b,T,S,C,E,R)=>{let V=m.transform;return p.e(Fo(h,e,n,a,o,c,m,g,y,b,T,S,C,R),{u_gamma_scale:a?Math.cos(V._pitch)*V.cameraToCenterDistance:1,u_device_pixel_ratio:m.pixelRatio,u_is_halo:+E})},Ca=(h,e,n,a,o,c,m,g,y,b,T,S,C,E)=>p.e(is(h,e,n,a,o,c,m,g,y,b,T,!0,S,!0,E),{u_texsize_icon:C,u_texture_icon:1}),Rs=(h,e,n)=>({u_matrix:h,u_opacity:e,u_color:n}),ka=(h,e,n,a,o,c)=>p.e(function(m,g,y,b){let T=y.imageManager.getPattern(m.from.toString()),S=y.imageManager.getPattern(m.to.toString()),{width:C,height:E}=y.imageManager.getPixelSize(),R=Math.pow(2,b.tileID.overscaledZ),V=b.tileSize*Math.pow(2,y.transform.tileZoom)/R,U=V*(b.tileID.canonical.x+b.tileID.wrap*R),$=V*b.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:T.tl,u_pattern_br_a:T.br,u_pattern_tl_b:S.tl,u_pattern_br_b:S.br,u_texsize:[C,E],u_mix:g.t,u_pattern_size_a:T.displaySize,u_pattern_size_b:S.displaySize,u_scale_a:g.fromScale,u_scale_b:g.toScale,u_tile_units_to_pixels:1/Ge(b,1,y.transform.tileZoom),u_pixel_coord_upper:[U>>16,$>>16],u_pixel_coord_lower:[65535&U,65535&$]}}(a,c,n,o),{u_matrix:h,u_opacity:e}),za={fillExtrusion:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_lightpos:new p.aN(h,e.u_lightpos),u_lightintensity:new p.aI(h,e.u_lightintensity),u_lightcolor:new p.aN(h,e.u_lightcolor),u_vertical_gradient:new p.aI(h,e.u_vertical_gradient),u_opacity:new p.aI(h,e.u_opacity)}),fillExtrusionPattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_lightpos:new p.aN(h,e.u_lightpos),u_lightintensity:new p.aI(h,e.u_lightintensity),u_lightcolor:new p.aN(h,e.u_lightcolor),u_vertical_gradient:new p.aI(h,e.u_vertical_gradient),u_height_factor:new p.aI(h,e.u_height_factor),u_image:new p.aH(h,e.u_image),u_texsize:new p.aO(h,e.u_texsize),u_pixel_coord_upper:new p.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(h,e.u_pixel_coord_lower),u_scale:new p.aN(h,e.u_scale),u_fade:new p.aI(h,e.u_fade),u_opacity:new p.aI(h,e.u_opacity)}),fill:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix)}),fillPattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_image:new p.aH(h,e.u_image),u_texsize:new p.aO(h,e.u_texsize),u_pixel_coord_upper:new p.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(h,e.u_pixel_coord_lower),u_scale:new p.aN(h,e.u_scale),u_fade:new p.aI(h,e.u_fade)}),fillOutline:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_world:new p.aO(h,e.u_world)}),fillOutlinePattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_world:new p.aO(h,e.u_world),u_image:new p.aH(h,e.u_image),u_texsize:new p.aO(h,e.u_texsize),u_pixel_coord_upper:new p.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(h,e.u_pixel_coord_lower),u_scale:new p.aN(h,e.u_scale),u_fade:new p.aI(h,e.u_fade)}),circle:(h,e)=>({u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_scale_with_map:new p.aH(h,e.u_scale_with_map),u_pitch_with_map:new p.aH(h,e.u_pitch_with_map),u_extrude_scale:new p.aO(h,e.u_extrude_scale),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_matrix:new p.aJ(h,e.u_matrix)}),collisionBox:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_pixel_extrude_scale:new p.aO(h,e.u_pixel_extrude_scale)}),collisionCircle:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_inv_matrix:new p.aJ(h,e.u_inv_matrix),u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_viewport_size:new p.aO(h,e.u_viewport_size)}),debug:(h,e)=>({u_color:new p.aL(h,e.u_color),u_matrix:new p.aJ(h,e.u_matrix),u_overlay:new p.aH(h,e.u_overlay),u_overlay_scale:new p.aI(h,e.u_overlay_scale)}),clippingMask:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix)}),heatmap:(h,e)=>({u_extrude_scale:new p.aI(h,e.u_extrude_scale),u_intensity:new p.aI(h,e.u_intensity),u_matrix:new p.aJ(h,e.u_matrix)}),heatmapTexture:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_world:new p.aO(h,e.u_world),u_image:new p.aH(h,e.u_image),u_color_ramp:new p.aH(h,e.u_color_ramp),u_opacity:new p.aI(h,e.u_opacity)}),hillshade:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_image:new p.aH(h,e.u_image),u_latrange:new p.aO(h,e.u_latrange),u_light:new p.aO(h,e.u_light),u_shadow:new p.aL(h,e.u_shadow),u_highlight:new p.aL(h,e.u_highlight),u_accent:new p.aL(h,e.u_accent)}),hillshadePrepare:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_image:new p.aH(h,e.u_image),u_dimension:new p.aO(h,e.u_dimension),u_zoom:new p.aI(h,e.u_zoom),u_unpack:new p.aK(h,e.u_unpack)}),line:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_ratio:new p.aI(h,e.u_ratio),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_units_to_pixels:new p.aO(h,e.u_units_to_pixels)}),lineGradient:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_ratio:new p.aI(h,e.u_ratio),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_units_to_pixels:new p.aO(h,e.u_units_to_pixels),u_image:new p.aH(h,e.u_image),u_image_height:new p.aI(h,e.u_image_height)}),linePattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_texsize:new p.aO(h,e.u_texsize),u_ratio:new p.aI(h,e.u_ratio),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_image:new p.aH(h,e.u_image),u_units_to_pixels:new p.aO(h,e.u_units_to_pixels),u_scale:new p.aN(h,e.u_scale),u_fade:new p.aI(h,e.u_fade)}),lineSDF:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_ratio:new p.aI(h,e.u_ratio),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_units_to_pixels:new p.aO(h,e.u_units_to_pixels),u_patternscale_a:new p.aO(h,e.u_patternscale_a),u_patternscale_b:new p.aO(h,e.u_patternscale_b),u_sdfgamma:new p.aI(h,e.u_sdfgamma),u_image:new p.aH(h,e.u_image),u_tex_y_a:new p.aI(h,e.u_tex_y_a),u_tex_y_b:new p.aI(h,e.u_tex_y_b),u_mix:new p.aI(h,e.u_mix)}),raster:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_tl_parent:new p.aO(h,e.u_tl_parent),u_scale_parent:new p.aI(h,e.u_scale_parent),u_buffer_scale:new p.aI(h,e.u_buffer_scale),u_fade_t:new p.aI(h,e.u_fade_t),u_opacity:new p.aI(h,e.u_opacity),u_image0:new p.aH(h,e.u_image0),u_image1:new p.aH(h,e.u_image1),u_brightness_low:new p.aI(h,e.u_brightness_low),u_brightness_high:new p.aI(h,e.u_brightness_high),u_saturation_factor:new p.aI(h,e.u_saturation_factor),u_contrast_factor:new p.aI(h,e.u_contrast_factor),u_spin_weights:new p.aN(h,e.u_spin_weights)}),symbolIcon:(h,e)=>({u_is_size_zoom_constant:new p.aH(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(h,e.u_is_size_feature_constant),u_size_t:new p.aI(h,e.u_size_t),u_size:new p.aI(h,e.u_size),u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_pitch:new p.aI(h,e.u_pitch),u_rotate_symbol:new p.aH(h,e.u_rotate_symbol),u_aspect_ratio:new p.aI(h,e.u_aspect_ratio),u_fade_change:new p.aI(h,e.u_fade_change),u_matrix:new p.aJ(h,e.u_matrix),u_label_plane_matrix:new p.aJ(h,e.u_label_plane_matrix),u_coord_matrix:new p.aJ(h,e.u_coord_matrix),u_is_text:new p.aH(h,e.u_is_text),u_pitch_with_map:new p.aH(h,e.u_pitch_with_map),u_is_along_line:new p.aH(h,e.u_is_along_line),u_is_variable_anchor:new p.aH(h,e.u_is_variable_anchor),u_texsize:new p.aO(h,e.u_texsize),u_texture:new p.aH(h,e.u_texture),u_translation:new p.aO(h,e.u_translation),u_pitched_scale:new p.aI(h,e.u_pitched_scale)}),symbolSDF:(h,e)=>({u_is_size_zoom_constant:new p.aH(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(h,e.u_is_size_feature_constant),u_size_t:new p.aI(h,e.u_size_t),u_size:new p.aI(h,e.u_size),u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_pitch:new p.aI(h,e.u_pitch),u_rotate_symbol:new p.aH(h,e.u_rotate_symbol),u_aspect_ratio:new p.aI(h,e.u_aspect_ratio),u_fade_change:new p.aI(h,e.u_fade_change),u_matrix:new p.aJ(h,e.u_matrix),u_label_plane_matrix:new p.aJ(h,e.u_label_plane_matrix),u_coord_matrix:new p.aJ(h,e.u_coord_matrix),u_is_text:new p.aH(h,e.u_is_text),u_pitch_with_map:new p.aH(h,e.u_pitch_with_map),u_is_along_line:new p.aH(h,e.u_is_along_line),u_is_variable_anchor:new p.aH(h,e.u_is_variable_anchor),u_texsize:new p.aO(h,e.u_texsize),u_texture:new p.aH(h,e.u_texture),u_gamma_scale:new p.aI(h,e.u_gamma_scale),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_is_halo:new p.aH(h,e.u_is_halo),u_translation:new p.aO(h,e.u_translation),u_pitched_scale:new p.aI(h,e.u_pitched_scale)}),symbolTextAndIcon:(h,e)=>({u_is_size_zoom_constant:new p.aH(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(h,e.u_is_size_feature_constant),u_size_t:new p.aI(h,e.u_size_t),u_size:new p.aI(h,e.u_size),u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_pitch:new p.aI(h,e.u_pitch),u_rotate_symbol:new p.aH(h,e.u_rotate_symbol),u_aspect_ratio:new p.aI(h,e.u_aspect_ratio),u_fade_change:new p.aI(h,e.u_fade_change),u_matrix:new p.aJ(h,e.u_matrix),u_label_plane_matrix:new p.aJ(h,e.u_label_plane_matrix),u_coord_matrix:new p.aJ(h,e.u_coord_matrix),u_is_text:new p.aH(h,e.u_is_text),u_pitch_with_map:new p.aH(h,e.u_pitch_with_map),u_is_along_line:new p.aH(h,e.u_is_along_line),u_is_variable_anchor:new p.aH(h,e.u_is_variable_anchor),u_texsize:new p.aO(h,e.u_texsize),u_texsize_icon:new p.aO(h,e.u_texsize_icon),u_texture:new p.aH(h,e.u_texture),u_texture_icon:new p.aH(h,e.u_texture_icon),u_gamma_scale:new p.aI(h,e.u_gamma_scale),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_is_halo:new p.aH(h,e.u_is_halo),u_translation:new p.aO(h,e.u_translation),u_pitched_scale:new p.aI(h,e.u_pitched_scale)}),background:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_opacity:new p.aI(h,e.u_opacity),u_color:new p.aL(h,e.u_color)}),backgroundPattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_opacity:new p.aI(h,e.u_opacity),u_image:new p.aH(h,e.u_image),u_pattern_tl_a:new p.aO(h,e.u_pattern_tl_a),u_pattern_br_a:new p.aO(h,e.u_pattern_br_a),u_pattern_tl_b:new p.aO(h,e.u_pattern_tl_b),u_pattern_br_b:new p.aO(h,e.u_pattern_br_b),u_texsize:new p.aO(h,e.u_texsize),u_mix:new p.aI(h,e.u_mix),u_pattern_size_a:new p.aO(h,e.u_pattern_size_a),u_pattern_size_b:new p.aO(h,e.u_pattern_size_b),u_scale_a:new p.aI(h,e.u_scale_a),u_scale_b:new p.aI(h,e.u_scale_b),u_pixel_coord_upper:new p.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(h,e.u_pixel_coord_lower),u_tile_units_to_pixels:new p.aI(h,e.u_tile_units_to_pixels)}),terrain:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_texture:new p.aH(h,e.u_texture),u_ele_delta:new p.aI(h,e.u_ele_delta),u_fog_matrix:new p.aJ(h,e.u_fog_matrix),u_fog_color:new p.aL(h,e.u_fog_color),u_fog_ground_blend:new p.aI(h,e.u_fog_ground_blend),u_fog_ground_blend_opacity:new p.aI(h,e.u_fog_ground_blend_opacity),u_horizon_color:new p.aL(h,e.u_horizon_color),u_horizon_fog_blend:new p.aI(h,e.u_horizon_fog_blend)}),terrainDepth:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_ele_delta:new p.aI(h,e.u_ele_delta)}),terrainCoords:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_texture:new p.aH(h,e.u_texture),u_terrain_coords_id:new p.aI(h,e.u_terrain_coords_id),u_ele_delta:new p.aI(h,e.u_ele_delta)}),sky:(h,e)=>({u_sky_color:new p.aL(h,e.u_sky_color),u_horizon_color:new p.aL(h,e.u_horizon_color),u_horizon:new p.aI(h,e.u_horizon),u_sky_horizon_blend:new p.aI(h,e.u_sky_horizon_blend)})};class rr{constructor(e,n,a){this.context=e;let o=e.gl;this.buffer=o.createBuffer(),this.dynamicDraw=!!a,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){let 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,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}let Ul={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Ea{constructor(e,n,a,o){this.length=n.length,this.attributes=a,this.itemSize=n.bytesPerElement,this.dynamicDraw=o,this.context=e;let c=e.gl;this.buffer=c.createBuffer(),e.bindVertexBuffer.set(this.buffer),c.bufferData(c.ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?c.DYNAMIC_DRAW:c.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);let n=this.context.gl;this.bind(),n.bufferSubData(n.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,n){for(let a=0;a0){let ee=p.H();p.aQ(ee,B.placementInvProjMatrix,h.transform.glCoordMatrix),p.aQ(ee,ee,B.placementViewportMatrix),y.push({circleArray:K,circleOffset:T,transform:Z.posMatrix,invTransform:ee,coord:Z}),b+=K.length/4,T=b}X&&g.draw(c,m.LINES,Ze.disabled,ht.disabled,h.colorModeForRenderPass(),at.disabled,{u_matrix:Z.posMatrix,u_pixel_extrude_scale:[1/(S=h.transform).width,1/S.height]},h.style.map.terrain&&h.style.map.terrain.getTerrainData(Z),n.id,X.layoutVertexBuffer,X.indexBuffer,X.segments,null,h.transform.zoom,null,null,X.collisionVertexBuffer)}var S;if(!o||!y.length)return;let C=h.useProgram("collisionCircle"),E=new p.aR;E.resize(4*b),E._trim();let R=0;for(let $ of y)for(let Z=0;Z<$.circleArray.length/4;Z++){let B=4*Z,X=$.circleArray[B+0],K=$.circleArray[B+1],ee=$.circleArray[B+2],oe=$.circleArray[B+3];E.emplace(R++,X,K,ee,oe,0),E.emplace(R++,X,K,ee,oe,1),E.emplace(R++,X,K,ee,oe,2),E.emplace(R++,X,K,ee,oe,3)}(!Xr||Xr.length<2*b)&&(Xr=function($){let Z=2*$,B=new p.aT;B.resize(Z),B._trim();for(let X=0;X=0&&($[B.associatedIconIndex]={shiftedAnchor:Fe,angle:pt})}else De(B.numGlyphs,V)}if(b){U.clear();let Z=h.icon.placedSymbolArray;for(let B=0;Bh.style.map.terrain.getElevation(fe,Bn,Fn):null,en=n.layout.get("text-rotation-alignment")==="map";D(Me,fe.posMatrix,h,o,Ln,Rn,$,b,en,V,fe.toUnwrapped(),R.width,R.height,Pi,We)}let Ai=fe.posMatrix,Mi=o&&he||po,kr=Z||Mi?ss:Ln,ji=sa,Rt=be&&n.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1)!==0,jt;jt=be?Me.iconsInText?Ca(Fe.kind,He,B,$,Z,Mi,h,Ai,kr,ji,Pi,Vt,Kt,Te):is(Fe.kind,He,B,$,Z,Mi,h,Ai,kr,ji,Pi,o,Vt,!0,Te):Fo(Fe.kind,He,B,$,Z,Mi,h,Ai,kr,ji,Pi,o,Vt,Te);let gi={program:Ue,buffers:Ve,uniformValues:jt,atlasTexture:Ni,atlasTextureIcon:Nt,atlasInterpolation:mt,atlasInterpolationIcon:ni,isSDF:be,hasHalo:Rt};if(K&&Me.canOverlap){ee=!0;let We=Ve.segments.get();for(let en of We)xe.push({segments:new p.a0([en]),sortKey:en.sortKey,state:gi,terrainData:ft})}else xe.push({segments:Ve.segments,sortKey:0,state:gi,terrainData:ft})}ee&&xe.sort((fe,pe)=>fe.sortKey-pe.sortKey);for(let fe of xe){let pe=fe.state;if(C.activeTexture.set(E.TEXTURE0),pe.atlasTexture.bind(pe.atlasInterpolation,E.CLAMP_TO_EDGE),pe.atlasTextureIcon&&(C.activeTexture.set(E.TEXTURE1),pe.atlasTextureIcon&&pe.atlasTextureIcon.bind(pe.atlasInterpolationIcon,E.CLAMP_TO_EDGE)),pe.isSDF){let Me=pe.uniformValues;pe.hasHalo&&(Me.u_is_halo=1,Ua(pe.buffers,fe.segments,n,h,pe.program,oe,T,S,Me,fe.terrainData)),Me.u_is_halo=0}Ua(pe.buffers,fe.segments,n,h,pe.program,oe,T,S,pe.uniformValues,fe.terrainData)}}function Ua(h,e,n,a,o,c,m,g,y,b){let T=a.context;o.draw(T,T.gl.TRIANGLES,c,m,g,at.disabled,y,b,n.id,h.layoutVertexBuffer,h.indexBuffer,e,n.paint,a.transform.zoom,h.programConfigurations.get(n.id),h.dynamicLayoutVertexBuffer,h.opacityVertexBuffer)}function $a(h,e,n,a){let o=h.context,c=o.gl,m=ht.disabled,g=new bt([c.ONE,c.ONE],p.aM.transparent,[!0,!0,!0,!0]),y=e.getBucket(n);if(!y)return;let b=a.key,T=n.heatmapFbos.get(b);T||(T=as(o,e.tileSize,e.tileSize),n.heatmapFbos.set(b,T)),o.bindFramebuffer.set(T.framebuffer),o.viewport.set([0,0,e.tileSize,e.tileSize]),o.clear({color:p.aM.transparent});let S=y.programConfigurations.get(n.id),C=h.useProgram("heatmap",S),E=h.style.map.terrain.getTerrainData(a);C.draw(o,c.TRIANGLES,Ze.disabled,m,g,at.disabled,ri(a.posMatrix,e,h.transform.zoom,n.paint.get("heatmap-intensity")),E,n.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,n.paint,h.transform.zoom,S)}function Kr(h,e,n){let a=h.context,o=a.gl;a.setColorMode(h.colorModeForRenderPass());let c=os(a,e),m=n.key,g=e.heatmapFbos.get(m);g&&(a.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,g.colorAttachment.get()),a.activeTexture.set(o.TEXTURE1),c.bind(o.LINEAR,o.CLAMP_TO_EDGE),h.useProgram("heatmapTexture").draw(a,o.TRIANGLES,Ze.disabled,ht.disabled,h.colorModeForRenderPass(),at.disabled,Es(h,e,0,1),null,e.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments,e.paint,h.transform.zoom),g.destroy(),e.heatmapFbos.delete(m))}function as(h,e,n){var a,o;let c=h.gl,m=c.createTexture();c.bindTexture(c.TEXTURE_2D,m),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.LINEAR);let g=(a=h.HALF_FLOAT)!==null&&a!==void 0?a:c.UNSIGNED_BYTE,y=(o=h.RGBA16F)!==null&&o!==void 0?o:c.RGBA;c.texImage2D(c.TEXTURE_2D,0,y,e,n,0,c.RGBA,g,null);let b=h.createFramebuffer(e,n,!1,!1);return b.colorAttachment.set(m),b}function os(h,e){return e.colorRampTexture||(e.colorRampTexture=new st(h,e.colorRamp,h.gl.RGBA)),e.colorRampTexture}function xn(h,e,n,a,o){if(!n||!a||!a.imageAtlas)return;let c=a.imageAtlas.patternPositions,m=c[n.to.toString()],g=c[n.from.toString()];if(!m&&g&&(m=g),!g&&m&&(g=m),!m||!g){let y=o.getPaintProperty(e);m=c[y],g=c[y]}m&&g&&h.setConstantPatternPositions(m,g)}function ls(h,e,n,a,o,c,m){let g=h.context.gl,y="fill-pattern",b=n.paint.get(y),T=b&&b.constantOr(1),S=n.getCrossfadeParameters(),C,E,R,V,U;m?(E=T&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",C=g.LINES):(E=T?"fillPattern":"fill",C=g.TRIANGLES);let $=b.constantOr(null);for(let Z of a){let B=e.getTile(Z);if(T&&!B.patternsLoaded())continue;let X=B.getBucket(n);if(!X)continue;let K=X.programConfigurations.get(n.id),ee=h.useProgram(E,K),oe=h.style.map.terrain&&h.style.map.terrain.getTerrainData(Z);T&&(h.context.activeTexture.set(g.TEXTURE0),B.imageAtlasTexture.bind(g.LINEAR,g.CLAMP_TO_EDGE),K.updatePaintBuffers(S)),xn(K,y,$,B,n);let he=oe?Z:null,xe=h.translatePosMatrix(he?he.posMatrix:Z.posMatrix,B,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));if(m){V=X.indexBuffer2,U=X.segments2;let Te=[g.drawingBufferWidth,g.drawingBufferHeight];R=E==="fillOutlinePattern"&&T?Do(xe,h,S,B,Te):Fl(xe,Te)}else V=X.indexBuffer,U=X.segments,R=T?Eo(xe,h,S,B):mn(xe);ee.draw(h.context,C,o,h.stencilModeForClipping(Z),c,at.disabled,R,oe,n.id,X.layoutVertexBuffer,V,U,n.paint,h.transform.zoom,K)}}function js(h,e,n,a,o,c,m){let g=h.context,y=g.gl,b="fill-extrusion-pattern",T=n.paint.get(b),S=T.constantOr(1),C=n.getCrossfadeParameters(),E=n.paint.get("fill-extrusion-opacity"),R=T.constantOr(null);for(let V of a){let U=e.getTile(V),$=U.getBucket(n);if(!$)continue;let Z=h.style.map.terrain&&h.style.map.terrain.getTerrainData(V),B=$.programConfigurations.get(n.id),X=h.useProgram(S?"fillExtrusionPattern":"fillExtrusion",B);S&&(h.context.activeTexture.set(y.TEXTURE0),U.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),B.updatePaintBuffers(C)),xn(B,b,R,U,n);let K=h.translatePosMatrix(V.posMatrix,U,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),ee=n.paint.get("fill-extrusion-vertical-gradient"),oe=S?zs(K,h,ee,E,V,C,U):es(K,h,ee,E);X.draw(g,g.gl.TRIANGLES,o,c,m,at.backCCW,oe,Z,n.id,$.layoutVertexBuffer,$.indexBuffer,$.segments,n.paint,h.transform.zoom,B,h.style.map.terrain&&$.centroidVertexBuffer)}}function vn(h,e,n,a,o,c,m){let g=h.context,y=g.gl,b=n.fbo;if(!b)return;let T=h.useProgram("hillshade"),S=h.style.map.terrain&&h.style.map.terrain.getTerrainData(e);g.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,b.colorAttachment.get()),T.draw(g,y.TRIANGLES,o,c,m,at.disabled,((C,E,R,V)=>{let U=R.paint.get("hillshade-shadow-color"),$=R.paint.get("hillshade-highlight-color"),Z=R.paint.get("hillshade-accent-color"),B=R.paint.get("hillshade-illumination-direction")*(Math.PI/180);R.paint.get("hillshade-illumination-anchor")==="viewport"&&(B-=C.transform.angle);let X=!C.options.moving;return{u_matrix:V?V.posMatrix:C.transform.calculatePosMatrix(E.tileID.toUnwrapped(),X),u_image:0,u_latrange:Ds(0,E.tileID),u_light:[R.paint.get("hillshade-exaggeration"),B],u_shadow:U,u_highlight:$,u_accent:Z}})(h,n,a,S?e:null),S,a.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments)}function bn(h,e,n,a,o,c){let m=h.context,g=m.gl,y=e.dem;if(y&&y.data){let b=y.dim,T=y.stride,S=y.getPixels();if(m.activeTexture.set(g.TEXTURE1),m.pixelStoreUnpackPremultiplyAlpha.set(!1),e.demTexture=e.demTexture||h.getTileTexture(T),e.demTexture){let E=e.demTexture;E.update(S,{premultiply:!1}),E.bind(g.NEAREST,g.CLAMP_TO_EDGE)}else e.demTexture=new st(m,S,g.RGBA,{premultiply:!1}),e.demTexture.bind(g.NEAREST,g.CLAMP_TO_EDGE);m.activeTexture.set(g.TEXTURE0);let C=e.fbo;if(!C){let E=new st(m,{width:b,height:b,data:null},g.RGBA);E.bind(g.LINEAR,g.CLAMP_TO_EDGE),C=e.fbo=m.createFramebuffer(b,b,!0,!1),C.colorAttachment.set(E.texture)}m.bindFramebuffer.set(C.framebuffer),m.viewport.set([0,0,b,b]),h.useProgram("hillshadePrepare").draw(m,g.TRIANGLES,a,o,c,at.disabled,((E,R)=>{let V=R.stride,U=p.H();return p.aP(U,0,p.X,-p.X,0,0,1),p.J(U,U,[0,-p.X,0]),{u_matrix:U,u_image:1,u_dimension:[V,V],u_zoom:E.overscaledZ,u_unpack:R.getUnpackVector()}})(e.tileID,y),null,n.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments),e.needsHillshadePrepare=!1}}function Ko(h,e,n,a,o,c){let m=a.paint.get("raster-fade-duration");if(!c&&m>0){let g=me.now(),y=(g-h.timeAdded)/m,b=e?(g-e.timeAdded)/m:-1,T=n.getSource(),S=o.coveringZoomLevel({tileSize:T.tileSize,roundZoom:T.roundZoom}),C=!e||Math.abs(e.tileID.overscaledZ-S)>Math.abs(h.tileID.overscaledZ-S),E=C&&h.refreshedUponExpiration?1:p.ac(C?y:1-b,0,1);return h.refreshedUponExpiration&&y>=1&&(h.refreshedUponExpiration=!1),e?{opacity:1,mix:1-E}:{opacity:E,mix:0}}return{opacity:1,mix:0}}let qa=new p.aM(1,0,0,1),Ye=new p.aM(0,1,0,1),Us=new p.aM(0,0,1,1),Yl=new p.aM(1,0,1,1),Jo=new p.aM(0,1,1,1);function wn(h,e,n,a){$s(h,0,e+n/2,h.transform.width,n,a)}function Yo(h,e,n,a){$s(h,e-n/2,0,n,h.transform.height,a)}function $s(h,e,n,a,o,c){let m=h.context,g=m.gl;g.enable(g.SCISSOR_TEST),g.scissor(e*h.pixelRatio,n*h.pixelRatio,a*h.pixelRatio,o*h.pixelRatio),m.clear({color:c}),g.disable(g.SCISSOR_TEST)}function Qo(h,e,n){let a=h.context,o=a.gl,c=n.posMatrix,m=h.useProgram("debug"),g=Ze.disabled,y=ht.disabled,b=h.colorModeForRenderPass(),T="$debug",S=h.style.map.terrain&&h.style.map.terrain.getTerrainData(n);a.activeTexture.set(o.TEXTURE0);let C=e.getTileByID(n.key).latestRawTileData,E=Math.floor((C&&C.byteLength||0)/1024),R=e.getTile(n).tileSize,V=512/Math.min(R,512)*(n.overscaledZ/h.transform.zoom)*.5,U=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(U+=` => ${n.overscaledZ}`),function($,Z){$.initDebugOverlayCanvas();let B=$.debugOverlayCanvas,X=$.context.gl,K=$.debugOverlayCanvas.getContext("2d");K.clearRect(0,0,B.width,B.height),K.shadowColor="white",K.shadowBlur=2,K.lineWidth=1.5,K.strokeStyle="white",K.textBaseline="top",K.font="bold 36px Open Sans, sans-serif",K.fillText(Z,5,5),K.strokeText(Z,5,5),$.debugOverlayTexture.update(B),$.debugOverlayTexture.bind(X.LINEAR,X.CLAMP_TO_EDGE)}(h,`${U} ${E}kB`),m.draw(a,o.TRIANGLES,g,y,bt.alphaBlended,at.disabled,ts(c,p.aM.transparent,V),null,T,h.debugBuffer,h.quadTriangleIndexBuffer,h.debugSegments),m.draw(a,o.LINE_STRIP,g,y,b,at.disabled,ts(c,p.aM.red),S,T,h.debugBuffer,h.tileBorderIndexBuffer,h.debugSegments)}function el(h,e,n){let a=h.context,o=a.gl,c=h.colorModeForRenderPass(),m=new Ze(o.LEQUAL,Ze.ReadWrite,h.depthRangeFor3D),g=h.useProgram("terrain"),y=e.getTerrainMesh();a.bindFramebuffer.set(null),a.viewport.set([0,0,h.width,h.height]);for(let b of n){let T=h.renderToTexture.getTexture(b),S=e.getTerrainData(b.tileID);a.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,T.texture);let C=h.transform.calculatePosMatrix(b.tileID.toUnwrapped()),E=e.getMeshFrameDelta(h.transform.zoom),R=h.transform.calculateFogMatrix(b.tileID.toUnwrapped()),V=Aa(C,E,R,h.style.sky,h.transform.pitch);g.draw(a,o.TRIANGLES,m,ht.disabled,c,at.backCCW,V,S,"terrain",y.vertexBuffer,y.indexBuffer,y.segments)}}class qs{constructor(e,n,a){this.vertexBuffer=e,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}}class Zs{constructor(e,n){this.context=new Jl(e),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:p.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Be.maxUnderzooming+Be.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Ia}resize(e,n,a){if(this.width=Math.floor(e*a),this.height=Math.floor(n*a),this.pixelRatio=a,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let o of this.style._order)this.style._layers[o].resize()}setup(){let e=this.context,n=new p.aX;n.emplaceBack(0,0),n.emplaceBack(p.X,0),n.emplaceBack(0,p.X),n.emplaceBack(p.X,p.X),this.tileExtentBuffer=e.createVertexBuffer(n,$r.members),this.tileExtentSegments=p.a0.simpleSegment(0,0,4,2);let a=new p.aX;a.emplaceBack(0,0),a.emplaceBack(p.X,0),a.emplaceBack(0,p.X),a.emplaceBack(p.X,p.X),this.debugBuffer=e.createVertexBuffer(a,$r.members),this.debugSegments=p.a0.simpleSegment(0,0,4,5);let o=new p.$;o.emplaceBack(0,0,0,0),o.emplaceBack(p.X,0,p.X,0),o.emplaceBack(0,p.X,0,p.X),o.emplaceBack(p.X,p.X,p.X,p.X),this.rasterBoundsBuffer=e.createVertexBuffer(o,Ir.members),this.rasterBoundsSegments=p.a0.simpleSegment(0,0,4,2);let c=new p.aX;c.emplaceBack(0,0),c.emplaceBack(1,0),c.emplaceBack(0,1),c.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(c,$r.members),this.viewportSegments=p.a0.simpleSegment(0,0,4,2);let m=new p.aZ;m.emplaceBack(0),m.emplaceBack(1),m.emplaceBack(3),m.emplaceBack(2),m.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(m);let g=new p.aY;g.emplaceBack(0,1,2),g.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(g);let y=this.context.gl;this.stencilClearMode=new ht({func:y.ALWAYS,mask:0},0,255,y.ZERO,y.ZERO,y.ZERO)}clearStencil(){let e=this.context,n=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let a=p.H();p.aP(a,0,this.width,this.height,0,0,1),p.K(a,a,[n.drawingBufferWidth,n.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(e,n.TRIANGLES,Ze.disabled,this.stencilClearMode,bt.disabled,at.disabled,ii(a),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,n){if(this.currentStencilSource===e.source||!e.isTileClipped()||!n||!n.length)return;this.currentStencilSource=e.source;let a=this.context,o=a.gl;this.nextStencilID+n.length>256&&this.clearStencil(),a.setColorMode(bt.disabled),a.setDepthMode(Ze.disabled);let c=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(let m of n){let g=this._tileClippingMaskIDs[m.key]=this.nextStencilID++,y=this.style.map.terrain&&this.style.map.terrain.getTerrainData(m);c.draw(a,o.TRIANGLES,Ze.disabled,new ht({func:o.ALWAYS,mask:0},g,255,o.KEEP,o.KEEP,o.REPLACE),bt.disabled,at.disabled,ii(m.posMatrix),y,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let e=this.nextStencilID++,n=this.context.gl;return new ht({func:n.NOTEQUAL,mask:255},e,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(e){let n=this.context.gl;return new ht({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,n.KEEP,n.KEEP,n.REPLACE)}stencilConfigForOverlap(e){let n=this.context.gl,a=e.sort((m,g)=>g.overscaledZ-m.overscaledZ),o=a[a.length-1].overscaledZ,c=a[0].overscaledZ-o+1;if(c>1){this.currentStencilSource=void 0,this.nextStencilID+c>256&&this.clearStencil();let m={};for(let g=0;g({u_sky_color:$.properties.get("sky-color"),u_horizon_color:$.properties.get("horizon-color"),u_horizon:(Z.height/2+Z.getHorizon())*B,u_sky_horizon_blend:$.properties.get("sky-horizon-blend")*Z.height/2*B}))(b,y.style.map.transform,y.pixelRatio),E=new Ze(S.LEQUAL,Ze.ReadWrite,[0,1]),R=ht.disabled,V=y.colorModeForRenderPass(),U=y.useProgram("sky");if(!b.mesh){let $=new p.aX;$.emplaceBack(-1,-1),$.emplaceBack(1,-1),$.emplaceBack(1,1),$.emplaceBack(-1,1);let Z=new p.aY;Z.emplaceBack(0,1,2),Z.emplaceBack(0,2,3),b.mesh=new qs(T.createVertexBuffer($,$r.members),T.createIndexBuffer(Z),p.a0.simpleSegment(0,0,$.length,Z.length))}U.draw(T,S.TRIANGLES,E,R,V,at.disabled,C,void 0,"sky",b.mesh.vertexBuffer,b.mesh.indexBuffer,b.mesh.segments)}(this,this.style.sky),this._showOverdrawInspector=n.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=a.length-1;this.currentLayer>=0;this.currentLayer--){let y=this.style._layers[a[this.currentLayer]],b=o[y.source],T=c[y.source];this._renderTileClippingMasks(y,T),this.renderLayer(this,b,y,T)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayerU.source&&!U.isHidden(T)?[b.sourceCaches[U.source]]:[]),E=C.filter(U=>U.getSource().type==="vector"),R=C.filter(U=>U.getSource().type!=="vector"),V=U=>{(!S||S.getSource().maxzoomV(U)),S||R.forEach(U=>V(U)),S}(this.style,this.transform.zoom);y&&function(b,T,S){for(let C=0;C0),o&&(p.b0(n,a),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(c,m){let g=c.context,y=g.gl,b=bt.unblended,T=new Ze(y.LEQUAL,Ze.ReadWrite,[0,1]),S=m.getTerrainMesh(),C=m.sourceCache.getRenderableTiles(),E=c.useProgram("terrainDepth");g.bindFramebuffer.set(m.getFramebuffer("depth").framebuffer),g.viewport.set([0,0,c.width/devicePixelRatio,c.height/devicePixelRatio]),g.clear({color:p.aM.transparent,depth:1});for(let R of C){let V=m.getTerrainData(R.tileID),U={u_matrix:c.transform.calculatePosMatrix(R.tileID.toUnwrapped()),u_ele_delta:m.getMeshFrameDelta(c.transform.zoom)};E.draw(g,y.TRIANGLES,T,ht.disabled,b,at.backCCW,U,V,"terrain",S.vertexBuffer,S.indexBuffer,S.segments)}g.bindFramebuffer.set(null),g.viewport.set([0,0,c.width,c.height])}(this,this.style.map.terrain),function(c,m){let g=c.context,y=g.gl,b=bt.unblended,T=new Ze(y.LEQUAL,Ze.ReadWrite,[0,1]),S=m.getTerrainMesh(),C=m.getCoordsTexture(),E=m.sourceCache.getRenderableTiles(),R=c.useProgram("terrainCoords");g.bindFramebuffer.set(m.getFramebuffer("coords").framebuffer),g.viewport.set([0,0,c.width/devicePixelRatio,c.height/devicePixelRatio]),g.clear({color:p.aM.transparent,depth:1}),m.coordsIndex=[];for(let V of E){let U=m.getTerrainData(V.tileID);g.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,C.texture);let $={u_matrix:c.transform.calculatePosMatrix(V.tileID.toUnwrapped()),u_terrain_coords_id:(255-m.coordsIndex.length)/255,u_texture:0,u_ele_delta:m.getMeshFrameDelta(c.transform.zoom)};R.draw(g,y.TRIANGLES,T,ht.disabled,b,at.backCCW,$,U,"terrain",S.vertexBuffer,S.indexBuffer,S.segments),m.coordsIndex.push(V.tileID.key)}g.bindFramebuffer.set(null),g.viewport.set([0,0,c.width,c.height])}(this,this.style.map.terrain))}renderLayer(e,n,a,o){if(!a.isHidden(this.transform.zoom)&&(a.type==="background"||a.type==="custom"||(o||[]).length))switch(this.id=a.id,a.type){case"symbol":(function(c,m,g,y,b){if(c.renderPass!=="translucent")return;let T=ht.disabled,S=c.colorModeForRenderPass();(g._unevaluatedLayout.hasValue("text-variable-anchor")||g._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(C,E,R,V,U,$,Z,B,X){let K=E.transform,ee=Ur(),oe=U==="map",he=$==="map";for(let xe of C){let Te=V.getTile(xe),fe=Te.getBucket(R);if(!fe||!fe.text||!fe.text.segments.get().length)continue;let pe=p.ag(fe.textSizeData,K.zoom),Me=Ge(Te,1,E.transform.zoom),Ve=Ar(xe.posMatrix,he,oe,E.transform,Me),ge=R.layout.get("icon-text-fit")!=="none"&&fe.hasIconData();if(pe){let be=Math.pow(2,K.zoom-Te.tileID.overscaledZ),Fe=E.style.map.terrain?(Ue,He)=>E.style.map.terrain.getElevation(xe,Ue,He):null,pt=ee.translatePosition(K,Te,Z,B);yn(fe,oe,he,X,K,Ve,xe.posMatrix,be,pe,ge,ee,pt,xe.toUnwrapped(),Fe)}}}(y,c,g,m,g.layout.get("text-rotation-alignment"),g.layout.get("text-pitch-alignment"),g.paint.get("text-translate"),g.paint.get("text-translate-anchor"),b),g.paint.get("icon-opacity").constantOr(1)!==0&&ja(c,m,g,y,!1,g.paint.get("icon-translate"),g.paint.get("icon-translate-anchor"),g.layout.get("icon-rotation-alignment"),g.layout.get("icon-pitch-alignment"),g.layout.get("icon-keep-upright"),T,S),g.paint.get("text-opacity").constantOr(1)!==0&&ja(c,m,g,y,!0,g.paint.get("text-translate"),g.paint.get("text-translate-anchor"),g.layout.get("text-rotation-alignment"),g.layout.get("text-pitch-alignment"),g.layout.get("text-keep-upright"),T,S),m.map.showCollisionBoxes&&(ns(c,m,g,y,!0),ns(c,m,g,y,!1))})(e,n,a,o,this.style.placement.variableOffsets);break;case"circle":(function(c,m,g,y){if(c.renderPass!=="translucent")return;let b=g.paint.get("circle-opacity"),T=g.paint.get("circle-stroke-width"),S=g.paint.get("circle-stroke-opacity"),C=!g.layout.get("circle-sort-key").isConstant();if(b.constantOr(1)===0&&(T.constantOr(1)===0||S.constantOr(1)===0))return;let E=c.context,R=E.gl,V=c.depthModeForSublayer(0,Ze.ReadOnly),U=ht.disabled,$=c.colorModeForRenderPass(),Z=[];for(let B=0;BB.sortKey-X.sortKey);for(let B of Z){let{programConfiguration:X,program:K,layoutVertexBuffer:ee,indexBuffer:oe,uniformValues:he,terrainData:xe}=B.state;K.draw(E,R.TRIANGLES,V,U,$,at.disabled,he,xe,g.id,ee,oe,B.segments,g.paint,c.transform.zoom,X)}})(e,n,a,o);break;case"heatmap":(function(c,m,g,y){if(g.paint.get("heatmap-opacity")===0)return;let b=c.context;if(c.style.map.terrain){for(let T of y){let S=m.getTile(T);m.hasRenderableParent(T)||(c.renderPass==="offscreen"?$a(c,S,g,T):c.renderPass==="translucent"&&Kr(c,g,T))}b.viewport.set([0,0,c.width,c.height])}else c.renderPass==="offscreen"?function(T,S,C,E){let R=T.context,V=R.gl,U=ht.disabled,$=new bt([V.ONE,V.ONE],p.aM.transparent,[!0,!0,!0,!0]);(function(Z,B,X){let K=Z.gl;Z.activeTexture.set(K.TEXTURE1),Z.viewport.set([0,0,B.width/4,B.height/4]);let ee=X.heatmapFbos.get(p.aU);ee?(K.bindTexture(K.TEXTURE_2D,ee.colorAttachment.get()),Z.bindFramebuffer.set(ee.framebuffer)):(ee=as(Z,B.width/4,B.height/4),X.heatmapFbos.set(p.aU,ee))})(R,T,C),R.clear({color:p.aM.transparent});for(let Z=0;Z20&&T.texParameterf(T.TEXTURE_2D,b.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,b.extTextureFilterAnisotropicMax);let fe=c.style.map.terrain&&c.style.map.terrain.getTerrainData(Z),pe=fe?Z:null,Me=pe?pe.posMatrix:c.transform.calculatePosMatrix(Z.toUnwrapped(),$),Ve=Nl(Me,xe||[0,0],he||1,oe,g);S instanceof pr?C.draw(b,T.TRIANGLES,B,ht.disabled,E,at.disabled,Ve,fe,g.id,S.boundsBuffer,c.quadTriangleIndexBuffer,S.boundsSegments):C.draw(b,T.TRIANGLES,B,R[Z.overscaledZ],E,at.disabled,Ve,fe,g.id,c.rasterBoundsBuffer,c.quadTriangleIndexBuffer,c.rasterBoundsSegments)}})(e,n,a,o);break;case"background":(function(c,m,g,y){let b=g.paint.get("background-color"),T=g.paint.get("background-opacity");if(T===0)return;let S=c.context,C=S.gl,E=c.transform,R=E.tileSize,V=g.paint.get("background-pattern");if(c.isPatternMissing(V))return;let U=!V&&b.a===1&&T===1&&c.opaquePassEnabledForLayer()?"opaque":"translucent";if(c.renderPass!==U)return;let $=ht.disabled,Z=c.depthModeForSublayer(0,U==="opaque"?Ze.ReadWrite:Ze.ReadOnly),B=c.colorModeForRenderPass(),X=c.useProgram(V?"backgroundPattern":"background"),K=y||E.coveringTiles({tileSize:R,terrain:c.style.map.terrain});V&&(S.activeTexture.set(C.TEXTURE0),c.imageManager.bind(c.context));let ee=g.getCrossfadeParameters();for(let oe of K){let he=y?oe.posMatrix:c.transform.calculatePosMatrix(oe.toUnwrapped()),xe=V?ka(he,T,c,V,{tileID:oe,tileSize:R},ee):Rs(he,T,b),Te=c.style.map.terrain&&c.style.map.terrain.getTerrainData(oe);X.draw(S,C.TRIANGLES,Z,$,B,at.disabled,xe,Te,g.id,c.tileExtentBuffer,c.quadTriangleIndexBuffer,c.tileExtentSegments)}})(e,0,a,o);break;case"custom":(function(c,m,g){let y=c.context,b=g.implementation;if(c.renderPass==="offscreen"){let T=b.prerender;T&&(c.setCustomLayerDefaults(),y.setColorMode(c.colorModeForRenderPass()),T.call(b,y.gl,c.transform.customLayerMatrix()),y.setDirty(),c.setBaseState())}else if(c.renderPass==="translucent"){c.setCustomLayerDefaults(),y.setColorMode(c.colorModeForRenderPass()),y.setStencilMode(ht.disabled);let T=b.renderingMode==="3d"?new Ze(c.context.gl.LEQUAL,Ze.ReadWrite,c.depthRangeFor3D):c.depthModeForSublayer(0,Ze.ReadOnly);y.setDepthMode(T),b.render(y.gl,c.transform.customLayerMatrix(),{farZ:c.transform.farZ,nearZ:c.transform.nearZ,fov:c.transform._fov,modelViewProjectionMatrix:c.transform.modelViewProjectionMatrix,projectionMatrix:c.transform.projectionMatrix}),y.setDirty(),c.setBaseState(),y.bindFramebuffer.set(null)}})(e,0,a)}}translatePosMatrix(e,n,a,o,c){if(!a[0]&&!a[1])return e;let m=c?o==="map"?this.transform.angle:0:o==="viewport"?-this.transform.angle:0;if(m){let b=Math.sin(m),T=Math.cos(m);a=[a[0]*T-a[1]*b,a[0]*b+a[1]*T]}let g=[c?a[0]:Ge(n,a[0],this.transform.zoom),c?a[1]:Ge(n,a[1],this.transform.zoom),0],y=new Float32Array(16);return p.J(y,e,g),y}saveTileTexture(e){let n=this._tileTextures[e.size[0]];n?n.push(e):this._tileTextures[e.size[0]]=[e]}getTileTexture(e){let n=this._tileTextures[e];return n&&n.length>0?n.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;let n=this.imageManager.getPattern(e.from.toString()),a=this.imageManager.getPattern(e.to.toString());return!n||!a}useProgram(e,n){this.cache=this.cache||{};let a=e+(n?n.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[a]||(this.cache[a]=new Ma(this.context,Mr[e],n,za[e],this._showOverdrawInspector,this.style.map.terrain)),this.cache[a]}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(){let e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new st(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){let{drawingBufferWidth:e,drawingBufferHeight:n}=this.context.gl;return this.width!==e||this.height!==n}}class Tn{constructor(e,n){this.points=e,this.planes=n}static fromInvProjectionMatrix(e,n,a){let o=Math.pow(2,a),c=[[-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(g=>{let y=1/(g=p.af([],g,e))[3]/n*o;return p.b1(g,g,[y,y,1/g[3],y])}),m=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(g=>{let y=function(C,E){var R=E[0],V=E[1],U=E[2],$=R*R+V*V+U*U;return $>0&&($=1/Math.sqrt($)),C[0]=E[0]*$,C[1]=E[1]*$,C[2]=E[2]*$,C}([],function(C,E,R){var V=E[0],U=E[1],$=E[2],Z=R[0],B=R[1],X=R[2];return C[0]=U*X-$*B,C[1]=$*Z-V*X,C[2]=V*B-U*Z,C}([],vi([],c[g[0]],c[g[1]]),vi([],c[g[2]],c[g[1]]))),b=-((T=y)[0]*(S=c[g[1]])[0]+T[1]*S[1]+T[2]*S[2]);var T,S;return y.concat(b)});return new Tn(c,m)}}class Sn{constructor(e,n){this.min=e,this.max=n,this.center=function(a,o,c){return a[0]=.5*o[0],a[1]=.5*o[1],a[2]=.5*o[2],a}([],function(a,o,c){return a[0]=o[0]+c[0],a[1]=o[1]+c[1],a[2]=o[2]+c[2],a}([],this.min,this.max))}quadrant(e){let n=[e%2==0,e<2],a=zi(this.min),o=zi(this.max);for(let c=0;c=0&&m++;if(m===0)return 0;m!==n.length&&(a=!1)}if(a)return 2;for(let o=0;o<3;o++){let c=Number.MAX_VALUE,m=-Number.MAX_VALUE;for(let g=0;gthis.max[o]-this.min[o])return 0}return 1}}class In{constructor(e=0,n=0,a=0,o=0){if(isNaN(e)||e<0||isNaN(n)||n<0||isNaN(a)||a<0||isNaN(o)||o<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=n,this.left=a,this.right=o}interpolate(e,n,a){return n.top!=null&&e.top!=null&&(this.top=p.y.number(e.top,n.top,a)),n.bottom!=null&&e.bottom!=null&&(this.bottom=p.y.number(e.bottom,n.bottom,a)),n.left!=null&&e.left!=null&&(this.left=p.y.number(e.left,n.left,a)),n.right!=null&&e.right!=null&&(this.right=p.y.number(e.right,n.right,a)),this}getCenter(e,n){let a=p.ac((this.left+e-this.right)/2,0,e),o=p.ac((this.top+n-this.bottom)/2,0,n);return new p.P(a,o)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new In(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}let Za=85.051129;class Pn{constructor(e,n,a,o,c){this.tileSize=512,this._renderWorldCopies=c===void 0||!!c,this._minZoom=e||0,this._maxZoom=n||22,this._minPitch=a??0,this._maxPitch=o??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new p.N(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new In,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={},this.minElevationForCurrentTile=0}clone(){let e=new Pn(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return e.apply(this),e}apply(e){this.tileSize=e.tileSize,this.latRange=e.latRange,this.lngRange=e.lngRange,this.width=e.width,this.height=e.height,this._center=e._center,this._elevation=e._elevation,this.minElevationForCurrentTile=e.minElevationForCurrentTile,this.zoom=e.zoom,this.angle=e.angle,this._fov=e._fov,this._pitch=e._pitch,this._unmodified=e._unmodified,this._edgeInsets=e._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(e){e===void 0?e=!0:e===null&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new p.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(e){let n=-p.b3(e,-180,180)*Math.PI/180;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=function(){var a=new p.A(4);return p.A!=Float32Array&&(a[1]=0,a[2]=0),a[0]=1,a[3]=1,a}(),function(a,o,c){var m=o[0],g=o[1],y=o[2],b=o[3],T=Math.sin(c),S=Math.cos(c);a[0]=m*S+y*T,a[1]=g*S+b*T,a[2]=m*-T+y*S,a[3]=g*-T+b*S}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(e){let n=p.ac(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(e){e=Math.max(.01,Math.min(60,e)),this._fov!==e&&(this._unmodified=!1,this._fov=e/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(e){let n=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this.tileZoom=Math.max(0,Math.floor(n)),this.scale=this.zoomScale(n),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(e){e!==this._elevation&&(this._elevation=e,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,n,a){this._unmodified=!1,this._edgeInsets.interpolate(e,n,a),this._constrain(),this._calcMatrices()}coveringZoomLevel(e){let n=(e.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/e.tileSize));return Math.max(0,n)}getVisibleUnwrappedCoordinates(e){let n=[new p.b4(0,e)];if(this._renderWorldCopies){let a=this.pointCoordinate(new p.P(0,0)),o=this.pointCoordinate(new p.P(this.width,0)),c=this.pointCoordinate(new p.P(this.width,this.height)),m=this.pointCoordinate(new p.P(0,this.height)),g=Math.floor(Math.min(a.x,o.x,c.x,m.x)),y=Math.floor(Math.max(a.x,o.x,c.x,m.x)),b=1;for(let T=g-b;T<=y+b;T++)T!==0&&n.push(new p.b4(T,e))}return n}coveringTiles(e){var n,a;let o=this.coveringZoomLevel(e),c=o;if(e.minzoom!==void 0&&oe.maxzoom&&(o=e.maxzoom);let m=this.pointCoordinate(this.getCameraPoint()),g=p.Z.fromLngLat(this.center),y=Math.pow(2,o),b=[y*m.x,y*m.y,0],T=[y*g.x,y*g.y,0],S=Tn.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,o),C=e.minzoom||0;!e.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(C=o);let E=e.terrain?2/Math.min(this.tileSize,e.tileSize)*this.tileSize:3,R=B=>({aabb:new Sn([B*y,0,0],[(B+1)*y,y,0]),zoom:0,x:0,y:0,wrap:B,fullyVisible:!1}),V=[],U=[],$=o,Z=e.reparseOverscaled?c:o;if(this._renderWorldCopies)for(let B=1;B<=3;B++)V.push(R(-B)),V.push(R(B));for(V.push(R(0));V.length>0;){let B=V.pop(),X=B.x,K=B.y,ee=B.fullyVisible;if(!ee){let fe=B.aabb.intersects(S);if(fe===0)continue;ee=fe===2}let oe=e.terrain?b:T,he=B.aabb.distanceX(oe),xe=B.aabb.distanceY(oe),Te=Math.max(Math.abs(he),Math.abs(xe));if(B.zoom===$||Te>E+(1<<$-B.zoom)-2&&B.zoom>=C){let fe=$-B.zoom,pe=b[0]-.5-(X<>1),Ve=B.zoom+1,ge=B.aabb.quadrant(fe);if(e.terrain){let be=new p.S(Ve,B.wrap,Ve,pe,Me),Fe=e.terrain.getMinMaxElevation(be),pt=(n=Fe.minElevation)!==null&&n!==void 0?n:this.elevation,Ue=(a=Fe.maxElevation)!==null&&a!==void 0?a:this.elevation;ge=new Sn([ge.min[0],ge.min[1],pt],[ge.max[0],ge.max[1],Ue])}V.push({aabb:ge,zoom:Ve,x:pe,y:Me,wrap:B.wrap,fullyVisible:ee})}}return U.sort((B,X)=>B.distanceSq-X.distanceSq).map(B=>B.tileID)}resize(e,n){this.width=e,this.height=n,this.pixelsToGLUnits=[2/e,-2/n],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(e){let n=p.ac(e.lat,-85.051129,Za);return new p.P(p.O(e.lng)*this.worldSize,p.Q(n)*this.worldSize)}unproject(e){return new p.Z(e.x/this.worldSize,e.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}getCameraPosition(){return{lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(e){let n=this.elevation,a=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,o=this.pointLocation(this.centerPoint,e),c=e.getElevationForLngLatZoom(o,this.tileZoom);if(!(this.elevation-c))return;let m=a+n-c,g=Math.cos(this._pitch)*this.cameraToCenterDistance/m/p.b5(1,o.lat),y=this.scaleZoom(g/this.tileSize);this._elevation=c,this._center=o,this.zoom=y}setLocationAtPoint(e,n){let a=this.pointCoordinate(n),o=this.pointCoordinate(this.centerPoint),c=this.locationCoordinate(e),m=new p.Z(c.x-(a.x-o.x),c.y-(a.y-o.y));this.center=this.coordinateLocation(m),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(e,n){return n?this.coordinatePoint(this.locationCoordinate(e),n.getElevationForLngLatZoom(e,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(e))}pointLocation(e,n){return this.coordinateLocation(this.pointCoordinate(e,n))}locationCoordinate(e){return p.Z.fromLngLat(e)}coordinateLocation(e){return e&&e.toLngLat()}pointCoordinate(e,n){if(n){let C=n.pointCoordinate(e);if(C!=null)return C}let a=[e.x,e.y,0,1],o=[e.x,e.y,1,1];p.af(a,a,this.pixelMatrixInverse),p.af(o,o,this.pixelMatrixInverse);let c=a[3],m=o[3],g=a[1]/c,y=o[1]/m,b=a[2]/c,T=o[2]/m,S=b===T?0:(0-b)/(T-b);return new p.Z(p.y.number(a[0]/c,o[0]/m,S)/this.worldSize,p.y.number(g,y,S)/this.worldSize)}coordinatePoint(e,n=0,a=this.pixelMatrix){let o=[e.x*this.worldSize,e.y*this.worldSize,n,1];return p.af(o,o,a),new p.P(o[0]/o[3],o[1]/o[3])}getBounds(){let e=Math.max(0,this.height/2-this.getHorizon());return new ie().extend(this.pointLocation(new p.P(0,e))).extend(this.pointLocation(new p.P(this.width,e))).extend(this.pointLocation(new p.P(this.width,this.height))).extend(this.pointLocation(new p.P(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new ie([this.lngRange[0],this.latRange[0]],[this.lngRange[1],this.latRange[1]]):null}getHorizon(){return Math.tan(Math.PI/2-this._pitch)*this.cameraToCenterDistance*.85}setMaxBounds(e){e?(this.lngRange=[e.getWest(),e.getEast()],this.latRange=[e.getSouth(),e.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-85.051129,Za])}calculateTileMatrix(e){let n=e.canonical,a=this.worldSize/this.zoomScale(n.z),o=n.x+Math.pow(2,n.z)*e.wrap,c=p.an(new Float64Array(16));return p.J(c,c,[o*a,n.y*a,0]),p.K(c,c,[a/p.X,a/p.X,1]),c}calculatePosMatrix(e,n=!1){let a=e.key,o=n?this._alignedPosMatrixCache:this._posMatrixCache;if(o[a])return o[a];let c=this.calculateTileMatrix(e);return p.L(c,n?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,c),o[a]=new Float32Array(c),o[a]}calculateFogMatrix(e){let n=e.key,a=this._fogMatrixCache;if(a[n])return a[n];let o=this.calculateTileMatrix(e);return p.L(o,this.fogMatrix,o),a[n]=new Float32Array(o),a[n]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(e,n){n=p.ac(+n,this.minZoom,this.maxZoom);let a={center:new p.N(e.lng,e.lat),zoom:n},o=this.lngRange;if(!this._renderWorldCopies&&o===null){let B=179.9999999999;o=[-B,B]}let c=this.tileSize*this.zoomScale(a.zoom),m=0,g=c,y=0,b=c,T=0,S=0,{x:C,y:E}=this.size;if(this.latRange){let B=this.latRange;m=p.Q(B[1])*c,g=p.Q(B[0])*c,g-mg&&($=g-B)}if(o){let B=(y+b)/2,X=R;this._renderWorldCopies&&(X=p.b3(R,B-c/2,B+c/2));let K=C/2;X-Kb&&(U=b-K)}if(U!==void 0||$!==void 0){let B=new p.P(U??R,$??V);a.center=this.unproject.call({worldSize:c},B).wrap()}return a}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let e=this._unmodified,{center:n,zoom:a}=this.getConstrained(this.center,this.zoom);this.center=n,this.zoom=a,this._unmodified=e,this._constraining=!1}_calcMatrices(){if(!this.height)return;let e=this.centerOffset,n=this.point.x,a=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=p.b5(1,this.center.lat)*this.worldSize;let o=p.an(new Float64Array(16));p.K(o,o,[this.width/2,-this.height/2,1]),p.J(o,o,[1,-1,0]),this.labelPlaneMatrix=o,o=p.an(new Float64Array(16)),p.K(o,o,[1,-1,1]),p.J(o,o,[-1,-1,0]),p.K(o,o,[2/this.width,2/this.height,1]),this.glCoordMatrix=o;let c=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),m=Math.min(this.elevation,this.minElevationForCurrentTile),g=c-m*this._pixelPerMeter/Math.cos(this._pitch),y=m<0?g:c,b=Math.PI/2+this._pitch,T=this._fov*(.5+e.y/this.height),S=Math.sin(T)*y/Math.sin(p.ac(Math.PI-b-T,.01,Math.PI-.01)),C=this.getHorizon(),E=2*Math.atan(C/this.cameraToCenterDistance)*(.5+e.y/(2*C)),R=Math.sin(E)*y/Math.sin(p.ac(Math.PI-b-E,.01,Math.PI-.01)),V=Math.min(S,R);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*V+y),this.nearZ=this.height/50,o=new Float64Array(16),p.b6(o,this._fov,this.width/this.height,this.nearZ,this.farZ),o[8]=2*-e.x/this.width,o[9]=2*e.y/this.height,this.projectionMatrix=p.ae(o),p.K(o,o,[1,-1,1]),p.J(o,o,[0,0,-this.cameraToCenterDistance]),p.b7(o,o,this._pitch),p.ad(o,o,this.angle),p.J(o,o,[-n,-a,0]),this.mercatorMatrix=p.K([],o,[this.worldSize,this.worldSize,this.worldSize]),p.K(o,o,[1,1,this._pixelPerMeter]),this.pixelMatrix=p.L(new Float64Array(16),this.labelPlaneMatrix,o),p.J(o,o,[0,0,-this.elevation]),this.modelViewProjectionMatrix=o,this.invModelViewProjectionMatrix=p.as([],o),this.fogMatrix=new Float64Array(16),p.b6(this.fogMatrix,this._fov,this.width/this.height,c,this.farZ),this.fogMatrix[8]=2*-e.x/this.width,this.fogMatrix[9]=2*e.y/this.height,p.K(this.fogMatrix,this.fogMatrix,[1,-1,1]),p.J(this.fogMatrix,this.fogMatrix,[0,0,-this.cameraToCenterDistance]),p.b7(this.fogMatrix,this.fogMatrix,this._pitch),p.ad(this.fogMatrix,this.fogMatrix,this.angle),p.J(this.fogMatrix,this.fogMatrix,[-n,-a,0]),p.K(this.fogMatrix,this.fogMatrix,[1,1,this._pixelPerMeter]),p.J(this.fogMatrix,this.fogMatrix,[0,0,-this.elevation]),this.pixelMatrix3D=p.L(new Float64Array(16),this.labelPlaneMatrix,o);let U=this.width%2/2,$=this.height%2/2,Z=Math.cos(this.angle),B=Math.sin(this.angle),X=n-Math.round(n)+Z*U+B*$,K=a-Math.round(a)+Z*$+B*U,ee=new Float64Array(o);if(p.J(ee,ee,[X>.5?X-1:X,K>.5?K-1:K,0]),this.alignedModelViewProjectionMatrix=ee,o=p.as(new Float64Array(16),this.pixelMatrix),!o)throw new Error("failed to invert matrix");this.pixelMatrixInverse=o,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;let e=this.pointCoordinate(new p.P(0,0)),n=[e.x*this.worldSize,e.y*this.worldSize,0,1];return p.af(n,n,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){let e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new p.P(0,e))}getCameraQueryGeometry(e){let n=this.getCameraPoint();if(e.length===1)return[e[0],n];{let a=n.x,o=n.y,c=n.x,m=n.y;for(let g of e)a=Math.min(a,g.x),o=Math.min(o,g.y),c=Math.max(c,g.x),m=Math.max(m,g.y);return[new p.P(a,o),new p.P(c,o),new p.P(c,m),new p.P(a,m),new p.P(a,o)]}}lngLatToCameraDepth(e,n){let a=this.locationCoordinate(e),o=[a.x*this.worldSize,a.y*this.worldSize,n,1];return p.af(o,o,this.modelViewProjectionMatrix),o[2]/o[3]}}function cs(h,e){let n,a=!1,o=null,c=null,m=()=>{o=null,a&&(h.apply(c,n),o=setTimeout(m,e),a=!1)};return(...g)=>(a=!0,c=this,n=g,o||m(),o)}class Gs{constructor(e){this._getCurrentHash=()=>{let n=window.location.hash.replace("#","");if(this._hashName){let a;return n.split("&").map(o=>o.split("=")).forEach(o=>{o[0]===this._hashName&&(a=o)}),(a&&a[1]||"").split("/")}return n.split("/")},this._onHashChange=()=>{let n=this._getCurrentHash();if(n.length>=3&&!n.some(a=>isNaN(a))){let 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}return!1},this._updateHashUnthrottled=()=>{let n=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,n)},this._removeHash=()=>{let n=this._getCurrentHash();if(n.length===0)return;let a=n.join("/"),o=a;o.split("&").length>0&&(o=o.split("&")[0]),this._hashName&&(o=`${this._hashName}=${a}`);let c=window.location.hash.replace(o,"");c.startsWith("#&")?c=c.slice(0,1)+c.slice(2):c==="#"&&(c="");let m=window.location.href.replace(/(#.+)?$/,c);m=m.replace("&&","&"),window.history.replaceState(window.history.state,null,m)},this._updateHash=cs(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){let n=this._map.getCenter(),a=Math.round(100*this._map.getZoom())/100,o=Math.ceil((a*Math.LN2+Math.log(512/360/.5))/Math.LN10),c=Math.pow(10,o),m=Math.round(n.lng*c)/c,g=Math.round(n.lat*c)/c,y=this._map.getBearing(),b=this._map.getPitch(),T="";if(T+=e?`/${m}/${g}/${a}`:`${a}/${g}/${m}`,(y||b)&&(T+="/"+Math.round(10*y)/10),b&&(T+=`/${Math.round(b)}`),this._hashName){let S=this._hashName,C=!1,E=window.location.hash.slice(1).split("&").map(R=>{let V=R.split("=")[0];return V===S?(C=!0,`${V}=${T}`):R}).filter(R=>R);return C||E.push(`${S}=${T}`),`#${E.join("&")}`}return`#${T}`}}let Hs={linearity:.3,easing:p.b8(0,0,.3,1)},Ga=p.e({deceleration:2500,maxSpeed:1400},Hs),Ql=p.e({deceleration:20,maxSpeed:1400},Hs),tl=p.e({deceleration:1e3,maxSpeed:360},Hs),Xs=p.e({deceleration:1e3,maxSpeed:90},Hs);class Ha{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:me.now(),settings:e})}_drainInertiaBuffer(){let e=this._inertiaBuffer,n=me.now();for(;e.length>0&&n-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;let n={zoom:0,bearing:0,pitch:0,pan:new p.P(0,0),pinchAround:void 0,around:void 0};for(let{settings:c}of this._inertiaBuffer)n.zoom+=c.zoomDelta||0,n.bearing+=c.bearingDelta||0,n.pitch+=c.pitchDelta||0,c.panDelta&&n.pan._add(c.panDelta),c.around&&(n.around=c.around),c.pinchAround&&(n.pinchAround=c.pinchAround);let a=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,o={};if(n.pan.mag()){let c=us(n.pan.mag(),a,p.e({},Ga,e||{}));o.offset=n.pan.mult(c.amount/n.pan.mag()),o.center=this._map.transform.center,hs(o,c)}if(n.zoom){let c=us(n.zoom,a,Ql);o.zoom=this._map.transform.zoom+c.amount,hs(o,c)}if(n.bearing){let c=us(n.bearing,a,tl);o.bearing=this._map.transform.bearing+p.ac(c.amount,-179,179),hs(o,c)}if(n.pitch){let c=us(n.pitch,a,Xs);o.pitch=this._map.transform.pitch+c.amount,hs(o,c)}if(o.zoom||o.bearing){let c=n.pinchAround===void 0?n.around:n.pinchAround;o.around=c?this._map.unproject(c):this._map.getCenter()}return this.clear(),p.e(o,{noMoveStart:!0})}}function hs(h,e){(!h.duration||h.durationn.unproject(y)),g=c.reduce((y,b,T,S)=>y.add(b.div(S.length)),new p.P(0,0));super(e,{points:c,point:g,lngLats:m,lngLat:n.unproject(g),originalEvent:a}),this._defaultPrevented=!1}}class il extends p.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,a){super(e,{originalEvent:a}),this._defaultPrevented=!1}}class rl{constructor(e,n){this._map=e,this._clickTolerance=n.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new il(e.type,this._map,e))}mousedown(e,n){return this._mousedownPos=n,this._firePreventable(new Ot(e.type,this._map,e))}mouseup(e){this._map.fire(new Ot(e.type,this._map,e))}click(e,n){this._mousedownPos&&this._mousedownPos.dist(n)>=this._clickTolerance||this._map.fire(new Ot(e.type,this._map,e))}dblclick(e){return this._firePreventable(new Ot(e.type,this._map,e))}mouseover(e){this._map.fire(new Ot(e.type,this._map,e))}mouseout(e){this._map.fire(new Ot(e.type,this._map,e))}touchstart(e){return this._firePreventable(new Jr(e.type,this._map,e))}touchmove(e){this._map.fire(new Jr(e.type,this._map,e))}touchend(e){this._map.fire(new Jr(e.type,this._map,e))}touchcancel(e){this._map.fire(new Jr(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class wt{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new Ot(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Ot("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new Ot(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Oi{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.pointLocation(p.P.convert(e),this._map.terrain)}}class mi{constructor(e,n){this._map=e,this._tr=new Oi(e),this._el=e.getCanvasContainer(),this._container=e.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(e,n){this.isEnabled()&&e.shiftKey&&e.button===0&&(se.disableDrag(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(e,n){if(!this._active)return;let a=n;if(this._lastPos.equals(a)||!this._box&&a.dist(this._startPos)c.fitScreenCoordinates(a,o,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&e.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(se.remove(this._box),this._box=null),se.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,n){return this._map.fire(new p.k(e,{originalEvent:n}))}}function ds(h,e){if(h.length!==e.length)throw new Error(`The number of touches and points are not equal - touches ${h.length}, points ${e.length}`);let n={};for(let a=0;athis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=e.timeStamp),a.length===this.numTouches&&(this.centroid=function(o){let c=new p.P(0,0);for(let m of o)c._add(m);return c.div(o.length)}(n),this.touches=ds(a,n)))}touchmove(e,n,a){if(this.aborted||!this.centroid)return;let o=ds(a,n);for(let c in this.touches){let m=o[c];(!m||m.dist(this.touches[c])>30)&&(this.aborted=!0)}}touchend(e,n,a){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),a.length===0){let o=!this.aborted&&this.centroid;if(this.reset(),o)return o}}}class Ws{constructor(e){this.singleTap=new Xa(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,n,a){this.singleTap.touchstart(e,n,a)}touchmove(e,n,a){this.singleTap.touchmove(e,n,a)}touchend(e,n,a){let o=this.singleTap.touchend(e,n,a);if(o){let c=e.timeStamp-this.lastTime<500,m=!this.lastTap||this.lastTap.dist(o)<30;if(c&&m||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=o,this.count===this.numTaps)return this.reset(),o}}}class An{constructor(e){this._tr=new Oi(e),this._zoomIn=new Ws({numTouches:1,numTaps:2}),this._zoomOut=new Ws({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,n,a){this._zoomIn.touchstart(e,n,a),this._zoomOut.touchstart(e,n,a)}touchmove(e,n,a){this._zoomIn.touchmove(e,n,a),this._zoomOut.touchmove(e,n,a)}touchend(e,n,a){let o=this._zoomIn.touchend(e,n,a),c=this._zoomOut.touchend(e,n,a),m=this._tr;return o?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:g=>g.easeTo({duration:300,zoom:m.zoom+1,around:m.unproject(o)},{originalEvent:e})}):c?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:g=>g.easeTo({duration:300,zoom:m.zoom-1,around:m.unproject(c)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class _r{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){let n=this._moveFunction(...e);if(n.bearingDelta||n.pitchDelta||n.around||n.panDelta)return this._active=!0,n}dragStart(e,n){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=n.length?n[0]:n,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,n){if(!this.isEnabled())return;let a=this._lastPoint;if(!a)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);let o=n.length?n[0]:n;return!this._moved&&o.dist(a){h.mousedown=h.dragStart,h.mousemoveWindow=h.dragMove,h.mouseup=h.dragEnd,h.contextmenu=e=>{e.preventDefault()}},Ja=({enable:h,clickTolerance:e,bearingDegreesPerPixelMoved:n=.8})=>{let a=new Ks({checkCorrectEvent:o=>se.mouseButton(o)===0&&o.ctrlKey||se.mouseButton(o)===2});return new _r({clickTolerance:e,move:(o,c)=>({bearingDelta:(c.x-o.x)*n}),moveStateManager:a,enable:h,assignEvents:Js})},Ya=({enable:h,clickTolerance:e,pitchDegreesPerPixelMoved:n=-.5})=>{let a=new Ks({checkCorrectEvent:o=>se.mouseButton(o)===0&&o.ctrlKey||se.mouseButton(o)===2});return new _r({clickTolerance:e,move:(o,c)=>({pitchDelta:(c.y-o.y)*n}),moveStateManager:a,enable:h,assignEvents:Js})};class Yr{constructor(e,n){this._clickTolerance=e.clickTolerance||1,this._map=n,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new p.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,n,a){return this._calculateTransform(e,n,a)}touchmove(e,n,a){if(this._active){if(!this._shouldBePrevented(a.length))return e.preventDefault(),this._calculateTransform(e,n,a);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,n,a){this._calculateTransform(e,n,a),this._active&&this._shouldBePrevented(a.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,n,a){a.length>0&&(this._active=!0);let o=ds(a,n),c=new p.P(0,0),m=new p.P(0,0),g=0;for(let b in o){let T=o[b],S=this._touches[b];S&&(c._add(T),m._add(T.sub(S)),g++,o[b]=T)}if(this._touches=o,this._shouldBePrevented(g)||!m.mag())return;let y=m.div(g);return this._sum._add(y),this._sum.mag()Math.abs(h.x)}class Mn extends Ys{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,n,a){super.touchstart(e,n,a),this._currentTouchCount=a.length}_start(e){this._lastPoints=e,Qs(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,n,a){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let o=e[0].sub(this._lastPoints[0]),c=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(o,c,a.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(o.y+c.y)/2*-.5}):void 0}gestureBeginsVertically(e,n,a){if(this._valid!==void 0)return this._valid;let o=e.mag()>=2,c=n.mag()>=2;if(!o&&!c)return;if(!o||!c)return this._firstMove===void 0&&(this._firstMove=a),a-this._firstMove<100&&void 0;let m=e.y>0==n.y>0;return Qs(e)&&Qs(n)&&m}}let nl={panStep:100,bearingStep:15,pitchStep:10};class Si{constructor(e){this._tr=new Oi(e);let n=nl;this._panStep=n.panStep,this._bearingStep=n.bearingStep,this._pitchStep=n.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let n=0,a=0,o=0,c=0,m=0;switch(e.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:e.shiftKey?a=-1:(e.preventDefault(),c=-1);break;case 39:e.shiftKey?a=1:(e.preventDefault(),c=1);break;case 38:e.shiftKey?o=1:(e.preventDefault(),m=-1);break;case 40:e.shiftKey?o=-1:(e.preventDefault(),m=1);break;default:return}return this._rotationDisabled&&(a=0,o=0),{cameraAnimation:g=>{let y=this._tr;g.easeTo({duration:300,easeId:"keyboardHandler",easing:nr,zoom:n?Math.round(y.zoom)+n*(e.shiftKey?2:1):y.zoom,bearing:y.bearing+a*this._bearingStep,pitch:y.pitch+o*this._pitchStep,offset:[-c*this._panStep,-m*this._panStep],center:y.center},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function nr(h){return h*(2-h)}let ro=4.000244140625;class Vi{constructor(e,n){this._onTimeout=a=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(a)},this._map=e,this._tr=new Oi(e),this._triggerRenderFrame=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&e.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let n=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY,a=me.now(),o=a-(this._lastWheelEventTime||0);this._lastWheelEventTime=a,n!==0&&n%ro==0?this._type="wheel":n!==0&&Math.abs(n)<4?this._type="trackpad":o>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(o*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),e.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=e,this._delta-=n,this._active||this._start(e)),e.preventDefault()}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);let n=se.mousePos(this._map.getCanvas(),e),a=this._tr;this._around=n.y>a.transform.height/2-a.transform.getHorizon()?p.N.convert(this._aroundCenter?a.center:a.unproject(n)):p.N.convert(a.center),this._aroundPoint=a.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;let e=this._tr.transform;if(this._delta!==0){let y=this._type==="wheel"&&Math.abs(this._delta)>ro?this._wheelZoomRate:this._defaultZoomRate,b=2/(1+Math.exp(-Math.abs(this._delta*y)));this._delta<0&&b!==0&&(b=1/b);let T=typeof this._targetZoom=="number"?e.zoomScale(this._targetZoom):e.scale;this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,e.scaleZoom(T*b))),this._type==="wheel"&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let n=typeof this._targetZoom=="number"?this._targetZoom:e.zoom,a=this._startZoom,o=this._easing,c,m=!1,g=me.now()-this._lastWheelEventTime;if(this._type==="wheel"&&a&&o&&g){let y=Math.min(g/200,1),b=o(y);c=p.y.number(a,n,b),y<1?this._frameId||(this._frameId=!0):m=!0}else c=n,m=!0;return this._active=!0,m&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!m,zoomDelta:c-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let n=p.b9;if(this._prevEase){let a=this._prevEase,o=(me.now()-a.start)/a.duration,c=a.easing(o+.01)-a.easing(o),m=.27/Math.sqrt(c*c+1e-4)*.01,g=Math.sqrt(.0729-m*m);n=p.b8(m,g,.25,1)}return this._prevEase={start:me.now(),duration:e,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Qr{constructor(e,n){this._clickZoom=e,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 ec{constructor(e){this._tr=new Oi(e),this.reset()}reset(){this._active=!1}dblclick(e,n){return e.preventDefault(),{cameraAnimation:a=>{a.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(n)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class tc{constructor(){this._tap=new Ws({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,n,a){if(!this._swipePoint)if(this._tapTime){let o=n[0],c=e.timeStamp-this._tapTime<500,m=this._tapPoint.dist(o)<30;c&&m?a.length>0&&(this._swipePoint=o,this._swipeTouch=a[0].identifier):this.reset()}else this._tap.touchstart(e,n,a)}touchmove(e,n,a){if(this._tapTime){if(this._swipePoint){if(a[0].identifier!==this._swipeTouch)return;let o=n[0],c=o.y-this._swipePoint.y;return this._swipePoint=o,e.preventDefault(),this._active=!0,{zoomDelta:c/128}}}else this._tap.touchmove(e,n,a)}touchend(e,n,a){if(this._tapTime)this._swipePoint&&a.length===0&&this.reset();else{let o=this._tap.touchend(e,n,a);o&&(this._tapTime=e.timeStamp,this._tapPoint=o)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class sl{constructor(e,n,a){this._el=e,this._mousePan=n,this._touchPan=a}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class al{constructor(e,n,a){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=n,this._mousePitch=a}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class no{constructor(e,n,a,o){this._el=e,this._touchZoom=n,this._touchRotate=a,this._tapDragZoom=o,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class Cn{constructor(e,n){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=e,this._options=n,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;let e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=se.create("div","maplibregl-cooperative-gesture-screen",e);let n=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(n=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));let a=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),o=document.createElement("div");o.className="maplibregl-desktop-message",o.textContent=n,this._container.appendChild(o);let c=document.createElement("div");c.className="maplibregl-mobile-message",c.textContent=a,this._container.appendChild(c),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(se.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,n){this._enabled&&(this._map.fire(new p.k("cooperativegestureprevented",{gestureType:e,originalEvent:n})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}let Ii=h=>h.zoom||h.drag||h.pitch||h.rotate;class Ie extends p.k{}function ea(h){return h.panDelta&&h.panDelta.mag()||h.zoomDelta||h.bearingDelta||h.pitchDelta}class so{constructor(e,n){this.handleWindowEvent=o=>{this.handleEvent(o,`${o.type}Window`)},this.handleEvent=(o,c)=>{if(o.type==="blur")return void this.stop(!0);this._updatingCamera=!0;let m=o.type==="renderFrame"?void 0:o,g={needsRenderFrame:!1},y={},b={},T=o.touches,S=T?this._getMapTouches(T):void 0,C=S?se.touchPos(this._map.getCanvas(),S):se.mousePos(this._map.getCanvas(),o);for(let{handlerName:V,handler:U,allowed:$}of this._handlers){if(!U.isEnabled())continue;let Z;this._blockedByActive(b,$,V)?U.reset():U[c||o.type]&&(Z=U[c||o.type](o,C,S),this.mergeHandlerResult(g,y,Z,V,m),Z&&Z.needsRenderFrame&&this._triggerRenderFrame()),(Z||U.isActive())&&(b[V]=U)}let E={};for(let V in this._previousActiveHandlers)b[V]||(E[V]=m);this._previousActiveHandlers=b,(Object.keys(E).length||ea(g))&&(this._changes.push([g,y,E]),this._triggerRenderFrame()),(Object.keys(b).length||ea(g))&&this._map._stop(!0),this._updatingCamera=!1;let{cameraAnimation:R}=g;R&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],R(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Ha(e),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n);let 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(let[o,c,m]of this._listeners)se.addEventListener(o,c,o===document?this.handleWindowEvent:this.handleEvent,m)}destroy(){for(let[e,n,a]of this._listeners)se.removeEventListener(e,n,e===document?this.handleWindowEvent:this.handleEvent,a)}_addDefaultHandlers(e){let n=this._map,a=n.getCanvasContainer();this._add("mapEvent",new rl(n,e));let o=n.boxZoom=new mi(n,e);this._add("boxZoom",o),e.interactive&&e.boxZoom&&o.enable();let c=n.cooperativeGestures=new Cn(n,e.cooperativeGestures);this._add("cooperativeGestures",c),e.cooperativeGestures&&c.enable();let m=new An(n),g=new ec(n);n.doubleClickZoom=new Qr(g,m),this._add("tapZoom",m),this._add("clickZoom",g),e.interactive&&e.doubleClickZoom&&n.doubleClickZoom.enable();let y=new tc;this._add("tapDragZoom",y);let b=n.touchPitch=new Mn(n);this._add("touchPitch",b),e.interactive&&e.touchPitch&&n.touchPitch.enable(e.touchPitch);let T=Ja(e),S=Ya(e);n.dragRotate=new al(e,T,S),this._add("mouseRotate",T,["mousePitch"]),this._add("mousePitch",S,["mouseRotate"]),e.interactive&&e.dragRotate&&n.dragRotate.enable();let C=(({enable:Z,clickTolerance:B})=>{let X=new Ks({checkCorrectEvent:K=>se.mouseButton(K)===0&&!K.ctrlKey});return new _r({clickTolerance:B,move:(K,ee)=>({around:ee,panDelta:ee.sub(K)}),activateOnStart:!0,moveStateManager:X,enable:Z,assignEvents:Js})})(e),E=new Yr(e,n);n.dragPan=new sl(a,C,E),this._add("mousePan",C),this._add("touchPan",E,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&n.dragPan.enable(e.dragPan);let R=new io,V=new eo;n.touchZoomRotate=new no(a,V,R,y),this._add("touchRotate",R,["touchPan","touchZoom"]),this._add("touchZoom",V,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&n.touchZoomRotate.enable(e.touchZoomRotate);let U=n.scrollZoom=new Vi(n,()=>this._triggerRenderFrame());this._add("scrollZoom",U,["mousePan"]),e.interactive&&e.scrollZoom&&n.scrollZoom.enable(e.scrollZoom);let $=n.keyboard=new Si(n);this._add("keyboard",$),e.interactive&&e.keyboard&&n.keyboard.enable(),this._add("blockableMapEvent",new wt(n))}_add(e,n,a){this._handlers.push({handlerName:e,handler:n,allowed:a}),this._handlersById[e]=n}stop(e){if(!this._updatingCamera){for(let{handler:n}of this._handlers)n.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(let{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Ii(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,n,a){for(let o in e)if(o!==a&&(!n||n.indexOf(o)<0))return!0;return!1}_getMapTouches(e){let n=[];for(let a of e)this._el.contains(a.target)&&n.push(a);return n}mergeHandlerResult(e,n,a,o,c){if(!a)return;p.e(e,a);let m={handlerName:o,originalEvent:a.originalEvent||c};a.zoomDelta!==void 0&&(n.zoom=m),a.panDelta!==void 0&&(n.drag=m),a.pitchDelta!==void 0&&(n.pitch=m),a.bearingDelta!==void 0&&(n.rotate=m)}_applyChanges(){let e={},n={},a={};for(let[o,c,m]of this._changes)o.panDelta&&(e.panDelta=(e.panDelta||new p.P(0,0))._add(o.panDelta)),o.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+o.zoomDelta),o.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+o.bearingDelta),o.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+o.pitchDelta),o.around!==void 0&&(e.around=o.around),o.pinchAround!==void 0&&(e.pinchAround=o.pinchAround),o.noInertia&&(e.noInertia=o.noInertia),p.e(n,c),p.e(a,m);this._updateMapTransform(e,n,a),this._changes=[]}_updateMapTransform(e,n,a){let o=this._map,c=o._getTransformForUpdate(),m=o.terrain;if(!(ea(e)||m&&this._terrainMovement))return this._fireEvents(n,a,!0);let{panDelta:g,zoomDelta:y,bearingDelta:b,pitchDelta:T,around:S,pinchAround:C}=e;C!==void 0&&(S=C),o._stop(!0),S=S||o.transform.centerPoint;let E=c.pointLocation(g?S.sub(g):S);b&&(c.bearing+=b),T&&(c.pitch+=T),y&&(c.zoom+=y),m?this._terrainMovement||!n.drag&&!n.zoom?n.drag&&this._terrainMovement?c.center=c.pointLocation(c.centerPoint.sub(g)):c.setLocationAtPoint(E,S):(this._terrainMovement=!0,this._map._elevationFreeze=!0,c.setLocationAtPoint(E,S)):c.setLocationAtPoint(E,S),o._applyUpdatedTransform(c),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(n,a,!0)}_fireEvents(e,n,a){let o=Ii(this._eventsInProgress),c=Ii(e),m={};for(let S in e){let{originalEvent:C}=e[S];this._eventsInProgress[S]||(m[`${S}start`]=C),this._eventsInProgress[S]=e[S]}!o&&c&&this._fireEvent("movestart",c.originalEvent);for(let S in m)this._fireEvent(S,m[S]);c&&this._fireEvent("move",c.originalEvent);for(let S in e){let{originalEvent:C}=e[S];this._fireEvent(S,C)}let g={},y;for(let S in this._eventsInProgress){let{handlerName:C,originalEvent:E}=this._eventsInProgress[S];this._handlersById[C].isActive()||(delete this._eventsInProgress[S],y=n[C]||E,g[`${S}end`]=y)}for(let S in g)this._fireEvent(S,g[S]);let b=Ii(this._eventsInProgress),T=(o||c)&&!b;if(T&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;let S=this._map._getTransformForUpdate();S.recalculateZoom(this._map.terrain),this._map._applyUpdatedTransform(S)}if(a&&T){this._updatingCamera=!0;let S=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),C=E=>E!==0&&-this._bearingSnap{delete this._frameId,this.handleEvent(new Ie("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class ol extends p.E{constructor(e,n){super(),this._renderFrameCallback=()=>{let a=Math.min((me.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(a)),a<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=n.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new p.N(this.transform.center.lng,this.transform.center.lat)}setCenter(e,n){return this.jumpTo({center:e},n)}panBy(e,n,a){return e=p.P.convert(e).mult(-1),this.panTo(this.transform.center,p.e({offset:e},n),a)}panTo(e,n,a){return this.easeTo(p.e({center:e},n),a)}getZoom(){return this.transform.zoom}setZoom(e,n){return this.jumpTo({zoom:e},n),this}zoomTo(e,n,a){return this.easeTo(p.e({zoom:e},n),a)}zoomIn(e,n){return this.zoomTo(this.getZoom()+1,e,n),this}zoomOut(e,n){return this.zoomTo(this.getZoom()-1,e,n),this}getBearing(){return this.transform.bearing}setBearing(e,n){return this.jumpTo({bearing:e},n),this}getPadding(){return this.transform.padding}setPadding(e,n){return this.jumpTo({padding:e},n),this}rotateTo(e,n,a){return this.easeTo(p.e({bearing:e},n),a)}resetNorth(e,n){return this.rotateTo(0,p.e({duration:1e3},e),n),this}resetNorthPitch(e,n){return this.easeTo(p.e({bearing:0,pitch:0,duration:1e3},e),n),this}snapToNorth(e,n){return Math.abs(this.getBearing()){if(this._zooming&&(o.zoom=p.y.number(c,U,oe)),this._rotating&&(o.bearing=p.y.number(m,b,oe)),this._pitching&&(o.pitch=p.y.number(g,T,oe)),this._padding&&(o.interpolatePadding(y,S,oe),E=o.centerPoint.add(C)),this.terrain&&!e.freezeElevation&&this._updateElevation(oe),X)o.setLocationAtPoint(X,K);else{let he=o.zoomScale(o.zoom-c),xe=U>c?Math.min(2,B):Math.max(.5,B),Te=Math.pow(xe,1-oe),fe=o.unproject($.add(Z.mult(oe*Te)).mult(he));o.setLocationAtPoint(o.renderWorldCopies?fe.wrap():fe,E)}this._applyUpdatedTransform(o),this._fireMoveEvents(n)},oe=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n,oe)},e),this}_prepareEase(e,n,a={}){this._moving=!0,n||a.moving||this.fire(new p.k("movestart",e)),this._zooming&&!a.zooming&&this.fire(new p.k("zoomstart",e)),this._rotating&&!a.rotating&&this.fire(new p.k("rotatestart",e)),this._pitching&&!a.pitching&&this.fire(new p.k("pitchstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);let n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&n!==this._elevationTarget){let a=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(a-(n-(a*e+this._elevationStart))/(1-e)),this._elevationTarget=n}this.transform.elevation=p.y.number(this._elevationStart,this._elevationTarget,e)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){let n=e.getCameraPosition(),a=this.terrain.getElevationForLngLatZoom(n.lngLat,e.zoom);if(n.altitudethis._elevateCameraIfInsideTerrain(o)),this.transformCameraUpdate&&n.push(o=>this.transformCameraUpdate(o)),!n.length)return;let a=e.clone();for(let o of n){let c=a.clone(),{center:m,zoom:g,pitch:y,bearing:b,elevation:T}=o(c);m&&(c.center=m),g!==void 0&&(c.zoom=g),y!==void 0&&(c.pitch=y),b!==void 0&&(c.bearing=b),T!==void 0&&(c.elevation=T),a.apply(c)}this.transform.apply(a)}_fireMoveEvents(e){this.fire(new p.k("move",e)),this._zooming&&this.fire(new p.k("zoom",e)),this._rotating&&this.fire(new p.k("rotate",e)),this._pitching&&this.fire(new p.k("pitch",e))}_afterEase(e,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;let a=this._zooming,o=this._rotating,c=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,a&&this.fire(new p.k("zoomend",e)),o&&this.fire(new p.k("rotateend",e)),c&&this.fire(new p.k("pitchend",e)),this.fire(new p.k("moveend",e))}flyTo(e,n){var a;if(!e.essential&&me.prefersReducedMotion){let be=p.M(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(be,n)}this.stop(),e=p.e({offset:[0,0],speed:1.2,curve:1.42,easing:p.b9},e);let o=this._getTransformForUpdate(),c=o.zoom,m=o.bearing,g=o.pitch,y=o.padding,b="bearing"in e?this._normalizeBearing(e.bearing,m):m,T="pitch"in e?+e.pitch:g,S="padding"in e?e.padding:o.padding,C=p.P.convert(e.offset),E=o.centerPoint.add(C),R=o.pointLocation(E),{center:V,zoom:U}=o.getConstrained(p.N.convert(e.center||R),(a=e.zoom)!==null&&a!==void 0?a:c);this._normalizeCenter(V,o);let $=o.zoomScale(U-c),Z=o.project(R),B=o.project(V).sub(Z),X=e.curve,K=Math.max(o.width,o.height),ee=K/$,oe=B.mag();if("minZoom"in e){let be=p.ac(Math.min(e.minZoom,c,U),o.minZoom,o.maxZoom),Fe=K/o.zoomScale(be-c);X=Math.sqrt(Fe/oe*2)}let he=X*X;function xe(be){let Fe=(ee*ee-K*K+(be?-1:1)*he*he*oe*oe)/(2*(be?ee:K)*he*oe);return Math.log(Math.sqrt(Fe*Fe+1)-Fe)}function Te(be){return(Math.exp(be)-Math.exp(-be))/2}function fe(be){return(Math.exp(be)+Math.exp(-be))/2}let pe=xe(!1),Me=function(be){return fe(pe)/fe(pe+X*be)},Ve=function(be){return K*((fe(pe)*(Te(Fe=pe+X*be)/fe(Fe))-Te(pe))/he)/oe;var Fe},ge=(xe(!0)-pe)/X;if(Math.abs(oe)<1e-6||!isFinite(ge)){if(Math.abs(K-ee)<1e-6)return this.easeTo(e,n);let be=ee0,Me=Fe=>Math.exp(be*X*Fe)}return e.duration="duration"in e?+e.duration:1e3*ge/("screenSpeed"in e?+e.screenSpeed/X:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=m!==b,this._pitching=T!==g,this._padding=!o.isPaddingEqual(S),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(V),this._ease(be=>{let Fe=be*ge,pt=1/Me(Fe);o.zoom=be===1?U:c+o.scaleZoom(pt),this._rotating&&(o.bearing=p.y.number(m,b,be)),this._pitching&&(o.pitch=p.y.number(g,T,be)),this._padding&&(o.interpolatePadding(y,S,be),E=o.centerPoint.add(C)),this.terrain&&!e.freezeElevation&&this._updateElevation(be);let Ue=be===1?V:o.unproject(Z.add(B.mult(Ve(Fe))).mult(pt));o.setLocationAtPoint(o.renderWorldCopies?Ue.wrap():Ue,E),this._applyUpdatedTransform(o),this._fireMoveEvents(n)},()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n)},e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,n){var a;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let o=this._onEaseEnd;delete this._onEaseEnd,o.call(this,n)}return e||(a=this.handlers)===null||a===void 0||a.stop(!1),this}_ease(e,n,a){a.animate===!1||a.duration===0?(e(1),n()):(this._easeStart=me.now(),this._easeOptions=a,this._onEaseFrame=e,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,n){e=p.b3(e,-180,180);let a=Math.abs(e-n);return Math.abs(e-360-n)180?-360:a<-180?360:0}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLatZoom(p.N.convert(e),this.transform.tileZoom)-this.transform.elevation:null}}let kn={compact:!0,customAttribution:'MapLibre'};class zn{constructor(e=kn){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=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=se.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=se.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=se.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(){se.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,n){let a=this._map._getUIString(`AttributionControl.${n}`);e.title=a,e.setAttribute("aria-label",a)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(o=>typeof o!="string"?"":o)):typeof this.options.customAttribution=="string"&&e.push(this.options.customAttribution)),this._map.style.stylesheet){let o=this._map.style.stylesheet;this.styleOwner=o.owner,this.styleId=o.id}let n=this._map.style.sourceCaches;for(let o in n){let c=n[o];if(c.used||c.usedForTerrain){let m=c.getSource();m.attribution&&e.indexOf(m.attribution)<0&&e.push(m.attribution)}}e=e.filter(o=>String(o).trim()),e.sort((o,c)=>o.length-c.length),e=e.filter((o,c)=>{for(let m=c+1;m=0)return!1;return!0});let a=e.join(" | ");a!==this._attribHTML&&(this._attribHTML=a,e.length?(this._innerContainer.innerHTML=a,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class ao{constructor(e={}){this._updateCompact=()=>{let n=this._container.children;if(n.length){let 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=e}getDefaultPosition(){return"bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=se.create("div","maplibregl-ctrl");let n=se.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(){se.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Xe{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){let n=++this._id;return this._queue.push({callback:e,id:n,cancelled:!1}),n}remove(e){let n=this._currentlyRunning,a=n?this._queue.concat(n):this._queue;for(let o of a)if(o.id===e)return void(o.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");let n=this._currentlyRunning=this._queue;this._queue=[];for(let a of n)if(!a.cancelled&&(a.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var oo=p.Y([{name:"a_pos3d",type:"Int16",components:3}]);class ic extends p.E{constructor(e){super(),this.sourceCache=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,e.usedForTerrain=!0,e.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(e,n){this.sourceCache.update(e,n),this._renderableTilesKeys=[];let a={};for(let o of e.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n}))a[o.key]=!0,this._renderableTilesKeys.push(o.key),this._tiles[o.key]||(o.posMatrix=new Float64Array(16),p.aP(o.posMatrix,0,p.X,0,p.X,0,1),this._tiles[o.key]=new Pr(o,this.tileSize));for(let o in this._tiles)a[o]||delete this._tiles[o]}freeRtt(e){for(let n in this._tiles){let a=this._tiles[n];(!e||a.tileID.equals(e)||a.tileID.isChildOf(e)||e.isChildOf(a.tileID))&&(a.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(e=>this.getTileByID(e))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e){let n={};for(let a of this._renderableTilesKeys){let o=this._tiles[a].tileID;if(o.canonical.equals(e.canonical)){let c=e.clone();c.posMatrix=new Float64Array(16),p.aP(c.posMatrix,0,p.X,0,p.X,0,1),n[a]=c}else if(o.canonical.isChildOf(e.canonical)){let c=e.clone();c.posMatrix=new Float64Array(16);let m=o.canonical.z-e.canonical.z,g=o.canonical.x-(o.canonical.x>>m<>m<>m;p.aP(c.posMatrix,0,b,0,b,0,1),p.J(c.posMatrix,c.posMatrix,[-g*b,-y*b,0]),n[a]=c}else if(e.canonical.isChildOf(o.canonical)){let c=e.clone();c.posMatrix=new Float64Array(16);let m=e.canonical.z-o.canonical.z,g=e.canonical.x-(e.canonical.x>>m<>m<>m;p.aP(c.posMatrix,0,p.X,0,p.X,0,1),p.J(c.posMatrix,c.posMatrix,[g*b,y*b,0]),p.K(c.posMatrix,c.posMatrix,[1/2**m,1/2**m,0]),n[a]=c}}return n}getSourceTile(e,n){let a=this.sourceCache._source,o=e.overscaledZ-this.deltaZoom;if(o>a.maxzoom&&(o=a.maxzoom),o=a.minzoom&&(!c||!c.dem);)c=this.sourceCache.getTileByID(e.scaledTo(o--).key);return c}tilesAfterTime(e=Date.now()){return Object.values(this._tiles).filter(n=>n.timeAdded>=e)}}class lo{constructor(e,n,a){this.painter=e,this.sourceCache=new ic(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(e,n,a,o=p.X){var c;if(!(n>=0&&n=0&&ae.canonical.z&&(e.canonical.z>=o?c=e.canonical.z-o:p.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));let m=e.canonical.x-(e.canonical.x>>c<>c<>8<<4|c>>8,n[m+3]=0;let a=new p.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),o=new st(e,a,e.gl.RGBA,{premultiply:!1});return o.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=o,o}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);let n=new Uint8Array(4),a=this.painter.context,o=a.gl,c=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),m=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),g=Math.round(this.painter.height/devicePixelRatio);a.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),o.readPixels(c,g-m-1,1,1,o.RGBA,o.UNSIGNED_BYTE,n),a.bindFramebuffer.set(null);let y=n[0]+(n[2]>>4<<8),b=n[1]+((15&n[2])<<8),T=this.coordsIndex[255-n[3]],S=T&&this.sourceCache.getTileByID(T);if(!S)return null;let C=this._coordsTextureSize,E=(1<e.id!==n),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(let 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!");let e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(let e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length!e.inUse)===!1}}let En={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class ll{constructor(e,n){this.painter=e,this.terrain=n,this.pool=new rc(e.context,30,n.sourceCache.tileSize*n.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,n){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=e._order.filter(a=>!e._layers[a].isHidden(n)),this._coordsDescendingInv={};for(let a in e.sourceCaches){this._coordsDescendingInv[a]={};let o=e.sourceCaches[a].getVisibleCoordinates();for(let c of o){let m=this.terrain.sourceCache.getTerrainCoords(c);for(let g in m)this._coordsDescendingInv[a][g]||(this._coordsDescendingInv[a][g]=[]),this._coordsDescendingInv[a][g].push(m[g])}}this._coordsDescendingInvStr={};for(let a of e._order){let o=e._layers[a],c=o.source;if(En[o.type]&&!this._coordsDescendingInvStr[c]){this._coordsDescendingInvStr[c]={};for(let m in this._coordsDescendingInv[c])this._coordsDescendingInvStr[c][m]=this._coordsDescendingInv[c][m].map(g=>g.key).sort().join()}}for(let a of this._renderableTiles)for(let o in this._coordsDescendingInvStr){let c=this._coordsDescendingInvStr[o][a.tileID.key];c&&c!==a.rttCoords[o]&&(a.rtt=[])}}renderLayer(e){if(e.isHidden(this.painter.transform.zoom))return!1;let n=e.type,a=this.painter,o=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(En[n]&&(this._prevType&&En[this._prevType]||this._stacks.push([]),this._prevType=n,this._stacks[this._stacks.length-1].push(e.id),!o))return!0;if(En[this._prevType]||En[n]&&o){this._prevType=n;let c=this._stacks.length-1,m=this._stacks[c]||[];for(let g of this._renderableTiles){if(this.pool.isFull()&&(el(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(g),g.rtt[c]){let b=this.pool.getObjectForId(g.rtt[c].id);if(b.stamp===g.rtt[c].stamp){this.pool.useObject(b);continue}}let y=this.pool.getOrCreateFreeObject();this.pool.useObject(y),this.pool.stampObject(y),g.rtt[c]={id:y.id,stamp:y.stamp},a.context.bindFramebuffer.set(y.fbo.framebuffer),a.context.clear({color:p.aM.transparent,stencil:0}),a.currentStencilSource=void 0;for(let b=0;b{h.touchstart=h.dragStart,h.touchmoveWindow=h.dragMove,h.touchend=h.dragEnd},sc={showCompass:!0,showZoom:!0,visualizePitch:!1};class ac{constructor(e,n,a=!1){this.mousedown=m=>{this.startMouse(p.e({},m,{ctrlKey:!0,preventDefault:()=>m.preventDefault()}),se.mousePos(this.element,m)),se.addEventListener(window,"mousemove",this.mousemove),se.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=m=>{this.moveMouse(m,se.mousePos(this.element,m))},this.mouseup=m=>{this.mouseRotate.dragEnd(m),this.mousePitch&&this.mousePitch.dragEnd(m),this.offTemp()},this.touchstart=m=>{m.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=se.touchPos(this.element,m.targetTouches)[0],this.startTouch(m,this._startPos),se.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),se.addEventListener(window,"touchend",this.touchend))},this.touchmove=m=>{m.targetTouches.length!==1?this.reset():(this._lastPos=se.touchPos(this.element,m.targetTouches)[0],this.moveTouch(m,this._lastPos))},this.touchend=m=>{m.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),this.touchRotate.reset(),this.touchPitch&&this.touchPitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10;let o=e.dragRotate._mouseRotate.getClickTolerance(),c=e.dragRotate._mousePitch.getClickTolerance();this.element=n,this.mouseRotate=Ja({clickTolerance:o,enable:!0}),this.touchRotate=(({enable:m,clickTolerance:g,bearingDegreesPerPixelMoved:y=.8})=>{let b=new Ka;return new _r({clickTolerance:g,move:(T,S)=>({bearingDelta:(S.x-T.x)*y}),moveStateManager:b,enable:m,assignEvents:ho})})({clickTolerance:o,enable:!0}),this.map=e,a&&(this.mousePitch=Ya({clickTolerance:c,enable:!0}),this.touchPitch=(({enable:m,clickTolerance:g,pitchDegreesPerPixelMoved:y=-.5})=>{let b=new Ka;return new _r({clickTolerance:g,move:(T,S)=>({pitchDelta:(S.y-T.y)*y}),moveStateManager:b,enable:m,assignEvents:ho})})({clickTolerance:c,enable:!0})),se.addEventListener(n,"mousedown",this.mousedown),se.addEventListener(n,"touchstart",this.touchstart,{passive:!1}),se.addEventListener(n,"touchcancel",this.reset)}startMouse(e,n){this.mouseRotate.dragStart(e,n),this.mousePitch&&this.mousePitch.dragStart(e,n),se.disableDrag()}startTouch(e,n){this.touchRotate.dragStart(e,n),this.touchPitch&&this.touchPitch.dragStart(e,n),se.disableDrag()}moveMouse(e,n){let a=this.map,{bearingDelta:o}=this.mouseRotate.dragMove(e,n)||{};if(o&&a.setBearing(a.getBearing()+o),this.mousePitch){let{pitchDelta:c}=this.mousePitch.dragMove(e,n)||{};c&&a.setPitch(a.getPitch()+c)}}moveTouch(e,n){let a=this.map,{bearingDelta:o}=this.touchRotate.dragMove(e,n)||{};if(o&&a.setBearing(a.getBearing()+o),this.touchPitch){let{pitchDelta:c}=this.touchPitch.dragMove(e,n)||{};c&&a.setPitch(a.getPitch()+c)}}off(){let e=this.element;se.removeEventListener(e,"mousedown",this.mousedown),se.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),se.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),se.removeEventListener(window,"touchend",this.touchend),se.removeEventListener(e,"touchcancel",this.reset),this.offTemp()}offTemp(){se.enableDrag(),se.removeEventListener(window,"mousemove",this.mousemove),se.removeEventListener(window,"mouseup",this.mouseup),se.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),se.removeEventListener(window,"touchend",this.touchend)}}let _i;function dt(h,e,n){let a=new p.N(h.lng,h.lat);if(h=new p.N(h.lng,h.lat),e){let o=new p.N(h.lng-360,h.lat),c=new p.N(h.lng+360,h.lat),m=n.locationPoint(h).distSqr(e);n.locationPoint(o).distSqr(e)180;){let o=n.locationPoint(h);if(o.x>=0&&o.y>=0&&o.x<=n.width&&o.y<=n.height)break;h.lng>n.center.lng?h.lng-=360:h.lng+=360}return h.lng!==a.lng&&n.locationPoint(h).y>n.height/2-n.getHorizon()?h:a}let Dn={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 ta(h,e,n){let a=h.classList;for(let o in Dn)a.remove(`maplibregl-${n}-anchor-${o}`);a.add(`maplibregl-${n}-anchor-${e}`)}class ia extends p.E{constructor(e){if(super(),this._onKeyPress=n=>{let a=n.code,o=n.charCode||n.keyCode;a!=="Space"&&a!=="Enter"&&o!==32&&o!==13||this.togglePopup()},this._onMapClick=n=>{let a=n.originalEvent.target,o=this._element;this._popup&&(a===o||o.contains(a))&&this.togglePopup()},this._update=n=>{var a;if(!this._map)return;let o=this._map.loaded()&&!this._map.isMoving();(n?.type==="terrain"||n?.type==="render"&&!o)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?dt(this._lngLat,this._flatPos,this._map.transform):(a=this._lngLat)===null||a===void 0?void 0:a.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationPoint(this._lngLat)._add(this._offset));let c="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?c=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(c=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let m="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?m="rotateX(0deg)":this._pitchAlignment==="map"&&(m=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||n&&n.type!=="moveend"||(this._pos=this._pos.round()),se.setTransform(this._element,`${Dn[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${m} ${c}`),me.frameAsync(new AbortController).then(()=>{this._updateOpacity(n&&n.type==="moveend")}).catch(()=>{})},this._onMove=n=>{if(!this._isDragging){let 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 p.k("dragstart"))),this.fire(new p.k("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 p.k("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=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&e.pitchAlignment!=="auto"?e.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(e?.opacity,e?.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=p.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=se.create("div");let n=se.createNS("http://www.w3.org/2000/svg","svg"),a=41,o=27;n.setAttributeNS(null,"display","block"),n.setAttributeNS(null,"height",`${a}px`),n.setAttributeNS(null,"width",`${o}px`),n.setAttributeNS(null,"viewBox",`0 0 ${o} ${a}`);let c=se.createNS("http://www.w3.org/2000/svg","g");c.setAttributeNS(null,"stroke","none"),c.setAttributeNS(null,"stroke-width","1"),c.setAttributeNS(null,"fill","none"),c.setAttributeNS(null,"fill-rule","evenodd");let m=se.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"fill-rule","nonzero");let g=se.createNS("http://www.w3.org/2000/svg","g");g.setAttributeNS(null,"transform","translate(3.0, 29.0)"),g.setAttributeNS(null,"fill","#000000");let y=[{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(let $ of y){let Z=se.createNS("http://www.w3.org/2000/svg","ellipse");Z.setAttributeNS(null,"opacity","0.04"),Z.setAttributeNS(null,"cx","10.5"),Z.setAttributeNS(null,"cy","5.80029008"),Z.setAttributeNS(null,"rx",$.rx),Z.setAttributeNS(null,"ry",$.ry),g.appendChild(Z)}let b=se.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"fill",this._color);let T=se.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);let S=se.createNS("http://www.w3.org/2000/svg","g");S.setAttributeNS(null,"opacity","0.25"),S.setAttributeNS(null,"fill","#000000");let C=se.createNS("http://www.w3.org/2000/svg","path");C.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),S.appendChild(C);let E=se.createNS("http://www.w3.org/2000/svg","g");E.setAttributeNS(null,"transform","translate(6.0, 7.0)"),E.setAttributeNS(null,"fill","#FFFFFF");let R=se.createNS("http://www.w3.org/2000/svg","g");R.setAttributeNS(null,"transform","translate(8.0, 8.0)");let V=se.createNS("http://www.w3.org/2000/svg","circle");V.setAttributeNS(null,"fill","#000000"),V.setAttributeNS(null,"opacity","0.25"),V.setAttributeNS(null,"cx","5.5"),V.setAttributeNS(null,"cy","5.5"),V.setAttributeNS(null,"r","5.4999962");let U=se.createNS("http://www.w3.org/2000/svg","circle");U.setAttributeNS(null,"fill","#FFFFFF"),U.setAttributeNS(null,"cx","5.5"),U.setAttributeNS(null,"cy","5.5"),U.setAttributeNS(null,"r","5.4999962"),R.appendChild(V),R.appendChild(U),m.appendChild(g),m.appendChild(b),m.appendChild(S),m.appendChild(E),m.appendChild(R),n.appendChild(m),n.setAttributeNS(null,"height",a*this._scale+"px"),n.setAttributeNS(null,"width",o*this._scale+"px"),this._element.appendChild(n),this._offset=p.P.convert(e&&e.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",n=>{n.preventDefault()}),this._element.addEventListener("mousedown",n=>{n.preventDefault()}),ta(this._element,this._anchor,"marker"),e&&e.className)for(let n of e.className.split(" "))this._element.classList.add(n);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",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("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),se.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=p.N.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){let o=Math.abs(13.5)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[o,-1*(38.1-13.5+o)],"bottom-right":[-o,-1*(38.1-13.5+o)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){let e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var n,a;if(!(!((n=this._map)===null||n===void 0)&&n.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}let o=this._map,c=o.terrain.depthAtPoint(this._pos),m=o.terrain.getElevationForLngLatZoom(this._lngLat,o.transform.tileZoom);if(o.transform.lngLatToCameraDepth(this._lngLat,m)-c<.006)return void(this._element.style.opacity=this._opacity);let g=-this._offset.y/o.transform._pixelPerMeter,y=Math.sin(o.getPitch()*Math.PI/180)*g,b=o.terrain.depthAtPoint(new p.P(this._pos.x,this._pos.y-this._offset.y)),T=o.transform.lngLatToCameraDepth(this._lngLat,m+y)-b>.006;!((a=this._popup)===null||a===void 0)&&a.isOpen()&&T&&this._popup.remove(),this._element.style.opacity=T?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=p.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&e!=="auto"?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,n){return e===void 0&&n===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),e!==void 0&&(this._opacity=e),n!==void 0&&(this._opacityWhenCovered=n),this._map&&this._updateOpacity(!0),this}}let hl={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0},fs=0,ms=!1,sr={maxWidth:100,unit:"metric"};function _s(h,e,n){let a=n&&n.maxWidth||100,o=h._container.clientHeight/2,c=h.unproject([0,o]),m=h.unproject([a,o]),g=c.distanceTo(m);if(n&&n.unit==="imperial"){let y=3.2808*g;y>5280?Ae(e,a,y/5280,h._getUIString("ScaleControl.Miles")):Ae(e,a,y,h._getUIString("ScaleControl.Feet"))}else n&&n.unit==="nautical"?Ae(e,a,g/1852,h._getUIString("ScaleControl.NauticalMiles")):g>=1e3?Ae(e,a,g/1e3,h._getUIString("ScaleControl.Kilometers")):Ae(e,a,g,h._getUIString("ScaleControl.Meters"))}function Ae(h,e,n,a){let o=function(c){let m=Math.pow(10,`${Math.floor(c)}`.length-1),g=c/m;return g=g>=10?10:g>=5?5:g>=3?3:g>=2?2:g>=1?1:function(y){let b=Math.pow(10,Math.ceil(-Math.log(y)/Math.LN10));return Math.round(y*b)/b}(g),m*g}(n);h.style.width=e*(o/n)+"px",h.innerHTML=`${o} ${a}`}let Re={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},ra=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function na(h){if(h){if(typeof h=="number"){let e=Math.round(Math.abs(h)/Math.SQRT2);return{center:new p.P(0,0),top:new p.P(0,h),"top-left":new p.P(e,e),"top-right":new p.P(-e,e),bottom:new p.P(0,-h),"bottom-left":new p.P(e,-e),"bottom-right":new p.P(-e,-e),left:new p.P(h,0),right:new p.P(-h,0)}}if(h instanceof p.P||Array.isArray(h)){let e=p.P.convert(h);return{center:e,top:e,"top-left":e,"top-right":e,bottom:e,"bottom-left":e,"bottom-right":e,left:e,right:e}}return{center:p.P.convert(h.center||[0,0]),top:p.P.convert(h.top||[0,0]),"top-left":p.P.convert(h["top-left"]||[0,0]),"top-right":p.P.convert(h["top-right"]||[0,0]),bottom:p.P.convert(h.bottom||[0,0]),"bottom-left":p.P.convert(h["bottom-left"]||[0,0]),"bottom-right":p.P.convert(h["bottom-right"]||[0,0]),left:p.P.convert(h.left||[0,0]),right:p.P.convert(h.right||[0,0])}}return na(new p.P(0,0))}let uo=ki;L.AJAXError=p.bh,L.Evented=p.E,L.LngLat=p.N,L.MercatorCoordinate=p.Z,L.Point=p.P,L.addProtocol=p.bi,L.config=p.a,L.removeProtocol=p.bj,L.AttributionControl=zn,L.BoxZoomHandler=mi,L.CanvasSource=bi,L.CooperativeGesturesHandler=Cn,L.DoubleClickZoomHandler=Qr,L.DragPanHandler=sl,L.DragRotateHandler=al,L.EdgeInsets=In,L.FullscreenControl=class extends p.E{constructor(h={}){super(),this._onFullscreenChange=()=>{var e;let n=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((e=n?.shadowRoot)===null||e===void 0)&&e.fullscreenElement;)n=n.shadowRoot.fullscreenElement;n===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,h&&h.container&&(h.container instanceof HTMLElement?this._container=h.container:p.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(h){return this._map=h,this._container||(this._container=this._map.getContainer()),this._controlContainer=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){se.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){let h=this._fullscreenButton=se.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);se.create("span","maplibregl-ctrl-icon",h).setAttribute("aria-hidden","true"),h.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){let h=this._getTitle();this._fullscreenButton.setAttribute("aria-label",h),this._fullscreenButton.title=h}_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 p.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new p.k("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()}},L.GeoJSONSource=Kn,L.GeolocateControl=class extends p.E{constructor(h){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new p.k("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(e),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new p.k("geolocate",e)),this._finish()}},this._updateCamera=e=>{let n=new p.N(e.coords.longitude,e.coords.latitude),a=e.coords.accuracy,o=this._map.getBearing(),c=p.e({bearing:o},this.options.fitBoundsOptions),m=ie.fromLngLat(n,a);this._map.fitBounds(m,c,{geolocateSource:!0})},this._updateMarker=e=>{if(e){let n=new p.N(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},this._onError=e=>{if(this._map){if(this.options.trackUserLocation)if(e.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;let n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(e.code===3&&ms)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new p.k("error",e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=se.create("button","maplibregl-ctrl-geolocate",this._container),se.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(e===!1){p.w("Geolocation support is not available so the GeolocateControl will be disabled.");let n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}else{let 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=se.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new ia({element:this._dotElement}),this._circleElement=se.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new ia({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",n=>{n.geolocateSource||this._watchState!=="ACTIVE_LOCK"||n.originalEvent&&n.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new p.k("trackuserlocationend")),this.fire(new p.k("userlocationlostfocus")))})}},this.options=p.e({},hl,h)}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return p._(this,arguments,void 0,function*(e=!1){if(_i!==void 0&&!e)return _i;if(window.navigator.permissions===void 0)return _i=!!window.navigator.geolocation,_i;try{_i=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{_i=!!window.navigator.geolocation}return _i})}().then(e=>this._finishSetupUI(e)),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(),se.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,fs=0,ms=!1}_isOutOfMapMaxBounds(h){let e=this._map.getMaxBounds(),n=h.coords;return e&&(n.longitudee.getEast()||n.latitudee.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":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){let h=this._map.getBounds(),e=h.getSouthEast(),n=h.getNorthEast(),a=e.distanceTo(n),o=Math.ceil(this._accuracy/(a/this._map._container.clientHeight)*2);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`}trigger(){if(!this._setup)return p.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 p.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":fs--,ms=!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 p.k("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 p.k("trackuserlocationstart")),this.fire(new p.k("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 h;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),fs++,fs>1?(h={maximumAge:6e5,timeout:0},ms=!0):(h=this.options.positionOptions,ms=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,h)}}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)}},L.Hash=Gs,L.ImageSource=pr,L.KeyboardHandler=Si,L.LngLatBounds=ie,L.LogoControl=ao,L.Map=class extends ol{constructor(h){p.bf.mark(p.bg.create);let e=Object.assign(Object.assign({},nc),h);if(e.minZoom!=null&&e.maxZoom!=null&&e.minZoom>e.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(e.minPitch!=null&&e.maxPitch!=null&&e.minPitch>e.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(e.minPitch!=null&&e.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(e.maxPitch!=null&&e.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new Pn(e.minZoom,e.maxZoom,e.minPitch,e.maxPitch,e.renderWorldCopies),{bearingSnap:e.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Xe,this._controls=[],this._mapId=p.a4(),this._contextLost=n=>{n.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new p.k("webglcontextlost",{originalEvent:n}))},this._contextRestored=n=>{this._setupPainter(),this.resize(),this._update(),this.fire(new p.k("webglcontextrestored",{originalEvent:n}))},this._onMapScroll=n=>{if(n.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=e.interactive,this._maxTileCacheSize=e.maxTileCacheSize,this._maxTileCacheZoomLevels=e.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat===!0,this._preserveDrawingBuffer=e.preserveDrawingBuffer===!0,this._antialias=e.antialias===!0,this._trackResize=e.trackResize===!0,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles===!0,this._fadeDuration=e.fadeDuration,this._crossSourceCollisions=e.crossSourceCollisions===!0,this._collectResourceTiming=e.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},co),e.locale),this._clickTolerance=e.clickTolerance,this._overridePixelRatio=e.pixelRatio,this._maxCanvasSize=e.maxCanvasSize,this.transformCameraUpdate=e.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=e.cancelPendingTileRequestsWhileZooming===!0,this._imageQueueHandle=hi.addThrottleControl(()=>this.isMoving()),this._requestManager=new wa(e.transformRequest),typeof e.container=="string"){if(this._container=document.getElementById(e.container),!this._container)throw new Error(`Container '${e.container}' not found.`)}else{if(!(e.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}if(e.maxBounds&&this.setMaxBounds(e.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)).on("moveend",()=>this._update(!1)).on("zoom",()=>this._update(!0)).on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}).once("idle",()=>{this._idleTriggered=!0}),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let n=!1,a=cs(o=>{this._trackResize&&!this._removed&&(this.resize(o),this.redraw())},50);this._resizeObserver=new ResizeObserver(o=>{n?a(o):n=!0}),this._resizeObserver.observe(this._container)}this.handlers=new so(this,e),this._hash=e.hash&&new Gs(typeof e.hash=="string"&&e.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch}),e.bounds&&(this.resize(),this.fitBounds(e.bounds,p.e({},e.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=e.localIdeographFontFamily,this._validateStyle=e.validateStyle,e.style&&this.setStyle(e.style,{localIdeographFontFamily:e.localIdeographFontFamily}),e.attributionControl&&this.addControl(new zn(typeof e.attributionControl=="boolean"?void 0:e.attributionControl)),e.maplibreLogo&&this.addControl(new ao,e.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",n=>{this._update(n.dataType==="style"),this.fire(new p.k(`${n.dataType}data`,n))}),this.on("dataloading",n=>{this.fire(new p.k(`${n.dataType}dataloading`,n))}),this.on("dataabort",n=>{this.fire(new p.k("sourcedataabort",n))})}_getMapId(){return this._mapId}addControl(h,e){if(e===void 0&&(e=h.getDefaultPosition?h.getDefaultPosition():"top-right"),!h||!h.onAdd)return this.fire(new p.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let n=h.onAdd(this);this._controls.push(h);let a=this._controlPositions[e];return e.indexOf("bottom")!==-1?a.insertBefore(n,a.firstChild):a.appendChild(n),this}removeControl(h){if(!h||!h.onRemove)return this.fire(new p.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));let e=this._controls.indexOf(h);return e>-1&&this._controls.splice(e,1),h.onRemove(this),this}hasControl(h){return this._controls.indexOf(h)>-1}calculateCameraOptionsFromTo(h,e,n,a){return a==null&&this.terrain&&(a=this.terrain.getElevationForLngLatZoom(n,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(h,e,n,a)}resize(h){var e;let n=this._containerDimensions(),a=n[0],o=n[1],c=this._getClampedPixelRatio(a,o);if(this._resizeCanvas(a,o,c),this.painter.resize(a,o,c),this.painter.overLimit()){let g=this.painter.context.gl;this._maxCanvasSize=[g.drawingBufferWidth,g.drawingBufferHeight];let y=this._getClampedPixelRatio(a,o);this._resizeCanvas(a,o,y),this.painter.resize(a,o,y)}this.transform.resize(a,o),(e=this._requestedCameraState)===null||e===void 0||e.resize(a,o);let m=!this._moving;return m&&(this.stop(),this.fire(new p.k("movestart",h)).fire(new p.k("move",h))),this.fire(new p.k("resize",h)),m&&this.fire(new p.k("moveend",h)),this}_getClampedPixelRatio(h,e){let{0:n,1:a}=this._maxCanvasSize,o=this.getPixelRatio(),c=h*o,m=e*o;return Math.min(c>n?n/c:1,m>a?a/m:1)*o}getPixelRatio(){var h;return(h=this._overridePixelRatio)!==null&&h!==void 0?h:devicePixelRatio}setPixelRatio(h){this._overridePixelRatio=h,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(h){return this.transform.setMaxBounds(ie.convert(h)),this._update()}setMinZoom(h){if((h=h??-2)>=-2&&h<=this.transform.maxZoom)return this.transform.minZoom=h,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=h,this._update(),this.getZoom()>h&&this.setZoom(h),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(h){if((h=h??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(h>=0&&h<=this.transform.maxPitch)return this.transform.minPitch=h,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(h>=this.transform.minPitch)return this.transform.maxPitch=h,this._update(),this.getPitch()>h&&this.setPitch(h),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(h){return this.transform.renderWorldCopies=h,this._update()}project(h){return this.transform.locationPoint(p.N.convert(h),this.style&&this.terrain)}unproject(h){return this.transform.pointLocation(p.P.convert(h),this.terrain)}isMoving(){var h;return this._moving||((h=this.handlers)===null||h===void 0?void 0:h.isMoving())}isZooming(){var h;return this._zooming||((h=this.handlers)===null||h===void 0?void 0:h.isZooming())}isRotating(){var h;return this._rotating||((h=this.handlers)===null||h===void 0?void 0:h.isRotating())}_createDelegatedListener(h,e,n){if(h==="mouseenter"||h==="mouseover"){let a=!1;return{layers:e,listener:n,delegates:{mousemove:c=>{let m=e.filter(y=>this.getLayer(y)),g=m.length!==0?this.queryRenderedFeatures(c.point,{layers:m}):[];g.length?a||(a=!0,n.call(this,new Ot(h,this,c.originalEvent,{features:g}))):a=!1},mouseout:()=>{a=!1}}}}if(h==="mouseleave"||h==="mouseout"){let a=!1;return{layers:e,listener:n,delegates:{mousemove:m=>{let g=e.filter(y=>this.getLayer(y));(g.length!==0?this.queryRenderedFeatures(m.point,{layers:g}):[]).length?a=!0:a&&(a=!1,n.call(this,new Ot(h,this,m.originalEvent)))},mouseout:m=>{a&&(a=!1,n.call(this,new Ot(h,this,m.originalEvent)))}}}}{let a=o=>{let c=e.filter(g=>this.getLayer(g)),m=c.length!==0?this.queryRenderedFeatures(o.point,{layers:c}):[];m.length&&(o.features=m,n.call(this,o),delete o.features)};return{layers:e,listener:n,delegates:{[h]:a}}}}_saveDelegatedListener(h,e){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[h]=this._delegatedListeners[h]||[],this._delegatedListeners[h].push(e)}_removeDelegatedListener(h,e,n){if(!this._delegatedListeners||!this._delegatedListeners[h])return;let a=this._delegatedListeners[h];for(let o=0;oe.includes(m))){for(let m in c.delegates)this.off(m,c.delegates[m]);return void a.splice(o,1)}}}on(h,e,n){if(n===void 0)return super.on(h,e);let a=this._createDelegatedListener(h,typeof e=="string"?[e]:e,n);this._saveDelegatedListener(h,a);for(let o in a.delegates)this.on(o,a.delegates[o]);return this}once(h,e,n){if(n===void 0)return super.once(h,e);let a=typeof e=="string"?[e]:e,o=this._createDelegatedListener(h,a,n);for(let c in o.delegates){let m=o.delegates[c];o.delegates[c]=(...g)=>{this._removeDelegatedListener(h,a,n),m(...g)}}this._saveDelegatedListener(h,o);for(let c in o.delegates)this.once(c,o.delegates[c]);return this}off(h,e,n){return n===void 0?super.off(h,e):(this._removeDelegatedListener(h,typeof e=="string"?[e]:e,n),this)}queryRenderedFeatures(h,e){if(!this.style)return[];let n,a=h instanceof p.P||Array.isArray(h),o=a?h:[[0,0],[this.transform.width,this.transform.height]];if(e=e||(a?{}:h)||{},o instanceof p.P||typeof o[0]=="number")n=[p.P.convert(o)];else{let c=p.P.convert(o[0]),m=p.P.convert(o[1]);n=[c,new p.P(m.x,c.y),m,new p.P(c.x,m.y),c]}return this.style.queryRenderedFeatures(n,e,this.transform)}querySourceFeatures(h,e){return this.style.querySourceFeatures(h,e)}setStyle(h,e){return(e=p.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},e)).diff!==!1&&e.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&h?(this._diffStyle(h,e),this):(this._localIdeographFontFamily=e.localIdeographFontFamily,this._updateStyle(h,e))}setTransformRequest(h){return this._requestManager.setTransformRequest(h),this}_getUIString(h){let e=this._locale[h];if(e==null)throw new Error(`Missing UI string '${h}'`);return e}_updateStyle(h,e){if(e.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(h,e));let n=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!h)),h?(this.style=new Cs(this,e||{}),this.style.setEventedParent(this,{style:this.style}),typeof h=="string"?this.style.loadURL(h,e,n):this.style.loadJSON(h,e,n),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Cs(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(h,e){if(typeof h=="string"){let n=this._requestManager.transformRequest(h,"Style");p.h(n,new AbortController).then(a=>{this._updateDiff(a.data,e)}).catch(a=>{a&&this.fire(new p.j(a))})}else typeof h=="object"&&this._updateDiff(h,e)}_updateDiff(h,e){try{this.style.setState(h,e)&&this._update(!0)}catch(n){p.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(h,e)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():p.w("There is no style added to the map.")}addSource(h,e){return this._lazyInitEmptyStyle(),this.style.addSource(h,e),this._update(!0)}isSourceLoaded(h){let e=this.style&&this.style.sourceCaches[h];if(e!==void 0)return e.loaded();this.fire(new p.j(new Error(`There is no source with ID '${h}'`)))}setTerrain(h){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),h){let e=this.style.sourceCaches[h.source];if(!e)throw new Error(`cannot load terrain, because there exists no source with ID: ${h.source}`);this.terrain===null&&e.reload();for(let n in this.style._layers){let a=this.style._layers[n];a.type==="hillshade"&&a.source===h.source&&p.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.")}this.terrain=new lo(this.painter,e,h),this.painter.renderToTexture=new ll(this.painter,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._terrainDataCallback=n=>{n.dataType==="style"?this.terrain.sourceCache.freeRtt():n.dataType==="source"&&n.tile&&(n.sourceId!==h.source||this._elevationFreeze||(this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.terrain.sourceCache.freeRtt(n.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.minElevationForCurrentTile=0,this.transform.elevation=0;return this.fire(new p.k("terrain",{terrain:h})),this}getTerrain(){var h,e;return(e=(h=this.terrain)===null||h===void 0?void 0:h.options)!==null&&e!==void 0?e:null}areTilesLoaded(){let h=this.style&&this.style.sourceCaches;for(let e in h){let n=h[e]._tiles;for(let a in n){let o=n[a];if(o.state!=="loaded"&&o.state!=="errored")return!1}}return!0}removeSource(h){return this.style.removeSource(h),this._update(!0)}getSource(h){return this.style.getSource(h)}addImage(h,e,n={}){let{pixelRatio:a=1,sdf:o=!1,stretchX:c,stretchY:m,content:g,textFitWidth:y,textFitHeight:b}=n;if(this._lazyInitEmptyStyle(),!(e instanceof HTMLImageElement||p.b(e))){if(e.width===void 0||e.height===void 0)return this.fire(new p.j(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`")));{let{width:T,height:S,data:C}=e,E=e;return this.style.addImage(h,{data:new p.R({width:T,height:S},new Uint8Array(C)),pixelRatio:a,stretchX:c,stretchY:m,content:g,textFitWidth:y,textFitHeight:b,sdf:o,version:0,userImage:E}),E.onAdd&&E.onAdd(this,h),this}}{let{width:T,height:S,data:C}=me.getImageData(e);this.style.addImage(h,{data:new p.R({width:T,height:S},C),pixelRatio:a,stretchX:c,stretchY:m,content:g,textFitWidth:y,textFitHeight:b,sdf:o,version:0})}}updateImage(h,e){let n=this.style.getImage(h);if(!n)return this.fire(new p.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let a=e instanceof HTMLImageElement||p.b(e)?me.getImageData(e):e,{width:o,height:c,data:m}=a;if(o===void 0||c===void 0)return this.fire(new p.j(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(o!==n.data.width||c!==n.data.height)return this.fire(new p.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));let g=!(e instanceof HTMLImageElement||p.b(e));return n.data.replace(m,g),this.style.updateImage(h,n),this}getImage(h){return this.style.getImage(h)}hasImage(h){return h?!!this.style.getImage(h):(this.fire(new p.j(new Error("Missing required image id"))),!1)}removeImage(h){this.style.removeImage(h)}loadImage(h){return hi.getImage(this._requestManager.transformRequest(h,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(h,e){return this._lazyInitEmptyStyle(),this.style.addLayer(h,e),this._update(!0)}moveLayer(h,e){return this.style.moveLayer(h,e),this._update(!0)}removeLayer(h){return this.style.removeLayer(h),this._update(!0)}getLayer(h){return this.style.getLayer(h)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(h,e,n){return this.style.setLayerZoomRange(h,e,n),this._update(!0)}setFilter(h,e,n={}){return this.style.setFilter(h,e,n),this._update(!0)}getFilter(h){return this.style.getFilter(h)}setPaintProperty(h,e,n,a={}){return this.style.setPaintProperty(h,e,n,a),this._update(!0)}getPaintProperty(h,e){return this.style.getPaintProperty(h,e)}setLayoutProperty(h,e,n,a={}){return this.style.setLayoutProperty(h,e,n,a),this._update(!0)}getLayoutProperty(h,e){return this.style.getLayoutProperty(h,e)}setGlyphs(h,e={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(h,e),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(h,e,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(h,e,n,a=>{a||this._update(!0)}),this}removeSprite(h){return this._lazyInitEmptyStyle(),this.style.removeSprite(h),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(h,e={}){return this._lazyInitEmptyStyle(),this.style.setSprite(h,e,n=>{n||this._update(!0)}),this}setLight(h,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(h,e),this._update(!0)}getLight(){return this.style.getLight()}setSky(h){return this._lazyInitEmptyStyle(),this.style.setSky(h),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(h,e){return this.style.setFeatureState(h,e),this._update()}removeFeatureState(h,e){return this.style.removeFeatureState(h,e),this._update()}getFeatureState(h){return this.style.getFeatureState(h)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let h=0,e=0;return this._container&&(h=this._container.clientWidth||400,e=this._container.clientHeight||300),[h,e]}_setupContainer(){let h=this._container;h.classList.add("maplibregl-map");let e=this._canvasContainer=se.create("div","maplibregl-canvas-container",h);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=se.create("canvas","maplibregl-canvas",e),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");let n=this._containerDimensions(),a=this._getClampedPixelRatio(n[0],n[1]);this._resizeCanvas(n[0],n[1],a);let o=this._controlContainer=se.create("div","maplibregl-control-container",h),c=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(m=>{c[m]=se.create("div",`maplibregl-ctrl-${m} `,o)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(h,e,n){this._canvas.width=Math.floor(n*h),this._canvas.height=Math.floor(n*e),this._canvas.style.width=`${h}px`,this._canvas.style.height=`${e}px`}_setupPainter(){let h={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1},e=null;this._canvas.addEventListener("webglcontextcreationerror",a=>{e={requestedAttributes:h},a&&(e.statusMessage=a.statusMessage,e.type=a.type)},{once:!0});let n=this._canvas.getContext("webgl2",h)||this._canvas.getContext("webgl",h);if(!n){let a="Failed to initialize WebGL";throw e?(e.message=a,new Error(JSON.stringify(e))):new Error(a)}this.painter=new Zs(n,this.transform),Fr.testSupport(n)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(h){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||h,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(h){return this._update(),this._renderTaskQueue.add(h)}_cancelRenderFrame(h){this._renderTaskQueue.remove(h)}_render(h){let e=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(h),this._removed)return;let n=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let o=this.transform.zoom,c=me.now();this.style.zoomHistory.update(o,c);let m=new p.z(o,{now:c,fadeDuration:e,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),g=m.crossFadingFactor();g===1&&g===this._crossFadingFactor||(n=!0,this._crossFadingFactor=g),this.style.update(m)}this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._elevationFreeze||(this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.minElevationForCurrentTile=0,this.transform.elevation=0),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,e,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:e,showPadding:this.showPadding}),this.fire(new p.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,p.bf.mark(p.bg.load),this.fire(new p.k("load"))),this.style&&(this.style.hasTransitions()||n)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let a=this._sourcesDirty||this._styleDirty||this._placementDirty;return a||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new p.k("idle")),!this._loaded||this._fullyLoaded||a||(this._fullyLoaded=!0,p.bf.mark(p.bg.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var h;this._hash&&this._hash.remove();for(let 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),hi.removeThrottleControl(this._imageQueueHandle),(h=this._resizeObserver)===null||h===void 0||h.disconnect();let e=this.painter.context.gl.getExtension("WEBGL_lose_context");e?.loseContext&&e.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),se.remove(this._canvasContainer),se.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),p.bf.clearMetrics(),this._removed=!0,this.fire(new p.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,me.frameAsync(this._frameRequest).then(h=>{p.bf.frame(h),this._frameRequest=null,this._render(h)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(h){this._showTileBoundaries!==h&&(this._showTileBoundaries=h,this._update())}get showPadding(){return!!this._showPadding}set showPadding(h){this._showPadding!==h&&(this._showPadding=h,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(h){this._showCollisionBoxes!==h&&(this._showCollisionBoxes=h,h?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(h){this._showOverdrawInspector!==h&&(this._showOverdrawInspector=h,this._update())}get repaint(){return!!this._repaint}set repaint(h){this._repaint!==h&&(this._repaint=h,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(h){this._vertices=h,this._update()}get version(){return cl}getCameraTargetElevation(){return this.transform.elevation}},L.MapMouseEvent=Ot,L.MapTouchEvent=Jr,L.MapWheelEvent=il,L.Marker=ia,L.NavigationControl=class{constructor(h){this._updateZoomButtons=()=>{let e=this._map.getZoom(),n=e===this._map.getMaxZoom(),a=e===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=()=>{let e=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=e},this._setButtonTitle=(e,n)=>{let a=this._map._getUIString(`NavigationControl.${n}`);e.title=a,e.setAttribute("aria-label",a)},this.options=p.e({},sc,h),this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",e=>this._map.zoomIn({},{originalEvent:e})),se.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",e=>this._map.zoomOut({},{originalEvent:e})),se.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})}),this._compassIcon=se.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(h){return this._map=h,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._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new ac(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){se.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._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(h,e){let n=se.create("button",h,this._container);return n.type="button",n.addEventListener("click",e),n}},L.Popup=class extends p.E{constructor(h){super(),this.remove=()=>(this._content&&se.remove(this._content),this._container&&(se.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 p.k("close"))),this),this._onMouseUp=e=>{this._update(e.point)},this._onMouseMove=e=>{this._update(e.point)},this._onDrag=e=>{this._update(e.point)},this._update=e=>{var n;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=se.create("div","maplibregl-popup",this._map.getContainer()),this._tip=se.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(let g of this.options.className.split(" "))this._container.classList.add(g);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=this._map.transform.renderWorldCopies&&!this._trackPointer?dt(this._lngLat,this._flatPos,this._map.transform):(n=this._lngLat)===null||n===void 0?void 0:n.wrap(),this._trackPointer&&!e)return;let a=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationPoint(this._lngLat));let o=this.options.anchor,c=na(this.options.offset);if(!o){let g=this._container.offsetWidth,y=this._container.offsetHeight,b;b=a.y+c.bottom.ythis._map.transform.height-y?["bottom"]:[],a.xthis._map.transform.width-g/2&&b.push("right"),o=b.length===0?"bottom":b.join("-")}let m=a.add(c[o]);this.options.subpixelPositioning||(m=m.round()),se.setTransform(this._container,`${Dn[o]} translate(${m.x}px,${m.y}px)`),ta(this._container,o,"popup")},this._onClose=()=>{this.remove()},this.options=p.e(Object.create(Re),h)}addTo(h){return this._map&&this.remove(),this._map=h,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 p.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(h){return this._lngLat=p.N.convert(h),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(h){return this.setDOMContent(document.createTextNode(h))}setHTML(h){let e=document.createDocumentFragment(),n=document.createElement("body"),a;for(n.innerHTML=h;a=n.firstChild,a;)e.appendChild(a);return this.setDOMContent(e)}getMaxWidth(){var h;return(h=this._container)===null||h===void 0?void 0:h.style.maxWidth}setMaxWidth(h){return this.options.maxWidth=h,this._update(),this}setDOMContent(h){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=se.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(h),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(h){return this._container&&this._container.classList.add(h),this}removeClassName(h){return this._container&&this._container.classList.remove(h),this}setOffset(h){return this.options.offset=h,this._update(),this}toggleClassName(h){if(this._container)return this._container.classList.toggle(h)}setSubpixelPositioning(h){this.options.subpixelPositioning=h}_createCloseButton(){this.options.closeButton&&(this._closeButton=se.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let h=this._container.querySelector(ra);h&&h.focus()}},L.RasterDEMTileSource=yt,L.RasterTileSource=et,L.ScaleControl=class{constructor(h){this._onMove=()=>{_s(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,_s(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},sr),h)}getDefaultPosition(){return"bottom-left"}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-scale",h.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){se.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},L.ScrollZoomHandler=Vi,L.Style=Cs,L.TerrainControl=class{constructor(h){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=h}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=se.create("button","maplibregl-ctrl-terrain",this._container),se.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(){se.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},L.TwoFingersTouchPitchHandler=Mn,L.TwoFingersTouchRotateHandler=io,L.TwoFingersTouchZoomHandler=eo,L.TwoFingersTouchZoomRotateHandler=no,L.VectorTileSource=Wn,L.VideoSource=un,L.addSourceType=(h,e)=>p._(void 0,void 0,void 0,function*(){if(Yn(h))throw new Error(`A source type called "${h}" already exists.`);((n,a)=>{Jn[n]=a})(h,e)}),L.clearPrewarmedResources=function(){let h=ui;h&&(h.isPreloaded()&&h.numActive()===1?(h.release(wr),ui=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()"))},L.getMaxParallelImageRequests=function(){return p.a.MAX_PARALLEL_IMAGE_REQUESTS},L.getRTLTextPluginStatus=function(){return er().getRTLTextPluginStatus()},L.getVersion=function(){return uo},L.getWorkerCount=function(){return Yi.workerCount},L.getWorkerUrl=function(){return p.a.WORKER_URL},L.importScriptInWorkers=function(h){return Xn().broadcast("IS",h)},L.prewarm=function(){Vr().acquire(wr)},L.setMaxParallelImageRequests=function(h){p.a.MAX_PARALLEL_IMAGE_REQUESTS=h},L.setRTLTextPlugin=function(h,e){return er().setRTLTextPlugin(h,e)},L.setWorkerCount=function(h){Yi.workerCount=h},L.setWorkerUrl=function(h){p.a.WORKER_URL=h}});var Bu=an;return Bu})});export default kp(); /*! Bundled license information: maplibre-gl/dist/maplibre-gl.js: (** * MapLibre GL JS * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v4.7.1/LICENSE.txt *) */